diff --git a/server/web/index.html b/server/web/index.html index 8ab65ae..b7b5410 100644 --- a/server/web/index.html +++ b/server/web/index.html @@ -204,8 +204,28 @@ // ── Send ────────────────────────────────────────────────────────────── $("pasteBtn").addEventListener("click", async () => { - try { $("out").value = await navigator.clipboard.readText(); status("pasted from clipboard", "ok"); } - catch (e) { status("clipboard read denied — paste manually", "err"); } + const ta = $("out"); + ta.focus(); + // Try a few strategies in order — iOS Safari is picky. + try { + const text = await navigator.clipboard.readText(); + if (text) { + ta.value = text; + ta.setSelectionRange(text.length, text.length); + status("pasted from clipboard ✓", "ok"); + return; + } + } catch (e) { /* fall through */ } + // Fallback: try execCommand paste while focused (deprecated but iOS still honors it) + try { + if (document.execCommand && document.execCommand("paste")) { + if (ta.value) { + status("pasted from clipboard ✓", "ok"); + return; + } + } + } catch (e) {} + status("clipboard read denied — long-press the box to paste", "err"); }); $("sendBtn").addEventListener("click", async () => {