forked from 1b-agent/opencadstudio-upstream
Merge PR #1096: align history controls and fix browser history copy
This commit is contained in:
commit
b2ec9ef863
6 files changed
+63
-7
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user