mirror of
https://github.com/doocs/md.git
synced 2025-02-12 01:30:08 +08:00
fix: ensure SVG elements are included in copy
This commit is contained in:
parent
a94da25b96
commit
a25dedf811
@ -125,7 +125,17 @@ function copy() {
|
|||||||
.replaceAll(`var(--el-text-color-regular)`, `#3f3f3f`)
|
.replaceAll(`var(--el-text-color-regular)`, `#3f3f3f`)
|
||||||
.replaceAll(`var(--md-primary-color)`, primaryColor.value)
|
.replaceAll(`var(--md-primary-color)`, primaryColor.value)
|
||||||
.replaceAll(/--md-primary-color:.+?;/g, ``)
|
.replaceAll(/--md-primary-color:.+?;/g, ``)
|
||||||
|
|
||||||
clipboardDiv.focus()
|
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)
|
||||||
|
|
||||||
window.getSelection()!.removeAllRanges()
|
window.getSelection()!.removeAllRanges()
|
||||||
const range = document.createRange()
|
const range = document.createRange()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user