Skip to content

Commit

Permalink
fix: cpoy of mermaid
Browse files Browse the repository at this point in the history
fix #469
  • Loading branch information
YangFong committed Dec 13, 2024
1 parent a62fa1f commit d29bc6a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/CodemirrorEditor/EditorHeader/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d29bc6a

Please sign in to comment.