From ee801967f614fc1f12d5e75f57f5dea5b75f5af1 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Sat, 15 Aug 2026 10:27:18 +0200 Subject: [PATCH] feat: words typed once are offered back MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LibreOffice's Word Completion, its defaults included: words from eight letters up are collected as they are finished, and the first three letters offer the rest. The offer is a widget decoration after the caret, so it is outside the document until Enter takes it — nothing to undo when it is not taken. Only while typing: a bare caret move drops the offer, or an Enter meant to split the paragraph would complete a word instead. The settings share the AutoCorrect dialog, as they share LibreOffice's. --- CHANGELOG.md | 3 +- src/lib/components/AutoCorrectDialog.svelte | 70 ++++++++++++++- src/lib/editor/extensions.ts | 2 + src/lib/editor/extensions/CLAUDE.md | 1 + src/lib/editor/extensions/wordCompletion.ts | 99 +++++++++++++++++++++ src/lib/i18n/locales/de.ts | 9 ++ src/lib/i18n/locales/en.ts | 9 ++ src/lib/storage/CLAUDE.md | 1 + src/lib/storage/wordCompletion.svelte.ts | 23 +++++ src/lib/storage/wordCompletion.ts | 41 +++++++++ src/lib/utils/wordCompletion.ts | 43 +++++++++ src/styles/editor.css | 7 ++ tests/unit/word-completion.test.ts | 98 ++++++++++++++++++++ 13 files changed, 404 insertions(+), 2 deletions(-) create mode 100644 src/lib/editor/extensions/wordCompletion.ts create mode 100644 src/lib/storage/wordCompletion.svelte.ts create mode 100644 src/lib/storage/wordCompletion.ts create mode 100644 src/lib/utils/wordCompletion.ts create mode 100644 tests/unit/word-completion.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fb6dc7..90d82cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ - Tab stops per paragraph: left, centre, right and decimal, honoured in the rendered text (CSS only has a fixed tab grid, so each tab is measured and placed); a hanging indent implies a stop at the text position. Set them on the ruler; round-trips to ODF `style:tab-stops` and DOCX `w:tabs` - Paragraph borders and shading: per-side borders with presets (all / single edges / none), width and color, plus a background fill, on paragraphs and headings; typing `---`, `___` or `===` on a line of its own turns it into a rule line (Word/LibreOffice AutoCorrect). Round-trips to ODF `fo:border-*`/`fo:background-color` and DOCX `w:pBdr`/`w:shd` - AutoCorrect while typing (LibreOffice's Tools ▸ AutoCorrect Options, one checkbox per rule): typographic quotes per document language (`"…"` / `„…“`), its dash matrix (`A - B` → `A – B`, `A--B` → `A—B`), its replacement table (`-->` → `→`, `(C)` → `©`, `...` → `…`), capitalize the first letter of a sentence — with an abbreviation exception list — and TWo INitial CApitals. URL recognition and auto-list ride the same switches +- Word completion (the same dialog's own section, as LibreOffice keeps it): every word of at least eight letters is remembered as it is typed, and typing its first three letters offers the rest in grey after the caret — Enter takes the offer, Esc drops it. It is offered while typing only, so an Enter meant to split a paragraph never completes a word instead, and the offer stays outside the document until it is accepted. Minimum length, an appended space and clearing the collected words are all settable - Automatic hyphenation for the whole document (Layout ▸ Hyphenation): the browser hyphenates in the document's own language, which shortens a justified paragraph the way LibreOffice does. Round-trips as ODF `fo:hyphenate` on the base style — where LibreOffice keeps it, in its *text* properties — and Word's `w:autoHyphenation` - Manual line breaks (Shift+Enter) @@ -160,7 +161,7 @@ The gap against Word/LibreOffice, most valuable first. Reviewed 2026-08-14. - Linked / chained text frames - Find & Replace by font, size or colour — the weight/slant/underline and paragraph-style half is implemented, but LibreOffice's Format dialog is the whole character dialog - Multi-document management: one document is open at a time, so there is no window list and no side-by-side compare -- Thesaurus, grammar check, word completion, AutoText / building blocks +- Thesaurus, grammar check, AutoText / building blocks - Vertical writing modes (ODF `tb-rl`) and Asian typography (ruby) - Password-protected ODT/DOCX; digital signatures - Split view: two views of one document, scrolled independently diff --git a/src/lib/components/AutoCorrectDialog.svelte b/src/lib/components/AutoCorrectDialog.svelte index a9d6454..d8003c5 100644 --- a/src/lib/components/AutoCorrectDialog.svelte +++ b/src/lib/components/AutoCorrectDialog.svelte @@ -1,9 +1,12 @@