The root file is read at every session start and had grown to 87 KB, so every session paid for knowledge it did not use. Move the per-directory detail into nested CLAUDE.md files, which load when a file in that directory is touched, and the five deep-dive topics into docs/. The root keeps the commands, the hard rules and an index of where the rest lives. Content moved verbatim — the probed Word/LibreOffice behaviour, sentinel order and shared constants are what the code cannot say. CI fails the root over 120 lines, since a prose budget alone is what let it grow.
3.7 KiB
src/lib/editor/
The TipTap extension registry (extensions.ts), the shortcut table, and the context-menu
builder. Per-extension notes live in extensions/CLAUDE.md.
Keyboard shortcuts (shortcuts.ts, extensions/shortcuts.ts)
Word/LibreOffice key bindings. editor/shortcuts.ts is the single source of truth:
DEFAULT_SHORTCUTS maps a stable id to a combo in ProseMirror keymap syntax, and every
binding site reads it (the Shortcuts extension, App.svelte's window handler, and the
Mod-k/Mod-Enter/Mod-m/Tab bindings still owned by link.ts/pageBreak.ts/
paragraphStyle.ts/indent.ts) — a planned remapping UI overrides that map alone.
TipTap's own defaults (Mod-b/i/u, Mod-Shift-s/h, Mod-z, Mod-Shift-7/8,
Mod-Shift-l/e/r/j) are not in the table; they aren't ours to bind.
matchesEvent(e, combo) serves the window handler (no keymap there), shortcutHint(id)
the tooltips (via withShortcut, which localizes Ctrl/Shift/Alt and swaps in ⌘/⇧/⌥ on Mac).
Shortcutsextension —priority: 1000soMod-Alt-Nbeats Heading'stoggleHeading(headings are applied as named styles) andMod-Shift-bbeats Bold'sMod-Balias. Optionbody: true(onlyextensions.ts) adds the bindings whose commands the header/footer schema lacks;hfExtensions()registers the bare extension, which contributes the shared set only (alignment, sub/superscript, font grow/shrink, NBSP, soft hyphen).Mod-Alt-<digit>can't go through the keymap: Windows reads Ctrl+Alt as AltGr, soevent.keyis layout-dependent (German AltGr+2 =²) and prosemirror-keymap skips its keyCode fallback for exactly that modifier pair. Those six run inaddProseMirrorPluginsoffevent.code(Digit0–Digit5) instead.- Deliberate resolutions:
Mod-mstays LibreOffice's clear formatting (Word's increase-indent is Tab);Ctrl+1/2/5are Word's line spacing, so headings are Ctrl+Alt+N only;Mod-Shift-sstays strikethrough, so there's no Save-As key; sub/superscript follow LO (Mod-Shift-b/Mod-Shift-p) because Word'sCtrl+=pair collides with zoom; formatting marks use LO'sCtrl+F10(Word'sCtrl+Shift+8is TipTap's bullet list).Ctrl+Nis unbindable in Chrome and therefore absent. tests/unit/shortcuts.test.tsasserts the table has no duplicate combo (the bindings are spread over several files, so nothing else can catch a collision) and coversmatchesEvent.
Right-click context menu (contextMenuItems.ts, components/ContextMenu.svelte)
Word's text context menu: clipboard, link, clear formatting — with the spelling
suggestions merged in as the first section (the old SpellContextMenu.svelte).
Deliberately flat: no submenus, so no indent column either.
buildContextMenu(editor, { spell }) returns a MenuEntry[]
(item/sep) whose run closures call the same commands the toolbars use;
ContextMenu.svelte only renders it, positioned as a sibling of the zoomed .paper so
it stays constant-size. Editor.svelte's openContextMenu (one oncontextmenu on
.editor) picks the caret (keeping a selection the click lands in, as Word does), reads
spellErrorAt, and builds the list. It bails on Shift+right-click (the browser menu,
whose Paste needs no clipboard permission — Firefox does this for page handlers anyway),
on images/text boxes (their floating toolbars), and in the header/footer (the HF schema
has none of the entries). Cut/copy go through document.execCommand so ProseMirror's own
copy handler builds the clipboard payload; paste reads navigator.clipboard and falls
back to an alert where the browser blocks it. The menu clamps itself into the viewport
via transforms, measured from layout offsets so the correction can't feed back into the
next measurement.