Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Add limit to blocks highlighting
Elian Doranf80cf0aa0280
diff --git a/src/public/app/widgets/type_widgets/ckeditor/syntax_highlight.js b/src/public/app/widgets/type_widgets/ckeditor/syntax_highlight.jsindex 396f2bea0d..6d858d9106 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