diff --git a/blocks/api/parser.js b/blocks/api/parser.js index 63ad01f98ab358..63af6229e39912 100644 --- a/blocks/api/parser.js +++ b/blocks/api/parser.js @@ -10,6 +10,7 @@ import { pickBy } from 'lodash'; import { parse as grammarParse } from './post.pegjs'; import { getBlockType, getUnknownTypeHandler } from './registration'; import { createBlock } from './factory'; +import { getBeautifulContent, getSaveContent } from './serializer'; /** * Returns the block attributes parsed from raw content. @@ -81,18 +82,59 @@ export function createBlockWithFallback( name, rawContent, attributes ) { // Include in set only if type were determined. // TODO do we ever expect there to not be an unknown type handler? - if ( blockType && ( rawContent.trim() || name !== fallbackBlock ) ) { + if ( blockType && ( rawContent || name !== fallbackBlock ) ) { // TODO allow blocks to opt-in to receiving a tree instead of a string. // Gradually convert all blocks to this new format, then remove the // string serialization. const block = createBlock( name, - getBlockAttributes( blockType, rawContent.trim(), attributes ) + getBlockAttributes( blockType, rawContent, attributes ) ); + + // Validate that the parsed block is valid, meaning that if we were to + // reserialize it given the assumed attributes, the markup matches the + // original value. Otherwise, preserve original to avoid destruction. + block.isValid = isValidBlock( rawContent, blockType, block.attributes ); + if ( ! block.isValid ) { + block.originalContent = rawContent; + } + return block; } } +/** + * Returns true if the parsed block is valid given the input content. A block + * is considered valid if, when serialized with assumed attributes, the content + * matches the original value. + * + * Logs to console in development environments when invalid. + * + * @param {String} rawContent Original block content + * @param {String} blockType Block type + * @param {Object} attributes Parsed block attributes + * @return {Boolean} Whether block is valid + */ +export function isValidBlock( rawContent, blockType, attributes ) { + const [ actual, expected ] = [ + rawContent, + getSaveContent( blockType, attributes ), + ].map( getBeautifulContent ); + + const isValid = ( actual === expected ); + + if ( ! isValid && 'development' === process.env.NODE_ENV ) { + // eslint-disable-next-line no-console + console.error( + 'Invalid block parse\n' + + '\tExpected: ' + expected + '\n' + + '\tActual: ' + actual + ); + } + + return isValid; +} + /** * Parses the post content with a PegJS grammar and returns a list of blocks. * @@ -102,7 +144,7 @@ export function createBlockWithFallback( name, rawContent, attributes ) { export function parseWithGrammar( content ) { return grammarParse( content ).reduce( ( memo, blockNode ) => { const { blockName, rawContent, attrs } = blockNode; - const block = createBlockWithFallback( blockName, rawContent, attrs ); + const block = createBlockWithFallback( blockName, rawContent.trim(), attrs ); if ( block ) { memo.push( block ); } diff --git a/blocks/api/serializer.js b/blocks/api/serializer.js index aed8cb12f3c88e..2657e727c30f56 100644 --- a/blocks/api/serializer.js +++ b/blocks/api/serializer.js @@ -111,10 +111,33 @@ export function serializeAttributes( attrs ) { .replace( /&/g, '\\u0026' ); // ibid } +/** + * Returns HTML markup processed by a markup beautifier configured for use in + * block serialization. + * + * @param {String} content Original HTML + * @return {String} Beautiful HTML + */ +export function getBeautifulContent( content ) { + return beautifyHtml( content, { + indent_inner_html: true, + wrap_line_length: 0, + } ); +} + export function serializeBlock( block ) { const blockName = block.name; const blockType = getBlockType( blockName ); - const saveContent = getSaveContent( blockType, block.attributes ); + + let saveContent; + if ( block.isValid ) { + saveContent = getSaveContent( blockType, block.attributes ); + } else { + // If block was parsed as invalid, skip serialization behavior and opt + // to use original content instead so we don't destroy user content. + saveContent = block.originalContent; + } + const saveAttributes = getCommentAttributes( block.attributes, parseBlockAttributes( saveContent, blockType.attributes ) ); if ( 'wp:core/more' === blockName ) { @@ -131,13 +154,7 @@ export function serializeBlock( block ) { return ( `\n` + - - /** make more readable - @see https://github.com/WordPress/gutenberg/pull/663 */ - beautifyHtml( saveContent, { - indent_inner_html: true, - wrap_line_length: 0, - } ) + - + getBeautifulContent( saveContent ) + `\n` ); } diff --git a/blocks/api/test/parser.js b/blocks/api/test/parser.js index 4d2ba513181800..17632802137d79 100644 --- a/blocks/api/test/parser.js +++ b/blocks/api/test/parser.js @@ -10,6 +10,7 @@ import { text } from '../query'; import { getBlockAttributes, parseBlockAttributes, + isValidBlock, createBlockWithFallback, default as parse, } from '../parser'; @@ -17,11 +18,14 @@ import { registerBlockType, unregisterBlockType, getBlockTypes, + getBlockType, setUnknownTypeHandler, } from '../registration'; describe( 'block parser', () => { - const defaultBlockSettings = { save: noop }; + const defaultBlockSettings = { + save: ( { attributes } ) => attributes.fruit, + }; afterEach( () => { setUnknownTypeHandler( undefined ); @@ -89,6 +93,28 @@ describe( 'block parser', () => { } ); } ); + describe( 'isValidBlock()', () => { + it( 'returns false is block is not valid', () => { + registerBlockType( 'core/test-block', defaultBlockSettings ); + + expect( isValidBlock( + 'Apples', + getBlockType( 'core/test-block' ), + { fruit: 'Bananas' } + ) ).toBe( false ); + } ); + + it( 'returns true is block is valid', () => { + registerBlockType( 'core/test-block', defaultBlockSettings ); + + expect( isValidBlock( + 'Bananas', + getBlockType( 'core/test-block' ), + { fruit: 'Bananas' } + ) ).toBe( true ); + } ); + } ); + describe( 'createBlockWithFallback', () => { it( 'should create the requested block if it exists', () => { registerBlockType( 'core/test-block', defaultBlockSettings ); diff --git a/blocks/api/test/serializer.js b/blocks/api/test/serializer.js index 73705b0846c108..97dda9b7ea30a3 100644 --- a/blocks/api/test/serializer.js +++ b/blocks/api/test/serializer.js @@ -6,7 +6,12 @@ import { createElement, Component } from 'element'; /** * Internal dependencies */ -import serialize, { getCommentAttributes, getSaveContent, serializeAttributes } from '../serializer'; +import serialize, { + getCommentAttributes, + getBeautifulContent, + getSaveContent, + serializeAttributes, +} from '../serializer'; import { getBlockTypes, registerBlockType, unregisterBlockType } from '../registration'; describe( 'block serializer', () => { @@ -16,6 +21,14 @@ describe( 'block serializer', () => { } ); } ); + describe( 'getBeautifulContent()', () => { + it( 'returns beautiful content', () => { + const content = getBeautifulContent( '
Beautiful
' ); + + expect( content ).toBe( '
\n
Beautiful
\n
' ); + } ); + } ); + describe( 'getSaveContent()', () => { describe( 'function save', () => { it( 'should return string verbatim', () => { @@ -185,6 +198,7 @@ describe( 'block serializer', () => { content: 'Ribs & Chicken', stuff: 'left & right -- but ', }, + isValid: true, }, ]; const expectedPostContent = '\n

Ribs & Chicken

\n'; diff --git a/blocks/test/fixtures/core-embed__animoto.json b/blocks/test/fixtures/core-embed__animoto.json index 28c7c26cd2cc2a..71eac6be8e7561 100644 --- a/blocks/test/fixtures/core-embed__animoto.json +++ b/blocks/test/fixtures/core-embed__animoto.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from animoto" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__animoto.serialized.html b/blocks/test/fixtures/core-embed__animoto.serialized.html index e6af9836343d1e..2d00b4dc7b234c 100644 --- a/blocks/test/fixtures/core-embed__animoto.serialized.html +++ b/blocks/test/fixtures/core-embed__animoto.serialized.html @@ -3,4 +3,4 @@ https://animoto.com/
Embedded content from animoto
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__cloudup.json b/blocks/test/fixtures/core-embed__cloudup.json index 22a55a4d296f99..5d5041cae3fdae 100644 --- a/blocks/test/fixtures/core-embed__cloudup.json +++ b/blocks/test/fixtures/core-embed__cloudup.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from cloudup" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__cloudup.serialized.html b/blocks/test/fixtures/core-embed__cloudup.serialized.html index 48f824b9c95cfa..8317513dabbaea 100644 --- a/blocks/test/fixtures/core-embed__cloudup.serialized.html +++ b/blocks/test/fixtures/core-embed__cloudup.serialized.html @@ -3,4 +3,4 @@ https://cloudup.com/
Embedded content from cloudup
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__collegehumor.json b/blocks/test/fixtures/core-embed__collegehumor.json index 47cff93865c5fa..710ee963585829 100644 --- a/blocks/test/fixtures/core-embed__collegehumor.json +++ b/blocks/test/fixtures/core-embed__collegehumor.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from collegehumor" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__collegehumor.serialized.html b/blocks/test/fixtures/core-embed__collegehumor.serialized.html index e6870f568d0a78..e55060027e7e63 100644 --- a/blocks/test/fixtures/core-embed__collegehumor.serialized.html +++ b/blocks/test/fixtures/core-embed__collegehumor.serialized.html @@ -3,4 +3,4 @@ https://collegehumor.com/
Embedded content from collegehumor
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__dailymotion.json b/blocks/test/fixtures/core-embed__dailymotion.json index 4ad16679bf20e9..90d547507833fa 100644 --- a/blocks/test/fixtures/core-embed__dailymotion.json +++ b/blocks/test/fixtures/core-embed__dailymotion.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from dailymotion" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__dailymotion.serialized.html b/blocks/test/fixtures/core-embed__dailymotion.serialized.html index 1cf35255677705..17a3680bf33bc1 100644 --- a/blocks/test/fixtures/core-embed__dailymotion.serialized.html +++ b/blocks/test/fixtures/core-embed__dailymotion.serialized.html @@ -3,4 +3,4 @@ https://dailymotion.com/
Embedded content from dailymotion
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__facebook.json b/blocks/test/fixtures/core-embed__facebook.json index 07e08896c62b42..3b91660cfbd3a2 100644 --- a/blocks/test/fixtures/core-embed__facebook.json +++ b/blocks/test/fixtures/core-embed__facebook.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from facebook" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__facebook.serialized.html b/blocks/test/fixtures/core-embed__facebook.serialized.html index a2dd1ce7dd9e9b..b0134a99a6a295 100644 --- a/blocks/test/fixtures/core-embed__facebook.serialized.html +++ b/blocks/test/fixtures/core-embed__facebook.serialized.html @@ -3,4 +3,4 @@ https://facebook.com/
Embedded content from facebook
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__flickr.json b/blocks/test/fixtures/core-embed__flickr.json index 35c28ec6b70e2f..2b264a5aff0e2a 100644 --- a/blocks/test/fixtures/core-embed__flickr.json +++ b/blocks/test/fixtures/core-embed__flickr.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from flickr" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__flickr.serialized.html b/blocks/test/fixtures/core-embed__flickr.serialized.html index b6d133afc5d35f..060005490065c3 100644 --- a/blocks/test/fixtures/core-embed__flickr.serialized.html +++ b/blocks/test/fixtures/core-embed__flickr.serialized.html @@ -3,4 +3,4 @@ https://flickr.com/
Embedded content from flickr
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__funnyordie.json b/blocks/test/fixtures/core-embed__funnyordie.json index 575ed6342f43b6..24907395f8f526 100644 --- a/blocks/test/fixtures/core-embed__funnyordie.json +++ b/blocks/test/fixtures/core-embed__funnyordie.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from funnyordie" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__funnyordie.serialized.html b/blocks/test/fixtures/core-embed__funnyordie.serialized.html index 21b1f2bf4aacfe..5d6cf0e352f29f 100644 --- a/blocks/test/fixtures/core-embed__funnyordie.serialized.html +++ b/blocks/test/fixtures/core-embed__funnyordie.serialized.html @@ -3,4 +3,4 @@ https://funnyordie.com/
Embedded content from funnyordie
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__hulu.json b/blocks/test/fixtures/core-embed__hulu.json index 35baceb73b1c0c..d2c9744e06a946 100644 --- a/blocks/test/fixtures/core-embed__hulu.json +++ b/blocks/test/fixtures/core-embed__hulu.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from hulu" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__hulu.serialized.html b/blocks/test/fixtures/core-embed__hulu.serialized.html index 29a851edcdd0b3..54fed29b9abf03 100644 --- a/blocks/test/fixtures/core-embed__hulu.serialized.html +++ b/blocks/test/fixtures/core-embed__hulu.serialized.html @@ -3,4 +3,4 @@ https://hulu.com/
Embedded content from hulu
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__imgur.json b/blocks/test/fixtures/core-embed__imgur.json index ea3b38321bec05..7ad645a4371c89 100644 --- a/blocks/test/fixtures/core-embed__imgur.json +++ b/blocks/test/fixtures/core-embed__imgur.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from imgur" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__imgur.serialized.html b/blocks/test/fixtures/core-embed__imgur.serialized.html index 9a05b120d43947..982e490a212f43 100644 --- a/blocks/test/fixtures/core-embed__imgur.serialized.html +++ b/blocks/test/fixtures/core-embed__imgur.serialized.html @@ -3,4 +3,4 @@ https://imgur.com/
Embedded content from imgur
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__instagram.json b/blocks/test/fixtures/core-embed__instagram.json index b47836c1c0daa2..9ddaf1fbaf6306 100644 --- a/blocks/test/fixtures/core-embed__instagram.json +++ b/blocks/test/fixtures/core-embed__instagram.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from instagram" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__instagram.serialized.html b/blocks/test/fixtures/core-embed__instagram.serialized.html index bb2c9f04c0dbc8..cbbac9624ab3ea 100644 --- a/blocks/test/fixtures/core-embed__instagram.serialized.html +++ b/blocks/test/fixtures/core-embed__instagram.serialized.html @@ -3,4 +3,4 @@ https://instagram.com/
Embedded content from instagram
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__issuu.json b/blocks/test/fixtures/core-embed__issuu.json index 868cd489e5c387..448529e6a8e3a0 100644 --- a/blocks/test/fixtures/core-embed__issuu.json +++ b/blocks/test/fixtures/core-embed__issuu.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from issuu" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__issuu.serialized.html b/blocks/test/fixtures/core-embed__issuu.serialized.html index 890348374d3985..af0b652be674d2 100644 --- a/blocks/test/fixtures/core-embed__issuu.serialized.html +++ b/blocks/test/fixtures/core-embed__issuu.serialized.html @@ -3,4 +3,4 @@ https://issuu.com/
Embedded content from issuu
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__kickstarter.json b/blocks/test/fixtures/core-embed__kickstarter.json index e917cfa1e3385e..4b083df44ac415 100644 --- a/blocks/test/fixtures/core-embed__kickstarter.json +++ b/blocks/test/fixtures/core-embed__kickstarter.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from kickstarter" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__kickstarter.serialized.html b/blocks/test/fixtures/core-embed__kickstarter.serialized.html index f3034e6fd96881..cf1057c4a93cd9 100644 --- a/blocks/test/fixtures/core-embed__kickstarter.serialized.html +++ b/blocks/test/fixtures/core-embed__kickstarter.serialized.html @@ -3,4 +3,4 @@ https://kickstarter.com/
Embedded content from kickstarter
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__meetup-com.json b/blocks/test/fixtures/core-embed__meetup-com.json index f29968f9082869..9782d21428217c 100644 --- a/blocks/test/fixtures/core-embed__meetup-com.json +++ b/blocks/test/fixtures/core-embed__meetup-com.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from meetup-com" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__meetup-com.serialized.html b/blocks/test/fixtures/core-embed__meetup-com.serialized.html index 60334419efc212..85c17eef67e664 100644 --- a/blocks/test/fixtures/core-embed__meetup-com.serialized.html +++ b/blocks/test/fixtures/core-embed__meetup-com.serialized.html @@ -3,4 +3,4 @@ https://meetup.com/
Embedded content from meetup-com
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__mixcloud.json b/blocks/test/fixtures/core-embed__mixcloud.json index 1594c158acbe68..75d19946fcd4a8 100644 --- a/blocks/test/fixtures/core-embed__mixcloud.json +++ b/blocks/test/fixtures/core-embed__mixcloud.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from mixcloud" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__mixcloud.serialized.html b/blocks/test/fixtures/core-embed__mixcloud.serialized.html index f1945625517031..a31f60256c0ca3 100644 --- a/blocks/test/fixtures/core-embed__mixcloud.serialized.html +++ b/blocks/test/fixtures/core-embed__mixcloud.serialized.html @@ -3,4 +3,4 @@ https://mixcloud.com/
Embedded content from mixcloud
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__photobucket.json b/blocks/test/fixtures/core-embed__photobucket.json index f8c2148cbcc77a..45f21b77c80236 100644 --- a/blocks/test/fixtures/core-embed__photobucket.json +++ b/blocks/test/fixtures/core-embed__photobucket.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from photobucket" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__photobucket.serialized.html b/blocks/test/fixtures/core-embed__photobucket.serialized.html index af884e8a6be15d..994303b105a489 100644 --- a/blocks/test/fixtures/core-embed__photobucket.serialized.html +++ b/blocks/test/fixtures/core-embed__photobucket.serialized.html @@ -3,4 +3,4 @@ https://photobucket.com/
Embedded content from photobucket
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__polldaddy.json b/blocks/test/fixtures/core-embed__polldaddy.json index 05e4cbeaf045c3..db7ad5fb4ca442 100644 --- a/blocks/test/fixtures/core-embed__polldaddy.json +++ b/blocks/test/fixtures/core-embed__polldaddy.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from polldaddy" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__polldaddy.serialized.html b/blocks/test/fixtures/core-embed__polldaddy.serialized.html index 32b560621b43ca..3e46fcad5579da 100644 --- a/blocks/test/fixtures/core-embed__polldaddy.serialized.html +++ b/blocks/test/fixtures/core-embed__polldaddy.serialized.html @@ -3,4 +3,4 @@ https://polldaddy.com/
Embedded content from polldaddy
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__reddit.json b/blocks/test/fixtures/core-embed__reddit.json index a04125b76926be..4a6f21f8b975cd 100644 --- a/blocks/test/fixtures/core-embed__reddit.json +++ b/blocks/test/fixtures/core-embed__reddit.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from reddit" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__reddit.serialized.html b/blocks/test/fixtures/core-embed__reddit.serialized.html index d498ea438065d9..bc9bc4ca9cc596 100644 --- a/blocks/test/fixtures/core-embed__reddit.serialized.html +++ b/blocks/test/fixtures/core-embed__reddit.serialized.html @@ -3,4 +3,4 @@ https://reddit.com/
Embedded content from reddit
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__reverbnation.json b/blocks/test/fixtures/core-embed__reverbnation.json index de0f5c62ef564d..404380fdb0703d 100644 --- a/blocks/test/fixtures/core-embed__reverbnation.json +++ b/blocks/test/fixtures/core-embed__reverbnation.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from reverbnation" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__reverbnation.serialized.html b/blocks/test/fixtures/core-embed__reverbnation.serialized.html index 3897cf035426b0..482b5406ae7436 100644 --- a/blocks/test/fixtures/core-embed__reverbnation.serialized.html +++ b/blocks/test/fixtures/core-embed__reverbnation.serialized.html @@ -3,4 +3,4 @@ https://reverbnation.com/
Embedded content from reverbnation
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__screencast.json b/blocks/test/fixtures/core-embed__screencast.json index a34839a87c2435..77d5edcd8113c1 100644 --- a/blocks/test/fixtures/core-embed__screencast.json +++ b/blocks/test/fixtures/core-embed__screencast.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from screencast" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__screencast.serialized.html b/blocks/test/fixtures/core-embed__screencast.serialized.html index 31a004a6d1c1ec..9f583032659b90 100644 --- a/blocks/test/fixtures/core-embed__screencast.serialized.html +++ b/blocks/test/fixtures/core-embed__screencast.serialized.html @@ -3,4 +3,4 @@ https://screencast.com/
Embedded content from screencast
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__scribd.json b/blocks/test/fixtures/core-embed__scribd.json index 81789fe717be3a..d87c507dc25bf4 100644 --- a/blocks/test/fixtures/core-embed__scribd.json +++ b/blocks/test/fixtures/core-embed__scribd.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from scribd" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__scribd.serialized.html b/blocks/test/fixtures/core-embed__scribd.serialized.html index 5adcd8d0a55ae0..7769847c701ffe 100644 --- a/blocks/test/fixtures/core-embed__scribd.serialized.html +++ b/blocks/test/fixtures/core-embed__scribd.serialized.html @@ -3,4 +3,4 @@ https://scribd.com/
Embedded content from scribd
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__slideshare.json b/blocks/test/fixtures/core-embed__slideshare.json index db0f30df975a9f..da9fa1915a7443 100644 --- a/blocks/test/fixtures/core-embed__slideshare.json +++ b/blocks/test/fixtures/core-embed__slideshare.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from slideshare" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__slideshare.serialized.html b/blocks/test/fixtures/core-embed__slideshare.serialized.html index 1149779e78c7e9..3fafcb4dc63425 100644 --- a/blocks/test/fixtures/core-embed__slideshare.serialized.html +++ b/blocks/test/fixtures/core-embed__slideshare.serialized.html @@ -3,4 +3,4 @@ https://slideshare.com/
Embedded content from slideshare
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__smugmug.json b/blocks/test/fixtures/core-embed__smugmug.json index 5b705c05e5c7d5..0dd566a0ea7487 100644 --- a/blocks/test/fixtures/core-embed__smugmug.json +++ b/blocks/test/fixtures/core-embed__smugmug.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from smugmug" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__smugmug.serialized.html b/blocks/test/fixtures/core-embed__smugmug.serialized.html index 01abea919b0d1b..fe3cf00c3fff24 100644 --- a/blocks/test/fixtures/core-embed__smugmug.serialized.html +++ b/blocks/test/fixtures/core-embed__smugmug.serialized.html @@ -3,4 +3,4 @@ https://smugmug.com/
Embedded content from smugmug
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__soundcloud.json b/blocks/test/fixtures/core-embed__soundcloud.json index 210360add6681b..dae423da3935cf 100644 --- a/blocks/test/fixtures/core-embed__soundcloud.json +++ b/blocks/test/fixtures/core-embed__soundcloud.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from soundcloud" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__soundcloud.serialized.html b/blocks/test/fixtures/core-embed__soundcloud.serialized.html index f5414ef81c99cf..4e11ca9e13f54d 100644 --- a/blocks/test/fixtures/core-embed__soundcloud.serialized.html +++ b/blocks/test/fixtures/core-embed__soundcloud.serialized.html @@ -3,4 +3,4 @@ https://soundcloud.com/
Embedded content from soundcloud
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__speaker.json b/blocks/test/fixtures/core-embed__speaker.json index 7fea3ba89edbde..8ec77be522d1bc 100644 --- a/blocks/test/fixtures/core-embed__speaker.json +++ b/blocks/test/fixtures/core-embed__speaker.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from speaker" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__speaker.serialized.html b/blocks/test/fixtures/core-embed__speaker.serialized.html index 2e3b4592cbc357..d98ad1a2e744ec 100644 --- a/blocks/test/fixtures/core-embed__speaker.serialized.html +++ b/blocks/test/fixtures/core-embed__speaker.serialized.html @@ -3,4 +3,4 @@ https://speaker.com/
Embedded content from speaker
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__spotify.json b/blocks/test/fixtures/core-embed__spotify.json index 2e1076dbb0c5fd..431f3c2884b494 100644 --- a/blocks/test/fixtures/core-embed__spotify.json +++ b/blocks/test/fixtures/core-embed__spotify.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from spotify" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__spotify.serialized.html b/blocks/test/fixtures/core-embed__spotify.serialized.html index 1fc73903acb3e1..4872c2a4ed9d99 100644 --- a/blocks/test/fixtures/core-embed__spotify.serialized.html +++ b/blocks/test/fixtures/core-embed__spotify.serialized.html @@ -3,4 +3,4 @@ https://spotify.com/
Embedded content from spotify
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__ted.json b/blocks/test/fixtures/core-embed__ted.json index 5011154882c69f..43d815e12eeea2 100644 --- a/blocks/test/fixtures/core-embed__ted.json +++ b/blocks/test/fixtures/core-embed__ted.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from ted" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__ted.serialized.html b/blocks/test/fixtures/core-embed__ted.serialized.html index 01eae201b6b924..164b87706001eb 100644 --- a/blocks/test/fixtures/core-embed__ted.serialized.html +++ b/blocks/test/fixtures/core-embed__ted.serialized.html @@ -3,4 +3,4 @@ https://ted.com/
Embedded content from ted
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__tumblr.json b/blocks/test/fixtures/core-embed__tumblr.json index ba37f49055801d..9c799a519180b4 100644 --- a/blocks/test/fixtures/core-embed__tumblr.json +++ b/blocks/test/fixtures/core-embed__tumblr.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from tumblr" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__tumblr.serialized.html b/blocks/test/fixtures/core-embed__tumblr.serialized.html index d558986629124a..f69836f3c01147 100644 --- a/blocks/test/fixtures/core-embed__tumblr.serialized.html +++ b/blocks/test/fixtures/core-embed__tumblr.serialized.html @@ -3,4 +3,4 @@ https://tumblr.com/
Embedded content from tumblr
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__twitter.json b/blocks/test/fixtures/core-embed__twitter.json index ff35783fbeeaa9..41aa2a510a114d 100644 --- a/blocks/test/fixtures/core-embed__twitter.json +++ b/blocks/test/fixtures/core-embed__twitter.json @@ -7,6 +7,7 @@ "caption": [ "We are Automattic" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__twitter.serialized.html b/blocks/test/fixtures/core-embed__twitter.serialized.html index 155eaaccbfcd04..537f6e359be2fe 100644 --- a/blocks/test/fixtures/core-embed__twitter.serialized.html +++ b/blocks/test/fixtures/core-embed__twitter.serialized.html @@ -3,4 +3,4 @@ https://twitter.com/automattic
We are Automattic
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__videopress.json b/blocks/test/fixtures/core-embed__videopress.json index 65e9458e95d877..49f639f7648b7c 100644 --- a/blocks/test/fixtures/core-embed__videopress.json +++ b/blocks/test/fixtures/core-embed__videopress.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from videopress" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__videopress.serialized.html b/blocks/test/fixtures/core-embed__videopress.serialized.html index 1b3e5f77597a21..98a77afdee43bf 100644 --- a/blocks/test/fixtures/core-embed__videopress.serialized.html +++ b/blocks/test/fixtures/core-embed__videopress.serialized.html @@ -3,4 +3,4 @@ https://videopress.com/
Embedded content from videopress
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__vimeo.json b/blocks/test/fixtures/core-embed__vimeo.json index a1f215beed6a8b..c8ad403ddd7e08 100644 --- a/blocks/test/fixtures/core-embed__vimeo.json +++ b/blocks/test/fixtures/core-embed__vimeo.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from vimeo" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__vimeo.serialized.html b/blocks/test/fixtures/core-embed__vimeo.serialized.html index 7f1a6d8889aa5d..76df2dfff0c2ed 100644 --- a/blocks/test/fixtures/core-embed__vimeo.serialized.html +++ b/blocks/test/fixtures/core-embed__vimeo.serialized.html @@ -3,4 +3,4 @@ https://vimeo.com/
Embedded content from vimeo
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__vine.json b/blocks/test/fixtures/core-embed__vine.json index af44e8956044ca..2dee557086683a 100644 --- a/blocks/test/fixtures/core-embed__vine.json +++ b/blocks/test/fixtures/core-embed__vine.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from vine" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__vine.serialized.html b/blocks/test/fixtures/core-embed__vine.serialized.html index 2681598e22b3fd..504267ab8fbca4 100644 --- a/blocks/test/fixtures/core-embed__vine.serialized.html +++ b/blocks/test/fixtures/core-embed__vine.serialized.html @@ -3,4 +3,4 @@ https://vine.com/
Embedded content from vine
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__wordpress-tv.json b/blocks/test/fixtures/core-embed__wordpress-tv.json index 8bf8d711faad06..ffacbfb1e479db 100644 --- a/blocks/test/fixtures/core-embed__wordpress-tv.json +++ b/blocks/test/fixtures/core-embed__wordpress-tv.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from wordpress-tv" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__wordpress-tv.serialized.html b/blocks/test/fixtures/core-embed__wordpress-tv.serialized.html index 5fbb3ea107940a..72683e8a4a1a9e 100644 --- a/blocks/test/fixtures/core-embed__wordpress-tv.serialized.html +++ b/blocks/test/fixtures/core-embed__wordpress-tv.serialized.html @@ -3,4 +3,4 @@ https://wordpress.tv/
Embedded content from wordpress-tv
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__wordpress.json b/blocks/test/fixtures/core-embed__wordpress.json index eb24c5f14258d0..041a2167384624 100644 --- a/blocks/test/fixtures/core-embed__wordpress.json +++ b/blocks/test/fixtures/core-embed__wordpress.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from WordPress" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__wordpress.serialized.html b/blocks/test/fixtures/core-embed__wordpress.serialized.html index 1543bb764978bd..e6aa8db231881a 100644 --- a/blocks/test/fixtures/core-embed__wordpress.serialized.html +++ b/blocks/test/fixtures/core-embed__wordpress.serialized.html @@ -3,4 +3,4 @@ https://wordpress.com/
Embedded content from WordPress
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core-embed__youtube.json b/blocks/test/fixtures/core-embed__youtube.json index e03983346dcee9..34a7768e4b612b 100644 --- a/blocks/test/fixtures/core-embed__youtube.json +++ b/blocks/test/fixtures/core-embed__youtube.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from youtube" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core-embed__youtube.serialized.html b/blocks/test/fixtures/core-embed__youtube.serialized.html index bf575266319a1d..d645549fc87830 100644 --- a/blocks/test/fixtures/core-embed__youtube.serialized.html +++ b/blocks/test/fixtures/core-embed__youtube.serialized.html @@ -3,4 +3,4 @@ https://youtube.com/
Embedded content from youtube
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core__button__center.json b/blocks/test/fixtures/core__button__center.json index 6a257c42322e77..ab6d2a2e4babc4 100644 --- a/blocks/test/fixtures/core__button__center.json +++ b/blocks/test/fixtures/core__button__center.json @@ -8,6 +8,7 @@ "text": [ "Help build Gutenberg" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core__button__center.serialized.html b/blocks/test/fixtures/core__button__center.serialized.html index 0376ad37ecc3cb..8e085b558c48f6 100644 --- a/blocks/test/fixtures/core__button__center.serialized.html +++ b/blocks/test/fixtures/core__button__center.serialized.html @@ -1,3 +1,3 @@
Help build Gutenberg
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core__code.json b/blocks/test/fixtures/core__code.json index 4d2fc33c743b73..9a0d8b4ec10a3c 100644 --- a/blocks/test/fixtures/core__code.json +++ b/blocks/test/fixtures/core__code.json @@ -4,6 +4,7 @@ "name": "core/code", "attributes": { "content": "export default function MyButton() {\n\treturn ;\n}" - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core__code.serialized.html b/blocks/test/fixtures/core__code.serialized.html index 5d3f951c17f71c..ba8ea3bed4cbdd 100644 --- a/blocks/test/fixtures/core__code.serialized.html +++ b/blocks/test/fixtures/core__code.serialized.html @@ -2,4 +2,4 @@
export default function MyButton() {
 	return <Button>Click Me!</Button>;
 }
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core__cover-image.json b/blocks/test/fixtures/core__cover-image.json index e76615bc0388e9..513aedf310c6b7 100644 --- a/blocks/test/fixtures/core__cover-image.json +++ b/blocks/test/fixtures/core__cover-image.json @@ -5,6 +5,7 @@ "attributes": { "url": "https://cldup.com/uuUqE_dXzy.jpg", "title": "Guten Berg!" - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core__cover-image.serialized.html b/blocks/test/fixtures/core__cover-image.serialized.html index 71dbaaf017f04c..e56ce920fbf162 100644 --- a/blocks/test/fixtures/core__cover-image.serialized.html +++ b/blocks/test/fixtures/core__cover-image.serialized.html @@ -4,4 +4,4 @@

Guten Berg!

- + \ No newline at end of file diff --git a/blocks/test/fixtures/core__embed.json b/blocks/test/fixtures/core__embed.json index f9f5ee6c346cda..0182b54a730fe4 100644 --- a/blocks/test/fixtures/core__embed.json +++ b/blocks/test/fixtures/core__embed.json @@ -7,6 +7,7 @@ "caption": [ "Embedded content from an example URL" ] - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core__embed.serialized.html b/blocks/test/fixtures/core__embed.serialized.html index a75136b0413ef7..6ec5ef182bce1c 100644 --- a/blocks/test/fixtures/core__embed.serialized.html +++ b/blocks/test/fixtures/core__embed.serialized.html @@ -3,4 +3,4 @@ https://example.com/
Embedded content from an example URL
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core__freeform.json b/blocks/test/fixtures/core__freeform.json index 35efd7b04fd19f..da8f65857a79df 100644 --- a/blocks/test/fixtures/core__freeform.json +++ b/blocks/test/fixtures/core__freeform.json @@ -4,6 +4,7 @@ "name": "core/freeform", "attributes": { "content": "Testing freeform block with some\n
\n\tHTML content\n
" - } + }, + "isValid": true } ] diff --git a/blocks/test/fixtures/core__freeform.serialized.html b/blocks/test/fixtures/core__freeform.serialized.html index 0bf5ad6d0d8292..232ec49ed7ff1c 100644 --- a/blocks/test/fixtures/core__freeform.serialized.html +++ b/blocks/test/fixtures/core__freeform.serialized.html @@ -3,4 +3,4 @@
HTML content
- + \ No newline at end of file diff --git a/blocks/test/fixtures/core__gallery.json b/blocks/test/fixtures/core__gallery.json index aa42f70c3990a2..b31406181c5191 100644 --- a/blocks/test/fixtures/core__gallery.json +++ b/blocks/test/fixtures/core__gallery.json @@ -37,6 +37,8 @@ "alt": "title" } ] - } + }, + "isValid": false, + "originalContent": "
\n\t\n\t\n
" } ] diff --git a/blocks/test/fixtures/core__gallery.serialized.html b/blocks/test/fixtures/core__gallery.serialized.html index f3be93a9cc842e..1d031e16635d3c 100644 --- a/blocks/test/fixtures/core__gallery.serialized.html +++ b/blocks/test/fixtures/core__gallery.serialized.html @@ -1,6 +1,10 @@ -