admin管理员组

文章数量:1332352

If I edit a block html and add a data-* attribute to the element, the editor complains and says that "This block contains unexpected or invalid content.".

for example, the perfectly valid html:

<h2 data-foo="bar">...</h2>

is marked as invalid by the editor. Bug, or am I doing something wrong? Other attributes, such as id can be added to headings, but not to, for example paragraphs.

My use case is that I have a filter function that acts on content_save_pre and adds both id and a data-attribute to specific headings. As long as the html is valid, I don't understand why the Gutenberg editor would complain.

本文标签: htmldata* attributes in blocks