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

Add removeEmpty option to insertNodes #2719

Merged
merged 3 commits into from
Oct 30, 2023
Merged

Conversation

12joan
Copy link
Collaborator

@12joan 12joan commented Oct 28, 2023

Description
Implements the removeEmpty option on insertNodes discussed here. If a node is removed as a result of this option, the nextBlock option is ignored.

I wasn't able to import ELEMENT_DEFAULT or isAncestorEmpty 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 the removeEmpty: true option to enable this behaviour.

If you want empty blocks other than paragraphs to be removed, you can pass a QueryNodeOptions object to removeEmpty. For example: removeEmpty: { allow: [ELEMENT_DEFAULT, ...KEYS_HEADING] }.

@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2023

🦋 Changeset detected

Latest commit: 5cda964

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 53 packages
Name Type
@udecode/plate-media Minor
@udecode/slate Minor
@udecode/plate Minor
@udecode/plate-serializer-docx Minor
@udecode/plate-serializer-md Minor
@udecode/plate-common Minor
@udecode/plate-core Minor
@udecode/plate-utils Minor
@udecode/slate-react Minor
@udecode/slate-utils Minor
@udecode/plate-alignment Minor
@udecode/plate-autoformat Minor
@udecode/plate-basic-elements Minor
@udecode/plate-basic-marks Minor
@udecode/plate-block-quote Minor
@udecode/plate-break Minor
@udecode/plate-caption Minor
@udecode/plate-cloud Minor
@udecode/plate-code-block Minor
@udecode/plate-combobox Minor
@udecode/plate-comments Minor
@udecode/plate-cursor Minor
@udecode/plate-dnd Minor
@udecode/plate-emoji Minor
@udecode/plate-excalidraw Minor
@udecode/plate-find-replace Minor
@udecode/plate-floating Minor
@udecode/plate-font Minor
@udecode/plate-heading Minor
@udecode/plate-highlight Minor
@udecode/plate-horizontal-rule Minor
@udecode/plate-indent-list Minor
@udecode/plate-indent Minor
@udecode/plate-juice Minor
@udecode/plate-kbd Minor
@udecode/plate-line-height Minor
@udecode/plate-link Minor
@udecode/plate-list Minor
@udecode/plate-mention Minor
@udecode/plate-node-id Minor
@udecode/plate-normalizers Minor
@udecode/plate-paragraph Minor
@udecode/plate-reset-node Minor
@udecode/plate-resizable Minor
@udecode/plate-select Minor
@udecode/plate-selection Minor
@udecode/plate-serializer-csv Minor
@udecode/plate-serializer-html Minor
@udecode/plate-suggestion Minor
@udecode/plate-tabbable Minor
@udecode/plate-table Minor
@udecode/plate-trailing-block Minor
@udecode/plate-yjs Minor

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

@vercel
Copy link

vercel bot commented Oct 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plate ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2023 8:41pm

@reviewpad reviewpad bot added small Pull request is small and removed medium Pull request is medium labels Oct 28, 2023
@reviewpad reviewpad bot added medium Pull request is medium and removed small Pull request is small labels Oct 28, 2023
@zbeyens
Copy link
Member

zbeyens commented Oct 30, 2023

Duplicating is fine for now. We have editor.blockFactory in plate but it's not accessible neither. It should probably be moved to Slate at some point.

@12joan 12joan merged commit 9d2931b into main Oct 30, 2023
6 checks passed
@12joan 12joan deleted the feat/insert-nodes-remove-empty branch October 30, 2023 14:33
@zbeyens zbeyens mentioned this pull request Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium Pull request is medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants