Skip to content

Commit 5c3c9fd

Browse files
Rich Taborjuanfra
andauthored
Quote block: Add transform to paragraph (#51809)
* Add ungroup transform as transform to p * Lint * Update test and snapshot. --------- Co-authored-by: Juan Aldasoro <[email protected]>
1 parent 55970a1 commit 5c3c9fd

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

packages/block-library/src/quote/test/__snapshots__/transforms.native.js.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ exports[`Quote block transforms to Group block 1`] = `
2222
<!-- /wp:group -->"
2323
`;
2424

25+
exports[`Quote block transforms to Paragraph block 1`] = `
26+
"<!-- wp:paragraph -->
27+
<p>"This will make running your own blog a viable alternative again."</p>
28+
<!-- /wp:paragraph -->
29+
30+
<!-- wp:paragraph -->
31+
<p>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></p>
32+
<!-- /wp:paragraph -->"
33+
`;
34+
2535
exports[`Quote block transforms to Pullquote block 1`] = `
2636
"<!-- wp:pullquote -->
2737
<figure class="wp-block-pullquote"><blockquote><p>"This will make running your own blog a viable alternative again."</p><cite>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></cite></blockquote></figure>

packages/block-library/src/quote/test/transforms.native.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ const initialHtml = `
2121
<!-- /wp:quote -->`;
2222

2323
const transformsWithInnerBlocks = [ 'Columns', 'Group' ];
24-
const blockTransforms = [ 'Pullquote', ...transformsWithInnerBlocks ];
24+
const blockTransforms = [
25+
'Pullquote',
26+
'Paragraph',
27+
...transformsWithInnerBlocks,
28+
];
2529

2630
setupCoreBlocks();
2731

packages/block-library/src/quote/transforms.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@ const transforms = {
109109
} );
110110
},
111111
},
112+
{
113+
type: 'block',
114+
blocks: [ 'core/paragraph' ],
115+
transform: ( { citation }, innerBlocks ) =>
116+
citation
117+
? [
118+
...innerBlocks,
119+
createBlock( 'core/paragraph', {
120+
content: citation,
121+
} ),
122+
]
123+
: innerBlocks,
124+
},
112125
{
113126
type: 'block',
114127
blocks: [ 'core/group' ],

0 commit comments

Comments
 (0)