Repository navigation
Conversation
Behind the "Optional block delimiters" experiment, HTML without block delimiters opens as blocks and is saved without them where possible. - Add @wordpress/html-api, a port of the WordPress HTML Tag Processor. - Read HTML outside delimiters as blocks instead of one Classic block. Elements no block reads become HTML blocks, with the blocks inside them editable. - Save untouched blocks exactly as written. Edited blocks change only what the edit changed, and get a delimiter only when reading the HTML back without one would give a different block. - Keep attributes a block doesn't know in `htmlAttributes`, show them in the editor and save them again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Try the browser's own parser instead of a port of the HTML API. HTML outside delimiters comes back as the browser writes it (for example `data-x` becomes `data-x=""`), but blocks still add nothing to it unless they're edited, and then change only what the edit changed. Delimited blocks keep their exact text. Removes @wordpress/html-api. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 PR meta 🤖🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. 📦 Bundle sizeSize Change: +3.14 kB (+0.04%) Total Size: 8.56 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. List in
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inner blocks of a block like List were each read back on their own to decide whether they need a delimiter. A list item alone isn't a list item, so editing one saved the whole list with delimiters. Inner blocks are now read back as part of their parent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the experiment: HTML outside delimiters is always read as blocks, and blocks that weren't edited are always saved as they were read. New blocks get delimiters as before. - Without a DOM or the HTML block, HTML is read and saved as before. - The current version of a block reads its HTML first, keeping unknown attributes in `htmlAttributes`; older versions are tried after. - Invalid blocks are saved as they were read, and logged as before. - Pasting HTML outside delimiters goes through raw handling again. - The full content fixtures check what blocks save, with the source set aside; untouched content is checked by the delimiter tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only HTML without delimiters is read for blocks inside it. A delimited Custom HTML block keeps its static HTML, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A delimited block inside HTML without delimiters, like a paragraph in a section, used to cut the HTML apart when read, so saving one wrapped the whole HTML in a Custom HTML block. HTML outside delimiters is now read in one pass with the delimited blocks in it, which become inner blocks of an HTML block where they sit inside an element. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Post content is rendered with a parser that reads HTML outside block delimiters as blocks, the same way the editor does, so render filters see each block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A block read from an old format, or holding one, is saved in the new format, as before. - Inserted pattern blocks are new blocks, not saved as the pattern file is written. - Whitespace before a removed first block isn't kept. - New Classic blocks, and new HTML blocks in widget editors, get delimiters, so they read back as the same block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This reads the same in the DOM but is a destructive operation. The one is a boolean attribute and the other is an attribute with an empty string as its value. Noting here because this goes beyond tidying and could be seen as a form of corruption. Just a random thought that doesn’t matter much. |
|
@dmsnell That's what all editors do though, such as ProseMirror and TinyMCE |
|
@ellatrix any DOM-based system will likely do this. I just noted that distinction and wanted to clarify it as a relevant point. |
What?
Alternative to #85500.
HTML without block delimiters, like a classic post, opens as blocks instead of one Classic block. Blocks that aren't edited are saved as they were read, and blocks read without delimiters stay without them unless an edit needs one. New blocks get delimiters as before. Unlike #85500, the HTML is read and written with the browser's DOM, not a port of the HTML API.
Why?
So Gutenberg can edit any HTML, like a classic post, without converting it or adding block markup. With the DOM, untouched HTML comes back tidied, but blocks add nothing to it, like extra classes or attributes.
How?
htmlAttributes, shown in the editor and saved again.Examples of tidying:
<P CLASS=tip>becomes<p class="tip">,<br />becomes<br>,data-xbecomesdata-x="", and a new attribute is added at the end of the tag.Testing Instructions
wp post create --post_title=Test --post_content='<P CLASS=tip>Hi<br />there</P><section><h3>Title</h3><p>Text</p></section>'.<p class="tip">Hi<br>there</p>), with no classes added.Testing Instructions for Keyboard
Same as above, typing the edit with the keyboard.
Use of AI Tools
Written with Claude Code (Claude Opus 5.5), reviewed by me.
🤖 Generated with Claude Code