diff --git a/packages/ckeditor5-table/tests/converters/table-cell-refresh-handler.js b/packages/ckeditor5-table/tests/converters/table-cell-refresh-handler.js index b7e05539fb0..d7ae36a7169 100644 --- a/packages/ckeditor5-table/tests/converters/table-cell-refresh-handler.js +++ b/packages/ckeditor5-table/tests/converters/table-cell-refresh-handler.js @@ -218,6 +218,22 @@ describe( 'Table cell refresh handler', () => { expect( getViewForParagraph( table ) ).to.not.equal( previousView ); } ); + it( 'should not rename to

when setting a selection attribute on ', () => { + editor.setData( '

00

' ); + + const table = root.getChild( 0 ); + const previousView = getViewForParagraph( table ); + + model.change( writer => { + writer.setAttribute( 'selection:bold', true, table.getNodeByPath( [ 0, 0, 0 ] ) ); + } ); + + expect( getViewData( view, { withoutSelection: true } ) ).to.equalMarkup( viewTable( [ + [ '00' ] + ], { asWidget: true } ) ); + expect( getViewForParagraph( table ) ).to.equal( previousView ); + } ); + it( 'should rename

to when removing one of two paragraphs inside table cell', () => { editor.setData( viewTable( [ [ '

00

foo

' ] ] ) ); diff --git a/packages/ckeditor5-table/tests/integration.js b/packages/ckeditor5-table/tests/integration.js index d1907adc3f6..378b7d48686 100644 --- a/packages/ckeditor5-table/tests/integration.js +++ b/packages/ckeditor5-table/tests/integration.js @@ -4,10 +4,12 @@ */ import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor.js'; -import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js'; +import { setData as setModelData, getData as getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js'; import BalloonToolbar from '@ckeditor/ckeditor5-ui/src/toolbar/balloon/balloontoolbar.js'; import ClipboardPipeline from '@ckeditor/ckeditor5-clipboard/src/clipboardpipeline.js'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph.js'; +import Heading from '@ckeditor/ckeditor5-heading/src/heading.js'; +import EmptyBlock from '@ckeditor/ckeditor5-html-support/src/emptyblock.js'; import global from '@ckeditor/ckeditor5-utils/src/dom/global.js'; import Table from '../src/table.js'; import TableToolbar from '../src/tabletoolbar.js'; @@ -99,4 +101,184 @@ describe( 'TableContentToolbar integration', () => { sinon.assert.notCalled( normalPrioritySpy ); } ); } ); + + describe( 'with the EmptyBlock', () => { + let editor, editorElement; + + beforeEach( async () => { + editorElement = global.document.createElement( 'div' ); + global.document.body.appendChild( editorElement ); + + editor = await ClassicTestEditor.create( editorElement, { + plugins: [ Table, Paragraph, Heading, EmptyBlock ] + } ); + } ); + + afterEach( async () => { + editorElement.remove(); + await editor.destroy(); + } ); + + it( 'plain content in table cell', () => { + editor.setData( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
x
 
' + ); + + expect( getModelData( editor.model, { withoutSelection: true } ) ).to.equal( + '' + + '' + + '' + + 'x' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + ); + + expect( editor.getData() ).to.equal( + '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
x
 
' + + '
' + ); + } ); + + it( 'content in paragraph in a table cell', () => { + editor.setData( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '

x

 

' + ); + + expect( getModelData( editor.model, { withoutSelection: true } ) ).to.equal( + '' + + '' + + '' + + 'x' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + ); + + expect( editor.getData() ).to.equal( + '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
x
 
' + + '
' + ); + } ); + + it( 'content in heading in a table cell', () => { + editor.setData( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '

x

 

' + ); + + expect( getModelData( editor.model, { withoutSelection: true } ) ).to.equal( + '' + + '' + + '' + + 'x' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + ); + + expect( editor.getData() ).to.equal( + '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '

x

 

' + + '
' + ); + } ); + } ); } );