Browse Source

chore: update mermaid to 11.9.0 (#8009)

Co-authored-by: ᴊᴏᴇ ᴄʜᴇɴ <jc@unknwon.io>
Dmitry Afanasiev 2 weeks ago
parent
commit
6a6364bb5d

+ 1 - 0
CHANGELOG.md

@@ -12,6 +12,7 @@ All notable changes to Gogs are documented in this file.
 
 
 - The required Go version to compile source code changed to 1.24.
 - The required Go version to compile source code changed to 1.24.
 - The build tag `cert` has been removed, and the `gogs cert` subcommand is now always available. [#7883](https://github.com/gogs/gogs/pull/7883)
 - The build tag `cert` has been removed, and the `gogs cert` subcommand is now always available. [#7883](https://github.com/gogs/gogs/pull/7883)
+- Updated Mermaid JS to 11.9.0. [#8009](https://github.com/gogs/gogs/pull/8009)
 
 
 ### Fixed
 ### Fixed
 
 

File diff suppressed because it is too large
+ 0 - 5
public/plugins/mermaid-10.9.1/mermaid.min.js


File diff suppressed because it is too large
+ 0 - 0
public/plugins/mermaid-11.9.0/mermaid.min.js


+ 41 - 2
templates/base/footer.tmpl

@@ -59,10 +59,49 @@
 	<script src="{{AppSubURL}}/plugins/autosize-4.0.2/autosize.min.js"></script>
 	<script src="{{AppSubURL}}/plugins/autosize-4.0.2/autosize.min.js"></script>
 {{end}}
 {{end}}
 {{if .IsMarkdown}}
 {{if .IsMarkdown}}
-	<script src="{{AppSubURL}}/plugins/mermaid-10.9.1/mermaid.min.js"></script>
+	<script src="{{AppSubURL}}/plugins/mermaid-11.9.0/mermaid.min.js"></script>
 	<script>
 	<script>
 		$(document).ready(function () {
 		$(document).ready(function () {
-			mermaid.init({startOnLoad: true, noteMargin: 10}, ".language-mermaid");
+			const deepMerge = function(target, source) {
+				// Create a deep copy of the target to avoid modifying the original
+				const output = { ...target };
+
+				if (target && typeof target === 'object' && source && typeof source === 'object') {
+					for (const key in source) {
+						if (source.hasOwnProperty(key)) {
+							if (source[key] instanceof Object && target[key] instanceof Object) {
+								// If both are objects, recursively merge
+								output[key] = deepMerge(target[key], source[key]);
+							} else if (Array.isArray(source[key]) && Array.isArray(target[key])) {
+								// If both are arrays, concatenate them
+								output[key] = [...target[key], ...source[key]];
+							} else {
+								// Otherwise, overwrite with the source value
+								output[key] = source[key];
+							}
+						}
+					}
+				}
+
+				return output;
+			};
+
+			let initializeOpts = { startOnLoad: false, sequence: {noteMargin: 10}, journey: {noteMargin: 10}, timeline: {noteMargin: 10}, state: {noteMargin: 10} };
+
+			if (window.MERMAID_INITIALIZE_OPTIONS) {
+				// allow customization in inject/head.tmpl
+				initializeOpts = deepMerge(initializeOpts, window.MERMAID_INITIALIZE_OPTIONS);
+			}
+
+			mermaid.initialize(initializeOpts);
+
+			let runOpts = { querySelector: '.language-mermaid' };
+			if (window.MERMAID_RUN_OPTIONS) {
+				// allow customization in inject/head.tmpl
+				runOpts = deepMerge(runOpts, window.MERMAID_RUN_OPTIONS);
+			}
+
+			mermaid.run(runOpts);
 		});
 		});
 	</script>
 	</script>
 {{end}}
 {{end}}

Some files were not shown because too many files changed in this diff