diff --git a/blocks/api/paste/index.js b/blocks/api/paste/index.js index 697a963c828b7..a8721465f1edf 100644 --- a/blocks/api/paste/index.js +++ b/blocks/api/paste/index.js @@ -19,7 +19,7 @@ import msListConverter from './ms-list-converter'; import listMerger from './list-merger'; import imageCorrector from './image-corrector'; import blockquoteNormaliser from './blockquote-normaliser'; -import { deepFilter, isInvalidInline, isNotWhitelisted, isPlain } from './utils'; +import { deepFilter, isInvalidInline, isNotWhitelisted, isPlain, isInline } from './utils'; import showdown from 'showdown'; export default function( { HTML, plainText, inline } ) { @@ -50,7 +50,7 @@ export default function( { HTML, plainText, inline } ) { formattingTransformer, stripAttributes, commentRemover, - createUnwrapper( isNotWhitelisted ), + createUnwrapper( ( node ) => isNotWhitelisted( node ) || ( inline && ! isInline( node ) ) ), blockquoteNormaliser, ] ); diff --git a/blocks/api/paste/test/index.js b/blocks/api/paste/test/index.js index 6f7d1e53f9588..2eacda7a389d8 100644 --- a/blocks/api/paste/test/index.js +++ b/blocks/api/paste/test/index.js @@ -68,6 +68,15 @@ describe( 'paste', () => { equal( pastedBlock.name, 'test/unknown' ); equal( pastedBlock.attributes.content, '
test
' ); } ); + + it( 'should filter inline content', () => { + const filtered = paste( { + HTML: '

test

', + inline: true, + } ); + + equal( filtered, 'test' ); + } ); } ); import './integration';