mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 03:32:26 +08:00
Add limit to blocks highlighting
This commit is contained in:
parent
6078620bf1
commit
f80cf0aa02
@ -3,6 +3,8 @@ export function initSyntaxHighlighting(editor) {
|
|||||||
initTextEditor(editor);
|
initTextEditor(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const HIGHLIGHT_MAX_BLOCK_COUNT = 500;
|
||||||
|
|
||||||
const tag = "SyntaxHighlightWidget";
|
const tag = "SyntaxHighlightWidget";
|
||||||
const debugLevels = ["error", "warn", "info", "log", "debug"];
|
const debugLevels = ["error", "warn", "info", "log", "debug"];
|
||||||
const debugLevel = "debug";
|
const debugLevel = "debug";
|
||||||
@ -162,6 +164,11 @@ function highlightCodeBlock(codeBlock, writer) {
|
|||||||
log("not highlighting plaintext codeblock");
|
log("not highlighting plaintext codeblock");
|
||||||
return;
|
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
|
// highlight.js needs the full text without HTML tags, eg for the
|
||||||
// text
|
// text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user