Repository navigation
fix: paragraph menu / command palette parity (focus, list unwrap, shortcut symbols) - #4504
Merged
Merged
Conversation
editor.focus() unconditionally moved the caret to the first content block. The desktop command palette blurs the editor (clearing activeContentBlock) and then re-focuses it before dispatching a command, so any palette-invoked block command operated on the first block instead of the user's block. This was invisible for commands with keyboard shortcuts / native menu items (which never go through the blur+focus round-trip), but "Reset Paragraph" has no keybinding and is palette-only, so it always no-oped on the wrong block. focus() now restores the user's last caret when its block is still in the tree, falling back to the first block otherwise. Refs #4429 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Clicking the already-active list type in the paragraph front menu was a no-op; legacy muyajs toggled the list off, unwrapping every item back into plain paragraphs. The front menu now mirrors that behaviour, matching the command-palette/menu "reset-to-paragraph" command. The engine unwrap (formerly the private _resetToParagraph) is promoted to a public Muya.resetToParagraph(block) so the front menu can reset the block it targets rather than the cursor block, keeping a single shared code path. Refs #4429 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Keybindings are stored as Electron word-form accelerators (Command, Option, Control). normalizeAccelerator only mapped the literal "cmd"/"ctrl" substrings, so the palette rendered literal "Command"/"Option" tokens that were inconsistent with the muya front menu and the native menus. Add a pure acceleratorToTokens(acc, isOsx) helper that maps modifiers to the native symbols (⌘ ⇧ ⌥ ⌃) on macOS and to readable words elsewhere, and route normalizeAccelerator through it. Refs #4429 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The shortcut tokens rendered as bare text. Give each <kbd> a bordered, rounded keycap style (theme-aware via --floatBgColor / --floatBorderColor / --editorColor) so the symbol shortcuts read as discrete keys, matching the pre-refactor button look. Refs #4429 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Restores three pre-refactor behaviours around the paragraph menu and command palette that regressed in the muyajs → @muyajs/core migration. Refs #4429.
Problems & fixes
A. Command palette "Reset Paragraph" did nothing
editor.focus()always moved the caret to the first content block. The command palette blurs the editor (clearingactiveContentBlock) and re-focuses it before dispatching, so palette commands targeted block #1. This was hidden for commands with keyboard shortcuts / native menu items (they never go through the blur+focus round-trip), but Reset Paragraph has no keybinding and is palette-only, so it always no-oped.focus()now restores the user's last caret when its block is still in the tree, falling back to the first block.B. Command palette shortcut style differed
Keybindings are stored as Electron word-forms (
Command/Option);normalizeAcceleratorleft them unmapped, so the palette showed literal "Command"/"Option" instead of symbols. A new pureacceleratorToTokens(acc, isOsx)maps modifiers to native symbols (⌘ ⇧ ⌥ ⌃) on macOS and readable words elsewhere.C. Front-menu list item didn't unpack a list
Clicking the active list type in the paragraph front menu was a no-op; legacy muyajs unwrapped the list back into paragraphs. The engine unwrap is promoted to a public
Muya.resetToParagraph(block)and the front menu now calls it, sharing one code path with the menu/palettereset-to-paragraphcommand.Tests
packages/muya/src/__tests__/focus.spec.ts— focus restores the last cursor, falls back to first blockpackages/muya/src/__tests__/resetToParagraph.spec.ts—resetToParagraphunwraps lists/blockquotes; front-menu active-type click unwrapspackages/desktop/test/unit/specs/accelerator.spec.ts— modifier→symbol/word mappingVerification
lint:typesclean, lint 0 errors, no circular depsNot yet verified by launching the Electron app — logic is covered at the unit level.
🤖 Generated with Claude Code