Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/6060

Vanessae795fdc20af8
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index 3b821184d2..24d752bc10 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -1,3 +1,5 @@
+import {focusByRange} from "./selection";
+
export const openByMobile = (uri: string) => {
if (!uri) {
return;
@@ -12,6 +14,10 @@ export const openByMobile = (uri: string) => {
};
export const writeText = async (text: string) => {
+ let range: Range
+ if (getSelection().rangeCount > 0) {
+ range = getSelection().getRangeAt(0).cloneRange();
+ }
try {
// navigator.clipboard.writeText 抛出异常不进入 catch,这里需要先处理移动端复制
if ("android" === window.siyuan.config.system.container && window.JSAndroid) {
@@ -38,6 +44,9 @@ export const writeText = async (text: string) => {
textElement.select();
document.execCommand("copy");
document.body.removeChild(textElement);
+ if (range) {
+ focusByRange(range);
+ }
}
}
};