Add custom data attributes to nodes #2129
Unanswered
jivesilver
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be awesome if we could add custom data attributes to nodes upon creating them. Like for headings
This way we could use it for other plugin/operations.
In my case, I was trying to create a "Table of contents" plugin.
Its main purpose is to generate a table of contents based on existing heading1 elements.
Got this to work, but it has limitations. Currently we can map the corresponding heading to the table of contents item via the text turned into ID by repacing SPACE with '-' and transforming the text to lower case.
I'm using this ID to scroll users into the corresponding heading element on click.
Problem is when users update the heading1 text.
I lose the link as it using the heading text as ID.
Beta Was this translation helpful? Give feedback.
All reactions