allow users to write with tabs instead of spaces

This commit is contained in:
ansuz
2017-08-11 15:21:26 +02:00
parent 64849507b3
commit 66cacf08da
3 changed files with 55 additions and 6 deletions

View File

@@ -61,19 +61,28 @@ define([
$iframe.find('.CodeMirror').addClass('fullPage');
editor = CodeMirror.editor;
var setIndentation = APP.setIndentation = function (units) {
var setIndentation = APP.setIndentation = function (units, useTabs) {
if (typeof(units) !== 'number') { return; }
editor.setOption('indentUnit', units);
editor.setOption('tabSize', units);
//editor.setOption('indentWithTabs', true);
editor.setOption('indentWithTabs', useTabs);
};
var indentKey = 'cryptpad.indentUnit';
var useTabsKey = 'cryptpad.indentWithTabs';
var proxy = Cryptpad.getProxy();
proxy.on('change', [indentKey], function (o, n) {
APP.setIndentation(n);
});
setIndentation(proxy[indentKey]);
var updateIndentSettings = function () {
var indentUnit = proxy[indentKey];
var useTabs = proxy[useTabsKey];
setIndentation(
typeof(indentUnit) === 'number'? indentUnit: 2,
typeof(useTabs) === 'boolean'? useTabs: false);
};
proxy.on('change', [indentKey], updateIndentSettings);
proxy.on('change', [useTabsKey], updateIndentSettings);
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');