fix: more reliable copy/paste with focus polling, clipboard save/restore, toast feedback
This commit is contained in:
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user