mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
a543ec97a5
commit
20bc84c542
1 changed files with 6 additions and 5 deletions
|
|
@ -26,10 +26,8 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
||||||
const undoOperations: IOperation[] = []
|
const undoOperations: IOperation[] = []
|
||||||
const foldHeadingIds: { id: string, parentID: string }[] = []
|
const foldHeadingIds: { id: string, parentID: string }[] = []
|
||||||
const targetId = targetElement.getAttribute("data-node-id")
|
const targetId = targetElement.getAttribute("data-node-id")
|
||||||
if (position === "afterend") {
|
let tempTargetElement = targetElement
|
||||||
sourceElements.reverse();
|
sourceElements.reverse().forEach((item, index) => {
|
||||||
}
|
|
||||||
sourceElements.forEach((item, index) => {
|
|
||||||
const id = item.getAttribute("data-node-id");
|
const id = item.getAttribute("data-node-id");
|
||||||
const parentID = item.parentElement.getAttribute("data-node-id") || protyle.block.rootID
|
const parentID = item.parentElement.getAttribute("data-node-id") || protyle.block.rootID
|
||||||
if (index === sourceElements.length - 1) {
|
if (index === sourceElements.length - 1) {
|
||||||
|
|
@ -58,13 +56,16 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
||||||
sameElement.remove();
|
sameElement.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
targetElement.insertAdjacentElement(position, item);
|
tempTargetElement.insertAdjacentElement(position, item);
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
action: "move",
|
action: "move",
|
||||||
id,
|
id,
|
||||||
previousID: position === "afterend" ? targetId : item.previousElementSibling?.getAttribute("data-node-id"), // 不能使用常量,移动后会被修改
|
previousID: position === "afterend" ? targetId : item.previousElementSibling?.getAttribute("data-node-id"), // 不能使用常量,移动后会被修改
|
||||||
parentID: item.parentElement?.getAttribute("data-node-id") || protyle.block.parentID || protyle.block.rootID,
|
parentID: item.parentElement?.getAttribute("data-node-id") || protyle.block.parentID || protyle.block.rootID,
|
||||||
});
|
});
|
||||||
|
if (position !== "afterend") {
|
||||||
|
tempTargetElement = item;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
undoOperations.reverse();
|
undoOperations.reverse();
|
||||||
for (let j = 0; j < foldHeadingIds.length; j++) {
|
for (let j = 0; j < foldHeadingIds.length; j++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue