fix: do not touch lists during migration

This commit is contained in:
thecodrr
2022-07-15 14:47:36 +05:00
parent a80badea31
commit ff6463f901

View File

@@ -94,12 +94,17 @@ function decodeWrappedTableHtml(html) {
} }
export function tinyToTiptap(html) { export function tinyToTiptap(html) {
if (typeof html !== "string") return html;
const document = parseHTML(html); const document = parseHTML(html);
const tables = document.querySelectorAll("table"); const tables = document.querySelectorAll("table");
for (const table of tables) { for (const table of tables) {
table.removeAttribute("contenteditable"); table.removeAttribute("contenteditable");
if (table.parentElement?.nodeName.toLowerCase() === "div") { if (
table.parentElement &&
table.parentElement.nodeName.toLowerCase() === "div"
) {
table.parentElement.replaceWith(table); table.parentElement.replaceWith(table);
} }
} }
@@ -119,15 +124,6 @@ export function tinyToTiptap(html) {
if (!p.childNodes.length) p.remove(); if (!p.childNodes.length) p.remove();
} }
const listItems = document.querySelectorAll("li");
for (const li of listItems) {
if (li.firstChild) {
const p = document.createElement("p");
p.appendChild(li.firstChild.cloneNode());
li.firstChild.replaceWith(p);
}
}
const bogus = document.querySelectorAll("[data-mce-bogus]"); const bogus = document.querySelectorAll("[data-mce-bogus]");
for (const element of bogus) { for (const element of bogus) {
element.remove(); element.remove();