mirror of
https://github.com/TommyFang2077/dsh-desktop.git
synced 2026-08-17 09:06:36 +08:00
fix: do not cancel HTML or text paste when no image is in the event
Empty text/plain used to preventDefault before native clipboard read, which discarded HTML-only paste if no image was recovered. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -186,10 +186,15 @@
|
||||
const local = fromEvent ? fromEvent(e) : [];
|
||||
const text = clipboardText(e, "text/plain");
|
||||
const uris = clipboardText(e, "text/uri-list");
|
||||
const steal = local.length > 0
|
||||
|| (pathLike && (pathLike(text) || pathLike(uris)))
|
||||
|| !String(text).trim();
|
||||
if (!steal) return;
|
||||
const html = clipboardText(e, "text/html");
|
||||
const imagePath = Boolean(pathLike && (pathLike(text) || pathLike(uris)));
|
||||
const hasText = Boolean(String(text).trim() || String(html).trim());
|
||||
// Image files in the event, or a pasted image path, are ours. Empty
|
||||
// payload is the Linux case where the image is only on the native
|
||||
// clipboard. Non-empty text/html must reach the page — do not cancel
|
||||
// first and then fail to recover an image.
|
||||
if (!local.length && !imagePath && hasText) return;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
window.__dshDesktopIngesting = true;
|
||||
|
||||
Reference in New Issue
Block a user