LibreOffice adds the upper block's space-below to the lower one's
space-above, and drops the space-above where a page break put the block
at a page top — but for a Word document it takes only the larger of the
two (all probed against soffice). CSS margins can only collapse, so
space-before rides --space-before and editor.css renders it as padding
('add') or margin ('max'); the model is read from settings.xml, assumed
for DOCX, and written back on ODF export.
4.9 KiB
4.9 KiB
src/lib/editor/extensions/
One file per feature (image.ts, indent.ts, …), never XyzExtension.ts. All are assembled in
../extensions.ts, which also lists the TipTap built-ins in use (Bold, Italic, Highlight
multicolor, TextStyle/FontFamily/FontSize, Heading, HardBreak, lists, Table family, History,
Placeholder, TextAlign). Document is widened to '(block | textBox | columns)+'.
Five topics are large enough to have their own deep-dive — read the file before changing them:
| Extension | Deep-dive |
|---|---|
pageBreaks.ts, columns.ts, columnsFlow.ts |
docs/architecture/pagination.md |
image.ts, textBox.ts |
docs/architecture/frames.md |
table*.ts, tableStyle.ts |
docs/architecture/tables.md |
textEffects.ts, indent.ts, tabStops.ts, listMarker.ts, paragraphBox.ts, dateTimeField.ts, bookmark.ts, crossReference.ts |
docs/architecture/formatting.md |
formula.ts |
docs/architecture/formulas.md |
paragraphStyle.ts, characterStyle.ts |
src/lib/styles/CLAUDE.md |
The rest, one line each
fontColor.ts(FontColor) —colorattr on the TextStyle mark; also emitsdata-colorso theme CSS (allBlack) can target color-bearing spans.fontWeight.ts(FontWeight) —fontWeightattr on TextStyle (setnormalto un-bold a heading without changing the node type).lineHeight.ts(LineHeight) —lineHeightattr on paragraph/heading.LINE_HEIGHT_RATIO = 1.15: ODF line spacing multiplies the font's natural line height (Liberation Serif ≈1.15× em), CSS multiplies the font size — so the on-screen value is scaled to match what LibreOffice renders. A spacing above single puts all of its extra leading below each line (probed: at 150% LibreOffice starts line 1 flush under the block above and adds 6.9pt after every line, the last included); CSS half-leads it, soeditor.cssshifts the block up by that half withposition:relative; top:— flow, and so pagination, unchanged.paragraphSpacing.ts(ParagraphSpacing) —spaceBefore/spaceAfterin pt, round-tripping 1:1 tofo:margin-top/fo:margin-bottom. Space after is a margin, space before rides--space-before(storage/spacingModel.tsdecides padding vs margin); pageBreaks.ts drops it where a page break put the block at a page top, as LibreOffice does.blockFontSize.ts— the font of the paragraph mark (Wordw:pPr/w:rPr, ODF the paragraph's own text properties).pageBreak.ts— the text-flow attrs of a paragraph/heading:breakBefore: 'page', pluskeepNext/keepLines(seedocs/architecture/pagination.md). OwnsMod-Enter.formattingMarks.ts(FormattingMarks) — decorations marking spaces (·) and tabs (→) when.paper.show-formatting-marksis set.bulletList.ts/orderedList.ts— the TipTap lists plus a marker-type attr:setBulletChar(innermost list,null= default cycle) and the ordered numbering cycle (utils/orderedListTypes.ts, multilevel targets the outermost list).link.ts— hyperlink mark; ownsMod-k, which fires the eventToolbar.sveltelistens for to open the link dialog. A#namehref targets a bookmark:Editor.svelte'shandleClickscrolls to it instead of opening a tab.bookmark.ts/crossReference.ts— a named range of text (a mark) and the live references to it (REF/PAGEREF).ToolbarExpanded.svelteowns both dialogs, as it does the link one.searchReplace.ts— Find & Replace: decorations highlight all matches, commands navigate/replace. Touches the document only for actual replacements.spellCheck.ts— decorations fromspell/controller.ts;spellErrorAtfeeds the context menu.tableOfContents.ts— a generated TOC: block atom listing every heading down tomaxLevel(ODFtext:outline-level, Word'sTOC \orange, default 5 — listing deeper than the file asks inflates the block by pages).title: ''is an index that deliberately has none (its heading is a separate paragraph, as Word and LibreOffice write it); only a missing title falls back to "Table of Contents".trailingNode.ts— keeps an empty paragraph after a trailing table, text box or columns section (they are isolating, so the caret would otherwise have nowhere to go).headerFooter.ts(hfExtensions) — the header/footer schema:Documentconstrained to one paragraph, the body's marks,HardBreak,TextAlign, and the twopageField.tsatoms. No image, no date field, no table.pageField.ts— inline atomspageNumber/pageCount, rendered as<span data-page-field>;HeaderFooterLayer.sveltepatches each span's text to the real per-page value.shortcuts.ts— seesrc/lib/editor/CLAUDE.md.
extensions.ts deliberately keeps TipTap's resizable: false (its columnResizing plugin stays
unloaded) and supplies the custom table view + drag plugins instead.