Skip to content

SD-2279 - fix: floating textbox not rendering#2732

Merged
caio-pizzol merged 6 commits into
mainfrom
gabriel/sd-2279-bug-floating-textbox-does-not-render
Apr 28, 2026
Merged

SD-2279 - fix: floating textbox not rendering#2732
caio-pizzol merged 6 commits into
mainfrom
gabriel/sd-2279-bug-floating-textbox-does-not-render

Conversation

@chittolinag
Copy link
Copy Markdown
Contributor

@chittolinag chittolinag commented Apr 7, 2026

Issue

Word sometimes emits DrawingML tags with arbitrary prefixes (e.g. ns6:). Our importer only looked for literal a:graphic/a:graphicData, so it dropped the whole drawing, emitted a passthroughBlock inside the run, and calculateInlineRunPropertiesPlugin crashed with RangeError: Invalid content for node type run.

Proposed solution

Normalize DrawingML lookups by local name in handleImageNode (and helpers) so graphic/graphicData, blips, transforms, etc. are found regardless of prefix; do the same in vector-shape-helpers.

@linear
Copy link
Copy Markdown

linear Bot commented Apr 7, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

All elements and attributes check out against the spec. The PR is a namespace-prefix normalization refactor — instead of hard-coding a: prefixes (e.g. el.name === 'a:graphic'), it now uses local-name matching utilities, which is more robust when parsers emit alternate prefixes like ns6:.

Status: PASS

Every DrawingML element and attribute accessed in this diff is valid per ECMA-376:

  • a:lum bright/contrast — correct (§20.1.8.42)
  • a:headEnd/a:tailEnd type/w/len — correct (§20.1.8.38, §20.1.8.57)
  • a:xfrm rot/flipH/flipV — correct (§20.4.2.43)
  • a:picLocks noChangeAspect — correct (§20.1.2.2.31)
  • a:grayscl — empty element, no attributes, correct (§20.1.8.34)
  • a:lin ang — correct (§20.1.8.41)
  • a:gs pos — correct (§20.1.8.36)
  • a:path (in gradFill) path attribute — correct (§20.1.8.46)

The findChildByLocalName / hasLocalName utilities are semantically equivalent to the original exact-match lookups for well-formed documents, and handle the alternate-prefix case correctly. The test covering ns6: prefixed nodes is a good addition.

One pre-existing note unrelated to this PR: in extractLineEnds, width and length in the return { type, width, length } are never assigned from the parsed attributes (they'll be undefined). That's not introduced here, but worth a follow-up.

@chittolinag chittolinag marked this pull request as ready for review April 7, 2026 17:58
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @chittolinag! good call on this :)

one out-of-diff thing worth a follow-up: merge-drawing-children.js:105-106 still hardcodes a:graphic. on export, a doc with the ns6: prefix won't get the same treatment. not a blocker here.

lgtm - feel free to merge after addressing the inline notes.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Migrates two remaining hardcoded namespace prefix lookups in the
DrawingML import path so docs that re-prefix the DrawingML namespace
(e.g. ns6: instead of a:) get consistent treatment alongside the rest
of the PR.

- encode-image-node-helpers.js: `adec:decorative`/`a16:decorative`
  in wp:docPr extLst now matches by local name `decorative`.
- merge-drawing-children.js: `a:graphic`/`a:graphicData` in the
  zero-id repair path now use findChildByLocalName.
@caio-pizzol caio-pizzol enabled auto-merge April 28, 2026 19:41
caio-pizzol and others added 3 commits April 28, 2026 16:49
Adds regression tests for the namespace-prefix-agnostic lookups
introduced in the previous commit:

- encode-image-node-helpers: covers `adec:decorative`, `a16:decorative`,
  re-aliased `ns7:decorative`, val=0, and missing-decorative cases.
- merge-drawing-children: covers the zero-id repair path when the
  graphic subtree uses `ns6:graphic` / `ns6:graphicData`.

Both new "re-prefixed" tests fail against the pre-fix implementation
and pass after, locking in the local-name matching as the contract.
Adds a 'namespace prefix tolerance' describe block to lock in the
local-name matching introduced in this PR for vector-shape-helpers.js
(34 callsites converted from `el.name === 'a:foo'` to findChild /
hasLocalName / filterChildren / getLocalName).

Covers the public surface that depends on those helpers:
  - extractStrokeWidth (a:ln)
  - extractStrokeColor (a:ln/a:noFill/a:solidFill/a:srgbClr/a:schemeClr)
  - extractFillColor   (a:solidFill/a:gradFill stops/lin angle)
  - extractLineEnds    (a:ln/a:headEnd/a:tailEnd)
  - extractCustomGeometry (a:custGeom/a:pathLst/a:path with
    a:moveTo/a:lnTo/a:close, plus a:pt children)

6 of the 7 new tests fail against the pre-fix implementation and
pass after, locking in the local-name matching as the contract.
@caio-pizzol caio-pizzol disabled auto-merge April 28, 2026 20:05
@caio-pizzol caio-pizzol enabled auto-merge April 28, 2026 20:05
@caio-pizzol
Copy link
Copy Markdown
Contributor

hey @chittolinag! quick follow-up.

i pushed the two fixes, added tests so we don't lose this, and uploaded a sample doc so layout and visual tests cover it.

lgtm.

@caio-pizzol caio-pizzol added this pull request to the merge queue Apr 28, 2026
Merged via the queue into main with commit 862f3fe Apr 28, 2026
56 checks passed
@caio-pizzol caio-pizzol deleted the gabriel/sd-2279-bug-floating-textbox-does-not-render branch April 28, 2026 20:32
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 28, 2026

🎉 This PR is included in superdoc v1.30.0-next.8

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 28, 2026

🎉 This PR is included in superdoc-sdk v1.8.0-next.8

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 28, 2026

🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.4

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 29, 2026

🎉 This PR is included in @superdoc-dev/react v1.2.0-next.49

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 29, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.51

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

🎉 This PR is included in superdoc v1.30.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

🎉 This PR is included in superdoc-cli v0.8.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

🎉 This PR is included in superdoc-sdk v1.8.0

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

🎉 This PR is included in @superdoc-dev/mcp v0.3.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 5, 2026

🎉 This PR is included in vscode-ext v2.3.0

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 7, 2026

🎉 This PR is included in @superdoc-dev/react v1.3.0

The release is available on GitHub release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants