Search code examples
javascriptsavecodemirror

Is there an in-built function defined to save the data in codemirror (other than the key map function)?


I am basically searching for a function that can be invoked on onClick event of a button. Also when saving the content it should be clear that which text area's content need to be saved if multiple text editors are present on the same page.


Solution

  • It depends how you have implemented the multiple text editors using CodeMirror. The following code returns the content of the editor instance.

    editor.getValue();
    

    Use this to save the content of a particular CodeMirror instance.