CodeMirror batch changes - Javascript CodeMirror

Javascript examples for CodeMirror:Configuration

Description

CodeMirror batch changes

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>CodeMirror GetDoc</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
window.onload = function () {//w w w .j av a2 s. c  o m
    var cm = CodeMirror.fromTextArea(document.getElementById('codesnippet_editable'), {
        mode: "javascript",
        theme: "default",
        lineNumbers: true,
        pollInterval: 500
    });
    document.getElementById("foo").addEventListener("click", function () {
        console.log(cm.getDoc().getHistory());
    });
};

      </script> 
   </head> 
   <body> 
      <link rel="stylesheet" href="https://codemirror.net/lib/codemirror.css"> 
      <script src="https://codemirror.net/lib/codemirror.js"></script> 
      <script src="https://codemirror.net/addon/edit/matchbrackets.js"></script> 
      <script src="https://codemirror.net/addon/edit/continuecomment.js"></script> 
      <script src="https://codemirror.net/mode/javascript/javascript.js"></script> 
      <button id="foo">See console after clicking me</button> 
      <textarea rows="4" cols="50" name="codesnippet_editable" id="codesnippet_editable">
// Write some code here
</textarea>   
   </body>
</html>

Related Tutorials