feat(ui): shortcut field on ui.commands.register (SD-2936)#3149
feat(ui): shortcut field on ui.commands.register (SD-2936)#3149caio-pizzol merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59ae2ff279
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
48de5bb to
d157326
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.52 The release is available on GitHub release |
|
🎉 This PR is included in @superdoc-dev/react v1.2.0-next.94 The release is available on GitHub release |
|
🎉 This PR is included in vscode-ext v2.3.0-next.96 |
|
🎉 This PR is included in superdoc v1.30.0-next.53 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-cli v0.8.0-next.70 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.8.0-next.53 |
Adds a
shortcutfield toui.commands.register({...})so consumers wiring custom actions ("Insert clause", "AI Rewrite", "Toggle Comment Sidebar") stop hand-rolling per-command keydown listeners and conflict-handling.Shortcut strings follow the ProseMirror / Tiptap convention so consumers don't have to relearn a new format:
Mod-K,Mod-Shift-C,Alt-Enter,Mod-Alt-1.Modis the platform-correct meta key (Cmd on macOS, Ctrl elsewhere) — bothCmd-Kon Mac andCtrl-Kon Windows match the same'Mod-K'registration. Modifier order in the input is normalized to canonicalMod, Alt, Shift, KEY.The controller installs a single
keydownlistener (capture phase, onglobalThis.document) and filters to events whose target lies inside this controller's painted host (presentationEditor.visibleHost) — same scoping asentityAt. SoCmd-Btyped in a sidebar input doesn't toggle Bold on the document. Matched shortcuts dispatch through the same pathui.commands.get(id).execute()uses, and the listener torn down via the controller's existing teardown chain.Custom-vs-custom collisions warn and the later registration wins (matches the
register({ id })replacement posture). Built-in editor keymaps (Bold'sCmd-B, etc.) are owned by the editor's own keymap plugin and are out of scope for collision detection — registering'Mod-B'fires alongside Bold rather than instead of it. That's documented on the field's JSDoc.Last in the SD-2936 stack. Stacks on PR #3146.
Verified:
pnpm exec vitest run src/ui→ 244 passed (16 files, +14 new — 8 in keyboard-shortcuts, 6 in custom-commands);pnpm exec tsc -b tsconfig.references.json→ clean.