BlockSuite API Documentation / @blocksuite/blocks / ShapeElementModel
Class: ShapeElementModel
Extends
ElementModel
<ShapeProps
>
Constructors
new ShapeElementModel(options)
new ShapeElementModel(
options
):ShapeElementModel
Parameters
• options
• options.model: SurfaceBlockModel
• options.onChange
• options.stashedStore: Map
<unknown
, unknown
>
• options.yMap: Map
<unknown
>
Returns
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:113
Properties
_disposable
protected
_disposable:DisposableGroup
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:72
_local
protected
_local:Map
<string
|symbol
,unknown
>
Inherited from
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
Inherited from
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.
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:65
_stashed
protected
_stashed:Map
<string
,unknown
>
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:66
color
color:
string
Source
packages/blocks/src/surface-block/element-model/shape.ts:119
display
display:
boolean
=true
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:90
externalXYWH
externalXYWH:
undefined
| `[${number},${number},${number},${number}]` =undefined
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:99
fillColor
fillColor:
string
='--affine-palette-shape-yellow'
Source
packages/blocks/src/surface-block/element-model/shape.ts:98
filled
filled:
boolean
=false
Source
packages/blocks/src/surface-block/element-model/shape.ts:95
fontFamily
fontFamily:
string
Source
packages/blocks/src/surface-block/element-model/shape.ts:125
fontSize
fontSize:
number
Source
packages/blocks/src/surface-block/element-model/shape.ts:122
fontStyle
fontStyle:
FontStyle
Source
packages/blocks/src/surface-block/element-model/shape.ts:131
fontWeight
fontWeight:
FontWeight
Source
packages/blocks/src/surface-block/element-model/shape.ts:128
index
index:
string
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:84
opacity
opacity:
number
=1
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:93
radius
radius:
number
=0
Source
packages/blocks/src/surface-block/element-model/shape.ts:92
rotate
rotate:
number
=0
Overrides
Source
packages/blocks/src/surface-block/element-model/shape.ts:86
roughness
roughness:
number
=DEFAULT_ROUGHNESS
Source
packages/blocks/src/surface-block/element-model/shape.ts:113
seed
seed:
number
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:87
shapeStyle
shapeStyle:
ShapeStyle
='General'
Source
packages/blocks/src/surface-block/element-model/shape.ts:110
shapeType
shapeType:
ShapeType
='rect'
Source
packages/blocks/src/surface-block/element-model/shape.ts:89
strokeColor
strokeColor:
string
='--affine-palette-line-yellow'
Source
packages/blocks/src/surface-block/element-model/shape.ts:104
strokeStyle
strokeStyle:
StrokeStyle
='solid'
Source
packages/blocks/src/surface-block/element-model/shape.ts:107
strokeWidth
strokeWidth:
number
=4
Source
packages/blocks/src/surface-block/element-model/shape.ts:101
surface
surface:
SurfaceBlockModel
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:75
text?
optional
text:Text
Source
packages/blocks/src/surface-block/element-model/shape.ts:116
textAlign
textAlign:
TextAlign
Source
packages/blocks/src/surface-block/element-model/shape.ts:134
textDisplay
textDisplay:
boolean
=true
Source
packages/blocks/src/surface-block/element-model/shape.ts:80
textHorizontalAlign
textHorizontalAlign:
TextAlign
Source
packages/blocks/src/surface-block/element-model/shape.ts:137
textVerticalAlign
textVerticalAlign:
VerticalAlign
Source
packages/blocks/src/surface-block/element-model/shape.ts:140
xywh
xywh: `[${number},${number},${number},${number}]` =
'[0,0,100,100]'
Overrides
Source
packages/blocks/src/surface-block/element-model/shape.ts:83
yMap
yMap:
Map
<unknown
>
Inherited from
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
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
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
type():string
Returns
string
Source
packages/blocks/src/surface-block/element-model/shape.ts:75
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
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:275
containedByBounds()
containedByBounds(
bounds
):boolean
Parameters
• bounds: Bound
Returns
boolean
Overrides
ElementModel
.containedByBounds
Source
packages/blocks/src/surface-block/element-model/shape.ts:153
getNearestPoint()
getNearestPoint(
point
):IVec2
Parameters
• point: IVec2
Returns
IVec2
Overrides
Source
packages/blocks/src/surface-block/element-model/shape.ts:161
getRelativePointLocation()
getRelativePointLocation(
point
):PointLocation
Parameters
• point: IVec2
Returns
PointLocation
Overrides
ElementModel
.getRelativePointLocation
Source
packages/blocks/src/surface-block/element-model/shape.ts:165
hitTest()
hitTest(
x
,y
,options
):boolean
Parameters
• x: number
• y: number
• options: HitTestOptions
Returns
boolean
Overrides
Source
packages/blocks/src/surface-block/element-model/shape.ts:142
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:157
pop()
pop(
prop
):void
Parameters
• prop: string
Returns
void
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:226
serialize()
serialize():
Object
Returns
Object
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:288
stash()
stash(
prop
):void
Parameters
• prop: string
Returns
void
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:187
propsToY()
static
propsToY(props
):ShapeProps
Parameters
• props: ShapeProps
Returns
ShapeProps
Overrides
Source
packages/blocks/src/surface-block/element-model/shape.ts:67