Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/17821

Vanessa470d587a2048
diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts
index ea5e5d434d..6945a2d659 100644
--- a/app/src/protyle/util/selection.ts
+++ b/app/src/protyle/util/selection.ts
@@ -505,6 +505,14 @@ export const focusByOffset = (container: Element, start: number, end: number, is
}
end -= dataLength;
return false;
+ } else if (node.nodeType === Node.ELEMENT_NODE &&
+ ((node as Element).tagName === "BR" || (node as Element).classList.contains("emoji"))) {
+ if (end <= 1) {
+ endNode = node;
+ return true;
+ }
+ end -= 1;
+ return false;
}
});
}
@@ -528,7 +536,7 @@ export const focusByOffset = (container: Element, start: number, end: number, is
range.collapse(true);
} else {
if (endNode) {
- if (startNode.nodeType === Node.TEXT_NODE && end <= (endNode as Text).data.length) {
+ if (endNode.nodeType === Node.TEXT_NODE && end <= (endNode as Text).data.length) {
range.setEnd(endNode, end);
} else {
range.setEndAfter(endNode);