I would like to insert a text with a link. I tried this:
const link = linkType.create({ href }); const node = state.schema.text(href).mark([link]); dispatch(state.tr.replaceSelectionWith(node, true));
but it only inserts the text. I don’t understand what I am doing wrong.
Double-check the docs for the second argument to replaceSelectionWith.
replaceSelectionWith
Thank you for your answer!
I checked the doc and tried state.tr.replaceSelectionWith(node, true) and state.tr.replaceSelectionWith(node), but thought the default was false (my fault).
state.tr.replaceSelectionWith(node, true)
state.tr.replaceSelectionWith(node)
false
So, indeed, it works with state.tr.replaceSelectionWith(node, false).
state.tr.replaceSelectionWith(node, false)