admin管理员组文章数量:1316654
I have a div called content_editable. I am making a code editing application. So there are certain css dimensions it needs to follow. But I want to be able to add the code mirror syntax highlighting script to it. But when I do it the way the documentation says to do it, nothing happens. At all. My div to be edited is called #editable_content
. How do I add the CodeMirror capabilities to it?
EDIT
link to the site documentation CodeMirror Documentation Also, a link to a JSFiddle or a JSBin would be greatly appreciated for example reasons
I have a div called content_editable. I am making a code editing application. So there are certain css dimensions it needs to follow. But I want to be able to add the code mirror syntax highlighting script to it. But when I do it the way the documentation says to do it, nothing happens. At all. My div to be edited is called #editable_content
. How do I add the CodeMirror capabilities to it?
EDIT
link to the site documentation CodeMirror Documentation Also, a link to a JSFiddle or a JSBin would be greatly appreciated for example reasons
Share Improve this question asked Nov 10, 2011 at 3:47 uu 9211 gold badge11 silver badges29 bronze badges1 Answer
Reset to default 9Something like this (untested) should do the trick
var ce = document.getElementById("content_editable");
// Probably needs more kludges to be portable... you get the idea
var text = ce.textContent || ce.innerText;
var editor = CodeMirror(function(node){ce.parentNode.replaceChild(node, ce);}, {
value: text
/* , your options */
});
本文标签: javascriptApply CodeMirror to preexisting divStack Overflow
版权声明:本文标题:javascript - Apply CodeMirror to pre-existing div - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742005790a2411924.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论