Inline-formatting keyboard shortcuts (⌘B/⌘I/⌘E/⌘⇧K) - #136
Draft
dylandeheer wants to merge 2 commits into
Draft
Conversation
The theme can recolor every element except heading text (it inherits bodyText), and the heading config covers every metric except the face — so an embedder that wants serif display headings over a sans body has to fork. HeadingStyle.fontName picks a PostScript face for headings, honored exactly so the chosen weight survives; an unresolvable name falls back to the stock bold base font, like TaskCheckboxStyle's symbol fallback. MarkdownEditorTheme.headingText colors heading text while the `#` glyphs stay on headingMarker and inline constructs inside a heading keep their own ink. Emphasis inside a heading still composes on top of the configured face (traits added, family and per-level size kept). Both knobs default to nil, which keeps styling identical to before. Co-authored-by: Cursor <cursoragent@cursor.com>
Key equivalents for the coordinator's existing toggleable formatting actions: ⌘B wraps/unwraps bold, ⌘I italic, ⌘E inline code, ⌘⇧K inserts the [text](url) link scaffold. Wired in performKeyEquivalent so the keys work regardless of menu setup, gated by MarkdownEditorConfiguration.formattingShortcutsEnabled (default on, mirroring the list helpers). Only exact modifier matches are consumed; plain ⌘K is deliberately left untouched because it is a common embedder binding (command palettes). Co-authored-by: Cursor <cursoragent@cursor.com>
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.
What
Key equivalents for the coordinator's existing toggleable formatting actions:
**wrap/unwrap;***both***→*italic*)*wrap/unwrap)`wrap/unwrap)[text](url))How
NativeTextView.performKeyEquivalent(the existing ⌘↵ seam) routes exact-modifier matches to thedidMarkdown*actions the context menu already drives, so wrap/unwrap/toggle semantics and caret placement are the proven ones covered byFormattingActionTests. Gated byMarkdownEditorConfiguration.formattingShortcutsEnabled(default ON, mirroringlists.helpersEnabled).Plain ⌘K is deliberately NOT consumed: the engine has no binding on it, but it is a common embedder key (command palettes), so the link scaffold lives on ⌘⇧K only.
Defaults
On by default (the keys previously did nothing in the editor); embedders that own these keys set
formattingShortcutsEnabled = false. Only exact modifier matches are consumed — every other ⌘-combination keeps flowing to menus and the responder chain, and read-only editors never consume the keys.Tests
FormattingShortcutTests: dispatch for all four shortcuts including toggle round-trips, plain-⌘K and extra-modifier pass-through, the config gate, read-only pass-through, and the default. Full suite green.Made with Cursor