Skip to content

Commit

Permalink
Content Model: Add solid paragraph in new table cell (#2055)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong authored Sep 8, 2023
1 parent 2fc7830 commit fb0febc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ describe('normalizeTable', () => {
blocks: [
{
blockType: 'Paragraph',
isImplicit: true,
segments: [
{
segmentType: 'Br',
Expand Down Expand Up @@ -678,7 +677,6 @@ describe('normalizeTable', () => {
blocks: [
{
blockType: 'Paragraph',
isImplicit: true,
segments: [
{
segmentType: 'Br',
Expand All @@ -688,6 +686,7 @@ describe('normalizeTable', () => {
},
],
format: {},
segmentFormat: { fontSize: '10px' },
},
],
dataset: {},
Expand Down Expand Up @@ -725,7 +724,6 @@ describe('normalizeTable', () => {

const block: ContentModelParagraph = {
blockType: 'Paragraph',
isImplicit: true,
segments: [
{
segmentType: 'Br',
Expand Down

0 comments on commit fb0febc

Please sign in to comment.