From 6eb9032c46c542795f7b81625c4522f3fc8ea2e3 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Sun, 16 Aug 2026 01:28:28 +0200 Subject: [PATCH] fix: paste no longer stamps a font the document never had MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit transformPasted fell back to a DEFAULT_EDITOR_FONT of 'Georgia' — the comment said it had to match ToolbarExpanded's, which is Liberation Serif. Text pasted where the caret carries no font mark got Georgia as direct formatting, and pasting into a heading overrode its sans font. Only an explicit font at the caret is carried over now. --- src/lib/components/Editor.svelte | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index 8183468..8b5a271 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -51,8 +51,6 @@ import { EMPTY_PAGE_DECOR, type PageDecor } from '../storage/pageDecor'; import { withShortcut } from '../i18n/shortcut'; import '../../styles/editor.css'; - const DEFAULT_EDITOR_FONT = 'Georgia'; // must match ToolbarExpanded.svelte - let { editor = $bindable(), tick = $bindable(0), currentPage = $bindable(1), numPages = $bindable(1), zoom = 100, onZoom, showFormattingMarks = false, showRuler = true, splitView = false, pageColumns = 1, pageMargins = DEFAULT_MARGINS, orientation = 'portrait', @@ -1056,8 +1054,10 @@ import { EMPTY_PAGE_DECOR, type PageDecor } from '../storage/pageDecor'; const textStyleType = view.state.schema.marks.textStyle; if (!textStyleType) return slice; const cursorMarks = view.state.storedMarks ?? view.state.selection.$head.marks(); - const cursorFont = cursorMarks.find(m => m.type === textStyleType)?.attrs.fontFamily as string | undefined; - const font = cursorFont ?? DEFAULT_EDITOR_FONT; + // Only an explicit font at the caret is carried over: with none, the pasted + // text inherits the paragraph's style, as it does in both word processors. + const font = cursorMarks.find(m => m.type === textStyleType)?.attrs.fontFamily as string | undefined; + if (!font) return slice; return new Slice(applyFontToFragment(slice.content, textStyleType, font), slice.openStart, slice.openEnd); }, },