Skip to content

Commit 6db47cb

Browse files
committed
fix: exclude tracked change metadata from explicit runProperties check
The DOCX converter stores paragraph-mark tracked changes (trackInsert, trackDelete) inside runProperties. These are revision metadata, not font overrides, but hasExplicitParagraphRunProperties counted them as explicit formatting — blocking previousParagraphFont inheritance for list items with tracked paragraph marks. Filter out trackInsert/trackDelete keys before the check so only actual formatting properties prevent font inheritance.
1 parent ae09d28 commit 6db47cb

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

packages/layout-engine/pm-adapter/src/attributes/paragraph.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,36 @@ describe('computeParagraphAttrs', () => {
103103
expect(hasExplicitParagraphRunProperties({ runProperties: {} } as never)).toBe(false);
104104
});
105105

106+
it('ignores tracked change metadata in runProperties', () => {
107+
expect(
108+
hasExplicitParagraphRunProperties({
109+
runProperties: { trackInsert: { id: '1', author: 'Author', date: '2026-01-01' } },
110+
} as never),
111+
).toBe(false);
112+
expect(
113+
hasExplicitParagraphRunProperties({
114+
runProperties: { trackDelete: { id: '2', author: 'Author', date: '2026-01-01' } },
115+
} as never),
116+
).toBe(false);
117+
expect(
118+
hasExplicitParagraphRunProperties({
119+
runProperties: {
120+
trackInsert: { id: '1', author: 'Author', date: '2026-01-01' },
121+
trackDelete: { id: '2', author: 'Author', date: '2026-01-01' },
122+
},
123+
} as never),
124+
).toBe(false);
125+
// Real formatting alongside tracked changes should still count as explicit
126+
expect(
127+
hasExplicitParagraphRunProperties({
128+
runProperties: {
129+
trackInsert: { id: '1', author: 'Author', date: '2026-01-01' },
130+
fontSize: 24,
131+
},
132+
} as never),
133+
).toBe(true);
134+
});
135+
106136
it('normalizes spacing, indent, alignment, and tabs from paragraphProperties', () => {
107137
const paragraph: PMNode = {
108138
type: { name: 'paragraph' },

packages/layout-engine/pm-adapter/src/attributes/paragraph.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,14 @@ export const normalizeNumberingProperties = (
120120
return value;
121121
};
122122

123+
const TRACKED_CHANGE_KEYS = new Set(['trackInsert', 'trackDelete']);
124+
123125
export const hasExplicitParagraphRunProperties = (
124126
paragraphProperties?: Pick<ParagraphProperties, 'runProperties'> | null,
125-
): boolean => paragraphProperties?.runProperties != null && Object.keys(paragraphProperties.runProperties).length > 0;
127+
): boolean => {
128+
if (paragraphProperties?.runProperties == null) return false;
129+
return Object.keys(paragraphProperties.runProperties).some((key) => !TRACKED_CHANGE_KEYS.has(key));
130+
};
126131

127132
const applyParagraphFontFallback = (
128133
runAttrs: ResolvedRunProperties,

0 commit comments

Comments
 (0)