Skip to content

Commit

Permalink
Quote Block: Add align support (#64188)
Browse files Browse the repository at this point in the history
* Quote Block: Add align support

* Inherit alignment when transforming from pullquote block

* Inherit alignment when transforming to pullquote block

* Try to fix mobile unit test

* Try to fix mobile unit test

* Try to fix mobile unit test

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: geriux <geriux@git.wordpress.org>
  • Loading branch information
4 people authored Aug 15, 2024
1 parent f4fe8d7 commit cb224d4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ Give quoted text visual emphasis. "In quoting others, we cite ourselves." — Ju

- **Name:** core/quote
- **Category:** text
- **Supports:** anchor, background (backgroundImage, backgroundSize), color (background, gradients, heading, link, text), dimensions (minHeight), interactivity (clientNavigation), layout (~~allowEditing~~), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Supports:** align (full, left, right, wide), anchor, background (backgroundImage, backgroundSize), color (background, gradients, heading, link, text), dimensions (minHeight), interactivity (clientNavigation), layout (~~allowEditing~~), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** citation, textAlign, value

## Read More
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/quote/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"supports": {
"anchor": true,
"align": [ "left", "right", "wide", "full" ],
"html": false,
"background": {
"backgroundImage": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/quote/test/transforms.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {

const block = 'Quote';
const initialHtml = `
<!-- wp:quote {"align":"left","className":"is-style-large"} -->
<!-- wp:quote {"textAlign":"left","className":"is-style-large"} -->
<blockquote class="wp-block-quote has-text-align-left is-style-large"><!-- wp:paragraph -->
<p>"This will make running your own blog a viable alternative again."</p>
<!-- /wp:paragraph --><cite>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></cite></blockquote>
Expand Down
13 changes: 11 additions & 2 deletions packages/block-library/src/quote/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ const transforms = {
{
type: 'block',
blocks: [ 'core/pullquote' ],
transform: ( { value, citation, anchor, fontSize, style } ) => {
transform: ( {
value,
align,
citation,
anchor,
fontSize,
style,
} ) => {
return createBlock(
'core/quote',
{
align,
citation,
anchor,
fontSize,
Expand Down Expand Up @@ -95,14 +103,15 @@ const transforms = {
);
},
transform: (
{ citation, anchor, fontSize, style },
{ align, citation, anchor, fontSize, style },
innerBlocks
) => {
const value = innerBlocks
.map( ( { attributes } ) => `${ attributes.content }` )
.join( '<br>' );
return createBlock( 'core/pullquote', {
value,
align,
citation,
anchor,
fontSize,
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/mobile/utils/alignments.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const WIDE_ALIGNMENTS = {
'core/image',
'core/separator',
'core/media-text',
'core/quote',
'core/pullquote',
],
};
Expand Down

0 comments on commit cb224d4

Please sign in to comment.