From 997692efb4be39bceb09bd7fe6860523997df3bc Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 5 Nov 2018 17:30:07 +0100 Subject: [PATCH] Use the font-size codemirror setting in the slide app too --- www/code/inner.js | 30 +------------------------- www/common/sframe-common-codemirror.js | 28 ++++++++++++++++++++++++ www/slide/inner.js | 1 + 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/www/code/inner.js b/www/code/inner.js index 2376c80bb..a6114c1dc 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -238,34 +238,6 @@ define([ }; }; - var mkIndentSettings = function (editor, metadataMgr) { - var setIndentation = function (units, useTabs, fontSize) { - if (typeof(units) !== 'number') { return; } - editor.setOption('indentUnit', units); - editor.setOption('tabSize', units); - editor.setOption('indentWithTabs', useTabs); - $('.CodeMirror').css('font-size', fontSize+'px'); - }; - - var indentKey = 'indentUnit'; - var useTabsKey = 'indentWithTabs'; - var fontKey = 'fontSize'; - var updateIndentSettings = function () { - if (!metadataMgr) { return; } - var data = metadataMgr.getPrivateData().settings; - data = data.codemirror || {}; - var indentUnit = data[indentKey]; - var useTabs = data[useTabsKey]; - var fontSize = data[fontKey]; - setIndentation( - typeof(indentUnit) === 'number'? indentUnit : 2, - typeof(useTabs) === 'boolean'? useTabs : false, - typeof(fontSize) === 'number' ? fontSize : 12); - }; - metadataMgr.onChangeLazy(updateIndentSettings); - updateIndentSettings(); - }; - var mkFilePicker = function (framework, editor, evModeChange) { evModeChange.reg(function (mode) { if (MEDIA_TAG_MODES.indexOf(mode) !== -1) { @@ -297,7 +269,7 @@ define([ evModeChange.reg(previewPane.modeChange); evModeChange.reg(markdownTb.modeChange); - mkIndentSettings(editor, framework._.cpNfInner.metadataMgr); + CodeMirror.mkIndentSettings(framework._.cpNfInner.metadataMgr); CodeMirror.init(framework.localChange, framework._.title, framework._.toolbar); mkFilePicker(framework, editor, evModeChange); diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index 58d84a616..0163001f7 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -346,6 +346,34 @@ define([ framework._.sfCommon.createFileManager(fmConfig); }; + exp.mkIndentSettings = function (metadataMgr) { + var setIndentation = function (units, useTabs, fontSize) { + if (typeof(units) !== 'number') { return; } + editor.setOption('indentUnit', units); + editor.setOption('tabSize', units); + editor.setOption('indentWithTabs', useTabs); + $('.CodeMirror').css('font-size', fontSize+'px'); + }; + + var indentKey = 'indentUnit'; + var useTabsKey = 'indentWithTabs'; + var fontKey = 'fontSize'; + var updateIndentSettings = function () { + if (!metadataMgr) { return; } + var data = metadataMgr.getPrivateData().settings; + data = data.codemirror || {}; + var indentUnit = data[indentKey]; + var useTabs = data[useTabsKey]; + var fontSize = data[fontKey]; + setIndentation( + typeof(indentUnit) === 'number'? indentUnit : 2, + typeof(useTabs) === 'boolean'? useTabs : false, + typeof(fontSize) === 'number' ? fontSize : 12); + }; + metadataMgr.onChangeLazy(updateIndentSettings); + updateIndentSettings(); + }; + return exp; }; diff --git a/www/slide/inner.js b/www/slide/inner.js index c06010b6e..1881e42b2 100644 --- a/www/slide/inner.js +++ b/www/slide/inner.js @@ -457,6 +457,7 @@ define([ mkMarkdownToolbar(framework, editor); mkHelpMenu(framework); + CodeMirror.mkIndentSettings(framework._.cpNfInner.metadataMgr); CodeMirror.configureTheme(common); framework.onContentUpdate(function (newContent) {