diff --git a/src/uncloseai-embed-modal.js b/src/uncloseai-embed-modal.js index ee2b105..5dc1782 100644 --- a/src/uncloseai-embed-modal.js +++ b/src/uncloseai-embed-modal.js @@ -1399,12 +1399,10 @@ You have complete knowledge of this page content and can reference any details, ); historicalUserAudio = result.audio; - // Add download button if not already present - if (!userMessageActions.querySelector('.download-btn')) { - const downloadBtn = document.createElement("button"); - downloadBtn.textContent = "💾"; - downloadBtn.title = getUIText("downloadChatAudio"); - downloadBtn.className = "uncloseai-btn-small uncloseai-download-btn"; + // Show and set up the download button + const downloadBtn = userMessageActions.querySelector('.uncloseai-download-btn'); + if (downloadBtn) { + downloadBtn.style.display = ""; // Show the button downloadBtn.onclick = async () => { try { const { generateTitleForTTS } = await import("./tts.js"); @@ -1421,13 +1419,6 @@ You have complete knowledge of this page content and can reference any details, a.click(); } }; - // Insert download button right after the play button (before delete button) - const userDeleteBtn = userMessageActions.querySelector('button[title="Delete message"]'); - if (userDeleteBtn) { - userMessageActions.insertBefore(downloadBtn, userDeleteBtn); - } else { - userMessageActions.appendChild(downloadBtn); - } } // Set up audio event handlers @@ -1487,6 +1478,15 @@ You have complete knowledge of this page content and can reference any details, }; userMessageActions.appendChild(userTtsBtn); + + // Add download button initially (hidden until audio is generated) + const userHistoricalDownloadBtn = document.createElement("button"); + userHistoricalDownloadBtn.textContent = "💾"; + userHistoricalDownloadBtn.title = getUIText("downloadChatAudio"); + userHistoricalDownloadBtn.className = "uncloseai-btn-small uncloseai-download-btn"; + userHistoricalDownloadBtn.style.display = "none"; // Hidden initially + userMessageActions.appendChild(userHistoricalDownloadBtn); + userMessageActions.appendChild(userDeleteBtn); userMsg.appendChild(messageText); userMsg.appendChild(userMessageActions); @@ -1557,12 +1557,10 @@ You have complete knowledge of this page content and can reference any details, ); historicalAudio = result.audio; - // Add download button if not already present - if (!messageActions.querySelector('.download-btn')) { - const downloadBtn = document.createElement("button"); - downloadBtn.textContent = "💾"; - downloadBtn.title = getUIText("downloadChatAudio"); - downloadBtn.className = "uncloseai-btn-small uncloseai-download-btn"; + // Show and set up the download button + const downloadBtn = messageActions.querySelector('.uncloseai-download-btn'); + if (downloadBtn) { + downloadBtn.style.display = ""; // Show the button downloadBtn.onclick = async () => { try { const { generateTitleForTTS } = await import("./tts.js"); @@ -1579,13 +1577,6 @@ You have complete knowledge of this page content and can reference any details, a.click(); } }; - // Insert download button right after the play button (before copy buttons) - const copyRawBtn = messageActions.querySelector('button[title="Copy raw response"]'); - if (copyRawBtn) { - messageActions.insertBefore(downloadBtn, copyRawBtn); - } else { - messageActions.appendChild(downloadBtn); - } } // Set up audio event handlers @@ -1684,6 +1675,15 @@ You have complete knowledge of this page content and can reference any details, }; messageActions.appendChild(ttsBtn); + + // Add download button initially (hidden until audio is generated) + const aiHistoricalDownloadBtn = document.createElement("button"); + aiHistoricalDownloadBtn.textContent = "💾"; + aiHistoricalDownloadBtn.title = getUIText("downloadChatAudio"); + aiHistoricalDownloadBtn.className = "uncloseai-btn-small uncloseai-download-btn"; + aiHistoricalDownloadBtn.style.display = "none"; // Hidden initially + messageActions.appendChild(aiHistoricalDownloadBtn); + messageActions.appendChild(copyRawBtn); messageActions.appendChild(copyHtmlBtn); messageActions.appendChild(deleteBtn); diff --git a/src/uncloseai-modal-builtin.css b/src/uncloseai-modal-builtin.css index cdbec68..14759e4 100644 --- a/src/uncloseai-modal-builtin.css +++ b/src/uncloseai-modal-builtin.css @@ -828,7 +828,7 @@ dialog#tts-modal { display: grid; grid-auto-flow: column; grid-auto-columns: max-content; - gap: 8px; + gap: 18px; opacity: 0.8; justify-content: end; } diff --git a/src/uncloseai-modal-pico.css b/src/uncloseai-modal-pico.css index d60d774..b2e1c89 100644 --- a/src/uncloseai-modal-pico.css +++ b/src/uncloseai-modal-pico.css @@ -884,7 +884,7 @@ dialog#tts-modal::backdrop { display: grid; grid-auto-flow: column; grid-auto-columns: max-content; - gap: 8px; + gap: 18px; opacity: 0.8; justify-content: end; }