CodeMirror 在線代碼編輯器


像百度編輯器插件部分、菜鳥教程示例等高德地圖都在使用,這里也記錄一下:

CodeMirror是一個用於編輯器文本框textarea代碼高亮javascript插件......

vue 中使用 參見:
https://www.npmjs.com/package/vue-codemirror
https://blog.csdn.net/oumaharuki/article/details/79268498

普通使用例如:
<!doctype html>
<title>CodeMirror</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="codemirror.css">
<script src="codemirror.js"></script>
<script src="xml.js"></script>
<article>
  <form style="border:1px solid red;">
    <textarea id="code" name="code">
    This is an example of EJS (embedded javascript)
    <p>The program says <%= hello("world") %>.</p>
    <script>
      alert("And here is some normal JS code"); // also colored
    </script>
    <div>addd</div>
    </textarea>
  </form>
  <script>
    var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
      lineNumbers: true,
      mode: "text/html",
      indentUnit: 4,
      indentWithTabs: true
    });
    editor.on("change", function (Editor, changes) {
      console.log('test')
      console.log(Editor)
      console.log(changes)
      console.log(editor.getValue())
    });
  </script>
</article>

 

 

地址:http://codemirror.net/

使用手冊:http://codemirror.net/doc/manual.html

github地址:https://github.com/marijnh/codemirror

 

使用方法等,可見前輩整理:

CodeMirror 使用大全 https://www.cnblogs.com/onlyonely/p/4450029.html

 編輯器大全  http://www.html580.com/6399


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM