Skip to content

Commit 7528699

Browse files
committed
🎨 #16139
1 parent 2dc9632 commit 7528699

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

app/src/protyle/wysiwyg/index.ts

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,6 @@ export class WYSIWYG {
307307
html += getTextStar(item) + "\n\n";
308308
} else {
309309
let itemHTML = "";
310-
if (item.getAttribute("data-type") === "NodeListItem") {
311-
listHTML = `<div data-subtype="${item.getAttribute("data-subtype")}" data-node-id="${Lute.NewNodeID()}" data-type="NodeList" class="list">`;
312-
}
313310
if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {
314311
needClipboardWrite = true;
315312
const response = await fetchSyncPost("/api/block/getHeadingChildrenDOM", {
@@ -326,12 +323,18 @@ export class WYSIWYG {
326323
} else {
327324
itemHTML = removeEmbed(item);
328325
}
329-
if (listHTML && (i === selectElements.length - 1 ||
330-
selectElements[i + 1].getAttribute("data-type") !== "NodeListItem" ||
331-
selectElements[i + 1].getAttribute("data-subtype") !== item.getAttribute("data-subtype")
332-
)) {
333-
html += `${listHTML}${itemHTML}<div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;
334-
listHTML = "";
326+
if (item.getAttribute("data-type") === "NodeListItem") {
327+
if (!listHTML) {
328+
listHTML = `<div data-subtype="${item.getAttribute("data-subtype")}" data-node-id="${Lute.NewNodeID()}" data-type="NodeList" class="list">`;
329+
}
330+
listHTML += itemHTML;
331+
if (i === selectElements.length - 1 ||
332+
selectElements[i + 1].getAttribute("data-type") !== "NodeListItem" ||
333+
selectElements[i + 1].getAttribute("data-subtype") !== item.getAttribute("data-subtype")
334+
) {
335+
html += `${listHTML}<div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;
336+
listHTML = "";
337+
}
335338
} else {
336339
html += itemHTML;
337340
}
@@ -1826,9 +1829,6 @@ export class WYSIWYG {
18261829
for (let i = 0; i < selectElements.length; i++) {
18271830
const item = getTopAloneElement(selectElements[i]);
18281831
let itemHTML = "";
1829-
if (item.getAttribute("data-type") === "NodeListItem") {
1830-
listHTML = `<div data-subtype="${item.getAttribute("data-subtype")}" data-node-id="${Lute.NewNodeID()}" data-type="NodeList" class="list">`;
1831-
}
18321832
if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {
18331833
needClipboardWrite = true;
18341834
const response = await fetchSyncPost("/api/block/getHeadingChildrenDOM", {
@@ -1845,12 +1845,18 @@ export class WYSIWYG {
18451845
} else {
18461846
itemHTML = removeEmbed(item);
18471847
}
1848-
if (listHTML && (i === selectElements.length - 1 ||
1849-
selectElements[i + 1].getAttribute("data-type") !== "NodeListItem" ||
1850-
selectElements[i + 1].getAttribute("data-subtype") !== item.getAttribute("data-subtype")
1851-
)) {
1852-
html += `${listHTML}${itemHTML}<div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;
1853-
listHTML = "";
1848+
if (item.getAttribute("data-type") === "NodeListItem") {
1849+
if (!listHTML) {
1850+
listHTML = `<div data-subtype="${item.getAttribute("data-subtype")}" data-node-id="${Lute.NewNodeID()}" data-type="NodeList" class="list">`;
1851+
}
1852+
listHTML += itemHTML;
1853+
if (i === selectElements.length - 1 ||
1854+
selectElements[i + 1].getAttribute("data-type") !== "NodeListItem" ||
1855+
selectElements[i + 1].getAttribute("data-subtype") !== item.getAttribute("data-subtype")
1856+
) {
1857+
html += `${listHTML}<div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;
1858+
listHTML = "";
1859+
}
18541860
} else {
18551861
html += itemHTML;
18561862
}

0 commit comments

Comments
 (0)