Reputation: 2809
Calling console.log(editor.state.doc)
reveals:
TextLeaf {
text: ["Test Text"],
length: 9,
Symbol(Symbol.iterator): function
}
So the text or editors value is there, however if I call editor.state.doc.text = ["New Test Text"]
I get missing text, so it doesn't seem to be the intended way to change it.
How do I actually do it?
editor.getDoc().setValue('New Test Text');
Upvotes: 3
Views: 3096
Reputation: 2809
The necessary information can be found here: https://codemirror.net/examples/change/
Example:
editor.dispatch({
changes: {from: 0, to: editor.state.doc.length, insert: 'New Test Text'}
});
editor
being a EditorView
instance.
Upvotes: 8