Dear Gutenberg Team,
i'm currently developing a Gutenberg Plugin to integrate EnlighterJS Syntax Highlighter into to editor and ran into serious trouble regarding the "block/element validation":
Because of the strict 1:1 structure validation there seems to be no possibility? to add optional attributes to the elements generated by the save function.
The editor always throws element validation errors in case custom attributes are added (e.g. manually by a user - which might be legitimate).
Of course, its possible to add all allowed attributes to the output...but this will mess-up the generated html with a lot of unused attributes
Example HTML Structure
<pre
data-enlighter-language="less"
data-enlighter-highlight="2"
data-enlighter-lineoffset=""
data-enlighter-linenumbers=""
data-enlighter-title="">
...
</pre>
Typical Validation Error

Suggestions
- Exclude
data- attributes from validation (they represent an elements state, not its structure)
- Add support for custom block validation methods (within
registerBlockType) to allow users to override the default behaviour
- Maybe use the attribute schema to validate the structure, including an
optional flag
best regards, Andi
Dear Gutenberg Team,
i'm currently developing a Gutenberg Plugin to integrate EnlighterJS Syntax Highlighter into to editor and ran into serious trouble regarding the "block/element validation":
Because of the strict 1:1 structure validation there seems to be no possibility? to add optional attributes to the elements generated by the
savefunction.The editor always throws element validation errors in case custom attributes are added (e.g. manually by a user - which might be legitimate).
Of course, its possible to add all allowed attributes to the output...but this will mess-up the generated html with a lot of unused attributes
Example HTML Structure
Typical Validation Error
Suggestions
data-attributes from validation (they represent an elements state, not its structure)registerBlockType) to allow users to override the default behaviouroptionalflagbest regards, Andi