Skip to content

Commit

Permalink
feat(@lexical/plaintext): Add escape key handler (#5991)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyclu authored May 6, 2024
1 parent c8e45fe commit ac97dfa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/lexical-plain-text/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
KEY_BACKSPACE_COMMAND,
KEY_DELETE_COMMAND,
KEY_ENTER_COMMAND,
KEY_ESCAPE_COMMAND,
PASTE_COMMAND,
REMOVE_TEXT_COMMAND,
SELECT_ALL_COMMAND,
Expand Down Expand Up @@ -324,6 +325,18 @@ export function registerPlainText(editor: LexicalEditor): () => void {
},
COMMAND_PRIORITY_EDITOR,
),
editor.registerCommand(
KEY_ESCAPE_COMMAND,
() => {
const selection = $getSelection();
if (!$isRangeSelection(selection)) {
return false;
}
editor.blur();
return true;
},
COMMAND_PRIORITY_EDITOR,
),
editor.registerCommand(
SELECT_ALL_COMMAND,
() => {
Expand Down

0 comments on commit ac97dfa

Please sign in to comment.