mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
copy code in progress
This commit is contained in:
parent
0d8755a03a
commit
50ff96cbc5
3 changed files with 33 additions and 24 deletions
|
|
@ -25,7 +25,8 @@ const detectCode = async (text) => {
|
|||
const language = await modelOperations.runModel(code);
|
||||
return part.replace(/^```/, `\`\`\`${language[0].languageId}`);
|
||||
} else {
|
||||
return i > 0 ? '\n' + part : part;
|
||||
// return i > 0 ? '\n' + part : part;
|
||||
return part;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import React from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import Clipboard from '../svg/Clipboard';
|
||||
|
||||
export default function Embed({ children, language = '', matched}) {
|
||||
return (
|
||||
|
|
@ -7,28 +8,7 @@ export default function Embed({ children, language = '', matched}) {
|
|||
<div className="relative flex items-center bg-gray-800 px-4 py-2 font-sans text-xs text-gray-200 rounded-tl-md rounded-tr-md">
|
||||
<span className="">{ (language === 'javascript' && !matched ? '' : language) }</span>
|
||||
<button className="ml-auto flex gap-2">
|
||||
<svg
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
strokeWidth="2"
|
||||
viewBox="0 0 24 24"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
className="h-4 w-4"
|
||||
height="1em"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path>
|
||||
<rect
|
||||
x="8"
|
||||
y="2"
|
||||
width="8"
|
||||
height="4"
|
||||
rx="1"
|
||||
ry="1"
|
||||
></rect>
|
||||
</svg>
|
||||
<Clipboard />
|
||||
Copy code
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
28
src/components/svg/Clipboard.jsx
Normal file
28
src/components/svg/Clipboard.jsx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import React from 'react';
|
||||
|
||||
export default function Clipboard() {
|
||||
return (
|
||||
<svg
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
strokeWidth="2"
|
||||
viewBox="0 0 24 24"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
className="h-4 w-4"
|
||||
height="1em"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path>
|
||||
<rect
|
||||
x="8"
|
||||
y="2"
|
||||
width="8"
|
||||
height="4"
|
||||
rx="1"
|
||||
ry="1"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue