Skip to content

BlockSuite API Documentation / @blocksuite/blocks / ShapeElementModel

Class: ShapeElementModel

Extends

Constructors

new ShapeElementModel()

new ShapeElementModel(options): ShapeElementModel

Parameters

options

options.id: string

options.model: SurfaceBlockModel

options.onChange

options.stashedStore: Map<unknown, unknown>

options.yMap: Map<unknown>

Returns

ShapeElementModel

Inherited from

ElementModel.constructor

Source

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

Properties

_disposable

protected _disposable: DisposableGroup

Inherited from

ElementModel._disposable

Source

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


_id

protected _id: string

Inherited from

ElementModel._id

Source

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


_local

protected _local: Map<string | symbol, unknown>

Inherited from

ElementModel._local

Source

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


_onChange()

protected _onChange: (payload) => void

Parameters

payload

payload.local: boolean

payload.oldValues: Record<string, unknown>

payload.props: Record<string, unknown>

Returns

void

Inherited from

ElementModel._onChange

Source

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


_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.

Inherited from

ElementModel._preserved

Source

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


_stashed

protected _stashed: Map<string, unknown>

Inherited from

ElementModel._stashed

Source

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


color

color: string

Source

packages/blocks/src/surface-block/element-model/shape.ts:120


display

display: boolean = true

Inherited from

ElementModel.display

Source

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


externalXYWH

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

Inherited from

ElementModel.externalXYWH

Source

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


fillColor

fillColor: string = '--affine-palette-shape-yellow'

Source

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


filled

filled: boolean = false

Source

packages/blocks/src/surface-block/element-model/shape.ts:96


fontFamily

fontFamily: string

Source

packages/blocks/src/surface-block/element-model/shape.ts:126


fontSize

fontSize: number

Source

packages/blocks/src/surface-block/element-model/shape.ts:123


fontStyle

fontStyle: FontStyle

Source

packages/blocks/src/surface-block/element-model/shape.ts:132


fontWeight

fontWeight: FontWeight

Source

packages/blocks/src/surface-block/element-model/shape.ts:129


index

index: string

Inherited from

ElementModel.index

Source

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


maxWidth

maxWidth: number | false = false

Source

packages/blocks/src/surface-block/element-model/shape.ts:147


opacity

opacity: number = 1

Inherited from

ElementModel.opacity

Source

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


radius

radius: number = 0

Source

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


rotate

rotate: number = 0

Overrides

ElementModel.rotate

Source

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


roughness

roughness: number = DEFAULT_ROUGHNESS

Source

packages/blocks/src/surface-block/element-model/shape.ts:114


seed

seed: number

Inherited from

ElementModel.seed

Source

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


shapeStyle

shapeStyle: ShapeStyle = 'General'

Source

packages/blocks/src/surface-block/element-model/shape.ts:111


shapeType

shapeType: ShapeType = 'rect'

Source

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


strokeColor

strokeColor: string = '--affine-palette-line-yellow'

Source

packages/blocks/src/surface-block/element-model/shape.ts:105


strokeStyle

strokeStyle: StrokeStyle = 'solid'

Source

packages/blocks/src/surface-block/element-model/shape.ts:108


strokeWidth

strokeWidth: number = 4

Source

packages/blocks/src/surface-block/element-model/shape.ts:102


surface

surface: SurfaceBlockModel

Inherited from

ElementModel.surface

Source

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


text?

optional text: Text

Source

packages/blocks/src/surface-block/element-model/shape.ts:117


textAlign

textAlign: TextAlign

Source

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


textBound

textBound: null | IBound = null

Source

packages/blocks/src/surface-block/element-model/shape.ts:149


textDisplay

textDisplay: boolean = true

Source

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


textHorizontalAlign

textHorizontalAlign: TextAlign

Source

packages/blocks/src/surface-block/element-model/shape.ts:138


textResizing

textResizing: TextResizing = TextResizing.AUTO_HEIGHT

Source

packages/blocks/src/surface-block/element-model/shape.ts:144


textVerticalAlign

textVerticalAlign: VerticalAlign

Source

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


xywh

xywh: `[${number},${number},${number},${number}]` = '[0,0,100,100]'

Overrides

ElementModel.xywh

Source

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


yMap

yMap: Map<unknown>

Inherited from

ElementModel.yMap

Source

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

Accessors

connectable

get connectable(): boolean

Returns

boolean

Source

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


deserializedXYWH

get deserializedXYWH(): XYWH

Returns

XYWH

Source

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


elementBound

get elementBound(): Bound

Returns

Bound

Source

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


externalBound

get externalBound(): null | Bound

Returns

null | Bound

Source

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


group

get group(): null | GroupLikeModel<BaseProps>

Returns

null | GroupLikeModel<BaseProps>

Source

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


groups

get groups(): GroupLikeModel<BaseProps>[]

Returns

GroupLikeModel<BaseProps>[]

Source

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


h

get h(): number

Returns

number

Source

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


id

get id(): string

Returns

string

Source

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


isConnected

get isConnected(): boolean

Returns

boolean

Source

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


type

get type(): string

Returns

string

Source

packages/blocks/src/surface-block/element-model/shape.ts:76


w

get w(): number

Returns

number

Source

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


x

get x(): number

Returns

number

Source

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


y

get y(): number

Returns

number

Source

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

Methods

boxSelect()

boxSelect(bound): boolean

Parameters

bound: Bound

Returns

boolean

Inherited from

ElementModel.boxSelect

Source

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


containedByBounds()

containedByBounds(bounds): boolean

Parameters

bounds: Bound

Returns

boolean

Overrides

ElementModel.containedByBounds

Source

packages/blocks/src/surface-block/element-model/shape.ts:158


getNearestPoint()

getNearestPoint(point): IVec2

Parameters

point: IVec2

Returns

IVec2

Overrides

ElementModel.getNearestPoint

Source

packages/blocks/src/surface-block/element-model/shape.ts:166


getRelativePointLocation()

getRelativePointLocation(point): PointLocation

Parameters

point: IVec2

Returns

PointLocation

Overrides

ElementModel.getRelativePointLocation

Source

packages/blocks/src/surface-block/element-model/shape.ts:170


hitTest()

hitTest(x, y, options): boolean

Parameters

x: number

y: number

options: HitTestOptions

Returns

boolean

Overrides

ElementModel.hitTest

Source

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


intersectWithLine()

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

Parameters

start: IVec2

end: IVec2

Returns

null | PointLocation[]

Overrides

ElementModel.intersectWithLine

Source

packages/blocks/src/surface-block/element-model/shape.ts:162


onCreated()

onCreated(): void

onCreated function will be executed when element is created in local rather than remote peers

Returns

void

Inherited from

ElementModel.onCreated

Source

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


pop()

pop(prop): void

Parameters

prop: string

Returns

void

Inherited from

ElementModel.pop

Source

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


serialize()

serialize(): object

Returns

object

Inherited from

ElementModel.serialize

Source

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


stash()

stash(prop): void

Parameters

prop: string

Returns

void

Inherited from

ElementModel.stash

Source

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


propsToY()

static propsToY(props): ShapeProps

Parameters

props: ShapeProps

Returns

ShapeProps

Overrides

ElementModel.propsToY

Source

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