mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
feat(client/web): Set clipboard export
This commit is contained in:
@@ -4,8 +4,14 @@ import Progressbar from "./features/progress/Progressbar";
|
||||
import TextUI from "./features/textui/TextUI";
|
||||
import InputDialog from "./features/dialog/InputDialog";
|
||||
import ContextMenu from "./features/menu/ContextMenu";
|
||||
import { useNuiEvent } from "./hooks/useNuiEvent";
|
||||
import { setClipboard } from "./utils/setClipboard";
|
||||
|
||||
const App: React.FC = () => {
|
||||
useNuiEvent("setClipboard", (data: string) => {
|
||||
setClipboard(data);
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Progressbar />
|
||||
|
||||
9
web/src/utils/setClipboard.ts
Normal file
9
web/src/utils/setClipboard.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
// yoinked from https://github.com/project-error/npwd/blob/d8dc5b7f47faf5fc581ffee30f31ff61d184cfe7/phone/src/os/phone/hooks/useClipboard.ts#L1
|
||||
export const setClipboard = (value: string) => {
|
||||
const clipElem = document.createElement('input');
|
||||
clipElem.value = value;
|
||||
document.body.appendChild(clipElem);
|
||||
clipElem.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(clipElem);
|
||||
};
|
||||
Reference in New Issue
Block a user