diff --git a/examples/tinychat/index.html b/examples/tinychat/index.html index 8cd2519078..a361dd01cb 100644 --- a/examples/tinychat/index.html +++ b/examples/tinychat/index.html @@ -97,7 +97,15 @@ button.className = 'clipboard-button'; button.innerHTML = ''; button.onclick = () => { - navigator.clipboard.writeText(codeBlock.textContent); + // navigator.clipboard.writeText(codeBlock.textContent); + const range = document.createRange(); + range.setStartBefore(codeBlock); + range.setEndAfter(codeBlock); + window.getSelection()?.removeAllRanges(); + window.getSelection()?.addRange(range); + document.execCommand('copy'); + window.getSelection()?.removeAllRanges(); + button.innerHTML = ''; setTimeout(() => button.innerHTML = '', 1000); };