Skip to content

BlockSuite API Documentation / @blocksuite/blocks / MindmapElementModel

Class: MindmapElementModel

Extends

  • GroupLikeModel<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

MindmapElementModel

Inherited from

GroupLikeModel<MindmapElementProps>.constructor

Source

packages/blocks/src/surface-block/element-model/base.ts:118

Properties

_disposable

protected _disposable: DisposableGroup

Inherited from

GroupLikeModel._disposable

Source

packages/blocks/src/surface-block/element-model/base.ts:76


_id

protected _id: string

Inherited from

GroupLikeModel._id

Source

packages/blocks/src/surface-block/element-model/base.ts:77


_local

protected _local: Map<string | symbol, unknown>

Inherited from

GroupLikeModel._local

Source

packages/blocks/src/surface-block/element-model/base.ts:70


_nodeMap

private _nodeMap: Map<string, MindmapNode>

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:160


_onChange()

protected _onChange: (payload) => void

Parameters

payload

payload.local: boolean

payload.oldValues: Record<string, unknown>

payload.props: Record<string, unknown>

Returns

void

Inherited from

GroupLikeModel._onChange

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

GroupLikeModel._preserved

Source

packages/blocks/src/surface-block/element-model/base.ts:68


_queued

private _queued: boolean = false

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:548


_stashed

protected _stashed: Map<string, unknown>

Inherited from

GroupLikeModel._stashed

Source

packages/blocks/src/surface-block/element-model/base.ts:69


_tree

private _tree: MindmapRoot

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:158


children

children: Map<NodeDetail>

Overrides

GroupLikeModel.children

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:122


connectors

connectors: Map<string, LocalConnectorElementModel>

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:156


display

display: boolean = true

Inherited from

GroupLikeModel.display

Source

packages/blocks/src/surface-block/element-model/base.ts:95


externalXYWH

externalXYWH: undefined | `[${number},${number},${number},${number}]` = undefined

Inherited from

GroupLikeModel.externalXYWH

Source

packages/blocks/src/surface-block/element-model/base.ts:104


index

index: string

Inherited from

GroupLikeModel.index

Source

packages/blocks/src/surface-block/element-model/base.ts:89


layoutType

layoutType: LayoutType = LayoutType.BALANCE

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:146


opacity

opacity: number = 1

Inherited from

GroupLikeModel.opacity

Source

packages/blocks/src/surface-block/element-model/base.ts:98


pathGenerator

pathGenerator: ConnectorPathGenerator

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:66


seed

seed: number

Inherited from

GroupLikeModel.seed

Source

packages/blocks/src/surface-block/element-model/base.ts:92


style

style: MindmapStyle = MindmapStyle.FOUR

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:154


surface

surface: SurfaceBlockModel

Inherited from

GroupLikeModel.surface

Source

packages/blocks/src/surface-block/element-model/base.ts:80


xywh

xywh: `[${number},${number},${number},${number}]` = '[0,0,0,0]'

Inherited from

GroupLikeModel.xywh

Source

packages/blocks/src/surface-block/element-model/base.ts:388


yMap

yMap: Map<unknown>

Inherited from

GroupLikeModel.yMap

Source

packages/blocks/src/surface-block/element-model/base.ts:79

Accessors

childElements

get childElements(): EdgelessModel[]

Returns

EdgelessModel[]

Source

packages/blocks/src/surface-block/element-model/base.ts:373


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:338


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

Bound

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


isConnected

get isConnected(): boolean

Returns

boolean

Source

packages/blocks/src/surface-block/element-model/base.ts:195


nodeMap

get nodeMap(): Map<string, MindmapNode>

Returns

Map<string, MindmapNode>

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:166


rotate

get rotate(): number

set rotate(_): void

Parameters

_: number

Returns

number

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:170


styleGetter

get styleGetter(): MindmapStyleGetter

Returns

MindmapStyleGetter

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:176


tree

get tree(): MindmapRoot

Returns

MindmapRoot

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:162


type

get type(): string

Returns

string

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:57


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

_cfgBalanceLayoutDir()

private _cfgBalanceLayoutDir(): void

Returns

void

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:241


_getPath()

private _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

ts
const path = mindmap.getPath('nodeId');
// [0, 1, 2]

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:283


addConnector()

protected addConnector(from, to, layout, connectorStyle): void

Parameters

from: MindmapNode

to: MindmapNode

layout: LayoutType

connectorStyle: ConnectorStyle

Returns

void

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:490


addNode()

addNode(parent, type, sibling?, position?, props?, direction?): string

Parameters

parent: null | string

The parent node id of the new node. If it's null, the node will be the root node

type: "shape"

sibling?: string

position?: "before" | "after"= '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:306


addTree()

addTree(parent, tree, sibling?): string

Parameters

parent: null | string

tree: Node

