BlockSuite API Documentation / @blocksuite/blocks / TextElementModel
Class: TextElementModel
Extends
ElementModel
<TextElementProps
>
Constructors
new TextElementModel(options)
new TextElementModel(
options
):TextElementModel
Parameters
• options
• options.id: string
• 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:118
Properties
_disposable
protected
_disposable:DisposableGroup
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:76
_id
protected
_id:string
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:77
_local
protected
_local:Map
<string
|symbol
,unknown
>
Inherited from
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
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
Source
packages/blocks/src/surface-block/element-model/base.ts:68
_stashed
protected
_stashed:Map
<string
,unknown
>
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:69
color
color:
string
='#000000'
Source
packages/blocks/src/surface-block/element-model/text.ts:51
display
display:
boolean
=true
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:95
externalXYWH
externalXYWH:
undefined
|[${number},${number},${number},${number}]
=undefined
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:104
fontFamily
fontFamily:
FontFamily
=FontFamily.Inter
Source
packages/blocks/src/surface-block/element-model/text.ts:57
fontSize
fontSize:
number
=16
Source
packages/blocks/src/surface-block/element-model/text.ts:54
fontStyle
fontStyle:
FontStyle
='normal'
Source
packages/blocks/src/surface-block/element-model/text.ts:63
fontWeight
fontWeight:
FontWeight
=FontWeight.Regular
Source
packages/blocks/src/surface-block/element-model/text.ts:60
hasMaxWidth?
optional
hasMaxWidth:boolean
Source
packages/blocks/src/surface-block/element-model/text.ts:69
index
index:
string
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:89
opacity
opacity:
number
=1
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:98
rotate
rotate:
number
=0
Overrides
Source
packages/blocks/src/surface-block/element-model/text.ts:45
seed
seed:
number
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:92
surface
surface:
SurfaceBlockModel
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:80
text
text:
Text
Source
packages/blocks/src/surface-block/element-model/text.ts:48
textAlign
textAlign:
TextAlign
='center'
Source
packages/blocks/src/surface-block/element-model/text.ts:66
xywh
xywh:
[${number},${number},${number},${number}]
='[0,0,16,16]'
Overrides
Source
packages/blocks/src/surface-block/element-model/text.ts:42
yMap
yMap:
Map
<unknown
>
Inherited from
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
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
type
get
type():string
Returns
string
Source
packages/blocks/src/surface-block/element-model/text.ts:71
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
Source
packages/blocks/src/surface-block/element-model/base.ts:297
containedByBounds()
containedByBounds(
bounds
):boolean
Parameters
• bounds: Bound
Returns
boolean
Overrides
ElementModel
.containedByBounds
Source
packages/blocks/src/surface-block/element-model/text.ts:82
getNearestPoint()
getNearestPoint(
point
):IVec2
Parameters
• point: IVec2
Returns
IVec2
Overrides
Source
packages/blocks/src/surface-block/element-model/text.ts:75
getRelativePointLocation()
getRelativePointLocation(
relativePoint
):PointLocation
Parameters
• relativePoint: IVec
Returns
PointLocation
Inherited from
ElementModel
.getRelativePointLocation
Source
packages/blocks/src/surface-block/element-model/base.ts:288
hitTest()
hitTest(
x
,y
):boolean
Parameters
• x: number
• y: number
Returns
boolean
Overrides
Source
packages/blocks/src/surface-block/element-model/text.ts:92
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/text.ts:87
onCreated()
onCreated():
void
onCreated
function will be executed when element is created in local rather than remote peers
Returns
void
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:318
pop()
pop(
prop
):void
Parameters
• prop: string
Returns
void
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:250
serialize()
serialize():
object
Returns
object
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:310
stash()
stash(
prop
):void
Parameters
• prop: string
Returns
void
Inherited from
Source
packages/blocks/src/surface-block/element-model/base.ts:195
propsToY()
static
propsToY(props
):Record
<string
,unknown
>
Parameters
• props: Record
<string
, unknown
>
Returns
Record
<string
, unknown
>
Overrides
Source
packages/blocks/src/surface-block/element-model/text.ts:33