Skip to content

BlockSuite API Documentation / @blocksuite/affine-model / MindmapElementModel

Class: MindmapElementModel

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:142

Extends

Constructors

new MindmapElementModel()

new MindmapElementModel(options): MindmapElementModel

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:66

Parameters

options
id

string

model

SurfaceBlockModel

onChange

(payload) => void

stashedStore

Map<unknown, unknown>

yMap

YMap<unknown>

Returns

MindmapElementModel

Inherited from

SurfaceGroupLikeModel.constructor

Properties

_disposable

protected _disposable: DisposableGroup

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:25

Inherited from

SurfaceGroupLikeModel._disposable


_id

protected _id: string

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:26

Inherited from

SurfaceGroupLikeModel._id


_local

protected _local: Map<string | symbol, unknown>

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:27

Inherited from

SurfaceGroupLikeModel._local


_onChange()

protected _onChange: (payload) => void

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:28

Parameters

payload
local

boolean

oldValues

Record<string, unknown>

props

Record<string, unknown>

Returns

void

Inherited from

SurfaceGroupLikeModel._onChange


_preserved

protected _preserved: Map<string, unknown>

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

Used to store a copy of data in the yMap.

Inherited from

SurfaceGroupLikeModel._preserved


_stashed

protected _stashed: Map<string, unknown>

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:37

Inherited from

SurfaceGroupLikeModel._stashed


[gfxGroupCompatibleSymbol]

[gfxGroupCompatibleSymbol]: true

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

Inherited from

SurfaceGroupLikeModel.[gfxGroupCompatibleSymbol]


connectors

connectors: Map<string, LocalConnectorElementModel>

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:155


propsUpdated

propsUpdated: Subject<{ key: string; }>

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

Inherited from

SurfaceGroupLikeModel.propsUpdated


surface

surface: SurfaceBlockModel

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:42

Inherited from

SurfaceGroupLikeModel.surface


yMap

yMap: YMap<unknown>

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:44

Inherited from

SurfaceGroupLikeModel.yMap

Accessors

childElements

Get Signature

get childElements(): GfxModel[]

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:113

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


childIds

Get Signature

get childIds(): string[]

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:118

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


children

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:965

Overrides

SurfaceGroupLikeModel.children


connectable

Get Signature

get connectable(): boolean

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:45

Returns

boolean

Inherited from

SurfaceGroupLikeModel.connectable


descendantElements

Get Signature

get descendantElements(): GfxModel[]

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

Returns

GfxModel[]

Inherited from

SurfaceGroupLikeModel.descendantElements


deserializedXYWH

Get Signature

get deserializedXYWH(): XYWH

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:46

Returns

XYWH

Inherited from

SurfaceGroupLikeModel.deserializedXYWH


display

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:93

Inherited from

SurfaceGroupLikeModel.display


elementBound

Get Signature

get elementBound(): Bound

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

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


externalBound

Get Signature

get externalBound(): null | Bound

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

Returns

null | Bound

Inherited from

SurfaceGroupLikeModel.externalBound


externalXYWH

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

In some cases, you need to draw something related to the element, but it does not belong to the element itself. And it is also interactive, you can select element by clicking on it. E.g. the title of the group element. In this case, we need to store this kind of external xywh in order to do hit test. This property should not be synced to the doc. This property should be updated every time it gets rendered.

Inherited from

SurfaceGroupLikeModel.externalXYWH


group

Get Signature

get group(): null | GfxGroupModel

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

Returns

null | GfxGroupModel

Inherited from

SurfaceGroupLikeModel.group


groups

Get Signature

get groups(): GfxGroupModel[]

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:57

Return the ancestor elements in order from the most recent to the earliest.

Returns

GfxGroupModel[]

Inherited from

SurfaceGroupLikeModel.groups


h

Get Signature

get h(): number

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:58

Returns

number

Inherited from

SurfaceGroupLikeModel.h


hidden

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

Inherited from

SurfaceGroupLikeModel.hidden


id

Get Signature

get id(): string

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:59

Returns

string

Inherited from

SurfaceGroupLikeModel.id


index

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

Inherited from

SurfaceGroupLikeModel.index


isConnected

Get Signature

get isConnected(): boolean

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:60

Returns

boolean

Inherited from

SurfaceGroupLikeModel.isConnected


layoutType

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:969


lockedBySelf

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

