Skip to content

Commit

Permalink
fix(katzencore): Fixed formatting after save
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlkatze committed Aug 8, 2024
1 parent c76f272 commit 7a757fa
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/runtime/components/views/EditView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,21 @@ onMounted(
selectedImage.value = content.src
}
else {
editor.value?.commands.setContent(component.content as string)
if (component.type === ComponentType.Text) {
editor.value?.commands.setContent(component.content as string)
}
else if (component.type === ComponentType.RichText) {
const parser = new DOMParser()
const dom = parser.parseFromString(component.content as string, 'text/html')
const pTags = dom.querySelectorAll('span')
const newDom = document.createElement('body')
pTags.forEach((pTag) => {
const p = document.createElement('p')
p.innerHTML = pTag.innerHTML
newDom.appendChild(p)
})
editor.value?.commands.setContent(newDom.innerHTML as string)
}
}
}
}
Expand Down Expand Up @@ -206,6 +220,7 @@ const editor = useEditor({
const text = dom.body.textContent || ''
if (currentSelectedComponent.value?.type === ComponentType.RichText) {
console.log(html)
const newDom = document.createElement('body')
const pTags = dom.querySelectorAll('p')
pTags.forEach((pTag, index) => {
Expand Down

0 comments on commit 7a757fa

Please sign in to comment.