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 1

Vanessaa4da24116825
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index 1a7193ed65..5db2200fa1 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -284,6 +284,18 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElement: Element, isBottom: boolean,
direct: "col" | "row", isCopy: boolean) => {
const isSameDoc = protyle.element.contains(sourceElements[0]);
+ // 把列表块中的唯一一个列表项块拖拽到列表块的左侧 https://github.com/siyuan-note/siyuan/issues/16315
+ if (isSameDoc && sourceElements[0].classList.contains("li") && targetElement === sourceElements[0].parentElement &&
+ targetElement.childElementCount === sourceElements.length + 1) {
+ const outLiElement = sourceElements.find((element) => {
+ if (!targetElement.contains(element)) {
+ return true;
+ }
+ });
+ if (!outLiElement) {
+ return;
+ }
+ }
const undoOperations: IOperation[] = [];
const targetMoveUndo: IOperation = {
action: "move",
diff --git a/app/src/protyle/wysiwyg/getBlock.ts b/app/src/protyle/wysiwyg/getBlock.ts
index 5985ccd699..f445dfcb54 100644
--- a/app/src/protyle/wysiwyg/getBlock.ts
+++ b/app/src/protyle/wysiwyg/getBlock.ts
@@ -118,7 +118,7 @@ export const getTopEmptyElement = (element: Element) => {
export const getTopAloneElement = (topSourceElement: Element) => {
if ("NodeBlockquote" === topSourceElement.parentElement.getAttribute("data-type") && topSourceElement.parentElement.childElementCount === 2) {
- while (!topSourceElement.parentElement.classList.contains("protyle-wysiwyg")) {
+ while (topSourceElement.parentElement && !topSourceElement.parentElement.classList.contains("protyle-wysiwyg")) {
if (topSourceElement.parentElement.getAttribute("data-type") === "NodeBlockquote" && topSourceElement.parentElement.childElementCount === 2) {
topSourceElement = topSourceElement.parentElement;
} else {
@@ -127,7 +127,7 @@ export const getTopAloneElement = (topSourceElement: Element) => {
}
}
} else if ("NodeSuperBlock" === topSourceElement.parentElement.getAttribute("data-type") && topSourceElement.parentElement.childElementCount === 2) {
- while (!topSourceElement.parentElement.classList.contains("protyle-wysiwyg")) {
+ while (topSourceElement.parentElement && !topSourceElement.parentElement.classList.contains("protyle-wysiwyg")) {
if (topSourceElement.parentElement.getAttribute("data-type") === "NodeSuperBlock" && topSourceElement.parentElement.childElementCount === 2) {
topSourceElement = topSourceElement.parentElement;
} else {
@@ -136,7 +136,7 @@ export const getTopAloneElement = (topSourceElement: Element) => {
}
}
} else if ("NodeListItem" === topSourceElement.parentElement.getAttribute("data-type") && topSourceElement.parentElement.childElementCount === 3) {
- while (!topSourceElement.parentElement.classList.contains("protyle-wysiwyg")) {
+ while (topSourceElement.parentElement && !topSourceElement.parentElement.classList.contains("protyle-wysiwyg")) {
if (topSourceElement.parentElement.getAttribute("data-type") === "NodeListItem" && topSourceElement.parentElement.childElementCount === 3) {
topSourceElement = topSourceElement.parentElement;
} else if (topSourceElement.parentElement.getAttribute("data-type") === "NodeList" && topSourceElement.parentElement.childElementCount === 2) {
@@ -147,7 +147,7 @@ export const getTopAloneElement = (topSourceElement: Element) => {
}
}
} else if ("NodeList" === topSourceElement.parentElement.getAttribute("data-type") && topSourceElement.parentElement.childElementCount === 2) {
- while (!topSourceElement.parentElement.classList.contains("protyle-wysiwyg")) {
+ while (topSourceElement.parentElement && !topSourceElement.parentElement.classList.contains("protyle-wysiwyg")) {
if ("NodeList" === topSourceElement.parentElement.getAttribute("data-type") && topSourceElement.parentElement.childElementCount === 2) {
topSourceElement = topSourceElement.parentElement;
} else if (topSourceElement.parentElement.getAttribute("data-type") === "NodeListItem" && topSourceElement.parentElement.childElementCount === 3) {