Skip to content

feat: add markdown formatting keyboard shortcuts - #6255

Closed
canakyuz wants to merge 1 commit into
usememos:mainfrom
canakyuz:feat/markdown-formatting-shortcuts
Closed

feat: add markdown formatting keyboard shortcuts#6255
canakyuz wants to merge 1 commit into
usememos:mainfrom
canakyuz:feat/markdown-formatting-shortcuts

Conversation

@canakyuz

Copy link
Copy Markdown

Closes #6253

Adds keyboard shortcuts for the existing formatting commands: Mod-B (bold), Mod-I (italic), Mod-Shift-X (strikethrough), Mod-E (inline code), Mod-K (link), matching Obsidian/Notion conventions. Mod- is Cmd on macOS and Ctrl elsewhere.

The keymap dispatches the same runFormattingCommand the toolbar uses, so toggle/strip behavior can never diverge between mouse and keyboard. Only inline marks and link are bound: block commands (lists, headings, code block) have no widely shared convention, and unused bindings would shadow browser/OS shortcuts for no gain.

Also: inserting a link without a URL now places the cursor between the parens ([label](|)), ready to type the target; with a URL supplied the cursor still lands after the finished link.

Changes

  • Editor/formatting.ts: extracted the controller's run body into an exported runFormattingCommand (controller delegates to it) + the link cursor placement
  • Editor/formattingKeymap.ts (new): the five bindings, each with preventDefault so browser chords like Ctrl-K never fire
  • Editor/extensions.ts: keymap wired above defaultKeymap so the formatting chords win
  • tests/memo-editor-formatting-keymap.test.ts (new): chord table, toolbar parity, link cursor placement

Testing

  • Full web suite passes: 144 files / 1127 tests
  • pnpm run lint (tsc + biome) clean

@canakyuz
canakyuz requested a review from a team as a code owner August 31, 2026 22:41
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 10c8fbfd-35bc-4224-b3e7-7b218c1acb28

📥 Commits

Reviewing files that changed from the base of the PR and between de843f6 and d4fe1b5.

📒 Files selected for processing (4)
  • web/src/components/MemoEditor/Editor/extensions.ts
  • web/src/components/MemoEditor/Editor/formatting.ts
  • web/src/components/MemoEditor/Editor/formattingKeymap.ts
  • web/tests/memo-editor-formatting-keymap.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

Adds shared formatting command dispatch and five memo-editor shortcuts: bold, italic, strikethrough, code, and link. The new keymap runs before the default keymap and prevents browser defaults. Link insertion now places the cursor before the closing parenthesis when the URL is empty. Tests cover shortcut handling, bold toggling, and link cursor placement.

Suggested reviewers: boojack, bluedbird

Merge Risk: ⚪ Minimal · up to d4fe1

The change adds localized formatting shortcuts and improves empty-link cursor placement without affecting services, permissions, persistence, or deployment behavior. No actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: adding Markdown formatting keyboard shortcuts.
Description check ✅ Passed The description is directly related to the changeset and explains the shortcuts, implementation, link cursor behavior, and tests.
Linked Issues check ✅ Passed The implementation satisfies issue [#6253] by adding keyboard shortcuts for Markdown formatting and aligning them with conventions from compatible applications.
Out of Scope Changes check ✅ Passed All changes support the formatting shortcut feature. The link cursor placement update directly improves the Mod-K workflow and is covered by the pull request objectives and tests.
  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds CodeMirror keyboard shortcuts for five inline Markdown formatting commands and routes them through the same command implementation used by the toolbar. It also adjusts URL-less link insertion so the cursor is positioned inside the destination parentheses.

  • Adds Mod-B, Mod-I, Mod-Shift-X, Mod-E, and Mod-K formatting bindings.
  • Places formatting bindings ahead of CodeMirror’s default keymap.
  • Extracts a shared formatting-command runner for toolbar and keyboard parity.
  • Adds keymap, formatting parity, and link-selection tests.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete behavioral, security, or compatibility defects identified.

The shortcuts are ordered ahead of default CodeMirror bindings, delegate to the established formatting implementation, and preserve editor update propagation; the changed link offset correctly targets the boundary between the destination parentheses.

Important Files Changed

Filename Overview
web/src/components/MemoEditor/Editor/extensions.ts Wires the formatting keymap ahead of the default keymap without conflicting with the existing submit, Tab, or Escape bindings.
web/src/components/MemoEditor/Editor/formatting.ts Extracts formatting dispatch into a shared function and correctly places the cursor inside empty link-destination parentheses.
web/src/components/MemoEditor/Editor/formattingKeymap.ts Defines conventional modifier shortcuts that invoke existing formatting commands and suppress competing browser defaults.
web/tests/memo-editor-formatting-keymap.test.ts Covers binding declarations, shared bold-toggle behavior, and both branches of link cursor placement, though not end-to-end keyboard-event dispatch.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  K[Formatting keyboard shortcut] --> M[CodeMirror formatting keymap]
  T[Toolbar action] --> C[Formatting controller]
  M --> R[runFormattingCommand]
  C --> R
  R --> D[Dispatch document and selection update]
  D --> U[Editor update listener]
  U --> S[Refresh formatting state]
Loading

Reviews (1): Last reviewed commit: "feat: add markdown formatting keyboard s..." | Re-trigger Greptile

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.

Add markdown formatting keyboard shortcuts

2 participants