Skip to content

BlockSuite API Documentation / @blocksuite/blocks / SurfaceBlockModel

Class: SurfaceBlockModel

Extends

Constructors

new SurfaceBlockModel()

new SurfaceBlockModel(): SurfaceBlockModel

Returns

SurfaceBlockModel

Overrides

BlockModel<SurfaceBlockProps>.constructor

Source

packages/blocks/src/surface-block/surface-model.ts:213

Properties

[modelLabel]

[modelLabel]: SurfaceBlockProps

Inherited from

BlockModel.[modelLabel]

Source

packages/framework/store/dist/schema/base.d.ts:101


_connectorToElements

private _connectorToElements: Map<string, string[]>

Source

packages/blocks/src/surface-block/surface-model.ts:186


_disposables

private _disposables: DisposableGroup

Source

packages/blocks/src/surface-block/surface-model.ts:183


_elementModels

private _elementModels: Map<string, object>

Source

packages/blocks/src/surface-block/surface-model.ts:179


_elementToConnector

private _elementToConnector: Map<string, string[]>

Source

packages/blocks/src/surface-block/surface-model.ts:187


_elementToGroup

private _elementToGroup: Map<string, string>

Source

packages/blocks/src/surface-block/surface-model.ts:185


_groupToElements

private _groupToElements: Map<string, string[]>

Source

packages/blocks/src/surface-block/surface-model.ts:184


childrenUpdated

childrenUpdated: Slot<void>

Inherited from

BlockModel.childrenUpdated

Source

packages/framework/store/dist/schema/base.d.ts:120


created

created: Slot<void>

Inherited from

BlockModel.created

Source

packages/framework/store/dist/schema/base.d.ts:115


deleted

deleted: Slot<void>

Inherited from

BlockModel.deleted

Source

packages/framework/store/dist/schema/base.d.ts:116


elementAdded

elementAdded: Slot<object>

Type declaration

id

id: string

local

local: boolean

Source

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


elementRemoved

elementRemoved: Slot<object>

Type declaration

id

id: string

local

local: boolean

model

model: ElementModel<BaseProps>

type

type: string

Source

packages/blocks/src/surface-block/surface-model.ts:200


elementUpdated

elementUpdated: Slot<ElementUpdatedData>

Source

packages/blocks/src/surface-block/surface-model.ts:198


elements

elements: Boxed<Map<Map<unknown>>>

Inherited from

BlockModel.elements

Source

packages/blocks/src/surface-block/surface-model.ts:36


flavour

flavour: string

Inherited from

BlockModel.flavour

Source

packages/framework/store/dist/schema/base.d.ts:103


hooks

protected hooks: object

Hooks is used to attach extra logic when calling addElementupdateElement(or assign property directly) and removeElement. It's usefull when dealing with relation between different model.

remove

remove: Slot<object>

Type declaration
id

id: string

model

model: ElementModel<BaseProps>

type

type: string

update

update: Slot<Omit<ElementUpdatedData, "local">>

Source

packages/blocks/src/surface-block/surface-model.ts:193


id

id: string

Inherited from

BlockModel.id

Source

packages/framework/store/dist/schema/base.d.ts:109


keys

keys: string[]

Inherited from

BlockModel.keys

Source

packages/framework/store/dist/schema/base.d.ts:111


page

page: Doc

Deprecated

use doc instead

Inherited from

BlockModel.page

Source

packages/framework/store/dist/schema/base.d.ts:108


pop()

pop: (prop) => void

Parameters

prop: "elements"

Returns

void

Inherited from

BlockModel.pop

Source

packages/framework/store/dist/schema/base.d.ts:113


propsUpdated

propsUpdated: Slot<object>

Type declaration

key

key: string

Inherited from

BlockModel.propsUpdated

Source

packages/framework/store/dist/schema/base.d.ts:117


role

role: "root" | "hub" | "content"

Inherited from

BlockModel.role

Source

packages/framework/store/dist/schema/base.d.ts:104


stash()

stash: (prop) => void

Parameters

prop: "elements"

Returns

void

Inherited from

BlockModel.stash

Source

packages/framework/store/dist/schema/base.d.ts:112


text?

optional text: Text

Inherited from

BlockModel.text

Source

packages/framework/store/dist/schema/base.d.ts:114


version

version: number

Inherited from

BlockModel.version

Source

packages/framework/store/dist/schema/base.d.ts:102


yBlock

yBlock: YBlock

Inherited from

BlockModel.yBlock

Source

packages/framework/store/dist/schema/base.d.ts:110

Accessors

childMap

get childMap(): Map<string, number>

Returns

Map<string, number>

Source

packages/framework/store/dist/schema/base.d.ts:123


children

get children(): BlockModel<object>[]

Returns

BlockModel<object>[]

Source

packages/framework/store/dist/schema/base.d.ts:124


doc

get doc(): Doc

set doc(doc): void

Parameters

doc: Doc

Returns

Doc

Source

packages/framework/store/dist/schema/base.d.ts:121


elementModels

get elementModels(): ElementModel<BaseProps>[]

Returns

ElementModel<BaseProps>[]

Source

packages/blocks/src/surface-block/surface-model.ts:207

Methods

_applyMiddlewares()

private _applyMiddlewares(): void

Returns

void

Source

packages/blocks/src/surface-block/surface-model.ts:225


_init()

private _init(): void

Returns

void

Source

packages/blocks/src/surface-block/surface-model.ts:218


_initElementModels()

private _initElementModels(): void

Returns

void

Source

packages/blocks/src/surface-block/surface-model.ts:234


_watchConnectorRelationChange()

private _watchConnectorRelationChange(): void

Returns

void

Source

packages/blocks/src/surface-block/surface-model.ts:399


_watchGroupRelationChange()

private _watchGroupRelationChange(): void

Returns

void

Source

packages/blocks/src/surface-block/surface-model.ts:309


addElement()

addElement<T>(props): string

Type parameters

T extends object = Record<string, unknown>

Parameters

props: Partial<T> & object

Returns

string

Source

packages/blocks/src/surface-block/surface-model.ts:552


dispose()

dispose(): void

Returns

void

Overrides

BlockModel.dispose

Source

packages/blocks/src/surface-block/surface-model.ts:488


firstChild()

firstChild(): null | BlockModel<object>

Returns

null | BlockModel<object>

Inherited from

BlockModel.firstChild

Source

packages/framework/store/dist/schema/base.d.ts:126


getConnectors()

getConnectors(id): ConnectorElementModel[]

Parameters

id: string

Returns

ConnectorElementModel[]

Source

packages/blocks/src/surface-block/surface-model.ts:510


getElementById()

getElementById(id): null | ElementModel<BaseProps>

Parameters

id: string

Returns

null | ElementModel<BaseProps>

Source

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


getElementsByType()

getElementsByType<K>(type): ElementModelMap[K][]

Type parameters

K extends keyof ElementModelMap

Parameters

type: K

Returns

ElementModelMap[K][]

Source

packages/blocks/src/surface-block/surface-model.ts:536


getGroup()

getGroup<T>(id): null | T

Type parameters

T extends GroupLikeModel<BaseProps> = GroupLikeModel<BaseProps>

Parameters

id: string

Returns

null | T

Source

packages/blocks/src/surface-block/surface-model.ts:516


getGroups()

getGroups(id): GroupLikeModel<BaseProps>[]

Parameters

id: string

Returns

GroupLikeModel<BaseProps>[]

Source

packages/blocks/src/surface-block/surface-model.ts:524


hasElementById()

hasElementById(id): boolean

Parameters

id: string

Returns

boolean

Source

packages/blocks/src/surface-block/surface-model.ts:544


isEmpty()

isEmpty(): boolean

Returns

boolean

Inherited from

BlockModel.isEmpty

Source

packages/framework/store/dist/schema/base.d.ts:125


isInMindmap()

isInMindmap(id): boolean

Parameters

id: string

Returns

boolean

Source

packages/blocks/src/surface-block/surface-model.ts:504


lastChild()

lastChild(): null | BlockModel<object>

Returns

null | BlockModel<object>

Inherited from

BlockModel.lastChild

Source

packages/framework/store/dist/schema/base.d.ts:127


removeElement()

removeElement(id): void

Parameters

id: string

Returns

void

Source

packages/blocks/src/surface-block/surface-model.ts:577


updateElement()

updateElement<T>(id, props): void

Type parameters

T extends object = Record<string, unknown>

Parameters

id: string

props: Partial<T>

Returns

void

Source

packages/blocks/src/surface-block/surface-model.ts:614