我正在使用 ACE
编辑器第一次。我有以下相关问题。
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?
我愿意为任何比 ACE
更好的编辑器提供建议将支持几乎所有类型的语言/标记/css 等并与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 有用或难以集成。
Here's a Wiki page for comparision of such editors .
还有一个付费的,我没试过(现在我记不起来了)。如果我能找到它,稍后会更新。
关于javascript - 我如何从 ACE 编辑器中获取值(value)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8963855/