8
0
Просмотр исходного кода

Make downcast conversion always create a TR element on table insert.

Maciej Gołaszewski 7 лет назад
Родитель
Сommit
e33455a737
1 измененных файлов с 5 добавлено и 3 удалено
  1. 5 3
      packages/ckeditor5-table/src/converters/downcast.js

+ 5 - 3
packages/ckeditor5-table/src/converters/downcast.js

@@ -58,7 +58,9 @@ export function downcastInsertTable( options = {} ) {
 			const tableRow = table.getChild( row );
 
 			// Check if row was converted
-			const trElement = getOrCreateTr( tableRow, row, tableSection, conversionApi );
+			// TODO: Smarter row management is needed.
+			const forceCreate = !cell.index;
+			const trElement = getOrCreateTr( tableRow, row, tableSection, conversionApi, forceCreate );
 
 			// Consume table cell - it will be always consumed as we convert whole table at once.
 			conversionApi.consumable.consume( cell, 'insert' );
@@ -411,10 +413,10 @@ function createViewTableCellElement( tableWalkerValue, tableAttributes, insertPo
 // @param {module:engine/view/element~Element} tableSection
 // @param {Object} conversionApi
 // @returns {module:engine/view/element~Element}
-function getOrCreateTr( tableRow, rowIndex, tableSection, conversionApi ) {
+function getOrCreateTr( tableRow, rowIndex, tableSection, conversionApi, force = false ) {
 	let trElement = conversionApi.mapper.toViewElement( tableRow );
 
-	if ( !trElement ) {
+	if ( !trElement || force ) {
 		// Will always consume since we're converting <tableRow> element from a parent <table>.
 		conversionApi.consumable.consume( tableRow, 'insert' );