Spaces:
Configuration error
Configuration error
Download web/libs/editor/src/components/SidePanels/Components/RegionContextMenu.tsx from bisalsaha/lebel-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/libs/editor/src/components/SidePanels/Components/RegionContextMenu.tsx
- Command line
-
hf download hf://spaces/bisalsaha/lebel-studio/web/libs/editor/src/components/SidePanels/Components/RegionContextMenu.tsx
-
curl -L -o RegionContextMenu.tsx https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/libs/editor/src/components/SidePanels/Components/RegionContextMenu.tsx
1.8 kB
| import { useCopyText } from "@humansignal/core"; | |
| import { IconEllipsis, IconLink } from "@humansignal/icons"; | |
| import { Button, ToastType, useToast } from "@humansignal/ui"; | |
| import { observer } from "mobx-react"; | |
| import { type FC, useCallback, useMemo, useState } from "react"; | |
| import { cn } from "../../../utils/bem"; | |
| import { ContextMenu, type ContextMenuAction, ContextMenuTrigger, type MenuActionOnClick } from "../../ContextMenu"; | |
| export const RegionContextMenu: FC<{ item: any }> = observer(({ item }: { item: any }) => { | |
| const [open, setOpen] = useState(false); | |
| const regionLink = useMemo(() => { | |
| const url = new URL(window.location.href); | |
| if (item.annotation.pk) { | |
| url.searchParams.set("annotation", item.annotation.pk); | |
| } | |
| if (item.id) { | |
| url.searchParams.set("region", item.id.split("#")[0]); | |
| } | |
| return url.toString(); | |
| }, [item]); | |
| const [copyLink] = useCopyText({ defaultText: regionLink }); | |
| const toast = useToast(); | |
| const onCopyLink = useCallback<MenuActionOnClick>( | |
| (_, ctx) => { | |
| copyLink(); | |
| ctx.dropdown?.close(); | |
| toast.show({ | |
| message: "Region link copied to clipboard", | |
| type: ToastType.info, | |
| }); | |
| }, | |
| [copyLink], | |
| ); | |
| const actions = useMemo<ContextMenuAction[]>( | |
| () => [ | |
| { | |
| label: "Copy Region Link", | |
| onClick: onCopyLink, | |
| icon: <IconLink />, | |
| }, | |
| ], | |
| [onCopyLink], | |
| ); | |
| return ( | |
| <ContextMenuTrigger | |
| className={cn("region-context-menu").mod({ open }).toClassName()} | |
| content={<ContextMenu actions={actions} />} | |
| onToggle={(isOpen) => setOpen(isOpen)} | |
| > | |
| <Button variant="neutral" look="string" size="smaller" aria-label="Region options"> | |
| <IconEllipsis /> | |
| </Button> | |
| </ContextMenuTrigger> | |
| ); | |
| }); | |