How to insert iconDiv at the end of each paragraph #2682
Answered
by
thegreatercurve
mahmedmushtaq
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
thegreatercurve
Jul 25, 2022
Replies: 1 comment
-
I've not tested this, but you could do something like the below to get the bounding box of the second-most parent element for each node in the tree, and then use that to position to absolutely position a floating menu. const anchorNode = $getSelection().anchorNode;
const secondLevelParentNode = $findMatchingParent(anchorNode, node => $getDepth(node) === 1)
const matchingElementForSecondLevelParentNode = editor.getElementByKey(secondLevelParentNode.getKey())
const {x, y} = matchingElementForSecondLevelParentNode.getBoundingClientRect() You could then use |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
thegreatercurve
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've not tested this, but you could do something like the below to get the bounding box of the second-most parent element for each node in the tree, and then use that to position to absolutely position a floating menu.
You could then use
registerUpdateListener
to recalculate the positions, any time there is an update to editor state.