BlockSuite API Documentation / @blocksuite/blocks / MindmapElementModel
Class: MindmapElementModel
Extends
SurfaceGroupLikeModel
<MindmapElementProps
>
Constructors
new MindmapElementModel()
new MindmapElementModel(
options
):MindmapElementModel
Parameters
options
id
string
model
onChange
(payload
) => void
stashedStore
Map
<unknown
, unknown
>
yMap
YMap
<unknown
>
Returns
Inherited from
SurfaceGroupLikeModel
.constructor
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:65
Properties
_disposable
protected
_disposable:DisposableGroup
Inherited from
SurfaceGroupLikeModel
._disposable
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:24
_id
protected
_id:string
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:25
_local
protected
_local:Map
<string
|symbol
,unknown
>
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:26
_onChange()
protected
_onChange: (payload
) =>void
Parameters
payload
local
boolean
oldValues
Record
<string
, unknown
>
props
Record
<string
, unknown
>
Returns
void
Inherited from
SurfaceGroupLikeModel
._onChange
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:27
_preserved
protected
_preserved:Map
<string
,unknown
>
Used to store a copy of data in the yMap.
Inherited from
SurfaceGroupLikeModel
._preserved
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:35
_stashed
protected
_stashed:Map
<string
,unknown
>
Inherited from
SurfaceGroupLikeModel
._stashed
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:36
[gfxGroupCompatibleSymbol]
[gfxGroupCompatibleSymbol]:
true
Inherited from
SurfaceGroupLikeModel
.[gfxGroupCompatibleSymbol]
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:112
connectors
connectors:
Map
<string
,LocalConnectorElementModel
>
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:68
propsUpdated
propsUpdated:
Slot
<{key
:string
; }>
Inherited from
SurfaceGroupLikeModel
.propsUpdated
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:37
surface
surface:
SurfaceBlockModel
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:41
yMap
yMap:
YMap
<unknown
>
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:43
Accessors
childElements
Get Signature
get childElements():
GfxModel
[]
All child element models of this container. Note that the childElements
may not contains all the children in childIds
, because some children may not be loaded.
Returns
GfxModel
[]
Inherited from
SurfaceGroupLikeModel
.childElements
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:113
childIds
Get Signature
get childIds():
string
[]
The ids of the children. Its role is to provide a unique way to access the children. You should update this field through setChildIds
when the children are added or removed.
Returns
string
[]
Inherited from
SurfaceGroupLikeModel
.childIds
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:118
children
Overrides
SurfaceGroupLikeModel
.children
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:156
connectable
Get Signature
get connectable():
boolean
Returns
boolean
Inherited from
SurfaceGroupLikeModel
.connectable
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:44
descendantElements
Get Signature
get descendantElements():
GfxModel
[]
Returns
GfxModel
[]
Inherited from
SurfaceGroupLikeModel
.descendantElements
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:119
deserializedXYWH
Get Signature
get deserializedXYWH():
XYWH
Returns
XYWH
Inherited from
SurfaceGroupLikeModel
.deserializedXYWH
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:45
display
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:93
elementBound
Get Signature
get elementBound():
Bound
The bound of the element after rotation. The bound without rotation should be created by Bound.deserialize(this.xywh)
.
Returns
Bound
Inherited from
SurfaceGroupLikeModel
.elementBound
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:50
externalBound
Get Signature
get externalBound():
null
|Bound
Returns
null
| Bound
Inherited from
SurfaceGroupLikeModel
.externalBound
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:51
externalXYWH
In some cases, you need to draw something related to the element, but it does not belong to the element itself. And it is also interactive, you can select element by clicking on it. E.g. the title of the group element. In this case, we need to store this kind of external xywh in order to do hit test. This property should not be synced to the doc. This property should be updated every time it gets rendered.
Inherited from
SurfaceGroupLikeModel
.externalXYWH
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:100
group
Get Signature
get group():
null
|GfxGroupModel
Returns
null
| GfxGroupModel
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:52
groups
Get Signature
get groups():
GfxGroupModel
[]
Return the ancestor elements in order from the most recent to the earliest.
Returns
GfxGroupModel
[]
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:56
h
Get Signature
get h():
number
Returns
number
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:57
hidden
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:101
id
Get Signature
get id():
string
Returns
string
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:58
index
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:102
isConnected
Get Signature
get isConnected():
boolean
Returns
boolean
Inherited from
SurfaceGroupLikeModel
.isConnected
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:59
layoutType
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:157
lockedBySelf
Indicates whether the current block is explicitly locked by self. For checking the lock status of the element, use isLocked
instead. For (un)locking the element, use (un)lock
instead.
Inherited from
SurfaceGroupLikeModel
.lockedBySelf
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:103
nodeMap
Get Signature
get nodeMap():
Map
<string
,MindmapNode
>
Returns
Map
<string
, MindmapNode
>
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:69
opacity
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:104
responseBound
Get Signature
get responseBound():
Bound
The bound of the element considering the response extension.
Returns
Bound
Inherited from
SurfaceGroupLikeModel
.responseBound
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:60
responseExtension
Defines the extension of the response area beyond the element's bounding box. This tuple specifies the horizontal and vertical margins to be added to the element's bound.
The first value represents the horizontal extension (added to both left and right sides), and the second value represents the vertical extension (added to both top and bottom sides).
The response area is computed as: [x - horizontal, y - vertical, w + 2 * horizontal, h + 2 * vertical]
.
Example:
- xywh:
[0, 0, 100, 100]
,responseExtension: [10, 20]
Resulting response area:[-10, -20, 120, 140]
. responseExtension: [0, 0]
keeps the response area equal to the bounding box.
Inherited from
SurfaceGroupLikeModel
.responseExtension
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:105
rotate
Get Signature
get rotate():
number
Returns
number
Set Signature
set rotate(
_
):void
Parameters
_
number
Returns
void
Overrides
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:70
seed
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:106
style
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:158
styleGetter
Get Signature
get styleGetter():
MindmapStyleGetter
Returns
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:72
tree
Get Signature
get tree():
MindmapRoot
Returns
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:73
type
Get Signature
get type():
string
Returns
string
Overrides
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:74
w
Get Signature
get w():
number
Returns
number
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:62
x
Get Signature
get x():
number
Returns
number
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:63
xywh
Get Signature
get xywh(): `[${number},${number},${number},${number}]`
Returns
`[${number},${number},${number},${number}]`
Set Signature
set xywh(
_
):void
Parameters
_
`[${number},${number},${number},${number}]`
Returns
void
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:120
y
Get Signature
get y():
number
Returns
number
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:64
Methods
_getXYWH()
protected
_getXYWH():Bound
Returns
Bound
Overrides
SurfaceGroupLikeModel
._getXYWH
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:78
addChild()
addChild(
_element
):void
Parameters
_element
GfxModel
Returns
void
Deprecated
you should not call this method directly
Overrides
SurfaceGroupLikeModel
.addChild
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:83
addNode()
addNode(
parent
,sibling
?,position
?,props
?):string
Parameters
parent
The parent node id of the new node. If it's null, the node will be the root node
null
| string
| MindmapNode
sibling?
string
| number
position?
"before"
| "after"
props?
Record
<string
, unknown
>
Returns
string
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:84
buildTree()
buildTree():
void
Returns
void
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:89
containsBound()
containsBound(
bounds
):boolean
Parameters
bounds
Bound
Returns
boolean
Inherited from
SurfaceGroupLikeModel
.containsBound
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:77
getChildNodes()
getChildNodes(
id
,subtree
?):MindmapNode
[]
Parameters
id
string
subtree?
The subtree of root, this only take effects when the layout type is BALANCED.
"left"
| "right"
Returns
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:95
getConnectors()
getConnectors(
node
):null
|object
[]
Get all the connectors start from the given node
Parameters
node
Returns
null
| object
[]
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:101
getLayoutDir()
getLayoutDir(
node
):LayoutType
Parameters
node
string
| MindmapNode
Returns
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:108
getLineIntersections()
getLineIntersections(
start
,end
):null
|PointLocation
[]
Parameters
start
IVec
end
IVec
Returns
null
| PointLocation
[]
Inherited from
SurfaceGroupLikeModel
.getLineIntersections
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:78
getNearestPoint()
getNearestPoint(
point
):IVec
Parameters
point
IVec
Returns
IVec
Inherited from
SurfaceGroupLikeModel
.getNearestPoint
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:79
getNode()
getNode(
id
):null
|MindmapNode
Parameters
id
string
Returns
null
| MindmapNode
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:109
getParentNode()
getParentNode(
id
):null
|MindmapNode
Parameters
id
string
Returns
null
| MindmapNode
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:110
getPath()
getPath(
element
):number
[]
Path is an array of indexes that represent the path from the root node to the target node. The first element of the array is always 0, which represents the root node.
Parameters
element
string
| MindmapNode
Returns
number
[]
Example
const path = mindmap.getPath('nodeId');
// [0, 1, 2]
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:123
getRelativePointLocation()
getRelativePointLocation(
relativePoint
):PointLocation
Parameters
relativePoint
IVec
Returns
PointLocation
Inherited from
SurfaceGroupLikeModel
.getRelativePointLocation
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:80
getSiblingNode()
getSiblingNode(
id
,direction
?,subtree
?):null
|MindmapNode
Parameters
id
string
direction?
"prev"
| "next"
subtree?
The subtree of which that the sibling node belongs to, this is used when the layout type is BALANCED.
"left"
| "right"
Returns
null
| MindmapNode
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:124
hasChild()
hasChild(
element
):boolean
The actual field that stores the children of the group. It should be a ymap decorated with @field
.
Parameters
element
GfxCompatibleInterface
Returns
boolean
Inherited from
SurfaceGroupLikeModel
.hasChild
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:128
hasDescendant()
hasDescendant(
element
):boolean
Check if the group has the given descendant.
Parameters
element
GfxCompatibleInterface
Returns
boolean
Inherited from
SurfaceGroupLikeModel
.hasDescendant
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:132
includesPoint()
includesPoint(
x
,y
,options
):boolean
Parameters
x
number
y
number
options
PointTestOptions
Returns
boolean
Overrides
SurfaceGroupLikeModel
.includesPoint
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:130
intersectsBound()
intersectsBound(
bound
):boolean
Parameters
bound
Bound
Returns
boolean
Inherited from
SurfaceGroupLikeModel
.intersectsBound
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:82
isLocked()
isLocked():
boolean
Check if the element is locked. It will check the lock status of the element and its ancestors.
Returns
boolean
Inherited from
SurfaceGroupLikeModel
.isLocked
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:83
isLockedByAncestor()
isLockedByAncestor():
boolean
Returns
boolean
Inherited from
SurfaceGroupLikeModel
.isLockedByAncestor
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:84
isLockedBySelf()
isLockedBySelf():
boolean
Returns
boolean
Inherited from
SurfaceGroupLikeModel
.isLockedBySelf
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:85
layout()
layout(
_tree
?,_options
?):void
Parameters
_tree?
_options?
applyStyle
boolean
calculateTreeBound
boolean
layoutType
stashed
boolean
Returns
void
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:131
lock()
lock():
void
Returns
void
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:86
moveTo()
moveTo(
targetXYWH
):void
Parameters
targetXYWH
XYWH
| `[${number},${number},${number},${number}]`
Returns
void
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:137
onCreated()
onCreated():
void
Returns
void
Overrides
SurfaceGroupLikeModel
.onCreated
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:138
onDestroyed()
onDestroyed():
void
Returns
void
Inherited from
SurfaceGroupLikeModel
.onDestroyed
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:88
pop()
pop(
prop
):void
Parameters
prop
string
Returns
void
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:89
removeChild()
removeChild(
element
):void
Remove the child from the group
Parameters
element
GfxModel
Returns
void
Overrides
SurfaceGroupLikeModel
.removeChild
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:139
requestBuildTree()
protected
requestBuildTree():void
Returns
void
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:140
requestLayout()
requestLayout():
void
Returns
void
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:141
serialize()
serialize():
SerializedMindmapElement
Returns
Overrides
SurfaceGroupLikeModel
.serialize
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:142
setChildIds()
setChildIds(
value
,fromLocal
):void
Set the new value of the childIds
Parameters
value
string
[]
the new value of the childIds
fromLocal
boolean
if true, the change is happened in the local
Returns
void
Inherited from
SurfaceGroupLikeModel
.setChildIds
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:142
setLayoutMethod()
setLayoutMethod(
layoutMethod
):void
Parameters
layoutMethod
(_tree
?, _options
?) => void
Returns
void
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:143
stash()
stash(
prop
):void
Parameters
prop
string
Returns
void
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:91
stashTree()
stashTree(
node
):undefined
| () =>void
Stash mind map node and its children's xywh property
Parameters
node
string
| MindmapNode
Returns
undefined
| () => void
a function that write back the stashed xywh into yjs
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:149
toggleCollapse()
toggleCollapse(
node
,options
?):void
Parameters
node
options?
layout
boolean
Returns
void
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:150
traverse()
traverse(
callback
,root
?,options
?):void
Parameters
callback
(node
, parent
) => void
root?
options?
stopOnCollapse
boolean
Returns
void
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:153
unlock()
unlock():
void
Returns
void
Inherited from
Defined in
packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:92
propsToY()
static
propsToY(props
):MindmapElementProps
Parameters
props
Record
<string
, unknown
>
Returns
MindmapElementProps
Overrides
SurfaceGroupLikeModel
.propsToY
Defined in
packages/affine/model/dist/elements/mindmap/mindmap.d.ts:75