formatting
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { FC } from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import rehypeHighlight from "rehype-highlight";
|
||||
import rehypeRaw from "rehype-raw";
|
||||
import rehypeSanitize from "rehype-sanitize";
|
||||
import "highlight.js/styles/github-dark.css";
|
||||
import { FC } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import rehypeHighlight from 'rehype-highlight';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
import rehypeSanitize from 'rehype-sanitize';
|
||||
import 'highlight.js/styles/github-dark.css';
|
||||
|
||||
import { defaultSchema } from "hast-util-sanitize";
|
||||
import { cn } from "../../lib/cn";
|
||||
import { defaultSchema } from 'hast-util-sanitize';
|
||||
import { cn } from '../../lib/cn';
|
||||
|
||||
const schema = {
|
||||
...defaultSchema,
|
||||
@@ -15,9 +15,9 @@ const schema = {
|
||||
...defaultSchema.attributes,
|
||||
div: [
|
||||
...(defaultSchema.attributes?.div || []),
|
||||
["style"] // разрешаем атрибут style на div
|
||||
]
|
||||
}
|
||||
['style'], // разрешаем атрибут style на div
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
interface MarkdownPreviewProps {
|
||||
@@ -25,13 +25,25 @@ interface MarkdownPreviewProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const MarkdownPreview: FC<MarkdownPreviewProps> = ({ content, className="" }) => {
|
||||
const MarkdownPreview: FC<MarkdownPreviewProps> = ({
|
||||
content,
|
||||
className = '',
|
||||
}) => {
|
||||
return (
|
||||
<div className={cn("flex-1 bg-[#161b22] rounded-lg shadow-lg p-6", className)}>
|
||||
<div
|
||||
className={cn(
|
||||
'flex-1 bg-[#161b22] rounded-lg shadow-lg p-6',
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<div className="prose prose-invert max-w-none h-full overflow-auto pr-4 medium-scrollbar">
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
rehypePlugins={[rehypeRaw, [rehypeSanitize, schema], rehypeHighlight]}
|
||||
rehypePlugins={[
|
||||
rehypeRaw,
|
||||
[rehypeSanitize, schema],
|
||||
rehypeHighlight,
|
||||
]}
|
||||
>
|
||||
{content}
|
||||
</ReactMarkdown>
|
||||
|
||||
Reference in New Issue
Block a user