CodeMirror 是一款允许在浏览器中使用的多功能文本编辑器, 专用于编辑代码, 并附带超过 100 种语言模式和各种插件, 可实现高级的代码编辑功能, 包括代码高亮显示、功能扩展以及多个主题样式。
官网: https://codemirror.net/
github地址:
https://github.com/codemirror/CodeMirror
function hello(who = "world") {
console.log(`Hello, ${who}!`)
}
这是一个 CodeMirror 字段,配置用于编辑 JavaScript 代码。
使用方法:
<link rel="stylesheet" href="lib/codemirror.css">
<script src="lib/codemirror.js"></script>
<script type="text/javascript">
// 使用方法:
var editor = CodeMirror.fromTextArea(myTextarea, {
lineNumbers: true
});
</script>
<textarea id='demotext'></textarea>