mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
This commit is contained in:
parent
468b670bcc
commit
c326989391
2 changed files with 29 additions and 27 deletions
|
@ -450,31 +450,29 @@ 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")) {
|
if (tempElement.content.firstChild.nodeType === 3 || (tempElement.content.firstChild.nodeType === 1 && tempElement.content.firstElementChild.tagName !== "DIV")) {
|
||||||
tempElement.innerHTML = protyle.lute.SpinBlockDOM(tempElement.innerHTML);
|
tempElement.innerHTML = protyle.lute.SpinBlockDOM(tempElement.innerHTML);
|
||||||
}
|
}
|
||||||
let foldHeadingId = "";
|
// let foldHeadingId = "";
|
||||||
let foldHTML = "";
|
// let foldHTML = "";
|
||||||
// 粘贴内容中包含折叠的子节点需后端插入到原节点中
|
// 粘贴内容中包含折叠的子节点需后端插入到原节点中
|
||||||
Array.from(tempElement.content.children).forEach((item) => {
|
// Array.from(tempElement.content.children).forEach((item) => {
|
||||||
if (!item.getAttribute("parent-heading") && foldHeadingId && foldHTML) {
|
// if (!item.getAttribute("parent-heading") && foldHeadingId && foldHTML) {
|
||||||
fetchPost("/api/block/appendHeadingChildren", {id: foldHeadingId, dom: foldHTML});
|
// fetchPost("/api/block/appendHeadingChildren", {id: foldHeadingId, dom: foldHTML});
|
||||||
foldHeadingId = "";
|
// foldHeadingId = "";
|
||||||
foldHTML = "";
|
// foldHTML = "";
|
||||||
}
|
// }
|
||||||
if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {
|
// if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {
|
||||||
foldHeadingId = item.getAttribute("data-node-id");
|
// foldHeadingId = item.getAttribute("data-node-id");
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
if (foldHeadingId && item.getAttribute("parent-heading")) {
|
// if (foldHeadingId && item.getAttribute("parent-heading")) {
|
||||||
foldHTML += item.outerHTML;
|
// foldHTML += item.outerHTML;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
if (foldHeadingId && foldHTML) {
|
// if (foldHeadingId && foldHTML) {
|
||||||
fetchPost("/api/block/appendHeadingChildren", {id: foldHeadingId, dom: foldHTML});
|
// fetchPost("/api/block/appendHeadingChildren", {id: foldHeadingId, dom: foldHTML});
|
||||||
}
|
// }
|
||||||
(insertBefore ? Array.from(tempElement.content.children) : Array.from(tempElement.content.children).reverse()).find((item) => {
|
(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");
|
let addId = item.getAttribute("data-node-id");
|
||||||
|
const hasParentHeading = item.getAttribute("parent-heading");
|
||||||
if (addId === id) {
|
if (addId === id) {
|
||||||
doOperation.push({
|
doOperation.push({
|
||||||
action: "update",
|
action: "update",
|
||||||
|
@ -499,10 +497,12 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
|
||||||
liElement.append(item);
|
liElement.append(item);
|
||||||
item = liElement;
|
item = liElement;
|
||||||
}
|
}
|
||||||
|
item.removeAttribute("parent-heading");
|
||||||
doOperation.push({
|
doOperation.push({
|
||||||
action: "insert",
|
action: "insert",
|
||||||
data: item.outerHTML,
|
data: item.outerHTML,
|
||||||
id: addId,
|
id: addId,
|
||||||
|
context: {ignoreProcess: hasParentHeading ? "true" : "false"},
|
||||||
nextID: insertBefore ? id : undefined,
|
nextID: insertBefore ? id : undefined,
|
||||||
previousID: insertBefore ? undefined : id
|
previousID: insertBefore ? undefined : id
|
||||||
});
|
});
|
||||||
|
@ -511,10 +511,12 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
|
||||||
id: addId,
|
id: addId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (insertBefore) {
|
if (!hasParentHeading) {
|
||||||
blockElement.before(item);
|
if (insertBefore) {
|
||||||
} else {
|
blockElement.before(item);
|
||||||
blockElement.after(item);
|
} else {
|
||||||
|
blockElement.after(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!lastElement) {
|
if (!lastElement) {
|
||||||
lastElement = item;
|
lastElement = item;
|
||||||
|
|
|
@ -108,7 +108,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
|
||||||
} else {
|
} else {
|
||||||
foldPreviousId = "";
|
foldPreviousId = "";
|
||||||
}
|
}
|
||||||
// // https://github.com/siyuan-note/siyuan/issues/4422
|
// https://github.com/siyuan-note/siyuan/issues/4422
|
||||||
topElement.firstElementChild.removeAttribute("contenteditable");
|
topElement.firstElementChild.removeAttribute("contenteditable");
|
||||||
topElement.remove();
|
topElement.remove();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue