-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Normalise falsely surrounds non void inline nodes #1948
Comments
Ah yeah, all inlines are surrounded by text nodes I guess. |
Why is this a thing? Is it a deliberate design decision or is it simply a consequence of the way Slate is implemented? Reading throughout other issues: Is it like that to fix the keyboard selection problem across multiple inlines (#1502)? |
@ianstormtaylor - I'm also curious if this is necessary for all inlines, or just void ones 😄 I have a large document with several hundred I'm happy to submit a PR implementing what @RXminuS suggested above |
I'm struggling a bit trying to apply this rule to only void inlines. Here's the schema: slate/packages/slate/src/plugins/core.js Lines 130 to 155 in cf46e9d
What I can't figure out is how to tell the schema to match only when the {
isVoid: true,
match: { object: 'inline' },
first: [{ object: 'block' }, { object: 'text' }],
...
} that seems to tell the schema that the I also tried checking inside the So, I'm stuck 😅. I don't want to double my node count by adding a bunch of empty text nodes, but i also don't want to add the same number of Any ideas? 🙏🏽 |
I believe that this may be fixed by #3093, which has changed a lot of the logic in Slate and |
I'm not sure if it's a bug, but the behaviour seems to deviate from the docs. In the docs it's suggested that only inlines that have
isVoid
must be surrounded by empty text nodes, but this normalisation function surrounds all inline nodes by text nodes.slate/packages/slate/src/constants/core-schema-rules.js
Line 142 in 3741864
I can either make a PR to fix the issue by a simple
or change the docs to clarify that every inline node needs to be surrounded by text nodes.
The reason this is important is that I wrote a performance critical "serialize" function that is supposed to output a perfect tree to avoid unnecessary normalisation, and this added a full 3 seconds to the loading time.
The text was updated successfully, but these errors were encountered: