Don't create sfcommon a second time in code and slide

This commit is contained in:
yflory
2018-01-16 11:26:16 +01:00
parent 4fc1079d67
commit 88a04fdb07
4 changed files with 17 additions and 30 deletions

View File

@@ -103,7 +103,7 @@ define([
return text.trim();
};
module.create = function (Common, defaultMode, CMeditor) {
module.create = function (defaultMode, CMeditor) {
var exp = {};
var CodeMirror = exp.CodeMirror = CMeditor;
@@ -195,7 +195,7 @@ define([
return module.getHeadingText(editor);
};
exp.configureLanguage = function (cb, onModeChanged) {
exp.configureLanguage = function (Common, cb, onModeChanged) {
var options = [];
Modes.list.forEach(function (l) {
options.push({
@@ -227,7 +227,7 @@ define([
if (cb) { cb(); }
};
exp.configureTheme = function (cb) {
exp.configureTheme = function (Common, cb) {
/* Remember the user's last choice of theme using localStorage */
var themeKey = ['codemirror', 'theme'];

View File

@@ -329,13 +329,10 @@ define([
Object.freeze(funcs);
return { create: function (cb) {
// TODO(cjd): This is crap but this gets loaded multiple places by /code/ and it is
// not ok with being loaded more than once.
if (window.CryptPad_sframe_common) {
setTimeout(function () { cb(window.CryptPad_sframe_common); });
return;
throw new Error("Sframe-common should only be created once");
}
window.CryptPad_sframe_common = funcs;
window.CryptPad_sframe_common = true;
nThen(function (waitFor) {
SFrameChannel.create(window.parent, waitFor(function (sfc) { ctx.sframeChan = sfc; }), true);