mirror of
https://github.com/wassname/talk.git
synced 2026-08-11 11:27:10 +08:00
* feat: added purify + linkify + better link detection * fix: linting + tests * chore: refactor RequireProperty Type
29 lines
626 B
TypeScript
29 lines
626 B
TypeScript
import cn from "classnames";
|
|
import React, { StatelessComponent } from "react";
|
|
|
|
import { createPurify } from "talk-common/utils/purify";
|
|
|
|
import styles from "./HTMLContent.css";
|
|
|
|
/**
|
|
* Create a purify instance that will be used to handle HTML content.
|
|
*/
|
|
const purify = createPurify(window, false);
|
|
|
|
interface HTMLContentProps {
|
|
children: string;
|
|
className?: string;
|
|
}
|
|
|
|
const HTMLContent: StatelessComponent<HTMLContentProps> = ({
|
|
children,
|
|
className,
|
|
}) => (
|
|
<div
|
|
className={cn(styles.root, className)}
|
|
dangerouslySetInnerHTML={{ __html: purify.sanitize(children) }}
|
|
/>
|
|
);
|
|
|
|
export default HTMLContent;
|