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?
link to the site documentation CodeMirror Documentation Also, a link to a JSFiddle or a JSBin would be greatly appreciated for example reasons
About. CodeMirror is open source under a permissive license (MIT). It is being developed on GitHub. Contributions are welcome.
Something 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 */
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With