BlockSuite API Documentation / @blocksuite/blocks / MindmapElementModel
Class: MindmapElementModel 
Extends 
SurfaceGroupLikeModel<MindmapElementProps>
Constructors 
new MindmapElementModel() 
new MindmapElementModel(
options):MindmapElementModel
Parameters 
• options
• options.id: string
• options.model: SurfaceBlockModel
• options.onChange
• options.stashedStore: Map<unknown, unknown>
• options.yMap: YMap<unknown>
Returns 
Inherited from 
SurfaceGroupLikeModel.constructor
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:92
Properties 
_disposable 
protected_disposable:DisposableGroup
Inherited from 
SurfaceGroupLikeModel._disposable
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:58
_id 
protected_id:string
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:59
_local 
protected_local:Map<string|symbol,unknown>
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:60
_onChange() 
protected_onChange: (payload) =>void
Parameters 
• payload
• payload.local: boolean
• payload.oldValues: Record<string, unknown>
• payload.props: Record<string, unknown>
Returns 
void
Inherited from 
SurfaceGroupLikeModel._onChange
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:61
_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/surface/element-model.d.ts:69
_stashed 
protected_stashed:Map<string,unknown>
Inherited from 
SurfaceGroupLikeModel._stashed
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:70
[gfxContainerSymbol] 
[gfxContainerSymbol]:
true
Inherited from 
SurfaceGroupLikeModel.[gfxContainerSymbol]
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:125
connectors 
connectors:
Map<string,LocalConnectorElementModel>
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:35
extraConnectors 
extraConnectors:
Map<string,LocalConnectorElementModel>
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:36
surface 
surface:
SurfaceBlockModel
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:72
yMap 
yMap:
YMap<unknown>
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:74
Accessors 
childElements 
getchildElements():GfxModel[]
Returns 
GfxModel[]
Inherited from 
SurfaceGroupLikeModel.childElements
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:126
childIds 
getchildIds():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/surface/element-model.d.ts:131
children 
Overrides 
SurfaceGroupLikeModel.children
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:118
connectable 
getconnectable():boolean
Returns 
boolean
Inherited from 
SurfaceGroupLikeModel.connectable
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:75
deserializedXYWH 
getdeserializedXYWH():XYWH
Returns 
XYWH
Inherited from 
SurfaceGroupLikeModel.deserializedXYWH
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:76
display 
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:114
elementBound 
getelementBound():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/surface/element-model.d.ts:81
externalBound 
getexternalBound():null|Bound
Returns 
null | Bound
Inherited from 
SurfaceGroupLikeModel.externalBound
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:82
externalXYWH 
Inherited from 
SurfaceGroupLikeModel.externalXYWH
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:115
group 
getgroup():null|SurfaceGroupLikeModel<BaseElementProps>
Returns 
null | SurfaceGroupLikeModel<BaseElementProps>
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:83
groups 
getgroups():SurfaceGroupLikeModel<BaseElementProps>[]
Returns 
SurfaceGroupLikeModel<BaseElementProps>[]
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:84
h 
geth():number
Returns 
number
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:85
id 
getid():string
Returns 
string
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:86
index 
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:116
isConnected 
getisConnected():boolean
Returns 
boolean
Inherited from 
SurfaceGroupLikeModel.isConnected
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:87
layoutType 
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:119
nodeMap 
getnodeMap():Map<string,MindmapNode>
Returns 
Map<string, MindmapNode>
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:37
opacity 
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:117
rotate 
getrotate():number
setrotate(_):void
Parameters 
• _: number
Returns 
number
Overrides 
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:38
seed 
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:118
style 
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:120
styleGetter 
getstyleGetter():MindmapStyleGetter
Returns 
MindmapStyleGetter
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:40
tree 
gettree():MindmapRoot
Returns 
MindmapRoot
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:41
type 
gettype():string
Returns 
string
Overrides 
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:42
w 
getw():number
Returns 
number
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:89
x 
getx():number
Returns 
number
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:90
xywh 
getxywh(): `[${number},${number},${number},${number}]`
setxywh(_):void
Parameters 
• _: `[${number},${number},${number},${number}]`
Returns 
`[${number},${number},${number},${number}]`
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:132
y 
gety():number
Returns 
number
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:91
Methods 
addConnector() 
protectedaddConnector(from,to,layout,connectorStyle,extra?):LocalConnectorElementModel
Parameters 
• from: MindmapNode
• to: MindmapNode
• layout: LayoutType
• connectorStyle: ConnectorStyle
• extra?: boolean
Returns 
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:47
addNode() 
addNode(
parent,sibling?,position?,props?,direction?):string
Parameters 
• parent: null | string | MindmapNode
The parent node id of the new node. If it's null, the node will be the root node
• sibling?: string | number
• position?: "before" | "after"
• props?: Record<string, unknown>
Force the layout direction of the node. It only works on the first level node with the layout type of BALANCE
Returns 
string
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:48
addTree() 
addTree(
parent,tree,sibling?,layout?):undefined|null|MindmapNode
Parameters 
• parent: string | MindmapNode
• tree: MindmapNode | Node
• sibling?: string | number
sibling indicates where to insert a subtree among peer elements. If it's a string, it represents a peer element's ID; if it's a number, it represents its index. The subtree will be inserted before the sibling element.
• layout?: LayoutType
Preferred layout direction, only works when parent is root and layout type is BALANCE
Returns 
undefined | null | MindmapNode
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:58
applyStyle() 
applyStyle(
fitContent?):void
Parameters 
• fitContent?: boolean
Returns 
void
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:70
buildTree() 
protectedbuildTree():void
Returns 
void
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:71
containsBound() 
containsBound(
bounds):boolean
Parameters 
• bounds: Bound
Returns 
boolean
Inherited from 
SurfaceGroupLikeModel.containsBound
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:104
descendants() 
descendants(
withoutGroup?):GfxModel[]
Parameters 
• withoutGroup?: boolean
if true, will not include group element
Returns 
GfxModel[]
Deprecated 
Use getAllDescendantElements instead. Get all descendants of this group
Inherited from 
SurfaceGroupLikeModel.descendants
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:140
detach() 
detach(
subtree):undefined|MindmapNode
Detach a mindmap. It is similar to removeChild but it does not delete the node.
So the node can be used to create a new mind map or merge into other mind map
Parameters 
• subtree: string | MindmapNode
Returns 
undefined | MindmapNode
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:78
getChildNodes() 
getChildNodes(
id,subtree?):MindmapNode[]
Parameters 
• id: string
• subtree?: "left" | "right"
The subtree of root, this only take effects when the layout type is BALANCED.
Returns 
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:84
getConnector() 
getConnector(
from,to):null|LocalConnectorElementModel
Parameters 
• from: MindmapNode
• to: MindmapNode
Returns 
null | LocalConnectorElementModel
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:85
getLayoutDir() 
getLayoutDir(
node):null|LayoutType
Parameters 
• node: string | MindmapNode
Returns 
null | LayoutType
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:86
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/surface/element-model.d.ts:105
getNearestPoint() 
getNearestPoint(
point):IVec
Parameters 
• point: IVec
Returns 
IVec
Inherited from 
SurfaceGroupLikeModel.getNearestPoint
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:106
getNode() 
getNode(
id):null|MindmapNode
Parameters 
• id: string
Returns 
null | MindmapNode
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:87
getParentNode() 
getParentNode(
id):null|MindmapNode
Parameters 
• id: string
Returns 
null | MindmapNode
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:88
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/block-surface/dist/element-model/mindmap.d.ts:101
getRelativePointLocation() 
getRelativePointLocation(
relativePoint):PointLocation
Parameters 
• relativePoint: IVec
Returns 
PointLocation
Inherited from 
SurfaceGroupLikeModel.getRelativePointLocation
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:107
getSiblingNode() 
getSiblingNode(
id,direction?,subtree?):null|MindmapNode
Parameters 
• id: string
• direction?: "next" | "prev"
• subtree?: "left" | "right"
The subtree of which that the sibling node belongs to, this is used when the layout type is BALANCED.
Returns 
null | MindmapNode
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:102
hasChild() 
hasChild(
element):boolean
The actual field that stores the children of the group. It should be a ymap decorated with @field.
Parameters 
• element: string | GfxModel
Returns 
boolean
Inherited from 
SurfaceGroupLikeModel.hasChild
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:145
hasDescendant() 
hasDescendant(
element):boolean
Check if the group has the given descendant.
Parameters 
• element: string | GfxModel
Returns 
boolean
Inherited from 
SurfaceGroupLikeModel.hasDescendant
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:149
includesPoint() 
includesPoint(
x,y,_,__):boolean
Parameters 
• x: number
• y: number
• _: PointTestOptions
• __: EditorHost
Returns 
boolean
Inherited from 
SurfaceGroupLikeModel.includesPoint
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:108
intersectsBound() 
intersectsBound(
bound):boolean
Parameters 
• bound: Bound
Returns 
boolean
Inherited from 
SurfaceGroupLikeModel.intersectsBound
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:109
layout() 
layout(
tree?,applyStyle?,layoutType?):void
Parameters 
• tree?: MindmapNode | MindmapRoot
• applyStyle?: boolean
• layoutType?: LayoutType
Returns 
void
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:108
moveTo() 
moveTo(
targetXYWH):void
Parameters 
• targetXYWH: `[${number},${number},${number},${number}]` | XYWH
Returns 
void
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:109
moveTree() 
moveTree(
tree,parent,siblingIndex,layout?):undefined|MindmapNode
Parameters 
• tree: MindmapNode
• parent: string | MindmapNode
• siblingIndex: number
• layout?: LayoutType
Returns 
undefined | MindmapNode
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:110
onCreated() 
onCreated():
void
Returns 
void
Overrides 
SurfaceGroupLikeModel.onCreated
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:111
pop() 
pop(
prop):void
Parameters 
• prop: string
Returns 
void
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:111
removeChild() 
removeChild(
id):void
Remove the child from the group
Parameters 
• id: string
Returns 
void
Overrides 
SurfaceGroupLikeModel.removeChild
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:112
requestBuildTree() 
protectedrequestBuildTree():void
Returns 
void
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:113
requestLayout() 
requestLayout():
void
Returns 
void
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:114
serialize() 
serialize():
SerializedMindmapElement
Returns 
Overrides 
SurfaceGroupLikeModel.serialize
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:115
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/surface/element-model.d.ts:159
stash() 
stash(
prop):void
Parameters 
• prop: string
Returns 
void
Inherited from 
Defined in 
packages/framework/block-std/dist/gfx/surface/element-model.d.ts:113
stashTree() 
stashTree(
node):undefined| () =>void
Parameters 
• node: string | MindmapNode
Returns 
undefined | () => void
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:116
traverse() 
traverse(
callback):void
Parameters 
• callback
Returns 
void
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:117
createFromTree() 
staticcreateFromTree(tree,style,layoutType,surface):MindmapElementModel
Parameters 
• tree: MindmapNode
• style: MindmapStyle
• layoutType: LayoutType
• surface: SurfaceBlockModel
Returns 
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:43
propsToY() 
staticpropsToY(props):MindmapElementProps
Parameters 
• props: Record<string, unknown>
Returns 
MindmapElementProps
Overrides 
SurfaceGroupLikeModel.propsToY
Defined in 
packages/affine/block-surface/dist/element-model/mindmap.d.ts:44