mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix greentext in rehype-sanitize
This commit is contained in:
+13
-2
@@ -1,10 +1,20 @@
|
||||
import React from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
// import { Link } from 'react-router-dom';
|
||||
import rehypeSanitize from 'rehype-sanitize';
|
||||
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
|
||||
import breaks from 'remark-breaks';
|
||||
|
||||
|
||||
const customSchema = {
|
||||
...defaultSchema,
|
||||
tagNames: [...defaultSchema.tagNames, 'div'],
|
||||
attributes: {
|
||||
...defaultSchema.attributes,
|
||||
div: ['className'],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
const blockquoteToGreentext = () => (tree) => {
|
||||
tree.children.forEach((node) => {
|
||||
if (node.type === 'blockquote') {
|
||||
@@ -28,6 +38,7 @@ const blockquoteToGreentext = () => (tree) => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// const createQuotelink = (handlequoteclick, comment, children) => {
|
||||
// const text = children.map((child) => (typeof child === 'string' ? child : child.props.children)).join('');
|
||||
// const regex = /(\s|^)(c\/[A-Za-z0-9]{12}|c\/[A-Za-z0-9]{45})(?=\s|$)/g;
|
||||
@@ -59,7 +70,7 @@ const Post = ({ content, handlequoteclick, comment }) => {
|
||||
<ReactMarkdown
|
||||
children={doubleNewlineContent}
|
||||
remarkPlugins={[blockquoteToGreentext, breaks]}
|
||||
rehypePlugins={[rehypeSanitize]}
|
||||
rehypePlugins={[[rehypeSanitize, customSchema]]}
|
||||
components={{
|
||||
img: () => null,
|
||||
video: () => null,
|
||||
|
||||
Reference in New Issue
Block a user