Feature Request: Function to Find the Closest Node by Type #6037
Aribaskar-jb
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
Description:
A utility function to find the closest node in the document tree using:
['paragraph', 'heading', 'listItem']
).nodePos
to locate the node.Proposed Functionality:
nodePos
.Use Cases:
Custom Toolbar Actions:
Identify the closest node of a specific type to enable or disable actions in a custom toolbar (e.g., toggling headings, lists, or formatting options).
Dynamic Node Manipulation:
Find and update the attributes or content of the nearest matching node programmatically (e.g., setting attributes for a parent
table
orblockquote
node).Plugin Development:
Streamline plugin logic by abstracting common operations like identifying the context of the current selection and traversing to find related parent nodes.
Validation of Nested Structures:
Verify the presence of specific node types with specific attributes in a nested hierarchy for document structure validation or error highlighting.
Contextual Styling or Behavior:
Change the behavior or styling of nodes dynamically based on the closest parent node that matches the specified type and attributes.
Type
New Tiptap API
Beta Was this translation helpful? Give feedback.
All reactions