1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00
vault-frontend/src/components/node/NodeTextBlock/index.tsx
2021-02-24 16:40:37 +07:00

26 lines
733 B
TypeScript

import React, { FC, useMemo } from 'react';
import { path } from 'ramda';
import { formatTextParagraphs } from '~/utils/dom';
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 {}
const NodeTextBlock: FC<IProps> = ({ node }) => {
const content = useMemo(() => formatTextParagraphs(path(['blocks', 0, 'text'], node)), [
node.blocks,
]);
return (
<div
className={classNames(styles.text, markdown.wrapper)}
dangerouslySetInnerHTML={{
__html: content,
}}
/>
);
};
export { NodeTextBlock };