From 7528699fbafc671e119328bef15dca80483932b6 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 18 Oct 2025 20:47:01 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/16139 --- app/src/protyle/wysiwyg/index.ts | 42 ++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index b061cf95e..a159658e4 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -307,9 +307,6 @@ export class WYSIWYG { html += getTextStar(item) + "\n\n"; } else { let itemHTML = ""; - if (item.getAttribute("data-type") === "NodeListItem") { - listHTML = `
`; - } if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") { needClipboardWrite = true; const response = await fetchSyncPost("/api/block/getHeadingChildrenDOM", { @@ -326,12 +323,18 @@ export class WYSIWYG { } else { itemHTML = removeEmbed(item); } - if (listHTML && (i === selectElements.length - 1 || - selectElements[i + 1].getAttribute("data-type") !== "NodeListItem" || - selectElements[i + 1].getAttribute("data-subtype") !== item.getAttribute("data-subtype") - )) { - html += `${listHTML}${itemHTML}
${Constants.ZWSP}
`; - listHTML = ""; + if (item.getAttribute("data-type") === "NodeListItem") { + if (!listHTML) { + listHTML = `
`; + } + listHTML += itemHTML; + if (i === selectElements.length - 1 || + selectElements[i + 1].getAttribute("data-type") !== "NodeListItem" || + selectElements[i + 1].getAttribute("data-subtype") !== item.getAttribute("data-subtype") + ) { + html += `${listHTML}
${Constants.ZWSP}
`; + listHTML = ""; + } } else { html += itemHTML; } @@ -1826,9 +1829,6 @@ export class WYSIWYG { for (let i = 0; i < selectElements.length; i++) { const item = getTopAloneElement(selectElements[i]); let itemHTML = ""; - if (item.getAttribute("data-type") === "NodeListItem") { - listHTML = `
`; - } if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") { needClipboardWrite = true; const response = await fetchSyncPost("/api/block/getHeadingChildrenDOM", { @@ -1845,12 +1845,18 @@ export class WYSIWYG { } else { itemHTML = removeEmbed(item); } - if (listHTML && (i === selectElements.length - 1 || - selectElements[i + 1].getAttribute("data-type") !== "NodeListItem" || - selectElements[i + 1].getAttribute("data-subtype") !== item.getAttribute("data-subtype") - )) { - html += `${listHTML}${itemHTML}
${Constants.ZWSP}
`; - listHTML = ""; + if (item.getAttribute("data-type") === "NodeListItem") { + if (!listHTML) { + listHTML = `
`; + } + listHTML += itemHTML; + if (i === selectElements.length - 1 || + selectElements[i + 1].getAttribute("data-type") !== "NodeListItem" || + selectElements[i + 1].getAttribute("data-subtype") !== item.getAttribute("data-subtype") + ) { + html += `${listHTML}
${Constants.ZWSP}
`; + listHTML = ""; + } } else { html += itemHTML; }