aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-07-24 05:21:51 +0100
committerGitHub <noreply@github.com>2021-07-24 00:21:51 -0400
commitf135a818f53d82a61f3d99d80e2a2384f00c51d2 (patch)
treeb335f68ee5308bf7ad4b9246c0feb3d4948cb304 /web_src/js
parent342f338bda2f728a869349e271a8b11ebc76372a (diff)
downloadgitea-f135a818f53d82a61f3d99d80e2a2384f00c51d2.tar.gz
gitea-f135a818f53d82a61f3d99d80e2a2384f00c51d2.zip
Make Mermaid.js limit configurable (#16519)
* Make Mermaid.js limit configurable Add `MERMAID_MAX_SOURCE_CHARACTERS` to `[markup]` settings to make the maximum size of a mermaid render configurable. Fix #16513 Signed-off-by: Andrew Thornton <art27@cantab.net> * fixup! Make Mermaid.js limit configurable * Update custom/conf/app.example.ini Co-authored-by: silverwind <me@silverwind.io> * Update docs/content/doc/advanced/config-cheat-sheet.en-us.md Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/markup/mermaid.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/web_src/js/markup/mermaid.js b/web_src/js/markup/mermaid.js
index d0aefd1aff..a5bd0e235c 100644
--- a/web_src/js/markup/mermaid.js
+++ b/web_src/js/markup/mermaid.js
@@ -1,4 +1,4 @@
-const MAX_SOURCE_CHARACTERS = 5000;
+const {MermaidMaxSourceCharacters} = window.config;
function displayError(el, err) {
el.closest('pre').classList.remove('is-loading');
@@ -26,8 +26,8 @@ export async function renderMermaid(els) {
});
for (const el of els) {
- if (el.textContent.length > MAX_SOURCE_CHARACTERS) {
- displayError(el, new Error(`Mermaid source of ${el.textContent.length} characters exceeds the maximum allowed length of ${MAX_SOURCE_CHARACTERS}.`));
+ if (MermaidMaxSourceCharacters >= 0 && el.textContent.length > MermaidMaxSourceCharacters) {
+ displayError(el, new Error(`Mermaid source of ${el.textContent.length} characters exceeds the maximum allowed length of ${MermaidMaxSourceCharacters}.`));
continue;
}