Merge pull request #409 from xwiki-labs/codemirrorStuff

Fix indent behaviour of Codemirror
pull/1/head
ansuz 5 years ago committed by GitHub
commit 19932e309c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -386,21 +386,32 @@ define([
exp.mkIndentSettings = function (metadataMgr) {
var setIndentation = function (units, useTabs, fontSize, spellcheck) {
if (typeof(units) !== 'number') { return; }
var doc = editor.getDoc();
editor.setOption('indentUnit', units);
editor.setOption('tabSize', units);
editor.setOption('indentWithTabs', useTabs);
editor.setOption('spellcheck', spellcheck);
if (!useTabs) {
editor.setOption("extraKeys", {
Tab: function() {
editor.replaceSelection(Array(units + 1).join(" "));
if (doc.somethingSelected()) {
editor.execCommand("indentMore");
}
});
} else {
editor.setOption("extraKeys", {
Tab: undefined,
});
else {
if (!useTabs) { editor.execCommand("insertSoftTab"); }
else { editor.execCommand("insertTab"); }
}
},
"Shift-Tab": function () {
editor.execCommand("indentLess");
},
"Backspace": function () {
var cursor = doc.getCursor();
var line = doc.getLine(cursor.line);
if (line.substring(0, cursor.ch).trim() === "") { editor.execCommand("indentLess"); }
else { editor.execCommand("delCharBefore"); }
},
});
$('.CodeMirror').css('font-size', fontSize+'px');
};

Loading…
Cancel
Save