From a31e56d42113c21bb5c6ac42dbf136f175613806 Mon Sep 17 00:00:00 2001 From: johannes karoff Date: Fri, 12 Jun 2020 15:33:21 +0200 Subject: [PATCH] option for settings previewhtml --- src/js/easymde.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/js/easymde.js b/src/js/easymde.js index bfa1a7b8..8d020e15 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -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); } }; @@ -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 { @@ -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) { @@ -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({ @@ -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; }