Commit Graph
270 Commits
Author SHA1 Message Date
Steffen Becker db0fe71cdb feat: a table keeps the cell margins its file gave it
The cell padding was a constant in three places that disagreed with each
other, so a narrow column lost 0.38cm it did not have: a bibliography
marker column of 0.71cm wrapped "[2] " onto three lines and every entry
grew with it, costing a fixture a whole page.

The table now carries its own margins (w:tblCellMar, direct or from the
table style; fo:padding on the ODF cell style) and both exports write
them back. A side within a twentieth of a millimetre of the default is
the default, or Word's 108 twips would tag every table.
2026-08-08 12:18:16 +00:00
Steffen Becker e4b679ad8b test: find whichever Chromium build is installed
The parity runner pinned one build number, so a fresh
`playwright-core install chromium` left it pointing at a directory that
is not there. PARITY_CHROME still overrides.
2026-08-08 12:17:51 +00:00
Steffen Becker a4209fd622 docs: bring the parity findings up to date
The index draws its leader now, and a frame's vertical offset is a kept
value rather than an ignored one — with the measurement that decided it.
2026-08-08 10:32:29 +00:00
Steffen Becker e4b6133d46 feat: keep a block's lines together, and stop reserving a frame's drop
keepLines (w:keepLines, fo:keep-together) is keepNext's sibling and was the
one of the pair nobody read: a block that declares it now paginates whole,
unless it is taller than a page, where Word splits it too.

The vertical frame offset is data only from here on. A line box avoids a
float's whole margin box, so applying it made dead space where Word flows
text — measured: a fixture's figure page went from 131mm off to 187mm.
2026-08-08 10:28:54 +00:00
Steffen Becker 5968b6a04b fix: a frame keeps its place whatever kind of frame it is
Text boxes and shapes had no offsets at all, and for images the wrap side
overrode the x: a file that names the side its text flows on lost the
coordinate, our own export included. Side and place are read separately now,
and one helper turns both into the float's margins for every frame kind.
2026-08-08 10:17:21 +00:00
Steffen Becker f8c818c203 test: LibreOffice reads every character effect back
The re-save leg is the only place that proves what we write is what LO
understands. A raised run is stored as a percentage of the font size, so the
fixture picks one that stays whole — LO rounds the percentage on save.
2026-08-08 10:08:16 +00:00
Steffen Becker b61fadca48 feat: the character effects Word and LO carry beyond bold and italic
Letter case, the underline's shape and colour, a double strikethrough and a
freely raised run all had no home in the model, so every one of them was
dropped on import. They ride the marks now, render in CSS, and round-trip.

odf-kit's run formatting has a field for none of them, so a sentinel folds
them into the run's own automatic style — the route the character styles
already take, and it reaches every path odf-kit serializes.
2026-08-08 10:06:31 +00:00
Steffen Becker 5549d625f7 feat: the index reads like the one a word processor generates
Its leader is real dots now, not a border, so it scales with the font and
reaches the PDF as text. Title and entries follow the document's Heading 1
and default style, which is what the index styles of Word and LO are based on.
2026-08-08 09:33:25 +00:00
Steffen Becker 34c529e3c4 feat: a floating frame keeps its distance from the anchor paragraph
Word's positionV and ODF's svg:y say how far below its paragraph a frame
sits; ignoring it put every figure at the anchor itself. It is the float's
top margin, so lines that fit above the frame still flow there, as in Word.
2026-08-08 09:22:03 +00:00
Steffen Becker 58607d92e9 docs: say what the parity harness cannot see
It compares where text sits, so a dropped highlight or fill reads as green;
the visual check that catches those, and its two traps, are written down.
Also records the list marker's ~4mm offset, which the tolerance hides.
2026-08-08 09:08:58 +00:00
Steffen Becker 993e64e933 fix: keep the highlighter pen a docx run carries
Word's highlighter is w:highlight, a palette name; only w:shd's hex fill was
read, so 121 yellow runs of a fixture imported unmarked. 'none' maps to the
same 'auto' sentinel an empty w:shd gives, so it still cancels a style's pen.
2026-08-08 08:56:38 +00:00
Steffen Becker 361b14dc17 test: compare the rendered page against LibreOffice
Everything else in tests/ compares documents at the model level; nothing checked
what a page actually looks like. run.mjs renders the same file through soffice
and through the real app in Chromium, reads both back as word boxes, and diffs
page count, line count, line text and line position.

