diff --git a/lib/parser.php b/lib/parser.php index 330249196861a0..85ca8213c3e60b 100644 --- a/lib/parser.php +++ b/lib/parser.php @@ -259,20 +259,22 @@ private function peg_f1($pre, $bs, $post) { return peg_join_blocks( $pre, $bs, $ private function peg_f2($blockName, $a) { return $a; } private function peg_f3($blockName, $attrs) { return array( - 'blockName' => $blockName, - 'attrs' => isset( $attrs ) ? $attrs : array(), - 'innerBlocks' => array(), - 'innerHTML' => '', + 'blockName' => $blockName, + 'attrs' => isset( $attrs ) ? $attrs : array(), + 'innerBlocks' => array(), + 'innerHTML' => '', + 'innerContent' => array(), ); } private function peg_f4($s, $children, $e) { - list( $innerHTML, $innerBlocks ) = peg_array_partition( $children, 'is_string' ); + list( $innerHTML, $innerBlocks, $innerContent ) = peg_process_inner_content( $children ); return array( 'blockName' => $s['blockName'], 'attrs' => $s['attrs'], 'innerBlocks' => $innerBlocks, - 'innerHTML' => implode( '', $innerHTML ), + 'innerHTML' => $innerHTML, + 'innerContent' => $innerContent, ); } private function peg_f5($blockName, $attrs) { @@ -711,36 +713,106 @@ private function peg_parseBlock_Balanced() { $s3 = $this->peg_parseBlock(); if ($s3 === $this->peg_FAILED) { $s3 = $this->peg_currPos; - $s4 = $this->peg_currPos; + $s4 = array(); $s5 = $this->peg_currPos; + $s6 = $this->peg_currPos; $this->peg_silentFails++; - $s6 = $this->peg_parseBlock_End(); + $s7 = $this->peg_parseBlock(); $this->peg_silentFails--; - if ($s6 === $this->peg_FAILED) { - $s5 = null; + if ($s7 === $this->peg_FAILED) { + $s6 = null; + } else { + $this->peg_currPos = $s6; + $s6 = $this->peg_FAILED; + } + if ($s6 !== $this->peg_FAILED) { + $s7 = $this->peg_currPos; + $this->peg_silentFails++; + $s8 = $this->peg_parseBlock_End(); + $this->peg_silentFails--; + if ($s8 === $this->peg_FAILED) { + $s7 = null; + } else { + $this->peg_currPos = $s7; + $s7 = $this->peg_FAILED; + } + if ($s7 !== $this->peg_FAILED) { + if ($this->input_length > $this->peg_currPos) { + $s8 = $this->input_substr($this->peg_currPos, 1); + $this->peg_currPos++; + } else { + $s8 = $this->peg_FAILED; + if ($this->peg_silentFails === 0) { + $this->peg_fail($this->peg_c0); + } + } + if ($s8 !== $this->peg_FAILED) { + $s6 = array($s6, $s7, $s8); + $s5 = $s6; + } else { + $this->peg_currPos = $s5; + $s5 = $this->peg_FAILED; + } + } else { + $this->peg_currPos = $s5; + $s5 = $this->peg_FAILED; + } } else { $this->peg_currPos = $s5; $s5 = $this->peg_FAILED; } if ($s5 !== $this->peg_FAILED) { - if ($this->input_length > $this->peg_currPos) { - $s6 = $this->input_substr($this->peg_currPos, 1); - $this->peg_currPos++; - } else { - $s6 = $this->peg_FAILED; - if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c0); + while ($s5 !== $this->peg_FAILED) { + $s4[] = $s5; + $s5 = $this->peg_currPos; + $s6 = $this->peg_currPos; + $this->peg_silentFails++; + $s7 = $this->peg_parseBlock(); + $this->peg_silentFails--; + if ($s7 === $this->peg_FAILED) { + $s6 = null; + } else { + $this->peg_currPos = $s6; + $s6 = $this->peg_FAILED; + } + if ($s6 !== $this->peg_FAILED) { + $s7 = $this->peg_currPos; + $this->peg_silentFails++; + $s8 = $this->peg_parseBlock_End(); + $this->peg_silentFails--; + if ($s8 === $this->peg_FAILED) { + $s7 = null; + } else { + $this->peg_currPos = $s7; + $s7 = $this->peg_FAILED; + } + if ($s7 !== $this->peg_FAILED) { + if ($this->input_length > $this->peg_currPos) { + $s8 = $this->input_substr($this->peg_currPos, 1); + $this->peg_currPos++; + } else { + $s8 = $this->peg_FAILED; + if ($this->peg_silentFails === 0) { + $this->peg_fail($this->peg_c0); + } + } + if ($s8 !== $this->peg_FAILED) { + $s6 = array($s6, $s7, $s8); + $s5 = $s6; + } else { + $this->peg_currPos = $s5; + $s5 = $this->peg_FAILED; + } + } else { + $this->peg_currPos = $s5; + $s5 = $this->peg_FAILED; + } + } else { + $this->peg_currPos = $s5; + $s5 = $this->peg_FAILED; } - } - if ($s6 !== $this->peg_FAILED) { - $s5 = array($s5, $s6); - $s4 = $s5; - } else { - $this->peg_currPos = $s4; - $s4 = $this->peg_FAILED; } } else { - $this->peg_currPos = $s4; $s4 = $this->peg_FAILED; } if ($s4 !== $this->peg_FAILED) { @@ -754,36 +826,106 @@ private function peg_parseBlock_Balanced() { $s3 = $this->peg_parseBlock(); if ($s3 === $this->peg_FAILED) { $s3 = $this->peg_currPos; - $s4 = $this->peg_currPos; + $s4 = array(); $s5 = $this->peg_currPos; + $s6 = $this->peg_currPos; $this->peg_silentFails++; - $s6 = $this->peg_parseBlock_End(); + $s7 = $this->peg_parseBlock(); $this->peg_silentFails--; - if ($s6 === $this->peg_FAILED) { - $s5 = null; + if ($s7 === $this->peg_FAILED) { + $s6 = null; + } else { + $this->peg_currPos = $s6; + $s6 = $this->peg_FAILED; + } + if ($s6 !== $this->peg_FAILED) { + $s7 = $this->peg_currPos; + $this->peg_silentFails++; + $s8 = $this->peg_parseBlock_End(); + $this->peg_silentFails--; + if ($s8 === $this->peg_FAILED) { + $s7 = null; + } else { + $this->peg_currPos = $s7; + $s7 = $this->peg_FAILED; + } + if ($s7 !== $this->peg_FAILED) { + if ($this->input_length > $this->peg_currPos) { + $s8 = $this->input_substr($this->peg_currPos, 1); + $this->peg_currPos++; + } else { + $s8 = $this->peg_FAILED; + if ($this->peg_silentFails === 0) { + $this->peg_fail($this->peg_c0); + } + } + if ($s8 !== $this->peg_FAILED) { + $s6 = array($s6, $s7, $s8); + $s5 = $s6; + } else { + $this->peg_currPos = $s5; + $s5 = $this->peg_FAILED; + } + } else { + $this->peg_currPos = $s5; + $s5 = $this->peg_FAILED; + } } else { $this->peg_currPos = $s5; $s5 = $this->peg_FAILED; } if ($s5 !== $this->peg_FAILED) { - if ($this->input_length > $this->peg_currPos) { - $s6 = $this->input_substr($this->peg_currPos, 1); - $this->peg_currPos++; - } else { - $s6 = $this->peg_FAILED; - if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c0); + while ($s5 !== $this->peg_FAILED) { + $s4[] = $s5; + $s5 = $this->peg_currPos; + $s6 = $this->peg_currPos; + $this->peg_silentFails++; + $s7 = $this->peg_parseBlock(); + $this->peg_silentFails--; + if ($s7 === $this->peg_FAILED) { + $s6 = null; + } else { + $this->peg_currPos = $s6; + $s6 = $this->peg_FAILED; + } + if ($s6 !== $this->peg_FAILED) { + $s7 = $this->peg_currPos; + $this->peg_silentFails++; + $s8 = $this->peg_parseBlock_End(); + $this->peg_silentFails--; + if ($s8 === $this->peg_FAILED) { + $s7 = null; + } else { + $this->peg_currPos = $s7; + $s7 = $this->peg_FAILED; + } + if ($s7 !== $this->peg_FAILED) { + if ($this->input_length > $this->peg_currPos) { + $s8 = $this->input_substr($this->peg_currPos, 1); + $this->peg_currPos++; + } else { + $s8 = $this->peg_FAILED; + if ($this->peg_silentFails === 0) { + $this->peg_fail($this->peg_c0); + } + } + if ($s8 !== $this->peg_FAILED) { + $s6 = array($s6, $s7, $s8); + $s5 = $s6; + } else { + $this->peg_currPos = $s5; + $s5 = $this->peg_FAILED; + } + } else { + $this->peg_currPos = $s5; + $s5 = $this->peg_FAILED; + } + } else { + $this->peg_currPos = $s5; + $s5 = $this->peg_FAILED; } - } - if ($s6 !== $this->peg_FAILED) { - $s5 = array($s5, $s6); - $s4 = $s5; - } else { - $this->peg_currPos = $s4; - $s4 = $this->peg_FAILED; } } else { - $this->peg_currPos = $s4; $s4 = $this->peg_FAILED; } if ($s4 !== $this->peg_FAILED) { @@ -1441,18 +1583,23 @@ public function parse($input) { // are the same as `json_decode` // array arguments are backwards because of PHP - if ( ! function_exists( 'peg_array_partition' ) ) { - function peg_array_partition( $array, $predicate ) { - $truthy = array(); - $falsey = array(); + if ( ! function_exists( 'peg_process_inner_content' ) ) { + function peg_process_inner_content( $array ) { + $html = ''; + $blocks = array(); + $content = array(); foreach ( $array as $item ) { - call_user_func( $predicate, $item ) - ? $truthy[] = $item - : $falsey[] = $item; + if ( is_string( $item ) ) { + $html .= $item; + $content[] = $item; + } else { + $blocks[] = $item; + $content[] = null; + } } - return array( $truthy, $falsey ); + return array( $html, $blocks, $content ); } } @@ -1465,7 +1612,8 @@ function peg_join_blocks( $pre, $tokens, $post ) { 'blockName' => null, 'attrs' => array(), 'innerBlocks' => array(), - 'innerHTML' => $pre + 'innerHTML' => $pre, + 'innerContent' => array( $pre ), ); } @@ -1479,7 +1627,8 @@ function peg_join_blocks( $pre, $tokens, $post ) { 'blockName' => null, 'attrs' => array(), 'innerBlocks' => array(), - 'innerHTML' => $html + 'innerHTML' => $html, + 'innerContent' => array( $html ), ); } } @@ -1489,7 +1638,8 @@ function peg_join_blocks( $pre, $tokens, $post ) { 'blockName' => null, 'attrs' => array(), 'innerBlocks' => array(), - 'innerHTML' => $post + 'innerHTML' => $post, + 'innerContent' => array( $post ), ); } diff --git a/packages/block-serialization-default-parser/parser.php b/packages/block-serialization-default-parser/parser.php index 9eb8aae492b723..2211cf0c192260 100644 --- a/packages/block-serialization-default-parser/parser.php +++ b/packages/block-serialization-default-parser/parser.php @@ -48,11 +48,26 @@ class WP_Block_Parser_Block { */ public $innerHTML; - function __construct( $name, $attrs, $innerBlocks, $innerHTML ) { + /** + * List of string fragments and null markers where inner blocks were found + * + * @example array( + * 'innerHTML' => 'BeforeInnerAfter', + * 'innerBlocks' => array( block, block ), + * 'innerContent' => array( 'Before', null, 'Inner', null, 'After' ), + * ) + * + * @since 4.2.0 + * @var array + */ + public $innerContent; + + function __construct( $name, $attrs, $innerBlocks, $innerHTML, $innerContent ) { $this->blockName = $name; $this->attrs = $attrs; $this->innerBlocks = $innerBlocks; $this->innerHTML = $innerHTML; + $this->innerContent = $innerContent; } } @@ -252,14 +267,14 @@ function proceed() { ) ); } - $this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ); + $this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ); $this->offset = $start_offset + $token_length; return true; } // otherwise we found an inner block $this->add_inner_block( - new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ), + new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ), $start_offset, $token_length ); @@ -269,7 +284,7 @@ function proceed() { case 'block-opener': // track all newly-opened blocks on the stack array_push( $this->stack, new WP_Block_Parser_Frame( - new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ), + new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ), $start_offset, $token_length, $start_offset + $token_length, @@ -306,7 +321,9 @@ function proceed() { * block and add it as a new innerBlock to the parent */ $stack_top = array_pop( $this->stack ); - $stack_top->block->innerHTML .= substr( $this->document, $stack_top->prev_offset, $start_offset - $stack_top->prev_offset ); + $html = substr( $this->document, $stack_top->prev_offset, $start_offset - $stack_top->prev_offset ); + $stack_top->block->innerHTML .= $html; + $stack_top->block->innerContent[] = $html; $stack_top->prev_offset = $start_offset + $token_length; $this->add_inner_block( @@ -406,7 +423,7 @@ function next_token() { * @return WP_Block_Parser_Block freeform block object */ static function freeform( $innerHTML ) { - return new WP_Block_Parser_Block( null, array(), array(), $innerHTML ); + return new WP_Block_Parser_Block( null, array(), array(), $innerHTML, array( $innerHTML ) ); } /** @@ -441,7 +458,14 @@ function add_freeform( $length = null ) { function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) { $parent = $this->stack[ count( $this->stack ) - 1 ]; $parent->block->innerBlocks[] = $block; - $parent->block->innerHTML .= substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset ); + $html = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset ); + + if ( ! empty( $html ) ) { + $parent->block->innerHTML .= $html; + $parent->block->innerContent[] = $html; + } + + $parent->block->innerContent[] = null; $parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length; } @@ -456,10 +480,15 @@ function add_block_from_stack( $end_offset = null ) { $stack_top = array_pop( $this->stack ); $prev_offset = $stack_top->prev_offset; - $stack_top->block->innerHTML .= isset( $end_offset ) + $html = isset( $end_offset ) ? substr( $this->document, $prev_offset, $end_offset - $prev_offset ) : substr( $this->document, $prev_offset ); + if ( ! empty( $html ) ) { + $stack_top->block->innerHTML .= $html; + $stack_top->block->innerContent[] = $html; + } + if ( isset( $stack_top->leading_html_start ) ) { $this->output[] = (array) self::freeform( substr( $this->document, diff --git a/packages/block-serialization-default-parser/src/index.js b/packages/block-serialization-default-parser/src/index.js index 27dd93bb9fb0f1..577284fc1e539e 100644 --- a/packages/block-serialization-default-parser/src/index.js +++ b/packages/block-serialization-default-parser/src/index.js @@ -4,17 +4,18 @@ let output; let stack; const tokenizer = /)[^])+?}\s+)?(\/)?-->/g; -function Block( blockName, attrs, innerBlocks, innerHTML ) { +function Block( blockName, attrs, innerBlocks, innerHTML, innerContent ) { return { blockName, attrs, innerBlocks, innerHTML, + innerContent, }; } function Freeform( innerHTML ) { - return Block( null, {}, [], innerHTML ); + return Block( null, {}, [], innerHTML, [ innerHTML ] ); } function Frame( block, tokenStart, tokenLength, prevOffset, leadingHtmlStart ) { @@ -84,14 +85,14 @@ function proceed() { if ( null !== leadingHtmlStart ) { output.push( Freeform( document.substr( leadingHtmlStart, startOffset - leadingHtmlStart ) ) ); } - output.push( Block( blockName, attrs, [], '' ) ); + output.push( Block( blockName, attrs, [], '', [] ) ); offset = startOffset + tokenLength; return true; } // otherwise we found an inner block addInnerBlock( - Block( blockName, attrs, [], '' ), + Block( blockName, attrs, [], '', [] ), startOffset, tokenLength, ); @@ -102,7 +103,7 @@ function proceed() { // track all newly-opened blocks on the stack stack.push( Frame( - Block( blockName, attrs, [], '' ), + Block( blockName, attrs, [], '', [] ), startOffset, tokenLength, startOffset + tokenLength, @@ -134,10 +135,9 @@ function proceed() { // otherwise we're nested and we have to close out the current // block and add it as a innerBlock to the parent const stackTop = stack.pop(); - stackTop.block.innerHTML += document.substr( - stackTop.prevOffset, - startOffset - stackTop.prevOffset, - ); + const html = document.substr( stackTop.prevOffset, startOffset - stackTop.prevOffset ); + stackTop.block.innerHTML += html; + stackTop.block.innerContent.push( html ); stackTop.prevOffset = startOffset + tokenLength; addInnerBlock( @@ -230,20 +230,25 @@ function addFreeform( rawLength ) { function addInnerBlock( block, tokenStart, tokenLength, lastOffset ) { const parent = stack[ stack.length - 1 ]; parent.block.innerBlocks.push( block ); - parent.block.innerHTML += document.substr( - parent.prevOffset, - tokenStart - parent.prevOffset, - ); + const html = document.substr( parent.prevOffset, tokenStart - parent.prevOffset ); + + if ( html ) { + parent.block.innerHTML += html; + parent.block.innerContent.push( html ); + } + + parent.block.innerContent.push( null ); parent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength; } function addBlockFromStack( endOffset ) { const { block, leadingHtmlStart, prevOffset, tokenStart } = stack.pop(); - if ( endOffset ) { - block.innerHTML += document.substr( prevOffset, endOffset - prevOffset ); - } else { - block.innerHTML += document.substr( prevOffset ); + const html = endOffset ? document.substr( prevOffset, endOffset - prevOffset ) : document.substr( prevOffset ); + + if ( html ) { + block.innerHTML += html; + block.innerContent.push( html ); } if ( null !== leadingHtmlStart ) { diff --git a/packages/block-serialization-default-parser/test/__snapshots__/index.js.snap b/packages/block-serialization-default-parser/test/__snapshots__/index.js.snap index 5b5abb61a3d2e5..4a6910fa35f61c 100644 --- a/packages/block-serialization-default-parser/test/__snapshots__/index.js.snap +++ b/packages/block-serialization-default-parser/test/__snapshots__/index.js.snap @@ -6,6 +6,9 @@ Array [ "attrs": Object {}, "blockName": "core/more", "innerBlocks": Array [], + "innerContent": Array [ + "", + ], "innerHTML": "", }, ] @@ -17,6 +20,9 @@ Array [ "attrs": Object {}, "blockName": "core/more", "innerBlocks": Array [], + "innerContent": Array [ + "", + ], "innerHTML": "", }, ] diff --git a/packages/block-serialization-spec-parser/grammar.pegjs b/packages/block-serialization-spec-parser/grammar.pegjs index 00d1fec2114136..4bf80d2f6755ac 100644 --- a/packages/block-serialization-spec-parser/grammar.pegjs +++ b/packages/block-serialization-spec-parser/grammar.pegjs @@ -51,18 +51,23 @@ // are the same as `json_decode` // array arguments are backwards because of PHP -if ( ! function_exists( 'peg_array_partition' ) ) { - function peg_array_partition( $array, $predicate ) { - $truthy = array(); - $falsey = array(); +if ( ! function_exists( 'peg_process_inner_content' ) ) { + function peg_process_inner_content( $array ) { + $html = ''; + $blocks = array(); + $content = array(); foreach ( $array as $item ) { - call_user_func( $predicate, $item ) - ? $truthy[] = $item - : $falsey[] = $item; + if ( is_string( $item ) ) { + $html .= $item; + $content[] = $item; + } else { + $blocks[] = $item; + $content[] = null; + } } - return array( $truthy, $falsey ); + return array( $html, $blocks, $content ); } } @@ -75,7 +80,8 @@ if ( ! function_exists( 'peg_join_blocks' ) ) { 'blockName' => null, 'attrs' => array(), 'innerBlocks' => array(), - 'innerHTML' => $pre + 'innerHTML' => $pre, + 'innerContent' => array( $pre ), ); } @@ -89,7 +95,8 @@ if ( ! function_exists( 'peg_join_blocks' ) ) { 'blockName' => null, 'attrs' => array(), 'innerBlocks' => array(), - 'innerHTML' => $html + 'innerHTML' => $html, + 'innerContent' => array( $html ), ); } } @@ -99,7 +106,8 @@ if ( ! function_exists( 'peg_join_blocks' ) ) { 'blockName' => null, 'attrs' => array(), 'innerBlocks' => array(), - 'innerHTML' => $post + 'innerHTML' => $post, + 'innerContent' => array( $post ), ); } @@ -115,6 +123,7 @@ function freeform( s ) { attrs: {}, innerBlocks: [], innerHTML: s, + innerContent: [ s ], }; } @@ -151,22 +160,27 @@ function maybeJSON( s ) { } } -function partition( predicate, list ) { +function processInnerContent( list ) { var i, l, item; - var truthy = []; - var falsey = []; + var html = ''; + var blocks = []; + var content = []; // nod to performance over a simpler reduce // and clone model we could have taken here for ( i = 0, l = list.length; i < l; i++ ) { item = list[ i ]; - predicate( item ) - ? truthy.push( item ) - : falsey.push( item ) + if ( 'string' === typeof item ) { + html += item; + content.push( item ); + } else { + blocks.push( item ); + content.push( null ); + } }; - return [ truthy, falsey ]; + return [ html, blocks, content ]; } } @@ -197,10 +211,11 @@ Block_Void { /** $blockName, - 'attrs' => isset( $attrs ) ? $attrs : array(), - 'innerBlocks' => array(), - 'innerHTML' => '', + 'blockName' => $blockName, + 'attrs' => isset( $attrs ) ? $attrs : array(), + 'innerBlocks' => array(), + 'innerHTML' => '', + 'innerContent' => array(), ); ?> **/ @@ -208,33 +223,37 @@ Block_Void blockName: blockName, attrs: attrs || {}, innerBlocks: [], - innerHTML: '' + innerHTML: '', + innerContent: [] }; } Block_Balanced - = s:Block_Start children:(Block / $(!Block_End .))* e:Block_End + = s:Block_Start children:(Block / $((!Block !Block_End .)+))* e:Block_End { /** $s['blockName'], 'attrs' => $s['attrs'], 'innerBlocks' => $innerBlocks, - 'innerHTML' => implode( '', $innerHTML ), + 'innerHTML' => $innerHTML, + 'innerContent' => $innerContent, ); ?> **/ - var innerContent = partition( function( a ) { return 'string' === typeof a }, children ); - var innerHTML = innerContent[ 0 ]; - var innerBlocks = innerContent[ 1 ]; + var innerParts = processInnerContent( children ); + var innerHTML = innerParts[ 0 ]; + var innerBlocks = innerParts[ 1 ]; + var innerContent = innerParts[ 2 ]; return { blockName: s.blockName, attrs: s.attrs, innerBlocks: innerBlocks, - innerHTML: innerHTML.join( '' ) + innerHTML: innerHTML, + innerContent: innerContent, }; } diff --git a/packages/block-serialization-spec-parser/parser.js b/packages/block-serialization-spec-parser/parser.js index e716efb9e3e8d2..85fdc6ec9b5d65 100644 --- a/packages/block-serialization-spec-parser/parser.js +++ b/packages/block-serialization-spec-parser/parser.js @@ -165,10 +165,11 @@ peg$c10 = function(blockName, attrs) { /** $blockName, - 'attrs' => isset( $attrs ) ? $attrs : array(), - 'innerBlocks' => array(), - 'innerHTML' => '', + 'blockName' => $blockName, + 'attrs' => isset( $attrs ) ? $attrs : array(), + 'innerBlocks' => array(), + 'innerHTML' => '', + 'innerContent' => array(), ); ?> **/ @@ -176,30 +177,34 @@ blockName: blockName, attrs: attrs || {}, innerBlocks: [], - innerHTML: '' + innerHTML: '', + innerContent: [] }; }, peg$c11 = function(s, children, e) { /** $s['blockName'], 'attrs' => $s['attrs'], 'innerBlocks' => $innerBlocks, - 'innerHTML' => implode( '', $innerHTML ), + 'innerHTML' => $innerHTML, + 'innerContent' => $innerContent, ); ?> **/ - var innerContent = partition( function( a ) { return 'string' === typeof a }, children ); - var innerHTML = innerContent[ 0 ]; - var innerBlocks = innerContent[ 1 ]; + var innerParts = processInnerContent( children ); + var innerHTML = innerParts[ 0 ]; + var innerBlocks = innerParts[ 1 ]; + var innerContent = innerParts[ 2 ]; return { blockName: s.blockName, attrs: s.attrs, innerBlocks: innerBlocks, - innerHTML: innerHTML.join( '' ) + innerHTML: innerHTML, + innerContent: innerContent, }; }, peg$c12 = "-->", @@ -784,7 +789,7 @@ } function peg$parseBlock_Balanced() { - var s0, s1, s2, s3, s4, s5, s6; + var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; s1 = peg$parseBlock_Start(); @@ -793,34 +798,102 @@ s3 = peg$parseBlock(); if (s3 === peg$FAILED) { s3 = peg$currPos; - s4 = peg$currPos; + s4 = []; s5 = peg$currPos; + s6 = peg$currPos; peg$silentFails++; - s6 = peg$parseBlock_End(); + s7 = peg$parseBlock(); peg$silentFails--; - if (s6 === peg$FAILED) { - s5 = void 0; + if (s7 === peg$FAILED) { + s6 = void 0; } else { - peg$currPos = s5; - s5 = peg$FAILED; + peg$currPos = s6; + s6 = peg$FAILED; } - if (s5 !== peg$FAILED) { - if (input.length > peg$currPos) { - s6 = input.charAt(peg$currPos); - peg$currPos++; + if (s6 !== peg$FAILED) { + s7 = peg$currPos; + peg$silentFails++; + s8 = peg$parseBlock_End(); + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = void 0; } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c0); } + peg$currPos = s7; + s7 = peg$FAILED; } - if (s6 !== peg$FAILED) { - s5 = [s5, s6]; - s4 = s5; + if (s7 !== peg$FAILED) { + if (input.length > peg$currPos) { + s8 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c0); } + } + if (s8 !== peg$FAILED) { + s6 = [s6, s7, s8]; + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } } else { - peg$currPos = s4; - s4 = peg$FAILED; + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$currPos; + s6 = peg$currPos; + peg$silentFails++; + s7 = peg$parseBlock(); + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = peg$currPos; + peg$silentFails++; + s8 = peg$parseBlock_End(); + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = void 0; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + if (input.length > peg$currPos) { + s8 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c0); } + } + if (s8 !== peg$FAILED) { + s6 = [s6, s7, s8]; + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } } } else { - peg$currPos = s4; s4 = peg$FAILED; } if (s4 !== peg$FAILED) { @@ -834,34 +907,102 @@ s3 = peg$parseBlock(); if (s3 === peg$FAILED) { s3 = peg$currPos; - s4 = peg$currPos; + s4 = []; s5 = peg$currPos; + s6 = peg$currPos; peg$silentFails++; - s6 = peg$parseBlock_End(); + s7 = peg$parseBlock(); peg$silentFails--; - if (s6 === peg$FAILED) { - s5 = void 0; + if (s7 === peg$FAILED) { + s6 = void 0; } else { - peg$currPos = s5; - s5 = peg$FAILED; + peg$currPos = s6; + s6 = peg$FAILED; } - if (s5 !== peg$FAILED) { - if (input.length > peg$currPos) { - s6 = input.charAt(peg$currPos); - peg$currPos++; + if (s6 !== peg$FAILED) { + s7 = peg$currPos; + peg$silentFails++; + s8 = peg$parseBlock_End(); + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = void 0; } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c0); } + peg$currPos = s7; + s7 = peg$FAILED; } - if (s6 !== peg$FAILED) { - s5 = [s5, s6]; - s4 = s5; + if (s7 !== peg$FAILED) { + if (input.length > peg$currPos) { + s8 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c0); } + } + if (s8 !== peg$FAILED) { + s6 = [s6, s7, s8]; + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } } else { - peg$currPos = s4; - s4 = peg$FAILED; + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$currPos; + s6 = peg$currPos; + peg$silentFails++; + s7 = peg$parseBlock(); + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = peg$currPos; + peg$silentFails++; + s8 = peg$parseBlock_End(); + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = void 0; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + if (input.length > peg$currPos) { + s8 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c0); } + } + if (s8 !== peg$FAILED) { + s6 = [s6, s7, s8]; + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } } } else { - peg$currPos = s4; s4 = peg$FAILED; } if (s4 !== peg$FAILED) { @@ -1478,18 +1619,23 @@ // are the same as `json_decode` // array arguments are backwards because of PHP - if ( ! function_exists( 'peg_array_partition' ) ) { - function peg_array_partition( $array, $predicate ) { - $truthy = array(); - $falsey = array(); + if ( ! function_exists( 'peg_process_inner_content' ) ) { + function peg_process_inner_content( $array ) { + $html = ''; + $blocks = array(); + $content = array(); foreach ( $array as $item ) { - call_user_func( $predicate, $item ) - ? $truthy[] = $item - : $falsey[] = $item; + if ( is_string( $item ) ) { + $html .= $item; + $content[] = $item; + } else { + $blocks[] = $item; + $content[] = null; + } } - return array( $truthy, $falsey ); + return array( $html, $blocks, $content ); } } @@ -1502,7 +1648,8 @@ 'blockName' => null, 'attrs' => array(), 'innerBlocks' => array(), - 'innerHTML' => $pre + 'innerHTML' => $pre, + 'innerContent' => array( $pre ), ); } @@ -1516,7 +1663,8 @@ 'blockName' => null, 'attrs' => array(), 'innerBlocks' => array(), - 'innerHTML' => $html + 'innerHTML' => $html, + 'innerContent' => array( $html ), ); } } @@ -1526,7 +1674,8 @@ 'blockName' => null, 'attrs' => array(), 'innerBlocks' => array(), - 'innerHTML' => $post + 'innerHTML' => $post, + 'innerContent' => array( $post ), ); } @@ -1542,6 +1691,7 @@ attrs: {}, innerBlocks: [], innerHTML: s, + innerContent: [ s ], }; } @@ -1578,22 +1728,27 @@ } } - function partition( predicate, list ) { + function processInnerContent( list ) { var i, l, item; - var truthy = []; - var falsey = []; + var html = ''; + var blocks = []; + var content = []; // nod to performance over a simpler reduce // and clone model we could have taken here for ( i = 0, l = list.length; i < l; i++ ) { item = list[ i ]; - predicate( item ) - ? truthy.push( item ) - : falsey.push( item ) + if ( 'string' === typeof item ) { + html += item; + content.push( item ); + } else { + blocks.push( item ); + content.push( null ); + } }; - return [ truthy, falsey ]; + return [ html, blocks, content ]; } diff --git a/packages/block-serialization-spec-parser/shared-tests.js b/packages/block-serialization-spec-parser/shared-tests.js index abfee9be4b5216..54137636d3afdf 100644 --- a/packages/block-serialization-spec-parser/shared-tests.js +++ b/packages/block-serialization-spec-parser/shared-tests.js @@ -62,6 +62,33 @@ export const jsTester = ( parse ) => () => { ] ) ) ); } ); + describe( 'innerBlock placemarkers', () => { + test( 'innerContent exists', () => { + expect( parse( 'test' )[ 0 ] ).toHaveProperty( 'innerContent', [ 'test' ] ); + expect( parse( '' )[ 0 ] ).toHaveProperty( 'innerContent', [] ); + } ); + + test( 'innerContent contains innerHTML', () => { + expect( parse( 'Inner' )[ 0 ] ).toHaveProperty( 'innerContent', [ 'Inner' ] ); + } ); + + test( 'block locations become null', () => { + expect( parse( '' )[ 0 ] ).toHaveProperty( 'innerContent', [ null ] ); + } ); + + test( 'HTML soup appears after blocks', () => { + expect( parse( 'After' )[ 0 ] ).toHaveProperty( 'innerContent', [ null, 'After' ] ); + } ); + + test( 'HTML soup appears before blocks', () => { + expect( parse( 'Before' )[ 0 ] ).toHaveProperty( 'innerContent', [ 'Before', null ] ); + } ); + + test( 'blocks follow each other', () => { + expect( parse( '' )[ 0 ] ).toHaveProperty( 'innerContent', [ null, null ] ); + } ); + } ); + describe( 'attack vectors', () => { test( 'really long JSON attribute sections', () => { const length = 100000; diff --git a/packages/block-serialization-spec-parser/test/__snapshots__/index.js.snap b/packages/block-serialization-spec-parser/test/__snapshots__/index.js.snap index 1a014545d98744..480cde5428505b 100644 --- a/packages/block-serialization-spec-parser/test/__snapshots__/index.js.snap +++ b/packages/block-serialization-spec-parser/test/__snapshots__/index.js.snap @@ -6,6 +6,9 @@ Array [ "attrs": Object {}, "blockName": "core/more", "innerBlocks": Array [], + "innerContent": Array [ + "", + ], "innerHTML": "", }, ] @@ -17,6 +20,9 @@ Array [ "attrs": Array [], "blockName": "core/more", "innerBlocks": Array [], + "innerContent": Array [ + "", + ], "innerHTML": "", }, ] diff --git a/test/integration/full-content/fixtures/core__4-invalid-starting-letter.parsed.json b/test/integration/full-content/fixtures/core__4-invalid-starting-letter.parsed.json index 2dfce101b41c98..b3c0c79ad5cf36 100644 --- a/test/integration/full-content/fixtures/core__4-invalid-starting-letter.parsed.json +++ b/test/integration/full-content/fixtures/core__4-invalid-starting-letter.parsed.json @@ -3,6 +3,9 @@ "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ + "\n" + ] } ] diff --git a/test/integration/full-content/fixtures/core__archives.parsed.json b/test/integration/full-content/fixtures/core__archives.parsed.json index fab690ff93afdf..f974a7a167ab33 100644 --- a/test/integration/full-content/fixtures/core__archives.parsed.json +++ b/test/integration/full-content/fixtures/core__archives.parsed.json @@ -6,6 +6,7 @@ "showPostCounts": false }, "innerBlocks": [], - "innerHTML": "" + "innerHTML": "", + "innerContent": [] } ] diff --git a/test/integration/full-content/fixtures/core__archives__showPostCounts.parsed.json b/test/integration/full-content/fixtures/core__archives__showPostCounts.parsed.json index cd58cbf96924db..88439c3fc9ff0e 100644 --- a/test/integration/full-content/fixtures/core__archives__showPostCounts.parsed.json +++ b/test/integration/full-content/fixtures/core__archives__showPostCounts.parsed.json @@ -6,6 +6,7 @@ "showPostCounts": true }, "innerBlocks": [], - "innerHTML": "" + "innerHTML": "", + "innerContent": [] } ] diff --git a/test/integration/full-content/fixtures/core__audio.parsed.json b/test/integration/full-content/fixtures/core__audio.parsed.json index 33926c0b889b55..6b0acbd0c4a1fb 100644 --- a/test/integration/full-content/fixtures/core__audio.parsed.json +++ b/test/integration/full-content/fixtures/core__audio.parsed.json @@ -5,12 +5,14 @@ "align": "right" }, "innerBlocks": [], - "innerHTML": "\n\n" + "innerHTML": "\n\n", + "innerContent": [ "\n\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__block.parsed.json b/test/integration/full-content/fixtures/core__block.parsed.json index 61b65e317a8e1c..33c4d86f6c6c7c 100644 --- a/test/integration/full-content/fixtures/core__block.parsed.json +++ b/test/integration/full-content/fixtures/core__block.parsed.json @@ -5,12 +5,14 @@ "ref": 123 }, "innerBlocks": [], - "innerHTML": "" + "innerHTML": "", + "innerContent": [] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__button__center.parsed.json b/test/integration/full-content/fixtures/core__button__center.parsed.json index 0094e8f2640736..352767e1c1a8f3 100644 --- a/test/integration/full-content/fixtures/core__button__center.parsed.json +++ b/test/integration/full-content/fixtures/core__button__center.parsed.json @@ -5,12 +5,14 @@ "align": "center" }, "innerBlocks": [], - "innerHTML": "\n
\n" + "innerHTML": "\n \n", + "innerContent": [ "\n \n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__categories.parsed.json b/test/integration/full-content/fixtures/core__categories.parsed.json index df39a8078db37b..60d03d7bc50625 100644 --- a/test/integration/full-content/fixtures/core__categories.parsed.json +++ b/test/integration/full-content/fixtures/core__categories.parsed.json @@ -7,12 +7,14 @@ "showHierarchy": false }, "innerBlocks": [], - "innerHTML": "" + "innerHTML": "", + "innerContent": [] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__code.parsed.json b/test/integration/full-content/fixtures/core__code.parsed.json index 5aea1d9a14a013..d9bf0a215e82b8 100644 --- a/test/integration/full-content/fixtures/core__code.parsed.json +++ b/test/integration/full-content/fixtures/core__code.parsed.json @@ -3,12 +3,14 @@ "blockName": "core/code", "attrs": {}, "innerBlocks": [], - "innerHTML": "\nexport default function MyButton() {\n\treturn <Button>Click Me!</Button>;\n}
\n"
+ "innerHTML": "\nexport default function MyButton() {\n\treturn <Button>Click Me!</Button>;\n}
\n",
+ "innerContent": [ "\nexport default function MyButton() {\n\treturn <Button>Click Me!</Button>;\n}
\n" ]
},
{
"blockName": null,
"attrs": {},
"innerBlocks": [],
- "innerHTML": "\n"
+ "innerHTML": "\n",
+ "innerContent": [ "\n" ]
}
]
diff --git a/test/integration/full-content/fixtures/core__column.parsed.json b/test/integration/full-content/fixtures/core__column.parsed.json
index 74b53bdf6ae966..10f1e1a07cf05b 100644
--- a/test/integration/full-content/fixtures/core__column.parsed.json
+++ b/test/integration/full-content/fixtures/core__column.parsed.json
@@ -7,21 +7,25 @@
"blockName": "core/paragraph",
"attrs": {},
"innerBlocks": [],
- "innerHTML": "\n\tColumn One, Paragraph One
\n\t" + "innerHTML": "\n\tColumn One, Paragraph One
\n\t", + "innerContent": [ "\n\tColumn One, Paragraph One
\n\t" ] }, { "blockName": "core/paragraph", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\tColumn One, Paragraph Two
\n\t" + "innerHTML": "\n\tColumn One, Paragraph Two
\n\t", + "innerContent": [ "\n\tColumn One, Paragraph Two
\n\t" ] } ], - "innerHTML": "\nColumn One, Paragraph One
\n\t\t" + "innerHTML": "\n\t\tColumn One, Paragraph One
\n\t\t", + "innerContent": [ + "\n\t\tColumn One, Paragraph One
\n\t\t" + ] }, { "blockName": "core/paragraph", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\t\tColumn One, Paragraph Two
\n\t\t" + "innerHTML": "\n\t\tColumn One, Paragraph Two
\n\t\t", + "innerContent": [ + "\n\t\tColumn One, Paragraph Two
\n\t\t" + ] } ], - "innerHTML": "\n\tColumn Two, Paragraph One
\n\t\t" + "innerHTML": "\n\t\tColumn Two, Paragraph One
\n\t\t", + "innerContent": [ + "\n\t\tColumn Two, Paragraph One
\n\t\t" + ] }, { "blockName": "core/paragraph", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\t\tColumn Three, Paragraph One
\n\t\t" + "innerHTML": "\n\t\tColumn Three, Paragraph One
\n\t\t", + "innerContent": [ + "\n\t\tColumn Three, Paragraph One
\n\t\t" + ] } ], - "innerHTML": "\n\tColumn One, Paragraph One
\n\t" + "innerHTML": "\n\tColumn One, Paragraph One
\n\t", + "innerContent": [ + "\n\tColumn One, Paragraph One
\n\t" + ] }, { "blockName": "core/paragraph", @@ -19,7 +22,10 @@ "layout": "column-1" }, "innerBlocks": [], - "innerHTML": "\n\tColumn One, Paragraph Two
\n\t" + "innerHTML": "\n\tColumn One, Paragraph Two
\n\t", + "innerContent": [ + "\n\tColumn One, Paragraph Two
\n\t" + ] }, { "blockName": "core/paragraph", @@ -27,7 +33,10 @@ "layout": "column-2" }, "innerBlocks": [], - "innerHTML": "\n\tColumn Two, Paragraph One
\n\t" + "innerHTML": "\n\tColumn Two, Paragraph One
\n\t", + "innerContent": [ + "\n\tColumn Two, Paragraph One
\n\t" + ] }, { "blockName": "core/paragraph", @@ -35,15 +44,32 @@ "layout": "column-3" }, "innerBlocks": [], - "innerHTML": "\n\tColumn Three, Paragraph One
\n\t" + "innerHTML": "\n\tColumn Three, Paragraph One
\n\t", + "innerContent": [ + "\n\tColumn Three, Paragraph One
\n\t" + ] } ], - "innerHTML": "\nGuten Berg!
\nGuten Berg!
\nGuten Berg!
\nGuten Berg!
\nGuten Berg!
\nGuten Berg!
\nGuten Berg!
\nGuten Berg!
\nGuten Berg!
\nMy Content
\n\t\t" + "innerHTML": "\n\t\tMy Content
\n\t\t", + "innerContent": [ + "\n\t\tMy Content
\n\t\t" + ] } ], - "innerHTML": "\nContent
\n\t\t" + "innerHTML": "\n\t\tContent
\n\t\t", + "innerContent": [ + "\n\t\tContent
\n\t\t" + ] } ], - "innerHTML": "\nMy Content
\n\t\t" + "innerHTML": "\n\t\tMy Content
\n\t\t", + "innerContent": [ + "\n\t\tMy Content
\n\t\t" + ] } ], - "innerHTML": "\nMy video
\n\t\t" + "innerHTML": "\n\t\tMy video
\n\t\t", + "innerContent": [ + "\n\t\tMy video
\n\t\t" + ] } ], - "innerHTML": "\nMy Content
\n\t\t" + "innerHTML": "\n\t\tMy Content
\n\t\t", + "innerContent": [ + "\n\t\tMy Content
\n\t\t" + ] } ], - "innerHTML": "\nTesting missing block with some
\nTesting missing block with some
\nTesting missing block with some
\n... like this one, which is separate from the above and right aligned.
\n" + "innerHTML": "\n... like this one, which is separate from the above and right aligned.
\n", + "innerContent": [ "\n... like this one, which is separate from the above and right aligned.
\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__paragraph__deprecated.parsed.json b/test/integration/full-content/fixtures/core__paragraph__deprecated.parsed.json index ac11af1b3a92cf..e6b914e24e1110 100644 --- a/test/integration/full-content/fixtures/core__paragraph__deprecated.parsed.json +++ b/test/integration/full-content/fixtures/core__paragraph__deprecated.parsed.json @@ -3,12 +3,14 @@ "blockName": "core/paragraph", "attrs": {}, "innerBlocks": [], - "innerHTML": "\nUnwrapped is still valid.\n" + "innerHTML": "\nUnwrapped is still valid.\n", + "innerContent": [ "\nUnwrapped is still valid.\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__preformatted.parsed.json b/test/integration/full-content/fixtures/core__preformatted.parsed.json index 247fdda2e3eee7..c78497076e90d2 100644 --- a/test/integration/full-content/fixtures/core__preformatted.parsed.json +++ b/test/integration/full-content/fixtures/core__preformatted.parsed.json @@ -3,12 +3,14 @@ "blockName": "core/preformatted", "attrs": {}, "innerBlocks": [], - "innerHTML": "\nSome preformatted text...\n" + "innerHTML": "\n
And more!
Some preformatted text...\n", + "innerContent": [ "\n
And more!
Some preformatted text...\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__pullquote.parsed.json b/test/integration/full-content/fixtures/core__pullquote.parsed.json index 0e39eea4ec89ce..033b311fa5a190 100644 --- a/test/integration/full-content/fixtures/core__pullquote.parsed.json +++ b/test/integration/full-content/fixtures/core__pullquote.parsed.json @@ -3,12 +3,14 @@ "blockName": "core/pullquote", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\n" + "innerHTML": "\n\n", + "innerContent": [ "\n\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__pullquote__multi-paragraph.parsed.json b/test/integration/full-content/fixtures/core__pullquote__multi-paragraph.parsed.json index 3b303a0d8d157a..fe8abfce70a364 100644 --- a/test/integration/full-content/fixtures/core__pullquote__multi-paragraph.parsed.json +++ b/test/integration/full-content/fixtures/core__pullquote__multi-paragraph.parsed.json @@ -3,12 +3,14 @@ "blockName": "core/pullquote", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\n" + "innerHTML": "\n\n", + "innerContent": [ "\n\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__quote__style-1.parsed.json b/test/integration/full-content/fixtures/core__quote__style-1.parsed.json index 12f480ef313feb..6a873438f17316 100644 --- a/test/integration/full-content/fixtures/core__quote__style-1.parsed.json +++ b/test/integration/full-content/fixtures/core__quote__style-1.parsed.json @@ -3,12 +3,14 @@ "blockName": "core/quote", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n
And more!
\n" + "innerHTML": "\nThe editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.
Matt Mullenweg, 2017
\n", + "innerContent": [ "\nThe editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.
Matt Mullenweg, 2017
\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__quote__style-2.parsed.json b/test/integration/full-content/fixtures/core__quote__style-2.parsed.json index 87a9377e2e9ede..6470afbc17a2e1 100644 --- a/test/integration/full-content/fixtures/core__quote__style-2.parsed.json +++ b/test/integration/full-content/fixtures/core__quote__style-2.parsed.json @@ -5,12 +5,14 @@ "className": "is-style-large" }, "innerBlocks": [], - "innerHTML": "\nThe editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.
Matt Mullenweg, 2017
\n" + "innerHTML": "\nThere is no greater agony than bearing an untold story inside you.
Maya Angelou
\n", + "innerContent": [ "\nThere is no greater agony than bearing an untold story inside you.
Maya Angelou
\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__separator.parsed.json b/test/integration/full-content/fixtures/core__separator.parsed.json index d01eb1eed1f591..48a8e742c35b05 100644 --- a/test/integration/full-content/fixtures/core__separator.parsed.json +++ b/test/integration/full-content/fixtures/core__separator.parsed.json @@ -3,12 +3,14 @@ "blockName": "core/separator", "attrs": {}, "innerBlocks": [], - "innerHTML": "\nThere is no greater agony than bearing an untold story inside you.
Maya Angelou
This is a subhead.
\n" + "innerHTML": "\nThis is a subhead.
\n", + "innerContent": [ "\nThis is a subhead.
\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__table.parsed.json b/test/integration/full-content/fixtures/core__table.parsed.json index 8c24b96113b947..7a2d91003f4373 100644 --- a/test/integration/full-content/fixtures/core__table.parsed.json +++ b/test/integration/full-content/fixtures/core__table.parsed.json @@ -3,12 +3,14 @@ "blockName": "core/table", "attrs": {}, "innerBlocks": [], - "innerHTML": "\nVersion | Musician | Date |
---|---|---|
.70 | No musician chosen. | May 27, 2003 |
1.0 | Miles Davis | January 3, 2004 |
Lots of versions skipped, see the full list | … | … |
4.4 | Clifford Brown | December 8, 2015 |
4.5 | Coleman Hawkins | April 12, 2016 |
4.6 | Pepper Adams | August 16, 2016 |
4.7 | Sarah Vaughan | December 6, 2016 |
Version | Musician | Date |
---|---|---|
.70 | No musician chosen. | May 27, 2003 |
1.0 | Miles Davis | January 3, 2004 |
Lots of versions skipped, see the full list | … | … |
4.4 | Clifford Brown | December 8, 2015 |
4.5 | Coleman Hawkins | April 12, 2016 |
4.6 | Pepper Adams | August 16, 2016 |
4.7 | Sarah Vaughan | December 6, 2016 |
Version | Musician | Date |
---|---|---|
.70 | No musician chosen. | May 27, 2003 |
1.0 | Miles Davis | January 3, 2004 |
Lots of versions skipped, see the full list | … | … |
4.4 | Clifford Brown | December 8, 2015 |
4.5 | Coleman Hawkins | April 12, 2016 |
4.6 | Pepper Adams | August 16, 2016 |
4.7 | Sarah Vaughan | December 6, 2016 |
One
\nTwo
\nOne
\nTwo
\nOne
\nTwo
\nThis is an old-style text block. Changed to paragraph
in #2135.
This is an old-style text block. Changed to paragraph
in #2135.
This is an old-style text block. Changed to paragraph
in #2135.
A verse…\n" + "innerHTML": "\n
And more!
A verse…\n", + "innerContent": [ "\n
And more!
A verse…\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ] diff --git a/test/integration/full-content/fixtures/core__video.parsed.json b/test/integration/full-content/fixtures/core__video.parsed.json index 7b448d6f380d9f..e9be9d8a2ea2c0 100644 --- a/test/integration/full-content/fixtures/core__video.parsed.json +++ b/test/integration/full-content/fixtures/core__video.parsed.json @@ -3,12 +3,14 @@ "blockName": "core/video", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\n" + "innerHTML": "\n\n", + "innerContent": [ "\n\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n" + "innerHTML": "\n", + "innerContent": [ "\n" ] } ]
And more!