Vanessa 2025-11-11 22:24:57 +08:00
parent 6f39028d24
commit 9eee5020ad
2 changed files with 27 additions and 0 deletions

View file

@ -173,6 +173,7 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
previousID: topSourceElement.previousElementSibling?.getAttribute("data-node-id"),
parentID: topSourceElement.parentElement?.getAttribute("data-node-id") || protyle.block.parentID || protyle.block.rootID
});
const topSourceParentElement = topSourceElement.parentElement;
topSourceElement.remove();
if (!isSameDoc) {
// 打开两个相同的文档
@ -181,6 +182,28 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
sameElement.remove();
}
}
if (topSourceParentElement.classList.contains("sb") && topSourceParentElement.childElementCount === 2) {
// 拖拽后sb 只剩下一个元素
if (isSameDoc) {
const sbData = await cancelSB(protyle, topSourceParentElement);
doOperations.push(sbData.doOperations[0], sbData.doOperations[1]);
undoOperations.push(sbData.undoOperations[1], sbData.undoOperations[0]);
} else {
/// #if !MOBILE
const allEditor = getAllEditor();
for (let i = 0; i < allEditor.length; i++) {
if (allEditor[i].protyle.element.contains(topSourceParentElement)) {
const otherSbData = await cancelSB(allEditor[i].protyle, topSourceParentElement);
doOperations.push(otherSbData.doOperations[0], otherSbData.doOperations[1]);
undoOperations.push(otherSbData.undoOperations[1], otherSbData.undoOperations[0]);
// 需清空操作栈,否则撤销到移动出去的块的操作会抛异常
allEditor[i].protyle.undo.clear();
break;
}
}
/// #endif
}
}
} else if (oldSourceParentElement.classList.contains("sb") && oldSourceParentElement.childElementCount === 2) {
// 拖拽后sb 只剩下一个元素
if (isSameDoc) {

View file

@ -13,6 +13,10 @@ export const updateListOrder = (listElement: Element, sIndex?: number) => {
}
let starIndex: number;
Array.from(listElement.children).forEach((item, index) => {
// https://github.com/siyuan-note/siyuan/issues/16315 第三点会有为空的情况
if (!item.classList.contains("li")) {
return;
}
if (index === 0) {
if (sIndex) {
starIndex = sIndex;