Skip to content

Commit

Permalink
Merge branch 'amp-stories-redux' into amp-story/1963-call-to-action
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Apr 4, 2019
2 parents 98c24dd + bd02987 commit 256522e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
8 changes: 5 additions & 3 deletions assets/css/amp-stories.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ amp-story-grid-layer[template="fill"] .wp-block-image { margin: 0; }
color: inherit;
}

.is-style-rounded {
.is-style-rounded,
.is-style-rounded img {
border-radius: 5px;
}
.is-style-rounded img {
border-radius: 5px;

.is-style-half-rounded {
border-radius: 4px 4px 26px 26px;
}
5 changes: 5 additions & 0 deletions assets/src/amp-story-editor-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ domReady( () => {
label: __( 'Rounded', 'amp' ),
} );

registerBlockStyle( 'amp/amp-story-text', {
name: 'half-rounded',
label: __( 'Half Rounded', 'amp' ),
} );

registerBlockStyle( 'core/image', {
name: 'rounded',
label: __( 'Rounded', 'amp' ),
Expand Down
12 changes: 10 additions & 2 deletions assets/src/blocks/amp-story-text/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,16 @@ class TextBlockEdit extends Component {
identifier="content"
wrapperClassName="wp-block-amp-story-text"
tagName="p"
value={ content }
onChange={ ( value ) => setAttributes( { content: value } ) }
// Ensure line breaks are normalised to HTML.
value={ content.replace( /\n/g, '<br>' ) }
onChange={ ( nextContent ) => {
setAttributes( {
// Ensure line breaks are normalised to characters. This
// saves space, is easier to read, and ensures display
// filters work correctly.
content: nextContent.replace( /<br ?\/?>/g, '\n' ),
} );
} }
onReplace={ this.onReplace }
style={ {
backgroundColor: backgroundColor.color,
Expand Down
2 changes: 2 additions & 0 deletions includes/class-amp-story-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,8 @@ function ( $font ) use ( $name ) {
public static function render_block_with_google_fonts( $props, $content ) {
$prop_name = 'ampFontFamily';

$content = nl2br( $content, false );

// Short-circuit if no font family present.
if ( empty( $props[ $prop_name ] ) ) {
return $content;
Expand Down
3 changes: 3 additions & 0 deletions tests/test-class-amp-service-worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ function () {
$this->assertEquals( 'exited', $exception->getMessage() );
$output = ob_get_clean();
$this->assertContains( '<script>navigator.serviceWorker.register', $output );

// Go back home to clean up 🤷!
$this->go_to( home_url() );
}

}

0 comments on commit 256522e

Please sign in to comment.