Skip to content

BlockSuite API Documentation / @blocksuite/blocks / LayoutableMindmapElementModel

Class: LayoutableMindmapElementModel

Extends

Constructors

new LayoutableMindmapElementModel()

new LayoutableMindmapElementModel(options): LayoutableMindmapElementModel

Parameters

options

options.id: string

options.model: SurfaceBlockModel

options.onChange

options.stashedStore: Map<unknown, unknown>

options.yMap: YMap<unknown>

Returns

LayoutableMindmapElementModel

Inherited from

MindmapElementModel.constructor

Defined in

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

Properties

_disposable

protected _disposable: DisposableGroup

Inherited from

MindmapElementModel._disposable

Defined in

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


_id

protected _id: string

Inherited from

MindmapElementModel._id

Defined in

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


_local

protected _local: Map<string | symbol, unknown>

Inherited from

MindmapElementModel._local

Defined in

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


_onChange()

protected _onChange: (payload) => void

Parameters

payload

payload.local: boolean

payload.oldValues: Record<string, unknown>

payload.props: Record<string, unknown>

Returns

void

Inherited from

MindmapElementModel._onChange

Defined in

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


_preserved

protected _preserved: Map<string, unknown>

Used to store a copy of data in the yMap.

Inherited from

MindmapElementModel._preserved

Defined in

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


_stashed

protected _stashed: Map<string, unknown>

Inherited from

MindmapElementModel._stashed

Defined in

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


[gfxContainerSymbol]

[gfxContainerSymbol]: true

Inherited from

MindmapElementModel.[gfxContainerSymbol]

Defined in

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


connectors

connectors: Map<string, LocalConnectorElementModel>

Inherited from

MindmapElementModel.connectors

Defined in

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


extraConnectors

extraConnectors: Map<string, LocalConnectorElementModel>

Inherited from

MindmapElementModel.extraConnectors

Defined in

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


surface

surface: SurfaceBlockModel

Inherited from

MindmapElementModel.surface

Defined in

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


yMap

yMap: YMap<unknown>

Inherited from

MindmapElementModel.yMap

Defined in

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

Accessors

childElements

get childElements(): GfxModel[]

! Note that childElements may not match the childIds during doc loading stage.

Returns

GfxModel[]

Inherited from

MindmapElementModel.childElements

Defined in

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


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

MindmapElementModel.childIds

Defined in

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


children

Inherited from

MindmapElementModel.children

Defined in

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


connectable

get connectable(): boolean

Returns

boolean

Inherited from

MindmapElementModel.connectable

Defined in

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


container

get container(): null | GfxModel & GfxContainerElement

Returns

null | GfxModel & GfxContainerElement

Inherited from

MindmapElementModel.container

Defined in

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


descendantElements

get descendantElements(): GfxModel[]

Returns

GfxModel[]

Inherited from

MindmapElementModel.descendantElements

Defined in

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


deserializedXYWH

get deserializedXYWH(): XYWH

Returns

XYWH

Inherited from

MindmapElementModel.deserializedXYWH

Defined in

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


display

Inherited from

MindmapElementModel.display

Defined in

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


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

MindmapElementModel.elementBound

Defined in

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


externalBound

get externalBound(): null | Bound

Returns

null | Bound

Inherited from

MindmapElementModel.externalBound

Defined in

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


externalXYWH

Inherited from

MindmapElementModel.externalXYWH

Defined in

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


group

get group(): null | SurfaceGroupLikeModel<BaseElementProps>

Returns

null | SurfaceGroupLikeModel<BaseElementProps>

Inherited from

MindmapElementModel.group

Defined in

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


groups

get groups(): SurfaceGroupLikeModel<BaseElementProps>[]

Returns

SurfaceGroupLikeModel<BaseElementProps>[]

Inherited from

MindmapElementModel.groups

Defined in

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


h

get h(): number

Returns

number

Inherited from

MindmapElementModel.h

Defined in

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


id

get id(): string

Returns

string

Inherited from

MindmapElementModel.id

Defined in

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


index

Inherited from

MindmapElementModel.index

Defined in

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


isConnected

get isConnected(): boolean

Returns

boolean

Inherited from

MindmapElementModel.isConnected

Defined in

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


layoutType

Inherited from

MindmapElementModel.layoutType

Defined in

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


nodeMap

get nodeMap(): Map<string, MindmapNode>

Returns

Map<string, MindmapNode>

Inherited from

MindmapElementModel.nodeMap

Defined in

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


opacity

Inherited from

MindmapElementModel.opacity

Defined in

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


rotate

get rotate(): number

set rotate(_): void

Parameters

_: number

Returns

number

Inherited from

MindmapElementModel.rotate

Defined in

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


seed

Inherited from

MindmapElementModel.seed

Defined in

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


style

Inherited from

MindmapElementModel.style

Defined in

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


styleGetter

get styleGetter(): MindmapStyleGetter

Returns

MindmapStyleGetter

Inherited from

MindmapElementModel.styleGetter

Defined in

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


tree

get tree(): MindmapRoot

Returns

MindmapRoot

Inherited from

MindmapElementModel.tree

Defined in

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


type

get type(): string

Returns

string

Inherited from

MindmapElementModel.type

Defined in

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


w

get w(): number

Returns

number

Inherited from

MindmapElementModel.w

Defined in

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


x

get x(): number

Returns

