Skip to content

fix: paragraph menu / command palette parity (focus, list unwrap, shortcut symbols) - #4504

Merged
Jocs merged 4 commits into
developfrom
fix/paragraph-menu-palette-parity
Jun 15, 2026
Merged

Jocs merged 4 commits into
developfrom
fix/paragraph-menu-palette-parity

Conversation

@Jocs

@Jocs Jocs commented Jun 14, 2026

Copy link
Copy Markdown
Member

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 (clearing activeContentBlock) 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); normalizeAccelerator left them unmapped, so the palette showed literal "Command"/"Option" instead of symbols. A new pure acceleratorToTokens(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/palette reset-to-paragraph command.

Tests

  • packages/muya/src/__tests__/focus.spec.ts — focus restores the last cursor, falls back to first block
  • packages/muya/src/__tests__/resetToParagraph.spec.ts — resetToParagraph unwraps lists/blockquotes; front-menu active-type click unwraps
  • packages/desktop/test/unit/specs/accelerator.spec.ts — modifier→symbol/word mapping

Verification

  • muya: 758 unit tests pass, lint:types clean, lint 0 errors, no circular deps
  • desktop: 470 unit tests pass, typecheck clean, lint 0 errors

Not yet verified by launching the Electron app — logic is covered at the unit level.

🤖 Generated with Claude Code

Jocs and others added 3 commits June 15, 2026 00:35
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]>
@github-actions

github-actions Bot commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Build artifacts for PR #4504:

Run: https://github.com/marktext/marktext/actions/runs/27506548113

Artifact Size Link
marktext-macos-x64 257.1 MB Download
marktext-windows-arm64 256.5 MB Download
marktext-linux 556.5 MB Download
marktext-windows-x64 257.8 MB Download
marktext-macos-arm64 246.8 MB Download

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]>
@Jocs
Jocs merged commit 3eaefce into develop Jun 15, 2026
16 of 17 checks passed
@Jocs
Jocs deleted the fix/paragraph-menu-palette-parity branch June 15, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant