fix: copy of dark theme (#328)

This commit is contained in:
YangFong 2024-08-19 09:54:19 +08:00 committed by GitHub
parent 6b49a13148
commit fb510ed1a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -113,48 +113,50 @@ function copy() {
toggleDark()
}
solveWeChatImage()
nextTick(() => {
solveWeChatImage()
const clipboardDiv = document.getElementById(`output`)
clipboardDiv.innerHTML = mergeCss(clipboardDiv.innerHTML)
clipboardDiv.innerHTML = modifyHtmlStructure(clipboardDiv.innerHTML)
const clipboardDiv = document.getElementById(`output`)
clipboardDiv.innerHTML = mergeCss(clipboardDiv.innerHTML)
clipboardDiv.innerHTML = modifyHtmlStructure(clipboardDiv.innerHTML)
// katex
clipboardDiv.innerHTML = clipboardDiv.innerHTML
.replace(
/class="base"( style="display: inline")*/g,
`class="base" style="display: inline"`,
)
// katex
clipboardDiv.innerHTML = clipboardDiv.innerHTML
.replace(
/class="base"( style="display: inline")*/g,
`class="base" style="display: inline"`,
)
// position translateY
.replace(/top:(.*?)em/g, `transform: translateY($1em)`)
.replace(/top:(.*?)em/g, `transform: translateY($1em)`)
//
.replaceAll(`var(--el-text-color-regular)`, `#3f3f3f`)
clipboardDiv.focus()
window.getSelection().removeAllRanges()
const range = document.createRange()
.replaceAll(`var(--el-text-color-regular)`, `#3f3f3f`)
clipboardDiv.focus()
window.getSelection().removeAllRanges()
const range = document.createRange()
range.setStartBefore(clipboardDiv.firstChild)
range.setEndAfter(clipboardDiv.lastChild)
window.getSelection().addRange(range)
document.execCommand(`copy`)
window.getSelection().removeAllRanges()
clipboardDiv.innerHTML = output.value
range.setStartBefore(clipboardDiv.firstChild)
range.setEndAfter(clipboardDiv.lastChild)
window.getSelection().addRange(range)
document.execCommand(`copy`)
window.getSelection().removeAllRanges()
clipboardDiv.innerHTML = output.value
if (isBeforeDark) {
toggleDark()
}
if (isBeforeDark) {
toggleDark()
}
//
ElNotification({
showClose: true,
message: `已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴`,
offset: 80,
duration: 1600,
type: `success`,
//
ElNotification({
showClose: true,
message: `已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴`,
offset: 80,
duration: 1600,
type: `success`,
})
editorRefresh()
emit(`endCopy`)
})
editorRefresh()
emit(`endCopy`)
}, 350)
}
</script>