Skip to content

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

:bug: Cannot long press to paste on mobile devices https://github.com/siyuan-note/siyuan/issues/14218

Danielc34d002b8761
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index 7a52d62b53..64fc5f7271 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -50,23 +50,24 @@ export const readClipboard = async () => {
} else if (isInHarmony()) {
text.textPlain = window.JSHarmony.readClipboard();
}
- if (typeof navigator.clipboard === "undefined" || !navigator.clipboard.read) {
- return text;
- }
- const clipboardContents = await navigator.clipboard.read();
- for (const item of clipboardContents) {
- if (item.types.includes("text/html")) {
- const blob = await item.getType("text/html");
- text.textHTML = await blob.text();
- }
- if (item.types.includes("text/plain")) {
- const blob = await item.getType("text/plain");
- text.textPlain = await blob.text();
- }
- if (item.types.includes("image/png")) {
- const blob = await item.getType("image/png");
- text.files = [new File([blob], "image.png", {type: "image/png", lastModified: Date.now()})];
+
+ try {
+ const clipboardContents = await navigator.clipboard.read();
+ for (const item of clipboardContents) {
+ if (item.types.includes("text/html")) {
+ const blob = await item.getType("text/html");
+ text.textHTML = await blob.text();
+ }
+ if (item.types.includes("text/plain")) {
+ const blob = await item.getType("text/plain");
+ text.textPlain = await blob.text();
+ }
+ if (item.types.includes("image/png")) {
+ const blob = await item.getType("image/png");
+ text.files = [new File([blob], "image.png", {type: "image/png", lastModified: Date.now()})];
+ }
}
+ } catch (e) {
}
return text;
};