mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
fixed text blocks
This commit is contained in:
parent
1169a90553
commit
e3bfacddcb
2 changed files with 8 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { INode } from '~/redux/types';
|
import { INode } from '~/redux/types';
|
||||||
import path from 'ramda/es/path';
|
import path from 'ramda/es/path';
|
||||||
import { formatText } from '~/utils/dom';
|
import { formatTextParagraphs } from '~/utils/dom';
|
||||||
import * as styles from './styles.scss';
|
import * as styles from './styles.scss';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
@ -12,7 +12,7 @@ const NodeTextBlock: FC<IProps> = ({ node }) => (
|
||||||
<div
|
<div
|
||||||
className={styles.text}
|
className={styles.text}
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: formatText(path(['blocks', 0, 'text'], node)),
|
__html: formatTextParagraphs(path(['blocks', 0, 'text'], node)),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -94,7 +94,12 @@ export const formatText = (text: string): string =>
|
||||||
.replace(/:\|--\|/gim, '://')
|
.replace(/:\|--\|/gim, '://')
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter(el => el.trim().length)
|
.filter(el => el.trim().length)
|
||||||
// .map(el => `<p>${el}</p>`)
|
.join('\n');
|
||||||
|
|
||||||
|
export const formatTextParagraphs = (text: string): string =>
|
||||||
|
text
|
||||||
|
.split('\n')
|
||||||
|
.map(str => `<p>${str}</p>`)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
|
|
||||||
export const findBlockType = (line: string): ValueOf<typeof COMMENT_BLOCK_TYPES> => {
|
export const findBlockType = (line: string): ValueOf<typeof COMMENT_BLOCK_TYPES> => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue