Skip to content

BlockSuite API Documentation / @blocksuite/blocks / MindmapElementModel

Class: MindmapElementModel

Extends

Extended by

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

MindmapElementModel

Inherited from

SurfaceGroupLikeModel.constructor

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:56

Properties

_disposable

protected _disposable: DisposableGroup

Inherited from

SurfaceGroupLikeModel._disposable

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:22


_id

protected _id: string

Inherited from

SurfaceGroupLikeModel._id

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:23


_local

protected _local: Map<string | symbol, unknown>

Inherited from

SurfaceGroupLikeModel._local

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:24


_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/model/surface/element-model.d.ts:25


_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:33


_stashed

protected _stashed: Map<string, unknown>

Inherited from

SurfaceGroupLikeModel._stashed

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:34


[gfxGroupCompatibleSymbol]

[gfxGroupCompatibleSymbol]: true

Inherited from

SurfaceGroupLikeModel.[gfxGroupCompatibleSymbol]

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:88


connectors

connectors: Map<string, LocalConnectorElementModel>

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:67


extraConnectors

extraConnectors: Map<string, LocalConnectorElementModel>

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:68


surface

surface: SurfaceBlockModel

Inherited from

SurfaceGroupLikeModel.surface

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:36


yMap

yMap: YMap<unknown>

Inherited from

SurfaceGroupLikeModel.yMap

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:38

Accessors

childElements

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


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[]

Inherited from

SurfaceGroupLikeModel.childIds

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:94


children

Overrides

SurfaceGroupLikeModel.children

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:140


connectable

get connectable(): boolean

Returns

boolean

Inherited from

SurfaceGroupLikeModel.connectable

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:39


descendantElements

get descendantElements(): GfxModel[]

Returns

GfxModel[]

Inherited from

SurfaceGroupLikeModel.descendantElements

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:95


deserializedXYWH

get deserializedXYWH(): XYWH

Returns

XYWH

Inherited from

SurfaceGroupLikeModel.deserializedXYWH

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:40


display

Inherited from

SurfaceGroupLikeModel.display

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:78


elementBound

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


externalBound

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


externalXYWH

Inherited from

SurfaceGroupLikeModel.externalXYWH

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:79


group

get group(): null | GfxGroupModel

Returns

null | GfxGroupModel

Inherited from

SurfaceGroupLikeModel.group

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:47


groups

get groups(): GfxGroupModel[]

Returns

GfxGroupModel[]

Inherited from

SurfaceGroupLikeModel.groups

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:48


h

get h(): number

Returns

number

Inherited from

SurfaceGroupLikeModel.h

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:49


id

get id(): string

Returns

string

Inherited from

SurfaceGroupLikeModel.id

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:50


index

Inherited from

SurfaceGroupLikeModel.index

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:80


isConnected

get isConnected(): boolean

Returns

boolean

Inherited from

SurfaceGroupLikeModel.isConnected

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:51


layoutType

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:141


nodeMap

get nodeMap(): Map<string, MindmapNode>

Returns

Map<string, MindmapNode>

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:69


opacity

Inherited from

SurfaceGroupLikeModel.opacity

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:81


rotate

get rotate(): number

set rotate(_): void

Parameters

_: number

Returns

number

Overrides

SurfaceGroupLikeModel.rotate

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:70


seed

Inherited from

SurfaceGroupLikeModel.seed

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:82


style

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:142


styleGetter

get styleGetter(): MindmapStyleGetter

Returns

MindmapStyleGetter

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:72


tree

get tree(): MindmapRoot

Returns

MindmapRoot

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:73


type

get type(): string

Returns

string

Overrides

SurfaceGroupLikeModel.type

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:74


w

get w(): number

Returns

number

Inherited from

SurfaceGroupLikeModel.w

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:53


x

get x(): number

Returns

number

Inherited from

SurfaceGroupLikeModel.x

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:54


xywh

get xywh(): `[${number},${number},${number},${number}]`

set xywh(_): void

Parameters

_: `[${number},${number},${number},${number}]`

Returns

`[${number},${number},${number},${number}]`

Inherited from

SurfaceGroupLikeModel.xywh

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:96


y

get y(): number

Returns

number

Inherited from

SurfaceGroupLikeModel.y

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:55

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


addConnector()

protected addConnector(from, to, layout, connectorStyle, extra?): LocalConnectorElementModel

Parameters

from: MindmapNode

to: MindmapNode

layout: LayoutType

connectorStyle: ConnectorStyle

extra?: boolean

Returns

LocalConnectorElementModel

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:84


addNode()

addNode(parent, sibling?, position?, props?): 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>

Returns

string

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:85


buildTree()

buildTree(): void

Returns

void

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:90


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


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

MindmapNode[]

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:96


getConnector()

getConnector(from, to): null | LocalConnectorElementModel

Parameters

from: MindmapNode

to: MindmapNode

Returns

null | LocalConnectorElementModel

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:97


getLayoutDir()

getLayoutDir(node): LayoutType

Parameters

node: string | MindmapNode

Returns

LayoutType

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:98


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


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


getNode()

getNode(id): null | MindmapNode

Parameters

id: string

Returns

null | MindmapNode

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:99


getParentNode()

getParentNode(id): null | MindmapNode

Parameters

id: string

Returns

null | MindmapNode

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:100


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

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

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:113


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


getSiblingNode()

getSiblingNode(id, direction?, subtree?): null | MindmapNode

Parameters

id: string

direction?: "prev" | "next"

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/model/dist/elements/mindmap/mindmap.d.ts:114


hasChild()

hasChild(element): boolean

The actual field that stores the children of the group. It should be a ymap decorated with @field.

Parameters

element: GfxModel

Returns

boolean

Inherited from

SurfaceGroupLikeModel.hasChild

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:104


hasDescendant()

hasDescendant(element): boolean

Check if the group has the given descendant.

Parameters

element: GfxModel

Returns

boolean

Inherited from

SurfaceGroupLikeModel.hasDescendant

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:108


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


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


layout()

layout(_tree?, _options?): void

Parameters

_tree?: MindmapNode | MindmapRoot

_options?

_options.applyStyle?: boolean

_options.calculateTreeBound?: boolean

_options.layoutType?: LayoutType

_options.stashed?: boolean

Returns

void

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:121


moveTo()

moveTo(targetXYWH): void

Parameters

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

Returns

void

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:127


onCreated()

onCreated(): void

Returns

void

Overrides

SurfaceGroupLikeModel.onCreated

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:128


pop()

pop(prop): void

Parameters

prop: string

Returns

void

Inherited from

SurfaceGroupLikeModel.pop

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:75


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


requestBuildTree()

protected requestBuildTree(): void

Returns

void

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:130


requestLayout()

requestLayout(): void

Returns

void

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:131


serialize()

serialize(): SerializedMindmapElement

Returns

SerializedMindmapElement

Overrides

SurfaceGroupLikeModel.serialize

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:132


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


stash()

stash(prop): void

Parameters

prop: string

Returns

void

Inherited from

SurfaceGroupLikeModel.stash

Defined in

packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:77


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


traverse()

traverse(callback): void

Parameters

callback

Returns

void

Defined in

packages/affine/model/dist/elements/mindmap/mindmap.d.ts:139


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