diff --git a/packages/blocks/src/api/raw-handling/paste-handler.js b/packages/blocks/src/api/raw-handling/paste-handler.js index 12eb25e72173cd..f126e050c15c08 100644 --- a/packages/blocks/src/api/raw-handling/paste-handler.js +++ b/packages/blocks/src/api/raw-handling/paste-handler.js @@ -50,6 +50,7 @@ const { console } = window; function filterInlineHTML( HTML ) { HTML = deepFilterHTML( HTML, [ googleDocsUIDRemover, phrasingContentReducer, commentRemover ] ); HTML = removeInvalidHTML( HTML, getPhrasingContentSchema( 'paste' ), { inline: true } ); + HTML = deepFilterHTML( HTML, [ htmlFormattingRemover, brRemover ] ); // Allows us to ask for this information when we get a report. console.log( 'Processed inline HTML:\n\n', HTML ); diff --git a/test/integration/__snapshots__/blocks-raw-handling.test.js.snap b/test/integration/__snapshots__/blocks-raw-handling.test.js.snap index 4197d9cfaffa6b..9cefe8bffb6fd9 100644 --- a/test/integration/__snapshots__/blocks-raw-handling.test.js.snap +++ b/test/integration/__snapshots__/blocks-raw-handling.test.js.snap @@ -10,6 +10,8 @@ exports[`Blocks raw handling pasteHandler should remove extra blank lines 1`] = " `; +exports[`Blocks raw handling pasteHandler should strip HTML formatting space from inline text 1`] = `"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent a elit eget tortor molestie egestas. Donec pretium urna vitae mattis imperdiet. Praesent et lorem iaculis, volutpat odio vitae, ornare lacus. Donec ut felis tristique, pharetra erat id, viverra justo. Integer sit amet elementum arcu, eget pharetra felis. In malesuada enim est, sed placerat nulla feugiat at. Vestibulum feugiat vitae elit sit amet tincidunt. Pellentesque finibus sed dolor non facilisis. Curabitur accumsan ante ac hendrerit vestibulum."`; + exports[`Blocks raw handling pasteHandler should strip some text-level elements 1`] = ` "
This is ncorect
diff --git a/test/integration/blocks-raw-handling.test.js b/test/integration/blocks-raw-handling.test.js index fd2255b1bd096f..d042702d37b0d2 100644 --- a/test/integration/blocks-raw-handling.test.js +++ b/test/integration/blocks-raw-handling.test.js @@ -319,6 +319,12 @@ describe( 'Blocks raw handling', () => { const HTML = readFile( path.join( __dirname, 'fixtures/windows.html' ) ); expect( serialize( pasteHandler( { HTML } ) ) ).toMatchSnapshot(); } ); + + it( 'should strip HTML formatting space from inline text', () => { + const HTML = readFile( path.join( __dirname, 'fixtures/inline-with-html-formatting-space.html' ) ); + expect( pasteHandler( { HTML } ) ).toMatchSnapshot(); + expect( console ).toHaveLogged(); + } ); } ); } ); diff --git a/test/integration/fixtures/inline-with-html-formatting-space.html b/test/integration/fixtures/inline-with-html-formatting-space.html new file mode 100644 index 00000000000000..3e51738cab59ea --- /dev/null +++ b/test/integration/fixtures/inline-with-html-formatting-space.html @@ -0,0 +1,11 @@ + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent a elit + eget tortor molestie egestas. Donec pretium urna vitae mattis + imperdiet. Praesent et lorem iaculis, volutpat odio vitae, ornare lacus. + Donec ut felis tristique, pharetra erat id, viverra justo. Integer sit + amet elementum arcu, eget pharetra felis. In malesuada enim est, sed + placerat nulla feugiat at. Vestibulum feugiat vitae elit sit amet + tincidunt. Pellentesque finibus sed dolor non facilisis. Curabitur + accumsan ante ac hendrerit vestibulum. + +