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/14218

Vanessa5753de5b1305
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index 64fc5f7271..1a5cbced0d 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -45,12 +45,6 @@ export const readClipboard = async () => {
textPlain?: string,
files?: File[],
} = {textPlain: "", textHTML: ""};
- if (isInAndroid()) {
- text.textPlain = window.JSAndroid.readClipboard();
- } else if (isInHarmony()) {
- text.textPlain = window.JSHarmony.readClipboard();
- }
-
try {
const clipboardContents = await navigator.clipboard.read();
for (const item of clipboardContents) {
@@ -67,9 +61,17 @@ export const readClipboard = async () => {
text.files = [new File([blob], "image.png", {type: "image/png", lastModified: Date.now()})];
}
}
+ return text;
} catch (e) {
+ if (isInAndroid()) {
+ text.textPlain = window.JSAndroid.readClipboard();
+ text.textHTML = window.JSAndroid.readHTMLClipboard();
+ } else if (isInHarmony()) {
+ text.textPlain = window.JSHarmony.readClipboard();
+ text.textHTML = window.JSHarmony.readHTMLClipboard();
+ }
+ return text;
}
- return text;
};
export const writeText = (text: string) => {
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 9d1b73096d..6970314ef2 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -191,6 +191,7 @@ interface Window {
writeHTMLClipboard(text: string, html: string): void
writeImageClipboard(uri: string): void
readClipboard(): string
+ readHTMLClipboard(): string
getBlockURL(): string
}
JSHarmony: {
@@ -199,6 +200,7 @@ interface Window {
writeClipboard(text: string): void
writeHTMLClipboard(text: string, html: string): void
readClipboard(): string
+ readHTMLClipboard(): string
returnDesktop(): void
}