* support room via server params and eventId * change copy link to matrix.to links * display matrix.to links in messages as pill and stop generating url previews for them * improve editor mention to include viaServers and eventId * fix mention custom attributes * always try to open room in current space * jump to latest remove target eventId from url * add create direct search options to open/create dm with url
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import React from 'react';
|
|
import parse, { HTMLReactParserOptions } from 'html-react-parser';
|
|
import Linkify from 'linkify-react';
|
|
import { Opts } from 'linkifyjs';
|
|
import { MessageEmptyContent } from './content';
|
|
import { sanitizeCustomHtml } from '../../utils/sanitize';
|
|
import { highlightText, scaleSystemEmoji } from '../../plugins/react-custom-html-parser';
|
|
|
|
type RenderBodyProps = {
|
|
body: string;
|
|
customBody?: string;
|
|
|
|
highlightRegex?: RegExp;
|
|
htmlReactParserOptions: HTMLReactParserOptions;
|
|
linkifyOpts: Opts;
|
|
};
|
|
export function RenderBody({
|
|
body,
|
|
customBody,
|
|
highlightRegex,
|
|
htmlReactParserOptions,
|
|
linkifyOpts,
|
|
}: RenderBodyProps) {
|
|
if (body === '') <MessageEmptyContent />;
|
|
if (customBody) {
|
|
if (customBody === '') <MessageEmptyContent />;
|
|
return parse(sanitizeCustomHtml(customBody), htmlReactParserOptions);
|
|
}
|
|
return (
|
|
<Linkify options={linkifyOpts}>
|
|
{highlightRegex
|
|
? highlightText(highlightRegex, scaleSystemEmoji(body))
|
|
: scaleSystemEmoji(body)}
|
|
</Linkify>
|
|
);
|
|
}
|