You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, we can specify rules in the schema that will match against properties of the nodes. The comparison is often as simple as a === against two attributes.
It takes each node where object === 'text' and check if the next sibling node verifies object === 'block' or object === 'inline'. If not, it goes through the normalize method.
It's enough to cover lots of use case, but I think we can go a little further.
What's the expected behaviour?
Let's say we want to enforce no succeeding blocks of certain types. I'll take an unordered-list as example. Right now we would have to list each and every other type of block on the rule to enforce this.
Would be really inefficient and error prone, especially for published plugins who have no idea of every other block types.
One easy way to solve this would be to inverse the condition. But I actually have no idea how to properly implement this, so here is 3 other options instead 😅:
Allow function to be passed as rule, the function would return a falsey value, or the error code
this could be useful to do some kind of negation check like not having void node as the last node rather than checking that the last node should be of type like the example schema for images. any thought @ianstormtaylor ?
Do you want to request a feature or report a bug?
A feature
What's the current behaviour?
Right now, we can specify rules in the schema that will match against properties of the nodes. The comparison is often as simple as a
===
against two attributes.Example for a rule like this:
It takes each node where
object === 'text'
and check if the next sibling node verifiesobject === 'block'
orobject === 'inline'
. If not, it goes through thenormalize
method.It's enough to cover lots of use case, but I think we can go a little further.
What's the expected behaviour?
Let's say we want to enforce no succeeding blocks of certain types. I'll take an
unordered-list
as example. Right now we would have to list each and every other type of block on the rule to enforce this.Would be really inefficient and error prone, especially for published plugins who have no idea of every other block types.
One easy way to solve this would be to inverse the condition. But I actually have no idea how to properly implement this, so here is 3 other options instead 😅:
Would be as simple as adding a
typeof === 'function'
at a few places like here src/models/schema.js#L533I could handle the implementation if that interests you :)
The text was updated successfully, but these errors were encountered: