Skip to content

Commit 2c23d05

Browse files
committed
🎨 #16146
1 parent 8d8f55e commit 2c23d05

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

app/src/protyle/wysiwyg/commonHotkey.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,10 @@ export const duplicateBlock = async (nodeElements: Element[], protyle: IProtyle)
258258
const doOperations: IOperation[] = [];
259259
const undoOperations: IOperation[] = [];
260260
let starIndex: number;
261-
if (nodeElements[nodeElements.length - 1].classList.contains("li") &&
262-
nodeElements[nodeElements.length - 1].getAttribute("data-subtype") === "o") {
263-
starIndex = parseInt(nodeElements[nodeElements.length - 1].getAttribute("data-marker"), 10);
261+
const lastElement = nodeElements[nodeElements.length - 1];
262+
if (lastElement.classList.contains("li") &&
263+
lastElement.getAttribute("data-subtype") === "o") {
264+
starIndex = parseInt(lastElement.getAttribute("data-marker"), 10);
264265
}
265266
const foldHeadingIds = [];
266267
for (let index = nodeElements.length - 1; index >= 0; --index) {
@@ -299,12 +300,12 @@ export const duplicateBlock = async (nodeElements: Element[], protyle: IProtyle)
299300
tempElement.setAttribute("data-marker", (orderIndex) + ".");
300301
tempElement.querySelector(".protyle-action--order").textContent = (orderIndex) + ".";
301302
}
302-
nodeElements[0].after(processClonePHElement(tempElement));
303+
lastElement.after(processClonePHElement(tempElement));
303304
doOperations.push({
304305
action: "insert",
305306
data: tempElement.outerHTML,
306307
id: newId,
307-
previousID: nodeElements[0].getAttribute("data-node-id"),
308+
previousID: lastElement.getAttribute("data-node-id"),
308309
});
309310
undoOperations.push({
310311
action: "delete",

0 commit comments

Comments
 (0)