mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-07-15 21:31:36 +03:00
Lexical: Updated toolbars to re-focus on editor on escape press
This commit is contained in:
@@ -30,7 +30,7 @@ export function isUiBuilderDefinition(object: any): object is EditorUiBuilderDef
|
||||
export abstract class EditorUiElement {
|
||||
protected dom: HTMLElement|null = null;
|
||||
private context: EditorUiContext|null = null;
|
||||
private abortController: AbortController = new AbortController();
|
||||
protected abortController: AbortController = new AbortController();
|
||||
|
||||
protected abstract buildDOM(): HTMLElement;
|
||||
|
||||
|
||||
@@ -18,9 +18,20 @@ export class EditorContextToolbar extends EditorContainerUiElement {
|
||||
}
|
||||
|
||||
protected buildDOM(): HTMLElement {
|
||||
return el('div', {
|
||||
const toolbar = el('div', {
|
||||
class: 'editor-context-toolbar',
|
||||
}, this.getChildren().map(child => child.getDOMElement()));
|
||||
|
||||
// Focus back on the editor on escape press
|
||||
toolbar.addEventListener('keydown', (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.getContext().editor.focus();
|
||||
}
|
||||
}, {signal: this.abortController.signal});
|
||||
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user