let attrs={ title: 'mylink', href:'google.com' }
let schema=view.state.schema
let node=schema.text(attrs.title)
node=node.mark(schema.marks.link.create(attrs))
view.dispatch(view.state.tr.replaceSelectionWith(node))
ok thx ! (would be great if text and mark will throw if marks is not an array…)
Still no luck, I tried:
let attrs={ title: 'mylink', href:'google.com' }
let schema=view.state.schema
let node=schema.text(attrs.title, [schema.marks.link.create(attrs)])
view.dispatch(view.state.tr.replaceSelectionWith(node))
but I still get a ‘mylink’ text without the link mark
(I inspected node and it does have a marks array with a single link mark)
let attrs={ title: 'mylink', href:'google.com' }
let schema=view.state.schema
let node=schema.text(attrs.title, [schema.marks.link.create(attrs)])
view.dispatch(view.state.tr.replaceSelectionWith(node, false))