From c747a36910777e9f3f8a058eb9ea2cf2c2778214 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 8 Sep 2020 11:28:58 +0200 Subject: [PATCH] Make sure we don't initialize orgmode multiple times --- www/code/orgmode.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/www/code/orgmode.js b/www/code/orgmode.js index c2af1bd5e..942d141f2 100644 --- a/www/code/orgmode.js +++ b/www/code/orgmode.js @@ -123,7 +123,10 @@ define([ }; }); + var init = false; CodeMirror.registerHelper("orgmode", "init", function (editor) { + if (init) { return; } + editor.setOption("extraKeys", { "Tab": function(cm) { org_cycle(cm); }, "Shift-Tab": function(cm){ org_shifttab(cm); }, @@ -139,6 +142,7 @@ define([ "Shift-Right": function(cm){ org_shiftright(cm); } }); + init = true; editor.on('mousedown', toggleHandler); editor.on('touchstart', toggleHandler); editor.on('gutterClick', foldLine); @@ -155,6 +159,9 @@ define([ }); CodeMirror.registerHelper("orgmode", "destroy", function (editor) { + if (!init) { return; } + + init = false; editor.off('mousedown', toggleHandler); editor.off('touchstart', toggleHandler); editor.off('gutterClick', foldLine);