Feat: add diagram copy button support for Mermaid and ECharts (#616)

This commit is contained in:
Cell
2025-08-13 17:05:33 +08:00
parent 590b8f47b2
commit 7b9c3e62c7
8 changed files with 104 additions and 4 deletions
@@ -0,0 +1,9 @@
{{- /* Diagram copy button */ -}}
{{- $label := .Label | default "Copy Diagram code" -}}
{{- $iconCopy := dict "Class" "fa-regular fa-clone" -}}
{{- $iconCheck := dict "Class" "fa-solid fa-check text-success" -}}
<div class="diagram-copy-btn" aria-label="{{ $label }}" role="button">
{{- $iconCopy | partial "plugin/icon.html" -}}
{{- $iconCheck | partial "plugin/icon.html" -}}
</div>
+6 -1
View File
@@ -1,4 +1,4 @@
{{- /* Echarts support for code fences extended and shortcodes. */ -}}
{{- /* ECharts support for code fences extended and shortcodes. */ -}}
{{- $width := .Options.width | default "100%" -}}
{{- $height := .Options.height | default "30rem" -}}
{{- $js := .Options.js | default false -}}
@@ -6,6 +6,9 @@
{{- $data := .Options.data -}}
{{- $file := .Options.file -}}
{{- $attrs := printf `style="width: %v; height: %v;"` $width $height -}}
<div class="echarts-container">
{{- dict "Label" "Copy ECharts code" | partial "plugin/diagram-copy-btn.html" -}}
<div class="echarts" {{ $attrs | safeHTMLAttr }}></div>
{{- $content := strings.TrimSpace .Inner -}}
{{- if $js | or (hasSuffix $file ".js") -}}
@@ -38,3 +41,5 @@
{{- end -}}
<template>{{ $content | jsonify }}</template>
{{- end -}}
</div>
{{- /* EOF */ -}}
+5 -2
View File
@@ -1,4 +1,7 @@
{{- /* Mermaid support for code fences extended and shortcodes. */ -}}
<pre class="mermaid">{{ .Inner | safeHTML }}</pre>
<template>{{ .Inner | safeHTML }}</template>
<div class="mermaid-container">
{{- dict "Label" "Copy Mermaid code" | partial "plugin/diagram-copy-btn.html" -}}
<pre class="mermaid">{{ .Inner | safeHTML }}</pre>
<template>{{ .Inner | safeHTML }}</template>
</div>
{{- /* EOF */ -}}