diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f813b0..5a2f8b5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -67,6 +67,7 @@
- Show formatting marks (spaces, tabs, paragraph marks)
**Editing aids**
+- Word/LibreOffice keyboard shortcuts throughout: Ctrl+L/E/R/J alignment, Ctrl+Alt+1–5 headings and Ctrl+Shift+N default style, Ctrl+1/2/5 line spacing, Ctrl+Shift+P / Ctrl+Shift+B super/subscript, Ctrl+Shift+. / Ctrl+Shift+, grow/shrink font, Ctrl+Space clear formatting, Ctrl+Shift+Space non-breaking space, Ctrl+Shift+- soft hyphen, Alt+Shift+D / Alt+Shift+T date & time field, Ctrl+O open, F3 / Shift+F3 find next/previous, Ctrl+F10 formatting marks — alongside the existing Ctrl+B/I/U, Ctrl+M, Ctrl+K, Ctrl+Enter, Ctrl+F/H, Ctrl+S/P and Tab/Shift+Tab. All bindings live in one table, so tooltips stay in sync and they can be remapped later
- Undo / Redo with a labelled history dropdown
- Search & Replace (Ctrl+F / Ctrl+H): live match highlighting, match count, next / previous, match-case and whole-word options, replace current / replace all
- Spell check in English and German with squiggles and a suggestions context menu (add / ignore word); selectable document language. Powered by Hunspell (WASM), so German compound words (Fußgänger, Krankenversicherung …) are recognised; dictionaries are lazy-loaded per language on demand
diff --git a/src/App.svelte b/src/App.svelte
index fc5024e..b1f1780 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -35,6 +35,7 @@
import AboutDialog from './lib/components/AboutDialog.svelte';
import { t } from './lib/i18n/i18n.svelte';
import { withShortcut } from './lib/i18n/shortcut';
+ import { DEFAULT_SHORTCUTS, matchesEvent, shortcutHint } from './lib/editor/shortcuts';
import { localizeImportMessage } from './lib/i18n/importMessages';
import { unavailableFonts } from './lib/utils/fontDetect';
import { registerEmbeddedFonts, clearEmbeddedFonts } from './lib/fonts/embeddedFonts';
@@ -670,38 +671,30 @@
// FontFace load fires 'loadingdone', which Editor.svelte re-paginates on.
void loadEmbeddedFonts().then(registerEmbeddedFonts);
+ // Shortcuts that must work regardless of focus and that suppress the browser's
+ // own binding (save page, find, open, zoom). Everything editor-scoped lives in
+ // the Shortcuts extension instead.
+ const appActions: [string, () => void][] = [
+ [DEFAULT_SHORTCUTS.save, handleSave],
+ [DEFAULT_SHORTCUTS.open, handleOpen],
+ [DEFAULT_SHORTCUTS.print, handlePrint],
+ [DEFAULT_SHORTCUTS.find, () => openFind('find')],
+ [DEFAULT_SHORTCUTS.replace, () => openFind('replace')],
+ // Closing the bar clears the search, so F3 with no bar starts one.
+ [DEFAULT_SHORTCUTS.findNext, () => (findOpen ? editor?.commands.findNext() : openFind('find'))],
+ [DEFAULT_SHORTCUTS.findPrevious, () => (findOpen ? editor?.commands.findPrevious() : openFind('find'))],
+ [DEFAULT_SHORTCUTS.formattingMarks, () => (showFormattingMarks = !showFormattingMarks)],
+ [DEFAULT_SHORTCUTS.zoomIn, () => setZoom(zoom + 10)],
+ [DEFAULT_SHORTCUTS.zoomOut, () => setZoom(zoom - 10)],
+ [DEFAULT_SHORTCUTS.zoomReset, () => setZoom(100)],
+ ];
+
function onKeydown(e: KeyboardEvent) {
- // Ctrl/Cmd+S → Save (suppress the browser's save-page dialog).
- if ((e.ctrlKey || e.metaKey) && !e.shiftKey && (e.key === 's' || e.key === 'S')) {
+ for (const [combo, run] of appActions) {
+ if (!matchesEvent(e, combo)) continue;
e.preventDefault();
- handleSave();
- }
- // Ctrl/Cmd+P → Print the paginated document (not the whole app UI).
- if ((e.ctrlKey || e.metaKey) && !e.shiftKey && (e.key === 'p' || e.key === 'P')) {
- e.preventDefault();
- handlePrint();
- }
- // Ctrl/Cmd+F → Find, Ctrl/Cmd+H → Find & Replace (suppress the browser's own find).
- if ((e.ctrlKey || e.metaKey) && !e.shiftKey && (e.key === 'f' || e.key === 'F')) {
- e.preventDefault();
- openFind('find');
- }
- if ((e.ctrlKey || e.metaKey) && !e.shiftKey && (e.key === 'h' || e.key === 'H')) {
- e.preventDefault();
- openFind('replace');
- }
- // Ctrl/Cmd +/−/0 → zoom the document, not the browser window.
- if ((e.ctrlKey || e.metaKey) && !e.shiftKey && !e.altKey) {
- if (e.key === '+' || e.key === '=' || e.code === 'NumpadAdd') {
- e.preventDefault();
- setZoom(zoom + 10);
- } else if (e.key === '-' || e.code === 'NumpadSubtract') {
- e.preventDefault();
- setZoom(zoom - 10);
- } else if (e.key === '0' || e.code === 'Numpad0') {
- e.preventDefault();
- setZoom(100);
- }
+ run();
+ return;
}
// Escape closes the bar (when it isn't handled inside an input).
if (e.key === 'Escape' && findOpen) closeFind();
@@ -808,7 +801,7 @@
-