diff --git a/www/code/main.js b/www/code/main.js index 36f734d0f..7ac345fb6 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -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'); diff --git a/www/settings/main.js b/www/settings/main.js index 24978bf50..c36e6cf0c 100644 --- a/www/settings/main.js +++ b/www/settings/main.js @@ -51,6 +51,7 @@ define([ ], 'code': [ 'indentUnit', + 'indentType' ] }; @@ -163,6 +164,41 @@ define([ return $div; }; + var createIndentTypeSelector = function (obj) { + var proxy = obj.proxy; + + var key = 'cryptpad.indentWithTabs'; + + var $div = $('
', { + 'class': 'indentType element' + }); + $('