How do I format HTML code in Code Mirror when the value is set to it?

冷暖自知 提交于 2019-12-04 10:04:57
Frank van Puffelen

There is a function called autoFormatRange

editor.autoFormatRange(range.from, range.to);

This fragment from the CodeMirror Group might be what you need:

function autoFormat() {
    var totalLines = editor.lineCount();
    var totalChars = editor.getTextArea().value.length;
    editor.autoFormatRange({line:0, ch:0}, {line:totalLines, ch:totalChars});
}

http://codemirror.net/2/demo/formatting.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!