number

Inherited from

MindmapElementModel.x

Defined in

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


xywh

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

set xywh(_): void

Parameters

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

Returns

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

Inherited from

MindmapElementModel.xywh

Defined in

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


y

get y(): number

Returns

number

Inherited from

MindmapElementModel.y

Defined in

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

Methods

addChild()

addChild(_element): void

Parameters

_element: GfxModel

Returns

void

Deprecated

you should not call this method directly

Inherited from

MindmapElementModel.addChild

Defined in

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


addConnector()

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

Parameters

from: MindmapNode

to: MindmapNode

layout: LayoutType

connectorStyle: ConnectorStyle

extra?: boolean

Returns

LocalConnectorElementModel

Inherited from

MindmapElementModel.addConnector

Defined in

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


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?: "after" | "before"

props?: Record<string, unknown>

Returns

string

Inherited from

MindmapElementModel.addNode

Defined in

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


buildTree()

buildTree(): void

Returns

void

Inherited from

MindmapElementModel.buildTree

Defined in

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


containsBound()

containsBound(bounds): boolean

Parameters

bounds: Bound

Returns

boolean

Inherited from

MindmapElementModel.containsBound

Defined in

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


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

Inherited from

MindmapElementModel.getChildNodes

Defined in

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


getConnector()

getConnector(from, to): null | LocalConnectorElementModel

Parameters

from: MindmapNode

to: MindmapNode

Returns

null | LocalConnectorElementModel

Inherited from

MindmapElementModel.getConnector

Defined in

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


getLayoutDir()

getLayoutDir(node): null | LayoutType

Parameters

node: string | MindmapNode

Returns

null | LayoutType

Inherited from

MindmapElementModel.getLayoutDir

Defined in

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


getLineIntersections()

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

Parameters

start: IVec

end: IVec

Returns

null | PointLocation[]

Inherited from

MindmapElementModel.getLineIntersections

Defined in

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


getNearestPoint()

getNearestPoint(point): IVec

Parameters

point: IVec

Returns

IVec

Inherited from

MindmapElementModel.getNearestPoint

Defined in

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


getNode()

getNode(id): null | MindmapNode

Parameters

id: string

Returns

null | MindmapNode

Inherited from

MindmapElementModel.getNode

Defined in

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


getParentNode()

getParentNode(id): null | MindmapNode

Parameters

id: string

Returns

null | MindmapNode

Inherited from

MindmapElementModel.getParentNode

Defined in

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


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]

Inherited from

MindmapElementModel.getPath

Defined in

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


getRelativePointLocation()

getRelativePointLocation(relativePoint): PointLocation

Parameters

relativePoint: IVec

Returns

PointLocation

Inherited from

MindmapElementModel.getRelativePointLocation

Defined in

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


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

Inherited from

MindmapElementModel.getSiblingNode

Defined in

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


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

MindmapElementModel.hasChild

Defined in

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


hasDescendant()

hasDescendant(element): boolean

Check if the group has the given descendant.

Parameters

element: GfxModel

Returns

boolean

Inherited from

MindmapElementModel.hasDescendant

Defined in

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


includesPoint()

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

Parameters

x: number

y: number

_: PointTestOptions

__: EditorHost

Returns

boolean

Inherited from

MindmapElementModel.includesPoint

Defined in

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


intersectsBound()

intersectsBound(bound): boolean

Parameters

bound: Bound

Returns

boolean

Inherited from

MindmapElementModel.intersectsBound

Defined in

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


layout()

layout(): void

Returns

void

Overrides

MindmapElementModel.layout

Defined in

packages/affine/block-surface/dist/utils/mindmap/utils.d.ts:4


moveTo()

moveTo(targetXYWH): void

Parameters

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

Returns

void

Inherited from

MindmapElementModel.moveTo

Defined in

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


onCreated()

onCreated(): void

Returns

void

Inherited from

MindmapElementModel.onCreated

Defined in

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


pop()

pop(prop): void

Parameters

prop: string

Returns

void

Inherited from

MindmapElementModel.pop

Defined in

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


removeChild()

removeChild(element): void

Remove the child from the group

Parameters

element: GfxModel

Returns

void

Inherited from

MindmapElementModel.removeChild

Defined in

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


requestBuildTree()

protected requestBuildTree(): void

Returns

void

Inherited from

MindmapElementModel.requestBuildTree

Defined in

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


requestLayout()

requestLayout(): void

Returns

void

Inherited from

MindmapElementModel.requestLayout

Defined in

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


serialize()

serialize(): SerializedMindmapElement

Returns

SerializedMindmapElement

Inherited from

MindmapElementModel.serialize

Defined in

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


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

MindmapElementModel.setChildIds

Defined in

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


stash()

stash(prop): void

Parameters

prop: string

Returns

void

Inherited from

MindmapElementModel.stash

Defined in

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


stashTree()

stashTree(node): undefined | () => void

Parameters

node: string | MindmapNode

Returns

undefined | () => void

Inherited from

MindmapElementModel.stashTree

Defined in

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


traverse()

traverse(callback): void

Parameters

callback

Returns

void

Inherited from

MindmapElementModel.traverse

Defined in

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


propsToY()

static propsToY(props): MindmapElementProps

Parameters

props: Record<string, unknown>

Returns

MindmapElementProps

Inherited from

MindmapElementModel.propsToY

Defined in

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