usePreviewFullscreen.ts 833 B

12345678910111213141516171819202122
  1. import { useRef, type RefObject } from 'react';
  2. import { useElementFullscreen } from './useElementFullscreen';
  3. export interface PreviewFullscreen {
  4. panelRef: RefObject<HTMLDivElement | null>;
  5. isFullscreen: boolean;
  6. toggleFullscreen: () => void;
  7. }
  8. /**
  9. * Fullscreen state for a file preview panel (#2976).
  10. *
  11. * Held by the modal rather than by `PreviewModalShell`, which renders the
  12. * toggle: the 3D viewer drives layout effects off `isFullscreen` — in
  13. * fullscreen the plate list splits off the canvas — so the flag has to be
  14. * readable outside the shell's own subtree.
  15. */
  16. export function usePreviewFullscreen(): PreviewFullscreen {
  17. const panelRef = useRef<HTMLDivElement>(null);
  18. const { isFullscreen, toggleFullscreen } = useElementFullscreen(panelRef);
  19. return { panelRef, isFullscreen, toggleFullscreen };
  20. }