diff --git a/src/public/app/widgets/type_widgets/ckeditor/syntax_highlight.js b/src/public/app/widgets/type_widgets/ckeditor/syntax_highlight.js index 396f2bea0..6d858d910 100644 --- a/src/public/app/widgets/type_widgets/ckeditor/syntax_highlight.js +++ b/src/public/app/widgets/type_widgets/ckeditor/syntax_highlight.js @@ -3,6 +3,8 @@ export function initSyntaxHighlighting(editor) { initTextEditor(editor); } +const HIGHLIGHT_MAX_BLOCK_COUNT = 500; + const tag = "SyntaxHighlightWidget"; const debugLevels = ["error", "warn", "info", "log", "debug"]; const debugLevel = "debug"; @@ -162,6 +164,11 @@ function highlightCodeBlock(codeBlock, writer) { log("not highlighting plaintext codeblock"); return; } + + // Don't highlight if the code is too big, as the typing performance will be highly degraded. + if (codeBlock.childCount >= HIGHLIGHT_MAX_BLOCK_COUNT) { + return; + } // highlight.js needs the full text without HTML tags, eg for the // text