import { Ref, forwardRef } from 'react' import { Text, TextProps } from '@audius/harmony/src/components/text' import { TextLink } from '@audius/harmony/src/components/text-link' import Linkify from 'linkify-react' import { IntermediateRepresentation } from 'linkifyjs' type LinkifyTextProps = TextProps const LinkifyText = forwardRef( (props: LinkifyTextProps, ref: Ref) => { const { ...other } = props return } ) const renderLink = ({ attributes, content }: IntermediateRepresentation) => { const { href, ...props } = attributes return ( {content} ) } const squashNewLines = ( str: string | null | undefined, newlineMax: number = 2 ) => { return str ? str .replace( new RegExp( `\\n\\s*(\\n\\s*){${Math.max(newlineMax - 2, 1)}}\\n`, 'g' ), '\n'.repeat(newlineMax) ) .trim() : str } type ServerUserGeneratedTextProps = TextProps export const ServerUserGeneratedText = ( props: ServerUserGeneratedTextProps ) => { const { children: childrenProp, ...other } = props const children = typeof childrenProp === 'string' ? squashNewLines(childrenProp) : childrenProp if (!children) return null return ( {children} ) }