-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Blocks: Add quote blocks style controls #482
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7c3bd20
Blocks: Add quote blocks style controls
youknowriad 2fa1233
Quote block: variation instead of level and more accurate placeholder
youknowriad c844bd5
Block Toolbar: rename level to subscript
youknowriad 968ec56
Use a number for quote style
nylen 33e7ef9
Clarify quote style message
nylen 02e832c
Parse quote style number out of saved markup
nylen 4b8d3e4
Fix the build :|
nylen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,21 @@ registerBlock( 'core/quote', { | |
citation: html( 'footer' ) | ||
}, | ||
|
||
controls: [ '1', '2' ].map( ( level ) => ( { | ||
icon: 'format-quote', | ||
title: wp.i18n.sprintf( wp.i18n.__( 'Quote %s' ), level ), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert this change because I'm using strings |
||
isActive: ( { style = '1' } ) => style === level, | ||
onClick( attributes, setAttributes ) { | ||
setAttributes( { style: level } ); | ||
}, | ||
level | ||
} ) ), | ||
|
||
edit( { attributes, setAttributes, focus, setFocus } ) { | ||
const { value, citation } = attributes; | ||
const { value, citation, style = '1' } = attributes; | ||
|
||
return ( | ||
<blockquote className="blocks-quote"> | ||
<blockquote className={ `blocks-quote blocks-quote-style-${ style }` }> | ||
<Editable | ||
value={ fromValueToParagraphs( value ) } | ||
onChange={ | ||
|
@@ -54,10 +64,10 @@ registerBlock( 'core/quote', { | |
}, | ||
|
||
save( attributes ) { | ||
const { value, citation } = attributes; | ||
const { value, citation, style = '1' } = attributes; | ||
|
||
return ( | ||
<blockquote> | ||
<blockquote className={ `blocks-quote-style-${ style }` }> | ||
{ value && value.map( ( paragraph, i ) => ( | ||
<p | ||
key={ i } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure
level
applies as well here as it does for a heading.variant
,variation
, orstyle
might be more accurate.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Do you think it's any different or better to treat
'1'
as a string vs.1
as a number?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a string is better to avoid any confusion while parsing and serializing the attribute back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a good point. Speaking of... how are we parsing the attribute?