sibling?: string

Returns

string

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:411


applyStyle()

applyStyle(): void

Returns

void

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:561


boxSelect()

boxSelect(bound): boolean

Parameters

bound: Bound

Returns

boolean

Inherited from

GroupLikeModel.boxSelect

Source

packages/blocks/src/surface-block/element-model/base.ts:301


buildTree()

protected buildTree(): void

Returns

void

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:180


calcConnection()

calcConnection(): void

Returns

void

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:462


containedByBounds()

containedByBounds(bounds): boolean

Parameters

bounds: Bound

Returns

boolean

Inherited from

GroupLikeModel.containedByBounds

Source

packages/blocks/src/surface-block/element-model/base.ts:276


decendants()

decendants(withoutGroup): EdgelessModel[]

Get all decendants of this group

Parameters

withoutGroup: boolean= true

if true, will not include group element

Returns

EdgelessModel[]

Inherited from

GroupLikeModel.decendants

Source

packages/blocks/src/surface-block/element-model/base.ts:406


getChildNodes()

getChildNodes(id, subtree?): ElementModel<BaseProps>[]

Parameters

id: string

subtree?: "right" | "left"

Returns

ElementModel<BaseProps>[]

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:637


getLayoutDir()

getLayoutDir(element): null | LayoutType

Parameters

element: string | EdgelessModel

Returns

null | LayoutType

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:523


getNearestPoint()

getNearestPoint(point): IVec

Parameters

point: IVec

Returns

IVec

Inherited from

GroupLikeModel.getNearestPoint

Source

packages/blocks/src/surface-block/element-model/base.ts:282


getNode()

getNode(id): null | MindmapNode

Parameters

id: string

Returns

null | MindmapNode

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:267


getParentNode()

getParentNode(id): null | ElementModel<BaseProps>

Parameters

id: string

Returns

null | ElementModel<BaseProps>

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:261


getRelativePointLocation()

getRelativePointLocation(relativePoint): PointLocation

Parameters

relativePoint: IVec

Returns

PointLocation

Inherited from

GroupLikeModel.getRelativePointLocation

Source

packages/blocks/src/surface-block/element-model/base.ts:292


getSiblingNode()

getSiblingNode(id, direction, subtree?): null | ElementModel<BaseProps>

Parameters

id: string

direction: "prev" | "next"= 'next'

subtree?: "right" | "left"

Returns

null | ElementModel<BaseProps>

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:606


hasDescendant()

hasDescendant(element): boolean

Check if the group has the given descendant.

Parameters

element: string | EdgelessModel

Returns

boolean

Inherited from

GroupLikeModel.hasDescendant

Source

packages/blocks/src/surface-block/element-model/base.ts:393


hitTest()

hitTest(x, y, _, __): boolean

Parameters

x: number

y: number

_: HitTestOptions

__: EditorHost

Returns

boolean

Inherited from

GroupLikeModel.hitTest

Source

packages/blocks/src/surface-block/element-model/base.ts:310


intersectWithLine()

intersectWithLine(start, end): null | PointLocation[]

Parameters

start: IVec

end: IVec

Returns

null | PointLocation[]

Inherited from

GroupLikeModel.intersectWithLine

Source

packages/blocks/src/surface-block/element-model/base.ts:287


layout()

layout(): void

Returns

void

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:454


moveTo()

moveTo(targetXYWH): void

Parameters

targetXYWH: XYWH | `[${number},${number},${number},${number}]`

Returns

void

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:589


onCreated()

onCreated(): void

Returns

void

Overrides

GroupLikeModel.onCreated

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:61


pop()

pop(prop): void

Parameters

prop: string

Returns

void

Inherited from

GroupLikeModel.pop

Source

packages/blocks/src/surface-block/element-model/base.ts:254


removeDescendant()

removeDescendant(id): void

Parameters

id: string

Returns

void

Overrides

GroupLikeModel.removeDescendant

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:431


requestLayout()

requestLayout(): void

Returns

void

Source

packages/blocks/src/surface-block/element-model/mindmap.ts:550


serialize()

serialize(): object

Returns

object

Inherited from

GroupLikeModel.serialize

Source

packages/blocks/src/surface-block/element-model/base.ts:314


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 happend in the local

Returns

void

Inherited from

GroupLikeModel.setChildIds

Source

packages/blocks/src/surface-block/element-model/base.ts:348


stash()

stash(prop): void

Parameters

prop: string

Returns

void

Inherited from

GroupLikeModel.stash

Source

packages/blocks/src/surface-block/element-model/base.ts:199


propsToY()

static propsToY(props): Record<string, unknown>

Parameters

props: Record<string, unknown>

Returns

Record<string, unknown>

Inherited from

GroupLikeModel.propsToY

Source

packages/blocks/src/surface-block/element-model/base.ts:57