-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
Add removeEmpty
option to insertNodes
#2719
Conversation
🦋 Changeset detectedLatest commit: 5cda964 The changes in this PR will be included in the next version bump. This PR includes changesets to release 53 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Duplicating is fine for now. We have |
Description
Implements the
removeEmpty
option oninsertNodes
discussed here. If a node is removed as a result of this option, thenextBlock
option is ignored.I wasn't able to import
ELEMENT_DEFAULT
orisAncestorEmpty
since these are from packages that depend on@udecode/slate
. @zbeyens Is there a workaround for this, or should we settle for duplicating them?Usage
Most or all Plate transforms that insert a node accept an options type inheriting from
InsertNodesOptions
; if anyone finds a transform that does not expose these options, feel free to make a PR. This is where you can add theremoveEmpty: true
option to enable this behaviour.If you want empty blocks other than paragraphs to be removed, you can pass a
QueryNodeOptions
object toremoveEmpty
. For example:removeEmpty: { allow: [ELEMENT_DEFAULT, ...KEYS_HEADING] }
.