Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: https://github.com/siyuan-note/siyuan/issues/16315 3

Vanessa9eee5020ad3e
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index 3ce216b7d2..4a67fb890e 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -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) {
diff --git a/app/src/protyle/wysiwyg/list.ts b/app/src/protyle/wysiwyg/list.ts
index 3ff5beb8e4..9141799165 100644
--- a/app/src/protyle/wysiwyg/list.ts
+++ b/app/src/protyle/wysiwyg/list.ts
@@ -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;