Skip to content

Commit

Permalink
Paste: remove non inline elements from inline pasted content
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Oct 3, 2017
1 parent 01d1c09 commit 0cc8444
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions blocks/api/paste/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } ) {
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function( { HTML, plainText, inline } ) {
formattingTransformer,
stripAttributes,
commentRemover,
createUnwrapper( isNotWhitelisted ),
createUnwrapper( ( node ) => isNotWhitelisted( node ) || ( inline && ! isInline( node ) ) ),
blockquoteNormaliser,
] );

Expand Down
9 changes: 9 additions & 0 deletions blocks/api/paste/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ describe( 'paste', () => {
equal( pastedBlock.name, 'test/unknown' );
equal( pastedBlock.attributes.content, '<figcaption>test</figcaption>' );
} );

it( 'should filter inline content', () => {
const filtered = paste( {
HTML: '<h2><em>test</em></h2>',
inline: true,
} );

equal( filtered, '<em>test</em>' );
} );
} );

import './integration';

0 comments on commit 0cc8444

Please sign in to comment.