Conversation
|
Status: FAIL The overall approach is sound — tracking inline keys to suppress redundant Style-inheritance merge order is reversed — // chain is built: [derivedStyle_rPr, baseStyle_rPr, grandbaseStyle_rPr, ...]
chain.forEach((rPr) => {
(rPr.elements || []).forEach((el) => {
if (el?.name) byName[el.name] = el; // last write wins
});
});The comment says "base first, then derived (later overrides by element name)" — which correctly describes OOXML cascade semantics — but the chain is populated derived-first (the while-loop starts at OOXML §17.7 is clear that a derived character style overrides its base. With the merge backwards, when a derived style changes a property that its base also defines (say The fix is a one-liner — reverse the chain before merging so base is processed first and derived writes last: chain.reverse().forEach((rPr) => { … });This only affects documents where a character style is derived from another character style and both define the same run property with different values — a real, if uncommon, pattern in Word templates. Single-level style references are unaffected. Everything else looks correct from a spec standpoint: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eaa6b03cab
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
packages/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/translate-table-cell.js
Outdated
Show resolved
Hide resolved
packages/super-editor/src/core/super-converter/export-helpers/run-properties-export.js
Outdated
Show resolved
Hide resolved
caio-pizzol
left a comment
There was a problem hiding this comment.
@VladaHarbour clean approach — tracking inline keys to avoid exporting inherited styles makes sense.
two things to fix: the style chain merge is in the wrong order (base overwrites derived), and the cell property filter drops user edits that weren't in the original import. also worth checking whether existing collab docs could have null inline keys — if so, export would strip their formatting.
minor cleanup: runPropertiesStyleKeys is saved but never read on export. run-properties-export.js has no unit tests. left inline comments.
|
|
||
| // Merge rPr elements: base first, then derived (later overrides by element name) | ||
| const byName = {}; | ||
| chain.forEach((rPr) => { |
There was a problem hiding this comment.
the merge loop processes derived styles first, then base styles — so base wins. it should be the other way around. add chain.reverse() before the loop.
| if (inlineKeys.length === 0) { | ||
| tableCellProperties = {}; | ||
| } else { | ||
| const allowed = new Set(inlineKeys); |
There was a problem hiding this comment.
this drops any cell property that wasn't in the original docx. but if a user adds a background color or changes alignment after import, those keys aren't in the allow-list and get silently removed on export. the border command handles this correctly (table.js:1253) — other editing commands need the same treatment.
There was a problem hiding this comment.
The issue was related to tcMar only to be honest and we already treat it above. Removed this check
| }; | ||
|
|
||
| if (segments.length === 1) { | ||
| if (JSON.stringify(runProperties) === JSON.stringify(runNode.attrs.runProperties)) return; |
There was a problem hiding this comment.
when run properties haven't changed, this returns early without setting runPropertiesInlineKeys. if any existing collab docs were saved before this PR, they'd have null inline keys — and export would drop all their formatting. is that a real scenario?
There was a problem hiding this comment.
added condition to support existing collab docs
| if (runProperties?.styleId && params?.docx) { | ||
| const styleRPr = getParagraphStyleRunPropertiesFromStylesXml(params.docx, runProperties.styleId, params); | ||
| if (styleRPr && Object.keys(styleRPr).length > 0) { | ||
| runPropertiesStyleKeys = Object.keys(styleRPr); |
There was a problem hiding this comment.
runPropertiesStyleKeys is saved during import but never used during export — export recomputes it from scratch. either use the saved value or remove it.
| * Same as resolveRunProperties but also returns which keys came from the inline rPr (so export can output only those). | ||
| * Used by the converter to mark inline properties at the combine step and export only inline. | ||
| */ | ||
| export function resolveRunPropertiesWithInlineFlag( |
There was a problem hiding this comment.
this wrapper just adds an Object.keys() call on top of resolveRunProperties. only one place uses it. worth inlining at the call site instead?
095867f to
68bf5ce
Compare
Exclude inherited props from document.xml on export