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}`);