admin管理员组文章数量:1305014
I have implemented Code Mirror as a plugin into a CMS system.
I have an issue where if I select multiple lines and press tab the lines are deleted.
This does not happen on the Code Mirror demo website. I can't find a configuration option to enable or disable multiple indent.
Here is my configuration code:
this.CodeArea = CodeMirror.fromTextArea(codeArea, {
lineNumbers: true,
mode: { name: "xml", htmlMode: true },
onChange : function (editor) {
editor.save();
}
});
Context: .Tridion2011Extensions.CodeMirror/BuildingBlocks.Tridion2011Extensions.CodeMirror/Scripts/codemirror/codemirror.js
I'm not sure what I'm missing. Any ideas?
I have implemented Code Mirror as a plugin into a CMS system.
I have an issue where if I select multiple lines and press tab the lines are deleted.
This does not happen on the Code Mirror demo website. I can't find a configuration option to enable or disable multiple indent.
Here is my configuration code:
this.CodeArea = CodeMirror.fromTextArea(codeArea, {
lineNumbers: true,
mode: { name: "xml", htmlMode: true },
onChange : function (editor) {
editor.save();
}
});
Context: https://github./rsleggett/tridion-mirror/blob/master/src/BuildingBlocks.Tridion2011Extensions.CodeMirror/BuildingBlocks.Tridion2011Extensions.CodeMirror/Scripts/codemirror/codemirror.js
I'm not sure what I'm missing. Any ideas?
Share Improve this question edited May 24, 2012 at 13:05 Rob Stevenson-Leggett asked May 21, 2012 at 18:03 Rob Stevenson-LeggettRob Stevenson-Leggett 35.7k21 gold badges92 silver badges142 bronze badges2 Answers
Reset to default 13 +200The CodeMirror javascripts differ between your version and the demo version:
In the demo version at around line 2036 there is the following code block that is missing from your version:
defaultTab: function(cm) {
if (cm.somethingSelected()) cm.indentSelection("add");
else cm.replaceSelection("\t", "end");
}
Along with a bunch of functions related to CodeMirror.keyMap
.
Compare the two and merge the missing bits, or just use the script from the demo version.
In my case, this was happening because I used the custom snippet from CodeMirror official documentation which mapped the Tab ¡to insert spaces instead of a tab character:
editor.setOption("extraKeys", {
Tab: function(cm) {
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
cm.replaceSelection(spaces);
}
});
Removing this custom snippet made block tabulation work again and spaces were used instead of tabs by default.
本文标签: javascriptCodeMirror 2 Multiple indent is deleting linesStack Overflow
版权声明:本文标题:javascript - CodeMirror 2: Multiple indent is deleting lines - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741791672a2397694.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论