BlockSuite API Documentation / @blocksuite/blocks / ShapeElementModel
Class: ShapeElementModel
Extends
SurfaceElementModel
<ShapeProps
>
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
Inherited from
SurfaceElementModel<ShapeProps>.constructor
Source
packages/blocks/src/surface-block/element-model/base.ts:229
Properties
_disposable
protected
_disposable:DisposableGroup
Inherited from
SurfaceElementModel._disposable
Source
packages/blocks/src/surface-block/element-model/base.ts:199
_id
protected
_id:string
Inherited from
SurfaceElementModel._id
Source
packages/blocks/src/surface-block/element-model/base.ts:201
_local
protected
_local:Map
<string
|symbol
,unknown
>
Inherited from
SurfaceElementModel._local
Source
packages/blocks/src/surface-block/element-model/base.ts:191
_onChange()
protected
_onChange: (payload
) =>void
Parameters
• payload
• payload.local: boolean
• payload.oldValues: Record
<string
, unknown
>
• payload.props: Record
<string
, unknown
>
Returns
void
Inherited from
SurfaceElementModel._onChange
Source
packages/blocks/src/surface-block/element-model/base.ts:193
_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 yfield 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
SurfaceElementModel._preserved
Source
packages/blocks/src/surface-block/element-model/base.ts:187
_stashed
protected
_stashed:Map
<string
,unknown
>
Inherited from
SurfaceElementModel._stashed
Source
packages/blocks/src/surface-block/element-model/base.ts:189
surface
surface:
SurfaceBlockModel
Inherited from
SurfaceElementModel.surface
Source
packages/blocks/src/surface-block/element-model/base.ts:205
textBound
textBound:
null
|IBound
=null
Source
packages/blocks/src/surface-block/element-model/shape.ts:158
yMap
yMap:
Map
<unknown
>
Inherited from
SurfaceElementModel.yMap
Source
packages/blocks/src/surface-block/element-model/base.ts:203
Accessors
color
connectable
get
connectable():boolean
Returns
boolean
Source
packages/blocks/src/surface-block/element-model/base.ts:124
deserializedXYWH
get
deserializedXYWH():XYWH
Returns
XYWH
Source
packages/blocks/src/surface-block/element-model/base.ts:128
display
elementBound
get
elementBound():Bound
Returns
Source
packages/blocks/src/surface-block/element-model/base.ts:166
externalBound
get
externalBound():null
|Bound
Returns
null
| Bound
Source
packages/blocks/src/surface-block/element-model/base.ts:112
externalXYWH
fillColor
filled
fontFamily
fontSize
fontStyle
fontWeight
group
get
group():null
|SurfaceGroupLikeModel
<IBaseProps
>
Returns
null
| SurfaceGroupLikeModel
<IBaseProps
>
Source
packages/blocks/src/surface-block/element-model/base.ts:154
groups
get
groups():SurfaceGroupLikeModel
<IBaseProps
>[]
Returns
SurfaceGroupLikeModel
<IBaseProps
>[]
Source
packages/blocks/src/surface-block/element-model/base.ts:158
h
get
h():number
Returns
number
Source
packages/blocks/src/surface-block/element-model/base.ts:150
id
get
id():string
Returns
string
Source
packages/blocks/src/surface-block/element-model/base.ts:162
index
isConnected
get
isConnected():boolean
Returns
boolean
Source
packages/blocks/src/surface-block/element-model/base.ts:174
maxWidth
opacity
padding
radius
rotate
roughness
seed
shadow
shapeStyle
shapeType
strokeColor
strokeStyle
strokeWidth
text
textAlign
textDisplay
textHorizontalAlign
textResizing
textVerticalAlign
type
get
type():string
Returns
string
Source
packages/blocks/src/surface-block/element-model/shape.ts:71
w
get
w():number
Returns
number
Source
packages/blocks/src/surface-block/element-model/base.ts:146
x
get
x():number
Returns
number
Source
packages/blocks/src/surface-block/element-model/base.ts:138
xywh
y
get
y():number
Returns
number
Source
packages/blocks/src/surface-block/element-model/base.ts:142
Methods
boxSelect()
boxSelect(
bound
):boolean
Parameters
• bound: Bound
Returns
boolean
Inherited from
SurfaceElementModel.boxSelect
Source
packages/blocks/src/surface-block/element-model/base.ts:352
containedByBounds()
containedByBounds(
bounds
):boolean
Parameters
• bounds: Bound
Returns
boolean
Overrides
SurfaceElementModel.containedByBounds
Source
packages/blocks/src/surface-block/element-model/shape.ts:167
getNearestPoint()
getNearestPoint(
point
):IVec2
Parameters
• point: IVec2
Returns
IVec2
Overrides
SurfaceElementModel.getNearestPoint
Source
packages/blocks/src/surface-block/element-model/shape.ts:175
getRelativePointLocation()
getRelativePointLocation(
point
):PointLocation
Parameters
• point: IVec2
Returns
PointLocation
Overrides
SurfaceElementModel.getRelativePointLocation
Source
packages/blocks/src/surface-block/element-model/shape.ts:179
hitTest()
hitTest(
x
,y
,options
):boolean
Parameters
• x: number
• y: number
• options: IHitTestOptions
Returns
boolean
Overrides
SurfaceElementModel.hitTest
Source
packages/blocks/src/surface-block/element-model/shape.ts:160
intersectWithLine()
intersectWithLine(
start
,end
):null
|PointLocation
[]
Parameters
• start: IVec2
• end: IVec2
Returns
null
| PointLocation
[]
Overrides
SurfaceElementModel.intersectWithLine
Source
packages/blocks/src/surface-block/element-model/shape.ts:171
onCreated()
onCreated():
void
onCreated
function will be executed when element is created in local rather than remote peers
Returns
void
Inherited from
SurfaceElementModel.onCreated
Source
packages/blocks/src/surface-block/element-model/base.ts:373
pop()
pop(
prop
):void
Parameters
• prop: string
Returns
void
Inherited from
SurfaceElementModel.pop
Source
packages/blocks/src/surface-block/element-model/base.ts:306
serialize()
serialize():
SerializedElement
Returns
SerializedElement
Inherited from
SurfaceElementModel.serialize
Source
packages/blocks/src/surface-block/element-model/base.ts:365
stash()
stash(
prop
):void
Parameters
• prop: string
Returns
void
Inherited from
SurfaceElementModel.stash
Source
packages/blocks/src/surface-block/element-model/base.ts:254
propsToY()
static
propsToY(props
):ShapeProps
Parameters
• props: ShapeProps
Returns
ShapeProps
Overrides
SurfaceElementModel.propsToY
Source
packages/blocks/src/surface-block/element-model/shape.ts:183