From 91a37c5652e675fce376ff2ffe3e3ad751268210 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Sun, 31 May 2026 15:41:25 +0200 Subject: [PATCH] fix: heading line space --- src/lib/editor/ToolbarExpanded.svelte | 2 +- src/lib/editor/lineHeight.ts | 12 ++++++------ src/lib/export/odt.ts | 3 +++ src/styles/editor.css | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/lib/editor/ToolbarExpanded.svelte b/src/lib/editor/ToolbarExpanded.svelte index 90b0972..ab83038 100644 --- a/src/lib/editor/ToolbarExpanded.svelte +++ b/src/lib/editor/ToolbarExpanded.svelte @@ -158,7 +158,7 @@ }); // Must match line-height in editor.css (.paper .tiptap) - const DEFAULT_LINE_HEIGHT = '1.5'; + const DEFAULT_LINE_HEIGHT = '1'; const LINE_HEIGHTS = [ { value: '1', label: 'Single' }, { value: '1.15', label: '1.15' }, diff --git a/src/lib/editor/lineHeight.ts b/src/lib/editor/lineHeight.ts index 95bef54..0996ef9 100644 --- a/src/lib/editor/lineHeight.ts +++ b/src/lib/editor/lineHeight.ts @@ -39,14 +39,14 @@ export const LineHeight = Extension.create({ addCommands() { return { setLineHeight: (lineHeight: string) => ({ commands }) => { - return this.options.types.every((type) => - commands.updateAttributes(type, { lineHeight }) - ); + return this.options.types + .map((type) => commands.updateAttributes(type, { lineHeight })) + .some((r) => r); }, unsetLineHeight: () => ({ commands }) => { - return this.options.types.every((type) => - commands.resetAttributes(type, 'lineHeight') - ); + return this.options.types + .map((type) => commands.resetAttributes(type, 'lineHeight')) + .some((r) => r); }, }; }, diff --git a/src/lib/export/odt.ts b/src/lib/export/odt.ts index 9162a3d..ae9c9db 100644 --- a/src/lib/export/odt.ts +++ b/src/lib/export/odt.ts @@ -12,6 +12,7 @@ const CUST_P = '__cust_p__'; const CUST_H = '__cust_h__'; const DEFAULT_FONT = 'Georgia'; // must match DEFAULT_EDITOR_FONT in ToolbarExpanded.svelte +const DEFAULT_LINE_HEIGHT = 1; // must match line-height in editor.css (.paper .tiptap) function hasCustomAttrs(attrs: TiptapNode['attrs']): boolean { if (!attrs) return false; @@ -177,6 +178,8 @@ export async function exportToOdt(editor: Editor): Promise { const lhRaw = String(node.attrs.lineHeight); const lhNum = parseFloat(lhRaw); opts.lineHeight = isNaN(lhNum) ? lhRaw : lhNum; + } else { + opts.lineHeight = DEFAULT_LINE_HEIGHT; } const ta = node.attrs?.textAlign; if (ta === 'left' || ta === 'center' || ta === 'right' || ta === 'justify') { diff --git a/src/styles/editor.css b/src/styles/editor.css index 053ef6a..e1839ec 100644 --- a/src/styles/editor.css +++ b/src/styles/editor.css @@ -24,7 +24,7 @@ outline: none; font-family: var(--font-serif); font-size: 1.05rem; - line-height: 1.5; + line-height: 1; color: var(--color-page-text); /* Multi-page background: page surfaces separated by editor background */ @@ -109,7 +109,7 @@ .paper .tiptap h2, .paper .tiptap h3 { font-weight: 700; - line-height: 1.3; + line-height: 1; margin-top: 1.5em; margin-bottom: 0.5em; }