From bc8f8d89d159f4cd08142006d705a0fa79f548f2 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Thu, 3 Sep 2026 23:22:37 +0200 Subject: [PATCH] fix: the empty document's placeholder follows the UI language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The body said "Start typing…" in every language while the header and footer zones were localized; switching the language now redraws it. --- src/lib/components/Editor.svelte | 7 +++++++ src/lib/editor/extensions.ts | 3 ++- src/lib/i18n/locales/de.ts | 1 + src/lib/i18n/locales/en.ts | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index b152ecf..f1359d8 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -1134,6 +1134,13 @@ import { EMPTY_PAGE_DECOR, type PageDecor } from '../storage/pageDecor'; waitForSettled(); }); + // The placeholder is a decoration, redrawn only by a view update; the UI language + // switching is not one, so give it a push. + $effect(() => { + t(); + editor?.view.updateState(editor.view.state); + }); + onMount(async () => { // Start with empty history lists — loaded content is not an undoable edit. resetHistoryLog(); diff --git a/src/lib/editor/extensions.ts b/src/lib/editor/extensions.ts index d8d2e66..eddc211 100644 --- a/src/lib/editor/extensions.ts +++ b/src/lib/editor/extensions.ts @@ -24,6 +24,7 @@ import { Table, TableHeader, TableCell } from '@tiptap/extension-table'; import { ResizableTableRow } from './extensions/tableRow'; import History from '@tiptap/extension-history'; import Placeholder from '@tiptap/extension-placeholder'; +import { t } from '../i18n/i18n.svelte'; import { PageBreaks } from './extensions/pageBreaks'; import { LineHeight } from './extensions/lineHeight'; @@ -224,7 +225,7 @@ export const extensions = [ // and the user can keep writing below a table at the document's end. TrailingNode, History, - Placeholder.configure({ placeholder: 'Start typing…' }), + Placeholder.configure({ placeholder: () => t().app.startTyping }), // No defaultAlignment: it would put textAlign:'left' on every block, and that inline // style beats the paragraph style's alignment. Unset = follow the style; an explicit // 'left' stays direct formatting that overrides it, as in Word/LibreOffice. diff --git a/src/lib/i18n/locales/de.ts b/src/lib/i18n/locales/de.ts index c3dc5b5..fdb66e1 100644 --- a/src/lib/i18n/locales/de.ts +++ b/src/lib/i18n/locales/de.ts @@ -1035,6 +1035,7 @@ const de: Messages = { app: { documentName: 'Dokumentname', untitled: 'Unbenanntes Dokument', + startTyping: 'Hier tippen…', newDocument: 'Neues Dokument', open: 'Öffnen…', save: '.odt speichern', diff --git a/src/lib/i18n/locales/en.ts b/src/lib/i18n/locales/en.ts index 3366617..bb7be8a 100644 --- a/src/lib/i18n/locales/en.ts +++ b/src/lib/i18n/locales/en.ts @@ -1041,6 +1041,7 @@ const en = { app: { documentName: 'Document name', untitled: 'Untitled document', + startTyping: 'Start typing…', newDocument: 'New document', open: 'Open…', save: 'Save .odt',