Skip to content

[Bug] muya inline format toolbar shortcut hints don't follow custom keybindings #4687

Closed

Description

@Jocs

Follow-up to #3998 (fixed by #4681). That PR made the menu bar and command palette reflect custom keybindings live; this issue tracks the one remaining surface — muya's inline format toolbar — which was intentionally left out of #4681.

Description

The inline format toolbar (the floating Bold / Italic / Underline / … bar that appears when you select text in the editor) shows keyboard-shortcut hints in its button tooltips (e.g. ⌘+B). These hints are hardcoded in the muya engine and are not synced with the user's custom keybindings, so after you change a format shortcut in Preferences → Keybindings, the toolbar tooltip keeps showing the old default while the menu bar / command palette already show the new value.

There is also a related behavior nuance: muya handles these format shortcuts internally with a hardcoded key map (FORMAT_SHORTCUTS in inlineFormatToolbar/index.ts). After rebinding a format command, the desktop unregisters the old accelerator, so the old key combo falls through to muya's internal handler and still applies the format — i.e. the old shortcut keeps working alongside the newly-assigned one.

Technical root cause

  • packages/muya/src/ui/inlineFormatToolbar/config.ts — COMMAND_KEY + 'B' etc. are hardcoded and rendered as the tooltip title (index.ts → _createIconItem). Decoupled from desktop keybindings.json; hand-aligned to the default bindings (see 选中文字时的弹出选项快捷键和快捷键设置中的不统一 #3630).
  • packages/muya/src/ui/inlineFormatToolbar/index.ts — FORMAT_SHORTCUTS / FORMAT_SHORTCUTS_SHIFT hardcoded internal handler.

Possible fix direction (kept out of #4681 because it spans the self-contained @muyajs/core engine, whose design keeps the engine unaware of the desktop key map): give InlineFormatToolbar an optional shortcut-map option that falls back to the current hardcoded defaults (so standalone muya / examples are unaffected); the desktop builds the map from the current keybindings and passes/updates it on change. The same map can drive the internal handler so the behavior follows suit.

Steps to Reproduce

  1. Open Preferences → Keybindings.
  2. Change a format shortcut — e.g. rebind format.strong (Bold) to a custom combo — and save.
  3. In the editor, select some text so the inline format toolbar appears.
  4. Hover the Bold button and read the shortcut hint in its tooltip.
  5. (Behavior) Press the old default combo (e.g. ⌘B) on a selection.

Expected Behavior

  • The tooltip shows the user's custom shortcut, matching the menu bar and command palette.
  • Only the currently-bound shortcut applies the format.

Actual Behavior

  • The tooltip still shows the hardcoded default (e.g. ⌘+B).
  • The old default combo still applies the format via muya's internal handler.

Screenshots / Logs

None.

Operating System

All platforms (macOS / Windows / Linux).

MarkText Version

develop (0.20.0-dev) — applies to the @muyajs/core editor engine.

OS Version

N/A (platform-independent).

Reproducibility

  • I can reliably reproduce this issue

Activity

  1. Jocs commented on Sep 30, 2026

    @Jocs
    MemberAuthor
  2. Jocs commented on Oct 7, 2026

    @Jocs
    MemberAuthor

    Dup with #2999

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions