Skip to content

Commit

Permalink
fix: dispatcher keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushAgrawal-A2 committed Dec 28, 2023
1 parent 36ccfd2 commit 7cdc79b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/block-std/src/event/control/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,28 @@ export class KeyboardControl {
document,
'compositionstart',
() => {
const selection = this._dispatcher.std.selection.value;
if (!selection.length) return;

this.composition = true;
}
);
this._dispatcher.disposables.addFromEvent(
document,
'compositionend',
() => {
const selection = this._dispatcher.std.selection.value;
if (!selection.length) return;

this.composition = false;
}
);
}

bindHotkey(keymap: Record<string, UIEventHandler>, options?: EventOptions) {
const selection = this._dispatcher.std.selection.value;
if (!selection.length) return;

return this._dispatcher.add(
'keyDown',
ctx => {
Expand All @@ -46,6 +55,9 @@ export class KeyboardControl {
}

private _down = (event: KeyboardEvent) => {
const selection = this._dispatcher.std.selection.value;
if (!selection.length) return;

const keyboardEventState = new KeyboardEventState({
event,
composing: this.composition,
Expand All @@ -57,6 +69,9 @@ export class KeyboardControl {
};

private _up = (event: KeyboardEvent) => {
const selection = this._dispatcher.std.selection.value;
if (!selection.length) return;

const keyboardEventState = new KeyboardEventState({
event,
composing: this.composition,
Expand Down

0 comments on commit 7cdc79b

Please sign in to comment.