Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2025-02-28 12:22:23 +08:00
commit d26b46478a

View File

@ -50,23 +50,24 @@ export const readClipboard = async () => {
} else if (isInHarmony()) { } else if (isInHarmony()) {
text.textPlain = window.JSHarmony.readClipboard(); text.textPlain = window.JSHarmony.readClipboard();
} }
if (typeof navigator.clipboard === "undefined" || !navigator.clipboard.read) {
return text; try {
} const clipboardContents = await navigator.clipboard.read();
const clipboardContents = await navigator.clipboard.read(); for (const item of clipboardContents) {
for (const item of clipboardContents) { if (item.types.includes("text/html")) {
if (item.types.includes("text/html")) { const blob = await item.getType("text/html");
const blob = await item.getType("text/html"); text.textHTML = await blob.text();
text.textHTML = await blob.text(); }
} if (item.types.includes("text/plain")) {
if (item.types.includes("text/plain")) { const blob = await item.getType("text/plain");
const blob = await item.getType("text/plain"); text.textPlain = await blob.text();
text.textPlain = await blob.text(); }
} if (item.types.includes("image/png")) {
if (item.types.includes("image/png")) { const blob = await item.getType("image/png");
const blob = await item.getType("image/png"); text.files = [new File([blob], "image.png", {type: "image/png", lastModified: Date.now()})];
text.files = [new File([blob], "image.png", {type: "image/png", lastModified: Date.now()})]; }
} }
} catch (e) {
} }
return text; return text;
}; };