feat: a tab lands on the file's own grid, and can draw its leader

The default tab interval was fixed at 1.25cm, so a file's own
w:defaultTabStop / style:tab-stop-distance was ignored and the DOCX
export wrote 1.25 back over Word's 1.27. It is a document setting now.

A stop can also carry the character it repeats across its gap. odf-kit
has no leader option and mints one automatic style per option set, so
the leader rides style:type behind a sentinel — matching on position
and alignment alone gave every stop at 6cm the same leader, which
LibreOffice drew back plain as day.
This commit is contained in:
Steffen Becker committed 2026-08-08 14:40:26 +00:00
1 parent 6accc7268f
commit ea39dde58b
20 files changed
+319 -39

No files matched your search

+5 -2
View File
@@ -19,6 +19,7 @@
import Ruler from './Ruler.svelte';
import { saveDocument, loadDocument } from '../storage/autosave';
import { applyMarginVars, cmToPx, DEFAULT_MARGINS, type PageMargins } from '../storage/pageMargins';
import { DEFAULT_TAB_INTERVAL_CM } from '../storage/tabInterval';
import { type Orientation } from '../storage/pageOrientation';
import { applyPageSizeVars, type PageFormat } from '../storage/pageFormat';
import { DEFAULT_HF_DISTANCES, hfIsEmpty, type HfDoc, type HfZone, type HfDistances, type HfSet } from '../storage/headerFooter';
@@ -36,7 +37,7 @@
let {
editor = $bindable(), tick = $bindable(0), currentPage = $bindable(1), numPages = $bindable(1),
zoom = 100, onZoom, showFormattingMarks = false, showRuler = true, pageMargins = DEFAULT_MARGINS, orientation = 'portrait',
pageFormat = 'A4',
pageFormat = 'A4', tabIntervalCm = DEFAULT_TAB_INTERVAL_CM,
headerDoc = $bindable(null), footerDoc = $bindable(null), hfDistances = DEFAULT_HF_DISTANCES,
headerFirstDoc = $bindable(null), footerFirstDoc = $bindable(null), differentFirstPage = false,
headerEvenDoc = $bindable(null), footerEvenDoc = $bindable(null), differentOddEven = false,
@@ -45,7 +46,7 @@
}: {
editor: Editor | null; tick: number; currentPage: number; numPages: number; zoom: number;
onZoom?: (zoom: number) => void;
showFormattingMarks?: boolean; showRuler?: boolean; pageMargins?: PageMargins; orientation?: Orientation; pageFormat?: PageFormat;
showFormattingMarks?: boolean; showRuler?: boolean; pageMargins?: PageMargins; orientation?: Orientation; pageFormat?: PageFormat; tabIntervalCm?: number;
headerDoc?: HfDoc; footerDoc?: HfDoc; hfDistances?: HfDistances;
headerFirstDoc?: HfDoc; footerFirstDoc?: HfDoc; differentFirstPage?: boolean;
headerEvenDoc?: HfDoc; footerEvenDoc?: HfDoc; differentOddEven?: boolean;
@@ -126,6 +127,8 @@
void (pageMargins.top + pageMargins.bottom + pageMargins.left + pageMargins.right);
void orientation;
void pageFormat;
// …the tab grid, which changes where a tab lands and so where a line breaks…
void tabIntervalCm;
// …and the header/footer-driven effective margins, so growing a zone re-paginates.
void (effTopRest + effTopFirst + effBottomRest + effBottomFirst);
void sectionReach;
+2 -1
View File
@@ -77,7 +77,8 @@
strip.releasePointerCapture(event.pointerId);
if (target.kind === 'stop') {
const rest = info.stops.filter((_, i) => i !== target.index);
apply(off ? rest : [...rest, { pos: cm, align: info.stops[target.index].align }]);
// Dragging moves the stop, so it keeps its alignment and its leader.
apply(off ? rest : [...rest, { ...info.stops[target.index], pos: cm }]);
} else if (target.kind === 'indent') {
// Moves the whole block: the first line keeps its offset from the indent.
editor?.chain().focus().setIndent(Math.max(0, cm)).run();