Merge PR #1096: align history controls and fix browser history copy

This commit is contained in:
Hakan Seven committed 2026-09-09 13:09:18 +03:00
commit b2ec9ef863
6 files changed
+63 -7

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
export async function copyHistory(text, fallbackLabel, closeLabel) {
try {
await navigator.clipboard.writeText(text);
return true;
} catch {
const dialog = document.createElement('dialog');
const label = document.createElement('p');
label.textContent = fallbackLabel;
const field = document.createElement('textarea');
field.value = text;
field.readOnly = true;
field.setAttribute('aria-label', fallbackLabel);
field.style.cssText = 'width:70vw;height:50vh;display:block';
const close = document.createElement('button');
close.textContent = closeLabel;
close.onclick = () => dialog.close();
dialog.append(label, field, close);
dialog.addEventListener('close', () => dialog.remove(), { once: true });
document.body.append(dialog);
dialog.showModal();
field.focus();
field.select();
return false;
}
}