mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat: add spoiler text
This commit is contained in:
@@ -28,4 +28,14 @@
|
|||||||
.embedButton:hover {
|
.embedButton:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: var(--button-desktop-text-color-hover);
|
color: var(--button-desktop-text-color-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.spoiler {
|
||||||
|
background-color: black;
|
||||||
|
color: black;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spoiler:hover {
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ import CommentMedia from '../comment-media';
|
|||||||
|
|
||||||
interface MarkdownProps {
|
interface MarkdownProps {
|
||||||
content: string;
|
content: string;
|
||||||
|
spoiler?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_LENGTH_FOR_GFM = 10000; // remarkGfm lags with large content
|
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]];
|
const remarkPlugins: any[] = [[supersub]];
|
||||||
|
|
||||||
if (content && content.length <= MAX_LENGTH_FOR_GFM) {
|
if (content && content.length <= MAX_LENGTH_FOR_GFM) {
|
||||||
@@ -68,6 +69,7 @@ const Markdown = ({ content }: MarkdownProps) => {
|
|||||||
remarkPlugins={remarkPlugins}
|
remarkPlugins={remarkPlugins}
|
||||||
rehypePlugins={[[rehypeSanitize, customSchema]]}
|
rehypePlugins={[[rehypeSanitize, customSchema]]}
|
||||||
components={{
|
components={{
|
||||||
|
p: ({ children }) => <p className=''>{spoiler ? <span className={styles.spoiler}>{children}</span> : children}</p>,
|
||||||
img: ({ src }) => <span>{src}</span>,
|
img: ({ src }) => <span>{src}</span>,
|
||||||
video: ({ src }) => <span>{src}</span>,
|
video: ({ src }) => <span>{src}</span>,
|
||||||
iframe: ({ src }) => <span>{src}</span>,
|
iframe: ({ src }) => <span>{src}</span>,
|
||||||
|
|||||||
Reference in New Issue
Block a user