Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block validation: exclude data attributes / add support for custom validators #8532

Closed
AndiDittrich opened this issue Aug 4, 2018 · 1 comment
Labels
[Feature] Paste [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed

Comments

@AndiDittrich
Copy link

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

gutenberg_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

@designsimply designsimply added [Feature] Paste [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed labels Aug 6, 2018
@designsimply
Copy link
Member

Closing in favor of consolidating with #7604. If you feel it's not a good consolidation, please leave a comment explaining why and we can re-open!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Paste [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed
Projects
None yet
Development

No branches or pull requests

2 participants