Indicates whether the current block is explicitly locked by self. For checking the lock status of the element, use isLocked instead. For (un)locking the element, use (un)lock instead.

Inherited from

SurfaceGroupLikeModel.lockedBySelf


nodeMap

Get Signature

get nodeMap(): Map<string, MindmapNode>

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:157

Returns

Map<string, MindmapNode>


opacity

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

Inherited from

SurfaceGroupLikeModel.opacity


responseBound

Get Signature

get responseBound(): Bound

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:61

The bound of the element considering the response extension.

Returns

Bound

Inherited from

SurfaceGroupLikeModel.responseBound


responseExtension

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

Defines the extension of the response area beyond the element's bounding box. This tuple specifies the horizontal and vertical margins to be added to the element's bound.

The first value represents the horizontal extension (added to both left and right sides), and the second value represents the vertical extension (added to both top and bottom sides).

The response area is computed as: [x - horizontal, y - vertical, w + 2 * horizontal, h + 2 * vertical].

Example:

  • xywh: [0, 0, 100, 100], responseExtension: [10, 20] Resulting response area: [-10, -20, 120, 140].
  • responseExtension: [0, 0] keeps the response area equal to the bounding box.

Inherited from

SurfaceGroupLikeModel.responseExtension


rotate

Get Signature

get rotate(): number

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:161

Returns

number

Set Signature

set rotate(_): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:165

Parameters
_

number

Returns

void

Overrides

SurfaceGroupLikeModel.rotate


seed

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:106

Inherited from

SurfaceGroupLikeModel.seed


style

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:973


styleGetter

Get Signature

get styleGetter(): MindmapStyleGetter

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:167

Returns

MindmapStyleGetter


tree

Get Signature

get tree(): MindmapRoot

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:171

Returns

MindmapRoot


type

Get Signature

get type(): string

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:175

Returns

string

Overrides

SurfaceGroupLikeModel.type


w

Get Signature

get w(): number

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

Returns

number

Inherited from

SurfaceGroupLikeModel.w


x

Get Signature

get x(): number

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:64

Returns

number

Inherited from

SurfaceGroupLikeModel.x


xywh

Get Signature

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

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

Returns

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

Set Signature

set xywh(_): void

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:121

Parameters
_

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

Returns

void

Inherited from

SurfaceGroupLikeModel.xywh


y

Get Signature

get y(): number

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

Returns

number

Inherited from

SurfaceGroupLikeModel.y

Methods

_getXYWH()

protected _getXYWH(): Bound

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:253

Returns

Bound

Overrides

SurfaceGroupLikeModel._getXYWH


addChild()

addChild(_element): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:261

Parameters

_element

GfxModel

Returns

void

Deprecated

you should not call this method directly

Overrides

SurfaceGroupLikeModel.addChild


addNode()

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

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:265

Parameters

parent

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

null | string | MindmapNode

sibling?

string | number

position?

"before" | "after"

props?

Record<string, unknown> = {}

Returns

string


buildTree()

buildTree(): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:364

Returns

void


containsBound()

containsBound(bounds): boolean

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

Parameters

bounds

Bound

Returns

boolean

Inherited from

SurfaceGroupLikeModel.containsBound


getChildNodes()

getChildNodes(id, subtree?): MindmapNode[]

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:472

Parameters

id

string

subtree?

The subtree of root, this only take effects when the layout type is BALANCED.

"left" | "right"

Returns

MindmapNode[]


getConnectors()

getConnectors(node): null | object[]

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:491

Get all the connectors start from the given node

Parameters

node

MindmapNode

Returns

null | object[]


getLayoutDir()

getLayoutDir(node): LayoutType

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:587

Parameters

node

string | MindmapNode

Returns

LayoutType


getLineIntersections()

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

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

Parameters

start

IVec

end

IVec

Returns

null | PointLocation[]

Inherited from

SurfaceGroupLikeModel.getLineIntersections


getNearestPoint()

getNearestPoint(point): IVec

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

Parameters

point

IVec

Returns

IVec

Inherited from

SurfaceGroupLikeModel.getNearestPoint


getNode()

getNode(id): null | MindmapNode

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:621

Parameters

id

string

Returns

null | MindmapNode


getNodeByPath()

getNodeByPath(path): null | MindmapNode

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:625

Parameters

path

number[]

Returns

null | MindmapNode


getParentNode()

getParentNode(id): null | MindmapNode

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:634

