This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree 2 files changed +24
-6
lines changed 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 ) {
115
115
conversionApi . writer . insert ( tableCell , splitResult . position ) ;
116
116
conversionApi . consumable . consume ( viewTableCell , { name : true } ) ;
117
117
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 ) ;
120
120
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 ) ;
125
124
}
126
125
127
126
// Set conversion result range.
Original file line number Diff line number Diff line change @@ -418,6 +418,25 @@ describe( 'upcastTable()', () => {
418
418
] ) ) ;
419
419
} ) ;
420
420
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
+
421
440
it ( 'should upcast table with multiple <p> in table cell' , ( ) => {
422
441
editor . setData (
423
442
'<table>' +
You can’t perform that action at this time.
0 commit comments