Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap cite with footer in saved markup for quote and pullquote blocks #9804

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/block-library/src/pullquote/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

.wp-block-pullquote {
cite .editor-rich-text__tinymce[data-is-empty="true"]::before {
footer .editor-rich-text__tinymce[data-is-empty="true"]::before {
font-size: 14px;
font-family: $default-font;
}
Expand Down
71 changes: 49 additions & 22 deletions packages/block-library/src/pullquote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const blockAttributes = {
citation: {
type: 'array',
source: 'children',
selector: 'cite',
selector: 'footer cite',
},
};

Expand Down Expand Up @@ -70,6 +70,7 @@ export const settings = {
/>
{ ( ! RichText.isEmpty( citation ) || isSelected ) && (
<RichText
tagName="footer"
value={ citation }
/* translators: the individual or entity quoted */
placeholder={ __( 'Write citation…' ) }
Expand All @@ -78,7 +79,6 @@ export const settings = {
citation: nextCitation,
} )
}
className="wp-block-pullquote__citation"
/>
) }
</blockquote>
Expand All @@ -91,34 +91,61 @@ export const settings = {
return (
<blockquote>
<RichText.Content value={ toRichTextValue( value ) } />
{ ! RichText.isEmpty( citation ) && <RichText.Content tagName="cite" value={ citation } /> }
{ ! RichText.isEmpty( citation ) && (
<footer>
<RichText.Content tagName="cite" value={ citation } />
</footer>
) }
</blockquote>
);
},

deprecated: [ {
attributes: {
...blockAttributes,
citation: {
type: 'array',
source: 'children',
selector: 'footer',
deprecated: [
{
attributes: {
...blockAttributes,
citation: {
type: 'array',
source: 'children',
selector: 'footer',
},
align: {
type: 'string',
default: 'none',
},
},
align: {
type: 'string',
default: 'none',

save( { attributes } ) {
const { value, citation, align } = attributes;

return (
<blockquote className={ `align${ align }` }>
<RichText.Content value={ toRichTextValue( value ) } />
{ ! RichText.isEmpty( citation ) && <RichText.Content tagName="footer" value={ citation } /> }
</blockquote>
);
},
},
{
attributes: {
...blockAttributes,
citation: {
type: 'array',
source: 'children',
selector: 'cite',
},
},

save( { attributes } ) {
const { value, citation, align } = attributes;
save( { attributes } ) {
const { value, citation } = attributes;

return (
<blockquote className={ `align${ align }` }>
<RichText.Content value={ toRichTextValue( value ) } />
{ ! RichText.isEmpty( citation ) && <RichText.Content tagName="footer" value={ citation } /> }
</blockquote>
);
return (
<blockquote>
<RichText.Content value={ toRichTextValue( value ) } />
{ ! RichText.isEmpty( citation ) && <RichText.Content tagName="cite" value={ citation } /> }
</blockquote>
);
},
},
} ],
],
};
1 change: 0 additions & 1 deletion packages/block-library/src/pullquote/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
line-height: 1.6;
}

cite,
footer {
position: relative;
}
Expand Down
4 changes: 1 addition & 3 deletions packages/block-library/src/pullquote/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
border-bottom: 4px solid $dark-gray-500;
color: $dark-gray-600;

cite,
footer,
&__citation {
footer {
color: $dark-gray-600;
text-transform: uppercase;
font-size: $default-font-size;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/quote/editor.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.wp-block-quote {
margin: 0;

&__citation {
footer {
font-size: $default-font-size;
}
}
31 changes: 28 additions & 3 deletions packages/block-library/src/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const blockAttributes = {
citation: {
type: 'array',
source: 'children',
selector: 'cite',
selector: 'footer cite',
},
align: {
type: 'string',
Expand Down Expand Up @@ -205,6 +205,7 @@ export const settings = {
/>
{ ( ! RichText.isEmpty( citation ) || isSelected ) && (
<RichText
tagName="footer"
value={ citation }
onChange={
( nextCitation ) => setAttributes( {
Expand All @@ -213,7 +214,6 @@ export const settings = {
}
/* translators: the individual or entity quoted */
placeholder={ __( 'Write citation…' ) }
className="wp-block-quote__citation"
/>
) }
</blockquote>
Expand All @@ -227,7 +227,11 @@ export const settings = {
return (
<blockquote style={ { textAlign: align ? align : null } }>
<RichText.Content value={ toRichTextValue( value ) } />
{ ! RichText.isEmpty( citation ) && <RichText.Content tagName="cite" value={ citation } /> }
{ ! RichText.isEmpty( citation ) && (
<footer>
<RichText.Content tagName="cite" value={ citation } />
</footer>
) }
</blockquote>
);
},
Expand Down Expand Up @@ -295,5 +299,26 @@ export const settings = {
);
},
},
{
attributes: {
...blockAttributes,
citation: {
type: 'array',
source: 'children',
selector: 'cite',
},
},

save( { attributes } ) {
const { align, value, citation } = attributes;

return (
<blockquote style={ { textAlign: align ? align : null } }>
<RichText.Content value={ toRichTextValue( value ) } />
{ ! RichText.isEmpty( citation ) && <RichText.Content tagName="cite" value={ citation } /> }
</blockquote>
);
},
},
],
};
1 change: 0 additions & 1 deletion packages/block-library/src/quote/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
line-height: 1.6;
}

cite,
footer {
font-size: 18px;
text-align: right;
Expand Down
4 changes: 1 addition & 3 deletions packages/block-library/src/quote/theme.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
.wp-block-quote {
margin: 20px 0;

cite,
footer,
&__citation {
footer {
color: $dark-gray-300;
font-size: $default-font-size;
margin-top: 1em;
Expand Down
3 changes: 2 additions & 1 deletion test/integration/full-content/fixtures/core__pullquote.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- wp:core/pullquote -->
<blockquote class="wp-block-pullquote">
<p>Testing pullquote block...</p><cite>...with a caption</cite>
<p>Testing pullquote block...</p>
<footer><cite>...with a caption</cite></footer>
</blockquote>
<!-- /wp:core/pullquote -->
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
]
},
"innerBlocks": [],
"originalContent": "<blockquote class=\"wp-block-pullquote\">\n<p>Testing pullquote block...</p><cite>...with a caption</cite>\n</blockquote>"
"originalContent": "<blockquote class=\"wp-block-pullquote\">\n<p>Testing pullquote block...</p>\n<footer><cite>...with a caption</cite></footer>\n</blockquote>"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"blockName": "core/pullquote",
"attrs": null,
"innerBlocks": [],
"innerHTML": "\n<blockquote class=\"wp-block-pullquote\">\n<p>Testing pullquote block...</p><cite>...with a caption</cite>\n</blockquote>\n"
"innerHTML": "\n<blockquote class=\"wp-block-pullquote\">\n<p>Testing pullquote block...</p>\n<footer><cite>...with a caption</cite></footer>\n</blockquote>\n"
},
{
"attrs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:pullquote -->
<blockquote class="wp-block-pullquote"><p>Testing pullquote block...</p><cite>...with a caption</cite></blockquote>
<blockquote class="wp-block-pullquote"><p>Testing pullquote block...</p><footer><cite>...with a caption</cite></footer></blockquote>
<!-- /wp:pullquote -->
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<blockquote class="wp-block-pullquote">
<p>Paragraph <strong>one</strong></p>
<p>Paragraph two</p>
<cite>by whomever</cite>
<footer>
<cite>by whomever</cite>
</footer>
</blockquote>
<!-- /wp:core/pullquote -->
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
]
},
"innerBlocks": [],
"originalContent": "<blockquote class=\"wp-block-pullquote\">\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <cite>by whomever</cite>\n</blockquote>"
"originalContent": "<blockquote class=\"wp-block-pullquote\">\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <footer>\n <cite>by whomever</cite>\n </footer>\n</blockquote>"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"blockName": "core/pullquote",
"attrs": null,
"innerBlocks": [],
"innerHTML": "\n<blockquote class=\"wp-block-pullquote\">\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <cite>by whomever</cite>\n</blockquote>\n"
"innerHTML": "\n<blockquote class=\"wp-block-pullquote\">\n <p>Paragraph <strong>one</strong></p>\n <p>Paragraph two</p>\n <footer>\n <cite>by whomever</cite>\n </footer>\n</blockquote>\n"
},
{
"attrs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:pullquote -->
<blockquote class="wp-block-pullquote"><p>Paragraph <strong>one</strong></p><p>Paragraph two</p><cite>by whomever</cite></blockquote>
<blockquote class="wp-block-pullquote"><p>Paragraph <strong>one</strong></p><p>Paragraph two</p><footer><cite>by whomever</cite></footer></blockquote>
<!-- /wp:pullquote -->
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:core/quote -->
<blockquote class="wp-block-quote"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><cite>Matt Mullenweg, 2017</cite></blockquote>
<blockquote class="wp-block-quote"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><footer><cite>Matt Mullenweg, 2017</cite></footer></blockquote>
<!-- /wp:core/quote -->
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
]
},
"innerBlocks": [],
"originalContent": "<blockquote class=\"wp-block-quote\"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><cite>Matt Mullenweg, 2017</cite></blockquote>"
"originalContent": "<blockquote class=\"wp-block-quote\"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><footer><cite>Matt Mullenweg, 2017</cite></footer></blockquote>"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"blockName": "core/quote",
"attrs": null,
"innerBlocks": [],
"innerHTML": "\n<blockquote class=\"wp-block-quote\"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><cite>Matt Mullenweg, 2017</cite></blockquote>\n"
"innerHTML": "\n<blockquote class=\"wp-block-quote\"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><footer><cite>Matt Mullenweg, 2017</cite></footer></blockquote>\n"
},
{
"attrs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><cite>Matt Mullenweg, 2017</cite></blockquote>
<blockquote class="wp-block-quote"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><footer><cite>Matt Mullenweg, 2017</cite></footer></blockquote>
<!-- /wp:quote -->
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:core/quote {"className":"is-style-large"} -->
<blockquote class="wp-block-quote is-style-large"><p>There is no greater agony than bearing an untold story inside you.</p><cite>Maya Angelou</cite></blockquote>
<blockquote class="wp-block-quote is-style-large"><p>There is no greater agony than bearing an untold story inside you.</p><footer><cite>Maya Angelou</cite></footer></blockquote>
<!-- /wp:core/quote -->
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"className": "is-style-large"
},
"innerBlocks": [],
"originalContent": "<blockquote class=\"wp-block-quote is-style-large\"><p>There is no greater agony than bearing an untold story inside you.</p><cite>Maya Angelou</cite></blockquote>"
"originalContent": "<blockquote class=\"wp-block-quote is-style-large\"><p>There is no greater agony than bearing an untold story inside you.</p><footer><cite>Maya Angelou</cite></footer></blockquote>"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"className": "is-style-large"
},
"innerBlocks": [],
"innerHTML": "\n<blockquote class=\"wp-block-quote is-style-large\"><p>There is no greater agony than bearing an untold story inside you.</p><cite>Maya Angelou</cite></blockquote>\n"
"innerHTML": "\n<blockquote class=\"wp-block-quote is-style-large\"><p>There is no greater agony than bearing an untold story inside you.</p><footer><cite>Maya Angelou</cite></footer></blockquote>\n"
},
{
"attrs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:quote {"className":"is-style-large"} -->
<blockquote class="wp-block-quote is-style-large"><p>There is no greater agony than bearing an untold story inside you.</p><cite>Maya Angelou</cite></blockquote>
<blockquote class="wp-block-quote is-style-large"><p>There is no greater agony than bearing an untold story inside you.</p><footer><cite>Maya Angelou</cite></footer></blockquote>
<!-- /wp:quote -->