Skip to content

Commit

Permalink
Content Model: Fix 212656 (#1924)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong authored Jun 29, 2023
1 parent b5b45f2 commit 3fddfb4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ export const handleTable: ContentModelBlockHandler<ContentModelTable> = (
}

if (!cell.cachedElement || (cell.format.useBorderBox && hasMetadata(table))) {
if (width > 0) {
if (width > 0 && !td.style.width) {
td.style.width = width + 'px';
}

if (height > 0) {
if (height > 0 && !td.style.height) {
td.style.height = height + 'px';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,4 +546,27 @@ describe('handleTable', () => {

expect(parent.innerHTML).toBe('<table><tbody><tr id="tr1"><td></td></tr></tbody></table>');
});

it('TD already has width and height', () => {
const parent = document.createElement('div');
const table = createTable(1, {});
const cell = createTableCell();

table.rows[0].cells.push(cell);

const td = document.createElement('td');
cell.cachedElement = td;

td.style.width = '20px';
td.style.height = '40px';

table.widths = [100];
table.rows[0].height = 200;

handleTable(document, parent, table, context, null);

expect(parent.innerHTML).toBe(
'<table><tbody><tr><td style="width: 20px; height: 40px;"></td></tr></tbody></table>'
);
});
});

0 comments on commit 3fddfb4

Please sign in to comment.