在线web代码编辑器的制作
来源:互联网 发布:淘客cms系统是什么 编辑:程序博客网 时间:2024/05/16 13:42
之前一直想做一个oj系统,但oj 系统前端核心就是代码编辑器,只要用户可以选中某一种语言,这种代码编辑器就可以针对影虎输入的代码进行代码高亮的操作,网上搜了一款在线web代码编辑器的插件ace ,推荐几个比较好的网站
1)http://www.cnblogs.com/HansBug/p/6546606.html
2)http://www.jianshu.com/p/7cc4359a97d9
3)官网 https://ace.c9.io/?spm=5176.100239.blogcont65260.13.VpYjw3
4)git地址 https://github.com/ajaxorg/ace?spm=5176.100239.blogcont65260.14.hFdsLx
其实我在网上看到其他代码编辑器,像微软的microsoft Editor 也不错,后续我也会研究一下
以下是我的做的一个小demo,后续也会继续完善这个项目,让她更好看
HTML页面:
</head> <body> <div style="margin-left: 10%;"> <h4>请选择语言:</h4> <select id="language" style="width: 200px;height: 30px;font-size: 15px" onchange="change()"> <option value="java" >java</option> <option value="c_cpp">c_cpp</option> <option value="javascript">javascript</option> </select> </div> <br/> <!--代码输入框(注意请务必设置高度,否则无法显示)--> <pre id="code" class="ace_editor" style="min-height:400px"> <textarea class="ace_text-input"> </textarea> </pre> </body> <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script> <script src="js/editor.js" type="text/javascript" charset="utf-8"></script></html>js脚本
$(function(){ init("java");});function change(){ var select = document.getElementById('language'); init(select.value);};function init(language){ //初始化对象 editor = ace.edit("code"); editor.setHighlightActiveLine(true); //设置风格和语言(更多风格和语言,请到github上相应目录查看) theme = "clouds" language=language; editor.setTheme("ace/theme/" + theme); editor.session.setMode("ace/mode/" + language); //字体大小 editor.setFontSize(18); //设置只读(true时只读,用于展示代码) editor.setReadOnly(false); //自动换行,设置为off关闭 editor.setOption("wrap", "free") //启用提示菜单 ace.require("ace/ext/language_tools"); editor.setOptions({ enableBasicAutocompletion: true, enableSnippets: true, enableLiveAutocompletion: true });}
阅读全文
0 0
- 在线web代码编辑器的制作
- 制作WEB在线编辑器-插入HTML标签
- 制作WEB在线编辑器-插入HTML标签
- 制作WEB在线编辑器-插入HTML标签
- 在线编辑器制作学习
- 符合Web标准的在线编辑器:widgEditor [
- 运行HTML代码的在线编辑器
- 基于浏览器的在线代码编辑器
- 强大的在线代码编辑器-ACE
- web在线编辑器FCKEditor
- web 在线word编辑器
- 在线HTML编辑器代码
- 在线代码编辑器
- 在线代码编辑器
- 在线代码编辑器
- 在线代码编辑器codeMirror
- 基于web的在线复杂公式编辑器的实现
- 22个Web在线编辑器
- 浅显易懂地解说 Paxos 的算法
- 学生信息系统学习心得四、学籍管理模块的创建
- html5自动弹出软键盘的方法
- idea注册码
- Leetcode 523.Continuous Subarray Sum
- 在线web代码编辑器的制作
- oracle封装方法
- JVM调优方法
- [MSSQL]SQL查询结果转换成HTML并通过邮件预警
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
- C#基础-036 类的继承
- mysql随笔(一)------基础知识
- 汽车轮胎代码意义
- Spring bean 的生命周期