mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-06-27 13:11:01 -06:00
Merge pull request #471 from LevitatingOrange/detachedPreviewRendering
This commit is contained in:
commit
b4c55d9075
@ -267,6 +267,11 @@ const editor = new EasyMDE({
|
||||
preview.innerHTML = customMarkdownParser(plainText);
|
||||
}, 250);
|
||||
|
||||
// If you return null, the innerHTML of the preview will not
|
||||
// be overwritten. Useful if you control the preview node's content via
|
||||
// vdom diffing.
|
||||
// return null;
|
||||
|
||||
return "Loading...";
|
||||
},
|
||||
promptURLs: true,
|
||||
|
@ -1072,7 +1072,11 @@ function togglePreview(editor) {
|
||||
toolbar_div.classList.add('disabled-for-preview');
|
||||
}
|
||||
}
|
||||
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
|
||||
|
||||
var preview_result = editor.options.previewRender(editor.value(), preview);
|
||||
if (preview_result !== null) {
|
||||
preview.innerHTML = preview_result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2860,7 +2864,11 @@ EasyMDE.prototype.value = function (val) {
|
||||
if (this.isPreviewActive()) {
|
||||
var wrapper = cm.getWrapperElement();
|
||||
var preview = wrapper.lastChild;
|
||||
preview.innerHTML = this.options.previewRender(val, preview);
|
||||
var preview_result = this.options.previewRender(val, preview);
|
||||
if (preview_result !== null) {
|
||||
preview.innerHTML = preview_result;
|
||||
}
|
||||
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
2
types/easymde.d.ts
vendored
2
types/easymde.d.ts
vendored
@ -196,7 +196,7 @@ declare namespace EasyMDE {
|
||||
previewClass?: string | ReadonlyArray<string>;
|
||||
previewImagesInEditor?: boolean;
|
||||
imagesPreviewHandler?: (src: string) => string,
|
||||
previewRender?: (markdownPlaintext: string, previewElement: HTMLElement) => string;
|
||||
previewRender?: (markdownPlaintext: string, previewElement: HTMLElement) => string | null;
|
||||
promptURLs?: boolean;
|
||||
renderingConfig?: RenderingOptions;
|
||||
shortcuts?: Shortcuts;
|
||||
|
Loading…
x
Reference in New Issue
Block a user