mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-03 23:38:49 +01:00
This commit is contained in:
parent
5bb03482df
commit
1f99efc83b
2 changed files with 11 additions and 1 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue