Skip to content

fix: unify desktop and Muya shortcut behavior and hints - #5887

Merged
Jocs merged 11 commits into
developfrom
fix/5155-duplicate-shortcut
Oct 26, 2026
Merged

Jocs merged 11 commits into
developfrom
fix/5155-duplicate-shortcut

Conversation

@Jocs

@Jocs Jocs commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Closes #2999
Closes #5155
Closes #4863

Muya's inline toolbar and quick-insert menu currently process their own command shortcuts and advertise bundled defaults. After rebinding or unbinding a desktop command, the old Muya shortcut can still execute and its tooltip can disagree with the application menu. For example, macOS inline code also responds to Control+Command+E even though the desktop command is Control+Command+C.

This change gives the desktop sole ownership of command shortcuts. All three Muya menus resolve hints from the active desktop map, including custom bindings and explicit unbinding. Saving settings updates open menus and editor windows immediately. Menu clicks and slash-menu navigation remain available, while native browser format* events cannot mutate the editor DOM behind the document model.

Changes

  • Add opt-in Muya host integration: keyboardShortcuts: false, getShortcut(action) and refreshShortcutHints(). Standalone consumers retain their default command handling.
  • Retain the complete active binding snapshot in the command-center store, including across async initialization, locale changes and late command registration. Use the same modifier formatting for palette and Muya hints.
  • Vendor the MIT-licensed keyboard helper from @hfelix/[email protected], following the direction recorded in [Bug] Keybindings recorder silently drops Shift for digit/punctuation combos (⌘⇧7 records as Cmd+7) #4863 / fix(desktop): preserve Shift for Cmd/Ctrl+digit keybindings (#4863) #4873. Recorder, validation, conflict checks, layout updates and Electron dispatch share the module; remove the dependency and untyped shim, and include the retained license in shipped notices.
  • Keep primary-modifier Shift digit/punctuation chords distinct from unshifted chords whether the event reports a base key or shifted symbol. Preserve layout-aware AltGr, dead keys, non-Latin, numpad, Dvorak-QWERTY-Command and literal-symbol bindings such as Ctrl+Plus.
  • Keep macOS Duplicate at Shift+Command+E, avoiding the system Dock shortcut. On Windows, reserve Ctrl+P for Quick Open and leave Print unbound by default. Update end-user and developer documentation.

Explicit Shift chords now stay distinct: Command+Shift+= does not silently execute Command+=. The documented macOS Promote Heading binding remains Command+=.

Registered command descriptions now refresh after the new locale finishes loading, while custom labels, command objects and active bindings are retained. The three Muya menus share their inherited options instead of keeping a second shortcut-options object. International-symbol and incomplete dead-key-layout regressions have dedicated tests.

Validation

  • All 21 GitHub checks passed for b444a65e: Linux Electron E2E 482 passed / 5 skipped, Muya Chromium E2E 591 passed / 6 skipped, and all six OS/architecture packaging jobs passed.

  • Desktop unit suite: 1366 passed. Muya unit suite: 3087 passed.

  • New Electron integration suite: 7 passed — custom binding / unbinding, native formatBold cancellation and DOM checks, old inline-code alias removal, Duplicate and undo, live hints, slash navigation, Preferences recording / Save / Unbind / Reset, restart persistence, multiple windows, equivalent shifted-symbol conflict rejection, and registered command names / Chinese search after cold and cached language changes.

  • Existing Electron menu / paragraph / source-mode regressions: 19 passed.

  • Standalone Muya Chromium toolbar / shortcuts / front-menu / slash-menu regressions: 33 passed. Post-cleanup Muya toolbar / host-integration tests: 25 passed.

  • pnpm run build:unpack, pnpm run typecheck, root and Muya ESLint, Muya typecheck and circular-dependency check passed. Both modified stylesheets pass stylelint. Full Muya CSS lint still reports 7 existing specificity errors in untouched blockSyntax.css and inlineSyntax.css.

  • Third-party notice generation verified with the vendored MIT copyright and license.

The current Preferences UI successfully records, saves and reloads custom bindings. After retesting with a fresh profile, #5117 was closed as not reproducible; this does not establish the cause of its original v0.19.1 failure. Related historical reports include #4687, #3630 and #4128. Thanks to @FurkaanBoraa for the earlier #4862 work; that overlapping PR was closed with thanks while consolidating this implementation.

Application-level injected events exercise Electron dispatch but bypass macOS global shortcut interception. Physical-keyboard macOS verification remains pending, as does Windows/Linux physical-keyboard verification. Platform packaging CI has passed. No claim of physical Dock-shortcut verification is made by these tests.

The desktop quick-insert E2E cases now use platform-specific desktop accelerators through Electron dispatch. Linux additionally checks that the old Muya Meta+Alt aliases no longer execute commands. The prior Linux failure exercised those intentionally disabled aliases.

@Jocs Jocs changed the title fix: #5155 correct Duplicate shortcut hints fix: #5155 align Duplicate hints and avoid macOS Dock shortcut Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Website preview ready: https://pr-5887-marktext-website.ransixi.workers.dev

Built from b444a65e8c6600a9e334156867ce15934b7473b8 · Worker: marktext-website · Version: 40576d18-2d2a-411a-a1e6-1f28df0d28f1 · Alias: pr-5887

@Jocs Jocs changed the title fix: #5155 align Duplicate hints and avoid macOS Dock shortcut fix: unify desktop and Muya shortcut behavior and hints Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Build artifacts for PR #5887:

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

Artifact Size Link
marktext-windows-x64 299.7 MB Download
marktext-windows-arm64 291.5 MB Download
marktext-linux-x64 669.4 MB Download
marktext-macos-arm64 300.9 MB Download
marktext-linux-arm64 523.4 MB Download
marktext-macos-x64 314.2 MB Download

@Jocs Jocs mentioned this pull request Oct 26, 2026
1 task done
@Jocs
Jocs merged commit b27b339 into develop Oct 26, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant