UNPKG

@plteam/chat-ui

Version:

CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript

28 lines (27 loc) 958 B
import * as React from 'react'; import { NOOP } from '../../../utils/NOOP'; import PhotoSwipeLightbox from '../../photoswipe/PhotoSwipeLightbox'; import { chatClassNames } from '../../core/chatClassNames'; export const usePhotoswipeInitialization = (containerId, typing) => { React.useEffect(() => { if (typing) return NOOP; let lightbox; try { lightbox = PhotoSwipeLightbox({ gallery: `#${containerId}`, children: `a.${chatClassNames.markdownImage}`, pswpModule: () => import('photoswipe'), zoom: false, showHideAnimationType: 'fade', }); lightbox.init(); } catch (e) { console.error('Gallery initialization error: ', e, containerId); } return () => { lightbox?.destroy(); }; }, [typing, containerId]); };