Final touches on chalkboard.

This commit is contained in:
Storm Dragon
2026-05-24 23:09:35 -04:00
parent 0a149e51ef
commit a35ae10bc7
4 changed files with 52 additions and 4 deletions
+38
View File
@@ -2635,6 +2635,17 @@ function updateChalkboardAccess() {
'aria-label',
canEdit ? 'Virtual chalkboard' : 'Virtual chalkboard, read only',
);
updateChalkboardCopyButton();
}
function updateChalkboardCopyButton() {
let chalkboard = /** @type {HTMLTextAreaElement} */
(document.getElementById('chalkboard'));
let copyButton = /** @type {HTMLButtonElement} */
(document.getElementById('chalkboard-copy'));
if(!chalkboard || !copyButton)
return;
copyButton.disabled = chalkboard.value.length === 0;
}
function resetChalkboard() {
@@ -2650,6 +2661,27 @@ function resetChalkboard() {
updateChalkboardAccess();
}
async function copyChalkboardToClipboard() {
let chalkboard = /** @type {HTMLTextAreaElement} */
(document.getElementById('chalkboard'));
if(!chalkboard || chalkboard.value.length === 0)
return;
try {
if(navigator.clipboard && navigator.clipboard.writeText) {
await navigator.clipboard.writeText(chalkboard.value);
} else {
chalkboard.focus();
chalkboard.select();
if(!document.execCommand('copy'))
throw new Error('copy command failed');
}
announceChat('Chalkboard copied to clipboard');
} catch(e) {
console.error(e);
displayError('Unable to copy chalkboard to clipboard');
}
}
/**
* @param {any} message
*/
@@ -3677,6 +3709,7 @@ document.getElementById('input').onkeypress = function(e) {
document.getElementById('chalkboard').addEventListener('input', function(e) {
if(applyingChalkboardUpdate)
return;
updateChalkboardCopyButton();
scheduleChalkboardSend();
});
@@ -3685,6 +3718,11 @@ document.getElementById('chalkboard').addEventListener('keydown', function(e) {
return;
});
document.getElementById('chalkboard-copy').addEventListener('click', function(e) {
e.preventDefault();
copyChalkboardToClipboard();
});
function updateChatResizerValue(leftPercent) {
let resizer = document.getElementById('resizer');
if(!resizer)