From 973195a131ebbff471c5e0179d1ac95181c9af3d Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 25 Nov 2021 12:22:44 +0100 Subject: [PATCH] Fix TypeError in codemirror with code blocks --- www/code/orgmode.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/www/code/orgmode.js b/www/code/orgmode.js index 942d141f2..0c46a7a20 100644 --- a/www/code/orgmode.js +++ b/www/code/orgmode.js @@ -2,6 +2,19 @@ define([ 'cm/lib/codemirror', 'cm/addon/mode/simple' ], function (CodeMirror) { + + // Hack to avoid breaking a document with ```__proto__ codeblock + CodeMirror.defineSimpleMode("__proto__", { + start: [ {regex: /.*/, token: "comment"} ], + env: [ {regex: /.*/, token: "comment"} ] + }); + CodeMirror.registerHelper("fold", "__proto__", function(cm, start) { + return { + from: CodeMirror.Pos(0,0), + to: CodeMirror.Pos(0,0) + }; + }); + CodeMirror.__mode = 'orgmode'; var isEmpty = function (el, idx) {