Skip to content

Commit

Permalink
🎨 #12792
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Oct 16, 2024
1 parent 93503e3 commit 054263d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/src/protyle/util/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ export const setLastNodeRange = (editElement: Element, range: Range, setStart =
// 防止单元格中 ⇧↓ 全部选中
return range;
}
// https://github.com/siyuan-note/siyuan/issues/12792
if (!lastNode.lastChild) {
break;
}
// 最后一个为多种行内元素嵌套
lastNode = lastNode.lastChild as Element;
}
Expand All @@ -322,9 +326,17 @@ export const setLastNodeRange = (editElement: Element, range: Range, setStart =
lastNode = editElement;
}
if (setStart) {
range.setStart(lastNode, lastNode.textContent.length);
if (lastNode.nodeType !== 3 && lastNode.classList.contains("render-node") && lastNode.innerHTML === "") {
range.setStartAfter(lastNode);
} else {
range.setStart(lastNode, lastNode.textContent.length);
}
} else {
range.setEnd(lastNode, lastNode.textContent.length);
if (lastNode.nodeType !== 3 && lastNode.classList.contains("render-node") && lastNode.innerHTML === "") {
range.setStartAfter(lastNode);
} else {
range.setEnd(lastNode, lastNode.textContent.length);
}
}
return range;
};
Expand Down

0 comments on commit 054263d

Please sign in to comment.