Files
Will GandGitHub 73079add66 feat: added session network page
Added network page to settings which shows information about the node network and sesh token
2025-05-13 14:23:03 +10:00

41 lines
1.2 KiB
TypeScript

import DOMPurify from 'dompurify';
import { createElement } from 'react';
import { supportedFormattingTags } from './Localizer';
import { LocalizerHtmlTag } from '../../localization/localeTools';
type ReceivedProps = {
html: string;
tag?: LocalizerHtmlTag;
key?: any;
className?: string;
};
/**
* Renders HTML as a string, sanitizing it first.
*
* @param props - The props to use for rendering.
* @param props.html - The HTML to render.
* @param props.tag - The tag to render the HTML as. Defaults to a div.
* @param props.key - The key to use for the rendered element.
* @param props.className - The className to use for the rendered element.
*
* For a list of supported tags, see {@link supportedFormattingTags}.
*
* @deprecated use Localizer instead of this to avoid html characters non-escape issues
*
* @returns The rendered HTML as a string.
*/
export const SessionHtmlRenderer = ({ tag = 'div', key, html, className }: ReceivedProps) => {
const clean = DOMPurify.sanitize(html, {
USE_PROFILES: { html: true },
ALLOWED_TAGS: supportedFormattingTags,
ALLOWED_ATTR: ['aria-label', 'role'],
});
return createElement(tag, {
key,
className,
dangerouslySetInnerHTML: { __html: clean },
});
};