Vanessa 2025-09-06 18:02:18 +08:00
parent 4767e399e2
commit 80cccd41b5
3 changed files with 86 additions and 38 deletions

View file

@ -450,10 +450,26 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
if (tempElement.content.firstChild.nodeType === 3 || (tempElement.content.firstChild.nodeType === 1 && tempElement.content.firstElementChild.tagName !== "DIV")) {
tempElement.innerHTML = protyle.lute.SpinBlockDOM(tempElement.innerHTML);
}
(insertBefore ? Array.from(tempElement.content.children) : Array.from(tempElement.content.children).reverse()).forEach((item) => {
// https://github.com/siyuan-note/siyuan/issues/13232
let foldHeadingId = "";
let foldHTML = "";
// 粘贴内容中包含折叠的子节点需后端插入到原节点中
Array.from(tempElement.content.children).forEach((item) => {
if (!item.getAttribute("parent-heading") && foldHeadingId && foldHTML) {
fetchPost("/api/block/appendHeadingChildren", {id: foldHeadingId, dom: foldHTML});
foldHeadingId = "";
foldHTML = "";
}
if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {
item.removeAttribute("fold");
foldHeadingId = item.getAttribute("data-node-id");
return true;
}
if (foldHeadingId && item.getAttribute("parent-heading") === foldHeadingId) {
foldHTML += item.outerHTML;
}
});
(insertBefore ? Array.from(tempElement.content.children) : Array.from(tempElement.content.children).reverse()).find((item) => {
if (item.getAttribute("parent-heading")) {
return;
}
let addId = item.getAttribute("data-node-id");
if (addId === id) {