Vanessa 2025-11-11 22:01:07 +08:00
parent 27030446f6
commit a4da241168
2 changed files with 16 additions and 4 deletions

View file

@ -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",

View file

@ -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) {