Skip to content

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

:bug: 空块无法 focus

Vanessa17d0557bad55
diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts
index 86e6ad7ef4..0ac2efeb07 100644
--- a/app/src/protyle/util/selection.ts
+++ b/app/src/protyle/util/selection.ts
@@ -280,10 +280,15 @@ export const setFirstNodeRange = (editElement: Element, range: Range) => {
return range;
};
-export const focusByOffset = (container: Node, start: number, end: number) => {
+export const focusByOffset = (container: Element, start: number, end: number) => {
if (!container) {
return false;
}
+ // 空块无法 focus
+ const editElement = getContenteditableElement(container);
+ if (editElement) {
+ container = editElement;
+ }
let startNode;
searchNode(container, container.firstChild, node => {
if (node.nodeType === Node.TEXT_NODE) {