mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 23:50:13 +01:00
This commit is contained in:
parent
6f39028d24
commit
9eee5020ad
2 changed files with 27 additions and 0 deletions
|
|
@ -173,6 +173,7 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
||||||
previousID: topSourceElement.previousElementSibling?.getAttribute("data-node-id"),
|
previousID: topSourceElement.previousElementSibling?.getAttribute("data-node-id"),
|
||||||
parentID: topSourceElement.parentElement?.getAttribute("data-node-id") || protyle.block.parentID || protyle.block.rootID
|
parentID: topSourceElement.parentElement?.getAttribute("data-node-id") || protyle.block.parentID || protyle.block.rootID
|
||||||
});
|
});
|
||||||
|
const topSourceParentElement = topSourceElement.parentElement;
|
||||||
topSourceElement.remove();
|
topSourceElement.remove();
|
||||||
if (!isSameDoc) {
|
if (!isSameDoc) {
|
||||||
// 打开两个相同的文档
|
// 打开两个相同的文档
|
||||||
|
|
@ -181,6 +182,28 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
||||||
sameElement.remove();
|
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) {
|
} else if (oldSourceParentElement.classList.contains("sb") && oldSourceParentElement.childElementCount === 2) {
|
||||||
// 拖拽后,sb 只剩下一个元素
|
// 拖拽后,sb 只剩下一个元素
|
||||||
if (isSameDoc) {
|
if (isSameDoc) {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,10 @@ export const updateListOrder = (listElement: Element, sIndex?: number) => {
|
||||||
}
|
}
|
||||||
let starIndex: number;
|
let starIndex: number;
|
||||||
Array.from(listElement.children).forEach((item, index) => {
|
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 (index === 0) {
|
||||||
if (sIndex) {
|
if (sIndex) {
|
||||||
starIndex = sIndex;
|
starIndex = sIndex;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue