BlockSuite API Documentation / @blocksuite/block-std / UIEventDispatcher
Class: UIEventDispatcher
Defined in: packages/framework/block-std/src/event/dispatcher.ts:79
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.
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:
created
: Called when the std is created.rendered
: Called whenstd.render
is called.mounted
: Called when the editor host is mounted.unmounted
: Called when the editor host is unmounted.
Extends
Constructors
new UIEventDispatcher()
new UIEventDispatcher(
std
):UIEventDispatcher
Defined in: packages/framework/block-std/src/event/dispatcher.ts:115
Parameters
std
Returns
UIEventDispatcher
Overrides
Properties
disposables
disposables:
DisposableGroup
Defined in: packages/framework/block-std/src/event/dispatcher.ts:101
std
readonly
std:BlockStdScope
Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:28
Inherited from
key
readonly
static
key:"UIEventDispatcher"
='UIEventDispatcher'
Defined in: packages/framework/block-std/src/event/dispatcher.ts:82
Overrides
Accessors
active
Get Signature
get active():
boolean
Defined in: packages/framework/block-std/src/event/dispatcher.ts:107
Returns
boolean
host
Get Signature
get host():
EditorHost
Defined in: packages/framework/block-std/src/event/dispatcher.ts:111
Returns
Methods
add()
add(
name
,handler
,options
?): () =>void
Defined in: packages/framework/block-std/src/event/dispatcher.ts:318
Parameters
name
"copy"
| "blur"
| "click"
| "doubleClick"
| "tripleClick"
| "pointerDown"
| "pointerMove"
| "pointerUp"
| "pointerOut"
| "dragStart"
| "dragMove"
| "dragEnd"
| "pinch"
| "pan"
| "keyDown"
| "keyUp"
| "selectionChange"
| "compositionStart"
| "compositionUpdate"
| "compositionEnd"
| "cut"
| "paste"
| "nativeDragStart"
| "nativeDragMove"
| "nativeDragEnd"
| "nativeDrop"
| "nativeDragOver"
| "nativeDragLeave"
| "beforeInput"
| "focus"
| "contextMenu"
| "wheel"
handler
options?
Returns
Function
Returns
void
bindHotkey()
bindHotkey(...
args
): () =>void
Defined in: packages/framework/block-std/src/event/dispatcher.ts:98
Parameters
args
...[Record
<string
, UIEventHandler
>, EventOptions
]
Returns
Function
Returns
void
buildEventScope()
buildEventScope(
name
,blocks
):undefined
|EventHandlerRunner
[]
Defined in: packages/framework/block-std/src/event/dispatcher.ts:334
Parameters
name
"copy"
| "blur"
| "click"
| "doubleClick"
| "tripleClick"
| "pointerDown"
| "pointerMove"
| "pointerUp"
| "pointerOut"
| "dragStart"
| "dragMove"
| "dragEnd"
| "pinch"
| "pan"
| "keyDown"
| "keyUp"
| "selectionChange"
| "compositionStart"
| "compositionUpdate"
| "compositionEnd"
| "cut"
| "paste"
| "nativeDragStart"
| "nativeDragMove"
| "nativeDragEnd"
| "nativeDrop"
| "nativeDragOver"
| "nativeDragLeave"
| "beforeInput"
| "focus"
| "contextMenu"
| "wheel"
blocks
string
[]
Returns
undefined
| EventHandlerRunner
[]
created()
created():
void
Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:52
Called when std is created.
Returns
void
Inherited from
mounted()
mounted():
void
Defined in: packages/framework/block-std/src/event/dispatcher.ts:377
Called when editor host is mounted. Which means the editor host emit the connectedCallback
lifecycle event.
Returns
void
Overrides
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
run()
run(
name
,context
,runners
?):void
Defined in: packages/framework/block-std/src/event/dispatcher.ts:391
Parameters
name
"copy"
| "blur"
| "click"
| "doubleClick"
| "tripleClick"
| "pointerDown"
| "pointerMove"
| "pointerUp"
| "pointerOut"
| "dragStart"
| "dragMove"
| "dragEnd"
| "pinch"
| "pan"
| "keyDown"
| "keyUp"
| "selectionChange"
| "compositionStart"
| "compositionUpdate"
| "compositionEnd"
| "cut"
| "paste"
| "nativeDragStart"
| "nativeDragMove"
| "nativeDragEnd"
| "nativeDrop"
| "nativeDragOver"
| "nativeDragLeave"
| "beforeInput"
| "focus"
| "contextMenu"
| "wheel"
context
runners?
Returns
void
unmounted()
unmounted():
void
Defined in: packages/framework/block-std/src/event/dispatcher.ts:415
Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback
lifecycle event.
Returns
void
Overrides
setup()
static
setup(di
):void
Defined in: packages/framework/block-std/src/extension/lifecycle-watcher.ts:32
Parameters
di
Container
Returns
void