Skip to content

Commit

Permalink
fix: list rendering error (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
YangFong committed May 12, 2024
1 parent ed951d2 commit 7ade99b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/components/CodemirrorEditor/EditorHeader/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,29 @@ export default {
copy() {
this.$emit(`startCopy`)
setTimeout(() => {
function modifyHtmlStructure(htmlString) {
// 创建一个 div 元素来暂存原始 HTML 字符串
const tempDiv = document.createElement(`div`)
tempDiv.innerHTML = htmlString
const originalItems = tempDiv.querySelectorAll(`li > ul, li > ol`)
originalItems.forEach((originalItem) => {
originalItem.parentElement.insertAdjacentElement(
`afterend`,
originalItem
)
})
// 返回修改后的 HTML 字符串
return tempDiv.innerHTML
}
solveWeChatImage()
const clipboardDiv = document.getElementById(`output`)
clipboardDiv.innerHTML = mergeCss(clipboardDiv.innerHTML)
clipboardDiv.innerHTML = modifyHtmlStructure(clipboardDiv.innerHTML)
// 调整 katex 公式元素为行内标签,目的是兼容微信公众号渲染
clipboardDiv.innerHTML = clipboardDiv.innerHTML
Expand Down

0 comments on commit 7ade99b

Please sign in to comment.