Closed SeongwoonHong closed 5 years ago
rte.selection()
returns the Selection object which you can use to detect the pointed node (from which you can get all the attributes you need)
@artf Could you give me an example of doing it please? I've tried lots of stuff but couldn't find a way to get any attributes using rte.selection().... I really appreciated it Artur.
It's all described here https://developer.mozilla.org/en-US/docs/Web/API/Selection
You can start by looking at Selection.focusNode
...
@artf Thank you for your quick response .. i know that the Selection document says that rte.selection().focusNode returns node but rte.selection().focusNode returns string here.. do you happen to know why and how to solve this? I even tried rte.selection().focusNode() but it says focusNode is not a function... Thank you so much..
focusNode returns string here
this is how the Node works, so to get the element just do rte.selection().focusNode.parentElement
@artf WOW you save my life!Thank you! I have no idea how many hours to figure this out by myself... thank you thank you! it's working now.....!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I have this rte toolbar where you can type and click 'save' and it's going to create a link for the selected text. but the problem is that the value of the input field should be dynamic based on selected text. If the selected text has href and the input field should show the href in there. How do i get href for the selected text in rte result or update function? This is a piece of my code
thank you Artur