mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
added markdown to text node
This commit is contained in:
parent
616398c4fc
commit
c98ac8b597
3 changed files with 23 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC, useMemo } from 'react';
|
||||||
import { ICommentBlockProps } from '~/constants/comment';
|
import { ICommentBlockProps } from '~/constants/comment';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
@ -8,11 +8,13 @@ import { formatText } from '~/utils/dom';
|
||||||
interface IProps extends ICommentBlockProps {}
|
interface IProps extends ICommentBlockProps {}
|
||||||
|
|
||||||
const CommentTextBlock: FC<IProps> = ({ block }) => {
|
const CommentTextBlock: FC<IProps> = ({ block }) => {
|
||||||
|
const content = useMemo(() => formatText(block.content), [block.content]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.text, markdown.wrapper)}
|
className={classNames(styles.text, markdown.wrapper)}
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: formatText(block.content),
|
__html: content,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,19 +1,26 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC, useMemo } from 'react';
|
||||||
import { INode } from '~/redux/types';
|
|
||||||
import { path } from 'ramda';
|
import { path } from 'ramda';
|
||||||
import { formatTextParagraphs } from '~/utils/dom';
|
import { formatTextParagraphs } from '~/utils/dom';
|
||||||
import styles from './styles.module.scss';
|
|
||||||
import { INodeComponentProps } from '~/redux/node/constants';
|
import { INodeComponentProps } from '~/redux/node/constants';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import styles from './styles.module.scss';
|
||||||
|
import markdown from '~/styles/common/markdown.module.scss';
|
||||||
|
|
||||||
interface IProps extends INodeComponentProps {}
|
interface IProps extends INodeComponentProps {}
|
||||||
|
|
||||||
const NodeTextBlock: FC<IProps> = ({ node }) => (
|
const NodeTextBlock: FC<IProps> = ({ node }) => {
|
||||||
<div
|
const content = useMemo(() => formatTextParagraphs(path(['blocks', 0, 'text'], node)), [
|
||||||
className={styles.text}
|
node.blocks,
|
||||||
dangerouslySetInnerHTML={{
|
]);
|
||||||
__html: formatTextParagraphs(path(['blocks', 0, 'text'], node)),
|
|
||||||
}}
|
return (
|
||||||
/>
|
<div
|
||||||
);
|
className={classNames(styles.text, markdown.wrapper)}
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: content,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export { NodeTextBlock };
|
export { NodeTextBlock };
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
color: white;
|
color: white;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
line-height: 1.2em;
|
line-height: 1.2em;
|
||||||
|
margin-bottom: $gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue