Skip to content

feat: register heading tags as server-side block elements#173

Merged
JohnMcLear merged 1 commit into
masterfrom
fix/cc-register-block-elements
May 8, 2026
Merged

feat: register heading tags as server-side block elements#173
JohnMcLear merged 1 commit into
masterfrom
fix/cc-register-block-elements

Conversation

@JohnMcLear
Copy link
Copy Markdown
Member

Wires the new server-side ccRegisterBlockElements hook (added in ether/ep_plugin_helpers#14) so the importer treats h1h4 and code as block elements, matching what aceRegisterBlockElements already does on the editor side.

Why

Etherpad core has two independent block-element registries: an editor-side one driven by aceRegisterBlockElements and a server-side one driven by ccRegisterBlockElements. ep_headings2 only registered the editor side, so contentcollector treated <h1>/<h2>/<code> as inline on the import path and merged adjacent ones into a single pad line. This bit native DOCX import in ether/etherpad#7568: mammoth produces <h1>A</h1><h2>B</h2><p>C</p>, the importer merged A and B into one line, and the round-trip lost the structure.

What

  • static/js/shared.js: re-export the new ccRegisterBlockElements from lineAttribute.
  • ep.json: wire it as a server-side hook.
  • package.json: bump ep_plugin_helpers minimum to ^0.5.2 (the version with the new export).
  • static/tests/backend/specs/exportHTML.ts: regression test asserting that an adjacent-headings pad (<h1>Alpha</h1><h2>Beta</h2>) survives a setHTML / getHTML round-trip with each heading on its own line and no merged "AlphaBeta" content.

CI runs against etherpad core's content collector with this plugin installed, so the new test exercises the full server-side path.

Refs ether/etherpad#7568.

ep_headings2 already registers h1-h4 + code as block elements in
the editor (aceRegisterBlockElements). It did NOT register them
on the server-side content collector (ccRegisterBlockElements),
so any HTML import path treated those tags as inline -- and
adjacent <h1>/<h2>/<code> blocks merged into a single pad line.

Fix: re-export the new ccRegisterBlockElements function from
ep_plugin_helpers' lineAttribute factory (added in
ether/ep_plugin_helpers#14) and wire it up via ep.json. This
treats h1-h4 + code as block elements on the import side too,
matching their editor behavior.

Bumps the ep_plugin_helpers minimum to ^0.5.2 (the version with
the new export).

Test added covers the regression: a pad with adjacent <h1> and
<h2> (no separator) survives a setHTML/getHTML round-trip with
each heading on its own line and no merged 'AlphaBeta' content.

Refs ether/etherpad#7568 -- this is the missing piece for the
DOCX/HTML round-trip story landing in core.
@qodo-code-review
Copy link
Copy Markdown

ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

@JohnMcLear JohnMcLear merged commit d3fdad9 into master May 8, 2026
5 checks passed
@JohnMcLear JohnMcLear deleted the fix/cc-register-block-elements branch May 8, 2026 18:19
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