codemirror javascript在线脚本编辑器

codemirror javascript在线脚本编辑器

https://codemirror.net/

 

    <title>codeMirror测试</title><link type="text/css" rel="stylesheet" href="codemirror/lib/codemirror.css" /><link type="text/css" rel="stylesheet" href="codemirror/theme/eclipse-ext.css" /><link type="text/css" rel="stylesheet" href="codemirror/addon/hint/show-hint.css" /><script type="text/javascript" src="codemirror/lib/codemirror.js"></script><script type="text/javascript" src="codemirror/mode/javascript/javascript.js"></script><script type="text/javascript" src="codemirror/addon/hint/show-hint.js"></script><script type="text/javascript" src="codemirror/addon/hint/javascript-hint.js"></script><style>.CodeMirror {border: 1px solid black;}</style><h2>Autocomplete Demo</h2>
< textarea id="code" name="code">< /textarea>
< button type="submit" name="button" id="button" value="if{ &#10 &#10}else{&#10 &#10}">if..else< /button>< script src="jquery-1.11.3.js">< /script>
< script>CodeMirror.velocityContext = "server software env";  //提取到外部,方便从后台获取数据CodeMirror.velocityCustomizedKeywords = "server.ip server.cache software.conf software.version software.tags.count";var editor = CodeMirror.fromTextArea(document.getElementById("code"), {lineNumbers: true,extraKeys: {"Ctrl-Q": "autocomplete"},  //避免热键冲突  mode: {name: "javascript", globalVars: true}});$("#button").click(function () {editor.replaceSelection("if{\n\n}else{\n\n}")});
//    editor.on('change', function() {
//        editor.showHint();  //满足自动触发自动联想功能
//    });
< /script>

 

Published by

风君子

独自遨游何稽首 揭天掀地慰生平