import { useIntegration } from '@gitroom/frontend/components/launches/helpers/use.integration'; import { useMediaDirectory } from '@gitroom/react/helpers/use.media.directory'; import clsx from 'clsx'; import { VideoOrImage } from '@gitroom/react/helpers/video.or.image'; import { FC } from 'react'; import { textSlicer } from '@gitroom/helpers/utils/count.length'; import Image from 'next/image'; import { useLaunchStore } from '@gitroom/frontend/components/new-launch/store'; import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validation'; export const GeneralPreviewComponent: FC<{ maximumCharacters?: number; }> = (props) => { const { value: topValue, integration } = useIntegration(); const current = useLaunchStore((state) => state.current); const mediaDir = useMediaDirectory(); const renderContent = topValue.map((p) => { const newContent = stripHtmlValidation( 'normal', p.content.replace( /([.\s\S]*?)<\/span>/gi, (match, match1, match2) => { return `[[[${match2}]]]`; } ), true ); console.log('newConetnt', newContent); const { start, end } = textSlicer( integration?.identifier || '', props.maximumCharacters || 10000, newContent ); const finalValue = newContent .slice(start, end) .replace(/\[\[\[([.\s\S]*?)]]]/, (match, match1) => { return `${match1}`; }) + `` + newContent.slice(end).replace(/\[\[\[([.\s\S]*?)]]]/, (match, match1) => { return `${match1}`; }) + ``; console.log(finalValue); return { text: finalValue, images: p.image }; }); return (
{renderContent.map((value, index) => (
x {current !== 'global' && ( {integration.identifier} )}
{index !== topValue.length - 1 && (
)}
{current === 'global' ? 'Global Edit' : integration?.name}
{current === 'global' ? '' : integration?.display || '@username'}
{!!value?.images?.length && (
3 ? 'grid grid-cols-2 gap-[4px]' : 'flex gap-[4px]' )} > {value.images.map((image, index) => ( ))}
)}
))}
); };