Use the font-size codemirror setting in the slide app too

This commit is contained in:
yflory 2018-11-05 17:30:07 +01:00
parent c4c1fcb080
commit 997692efb4
3 changed files with 30 additions and 29 deletions

View File

@ -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);

View File

@ -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;
};

View File

@ -457,6 +457,7 @@ define([
mkMarkdownToolbar(framework, editor);
mkHelpMenu(framework);
CodeMirror.mkIndentSettings(framework._.cpNfInner.metadataMgr);
CodeMirror.configureTheme(common);
framework.onContentUpdate(function (newContent) {