Skip to content

Commit

Permalink
Parse quote style number out of saved markup
Browse files Browse the repository at this point in the history
  • Loading branch information
nylen committed Apr 21, 2017
1 parent 33e7ef9 commit 02e832c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions blocks/library/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './style.scss';
import { registerBlock, query as hpq } from 'api';
import Editable from 'components/editable';

const { parse, html, query } = hpq;
const { parse, html, query, attr } = hpq;

const fromValueToParagraphs = ( value ) => value ? value.map( ( paragraph ) => `<p>${ paragraph }</p>` ).join( '' ) : '';
const fromParagraphsToValue = ( paragraphs ) => parse( paragraphs, query( 'p', html() ) );
Expand All @@ -17,7 +17,13 @@ registerBlock( 'core/quote', {

attributes: {
value: query( 'blockquote > p', html() ),
citation: html( 'footer' )
citation: html( 'footer' ),
style: node => {
const value = attr( 'blockquote', 'class' )( node );
console.log( value );
const match = value.match( /\bblocks-quote-style-(\d+)\b/ );
return match ? +match[ 1 ] : null;
},
},

controls: [ 1, 2 ].map( ( variation ) => ( {
Expand Down
2 changes: 1 addition & 1 deletion languages/gutenberg.pot
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ msgstr ""
msgid "Quote"
msgstr ""

#: blocks/library/quote/index.js:25
#: blocks/library/quote/index.js:31
msgid "Quote style %d"
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion post-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ window._wpGutenbergPost = {
'<!-- /wp:core/text -->',

'<!-- wp:core/quote -->',
'<blockquote><p>Real artists ship.</p><footer><p><a href="http://www.folklore.org/StoryView.py?story=Real_Artists_Ship.txt">Steve Jobs, 1983</a></p></footer></blockquote>',
'<blockquote class="blocks-quote-style-2"><p>Real artists ship.</p><footer><p><a href="http://www.folklore.org/StoryView.py?story=Real_Artists_Ship.txt">Steve Jobs, 1983</a></p></footer></blockquote>',
'<!-- /wp:core/quote -->',

'<!-- wp:core/image -->',
Expand Down

0 comments on commit 02e832c

Please sign in to comment.