2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-08-18 14:42:46 -06:00

Merge pull request #404 from hansottowirtz/fix_399

Fix preview not rerendering when setting value
This commit is contained in:
Wes Cossick 2016-07-30 17:39:17 -05:00 committed by GitHub
commit 7e58a01a35

View File

@ -1896,10 +1896,16 @@ SimpleMDE.prototype.createStatusbar = function(status) {
* Get or set the text content. * Get or set the text content.
*/ */
SimpleMDE.prototype.value = function(val) { SimpleMDE.prototype.value = function(val) {
var cm = this.codemirror;
if(val === undefined) { if(val === undefined) {
return this.codemirror.getValue(); return cm.getValue();
} else { } else {
this.codemirror.getDoc().setValue(val); cm.getDoc().setValue(val);
if(this.isPreviewActive()) {
var wrapper = cm.getWrapperElement();
var preview = wrapper.lastChild;
preview.innerHTML = this.options.previewRender(val, preview);
}
return this; return this;
} }
}; };