Create text node with mark

Hi, I want to create a text node with some marks like emphasize.

I want do so via

const tr = view.state.tr.replaceRangeWith( range.from, range.to, view.state.schema.text(“test”, [view.state.schema.marks.em]) ) view.dispatch(tr)

This does not work - I get an error message “Uncaught TypeError: Cannot read property ‘excludes’ of undefined”.

It works, however, if I am removing the field for marks?

Do you know how to make this work?

Just learning myself, and haven’t tried running this, but I think you want:

const tr = view.state.tr.replaceRangeWith( range.from, range.to, view.state.schema.text(“test”, [view.state.schema.mark(“em”)]) ) view.dispatch(tr)

Thank you very much, that helped immediately! :slight_smile: