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

Vanessa1f99efc83b29
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index c4a70e2afb..b2265da451 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -40,7 +40,11 @@ export const readText = () => {
};
export const readClipboard = async () => {
- const text = {textPlain: "", textHTML: ""};
+ const text: {
+ textHTML?: string,
+ textPlain?: string,
+ files?: File,
+ } = {textPlain: "", textHTML: ""};
if (isInAndroid()) {
text.textPlain = window.JSAndroid.readClipboard();
} else if (isInHarmony()) {
@@ -56,6 +60,10 @@ export const readClipboard = async () => {
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()});
+ }
}
return text;
};
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts
index 218aff5a14..9fd49f86cf 100644
--- a/app/src/protyle/util/paste.ts
+++ b/app/src/protyle/util/paste.ts
@@ -255,6 +255,7 @@ const readLocalFile = async (protyle: IProtyle, localFiles: string[]) => {
export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvent | {
textHTML?: string,
textPlain?: string,
+ files?: FileList,
}) & {
target: HTMLElement
}) => {
@@ -281,6 +282,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
} else {
textHTML = event.textHTML;
textPlain = event.textPlain;
+ files = event.files;
}
// Improve the pasting of selected text in PDF rectangular annotation https://github.com/siyuan-note/siyuan/issues/11629