Skip to content

BlockSuite API Documentation / @blocksuite/blocks / ElementModel

Class: abstract ElementModel<Props>

Extended by

Type parameters

Props extends BaseProps = BaseProps

Implements

  • IEdgelessElement

Constructors

new ElementModel(options)

new ElementModel<Props>(options): ElementModel<Props>

Parameters

options

options.model: SurfaceBlockModel

options.onChange

options.stashedStore: Map<unknown, unknown>

options.yMap: Map<unknown>

Returns

ElementModel<Props>

Source

packages/blocks/src/surface-block/element-model/base.ts:113

Properties

_disposable

protected _disposable: DisposableGroup

Source

packages/blocks/src/surface-block/element-model/base.ts:72


_lastXYWH

private _lastXYWH: `[${number},${number},${number},${number}]` = '[0,0,0,0]'

Source

packages/blocks/src/surface-block/element-model/base.ts:139


_local

protected _local: Map<string | symbol, unknown>

Source

packages/blocks/src/surface-block/element-model/base.ts:67


_onChange

protected _onChange: (payload) => void

Parameters

payload

payload.oldValues: Record<string, unknown>

payload.props: Record<string, unknown>

Returns

void

Source

packages/blocks/src/surface-block/element-model/base.ts:68


_preserved

protected _preserved: Map<string, unknown>

When the ymap is not connected to the doc, its value cannot be read. But we need to use those value during the creation, so the yfied decorated field's value will be stored in this map too during the creation.

After the ymap is connected to the doc, this map will be cleared.

Source

packages/blocks/src/surface-block/element-model/base.ts:65


_stashed

protected _stashed: Map<string | keyof Props, unknown>

Source

packages/blocks/src/surface-block/element-model/base.ts:66


display

display: boolean = true

Source

packages/blocks/src/surface-block/element-model/base.ts:90


externalXYWH

externalXYWH: undefined | `[${number},${number},${number},${number}]` = undefined

Implementation of

IEdgelessElement.externalXYWH

Source

packages/blocks/src/surface-block/element-model/base.ts:99


index

index: string

Implementation of

IEdgelessElement.index

Source

packages/blocks/src/surface-block/element-model/base.ts:84


opacity

opacity: number = 1

Source

packages/blocks/src/surface-block/element-model/base.ts:93


rotate

abstract rotate: number

Implementation of

IEdgelessElement.rotate

Source

packages/blocks/src/surface-block/element-model/base.ts:77


seed

seed: number

Source

packages/blocks/src/surface-block/element-model/base.ts:87


surface

surface: SurfaceBlockModel

Source

packages/blocks/src/surface-block/element-model/base.ts:75


xywh

abstract xywh: `[${number},${number},${number},${number}]`

Implementation of

IEdgelessElement.xywh

Source

packages/blocks/src/surface-block/element-model/base.ts:79


yMap

yMap: Map<unknown>

Source

packages/blocks/src/surface-block/element-model/base.ts:74

Accessors

connectable

get connectable(): boolean

Returns

boolean

Source

packages/blocks/src/surface-block/element-model/base.ts:135


deserializedXYWH

get deserializedXYWH(): XYWH

Returns

XYWH

Source

packages/blocks/src/surface-block/element-model/base.ts:141


elementBound

get elementBound(): Bound

Returns

Bound

Source

packages/blocks/src/surface-block/element-model/base.ts:179


externalBound

get externalBound(): null | Bound

Returns

null | Bound

Source

packages/blocks/src/surface-block/element-model/base.ts:101


group

get group(): null | GroupElementModel

Returns

null | GroupElementModel

Source

packages/blocks/src/surface-block/element-model/base.ts:167


groups

get groups(): GroupElementModel[]

Returns

GroupElementModel[]

Source

packages/blocks/src/surface-block/element-model/base.ts:171


h

get h(): number

Returns

number

Source

packages/blocks/src/surface-block/element-model/base.ts:163


id

get id(): string

Returns

string

Source

packages/blocks/src/surface-block/element-model/base.ts:175


type

get abstract type(): string

Returns

string

Source

packages/blocks/src/surface-block/element-model/base.ts:81


w

get w(): number

Returns

number

Source

packages/blocks/src/surface-block/element-model/base.ts:159


x

get x(): number

Returns

number

Source

packages/blocks/src/surface-block/element-model/base.ts:151


y

get y(): number

Returns

number

Source

packages/blocks/src/surface-block/element-model/base.ts:155

Methods

boxSelect()

boxSelect(bound): boolean

Parameters

bound: Bound

Returns

boolean

Implementation of

IEdgelessElement.boxSelect

Source

packages/blocks/src/surface-block/element-model/base.ts:275


containedByBounds()

containedByBounds(bounds): boolean

Parameters

bounds: Bound

Returns

boolean

Implementation of

IEdgelessElement.containedByBounds

Source

packages/blocks/src/surface-block/element-model/base.ts:250


getNearestPoint()

getNearestPoint(point): IVec

Parameters

point: IVec

Returns

IVec

Implementation of

IEdgelessElement.getNearestPoint

Source

packages/blocks/src/surface-block/element-model/base.ts:256


getRelativePointLocation()

getRelativePointLocation(relativePoint): PointLocation

Parameters

relativePoint: IVec

Returns

PointLocation

Implementation of

IEdgelessElement.getRelativePointLocation

Source

packages/blocks/src/surface-block/element-model/base.ts:266


hitTest()

hitTest(x, y, _, __): boolean

Parameters

x: number

y: number

_: HitTestOptions

__: EditorHost

Returns

boolean

Implementation of

IEdgelessElement.hitTest

Source

packages/blocks/src/surface-block/element-model/base.ts:284


intersectWithLine()

intersectWithLine(start, end): null | PointLocation[]

Parameters

start: IVec

end: IVec

Returns

null | PointLocation[]

Implementation of

IEdgelessElement.intersectWithLine

Source

packages/blocks/src/surface-block/element-model/base.ts:261


pop()

pop(prop): void

Parameters

prop: string | keyof Props

Returns

void

Source

packages/blocks/src/surface-block/element-model/base.ts:226


serialize()

serialize(): Object

Returns

Object

Source

packages/blocks/src/surface-block/element-model/base.ts:288


stash()

stash(prop): void

Parameters

prop: string | keyof Props

Returns

void

Source

packages/blocks/src/surface-block/element-model/base.ts:187


propsToY()

static propsToY(props): Record<string, unknown>

Parameters

props: Record<string, unknown>

Returns

Record<string, unknown>

Source

packages/blocks/src/surface-block/element-model/base.ts:54