mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
This commit is contained in:
parent
d26b46478a
commit
5753de5b13
2 changed files with 11 additions and 7 deletions
|
|
@ -45,12 +45,6 @@ export const readClipboard = async () => {
|
|||
textPlain?: string,
|
||||
files?: File[],
|
||||
} = {textPlain: "", textHTML: ""};
|
||||
if (isInAndroid()) {
|
||||
text.textPlain = window.JSAndroid.readClipboard();
|
||||
} else if (isInHarmony()) {
|
||||
text.textPlain = window.JSHarmony.readClipboard();
|
||||
}
|
||||
|
||||
try {
|
||||
const clipboardContents = await navigator.clipboard.read();
|
||||
for (const item of clipboardContents) {
|
||||
|
|
@ -67,9 +61,17 @@ export const readClipboard = async () => {
|
|||
text.files = [new File([blob], "image.png", {type: "image/png", lastModified: Date.now()})];
|
||||
}
|
||||
}
|
||||
return text;
|
||||
} catch (e) {
|
||||
if (isInAndroid()) {
|
||||
text.textPlain = window.JSAndroid.readClipboard();
|
||||
text.textHTML = window.JSAndroid.readHTMLClipboard();
|
||||
} else if (isInHarmony()) {
|
||||
text.textPlain = window.JSHarmony.readClipboard();
|
||||
text.textHTML = window.JSHarmony.readHTMLClipboard();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
export const writeText = (text: string) => {
|
||||
|
|
|
|||
2
app/src/types/index.d.ts
vendored
2
app/src/types/index.d.ts
vendored
|
|
@ -191,6 +191,7 @@ interface Window {
|
|||
writeHTMLClipboard(text: string, html: string): void
|
||||
writeImageClipboard(uri: string): void
|
||||
readClipboard(): string
|
||||
readHTMLClipboard(): string
|
||||
getBlockURL(): string
|
||||
}
|
||||
JSHarmony: {
|
||||
|
|
@ -199,6 +200,7 @@ interface Window {
|
|||
writeClipboard(text: string): void
|
||||
writeHTMLClipboard(text: string, html: string): void
|
||||
readClipboard(): string
|
||||
readHTMLClipboard(): string
|
||||
returnDesktop(): void
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue