mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 00:20:05 +01:00
34 lines
781 B
TypeScript
34 lines
781 B
TypeScript
import DOMPurify from "dompurify";
|
|
import { memo, useMemo } from "react";
|
|
import {
|
|
convertImageLinksToHtml,
|
|
convertNewLinesToBreaks,
|
|
} from "components/apps/Messenger/functions";
|
|
|
|
const SanitizedContent: FC<{ content: string; decrypted: boolean }> = ({
|
|
content,
|
|
decrypted,
|
|
}) => {
|
|
const decryptedContent = useMemo(
|
|
() =>
|
|
decrypted
|
|
? convertImageLinksToHtml(convertNewLinesToBreaks(content))
|
|
: "",
|
|
[content, decrypted]
|
|
);
|
|
|
|
return (
|
|
<div
|
|
// eslint-disable-next-line react/no-danger
|
|
dangerouslySetInnerHTML={{
|
|
__html: DOMPurify.sanitize(decryptedContent || content, {
|
|
ALLOWED_ATTR: ["src"],
|
|
ALLOWED_TAGS: ["br", "img"],
|
|
}),
|
|
}}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default memo(SanitizedContent);
|