Add strikethrough shortcut, fenced code toggle, and CodeMirror-aware undo/redo

- Bind Ctrl+Shift+S to strikethrough
- Smart code toggle: fenced block for multi-line selections, inline otherwise
- Link editing: selecting an existing link now selects its URL for editing
- Route undo/redo shortcuts through IPC so CodeMirror history is used when
  the editor has focus instead of Electron's native menu-role undo/redo
- Add Indent/Outdent toolbar buttons
This commit is contained in:
avi 2026-08-17 13:02:42 -05:00
commit 45990bbd62
9 changed files with 185 additions and 12 deletions

View file

@ -141,12 +141,50 @@ const BOOK_DIR = __BOOKDIR_VALUE__;
await new Promise((r) => setTimeout(r, 50));
out.redoOk = cm.state.doc.toString().startsWith("## ");
cm.dispatch({ selection: { anchor: 15, head: 20 } }); // "World"
cm.contentDOM.dispatchEvent(
new KeyboardEvent("keydown", {
key: "s",
ctrlKey: true,
shiftKey: true,
bubbles: true,
cancelable: true,
})
);
await new Promise((r) => setTimeout(r, 50));
out.strikeShortcutOk = cm.state.doc.toString().includes("~~World~~");
cm.dispatch({
changes: { from: 0, to: 0, insert: "line one\nline two\n" },
selection: { anchor: 0, head: 16 },
});
document.querySelector('[data-cmd="code"]').click();
await new Promise((r) => setTimeout(r, 50));
out.fencedCodeOk = cm.state.doc.toString().startsWith("```\nline one\nline two\n```");
await new Promise((r) => setTimeout(r, 1200)); // wait for autosave debounce
out.formattingAutosaved =
(await window.folio.getChapterContent(typedId)).includes("**Hello**");
}
out.all = true;
const okFlags = [
"dndMoved",
"kbMoved",
"modalShown",
"uiCreated",
"hasEditor",
"editorAutosaved",
"toolbarBoldOk",
"focusAfterBold",
"shortcutBoldOk",
"headingOk",
"undoOk",
"redoOk",
"strikeShortcutOk",
"fencedCodeOk",
"formattingAutosaved",
];
out.all = okFlags.every((f) => out[f] === true);
} catch (e) {
out.error = String((e && e.message) || e);
}