From d29bc6a4461902343e8acc31cf5884cafe60e8af Mon Sep 17 00:00:00 2001 From: YangFong Date: Fri, 13 Dec 2024 13:10:46 +0800 Subject: [PATCH] fix: cpoy of mermaid fix #469 --- .../CodemirrorEditor/EditorHeader/index.vue | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/components/CodemirrorEditor/EditorHeader/index.vue b/src/components/CodemirrorEditor/EditorHeader/index.vue index 3f65709a8..c528a9e04 100644 --- a/src/components/CodemirrorEditor/EditorHeader/index.vue +++ b/src/components/CodemirrorEditor/EditorHeader/index.vue @@ -137,6 +137,21 @@ function copy() { p.innerHTML = ` ` clipboardDiv.insertBefore(p, clipboardDiv.firstChild) + // 兼容 Mermaid + const nodes = clipboardDiv.querySelectorAll(`.nodeLabel`) + for (const node of nodes) { + const parent = node.parentElement! + const xmlns = parent.getAttribute(`xmlns`)! + const style = parent.getAttribute(`style`)! + const section = document.createElement(`section`) + section.setAttribute(`xmlns`, xmlns) + section.setAttribute(`style`, style) + section.innerHTML = parent.innerHTML + const grand = parent.parentElement! + grand.innerHTML = `` + grand.appendChild(section) + } + window.getSelection()!.removeAllRanges() const range = document.createRange()