import React from 'react';
import parse from 'html-react-parser';
import { as, Box, Header, Icon, IconButton, Icons, Modal, Scroll, Text } from 'folds';
import classNames from 'classnames';
import Linkify from 'linkify-react';
import { useModalStyle } from '../../hooks/useModalStyle';
import * as css from './style.css';
import { LINKIFY_OPTS, scaleSystemEmoji } from '../../plugins/react-custom-html-parser';
import { sanitizeCustomHtml } from '../../utils/sanitize';
import { RoomTopicContent } from '../../hooks/useRoomMeta';
export const RoomTopicViewer = as<
'div',
{
name: string;
topic: string | RoomTopicContent;
requestClose: () => void;
}
>(({ name, topic, requestClose, className, ...props }, ref) => {
const topicStr = typeof topic === 'string' ? topic : topic.topic;
const modalStyle = useModalStyle(480);
const isFormatted =
typeof topic !== 'string' &&
topic.format === 'org.matrix.custom.html' &&
typeof topic.formatted_body === 'string';
return (
{isFormatted ? (
parse(sanitizeCustomHtml((topic as RoomTopicContent).formatted_body!))
) : (
{scaleSystemEmoji(topicStr)}
)}
);
});