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

pull/1/head
yflory 6 years ago
parent c4c1fcb080
commit 997692efb4

@ -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) { var mkFilePicker = function (framework, editor, evModeChange) {
evModeChange.reg(function (mode) { evModeChange.reg(function (mode) {
if (MEDIA_TAG_MODES.indexOf(mode) !== -1) { if (MEDIA_TAG_MODES.indexOf(mode) !== -1) {
@ -297,7 +269,7 @@ define([
evModeChange.reg(previewPane.modeChange); evModeChange.reg(previewPane.modeChange);
evModeChange.reg(markdownTb.modeChange); evModeChange.reg(markdownTb.modeChange);
mkIndentSettings(editor, framework._.cpNfInner.metadataMgr); CodeMirror.mkIndentSettings(framework._.cpNfInner.metadataMgr);
CodeMirror.init(framework.localChange, framework._.title, framework._.toolbar); CodeMirror.init(framework.localChange, framework._.title, framework._.toolbar);
mkFilePicker(framework, editor, evModeChange); mkFilePicker(framework, editor, evModeChange);

@ -346,6 +346,34 @@ define([
framework._.sfCommon.createFileManager(fmConfig); 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; return exp;
}; };

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

Loading…
Cancel
Save