I would like to reset all the contents of the Codemirror editor. Ideally, this should clear the text box, remove all marks and clear the history.
What is the best way to achieve this?
cm.setValue(""); cm.clearHistory(); // cm.clearGutter("gutterId"); if you have gutters
If you don't want to kill an instance of CodeMirror, just change the entire document containing the text, marker data, etc.
This can be done by calling cm.swapDoc(doc: CodeMirror.Doc) .
cm.swapDoc(doc: CodeMirror.Doc)
In addition, executing cm.setValue(newValue) simply sets the contents of the editor without deleting the CM instance. Doc
cm.setValue(newValue)
Source: https://habr.com/ru/post/944289/More articles:Do I need to use the volatile keyword if I declare a variable between mutexes and return it? - c ++How to install visual studio documentation offline? - visual-studioTweepy user id from mention - pythonMultiline with sentence in Python - pythonuint24_t and uint48_t in MinGW - c ++Python single-line (perl to pyp conversion) - pythonDart Separation - dartLaravel menu self-regulation - phpGIT traction conflict: if not on any branch? - gitHow best to keep the job queue clean from duplicate / duplicate jobs (using sidekiq and redis-semaphore) - ruby โโ| fooobar.comAll Articles