Vanessa 2025-02-19 16:01:57 +08:00
parent 5bb03482df
commit 1f99efc83b
2 changed files with 11 additions and 1 deletions

View file

@ -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;
};

View file

@ -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