Add markdown formatting hotkeys to the editor

Ctrl/Cmd+B/I/E wrap the selection in bold / italic / inline-code markers,
Ctrl/Cmd+Shift+X in strikethrough, and Ctrl/Cmd+K as a link (with the url
placeholder selected). Pressing the same key on already-wrapped text
removes the markers. Applied to the live selection via the TextEdit
cursor range, with the caret/selection restored around the edit.

Documented in the built-in cheatsheet and the README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
landon
2026-08-04 07:59:19 -05:00
parent a50fc5d521
commit ae8de32f04
3 changed files with 225 additions and 9 deletions
+18
View File
@@ -54,6 +54,24 @@ fn cheatsheet_body(ui: &mut egui::Ui) {
],
);
section(ui, "Formatting hotkeys");
syntax(
ui,
"cs-keys",
&[
("Ctrl/Cmd + B", "Bold the selection (**…**)."),
("Ctrl/Cmd + I", "Italicise the selection (*…*)."),
("Ctrl/Cmd + E", "Inline code (`…`)."),
("Ctrl/Cmd + Shift + X", "Strikethrough (~~…~~)."),
("Ctrl/Cmd + K", "Wrap as a link and select the url to replace."),
],
);
note(
ui,
"Applied to the selected text (or the caret, for an empty selection). \
Pressing the same key on already-wrapped text removes the markers.",
);
section(ui, "Paragraphs & breaks");
syntax(
ui,