Skip to content

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

Class: Clipboard

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

new Clipboard(std): Clipboard

Parameters

std: BlockStdScope

Returns

Clipboard

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: "clipboard" = 'clipboard'

Overrides

LifeCycleWatcher.key

Defined in

packages/framework/block-std/src/clipboard/index.ts:61

Accessors

configs

get configs(): Map<string, string>

Returns

Map<string, string>

Defined in

packages/framework/block-std/src/clipboard/index.ts:268

Methods

copy()

copy(slice): Promise<void>

Parameters

slice: Slice

Returns

Promise<void>

Defined in

packages/framework/block-std/src/clipboard/index.ts:160


copySlice()

copySlice(slice): Promise<void>

Parameters

slice: Slice

Returns

Promise<void>

Defined in

packages/framework/block-std/src/clipboard/index.ts:165


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


duplicateSlice()

duplicateSlice(slice, doc, parent?, index?, type?): Promise<void>

Parameters

slice: Slice

doc: Doc

parent?: string

index?: number

type?: string = 'BLOCKSUITE/SNAPSHOT'

Returns

Promise<void>

Defined in

packages/framework/block-std/src/clipboard/index.ts:183


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


paste()

paste(event, doc, parent?, index?): Promise<undefined | null | Slice>

Parameters

event: ClipboardEvent

doc: Doc

parent?: string

index?: number

Returns

Promise<undefined | null | Slice>

Defined in

packages/framework/block-std/src/clipboard/index.ts:202


pasteBlockSnapshot()

pasteBlockSnapshot(snapshot, doc, parent?, index?): Promise<undefined | BlockModel<object, SignaledProps<object>>>

Parameters

snapshot: BlockSnapshot

doc: Doc

parent?: string

index?: number

Returns

Promise<undefined | BlockModel<object, SignaledProps<object>>>

Defined in

packages/framework/block-std/src/clipboard/index.ts:239


readFromClipboard()

readFromClipboard(clipboardData): any

Parameters

clipboardData: DataTransfer

Returns

any

Defined in

packages/framework/block-std/src/clipboard/index.ts:294


registerAdapter()

registerAdapter<T>(mimeType, adapter, priority): void

Type Parameters

T extends BaseAdapter<unknown>

Parameters

mimeType: string

adapter: AdapterConstructor<T>

priority: number = 0

Returns

void

Defined in

packages/framework/block-std/src/clipboard/index.ts:248


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


unmounted()

unmounted(): void

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

Returns

void

Inherited from

LifeCycleWatcher.unmounted

Defined in

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


unregisterAdapter()

unregisterAdapter(mimeType): void

Parameters

mimeType: string

Returns

void

Defined in

packages/framework/block-std/src/clipboard/index.ts:256


unuse()

unuse(middleware): void

Parameters

middleware: JobMiddleware

Returns

void

Defined in

packages/framework/block-std/src/clipboard/index.ts:260


use()

use(middleware): void

Parameters

middleware: JobMiddleware

Returns

void

Defined in

packages/framework/block-std/src/clipboard/index.ts:264


writeToClipboard()

writeToClipboard(updateItems): Promise<void>

Parameters

updateItems

Returns

Promise<void>

Defined in

packages/framework/block-std/src/clipboard/index.ts:313


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