如何从 ACE 编辑器中获取价值? [英] How do I get value from ACE editor?
问题描述
我第一次使用 ACE
编辑器.我有以下相关问题.
如何在页面上找到
ACE
编辑器的实例?我不要维护一个将保存编辑器实例的全局变量.一世需要按需查找其实例.如何获取和设置它的值?
我愿意为任何比 ACE
编辑器更好的编辑器提供建议,该编辑器将支持几乎所有类型的语言/标记/css 等,并与 jQuery
高度集成.>
根据他们的 API:
标记:
<div id="aceEditor" style="height: 500px; width: 500px">一些文字</div>
查找实例:
var editor = ace.edit("aceEditor");
获取/设置值:
var code = editor.getValue();editor.setValue("这里有新代码");
根据我的经验,Ace 是我见过的最好的代码编辑器.还有一些其他的,例如 CodeMirror 等,但我发现它们不如 Ace 有用或难以集成.>
还有一个付费的,我没试过(我现在不记得了).以后能找到的话会更新的.
I am using ACE
editor for the first time. I have the below questions related to it.
How do I find the instance of
ACE
editor on the page? I don't want to maintain a global variable which will hold the editor instance. I need to find its instance on demand.How to get and set its value?
I am open for suggestions for any better editor than ACE
editor which will support almost all types of language/markup/css etc and highly integrated with jQuery
.
Per their API:
Markup:
<div id="aceEditor" style="height: 500px; width: 500px">some text</div>
Finding an instance:
var editor = ace.edit("aceEditor");
Getting/Setting Values:
var code = editor.getValue();
editor.setValue("new code here");
Based on my experience, Ace is the best code editor I've seen. There are few others such as CodeMirror etc. but I found them to be less useful or difficult to integrate than Ace.
Here's a Wiki page for comparision of such editors.
There is a paid one also which I haven't tried (and I can't remember for now). Will updated later if I can find it.
这篇关于如何从 ACE 编辑器中获取价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!