I would like to get all the marks which surrounding the cursor in hierarchical order. So if you take for example:
Vivamus
<span class="text-red">
rhoncus justo vitae
<i>sem consequat, ac <b>tristique{{$cursor}}</b> neque maximus. </i>
Etiam et sapien vel ipsum tincidunt iaculis. Nullam sed purus mi.
</span>
Morbi eu vestibulum augue, at dignissim met
where {{$cursor}} denotes the position of the cursor.
I would like to end up with and array like
[
{ from: 26; to: 35, name: 'b' ''},
{ from: 17; to: 45, name: 'i'}
{ from: 7; to: 56, name: 'span'}
]
Notice how they are in order as you travel up the dom tree.
Is there an already established easy way to get hold of this information.
If you had to create it from scratch how would you go about it ?
No it’s not, it’s the normalized order based on the order of the marks in the schema.
Marks do not have a position. They may be attached to nodes, and if those nodes are adjacent you may consider the marked region to belong together, but the way they are stored doesn’t reflect that, so you’ll have to scan the marked node’s sibling nodes.