feat: the space between two blocks follows the document's own model

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.
This commit is contained in:
Steffen Becker committed 2026-08-09 16:53:13 +00:00
1 parent af299d8b9f
commit d6bc656c83
13 files changed
+154 -15

No files matched your search

+18 -1
View File
@@ -392,6 +392,7 @@
}
.paper .tiptap .textbox-content > :first-child {
margin-top: 0;
padding-top: 0;
}
.paper .tiptap .textbox-content > :last-child {
margin-bottom: 0;
@@ -405,6 +406,7 @@
}
.paper .tiptap .columns-node > :first-child {
margin-top: 0;
padding-top: 0;
}
.paper .tiptap .columns-node > :last-child {
margin-bottom: 0;
@@ -462,6 +464,22 @@
margin: 0;
}
/* Space above a block. LibreOffice adds it to the space below the block above, which CSS
margins can't do (they collapse to the larger) — so it renders as padding. A Word
document takes the larger, LibreOffice included, and gets a margin instead. */
@property --space-before {
syntax: '<length>';
inherits: false;
initial-value: 0;
}
.paper .tiptap :is(p, h1, h2, h3, h4, h5, .toc, .toc-title) {
padding-top: var(--space-before);
}
.paper[data-spacing-model='max'] .tiptap :is(p, h1, h2, h3, h4, h5, .toc, .toc-title) {
padding-top: 0;
margin-top: var(--space-before);
}
/* The line box: the paragraph's spacing factor times its font's natural line height.
Either half may come from the style rule or, nearer, from the block's own attrs
(lineHeight.ts / blockFontSize.ts) — multiplying them here is what keeps both. */
@@ -848,7 +866,6 @@
}
.paper .tiptap > *[data-page-break] {
margin-top: 0 !important;
page-break-before: always;
}