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

feat(placeholder): allow editor-is-empty class on any node #4335

Merged
merged 1 commit into from Aug 18, 2023

Conversation

bdbch
Copy link
Contributor

@bdbch bdbch commented Aug 16, 2023

Please describe your changes

This PR implements a new option for @tiptap/extension-placeholder that will allow users to enable more nodes than just paragraphs as empty for the editor-is-empty empty check.

How did you accomplish your changes

Instead of creating an empty doc copy, I'm directly checking the current document childCount, check if the first element is a valid node (as configured or is it not a atom or leaf) and then enable the class for valid nodes found at the first position of the editor.

How have you tested your changes

I used the local development environment for testing.

How can we verify your changes

  1. Checkout this PR
  2. Go to the Placeholder demo of your choice
  3. Add the option considerAnyAsEmpty: true
  4. Test inside your browser if the empty-editor placeholder will be shown for headlines too

Remarks

  • In the future we could even make this more granular by adding node type filters

Checklist

  • The changes are not breaking the editor
  • Added tests where possible
  • Followed the guidelines
  • Fixed linting issues

Related issues

  • No related issues

@bdbch bdbch added the Type: Feature The issue or pullrequest is a new feature label Aug 16, 2023
@bdbch bdbch requested a review from svenadlung as a code owner August 16, 2023 16:52
@bdbch bdbch self-assigned this Aug 16, 2023
@netlify
Copy link

netlify bot commented Aug 16, 2023

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 9f45028
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/64dcfeba6c51ee0008e69a4e
😎 Deploy Preview https://deploy-preview-4335--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bdbch bdbch merged commit ff929b1 into develop Aug 18, 2023
15 checks passed
@bdbch bdbch deleted the bdbch/placeholder-consider-any-feature branch August 18, 2023 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature The issue or pullrequest is a new feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants