Compare commits

...

2 Commits

Author SHA1 Message Date
YangFong
e8b815033e
Merge ed22528b0b8b42469a449711a04cf53b726024e0 into 1ab6cbfeb21220428c2e616dc12609435bb1b307 2024-12-23 12:27:54 +08:00
Libin YANG
1ab6cbfeb2
fix: copy svg (#491)
All checks were successful
Build and Deploy / build-and-deploy (push) Has been skipped
close #490
2024-12-23 11:34:33 +08:00

View File

@ -55,6 +55,15 @@ const copyMode = useStorage(addPrefix(`copyMode`), `txt`)
const source = ref(``)
const { copy: copyContent } = useClipboard({ source })
const creatEmptyNode = () => {
const node = document.createElement(`p`)
node.style.fontSize = `0`
node.style.lineHeight = `0`
node.style.margin = `0`
node.innerHTML = ` `
return node
}
//
function copy() {
emit(`startCopy`)
@ -98,13 +107,11 @@ function copy() {
clipboardDiv.focus()
// edge case: svg
const p = document.createElement(`p`)
p.style.fontSize = `0` // 0
p.style.lineHeight = `0` // 0
p.style.margin = `0` //
p.innerHTML = ` `
clipboardDiv.insertBefore(p, clipboardDiv.firstChild)
// svg
const beforeNode = creatEmptyNode()
const afterNode = creatEmptyNode()
clipboardDiv.insertBefore(beforeNode, clipboardDiv.firstChild)
clipboardDiv.appendChild(afterNode)
// Mermaid
const nodes = clipboardDiv.querySelectorAll(`.nodeLabel`)