This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed
Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -115,13 +115,12 @@ export function upcastTableCell( elementName ) {
115115 conversionApi . writer . insert ( tableCell , splitResult . position ) ;
116116 conversionApi . consumable . consume ( viewTableCell , { name : true } ) ;
117117
118- for ( const child of viewTableCell . getChildren ( ) ) {
119- const { modelCursor } = conversionApi . convertItem ( child , ModelPosition . createAt ( tableCell , 'end' ) ) ;
118+ const modelCursor = ModelPosition . createAt ( tableCell ) ;
119+ conversionApi . convertChildren ( viewTableCell , modelCursor ) ;
120120
121- // Ensure empty paragraph in table cell.
122- if ( modelCursor . parent . name == 'tableCell' && ! modelCursor . parent . childCount ) {
123- conversionApi . writer . insertElement ( 'paragraph' , modelCursor ) ;
124- }
121+ // Ensure a paragraph in the model for empty table cells.
122+ if ( ! tableCell . childCount ) {
123+ conversionApi . writer . insertElement ( 'paragraph' , modelCursor ) ;
125124 }
126125
127126 // Set conversion result range.
Original file line number Diff line number Diff line change @@ -418,6 +418,25 @@ describe( 'upcastTable()', () => {
418418 ] ) ) ;
419419 } ) ;
420420
421+ it ( 'should upcast table inline content to single <paragraph>' , ( ) => {
422+ editor . model . schema . extend ( '$text' , { allowAttributes : 'bold' } ) ;
423+ editor . conversion . attributeToElement ( { model : 'bold' , view : 'strong' } ) ;
424+
425+ editor . setData (
426+ '<table>' +
427+ '<tbody>' +
428+ '<tr>' +
429+ '<td>foo <strong>bar</strong></td>' +
430+ '</tr>' +
431+ '</tbody>' +
432+ '</table>'
433+ ) ;
434+
435+ expectModel ( modelTable ( [
436+ [ 'foo <$text bold="true">bar</$text>' ]
437+ ] ) ) ;
438+ } ) ;
439+
421440 it ( 'should upcast table with multiple <p> in table cell' , ( ) => {
422441 editor . setData (
423442 '<table>' +
You can’t perform that action at this time.
0 commit comments