From 82a00480829f47853f0f8217d9fb56f82e1e7625 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 26 Sep 2019 11:56:53 +0200 Subject: [PATCH] keep trying to draw the preview pane, if necessary --- www/code/inner.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/www/code/inner.js b/www/code/inner.js index 7f043a9c9..7c5e64c4f 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -227,6 +227,20 @@ define([ $(window).off('mouseup mousemove', handler); $(window).on('mouseup mousemove', handler); }); + + var previewInt; + var clear = function () { clearInterval(previewInt); }; + + // keep trying to draw until you're confident it has been drawn + previewInt = setInterval(function () { + // give up if it's not a valid preview mode + if (['markdown', 'gfm'].indexOf(CodeMirror.highlightMode) === -1) { return void clear(); } + // give up if content has been drawn + if ($preview.text()) { return void clear(); } + // only draw if there is actually content to display + if (editor && !editor.getValue().trim()) { return void clear(); } + forceDrawPreview(); + }, 1000); }); framework._.sfCommon.getPadAttribute('previewMode', function (e, data) {