From 550cc796ea2ea7f7cd3e03a346c9021bdbaab7ae Mon Sep 17 00:00:00 2001 From: iseulde Date: Tue, 20 Nov 2018 17:25:19 +0100 Subject: [PATCH 1/2] preserve quote content --- packages/block-library/src/quote/index.js | 5 ++++- .../__snapshots__/blocks-raw-handling.spec.js.snap | 10 +++++++++- test/integration/fixtures/wordpress-convert.html | 13 +++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/quote/index.js b/packages/block-library/src/quote/index.js index 78e53875b771d..51747b3633a9a 100644 --- a/packages/block-library/src/quote/index.js +++ b/packages/block-library/src/quote/index.js @@ -100,7 +100,10 @@ export const settings = { }, { type: 'raw', - selector: 'blockquote', + isMatch: ( node ) => ( + node.nodeName === 'BLOCKQUOTE' && + Array.from( node.childNodes ).every( ( child ) => child.nodeName === 'P' ) + ), schema: { blockquote: { children: { diff --git a/test/integration/__snapshots__/blocks-raw-handling.spec.js.snap b/test/integration/__snapshots__/blocks-raw-handling.spec.js.snap index 1fbb36f44d9ab..320b201a836e3 100644 --- a/test/integration/__snapshots__/blocks-raw-handling.spec.js.snap +++ b/test/integration/__snapshots__/blocks-raw-handling.spec.js.snap @@ -44,5 +44,13 @@ exports[`Blocks raw handling rawHandler should convert HTML post to blocks with
  1. Item
-" + + + +

Text.

+ + + +

Heading

Text.

+" `; diff --git a/test/integration/fixtures/wordpress-convert.html b/test/integration/fixtures/wordpress-convert.html index 0a8a20c6e19b1..0fe1de21dc662 100644 --- a/test/integration/fixtures/wordpress-convert.html +++ b/test/integration/fixtures/wordpress-convert.html @@ -23,3 +23,16 @@

Shortcode

  • Item
  • + + + +
    +

    Text.

    +
    + + + +
    +

    Heading

    +

    Text.

    +
    From dd828b071b1ce6ab5ac4548f943dffc22ac83535 Mon Sep 17 00:00:00 2001 From: iseulde Date: Tue, 20 Nov 2018 17:42:23 +0100 Subject: [PATCH 2/2] Add comment --- packages/block-library/src/quote/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/block-library/src/quote/index.js b/packages/block-library/src/quote/index.js index 51747b3633a9a..d3f020a220c3d 100644 --- a/packages/block-library/src/quote/index.js +++ b/packages/block-library/src/quote/index.js @@ -102,6 +102,8 @@ export const settings = { type: 'raw', isMatch: ( node ) => ( node.nodeName === 'BLOCKQUOTE' && + // The quote block can only handle multiline paragraph + // content. Array.from( node.childNodes ).every( ( child ) => child.nodeName === 'P' ) ), schema: {