From fb0febca1724ed791d5bf816627ec3b00fb45400 Mon Sep 17 00:00:00 2001 From: Jiuqing Song Date: Fri, 8 Sep 2023 13:02:10 -0700 Subject: [PATCH] Content Model: Add solid paragraph in new table cell (#2055) --- .../lib/modelApi/table/normalizeTable.ts | 10 +++++++++- .../test/modelApi/table/normalizeTableTest.ts | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages-content-model/roosterjs-content-model-editor/lib/modelApi/table/normalizeTable.ts b/packages-content-model/roosterjs-content-model-editor/lib/modelApi/table/normalizeTable.ts index ac53ef20bd7..e150418fa9e 100644 --- a/packages-content-model/roosterjs-content-model-editor/lib/modelApi/table/normalizeTable.ts +++ b/packages-content-model/roosterjs-content-model-editor/lib/modelApi/table/normalizeTable.ts @@ -1,4 +1,4 @@ -import { addSegment, createBr } from 'roosterjs-content-model-dom'; +import { addBlock, addSegment, createBr, createParagraph } from 'roosterjs-content-model-dom'; import { arrayPush } from 'roosterjs-editor-dom'; import { ContentModelSegment, @@ -30,6 +30,14 @@ export function normalizeTable( table.rows.forEach((row, rowIndex) => { row.cells.forEach((cell, colIndex) => { if (cell.blocks.length == 0) { + addBlock( + cell, + createParagraph( + undefined /*isImplicit*/, + undefined /*blockFormat*/, + defaultSegmentFormat + ) + ); addSegment(cell, createBr(defaultSegmentFormat)); } diff --git a/packages-content-model/roosterjs-content-model-editor/test/modelApi/table/normalizeTableTest.ts b/packages-content-model/roosterjs-content-model-editor/test/modelApi/table/normalizeTableTest.ts index 0378bc1c830..f2379aa2f28 100644 --- a/packages-content-model/roosterjs-content-model-editor/test/modelApi/table/normalizeTableTest.ts +++ b/packages-content-model/roosterjs-content-model-editor/test/modelApi/table/normalizeTableTest.ts @@ -78,7 +78,6 @@ describe('normalizeTable', () => { blocks: [ { blockType: 'Paragraph', - isImplicit: true, segments: [ { segmentType: 'Br', @@ -678,7 +677,6 @@ describe('normalizeTable', () => { blocks: [ { blockType: 'Paragraph', - isImplicit: true, segments: [ { segmentType: 'Br', @@ -688,6 +686,7 @@ describe('normalizeTable', () => { }, ], format: {}, + segmentFormat: { fontSize: '10px' }, }, ], dataset: {}, @@ -725,7 +724,6 @@ describe('normalizeTable', () => { const block: ContentModelParagraph = { blockType: 'Paragraph', - isImplicit: true, segments: [ { segmentType: 'Br',