Skip to content

Commit c4599fc

Browse files
Merge pull request #6 from moveyourdigital/fix-html-render-quote-block
Fix html render quote block
2 parents 1589280 + ee4d1c6 commit c4599fc

File tree

7 files changed

+33
-17
lines changed

7 files changed

+33
-17
lines changed

src/renderers/list/__snapshots__/index.test.tsx.snap

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ exports[`<List /> when receives a list unordered block renders a <ul> block 1`]
2020
It is a block-styled editor
2121
</li>
2222
<li>
23-
It returns clean data output in JSON
23+
It returns clean
24+
<b>
25+
data output
26+
</b>
27+
in JSON
2428
</li>
2529
<li>
2630
Designed to be extendable and pluggable with a simple API

src/renderers/list/index.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('<List />', () => {
88
style: 'unordered',
99
items: [
1010
'It is a block-styled editor',
11-
'It returns clean data output in JSON',
11+
'It returns clean <b>data output</b> in JSON',
1212
'Designed to be extendable and pluggable with a simple API',
1313
],
1414
};

src/renderers/paragraph/__snapshots__/index.test.tsx.snap

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
exports[`<Paragraph /> when receives a paragraph block renders a <p> tag 1`] = `
44
<p>
5-
Hey. Meet the new Editor. On this page you can see it in action — try to edit this text. Source code of the page contains the example of connection and configuration.
5+
Hey. Meet the new
6+
<b>
7+
Editor
8+
</b>
9+
. On this page you can see it in action — try to edit this text. Source code of the page contains the example of connection and configuration.
610
</p>
711
`;

src/renderers/paragraph/index.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('<Paragraph />', () => {
66
describe('when receives a paragraph block', () => {
77
const data: ParagraphBlockData = {
88
text:
9-
'Hey. Meet the new Editor. On this page you can see it in action — try to edit this text. Source code of the page contains the example of connection and configuration.',
9+
'Hey. Meet the new <b>Editor</b>. On this page you can see it in action — try to edit this text. Source code of the page contains the example of connection and configuration.',
1010
};
1111

1212
it('renders a <p> tag', () => {

src/renderers/quote/__snapshots__/index.test.tsx.snap

+13-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@ exports[`<Quote /> when receives a Quote block renders a <blockquote> block with
55
className="text-align-center special-quote"
66
>
77
<p>
8-
Esse ea consectetur est fugiat ut dolor pariatur ex voluptate ad Lorem Lorem sit sunt.
9-
</p>
10-
<p>
11-
Eiusmod voluptate ullamco laborum minim elit.
8+
<i>
9+
Esse ea consectetur est fugiat ut dolor pariatur ex voluptate ad Lorem Lorem sit sunt.
10+
</i>
1211
</p>
1312
<p>
13+
<i>
14+
Eiusmod voluptate
15+
<b>
16+
ullamco
17+
</b>
18+
laborum minim elit.
19+
</i>
20+
<i>
21+
<br />
22+
</i>
1423
Cillum ullamco fugiat tempor dolore enim.
1524
<br />
1625
Excepteur exercitation amet aliqua proident labore qui sint do dolore sint nulla aute.

src/renderers/quote/index.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('<Quote />', () => {
66
describe('when receives a Quote block', () => {
77
const data: QuoteBlockData = {
88
text:
9-
'Esse ea consectetur est fugiat ut dolor pariatur ex voluptate ad Lorem Lorem sit sunt.\n\nEiusmod voluptate ullamco laborum minim elit.\n\nCillum ullamco fugiat tempor dolore enim.\nExcepteur exercitation amet aliqua proident labore qui sint do dolore sint nulla aute.',
9+
'<i>Esse ea consectetur est fugiat ut dolor pariatur ex voluptate ad Lorem Lorem sit sunt.</i>\n\n<i>Eiusmod voluptate <b>ullamco</b> laborum minim elit.</i><i><br></i>Cillum ullamco fugiat tempor dolore enim.\nExcepteur exercitation amet aliqua proident labore qui sint do dolore sint nulla aute.</i>',
1010
caption: 'Carpe Diem, <cite>Lorem ipusm dolor</cite>.',
1111
alignment: 'center',
1212
};

src/renderers/quote/index.tsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ const Quote = ({
3939
return (
4040
<blockquote {...blockquoteprops}>
4141
{data.text &&
42-
data.text.split('\n\n').map((paragraph, i) => (
43-
<p key={i}>
44-
{paragraph
45-
.split('\n')
46-
// @ts-ignore
47-
.reduce((total, line, j) => [total, <br key={j} />, line])}
48-
</p>
49-
))}
42+
data.text
43+
.split('\n\n')
44+
.map((paragraph, i) => (
45+
<p key={i}>
46+
{ReactHtmlParser(paragraph.split('\n').reduce((total, line) => [total, '<br />', line].join('')))}
47+
</p>
48+
))}
5049
{data.caption && <footer>{ReactHtmlParser(data.caption)}</footer>}
5150
</blockquote>
5251
);

0 commit comments

Comments
 (0)