diff --git a/.vitepress/theme/components/MermaidZoom.vue b/.vitepress/theme/components/MermaidZoom.vue
new file mode 100644
index 00000000..f330fcc0
--- /dev/null
+++ b/.vitepress/theme/components/MermaidZoom.vue
@@ -0,0 +1,497 @@
+
+
+
+
+
+
+
+
+
diff --git a/.vitepress/theme/index.mts b/.vitepress/theme/index.mts
index ae7adffd..a06ce203 100644
--- a/.vitepress/theme/index.mts
+++ b/.vitepress/theme/index.mts
@@ -12,6 +12,7 @@ import { h } from "vue"
import TranslationNotice from "./components/TranslationNotice.vue"
import PageContributors from "./components/PageContributors.vue"
import BackToTop from "./components/BackToTop.vue"
+import MermaidZoom from "./components/MermaidZoom.vue"
export default {
extends: DefaultTheme,
@@ -35,7 +36,7 @@ export default {
return h(DefaultTheme.Layout, null, {
"doc-before": () => h(TranslationNotice),
"doc-after": () => h(PageContributors),
- "layout-bottom": () => h(BackToTop)
+ "layout-bottom": () => [h(BackToTop), h(MermaidZoom)]
})
}
}
diff --git a/.vitepress/theme/style/index.css b/.vitepress/theme/style/index.css
index 346c3319..5f2d822f 100644
--- a/.vitepress/theme/style/index.css
+++ b/.vitepress/theme/style/index.css
@@ -1,3 +1,4 @@
@import "./var.css";
@import "./custom-block.css";
@import "./blockquote.css";
+@import "./vitepress-plugin-mermaid.css";
diff --git a/.vitepress/theme/style/vitepress-plugin-mermaid.css b/.vitepress/theme/style/vitepress-plugin-mermaid.css
new file mode 100644
index 00000000..cd4976f8
--- /dev/null
+++ b/.vitepress/theme/style/vitepress-plugin-mermaid.css
@@ -0,0 +1,23 @@
+/* .vitepress/theme/style/vitepress-plugin-mermaid.css */
+
+/* Fix: VitePress typography styles affect Mermaid htmlLabels and clip last line */
+.vp-doc .mermaid svg foreignObject p {
+ margin: 0 !important;
+ padding: 0 !important;
+ line-height: 1.2 !important;
+}
+
+/* In some cases, the default overflow setting for foreignObjects may cause clipping, so I'll go ahead and disable it */
+.vp-doc .mermaid svg foreignObject > div {
+ width: 100% !important;
+ height: 100% !important;
+ display: flex !important;
+ align-items: center !important;
+ justify-content: center !important;
+ text-align: center !important;
+ box-sizing: border-box;
+}
+
+.vp-doc .mermaid svg {
+ cursor: zoom-in;
+}
diff --git a/package.json b/package.json
index d8fd7223..7709a3ea 100644
--- a/package.json
+++ b/package.json
@@ -2,6 +2,7 @@
"devDependencies": {
"medium-zoom": "^1.1.0",
"mermaid": "^11.12.2",
+ "svg-pan-zoom": "^3.6.2",
"vitepress": "2.0.0-alpha.15",
"vitepress-plugin-llms": "^1.10.0",
"vitepress-plugin-mermaid": "^2.0.17"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e821fa9d..6c9d53d3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -14,6 +14,9 @@ importers:
mermaid:
specifier: ^11.12.2
version: 11.12.2
+ svg-pan-zoom:
+ specifier: ^3.6.2
+ version: 3.6.2
vitepress:
specifier: 2.0.0-alpha.15
version: 2.0.0-alpha.15(postcss@8.5.6)
@@ -1320,6 +1323,9 @@ packages:
resolution: {integrity: sha512-H+ue8Zo4vJmV2nRjpx86P35lzwDT3nItnIsocgumgr0hHMQ+ZGq5vrERg9kJBo5AWGmxZDhzDo+WVIJqkB0cGA==}
engines: {node: '>=16'}
+ svg-pan-zoom@3.6.2:
+ resolution: {integrity: sha512-JwnvRWfVKw/Xzfe6jriFyfey/lWJLq4bUh2jwoR5ChWQuQoOH8FEh1l/bEp46iHHKHEJWIyFJETbazraxNWECg==}
+
tabbable@6.3.0:
resolution: {integrity: sha512-EIHvdY5bPLuWForiR/AN2Bxngzpuwn1is4asboytXtpTgsArc+WmSJKVLlhdh71u7jFcryDqB2A8lQvj78MkyQ==}
@@ -2898,6 +2904,8 @@ snapshots:
dependencies:
copy-anything: 4.0.5
+ svg-pan-zoom@3.6.2: {}
+
tabbable@6.3.0: {}
tinyexec@1.0.2: {}