Skip to content

Commit

Permalink
🎨 #13016
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Nov 22, 2024
1 parent ab8f2b7 commit c6e816e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/src/protyle/wysiwyg/enter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,13 @@ const listEnter = (protyle: IProtyle, blockElement: HTMLElement, range: Range) =
newElement = genListItemElement(listItemElement, 0, false);
const newEditElement = getContenteditableElement(newElement);
newEditElement.appendChild(range.extractContents());
newEditElement.parentElement.after(subListElement);
let subListNextElement = subListElement.nextElementSibling;
newElement.lastElementChild.before(subListElement);
// https://github.com/siyuan-note/siyuan/issues/13016
while (!subListNextElement.classList.contains("protyle-attr")) {
subListNextElement = subListNextElement.nextElementSibling;
newElement.lastElementChild.before(subListNextElement.previousElementSibling);
}
listItemElement.insertAdjacentElement("afterend", newElement);
if (listItemElement.getAttribute("data-subtype") === "o") {
updateListOrder(listItemElement.parentElement);
Expand Down Expand Up @@ -455,7 +461,7 @@ const listEnter = (protyle: IProtyle, blockElement: HTMLElement, range: Range) =
}
range.insertNode(document.createElement("wbr"));
const listItemHTML = listItemElement.outerHTML;
const html = listItemElement.parentElement.outerHTML;
const oldHTML = listItemElement.parentElement.outerHTML;
if (range.toString() !== "") {
// 选中数学公式后回车取消选中 https://github.com/siyuan-note/siyuan/issues/12637#issuecomment-2381106949
const mathElement = hasClosestByAttribute(range.startContainer, "data-type", "inline-math");
Expand Down Expand Up @@ -513,7 +519,7 @@ const listEnter = (protyle: IProtyle, blockElement: HTMLElement, range: Range) =
data: listItemHTML
}]);
} else {
updateTransaction(protyle, listItemElement.parentElement.getAttribute("data-node-id"), listItemElement.parentElement.outerHTML, html);
updateTransaction(protyle, listItemElement.parentElement.getAttribute("data-node-id"), listItemElement.parentElement.outerHTML, oldHTML);
}
focusByWbr(newElement, range);
scrollCenter(protyle);
Expand Down

0 comments on commit c6e816e

Please sign in to comment.