fix: a link keeps its own paint over a baked region color

The editor's a-rule and LibreOffice's Internet Link style both outrank the
region CSS, so neither export lets the baked region color override a
non-plain link's paint: ODT leaves the color off the link run, DOCX paints
the link blue unless the run carries a direct color — the DOCX import
otherwise read its own link back as plain.
This commit is contained in:
Steffen Becker committed 2026-08-16 13:42:30 +02:00
1 parent 4c55e9b9f5
commit 6987eda4fc
2 files changed
+8 -2

No files matched your search

+3 -2
View File
@@ -373,9 +373,10 @@ function runPropsFromMarks(marks: TiptapNode['marks'] = [], force: TextProps = {
if (h) props.shading = { type: ShadingType.CLEAR, fill: h };
}
// Visible hyperlink styling (the ExternalHyperlink wrapper carries the target), unless
// the link came in without one — Word draws those like the text around them.
// the link came in without one — Word draws those like the text around them. The blue
// outranks a baked region color, as the editor's a-rule beats the region CSS.
if (marks?.some((m) => m.type === 'link' && !m.attrs?.plain)) {
if (!props.color) props.color = '0563C1';
if (!ts?.attrs?.color) props.color = '0563C1';
if (!props.underline) props.underline = { type: UnderlineType.SINGLE };
}
return props;
+5
View File
@@ -2984,6 +2984,11 @@ function applyRuns(p: ParagraphBuilder | CellBuilder, content: TiptapNode[] = []
const direct = { ...fmt };
Object.assign(fmt, forced, direct);
if (!direct.bold && fmt.fontWeight === 'normal') delete fmt.bold;
// A link keeps its own paint: LibreOffice's Internet Link style and the editor's
// a-rule both outrank the region color, so the bake must not override it.
if (!direct.color && node.marks?.some((m) => m.type === 'link' && !m.attrs?.plain)) {
delete fmt.color;
}
}
// A named character style: bake its resolved formatting (so odf-kit always mints a
// span) and mark the run, so applyCharacterStyles can re-point that span at the style.