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

NodePos implementation #4701

Merged
merged 7 commits into from
Jan 8, 2024
Merged

NodePos implementation #4701

merged 7 commits into from
Jan 8, 2024

Conversation

bdbch
Copy link
Contributor

@bdbch bdbch commented Dec 15, 2023

Please describe your changes

This PR implements a new "NodePos" feature to Tiptap. It allows users to access the state of the document similar to the browser DOM to access specific elements.

As a first draft you'll be able to run things like querySelector, querySelectorAll, closest, before, after, and more.

How did you accomplish your changes

I added a new class that will be used to track Node Positions and expose an API for easier traversion of nodes in the document itself. I added those as exported values but also to the editor object itself. It can be accessed via

editor.$doc
editor.$node
editor.$nodes
editor.$pos

for example

editor.$node('bulletList') // <- returns the first bulletList node found
editor.$nodes('listItem') // <- returns all listItem nodes found
editor.$node('bulletList').querySelectorAll('listItem') // <- returns all listItems inside the specific bulletList

How have you tested your changes

I've run local tests for now to verify my changes were working. I'll probably add tests to this PR asap so we don't run into issues later down the line.

Remarks

I'd like to get this done and into a new major or minor version as this is quite a big new feature.

Checklist

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

Copy link

netlify bot commented Dec 15, 2023

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit eab4814
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/659c375efcd3fb0008047d9b
😎 Deploy Preview https://deploy-preview-4701--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 mentioned this pull request Dec 15, 2023
5 tasks
Copy link

@montapro montapro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants