mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-22 00:06:09 +01:00
This commit is contained in:
parent
8e42b15db3
commit
ac9f8b8680
1 changed files with 35 additions and 12 deletions
|
|
@ -300,7 +300,7 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range:
|
|||
if (!liItemElements[0].previousElementSibling && liElement.getAttribute("data-subtype") === "o") {
|
||||
startIndex = parseInt(liItemElements[0].getAttribute("data-marker"));
|
||||
}
|
||||
let previousID = liId;
|
||||
let topPreviousID = liId;
|
||||
let previousElement: Element = liElement;
|
||||
let nextElement = liItemElements[liItemElements.length - 1].nextElementSibling;
|
||||
let lastBlockElement = liItemElements[liItemElements.length - 1].lastElementChild.previousElementSibling;
|
||||
|
|
@ -316,17 +316,17 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range:
|
|||
doOperations.push({
|
||||
action: "move",
|
||||
id,
|
||||
previousID,
|
||||
previousID: topPreviousID,
|
||||
parentID: parentLiItemElement.getAttribute("data-node-id") || protyle.block.parentID
|
||||
});
|
||||
undoOperations.push({
|
||||
action: "move",
|
||||
id,
|
||||
previousID: index === 1 ? undefined : previousID,
|
||||
previousID: index === 1 ? undefined : topPreviousID,
|
||||
parentID: item.getAttribute("data-node-id"),
|
||||
data: blockElement.contains(range.startContainer) ? "focus" : "" // 标记需要 focus,https://ld246.com/article/1650018446988/comment/1650081404993?r=Vanessa#comments
|
||||
});
|
||||
previousID = id;
|
||||
topPreviousID = id;
|
||||
previousElement.after(blockElement);
|
||||
previousElement = blockElement;
|
||||
});
|
||||
|
|
@ -351,21 +351,21 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range:
|
|||
previousID: previousElement.getAttribute("data-node-id"),
|
||||
});
|
||||
}
|
||||
let previousID;
|
||||
let topOldPreviousID;
|
||||
while (nextElement && !nextElement.classList.contains("protyle-attr")) {
|
||||
doOperations.push({
|
||||
action: "move",
|
||||
id: nextElement.getAttribute("data-node-id"),
|
||||
previousID: previousID || lastBlockElement.lastElementChild.previousElementSibling?.getAttribute("data-node-id"),
|
||||
previousID: topOldPreviousID || lastBlockElement.lastElementChild.previousElementSibling?.getAttribute("data-node-id"),
|
||||
parentID: lastBlockElement.getAttribute("data-node-id")
|
||||
});
|
||||
undoOperations.push({
|
||||
action: "move",
|
||||
id: nextElement.getAttribute("data-node-id"),
|
||||
parentID: lastBlockElement.getAttribute("data-node-id"),
|
||||
previousID: previousID || nextElement.previousElementSibling?.getAttribute("data-node-id"),
|
||||
previousID: topOldPreviousID || nextElement.previousElementSibling?.getAttribute("data-node-id"),
|
||||
});
|
||||
previousID = nextElement.getAttribute("data-node-id");
|
||||
topOldPreviousID = nextElement.getAttribute("data-node-id");
|
||||
const tempElement = nextElement;
|
||||
nextElement = nextElement.nextElementSibling;
|
||||
lastBlockElement.lastElementChild.before(tempElement);
|
||||
|
|
@ -554,7 +554,7 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range:
|
|||
});
|
||||
liItemElements[0].lastElementChild.before(lastBlockElement);
|
||||
}
|
||||
let previousID;
|
||||
let subPreviousID;
|
||||
while (nextElement && !nextElement.classList.contains("protyle-attr")) {
|
||||
const nextId = nextElement.getAttribute("data-node-id");
|
||||
if (nextElement.getAttribute("data-subtype") !== lastBlockElement.getAttribute("data-subtype")) {
|
||||
|
|
@ -575,15 +575,15 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range:
|
|||
doOperations.push({
|
||||
action: "move",
|
||||
id: nextId,
|
||||
previousID: previousID || lastBlockElement.lastElementChild.previousElementSibling?.getAttribute("data-node-id"),
|
||||
previousID: subPreviousID || lastBlockElement.lastElementChild.previousElementSibling?.getAttribute("data-node-id"),
|
||||
parentID: lastBlockElement.getAttribute("data-node-id")
|
||||
});
|
||||
undoOperations.push({
|
||||
action: "move",
|
||||
id: nextId,
|
||||
previousID: previousID || lastBlockElement.parentElement?.getAttribute("data-node-id"),
|
||||
previousID: subPreviousID || lastBlockElement.parentElement?.getAttribute("data-node-id"),
|
||||
});
|
||||
previousID = nextId;
|
||||
subPreviousID = nextId;
|
||||
const tempElement = nextElement;
|
||||
nextElement = nextElement.nextElementSibling;
|
||||
lastBlockElement.lastElementChild.before(tempElement);
|
||||
|
|
@ -618,6 +618,29 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range:
|
|||
});
|
||||
}
|
||||
}
|
||||
if (!window.siyuan.config.editor.listLogicalOutdent && liElement.nextElementSibling) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/9226
|
||||
nextElement = liElement.nextElementSibling;
|
||||
let subBlockPreviousID;
|
||||
while (nextElement && !nextElement.classList.contains("protyle-attr")) {
|
||||
const nextId = nextElement.getAttribute("data-node-id");
|
||||
doOperations.push({
|
||||
action: "move",
|
||||
id: nextId,
|
||||
previousID: subBlockPreviousID || lastBlockElement.getAttribute("data-node-id"),
|
||||
});
|
||||
undoOperations.push({
|
||||
action: "move",
|
||||
id: nextId,
|
||||
previousID: subBlockPreviousID || liElement.getAttribute("data-node-id"),
|
||||
});
|
||||
subBlockPreviousID = nextId;
|
||||
const tempElement = nextElement;
|
||||
nextElement = nextElement.nextElementSibling;
|
||||
lastBlockElement.after(tempElement);
|
||||
lastBlockElement = tempElement;
|
||||
}
|
||||
}
|
||||
if (liElement.childElementCount === 1 && parentLiItemElement.childElementCount === 3) {
|
||||
// https://ld246.com/article/1691981936960
|
||||
doOperations.push({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue