I am finding CodeMirror 6 extremely difficult to understand - there is so little documentation, except for the automatically generated documentation which are extremely complicated and of so little use. I simply cannot get my view to update.
i have text that changes from being loaded by API, the code mirror instance should update to show this new text. i tried the following:
...
object.code = 'the new text from the db';
...
let {view} = instance; //instance is my cm6 instance
let transaction = view.state.update({changes : {newDoc : object.code}});
view.dispatch(transaction);
this doesn’t work
nor does this work
...
let {view} = instance; //instance is my cm6 instance
let transaction = view.state.update({newDoc : object.code});
view.dispatch(transaction);
nor does any other combination of whatever else work.
The dispatch() does not fail.
The update() does not fail.
this also does not work:
let changes = cm6.createEditorState(object.code);
let transaction = view.state.update({changes});
view.dispatch(transaction);
You can pass it any rubbish it will simply execute and do nothing - defeating the whole purpose of having strong types - what a terrible idea to move to typescript imo - never trust m$