Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Deploying lexical with
|
| Latest commit: |
053ff26
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://de936709.lexical-a1o.pages.dev |
| Branch Preview URL: | https://claude-keyboard-shortcuts-di.lexical-a1o.pages.dev |
…ortcut dispatch Replace the O(n) if/else keyboard shortcut matching with a data-driven scheme: shortcuts are declared as data (key + modifier mask + handler) and compiled down to a Map keyed by the modifier bitmask and pressed key, so dispatch is O(1) per keypress regardless of table size. The matching semantics (including the event.code fallback for non-Latin keyboard layouts) are identical to isExactShortcutMatch, verified by an exhaustive parity test. - @lexical/extension: add compileKeyboardShortcuts, registerKeyboardShortcuts, and KeyboardShortcutsExtension. The extension holds a named shortcut table merged across the extension graph, so apps and other extensions can overlay it: configure an existing name to remap a shortcut, configure it to null to disable it, or add new names for new shortcuts. The config is exposed as signals so the table can also be remapped at runtime. - lexical: export the KeyboardEventModifiers and KeyboardEventModifierMask types. - lexical-playground: ShortcutsPlugin now declares its bindings in a SHORTCUT_BINDINGS table and registers them through registerKeyboardShortcuts instead of testing 27 predicates in sequence. Co-Authored-By: Claude Fable 5 <[email protected]>
… in LexicalEvents Move the compiled keyboard shortcut dispatcher into the lexical core (LexicalKeyboardShortcuts.ts) so that the editor's own $handleKeyDown uses the same code as KeyboardShortcutsExtension. The 28-branch predicate chain in LexicalEvents is now a declarative table compiled once (lazily) into the O(1) modifier-bitmask + key lookup, and the ~30 single-use is* predicates it called (isBold, isMoveForward, isRedo, etc.) are deleted from LexicalUtils along with their CONTROL_OR_META / CONTROL_OR_ALT constants. - lexical: add CompiledKeyboardShortcuts, compileKeyboardShortcuts, registerKeyboardShortcuts, and the KeyboardShortcut types to the public API; rewrite $handleKeyDown on the compiled table. - @lexical/extension: KeyboardShortcutsExtension now reuses the core implementation and re-exports it, shrinking the extension module to just the named-table config/overlay logic. - Parity is verified by an exhaustive test that transcribes the old predicate chain and compares dispatched commands, payloads, and preventDefault against the new table for 25 key/code pairs x 16 modifier states on both Apple and non-Apple platforms (including non-Latin layout code fallbacks). Co-Authored-By: Claude Fable 5 <[email protected]>
… jsx build The build pipeline parses .ts modules with the JSX plugin enabled, so the generic arrow function `<T>(command, payload) => ...` in buildKeyDownShortcuts was misparsed as a JSX tag and failed `pnpm run build` in CI (tsc, eslint, and vitest all accepted it). Use a function declaration instead. Co-Authored-By: Claude Fable 5 <[email protected]>
…llup build @babel/preset-react unconditionally enables JSX parsing for every file it processes, so applying it to all extensions made the build parse .ts modules as TSX, where a generic arrow function like `<T>(x: T) => x` is misparsed as a JSX opening tag (tsc accepts it in .ts, so only the build failed). Move the preset into a babel overrides block gated on /\.[jt]sx$/ so .ts is parsed as plain TypeScript, and restore the generic arrow in buildKeyDownShortcuts that previously had to be written as a function declaration to work around this. Co-Authored-By: Claude Fable 5 <[email protected]>
Replace the repeated {key, modifiers, onMatch} object literals in
buildKeyDownShortcuts with dispatch/prevent/enter/copyOrCut factories
so each binding is a one-line call; only the three entries with
genuinely custom behavior (Backspace, select-all, Apple Ctrl+O) remain
literals. Also derive getEventModifierBits from the shared
MODIFIER_BITS table instead of repeating each modifier constant.
Co-Authored-By: Claude Fable 5 <[email protected]>
…ed shortcuts with $disabled and $dispatch Redesign KeyboardShortcut as pure data: a shortcut now maps a key binding to a LexicalCommand<KeyboardEvent> that is dispatched with the matched event as its payload, instead of holding an arbitrary handler function. This keeps the table declarative - it can be extracted to build a shortcuts menu (with the new formatKeyboardShortcut display helper and optional description field), remapped through the KeyboardShortcutsExtension signal, and the behavior lives in command listeners that menus and buttons can share. Two escape hatches: $disabled(selection, editor) is checked before dispatch (and can drive disabled menu items), and $dispatch(command, event, $next, editor) is optional middleware for shortcuts that must run additional code around the dispatch without defining a wrapper command. - lexical: export CONTROL_OR_META and CONTROL_OR_ALT (used by the core keydown table, the playground, and most shortcut definitions) and formatKeyboardShortcut. - lexical-playground: migrate ShortcutsPlugin (React) to a ShortcutsExtension (no React): each action is a SHORTCUT_COMMANDS[name] command registered by the extension, the key bindings are contributed to the KeyboardShortcutsExtension signal table, blockType/fontSize/isLink are derived from the editor state instead of ToolbarContext, and the insert-link shortcut publishes an isLinkEditMode signal that Editor.tsx consumes in place of its React state. Co-Authored-By: Claude Fable 5 <[email protected]>
… and move formatKeyboardShortcut registerKeyboardShortcuts now calls the internal dispatchCommand primitive instead of editor.dispatchCommand, and binds $next with Function.prototype.bind (only when a $dispatch middleware is present) instead of allocating an arrow closure per dispatch. Move formatKeyboardShortcut and FormatKeyboardShortcutOptions out of the lexical core into @lexical/extension - display formatting for menus doesn't need to bloat the core. Co-Authored-By: Claude Fable 5 <[email protected]>
A generator is unnecessary here since the match lists are so cheap to materialize; an array is simpler for callers and menu builders. Co-Authored-By: Claude Fable 5 <[email protected]>
etrepum
force-pushed
the
claude/keyboard-shortcuts-dispatch-6thty5
branch
from
July 20, 2026 20:25
a927664 to
053ff26
Compare
6 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the O(n) if/else keyboard shortcut matching with a data-driven
scheme: shortcuts are declared as data (key + modifier mask + handler)
and compiled down to a Map keyed by the modifier bitmask and pressed
key, so dispatch is O(1) per keypress regardless of table size. The
matching semantics (including the event.code fallback for non-Latin
keyboard layouts) are identical to isExactShortcutMatch, verified by an
exhaustive parity test.
registerKeyboardShortcuts, and KeyboardShortcutsExtension. The
extension holds a named shortcut table merged across the extension
graph, so apps and other extensions can overlay it: configure an
existing name to remap a shortcut, configure it to null to disable
it, or add new names for new shortcuts. The config is exposed as
signals so the table can also be remapped at runtime.
KeyboardEventModifierMask types.
SHORTCUT_BINDINGS table and registers them through
registerKeyboardShortcuts instead of testing 27 predicates in
sequence.
Co-Authored-By: Claude Fable 5 [email protected]