mirror of
https://github.com/doocs/md.git
synced 2025-02-09 00:05:46 +08:00
Compare commits
2 Commits
5f53be4534
...
e8b815033e
Author | SHA1 | Date | |
---|---|---|---|
|
e8b815033e | ||
|
1ab6cbfeb2 |
@ -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`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user