API > @blocksuite/blocks > ShapeElement
Class: ShapeElement ​
Extends ​
SurfaceElement
<IShape
,IShapeLocalRecord
>
Constructors ​
constructor ​
new ShapeElement(
yMap
,options
,data
={}
):ShapeElement
Parameters ​
Parameter | Type |
---|---|
yMap | Map < unknown > |
options | object |
options.getGroupParent | function |
options.getLocalRecord | function |
options.onElementUpdated | function |
options.pickById | function |
options.selectionManager ? | EdgelessSelectionManager |
options.setGroupParent | function |
options.updateElementLocalRecord | function |
data | Partial < IShape > |
Returns ​
Inherited from ​
SurfaceElement<IShape, IShapeLocalRecord>.constructor
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:95
Properties ​
_connectable ​
protected
_connectable:boolean
=true
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:91
Inherited from ​
SurfaceElement._connectable
computedValue ​
computedValue:
ComputedValue
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:93
Inherited from ​
SurfaceElement.computedValue
options ​
protected
options:object
Type declaration ​
options.getGroupParent
​getGroupParent:
function
Parameters ​
Parameter Type element
string
|EdgelessElement
Returns ​
options.getLocalRecord
​getLocalRecord:
function
Parameters ​
Parameter Type id
string
Returns ​
undefined
|IShapeLocalRecord
|ISurfaceElementLocalRecord
options.onElementUpdated
​onElementUpdated:
function
Parameters ​
Parameter Type update
object
update.id
string
update.props
object
Returns ​
void
options.pickById
​pickById:
function
Parameters ​
Parameter Type id
string
Returns ​
null
|EdgelessElement
options.selectionManager
​
optional
selectionManager:EdgelessSelectionManager
options.setGroupParent
​setGroupParent:
function
Parameters ​
Parameter Type element
string
|EdgelessElement
group
GroupElement
Returns ​
void
options.updateElementLocalRecord
​updateElementLocalRecord:
function
Parameters ​
Parameter Type id
string
record
Record
<string
,unknown
>Returns ​
void
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:70
Inherited from ​
SurfaceElement.options
renderer ​
protected
renderer:null
|Renderer
=null
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:90
Inherited from ​
SurfaceElement.renderer
yMap ​
yMap:
Map
<unknown
>
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:68
Inherited from ​
SurfaceElement.yMap
Accessors ​
batch ​
get
batch():null
|NonNullable
<T
["batch"
] >
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:144
Inherited from ​
SurfaceElement.batch
bold ​
get
bold():boolean
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:120
color ​
get
color():string
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:81
connectable ​
get
connectable():boolean
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:179
Inherited from ​
SurfaceElement.connectable
fillColor ​
get
fillColor():string
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:37
filled ​
get
filled():boolean
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:32
font ​
get
font():string
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:144
fontFamily ​
get
fontFamily():string
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:93
fontSize ​
get
fontSize():SHAPE_TEXT_FONT_SIZE
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:86
gridBound ​
get
gridBound():Bound
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:148
Inherited from ​
SurfaceElement.gridBound
h ​
get
h():number
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:170
Inherited from ​
SurfaceElement.h
horizontalOffset ​
get
horizontalOffset():number
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:156
id ​
get
id():T
["id"
]
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:114
Inherited from ​
SurfaceElement.id
index ​
get
index():T
["index"
]
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:119
Inherited from ​
SurfaceElement.index
italic ​
get
italic():boolean
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:125
localRecord ​
get
localRecord():undefined
|IShapeLocalRecord
|ISurfaceElementLocalRecord
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:175
Inherited from ​
SurfaceElement.localRecord
radius ​
get
radius():number
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:27
realFillColor ​
get
realFillColor():string
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:67
realStrokeColor ​
get
realStrokeColor():string
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:63
rotate ​
get
rotate():T
["rotate"
]
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:139
Inherited from ​
SurfaceElement.rotate
roughness ​
get
roughness():number
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:57
seed ​
get
seed():T
["seed"
]
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:134
Inherited from ​
SurfaceElement.seed
shapeStyle ​
get
shapeStyle():ShapeStyle
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:71
shapeType ​
get
shapeType():ShapeType
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:22
strokeColor ​
get
strokeColor():string
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:47
strokeStyle ​
get
strokeStyle():StrokeStyle
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:52
strokeWidth ​
get
strokeWidth():number
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:42
text ​
get
text():undefined
|Text
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:76
textAlign ​
get
textAlign():"center"
|"left"
|"right"
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:100
textHorizontalAlign ​
get
textHorizontalAlign():"center"
|"left"
|"right"
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:106
textVerticalAlign ​
get
textVerticalAlign():"center"
|"top"
|"bottom"
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:113
type ​
get
type():T
["type"
]
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:124
Inherited from ​
SurfaceElement.type
w ​
get
w():number
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:165
Inherited from ​
SurfaceElement.w
wrapTextDeltas ​
get
wrapTextDeltas():ITextDelta
[]
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:130
x ​
get
x():number
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:155
Inherited from ​
SurfaceElement.x
xywh ​
get
xywh():T
["xywh"
]
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:129
Inherited from ​
SurfaceElement.xywh
y ​
get
y():number
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:160
Inherited from ​
SurfaceElement.y
Methods ​
_renderText ​
private
_renderText(ctx
):void
Parameters ​
Parameter | Type |
---|---|
ctx | CanvasRenderingContext2D |
Returns ​
void
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:217
applyUpdate ​
applyUpdate(
updates
):void
Parameters ​
Parameter | Type |
---|---|
updates | Partial < IShape > |
Returns ​
void
Inherited from ​
SurfaceElement.applyUpdate
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:187
boxSelect ​
boxSelect(
bound
):boolean
Parameters ​
Parameter | Type |
---|---|
bound | Bound |
Returns ​
boolean
Inherited from ​
SurfaceElement.boxSelect
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:59
containedByBounds ​
containedByBounds(
bounds
):boolean
Parameters ​
Parameter | Type |
---|---|
bounds | Bound |
Returns ​
boolean
Overrides ​
SurfaceElement.containedByBounds
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:185
deserializeXYWH ​
deserializeXYWH():
XYWH
Returns ​
Inherited from ​
SurfaceElement.deserializeXYWH
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:193
getLocalRecord ​
getLocalRecord():
IShapeLocalRecord
Returns ​
IShapeLocalRecord
Inherited from ​
SurfaceElement.getLocalRecord
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:183
getNearestPoint ​
getNearestPoint(
point
):IVec
Parameters ​
Parameter | Type |
---|---|
point | IVec |
Returns ​
Overrides ​
SurfaceElement.getNearestPoint
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:193
getRelativePointLocation ​
getRelativePointLocation(
point
):PointLocation
Parameters ​
Parameter | Type |
---|---|
point | IVec |
Returns ​
Overrides ​
SurfaceElement.getRelativePointLocation
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:197
hitTest ​
hitTest(
x
,y
,options
):boolean
Parameters ​
Parameter | Type |
---|---|
x | number |
y | number |
options | HitTestOptions |
Returns ​
boolean
Overrides ​
SurfaceElement.hitTest
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:174
init ​
init():
void
Returns ​
void
Inherited from ​
SurfaceElement.init
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:112
intersectWithLine ​
intersectWithLine(
start
,end
):null
|PointLocation
[]
Parameters ​
Parameter | Type |
---|---|
start | IVec |
end | IVec |
Returns ​
null
| PointLocation
[]
Overrides ​
SurfaceElement.intersectWithLine
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:189
mount ​
mount(
renderer
):void
Parameters ​
Parameter | Type |
---|---|
renderer | Renderer |
Returns ​
void
Inherited from ​
SurfaceElement.mount
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:219
render ​
render(
ctx
,matrix
,rc
):void
Parameters ​
Parameter | Type |
---|---|
ctx | CanvasRenderingContext2D |
matrix | DOMMatrix |
rc | RoughCanvas |
Returns ​
void
Overrides ​
SurfaceElement.render
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:204
serialize ​
serialize():
IShape
Returns ​
Inherited from ​
SurfaceElement.serialize
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:197
unmount ​
unmount():
void
Returns ​
void
Inherited from ​
SurfaceElement.unmount
Defined In ​
packages/blocks/src/surface-block/elements/surface-element.ts:225
verticalOffset ​
verticalOffset(
lines
,lineHeight
):number
Parameters ​
Parameter | Type |
---|---|
lines | ITextDelta [][] |
lineHeight | number |
Returns ​
number
Defined In ​
packages/blocks/src/surface-block/elements/shape/shape-element.ts:165