tr.replaceWith to insert a mark

Is it not possible to insert a mark instead of a node using tr.replaceWith() ?

I’m replacing a substring of text from pos - href.length + 1 where pos is the current selection / cursor position to pos

it’s not working

          pos - href.length + 1,
{ href })

The text in the specified range will vanish but the mark won’t be inserted

As per the docs tr.replaceWith works with nodes and not marks. You should be instead using tr.addMark to add a mark to a range.

1 Like