|
|
@ -110,12 +110,16 @@ define([
|
|
|
|
return stringify(obj);
|
|
|
|
return stringify(obj);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var drawPreview = Cryptpad.throttle(function () {
|
|
|
|
var forceDrawPreview = function () {
|
|
|
|
if (CodeMirror.highlightMode !== 'markdown') { return; }
|
|
|
|
|
|
|
|
if (!$previewContainer.is(':visible')) { return; }
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DiffMd.apply(DiffMd.render(editor.getValue()), $preview);
|
|
|
|
DiffMd.apply(DiffMd.render(editor.getValue()), $preview);
|
|
|
|
} catch (e) { console.error(e); }
|
|
|
|
} catch (e) { console.error(e); }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var drawPreview = Cryptpad.throttle(function () {
|
|
|
|
|
|
|
|
if (CodeMirror.highlightMode !== 'markdown') { return; }
|
|
|
|
|
|
|
|
if (!$previewContainer.is(':visible')) { return; }
|
|
|
|
|
|
|
|
forceDrawPreview();
|
|
|
|
}, 150);
|
|
|
|
}, 150);
|
|
|
|
|
|
|
|
|
|
|
|
var onLocal = config.onLocal = function () {
|
|
|
|
var onLocal = config.onLocal = function () {
|
|
|
@ -239,9 +243,16 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$previewContainer.toggle();
|
|
|
|
$previewContainer.toggle();
|
|
|
|
if ($previewContainer.is(':visible')) {
|
|
|
|
if ($previewContainer.is(':visible')) {
|
|
|
|
|
|
|
|
forceDrawPreview();
|
|
|
|
$codeMirror.removeClass('fullPage');
|
|
|
|
$codeMirror.removeClass('fullPage');
|
|
|
|
|
|
|
|
Cryptpad.setPadAttribute('previewMode', true, function (e, data) {
|
|
|
|
|
|
|
|
if (e) { return console.log(e); }
|
|
|
|
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$codeMirror.addClass('fullPage');
|
|
|
|
$codeMirror.addClass('fullPage');
|
|
|
|
|
|
|
|
Cryptpad.setPadAttribute('previewMode', false, function (e, data) {
|
|
|
|
|
|
|
|
if (e) { return console.log(e); }
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$rightside.append($previewButton);
|
|
|
|
$rightside.append($previewButton);
|
|
|
@ -255,6 +266,7 @@ define([
|
|
|
|
CodeMirror.configureTheme();
|
|
|
|
CodeMirror.configureTheme();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set the hash
|
|
|
|
// set the hash
|
|
|
|
if (!readOnly) { Cryptpad.replaceHash(editHash); }
|
|
|
|
if (!readOnly) { Cryptpad.replaceHash(editHash); }
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -306,6 +318,14 @@ define([
|
|
|
|
Title.updateTitle(Cryptpad.initialName);
|
|
|
|
Title.updateTitle(Cryptpad.initialName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.getPadAttribute('previewMode', function (e, data) {
|
|
|
|
|
|
|
|
if (e) { return void console.error(e); }
|
|
|
|
|
|
|
|
var $codeMirror = $iframe.find('.CodeMirror');
|
|
|
|
|
|
|
|
if (data === false && APP.$previewButton) {
|
|
|
|
|
|
|
|
APP.$previewButton.click();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.removeLoadingScreen();
|
|
|
|
Cryptpad.removeLoadingScreen();
|
|
|
|
setEditable(true);
|
|
|
|
setEditable(true);
|
|
|
|
initializing = false;
|
|
|
|
initializing = false;
|
|
|
|