Skip to content

fix(docx-io): drop the blank paragraph written after each void element - #5333

Merged
zbeyens merged 1 commit into
mainfrom
docx-io/void-spacer
Nov 4, 2026
Merged

zbeyens merged 1 commit into
mainfrom
docx-io/void-spacer

Conversation

@zbeyens

@zbeyens zbeyens commented Nov 4, 2026 •

Copy link
Copy Markdown
Member
  • Auto release

Why

Every image exported with @platejs/docx-io is followed by an extra paragraph that holds only U+FEFF, in the body and in table cells. Plate's static HTML puts each void element's empty text inside a hidden <span data-slate-spacer="true">, and the converter wrote that span as a paragraph of its own.

Scope

  • packages/docx-io/src/lib/internal/helpers/render-document-file.ts: renderDocumentFile prunes every data-slate-spacer node from the parsed tree before it converts it. The spacer only holds the hidden empty text, so nothing visible is lost.
  • packages/docx-io/src/lib/internal/html-to-docx.slow.ts: two cases export Plate's static image markup, in the body and in a table cell, through htmlToDocxBlob and check that no paragraph holds only U+FEFF.
  • .changeset/docx-void-spacer.md: a patch changeset for @platejs/docx-io.

Blast Radius

This touches body export through htmlToDocxBlob and exportToDocx. The converter drops only nodes marked data-slate-spacer, and Plate renders that attribute only on the hidden spacer of a void element. Header and footer HTML stay as they were.

It leaves alone the figure code that #5330 changes for table cells and list items, so the two PRs merge in either order.

Verification

Plate's static HTML renders each void element's empty text inside a hidden
data-slate-spacer span that holds a U+FEFF and a line break. The DOCX
converter turned that span into its own paragraph, so every exported image
was followed by a paragraph holding only U+FEFF, in the body and in table
cells. The converter now prunes those spacers right after it parses the HTML.
@zbeyens
zbeyens requested a review from a team November 4, 2026 16:50
@codesandbox

codesandbox Bot commented Nov 4, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web Editor • VS Code • Insiders

Open Preview

@changeset-bot

changeset-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 408927b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@platejs/docx-io Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@zbeyens
zbeyens merged commit b6e5978 into main Nov 4, 2026
6 checks passed
@zbeyens
zbeyens deleted the docx-io/void-spacer branch November 4, 2026 17:30

This branch was successfully deployed

1 active deployment
Preview — 408927bd Deployed Nov 4, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant