Skip to content

BlockSuite API Documentation / @blocksuite/block-std / ViewStore

Class: ViewStore

A life cycle watcher is an extension that watches the life cycle of the editor. It is used to perform actions when the editor is created, mounted, rendered, or unmounted.

When creating a life cycle watcher, you must define a key that is unique to the watcher. The key is used to identify the watcher in the dependency injection container.

ts
class MyLifeCycleWatcher extends LifeCycleWatcher {
 static override readonly key = 'my-life-cycle-watcher';

In the life cycle watcher, the methods will be called in the following order:

  1. created: Called when the std is created.
  2. rendered: Called when std.render is called.
  3. mounted: Called when the editor host is mounted.
  4. unmounted: Called when the editor host is unmounted.

Extends

Constructors

new ViewStore()

new ViewStore(std): ViewStore

Parameters

std: BlockStdScope

Returns

ViewStore

Inherited from

LifeCycleWatcher.constructor

Defined in

packages/framework/block-std/src/extension/lifecycle-watcher.ts:30

Properties

std

readonly std: BlockStdScope

Inherited from

LifeCycleWatcher.std

Defined in

packages/framework/block-std/src/extension/lifecycle-watcher.ts:30


key

readonly static key: "viewStore" = 'viewStore'

Overrides

LifeCycleWatcher.key

Defined in

packages/framework/block-std/src/view/view-store.ts:6

Methods

created()

created(): void

Called when std is created.

Returns

void

Inherited from

LifeCycleWatcher.created

Defined in

packages/framework/block-std/src/extension/lifecycle-watcher.ts:54


deleteBlock()

deleteBlock(node): void

Parameters

node: BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>

Returns

void

Defined in

packages/framework/block-std/src/view/view-store.ts:22


deleteWidget()

deleteWidget(node): void

Parameters

node: WidgetComponent<BlockModel<object, SignaledProps<object>>, BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>, BlockService>

Returns

void

Defined in

packages/framework/block-std/src/view/view-store.ts:26


getBlock()

getBlock(id): null | BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>

Parameters

id: string

Returns

null | BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>

Defined in

packages/framework/block-std/src/view/view-store.ts:32


getWidget()

getWidget(widgetName, hostBlockId): null | WidgetComponent<BlockModel<object, SignaledProps<object>>, BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>, BlockService>

Parameters

widgetName: string

hostBlockId: string

Returns

null | WidgetComponent<BlockModel<object, SignaledProps<object>>, BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>, BlockService>

Defined in

packages/framework/block-std/src/view/view-store.ts:36


mounted()

mounted(): void

Called when editor host is mounted. Which means the editor host emit the connectedCallback lifecycle event.

Returns

void

Inherited from

LifeCycleWatcher.mounted

Defined in

packages/framework/block-std/src/extension/lifecycle-watcher.ts:60


rendered()

rendered(): void

Called when std.render is called.

Returns

void

Inherited from

LifeCycleWatcher.rendered

Defined in

packages/framework/block-std/src/extension/lifecycle-watcher.ts:65


setBlock()

setBlock(node): void

Parameters

node: BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>

Returns

void

Defined in

packages/framework/block-std/src/view/view-store.ts:44


setWidget()

setWidget(node): void

Parameters

node: WidgetComponent<BlockModel<object, SignaledProps<object>>, BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>, BlockService>

Returns

void

Defined in

packages/framework/block-std/src/view/view-store.ts:48


unmounted()

unmounted(): void

Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback lifecycle event.

Returns

void

Overrides

LifeCycleWatcher.unmounted

Defined in

packages/framework/block-std/src/view/view-store.ts:90


walkThrough()

walkThrough(fn, blockId?): void

Parameters

fn

blockId?: null | string

Returns

void

Defined in

packages/framework/block-std/src/view/view-store.ts:54


setup()

static setup(di): void

Parameters

di: Container

Returns

void

Inherited from

LifeCycleWatcher.setup

Defined in

packages/framework/block-std/src/extension/lifecycle-watcher.ts:34