The corpus stays out of the repo: make-fixtures.mjs authors the baseline .docx
files, and real-world documents are whatever you drop into the gitignored
fixtures/ yourself.
2026-08-08 08:35:34 +00:00
Steffen Becker 09f57c5326 feat: keep the space a chart or a metafile reserves
A drawing the editor cannot render was dropped outright, and everything below
it moved up: a thesis with five charts and four EMF figures lost 102cm of
layout, five whole pages of it. They now come in as a labelled box of the
drawing's own size, so the pages hold what they hold in Word.
2026-08-08 08:30:06 +00:00
Steffen Becker b217de06c1 feat: a table of contents keeps the heading its file gave it
A German document's "Inhalt" came back as "Table of Contents" — the node
carried no title of its own, so the generated one always won. Now the
imported heading rides on the node and goes back out with it.
2026-08-08 08:30:06 +00:00
Steffen Becker f62559707c fix: a header/footer zone keeps its blank lines and its logo's height
A letterhead header is usually a couple of empty lines, the logo, then one
more — the empty leading ones were dropped on import, and the body's content
area counted every line as one text line, logo included. Page 1 of a contract
form started 19mm too high.
2026-08-08 08:30:06 +00:00
Steffen Becker d26fcae94d feat: keep a block with the next one across a page break
A heading whose successor no longer fits below it was left stranded at the
page foot; Word and LibreOffice move it down with them, which is why their
heading styles all carry w:keepNext / fo:keep-with-next. Headings do it by
default here, so the attr only marks the other blocks that ask for it.

One level deep: a run of kept-together blocks would need the pagination pass
to reconsider leaves it has already placed.
2026-08-08 08:30:05 +00:00
Steffen Becker c82a78cc6a feat: character spacing, and a line box that multiplies its two halves
Word's Title style tightens by -0.5pt, so a title came out ~3mm wide of
LibreOffice's. letterSpacingPt joins TextProps and rides both formats
(w:spacing, fo:letter-spacing).

Line spacing needed the same care: it is proportional to the font's natural
line height, so the factor and that height are now separate CSS variables and
editor.css multiplies them in one place. Before, whichever of the two was
declared nearer simply overwrote the other — a block carrying its own font
silently dropped the style's spacing.
2026-08-08 08:30:05 +00:00
Steffen Becker e2e885e1e8 feat: the paragraph mark carries the block's font, not only its size
The block's CSS strut is the floor under every line, so a paragraph whose runs
are smaller or of another family than the style rendered too tall — 03-fonts
drifted 4mm over a page. The mark's family now rides the block like its size
already did (Word's w:pPr/w:rPr/w:rFonts, ODF the paragraph's own text
properties), and supplies the natural line height single spacing means.

