forked from open-webui/open-webui
feat: copy code block added
This commit is contained in:
parent
e509dafd78
commit
28ea56c95a
1 changed files with 5 additions and 2 deletions
|
@ -123,7 +123,8 @@
|
||||||
|
|
||||||
blocks.forEach((block) => {
|
blocks.forEach((block) => {
|
||||||
// only add button if browser supports Clipboard API
|
// only add button if browser supports Clipboard API
|
||||||
if (navigator.clipboard) {
|
|
||||||
|
if (navigator.clipboard && block.childNodes.length < 2) {
|
||||||
let button = document.createElement('button');
|
let button = document.createElement('button');
|
||||||
|
|
||||||
button.innerText = 'Copy Code';
|
button.innerText = 'Copy Code';
|
||||||
|
@ -380,6 +381,7 @@
|
||||||
responseMessage.context = data.context;
|
responseMessage.context = data.context;
|
||||||
messages = messages;
|
messages = messages;
|
||||||
hljs.highlightAll();
|
hljs.highlightAll();
|
||||||
|
createCopyCodeBlockButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -477,6 +479,7 @@
|
||||||
responseMessage.context = data.context;
|
responseMessage.context = data.context;
|
||||||
messages = messages;
|
messages = messages;
|
||||||
hljs.highlightAll();
|
hljs.highlightAll();
|
||||||
|
createCopyCodeBlockButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -661,7 +664,7 @@
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div
|
<div
|
||||||
class="prose prose-invert prose-headings:my-0 prose-p:my-0 prose-pre:my-0 prose-table:my-0 prose-blockquote:my-0 prose-img:my-0 prose-ul:-my-2 prose-ol:-my-2 prose-li:-my-2 whitespace-pre-line"
|
class="prose max-w-full prose-invert prose-headings:my-0 prose-p:my-0 prose-pre:my-0 prose-table:my-0 prose-blockquote:my-0 prose-img:my-0 prose-ul:-my-2 prose-ol:-my-2 prose-li:-my-2 whitespace-pre-line"
|
||||||
>
|
>
|
||||||
{@html marked.parse(message.content)}
|
{@html marked.parse(message.content)}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue