🐛 遇到 br 时全选
This commit is contained in:
parent
0da5bb7e71
commit
b1dcfe6845
1 changed files with 6 additions and 5 deletions
|
@ -52,21 +52,22 @@ export const selectAll = (protyle: IProtyle, nodeElement: Element, range: Range)
|
|||
firstChild = firstChild.firstChild;
|
||||
}
|
||||
}
|
||||
let lastChild = editElement.lastChild;
|
||||
let lastChild = editElement.lastChild as HTMLElement;
|
||||
while (lastChild) {
|
||||
if (lastChild.nodeType === 3) {
|
||||
if (lastChild.textContent !== "") {
|
||||
range.setEnd(lastChild, lastChild.textContent.length);
|
||||
break;
|
||||
}
|
||||
lastChild = lastChild.previousSibling;
|
||||
lastChild = lastChild.previousSibling as HTMLElement;
|
||||
} else {
|
||||
if ((lastChild as HTMLElement).classList.contains("render-node") ||
|
||||
(lastChild as HTMLElement).classList.contains("img")) {
|
||||
if (lastChild.classList.contains("render-node") ||
|
||||
lastChild.classList.contains("img") ||
|
||||
lastChild.tagName === "BR") {
|
||||
range.setEndAfter(lastChild);
|
||||
break;
|
||||
}
|
||||
lastChild = lastChild.lastChild;
|
||||
lastChild = lastChild.lastChild as HTMLElement;
|
||||
}
|
||||
}
|
||||
protyle.toolbar.render(protyle, range);
|
||||
|
|
Loading…
Add table
Reference in a new issue