admin管理员组文章数量:1331648
I try to get and set the value of an ace editor on a random website. But I do not know the instance names. Also there is no ID on any div. Is there a way to find one or all instances, so that I can access the api like:
var editor = ace.edit("...");
Thanks for your advice :)
I try to get and set the value of an ace editor on a random website. But I do not know the instance names. Also there is no ID on any div. Is there a way to find one or all instances, so that I can access the api like:
var editor = ace.edit("...");
Thanks for your advice :)
Share Improve this question asked Sep 14, 2015 at 13:40 pa1ndpa1nd 4424 silver badges17 bronze badges1 Answer
Reset to default 11all ace editors need to have ace_editor
classname and ace.edit
saves editor to <domNode>.env.editor
so the following should work in most cases
var all = document.querySelectorAll(".ace_editor");
for (var i = 0; i < all.length; i++) {
if (all[i].env && all[i].env.editor)
console.log(all[i].env.editor)
else
console.log("can't get editor from" all[i])
}
This won't work for editors created as new Editor()
which do not have env
and for editors created in shadow dom, which can't be found via querySelectorAll.
本文标签: javascriptAce EditorHow to find one or all instancesStack Overflow
版权声明:本文标题:javascript - Ace Editor - How to find one or all instances? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742223837a2435641.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论