Find a node by attribute value #1946
Answered
by
KaneCohen
iamursky
asked this question in
Questions & Help
-
I'm trying to find a position of heading that has id attribute with some value to apply |
Beta Was this translation helpful? Give feedback.
Answered by
KaneCohen
Sep 27, 2021
Replies: 2 comments 1 reply
-
Answered in discord, but for future reference if it might have somebody looking for similar issue, here's a possible solution (that I didn't test): editor.state.doc.forEach(node, offset) => {
if (node.attrs.id === yourId) {
editor.chain().setNodeSelection(offset).scrollIntoView().run();
}
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
iamursky
-
You can set some attribute of node DOM when render HTML, then just query the DOM, and use the scrollIntoView method. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Answered in discord, but for future reference if it might have somebody looking for similar issue, here's a possible solution (that I didn't test):