diff --git a/src/components/markdown/markdown.module.css b/src/components/markdown/markdown.module.css index 8c12a714..bfdb899c 100644 --- a/src/components/markdown/markdown.module.css +++ b/src/components/markdown/markdown.module.css @@ -28,4 +28,14 @@ .embedButton:hover { cursor: pointer; color: var(--button-desktop-text-color-hover); +} + +.spoiler { + background-color: black; + color: black; + width: fit-content; +} + +.spoiler:hover { + color: white; } \ No newline at end of file diff --git a/src/components/markdown/markdown.tsx b/src/components/markdown/markdown.tsx index 31542885..1ac29608 100644 --- a/src/components/markdown/markdown.tsx +++ b/src/components/markdown/markdown.tsx @@ -10,6 +10,7 @@ import CommentMedia from '../comment-media'; interface MarkdownProps { content: string; + spoiler?: boolean; } const MAX_LENGTH_FOR_GFM = 10000; // remarkGfm lags with large content @@ -37,7 +38,7 @@ const blockquoteToGreentext = () => (tree: any) => { }); }; -const Markdown = ({ content }: MarkdownProps) => { +const Markdown = ({ content, spoiler }: MarkdownProps) => { const remarkPlugins: any[] = [[supersub]]; if (content && content.length <= MAX_LENGTH_FOR_GFM) { @@ -68,6 +69,7 @@ const Markdown = ({ content }: MarkdownProps) => { remarkPlugins={remarkPlugins} rehypePlugins={[[rehypeSanitize, customSchema]]} components={{ + p: ({ children }) =>

{spoiler ? {children} : children}

, img: ({ src }) => {src}, video: ({ src }) => {src}, iframe: ({ src }) => {src},