mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-11 01:10:11 +01:00
56dc49966d
* add copy feature to assistant chat message * fix tooltip not hiding on mobile * fix: add tooltips chore: breakout actions to extendable component + memoize add CopyText to hook we can reuse fix: Copy on code snippets broken, moved to event listener fix: highlightjs patch for new API support feat: add copy response support --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
16 lines
371 B
JavaScript
16 lines
371 B
JavaScript
import { useState } from "react";
|
|
|
|
export default function useCopyText(delay = 2500) {
|
|
const [copied, setCopied] = useState(false);
|
|
const copyText = async (content) => {
|
|
if (!content) return;
|
|
navigator?.clipboard?.writeText(content);
|
|
setCopied(content);
|
|
setTimeout(() => {
|
|
setCopied(false);
|
|
}, delay);
|
|
};
|
|
|
|
return { copyText, copied };
|
|
}
|