Vanessa 2025-10-18 22:05:52 +08:00
parent 8d8f55e49a
commit 2c23d05c7c

View file

@ -258,9 +258,10 @@ export const duplicateBlock = async (nodeElements: Element[], protyle: IProtyle)
const doOperations: IOperation[] = []; const doOperations: IOperation[] = [];
const undoOperations: IOperation[] = []; const undoOperations: IOperation[] = [];
let starIndex: number; let starIndex: number;
if (nodeElements[nodeElements.length - 1].classList.contains("li") && const lastElement = nodeElements[nodeElements.length - 1];
nodeElements[nodeElements.length - 1].getAttribute("data-subtype") === "o") { if (lastElement.classList.contains("li") &&
starIndex = parseInt(nodeElements[nodeElements.length - 1].getAttribute("data-marker"), 10); lastElement.getAttribute("data-subtype") === "o") {
starIndex = parseInt(lastElement.getAttribute("data-marker"), 10);
} }
const foldHeadingIds = []; const foldHeadingIds = [];
for (let index = nodeElements.length - 1; index >= 0; --index) { for (let index = nodeElements.length - 1; index >= 0; --index) {
@ -299,12 +300,12 @@ export const duplicateBlock = async (nodeElements: Element[], protyle: IProtyle)
tempElement.setAttribute("data-marker", (orderIndex) + "."); tempElement.setAttribute("data-marker", (orderIndex) + ".");
tempElement.querySelector(".protyle-action--order").textContent = (orderIndex) + "."; tempElement.querySelector(".protyle-action--order").textContent = (orderIndex) + ".";
} }
nodeElements[0].after(processClonePHElement(tempElement)); lastElement.after(processClonePHElement(tempElement));
doOperations.push({ doOperations.push({
action: "insert", action: "insert",
data: tempElement.outerHTML, data: tempElement.outerHTML,
id: newId, id: newId,
previousID: nodeElements[0].getAttribute("data-node-id"), previousID: lastElement.getAttribute("data-node-id"),
}); });
undoOperations.push({ undoOperations.push({
action: "delete", action: "delete",