diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 1a7193ed6..5db2200fa 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 5985ccd69..f445dfcb5 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) {