Skip to content

Commit 31fb633

Browse files
committed
Merge branch 'Matteo-it/storyteller' of github.com:arduino/app-bricks-examples into Matteo-it/storyteller
2 parents 734eb18 + d54538b commit 31fb633

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

examples/bedtime-story-teller/assets/app.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ function resetStoryView() {
317317
arrow.classList.add('rotated');
318318
container.classList.remove('disabled');
319319
} else {
320-
container.classList.add('disabled');
320+
if (container.id !== 'prompt-container') {
321+
container.classList.add('disabled');
322+
}
321323
content.style.display = 'none';
322324
arrow.classList.remove('rotated');
323325
}
@@ -444,19 +446,26 @@ document.addEventListener('DOMContentLoaded', () => {
444446
});
445447

446448
document.getElementById('copy-story-button').addEventListener('click', () => {
447-
const storyText = document.getElementById('story-response').textContent;
448-
navigator.clipboard.writeText(storyText).then(() => {
449-
const copyButton = document.getElementById('copy-story-button');
450-
const originalHTML = copyButton.innerHTML;
449+
const storyText = document.getElementById('story-response').innerText;
450+
const copyButton = document.getElementById('copy-story-button');
451+
const originalHTML = copyButton.innerHTML;
452+
const textarea = document.createElement('textarea');
453+
textarea.value = storyText;
454+
document.body.appendChild(textarea);
455+
textarea.select();
456+
try {
457+
document.execCommand('copy');
451458
copyButton.textContent = 'Copied!';
452459
copyButton.disabled = true;
453-
setTimeout(() => {
454-
copyButton.innerHTML = originalHTML;
455-
copyButton.disabled = false;
456-
}, 2000);
457-
}, (err) => {
460+
} catch (err) {
458461
console.error('Could not copy text: ', err);
459-
});
462+
}
463+
document.body.removeChild(textarea);
464+
465+
setTimeout(() => {
466+
copyButton.innerHTML = originalHTML;
467+
copyButton.disabled = false;
468+
}, 2000);
460469
});
461470

462471
document.getElementById('generate-randomly-button').addEventListener('click', () => {

examples/bedtime-story-teller/assets/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ body {
639639
line-height: 1.6;
640640
white-space: pre-wrap;
641641
overflow-y: auto;
642+
max-height: 60vh; /* Added for fixed height and scrollbar */
642643
}
643644

644645
#prompt-display strong {

0 commit comments

Comments
 (0)