Skip to content

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

Class: DndController

Defined in: packages/framework/block-std/src/extension/dnd/index.ts:210

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 DndController()

new DndController(std): DndController

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:28

Parameters

std

BlockStdScope

Returns

DndController

Inherited from

LifeCycleWatcher.constructor

Properties

std

readonly std: BlockStdScope

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:28

Inherited from

LifeCycleWatcher.std


key

static key: string = 'DndController'

Defined in: packages/framework/block-std/src/extension/dnd/index.ts:211

Overrides

LifeCycleWatcher.key

Methods

autoScroll()

autoScroll<PayloadEntity, PayloadFrom>(options): CleanupFn

Defined in: packages/framework/block-std/src/extension/dnd/index.ts:367

Type Parameters

PayloadEntity

PayloadEntity extends DragEntity = DragEntity

PayloadFrom

PayloadFrom extends DragFrom = DragFromBlockSuite

Parameters

options

AutoScroll<PayloadEntity, PayloadFrom>

Returns

CleanupFn


created()

created(): void

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:52

Called when std is created.

Returns

void

Inherited from

LifeCycleWatcher.created


draggable()

draggable<PayloadEntity, DropData>(args): CleanupFn

Defined in: packages/framework/block-std/src/extension/dnd/index.ts:216

Make an element draggable.

Type Parameters

PayloadEntity

PayloadEntity extends DragEntity = DragEntity

DropData

DropData extends object = {}

Parameters

args

DraggableOption<PayloadEntity, DragFromBlockSuite, DropPayload<DropData>>

Returns

CleanupFn


dropTarget()

dropTarget<PayloadEntity, DropData, PayloadFrom>(args): CleanupFn

Defined in: packages/framework/block-std/src/extension/dnd/index.ts:324

Make an element a drop target.

Type Parameters

PayloadEntity

PayloadEntity extends DragEntity = DragEntity

DropData

DropData extends object = {}

PayloadFrom

PayloadFrom extends DragFrom = DragFromBlockSuite

Parameters

args

DropTargetOption<PayloadEntity, PayloadFrom, DropPayload<DropData>>

Returns

CleanupFn


monitor()

monitor<PayloadEntity, DropData, PayloadFrom>(args): CleanupFn

Defined in: packages/framework/block-std/src/extension/dnd/index.ts:359

Type Parameters

PayloadEntity

PayloadEntity extends DragEntity = DragEntity

DropData

DropData extends object = {}

PayloadFrom

PayloadFrom extends DragFrom = DragFromBlockSuite

Parameters

args

MonitorOption<PayloadEntity, PayloadFrom, DropPayload<DropData>>

Returns

CleanupFn


mounted()

mounted(): void

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:58

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

Returns

void

Inherited from

LifeCycleWatcher.mounted


rendered()

rendered(): void

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:63

Called when std.render is called.

Returns

void

Inherited from

LifeCycleWatcher.rendered


unmounted()

unmounted(): void

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:69

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

Returns

void

Inherited from

LifeCycleWatcher.unmounted


setup()

static setup(di): void

Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:32

Parameters

di

Container

Returns

void

Inherited from

LifeCycleWatcher.setup