({ children }: { children?: ReactNode })
| 35 | import { slugify } from "../lib/helpers"; |
| 36 | |
| 37 | export default function ShareDialog({ children }: { children?: ReactNode }) { |
| 38 | const isHosted = useDocDetails("isHosted"); |
| 39 | const { shareModal, setShareModal } = useContext(AppContext); |
| 40 | const docString = useDoc(docToString); |
| 41 | const shareLink = useMemo(() => { |
| 42 | return compressToEncodedURIComponent(docString); |
| 43 | }, [docString]); |
| 44 | const fullscreen = `${new URL(window.location.href).origin}/f#${shareLink}`; |
| 45 | const readOnly = `${new URL(window.location.href).origin}/c#${shareLink}`; |
| 46 | const editable = `${new URL(window.location.href).origin}/#load:${shareLink}`; |
| 47 | const filename = useDownloadFilename(); |
| 48 | const hasProAccess = useHasProAccess(); |
| 49 | const watermark = !hasProAccess; |
| 50 | const scale = hasProAccess ? AUTH_IMG_SCALE : UNAUTH_IMG_SCALE; |
| 51 | |
| 52 | return ( |
| 53 | <Dialog.Root |
| 54 | open={shareModal} |
| 55 | onOpenChange={setShareModal} |
| 56 | aria-label={t`Export`} |
| 57 | > |
| 58 | <Dialog.Trigger asChild>{children}</Dialog.Trigger> |
| 59 | <Overlay /> |
| 60 | <Content |
| 61 | maxWidthClass="max-w-[600px] w-full" |
| 62 | overflowV |
| 63 | data-location="Share Dialog" |
| 64 | > |
| 65 | <Close /> |
| 66 | <PreviewImage watermark={watermark} scale={scale} /> |
| 67 | <Column> |
| 68 | <SectionTitle className="mb-1"> |
| 69 | <Trans>Download</Trans> |
| 70 | </SectionTitle> |
| 71 | <div className="grid gap-2 grid-cols-3"> |
| 72 | <Button2 |
| 73 | aria-label="Download PNG" |
| 74 | data-session-activity="Download PNG" |
| 75 | onClick={() => { |
| 76 | if (!window.__cy) return; |
| 77 | getCanvas({ |
| 78 | cy: window.__cy, |
| 79 | type: "png", |
| 80 | watermark, |
| 81 | scale, |
| 82 | }) |
| 83 | .then((canvas) => |
| 84 | downloadCanvas({ |
| 85 | ...canvas, |
| 86 | filename, |
| 87 | }) |
| 88 | ) |
| 89 | .catch(console.error); |
| 90 | }} |
| 91 | > |
| 92 | PNG |
| 93 | </Button2> |
| 94 | <Button2 |
nothing calls this directly
no test coverage detected