aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/markup/mermaid.js
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js/markup/mermaid.js')
-rw-r--r--web_src/js/markup/mermaid.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/web_src/js/markup/mermaid.js b/web_src/js/markup/mermaid.js
index efd9abbb56..29fa92552d 100644
--- a/web_src/js/markup/mermaid.js
+++ b/web_src/js/markup/mermaid.js
@@ -1,4 +1,6 @@
import {isDarkTheme} from '../utils.js';
+import {makeCodeCopyButton} from './codecopy.js';
+
const {mermaidMaxSourceCharacters} = window.config;
const iframeCss = `
@@ -58,7 +60,13 @@ export async function renderMermaid() {
iframe.sandbox = 'allow-scripts';
iframe.style.height = `${Math.ceil(parseFloat(heightStr))}px`;
iframe.srcdoc = `<html><head><style>${iframeCss}</style></head><body>${svgStr}</body></html>`;
- el.closest('pre').replaceWith(iframe);
+ const mermaidBlock = document.createElement('div');
+ mermaidBlock.classList.add('mermaid-block');
+ mermaidBlock.append(iframe);
+ const btn = makeCodeCopyButton();
+ btn.setAttribute('data-clipboard-text', source);
+ mermaidBlock.append(btn);
+ el.closest('pre').replaceWith(mermaidBlock);
});
} catch (err) {
displayError(el, err);