How to modify Mark Attributes - change the href on a link

Let’s say I have. The following html where {{$cusor}} denotes the position of the cursor.

Vivamus augue
<span class="text-red">
<a href="https://google.com">Google{{$cursor}}</a>
</span> 
Morbi eu vestibulum augue, at dignissim met

I would like to modify the href attribute of this link mark. What is the current way of doing this ?

An other example would be is to modify the class on the span.

Thank you !

You should be able to call addMark with the extent of the old mark and the new attributes. Since you can’t have two link marks on the same content, that’ll automatically replace the previous link mark.

1 Like

Hello! I’m currently trying to update attributes on a customized type of mark in our RTE.

Since you can’t have two link marks on the same content, that’ll automatically replace the previous link mark.

I’m curious how this is achieved, since I’m hesitant to go the addMark direction because I want to avoid cluttering the node with superfluous marks.

Remove the old mark, and then add a new mark with the proper attributes.