diff --git a/blocks/api/parser.js b/blocks/api/parser.js index 63ad01f98ab35..63af6229e3991 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 aed8cb12f3c88..2657e727c30f5 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 4d2ba51318180..17632802137d7 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 73705b0846c10..97dda9b7ea30a 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 28c7c26cd2cc2..71eac6be8e756 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 e6af9836343d1..2d00b4dc7b234 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 22a55a4d296f9..5d5041cae3fda 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 48f824b9c95cf..8317513dabbae 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 47cff93865c5f..710ee96358582 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 e6870f568d0a7..e55060027e7e6 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 4ad16679bf20e..90d547507833f 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 1cf3525567770..17a3680bf33bc 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 07e08896c62b4..3b91660cfbd3a 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 a2dd1ce7dd9e9..b0134a99a6a29 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 35c28ec6b70e2..2b264a5aff0e2 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 b6d133afc5d35..060005490065c 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 575ed6342f43b..24907395f8f52 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 21b1f2bf4aacf..5d6cf0e352f29 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 35baceb73b1c0..d2c9744e06a94 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 29a851edcdd0b..54fed29b9abf0 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 ea3b38321bec0..7ad645a4371c8 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 9a05b120d4394..982e490a212f4 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 b47836c1c0daa..9ddaf1fbaf630 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 bb2c9f04c0dbc..cbbac9624ab3e 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 868cd489e5c38..448529e6a8e3a 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 890348374d398..af0b652be674d 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 e917cfa1e3385..4b083df44ac41 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 f3034e6fd9688..cf1057c4a93cd 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 f29968f908286..9782d21428217 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 60334419efc21..85c17eef67e66 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 1594c158acbe6..75d19946fcd4a 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 f194562551703..a31f60256c0ca 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 f8c2148cbcc77..45f21b77c8023 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 af884e8a6be15..994303b105a48 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 05e4cbeaf045c..db7ad5fb4ca44 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 32b560621b43c..3e46fcad5579d 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 a04125b76926b..4a6f21f8b975c 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 d498ea438065d..bc9bc4ca9cc59 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 de0f5c62ef564..404380fdb0703 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 3897cf035426b..482b5406ae743 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 a34839a87c243..77d5edcd8113c 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 31a004a6d1c1e..9f583032659b9 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 81789fe717be3..d87c507dc25bf 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 5adcd8d0a55ae..7769847c701ff 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 db0f30df975a9..da9fa1915a744 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 1149779e78c7e..3fafcb4dc6342 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 5b705c05e5c7d..0dd566a0ea748 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 01abea919b0d1..fe3cf00c3fff2 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 210360add6681..dae423da3935c 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 f5414ef81c99c..4e11ca9e13f54 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 7fea3ba89edbd..8ec77be522d1b 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 2e3b4592cbc35..d98ad1a2e744e 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 2e1076dbb0c5f..431f3c2884b49 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 1fc73903acb3e..4872c2a4ed9d9 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 5011154882c69..43d815e12eeea 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 01eae201b6b92..164b87706001e 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 ba37f49055801..9c799a519180b 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 d558986629124..f69836f3c0114 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 ff35783fbeeaa..41aa2a510a114 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 155eaaccbfcd0..537f6e359be2f 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 65e9458e95d87..49f639f7648b7 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 1b3e5f77597a2..98a77afdee43b 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 a1f215beed6a8..c8ad403ddd7e0 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 7f1a6d8889aa5..76df2dfff0c2e 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 af44e8956044c..2dee557086683 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 2681598e22b3f..504267ab8fbca 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 8bf8d711faad0..ffacbfb1e479d 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 5fbb3ea107940..72683e8a4a1a9 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 eb24c5f14258d..041a216738462 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 1543bb764978b..e6aa8db231881 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 e03983346dcee..34a7768e4b612 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 bf575266319a1..d645549fc8783 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 6a257c42322e7..ab6d2a2e4babc 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 0376ad37ecc3c..8e085b558c48f 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 4d2fc33c743b7..9a0d8b4ec10a3 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 5d3f951c17f71..ba8ea3bed4cbd 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 e76615bc0388e..513aedf310c6b 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 71dbaaf017f04..e56ce920fbf16 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 f9f5ee6c346cd..0182b54a730fe 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 a75136b0413ef..6ec5ef182bce1 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 35efd7b04fd19..da8f65857a79d 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 0bf5ad6d0d829..232ec49ed7ff1 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 aa42f70c3990a..b31406181c519 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 f3be93a9cc842..1d031e16635d3 100644 --- a/blocks/test/fixtures/core__gallery.serialized.html +++ b/blocks/test/fixtures/core__gallery.serialized.html @@ -1,6 +1,10 @@ -