MCPcopy Index your code
hub / github.com/codex-team/editor.js / defaultBehaviour

Method defaultBehaviour

src/components/modules/ui.ts:505–535  ·  view source on GitHub ↗

* Ignore all other document's keydown events * * @param {KeyboardEvent} event - keyboard event

(event: KeyboardEvent)

Source from the content-addressed store, hash-verified

503 * @param {KeyboardEvent} event - keyboard event
504 */
505 private defaultBehaviour(event: KeyboardEvent): void {
506 const { currentBlock } = this.Editor.BlockManager;
507 const keyDownOnEditor = (event.target as HTMLElement).closest(`.${this.CSS.editorWrapper}`);
508 const isMetaKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
509
510 /**
511 * When some block is selected, but the caret is not set inside the editor, treat such keydowns as keydown on selected block.
512 */
513 if (currentBlock !== undefined && keyDownOnEditor === null) {
514 this.Editor.BlockEvents.keydown(event);
515
516 return;
517 }
518
519 /**
520 * Ignore keydowns on editor and meta keys
521 */
522 if (keyDownOnEditor || (currentBlock && isMetaKey)) {
523 return;
524 }
525
526 /**
527 * Remove all highlights and remove caret
528 */
529 this.Editor.BlockManager.unsetCurrentBlock();
530
531 /**
532 * Close Toolbar
533 */
534 this.Editor.Toolbar.close();
535 }
536
537 /**
538 * @param {KeyboardEvent} event - keyboard event

Callers 1

documentKeydownMethod · 0.95

Calls 3

unsetCurrentBlockMethod · 0.80
keydownMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected