如何从ACE编辑器获得价值? [英] How do I get value from ACE editor?
问题描述
我第一次使用 ACE
编辑器。我有以下与之相关的问题。
I am using ACE
editor for the first time. I have the below questions related to it.
-
如何找到<$的实例c $ c> ACE 页面上的编辑器?我不希望
维护一个包含编辑器实例的全局变量。 I
需要按需查找其实例。
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.
如何获取和设置其值?
我愿意接受比 ACE
编辑器更好的编辑器的建议将支持几乎所有类型的语言/标记/ CSS等,并高度集成 jQuery
。
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
.
推荐答案
根据他们的 API :
加价:
<div id="aceEditor" style="height: 500px; width: 500px">some text</div>
查找实例:
var editor = ace.edit("aceEditor");
获取/设置值:
var code = editor.getValue();
editor.setValue("new code here");
根据我的经验,Ace是我见过的最好的代码编辑器。很少有其他如 CodeMirror 等,但我发现它们比Ace更不实用或难以集成。
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.
还有一个付费的,我还没有尝试过(我现在也记不住了)。如果我能找到它,将在以后更新。
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屋!