I wanted to clear the editor with an external action. Passing null to tr.replaceWith
seems to work, but it does not feel like it is the right approach. I tried passing state.schema.text('')
too, but I get the Uncaught RangeError: Empty text nodes are not allowed
error.
const { state } = view;
const tr = state.tr;
tr.replaceWith(0, state.doc.content.size, null);
const newState = state.apply(tr);
view.updateState(newState);
What would be the appropriate action?
What would be the best way to dynamically add html content instead of using tr.insertText()