Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/js/easymde.js
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ function toggleSideBySide(editor) {
var sideBySideRenderingFunction = function () {
var newValue = editor.options.previewRender(editor.value(), preview);
if (newValue != null) {
preview.innerHTML = newValue;
editor.options.setPreviewRender(preview, newValue);
}
};

Expand All @@ -947,7 +947,7 @@ function toggleSideBySide(editor) {
if (useSideBySideListener) {
var newValue = editor.options.previewRender(editor.value(), preview);
if (newValue != null) {
preview.innerHTML = newValue;
editor.options.setPreviewRender(preview, newValue);
}
cm.on('update', cm.sideBySideRenderingFunction);
} else {
Expand Down Expand Up @@ -1014,8 +1014,7 @@ function togglePreview(editor) {
toolbar_div.className += ' disabled-for-preview';
}
}
preview.innerHTML = editor.options.previewRender(editor.value(), preview);

editor.options.setPreviewRender(preview, editor.options.previewRender(editor.value(), preview));
}

function _replaceSelection(cm, active, startEnd, url) {
Expand Down Expand Up @@ -1690,6 +1689,12 @@ function EasyMDE(options) {
};
}

if (!options.setPreviewRender) {
options.setPreviewRender = function (preview, html) {
preview.innerHTML = html;
};
}


// Set default options for parsing config
options.parsingConfig = extend({
Expand Down Expand Up @@ -2609,7 +2614,7 @@ EasyMDE.prototype.value = function (val) {
if (this.isPreviewActive()) {
var wrapper = cm.getWrapperElement();
var preview = wrapper.lastChild;
preview.innerHTML = this.options.previewRender(val, preview);
this.options.setPreviewRender(preview, this.options.previewRender(val, preview));
}
return this;
}
Expand Down