mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
✨ Feat: add diagram copy button support for Mermaid and ECharts (#616)
This commit is contained in:
@@ -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>
|
||||
@@ -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 */ -}}
|
||||
|
||||
@@ -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 */ -}}
|
||||
|
||||
Reference in New Issue
Block a user