Skip to content

Commit

Permalink
Sync changes from original text-area back to editor regularrily.
Browse files Browse the repository at this point in the history
This should fix the issue with the Issue Templates plugin and others.
  • Loading branch information
root committed Jul 26, 2018
1 parent 4804f2d commit 31aa49e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions assets/javascripts/bestest_markdown_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bestest_markdown_editor.helper = function(field_id, _locale, helpLink) {
}

var element = document.getElementById(field_id);
var value = element.value;
var timer = undefined;
var last_pre = 0;
var hidden = true;
Expand Down Expand Up @@ -71,17 +72,22 @@ bestest_markdown_editor.helper = function(field_id, _locale, helpLink) {
editor.codemirror.on('blur', function() { editor.codemirror.save(); });

setInterval(function() {
var h = editor.codemirror.getWrapperElement().offsetHeight === 0 && editor.codemirror.getWrapperElement().offsetWidth === 0;
var h = editor.codemirror.getWrapperElement().offsetHeight === 0 && editor.codemirror.getWrapperElement().offsetWidth === 0;
var v = element.value;

if (hidden !== h) {
if (hidden && !h) {
editor.value(element.value);
editor.codemirror.focus();
}
if (hidden !== h) {
if (hidden && !h) {
editor.value(element.value);
editor.codemirror.focus();
}

hidden = h;
}
}, 300);
hidden = h;
}
else if (value != v) {
editor.value(v);
value = v;
}
}, 300);
}

var bestest_markdown_editor_preview = {};

0 comments on commit 31aa49e

Please sign in to comment.