mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 19:59:08 +08:00
🐛 Cannot long press to paste on mobile devices https://github.com/siyuan-note/siyuan/issues/14218
This commit is contained in:
parent
19a37f19a3
commit
c34d002b87
@ -50,23 +50,24 @@ export const readClipboard = async () => {
|
||||
} else if (isInHarmony()) {
|
||||
text.textPlain = window.JSHarmony.readClipboard();
|
||||
}
|
||||
if (typeof navigator.clipboard === "undefined" || !navigator.clipboard.read) {
|
||||
return text;
|
||||
}
|
||||
const clipboardContents = await navigator.clipboard.read();
|
||||
for (const item of clipboardContents) {
|
||||
if (item.types.includes("text/html")) {
|
||||
const blob = await item.getType("text/html");
|
||||
text.textHTML = await blob.text();
|
||||
}
|
||||
if (item.types.includes("text/plain")) {
|
||||
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()})];
|
||||
|
||||
try {
|
||||
const clipboardContents = await navigator.clipboard.read();
|
||||
for (const item of clipboardContents) {
|
||||
if (item.types.includes("text/html")) {
|
||||
const blob = await item.getType("text/html");
|
||||
text.textHTML = await blob.text();
|
||||
}
|
||||
if (item.types.includes("text/plain")) {
|
||||
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()})];
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user