Parameters

id

string

Returns

null | MindmapNode


getPath()

getPath(element): number[]

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:652

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]

getRelativePointLocation()

getRelativePointLocation(relativePoint): PointLocation

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

Parameters

relativePoint

IVec

Returns

PointLocation

Inherited from

SurfaceGroupLikeModel.getRelativePointLocation


getSiblingNode()

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

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:675

Parameters

id

string

direction

"prev" | "next"

subtree?

The subtree of which that the sibling node belongs to, this is used when the layout type is BALANCED.

"left" | "right"

Returns

null | MindmapNode


hasChild()

hasChild(element): boolean

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:128

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

Parameters

element

GfxCompatibleInterface

Returns

boolean

Inherited from

SurfaceGroupLikeModel.hasChild


hasDescendant()

hasDescendant(element): boolean

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:132

Check if the group has the given descendant.

Parameters

element

GfxCompatibleInterface

Returns

boolean

Inherited from

SurfaceGroupLikeModel.hasDescendant


includesPoint()

includesPoint(x, y, options): boolean

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:710

Parameters

x

number

y

number

options

PointTestOptions

Returns

boolean

Overrides

SurfaceGroupLikeModel.includesPoint


intersectsBound()

intersectsBound(bound): boolean

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

Parameters

bound

Bound

Returns

boolean

Inherited from

SurfaceGroupLikeModel.intersectsBound


isLocked()

isLocked(): boolean

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

Check if the element is locked. It will check the lock status of the element and its ancestors.

Returns

boolean

Inherited from

SurfaceGroupLikeModel.isLocked


isLockedByAncestor()

isLockedByAncestor(): boolean

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

Returns

boolean

Inherited from

SurfaceGroupLikeModel.isLockedByAncestor


isLockedBySelf()

isLockedBySelf(): boolean

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

Returns

boolean

Inherited from

SurfaceGroupLikeModel.isLockedBySelf


layout()

layout(_tree, _options): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:721

Parameters

_tree

MindmapNode | MindmapRoot

_options
applyStyle?

boolean

calculateTreeBound?

boolean

layoutType?

LayoutType

stashed?

boolean

Returns

void


lock()

lock(): void

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

Returns

void

Inherited from

SurfaceGroupLikeModel.lock


moveTo()

moveTo(targetXYWH): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:741

Parameters

targetXYWH

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

Returns

void


onCreated()

onCreated(): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:758

Returns

void

Overrides

SurfaceGroupLikeModel.onCreated


onDestroyed()

onDestroyed(): void

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

Returns

void

Inherited from

SurfaceGroupLikeModel.onDestroyed


pop()

pop(prop): void

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:89

Parameters

prop

string

Returns

void

Inherited from

SurfaceGroupLikeModel.pop


removeChild()

removeChild(element): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:762

Remove the child from the group

Parameters

element

GfxModel

Returns

void

Overrides

SurfaceGroupLikeModel.removeChild


requestBuildTree()

protected requestBuildTree(): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:792

Returns

void


requestLayout()

requestLayout(): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:804

Returns

void


serialize()

serialize(): SerializedMindmapElement

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:815

Returns

SerializedMindmapElement

Overrides

SurfaceGroupLikeModel.serialize


setChildIds()

setChildIds(value, fromLocal): void

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:142

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


setLayoutMethod()

setLayoutMethod(layoutMethod): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:820

Parameters

layoutMethod

(_tree, _options) => void

Returns

void


stash()

stash(prop): void

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:91

Parameters

prop

string

Returns

void

Inherited from

SurfaceGroupLikeModel.stash


stashTree()

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

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:829

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


toggleCollapse()

toggleCollapse(node, options): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:856

Parameters

node

MindmapNode

options
layout?

boolean

Returns

void


traverse()

traverse(callback, root, options): void

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:893

Parameters

callback

(node, parent) => void

root

MindmapNode = ...

options
stopOnCollapse?

boolean

Returns

void


unlock()

unlock(): void

Defined in: packages/framework/block-std/dist/gfx/model/surface/element-model.d.ts:92

Returns

void

Inherited from

SurfaceGroupLikeModel.unlock


propsToY()

static propsToY(props): MindmapElementProps

Defined in: packages/affine/model/src/elements/mindmap/mindmap.ts:179

Parameters

props

Record<string, unknown>

Returns

MindmapElementProps