Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: 遇到 br 时全选

Vanessab1dcfe68451c
diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts
index 30ef60014c..aafc0e0a14 100644
--- a/app/src/protyle/util/selection.ts
+++ b/app/src/protyle/util/selection.ts
@@ -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);