diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts index c4a70e2af..b2265da45 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 218aff5a1..9fd49f86c 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