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/lab/LabText/index.tsx
2022-01-02 21:28:31 +07:00

30 lines
893 B
TypeScript

import React, { FC, useMemo } from 'react';
import { Markdown } from '~/components/containers/Markdown';
import { INodeComponentProps } from '~/constants/node';
import { formatTextParagraphs } from '~/utils/dom';
import { path } from 'ramda';
import styles from './styles.module.scss';
import { useGotoNode } from '~/hooks/node/useGotoNode';
import { Paragraph } from '~/components/placeholders/Paragraph';
const LabText: FC<INodeComponentProps> = ({ node, isLoading }) => {
const content = useMemo(() => formatTextParagraphs(path(['blocks', 0, 'text'], node) || ''), [
node,
]);
const onClick = useGotoNode(node.id);
return isLoading ? (
<div className={styles.wrap}>
<Paragraph lines={5} />
</div>
) : (
<Markdown
dangerouslySetInnerHTML={{ __html: content }}
className={styles.wrap}
onClick={onClick}
/>
);
};
export { LabText };