diff --git a/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.edge.word2016.html b/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.edge.word2016.html
index 049736574ec..d9ec854fca3 100644
--- a/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.edge.word2016.html
+++ b/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.edge.word2016.html
@@ -2,30 +2,30 @@
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
+
+
-
+
diff --git a/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.safari.word2016.html b/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.safari.word2016.html
index ee6b7a66eb7..2106f1dc715 100644
--- a/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.safari.word2016.html
+++ b/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.safari.word2016.html
@@ -1,20 +1,20 @@
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
diff --git a/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.word2016.html b/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.word2016.html
index 7514039208f..e650b75d1f6 100644
--- a/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.word2016.html
+++ b/packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.word2016.html
@@ -1,29 +1,29 @@
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
+
+
-
+
diff --git a/packages/ckeditor5-table/src/converters/upcasttable.js b/packages/ckeditor5-table/src/converters/upcasttable.js
index e772a3cd448..2df29d0c6b8 100644
--- a/packages/ckeditor5-table/src/converters/upcasttable.js
+++ b/packages/ckeditor5-table/src/converters/upcasttable.js
@@ -84,31 +84,6 @@ export function skipEmptyTableRow() {
};
}
-/**
- * A converter that ensures an empty paragraph is inserted in a table cell if no other content was converted.
- *
- * @returns {Function} Conversion helper.
- */
-export function ensureParagraphInTableCell( elementName ) {
- return dispatcher => {
- dispatcher.on( `element:${ elementName }`, ( evt, data, conversionApi ) => {
- // The default converter will create a model range on converted table cell.
- if ( !data.modelRange ) {
- return;
- }
-
- const tableCell = data.modelRange.start.nodeAfter;
-
- // Ensure a paragraph in the model for empty table cells for converted table cells.
- if ( !tableCell.childCount ) {
- const modelCursor = conversionApi.writer.createPositionAt( tableCell, 0 );
-
- conversionApi.writer.insertElement( 'paragraph', modelCursor );
- }
- }, { priority: 'low' } );
- };
-}
-
// Scans table rows and extracts required metadata from the table:
//
// headingRows - The number of rows that go as table headers.
diff --git a/packages/ckeditor5-table/src/tableediting.js b/packages/ckeditor5-table/src/tableediting.js
index 56de2cd3b68..d2b123076e3 100644
--- a/packages/ckeditor5-table/src/tableediting.js
+++ b/packages/ckeditor5-table/src/tableediting.js
@@ -9,7 +9,7 @@
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
-import upcastTable, { ensureParagraphInTableCell, skipEmptyTableRow } from './converters/upcasttable';
+import upcastTable, { skipEmptyTableRow } from './converters/upcasttable';
import {
downcastInsertCell,
downcastInsertRow,
@@ -106,8 +106,6 @@ export default class TableEditing extends Plugin {
// Table cell conversion.
conversion.for( 'upcast' ).elementToElement( { model: 'tableCell', view: 'td' } );
conversion.for( 'upcast' ).elementToElement( { model: 'tableCell', view: 'th' } );
- conversion.for( 'upcast' ).add( ensureParagraphInTableCell( 'td' ) );
- conversion.for( 'upcast' ).add( ensureParagraphInTableCell( 'th' ) );
conversion.for( 'editingDowncast' ).add( downcastInsertCell() );
diff --git a/packages/ckeditor5-table/tests/converters/upcasttable.js b/packages/ckeditor5-table/tests/converters/upcasttable.js
index e47c5c80f15..2fab95fae2b 100644
--- a/packages/ckeditor5-table/tests/converters/upcasttable.js
+++ b/packages/ckeditor5-table/tests/converters/upcasttable.js
@@ -285,7 +285,7 @@ describe( 'upcastTable()', () => {
);
expectModel(
- ''
+ ''
);
} );
diff --git a/packages/ckeditor5-table/tests/tableclipboard-paste.js b/packages/ckeditor5-table/tests/tableclipboard-paste.js
index 53bc05c8d4a..6373abe0d94 100644
--- a/packages/ckeditor5-table/tests/tableclipboard-paste.js
+++ b/packages/ckeditor5-table/tests/tableclipboard-paste.js
@@ -3917,6 +3917,36 @@ describe( 'table clipboard', () => {
[ '02', '21', '22' ]
] ) );
} );
+
+ it( 'should not blow up when pasting unsupported element in table', async () => {
+ await createEditor( [ TableCellPropertiesEditing ] );
+
+ pasteHtml( editor,
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ ' ' +
+ '' +
+ '' +
+ '' +
+ ' Test ' +
+ ' | ' +
+ ' ' +
+ '' +
+ ' ' +
+ ' ' +
+ ' | ' +
+ '
' +
+ '' +
+ '
'
+ );
+
+ assertEqualMarkup( getModelData( model, { withoutSelection: true } ), modelTable( [
+ [ 'Test' ]
+ ] ) );
+ } );
} );
async function createEditor( extraPlugins = [] ) {
@@ -3930,6 +3960,17 @@ describe( 'table clipboard', () => {
tableSelection = editor.plugins.get( 'TableSelection' );
}
+ function pasteHtml( editor, html ) {
+ const data = {
+ dataTransfer: createDataTransfer(),
+ stopPropagation() {},
+ preventDefault() {}
+ };
+
+ data.dataTransfer.setData( 'text/html', html );
+ editor.editing.view.document.fire( 'paste', data );
+ }
+
function pasteTable( tableData, attributes = {} ) {
const data = {
dataTransfer: createDataTransfer(),