diff --git a/packages/ckeditor5-paste-from-office/src/filters/removestyleblock.ts b/packages/ckeditor5-paste-from-office/src/filters/removestyleblock.ts new file mode 100644 index 00000000000..90dd9e4a9cd --- /dev/null +++ b/packages/ckeditor5-paste-from-office/src/filters/removestyleblock.ts @@ -0,0 +1,23 @@ +/** + * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. + * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license + */ + +/** + * @module paste-from-office/filters/removestyleblock + */ + +import type { UpcastWriter, ViewDocumentFragment } from 'ckeditor5/src/engine'; + +/** + * Removes `' + + '' + + '' + + '' + + '' + + '' + + '' + + '
123
'; + + const documentFragment = htmlDataProcessor.toView( inputData ); + + removeStyleBlock( documentFragment, writer ); + + expect( htmlDataProcessor.toData( documentFragment ) ).to.equal( '
123
' ); + } ); + + it( 'works with multiple consecutive ' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
123
'; + + const documentFragment = htmlDataProcessor.toView( inputData ); + + removeStyleBlock( documentFragment, writer ); + + expect( htmlDataProcessor.toData( documentFragment ) ).to.equal( '
123
' ); + } ); + + it( 'works with multiple non-consecutive ' + + '' + + '' + + '' + + '' + + '' + + '' + + '
123
' + + ''; + + const documentFragment = htmlDataProcessor.toView( inputData ); + + removeStyleBlock( documentFragment, writer ); + + expect( htmlDataProcessor.toData( documentFragment ) ).to.equal( '
123
' ); + } ); + } ); +} );