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: Map
<unknown
>
Returns
Inherited from
SurfaceGroupLikeModel<MindmapElementProps>.constructor
Source
packages/blocks/src/surface-block/element-model/base.ts:229
Properties
_disposable
protected
_disposable:DisposableGroup
Inherited from
SurfaceGroupLikeModel._disposable
Source
packages/blocks/src/surface-block/element-model/base.ts:199
_id
protected
_id:string
Inherited from
SurfaceGroupLikeModel._id
Source
packages/blocks/src/surface-block/element-model/base.ts:201
_local
protected
_local:Map
<string
|symbol
,unknown
>
Inherited from
SurfaceGroupLikeModel._local
Source
packages/blocks/src/surface-block/element-model/base.ts:191
_nodeMap
private
_nodeMap:Map
<string
,MindmapNode
>
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:80
_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
Source
packages/blocks/src/surface-block/element-model/base.ts:193
_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 yfield 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
SurfaceGroupLikeModel._preserved
Source
packages/blocks/src/surface-block/element-model/base.ts:187
_queueBuildTree
private
_queueBuildTree:boolean
=false
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:82
_queued
private
_queued:boolean
=false
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:84
_stashed
protected
_stashed:Map
<string
,unknown
>
Inherited from
SurfaceGroupLikeModel._stashed
Source
packages/blocks/src/surface-block/element-model/base.ts:189
_tree
private
_tree:MindmapRoot
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:78
connectors
connectors:
Map
<string
,LocalConnectorElementModel
>
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:178
extraConnectors
extraConnectors:
Map
<string
,LocalConnectorElementModel
>
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:180
pathGenerator
pathGenerator:
ConnectorPathGenerator
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:86
surface
surface:
SurfaceBlockModel
Inherited from
SurfaceGroupLikeModel.surface
Source
packages/blocks/src/surface-block/element-model/base.ts:205
yMap
yMap:
Map
<unknown
>
Inherited from
SurfaceGroupLikeModel.yMap
Source
packages/blocks/src/surface-block/element-model/base.ts:203
Accessors
childElements
get
childElements():EdgelessModelType
[]
Returns
EdgelessModelType
[]
Source
packages/blocks/src/surface-block/element-model/base.ts:391
childIds
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
[]
Source
packages/blocks/src/surface-block/element-model/base.ts:387
children
connectable
get
connectable():boolean
Returns
boolean
Source
packages/blocks/src/surface-block/element-model/base.ts:124
deserializedXYWH
get
deserializedXYWH():XYWH
Returns
XYWH
Source
packages/blocks/src/surface-block/element-model/base.ts:128
display
elementBound
get
elementBound():Bound
Returns
Source
packages/blocks/src/surface-block/element-model/base.ts:166
externalBound
get
externalBound():null
|Bound
Returns
null
| Bound
Source
packages/blocks/src/surface-block/element-model/base.ts:112
externalXYWH
group
get
group():null
|SurfaceGroupLikeModel
<IBaseProps
>
Returns
null
| SurfaceGroupLikeModel
<IBaseProps
>
Source
packages/blocks/src/surface-block/element-model/base.ts:154
groups
get
groups():SurfaceGroupLikeModel
<IBaseProps
>[]
Returns
SurfaceGroupLikeModel
<IBaseProps
>[]
Source
packages/blocks/src/surface-block/element-model/base.ts:158
h
get
h():number
Returns
number
Source
packages/blocks/src/surface-block/element-model/base.ts:150
id
get
id():string
Returns
string
Source
packages/blocks/src/surface-block/element-model/base.ts:162
index
isConnected
get
isConnected():boolean
Returns
boolean
Source
packages/blocks/src/surface-block/element-model/base.ts:174
layoutType
nodeMap
get
nodeMap():Map
<string
,MindmapNode
>
Returns
Map
<string
, MindmapNode
>
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:64
opacity
rotate
get
rotate():number
set
rotate(_
):void
Parameters
• _: number
Returns
number
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:68
seed
style
styleGetter
get
styleGetter():MindmapStyleGetter
Returns
MindmapStyleGetter
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:74
tree
get
tree():MindmapRoot
Returns
MindmapRoot
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:60
type
get
type():string
Returns
string
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:56
w
get
w():number
Returns
number
Source
packages/blocks/src/surface-block/element-model/base.ts:146
x
get
x():number
Returns
number
Source
packages/blocks/src/surface-block/element-model/base.ts:138
xywh
y
get
y():number
Returns
number
Source
packages/blocks/src/surface-block/element-model/base.ts:142
Methods
_cfgBalanceLayoutDir()
private
_cfgBalanceLayoutDir():void
Returns
void
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:182
_isConnectorOutdated()
private
_isConnectorOutdated(options
,updateKey
):object
Parameters
• options
• options.connector: LocalConnectorElementModel
• options.from: MindmapNode
• options.layout: LayoutType
• options.to: MindmapNode
• updateKey: boolean
= true
Returns
object
cacheKey
cacheKey:
string
outdated
outdated:
boolean
=false
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:213
addConnector()
protected
addConnector(from
,to
,layout
,connectorStyle
,extra
):LocalConnectorElementModel
Parameters
• from: MindmapNode
• to: MindmapNode
• layout: LayoutType
• connectorStyle: ConnectorStyle
• extra: boolean
= false
Returns
LocalConnectorElementModel
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:324
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?: "after"
| "before"
= 'after'
• props?: Record
<string
, unknown
>= {}
• direction?: RIGHT
| LEFT
Force the layout direction of the node. It only works on the first level node with the layout type of BALANCE
Returns
string
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:444
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
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:623
applyStyle()
applyStyle(
fitContent
):void
Parameters
• fitContent: boolean
= false
Returns
void
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:853
boxSelect()
boxSelect(
bound
):boolean
Parameters
• bound: Bound
Returns
boolean
Inherited from
SurfaceGroupLikeModel.boxSelect
Source
packages/blocks/src/surface-block/element-model/base.ts:352
buildTree()
protected
buildTree():void
Returns
void
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:248
containedByBounds()
containedByBounds(
bounds
):boolean
Parameters
• bounds: Bound
Returns
boolean
Inherited from
SurfaceGroupLikeModel.containedByBounds
Source
packages/blocks/src/surface-block/element-model/base.ts:327
descendants()
descendants(
withoutGroup
):EdgelessModelType
[]
Get all descendants of this group
Parameters
• withoutGroup: boolean
= true
if true, will not include group element
Returns
EdgelessModelType
[]
Inherited from
SurfaceGroupLikeModel.descendants
Source
packages/blocks/src/surface-block/element-model/base.ts:470
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
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:950
getChildNodes()
getChildNodes(
id
,subtree
?):MindmapNode
[]
Parameters
• id: string
• subtree?: "right"
| "left"
The subtree of root, this only take effects when the layout type is BALANCED.
Returns
MindmapNode
[]
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:930
getConnector()
getConnector(
from
,to
):null
|LocalConnectorElementModel
Parameters
• from: MindmapNode
• to: MindmapNode
Returns
null
| LocalConnectorElementModel
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:798
getLayoutDir()
getLayoutDir(
node
):null
|LayoutType
Parameters
• node: string
| MindmapNode
Returns
null
| LayoutType
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:811
getNearestPoint()
getNearestPoint(
point
):IVec
Parameters
• point: IVec
Returns
IVec
Inherited from
SurfaceGroupLikeModel.getNearestPoint
Source
packages/blocks/src/surface-block/element-model/base.ts:333
getNode()
getNode(
id
):null
|MindmapNode
Parameters
• id: string
Returns
null
| MindmapNode
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:393
getParentNode()
getParentNode(
id
):null
|MindmapNode
Parameters
• id: string
Returns
null
| MindmapNode
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:387
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]
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:409
getRelativePointLocation()
getRelativePointLocation(
relativePoint
):PointLocation
Parameters
• relativePoint: IVec
Returns
PointLocation
Inherited from
SurfaceGroupLikeModel.getRelativePointLocation
Source
packages/blocks/src/surface-block/element-model/base.ts:343
getSiblingNode()
getSiblingNode(
id
,direction
,subtree
?):null
|MindmapNode
Parameters
• id: string
• direction: "next"
| "prev"
= 'next'
• subtree?: "right"
| "left"
The subtree of which that the sibling node belongs to, this is used when the layout type is BALANCED.
Returns
null
| MindmapNode
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:890
hasChild()
hasChild(
element
):boolean
Parameters
• element: string
| EdgelessModelType
Returns
boolean
Inherited from
SurfaceGroupLikeModel.hasChild
Source
packages/blocks/src/surface-block/element-model/base.ts:447
hasDescendant()
hasDescendant(
element
):boolean
Check if the group has the given descendant.
Parameters
• element: string
| EdgelessModelType
Returns
boolean
Inherited from
SurfaceGroupLikeModel.hasDescendant
Source
packages/blocks/src/surface-block/element-model/base.ts:458
hitTest()
hitTest(
x
,y
,_
,__
):boolean
Parameters
• x: number
• y: number
• _: IHitTestOptions
• __: EditorHost
Returns
boolean
Inherited from
SurfaceGroupLikeModel.hitTest
Source
packages/blocks/src/surface-block/element-model/base.ts:361
intersectWithLine()
intersectWithLine(
start
,end
):null
|PointLocation
[]
Parameters
• start: IVec
• end: IVec
Returns
null
| PointLocation
[]
Inherited from
SurfaceGroupLikeModel.intersectWithLine
Source
packages/blocks/src/surface-block/element-model/base.ts:338
layout()
layout(
tree
,applyStyle
,layoutType
?):void
Parameters
• tree: MindmapNode
| MindmapRoot
= undefined
• applyStyle: boolean
= true
• layoutType?: LayoutType
Returns
void
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:781
moveTo()
moveTo(
targetXYWH
):void
Parameters
• targetXYWH: XYWH
| `[${number},${number},${number},${number}]`
Returns
void
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:873
moveTree()
moveTree(
tree
,parent
,siblingIndex
,layout
?):undefined
|MindmapNode
Parameters
• tree: MindmapNode
• parent: string
| MindmapNode
• siblingIndex: number
• layout?: LayoutType
Returns
undefined
| MindmapNode
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:570
onCreated()
onCreated():
void
Returns
void
Overrides
SurfaceGroupLikeModel.onCreated
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:383
pop()
pop(
prop
):void
Parameters
• prop: string
Returns
void
Inherited from
SurfaceGroupLikeModel.pop
Source
packages/blocks/src/surface-block/element-model/base.ts:306
removeChild()
removeChild(
id
):void
Parameters
• id: string
Returns
void
Overrides
SurfaceGroupLikeModel.removeChild
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:751
requestBuildTree()
protected
requestBuildTree():void
Returns
void
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:236
requestLayout()
requestLayout():
void
Returns
void
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:842
serialize()
serialize():
SerializedElement
Returns
SerializedElement
Inherited from
SurfaceGroupLikeModel.serialize
Source
packages/blocks/src/surface-block/element-model/base.ts:365
setChildIds()
protected
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
Source
packages/blocks/src/surface-block/element-model/base.ts:422
stash()
stash(
prop
):void
Parameters
• prop: string
Returns
void
Inherited from
SurfaceGroupLikeModel.stash
Source
packages/blocks/src/surface-block/element-model/base.ts:254
stashTree()
stashTree(
node
):undefined
| () =>void
Parameters
• node: string
| MindmapNode
Returns
undefined
| () => void
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:705
traverse()
traverse(
callback
):void
Parameters
• callback
Returns
void
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:432
createFromTree()
static
createFromTree(tree
,style
,layoutType
,surface
):MindmapElementModel
Parameters
• tree: MindmapNode
• style: MindmapStyle
• layoutType: LayoutType
• surface: SurfaceBlockModel
Returns
Source
packages/blocks/src/surface-block/element-model/mindmap.ts:982
propsToY()
static
propsToY(props
):Record
<string
,unknown
>
Parameters
• props: Record
<string
, unknown
>
Returns
Record
<string
, unknown
>
Inherited from
SurfaceGroupLikeModel.propsToY
Source
packages/blocks/src/surface-block/element-model/base.ts:375