mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-19 16:56:12 +01:00
feat: export to screenshot
This commit is contained in:
parent
6f0b559927
commit
96914387a6
5 changed files with 73 additions and 25 deletions
21
client/src/utils/screenshotContext.jsx
Normal file
21
client/src/utils/screenshotContext.jsx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import React, { createContext, useRef, useContext, useCallback } from 'react';
|
||||
import { useScreenshot as useScreenshot_ } from 'use-react-screenshot';
|
||||
|
||||
const ScreenshotContext = createContext({});
|
||||
|
||||
export const useScreenshot = () => {
|
||||
const { ref } = useContext(ScreenshotContext);
|
||||
const [image, takeScreenshot] = useScreenshot_();
|
||||
|
||||
const captureScreenshot = () => {
|
||||
return takeScreenshot(ref.current);
|
||||
};
|
||||
|
||||
return { screenshotTargetRef: ref, captureScreenshot };
|
||||
};
|
||||
|
||||
export const ScreenshotProvider = ({ children }) => {
|
||||
const ref = useRef(null);
|
||||
|
||||
return <ScreenshotContext.Provider value={{ ref }}>{children}</ScreenshotContext.Provider>;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue