fix: more reliable copy/paste with focus polling, clipboard save/restore, toast feedback

This commit is contained in:
Dávid Ádám
2026-06-06 14:19:13 +02:00
parent 96ef83c904
commit 303aa97e07
3 changed files with 91 additions and 11 deletions
+27
View File
@@ -446,6 +446,33 @@ document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft' && currentPage > 0) renderPage(currentPage - 1);
});
/* ─── Clipboard result toast ────────────────────────────────────────────── */
const toastEl = document.getElementById('toast');
let toastTimer = null;
function showToast(msg, duration) {
duration = duration || 2000;
if (!toastEl) return;
toastEl.textContent = msg;
toastEl.style.display = 'block';
if (toastTimer) clearTimeout(toastTimer);
toastTimer = setTimeout(() => {
toastEl.style.display = 'none';
}, duration);
}
if (IS_ELECTRON) {
window.electronAPI.onClipboardResult((data) => {
if (data.action === 'copy' && data.text) {
const short = data.text.length > 60 ? data.text.substring(0, 57) + '…' : data.text;
showToast(`Copied: "${short}"`, 2500);
} else if (data.action === 'cut' && data.text) {
const short = data.text.length > 60 ? data.text.substring(0, 57) + '…' : data.text;
showToast(`Cut: "${short}"`, 2500);
}
});
}
/* ─── Document-level event logger (for troubleshooting touch) ──────────── */
function docLog(e) {
window.debugLog(`📄 ${e.type}`, `target:${e.target?.tagName} pt:${e.pointerType || '-'} btn:${e.which || e.button || 0}`);
+1
View File
@@ -31,6 +31,7 @@
<div id="page-indicator"></div>
</div>
<div id="toast" style="display:none; position:fixed; bottom:60px; left:50%; transform:translateX(-50%); background:rgba(0,0,0,0.8); color:#fff; padding:10px 20px; border-radius:8px; font:14px sans-serif; max-width:80%; text-align:center; z-index:999; pointer-events:none;"></div>
<div id="debug-overlay" style="display:none; position:fixed; bottom:0; left:0; right:0; background:rgba(0,0,0,0.85); color:#0f0; font:11px monospace; padding:6px; max-height:80px; overflow-y:auto; z-index:999; pointer-events:none;"></div>
<script src="app.js"></script>
</body>