A mark that declares nothing but whose runs all agree takes their font: that
is the paragraph's font, and it is what a word processor struts with.
2026-08-08 08:30:05 +00:00
Steffen Becker d2701d38ae feat: place a floating image at its x in the text column
Word anchors a wrapped frame at an offset; the model only knew a side, so a
frame the file puts 91mm in snapped to the margin and the text beside it came
out 20mm too narrow. wrapOffset carries that x (cm from the column's left
edge, Word's posOffset / ODF svg:x) and the float's outer margin renders it —
against the column vars, so an indented anchor paragraph cannot skew it.

Picking a wrap side in the toolbar clears the offset: that gesture means
"put it there".
2026-08-08 08:30:05 +00:00
Steffen Becker 273654640c fix: fit an imported as-character image to the text column
An inline atom wider than the column is pushed onto a line of its own and
leaves the empty line above it in the document — 5mm per image. A picture the
file sizes to the column lands there anyway once its cm/EMU width is rounded
to whole px, which is how a full-width Word picture triggered it.
2026-08-08 08:30:05 +00:00
Steffen Becker c34fb4312a fix: drop the trailing-break line after an inline atom
A paragraph holding an image rendered a line taller than it does anywhere
else: under white-space: pre-wrap the browser already shows the last line, so
ProseMirror's hack BR adds an empty one. The hack is kept where it earns its
keep — after a real break it carries the caret onto the empty line, and in an
empty block it is the only line box there is.
2026-08-08 08:30:04 +00:00
Steffen Becker 58eadc3a2e fix: read a header/footer wrapped in a content control
Word's inserted page number sits in a w:sdt, so the paragraph is not a child
of w:ftr and the whole zone came back empty. Mirrors what convertBlocks
already does for the body.
2026-08-08 08:30:04 +00:00
Steffen Becker 9d6b77a876 fix: take a wrapped frame's side from its own x
wrapText="bothSides" says nothing about the side, so every such frame floated
left — including the ones Word puts in the right half of the column, which
then pushed the text off the page's right edge instead of flowing beside it.
2026-08-08 08:30:04 +00:00
Steffen Becker 3344d20481 fix: apply a table style's paragraph spacing to its cells
Word's Table Grid — the style nearly every real table names — sets space
after 0 and single line spacing in its own w:pPr, which is why a table's rows
are line-tight. The cell paragraphs were taking the document default instead.

An explicit single spacing is now written out as well: it only used to be
dropped as redundant, but the block's own style may set another one.
2026-08-08 08:30:04 +00:00
Steffen Becker 9f6736d5a8 fix: honour w:contextualSpacing on import
Word's List Paragraph carries it, so consecutive list points sit line-tight.
Without it every one of them took the document default's 8pt after, and a
document that is mostly bullets drifted more than a page.
2026-08-08 08:30:04 +00:00
Steffen Becker 821688c2cb fix: carry the theme font into an imported paragraph style
A run with no font already fell back to the document's theme; the style did
not, so the registry held Standard and the headings without a family. Single
line spacing is measured against that family, so it resolved to the wrong one.
2026-08-08 08:30:04 +00:00
Steffen Becker 869556e531 feat: render Calibri Light with the bundled Carlito
Word's default theme heading font, so every Word file with a Title or a
heading references it. Without a face it dropped to the browser's serif —
a serif heading at the wrong width.
2026-08-08 08:30:04 +00:00
Steffen Becker 3a71491b58 fix: scale a named style's line spacing by the font's natural line height
A proportional line spacing multiplies the font's own single line height in
Word and LibreOffice, CSS multiplies the font size. The node attr already
scaled by Liberation Serif's 1.15; a style's line-height went out raw, so an
imported 1.08 rendered ~20% tighter than the file asks for and the drift
accumulated down the page.
2026-08-08 08:30:04 +00:00
Steffen Becker be96ee626c docs: apply rules for comments 2026-08-08 08:28:55 +00:00
Steffen Becker cd1da67586 fix: carry a character style through a list item on ODF export
odf-kit's list builder reads a run's marks itself and knows nothing about
charStyle, and applyRuns — which handles the style on every other path — never
sees a list paragraph, so a character-styled list item exported as plain text.

A pre-pass now does both of applyRuns' jobs: bake the resolved props into direct
marks (the run's own marks staying on top), which is what gets the run a span at
all, and prefix the CST sentinel so applyCharacterStyles re-points that span at
the named style. Formatting and name both round-trip.
2026-08-07 20:27:31 +00:00
Steffen Becker a8a4a4c32f feat: let a character style on the item's first portion reach the marker
The charStyle mark carries only a name, so resolving it needs the registry: the
plugin takes it as a `sheet` option (like ParagraphStyle), the exporters read
their own exportSheet. The style is the base, the portion's own marks stay on
top. The decoration pass now also re-runs on FORCE_PAGE_RECALC, so editing a
style repaints the markers.

The ODF marker style moves to styles.xml as a named style — LibreOffice ignores
a level's text:style-name when it resolves to an automatic style, which made the
whole ODF leg a no-op (probed both ways).
2026-08-07 20:27:07 +00:00
Steffen Becker 943a885754 feat: carry the item's formatting into its list marker
The marker took only the weight of the item's first text portion. It now takes
the family, slant, size and color too — as custom properties on every item,
since they inherit and a nested item must not take its parent's.

A named paragraph style reaches it a second way: the marker inherits the list
item's own font, and the document stylesheet only styled the item's paragraph,
so an imported document whose Standard style is Arial drew its numbers in the
editor's serif default. styleCss now emits the style's text half for the item
too (li:has(> …)).

Both file formats carry marker formatting per level, so a level definition is
written only for a list whose items agree: ODF mints a character style the level
points at, DOCX the level's w:rPr. A mixed list gets none on purpose, so
LibreOffice keeps applying its own first-portion rule.
2026-08-07 20:26:44 +00:00
Steffen Becker 0b54f6cc44 feat: render a list marker bold when the item starts bold
A bold mark sits inside the item's paragraph and never reaches ::marker, so the
roman numerals of a numbered heading stayed light while their text was bold.
A plugin tags such items and editor.css weights the marker. The trigger is the
first text portion, which is the rule LibreOffice numbering itself uses.
2026-08-07 17:41:09 +00:00
Steffen Becker 0d4ed9e591 fix: honour the paragraph mark's font size on every line
Its size is the block's line-height floor, not just an empty line's height:
10pt text in an 11pt style kept the taller strut and every line came out 0.4mm
high. Both importers now carry it as the blockFontSize attr whenever it differs
from what the block renders at, and the ODF export emits the FSZ sentinel for a
filled block too.
2026-08-07 17:33:23 +00:00
Steffen Becker 8b9ba74a48 fix: import a list indented less than the level base
A list's own indent is the offset from the level's 1.27cm base, and the
importers dropped it when the file put the list left of that (w:ind w:left="360"
is a common one), so every item rendered 6.3mm too far right. The offset is
signed now, floored at the base so the list stays inside the text column.
2026-08-07 17:32:59 +00:00
Steffen Becker 38e852190d fix: keep a header/footer's own font on DOCX import
blockDefaults(baseRun) made the Header/Footer style's own font the yardstick,
so a run matching it imported without marks. The zone carries no styleName and
no style CSS reaches it, so it then rendered in the editor default instead —
an Arial footer came back as Liberation Serif, 2.3mm narrow per line.
2026-08-07 17:32:24 +00:00
Steffen Becker 67e2a00bf0 feat: add a right paragraph indent
The mirror of the left indent (fo:margin-right, w:ind w:right) with its own
marker on the ruler. ODF export rides the PBX sentinel: odf-kit has a paragraph
option for the left indent but none for the right one.

Clearing direct formatting now resets the first-line and right indents as well —
no named style governs either, so both are always direct formatting.
2026-08-07 16:34:42 +00:00
Steffen Becker 7c09727cda docs: remove word as placeholder for general text editor 2026-08-07 18:08:20 +02:00
Steffen Becker ad38994c65 feat: add ruler for tab stops and indents
Click the strip to place a stop of the selected type, drag to move it, drag it
off to drop it; the two triangles set the paragraph's first-line and left
indent. Sticky inside the scroll area, so it clears the toolbar island and
stays aligned with the page as it scrolls or zooms.
2026-08-07 17:47:30 +02:00
Steffen Becker 92d641f72f feat: honour a paragraph's own tab stops
CSS only has the fixed tab-size grid, so a tab that resolves to one of the
paragraph's stops is measured and given the exact advance as an inline margin.
A hanging indent implies a stop at the text position, as in Word.
2026-08-06 21:45:47 +00:00
Steffen Becker 7d4a0b256e fix: indent list levels by the step both exporters write
Lists were padded 1.5rem per level on screen while the DOCX and ODT
exports place item text at LIST_LEFT_STEP_CM (1.27cm) per level, so the
editor disagreed with its own output and with Word and LibreOffice by
6.4mm on the first level, doubling with each nesting level.
2026-08-06 20:01:23 +00:00
Steffen Becker c014a73da2 feat: support first-line and hanging indents
Only the block's left margin was read, so w:firstLine, w:hanging and
fo:text-indent were dropped: every hanging-indent paragraph rendered with
its first line flush with the rest instead of outdented.

Stored as the signed indentFirst attr in cm (negative = hanging) and
rendered as CSS text-indent. Word splits it into two exclusive
attributes by sign, ODF keeps one signed value.
2026-08-06 19:58:33 +00:00
Steffen Becker 3a68a144cb fix: read OOXML toggles as ST_OnOff, not as element presence
w:evenAndOddHeaders, w:titlePg and w:pageBreakBefore were treated as on
whenever the element existed, but w:val="false"/"0"/"off" turns them off
and both Word and the docx lib write that explicit form.

A file with <w:evenAndOddHeaders w:val="false"/> therefore took the
even-page header variant on every second page, which is empty — the
header and footer vanished from page 2 onwards.
2026-08-06 19:53:47 +00:00
Steffen Becker f48e5508a8 feat: honour the document's widow-orphan setting
Widow-orphan control was hardcoded on. It is a per-paragraph property in
both formats, so a file that turns it off paginated differently from
Word and LibreOffice.

Stored as the widowControl attr next to breakBefore. DOCX resolves
w:widowControl direct-then-style-chain-then-docDefaults; ODF reads
fo:widows/fo:orphans, where only an explicit 0 means off (absent is the
XSL-FO default of 2). Export rides the existing PBX sentinel rather than
adding a pass.
2026-08-06 19:45:08 +00:00
Steffen Becker 275a77564e fix: use Word's asymmetric cell padding for tables
Cells padded 0.1cm on all sides; Word and LibreOffice use 0.19cm left and
right and none top or bottom. Text sat 0.7mm too far left and every row
was 2mm too tall, so the offset accumulated down a table.

odf-kit only writes the fo:padding shorthand, which ODF defines as a
single length — LibreOffice drops a two-value form — so the export
expands it per side.
2026-08-06 19:26:56 +00:00
Steffen Becker 52cf5ac702 fix: derive single line spacing from the font, not a fixed 1.15
Single spacing is the font's natural line height. The hardcoded 1.15 is
Liberation Serif's (and Liberation Sans' and Caladea's), but Carlito
needs 1.2208 and Liberation Mono 1.1333 — measured against LibreOffice
at 12pt. A Calibri body ran 6% too tight, drifting a line per page.

Emitted next to font-family, so an explicit line spacing still wins.
2026-08-06 19:19:06 +00:00
Steffen Becker b1c515fd2f fix: adopt the DOCX document default font into the Standard style
Body paragraphs carry no w:pStyle, so the default style never reached
usedStyles and Standard kept the editor's Liberation Serif 12pt. Run
suppression meanwhile resolves against w:docDefaults, so the file's body
font was dropped with no run mark left to render it: a Calibri 11pt Word
document rendered as Liberation Serif 12pt.
2026-08-06 19:18:58 +00:00
Steffen Becker 328aff97dd fix: add widow-orphan control to prevent single paragraph lines 2026-08-06 20:59:33 +02:00
Steffen Becker 6c256c6533 fix: add pre-wrap for line-end space 2026-08-06 20:46:17 +02:00
Steffen Becker d608771105 feat: add table options 2026-08-06 20:01:44 +02:00