diff --git a/src/converters/slate.js b/src/converters/slate.js index b712d40..65809e3 100644 --- a/src/converters/slate.js +++ b/src/converters/slate.js @@ -296,7 +296,9 @@ const slateTableBlock = (elem) => { const cells = []; for (const cell of tchild.children) { const cellType = cell.tagName === 'TD' ? 'data' : 'header'; - const cellValue = Array.from(cell.childNodes).map(deserialize); + const cellValue = Array.from(cell.childNodes) + .map(deserialize) + .filter((x) => x); cells.push(createCell(cellType, cellValue)); } rows.push({ key: getId(), cells }); diff --git a/src/converters/slate.test.js b/src/converters/slate.test.js index 643ccc3..594fff1 100644 --- a/src/converters/slate.test.js +++ b/src/converters/slate.test.js @@ -525,6 +525,25 @@ describe('slateTableBlock processing a simple table', () => { }); }); +describe('slateTableBlock processing a table with whitespace', () => { + const elem = elementFromString( + '
A value
 
', + ); + + test('will remove the whitespace', () => { + const result = slateTableBlock(elem); + const rows = result.table.rows; + expect(rows).toHaveLength(1); + const cells = rows[0].cells; + expect(cells).toHaveLength(1); + const cell = cells[0]; + expect(cell.value).toEqual([ + { type: 'p', children: [{ text: 'A value' }] }, + { type: 'p', children: [{ text: '\n' }] }, + ]); + }); +}); + describe('slateTableBlock processing a table with a link', () => { const elem = elementFromString( '
Plone
',