BlockSuite API Documentation / @blocksuite/affine-block-surface / MindmapUtils
Variable: MindmapUtils
const
MindmapUtils:object
Type declaration
addTree()
addTree: (
mindmap
,parent
,tree
,sibling
?) =>undefined
|null
|MindmapNode
Parameters
mindmap
parent
string
| MindmapNode
tree
MindmapNode
| Node
sibling?
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.
string
| number
Returns
undefined
| null
| MindmapNode
containsNode()
containsNode: (
mindmap
,targetNode
,searchParent
?) =>boolean
Check if the mind map contains the target node.
Parameters
mindmap
Mind map to check
targetNode
Node to check
searchParent?
If provided, check if the node is a descendant of the parent node. Otherwise, check the whole mind map.
Returns
boolean
createFromTree()
createFromTree: (
tree
,style
,layoutType
,surface
) =>MindmapElementModel
Parameters
tree
style
layoutType
surface
Returns
detachMindmap()
detachMindmap: (
mindmap
,subtree
) =>undefined
|MindmapNode
Detach a mindmap node or subtree. 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
mindmap
the mind map that the subtree belongs to
subtree
the subtree to detach
string
| MindmapNode
Returns
undefined
| MindmapNode
findTargetNode()
findTargetNode: (
mindmap
,position
) =>MindmapNode
|null
Parameters
mindmap
position
IVec
Returns
MindmapNode
| null
hideNodeConnector()
hideNodeConnector: (
mindmap
,target
) =>undefined
| () =>void
Hide the connector between the target node and its parent
Parameters
mindmap
target
The mind map node which's connector will be hide
Returns
undefined
| () => void
moveNode()
moveNode: (
from
,subtree
,to
,parent
,index
) =>void
|MindmapNode
Move a subtree from one mind map to another
Parameters
from
the mind map that the subtree
belongs to
subtree
the subtree to move
to
the mind map to move the subtree
to
parent
the new parent node to attach the subtree
to
string
| MindmapNode
index
number
the index to insert the subtree
at
Returns
void
| MindmapNode
tryMoveNode()
tryMoveNode: (
targetMindMap
,target
,sourceMindMap
,source
,position
,callback
) =>null
| {abort
: () =>void
;merge
: () =>void
; }
Try to move a node to another mind map. It will show a merge indicator if the node can be merged to the target mind map.
Parameters
targetMindMap
target
sourceMindMap
source
position
IVec
callback
(option
) => () => void
Returns
null
| { abort
: () => void
; merge
: () => void
; }
return two functions, abort
and merge
. abort
will cancel the operation and merge
will merge the node to the target mind map.
Defined in
packages/affine/block-surface/src/index.ts:145