Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: list rendering error #297

Merged
merged 1 commit into from
May 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading