From e3bfacddcb7b3195d9354e78f0cdbe12b03494fa Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 27 Nov 2019 10:01:10 +0700 Subject: [PATCH] fixed text blocks --- src/components/node/NodeTextBlock/index.tsx | 4 ++-- src/utils/dom.ts | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/node/NodeTextBlock/index.tsx b/src/components/node/NodeTextBlock/index.tsx index adb38d73..93100b84 100644 --- a/src/components/node/NodeTextBlock/index.tsx +++ b/src/components/node/NodeTextBlock/index.tsx @@ -1,7 +1,7 @@ import React, { FC } from 'react'; import { INode } from '~/redux/types'; import path from 'ramda/es/path'; -import { formatText } from '~/utils/dom'; +import { formatTextParagraphs } from '~/utils/dom'; import * as styles from './styles.scss'; interface IProps { @@ -12,7 +12,7 @@ const NodeTextBlock: FC = ({ node }) => (
); diff --git a/src/utils/dom.ts b/src/utils/dom.ts index b13ed3f1..ecefc029 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -94,9 +94,14 @@ export const formatText = (text: string): string => .replace(/:\|--\|/gim, '://') .split('\n') .filter(el => el.trim().length) - // .map(el => `

${el}

`) .join('\n'); +export const formatTextParagraphs = (text: string): string => + text + .split('\n') + .map(str => `

${str}

`) + .join('\n'); + export const findBlockType = (line: string): ValueOf => { const match = Object.values(COMMENT_BLOCK_DETECTORS).find(detector => line.match(detector.test)); return (match && match.type) || COMMENT_BLOCK_TYPES.TEXT;