@@ -294,6 +294,56 @@ describe('LexicalTableNode tests', () => {
294294 `<p><br></p><table><tr><th><p><br></p></th><th><p><br></p></th><th><p><br></p></th><th><p><br></p></th></tr><tr><th><p><br></p></th><td><p><br></p></td><td><p><br></p></td><td><p><br></p></td></tr><tr><th><p><br></p></th><td><p><br></p></td><td><p><br></p></td><td><p><br></p></td></tr><tr><th><p><br></p></th><td><p><br></p></td><td><p><br></p></td><td><p><br></p></td></tr></table>` ,
295295 ) ;
296296 } ) ;
297+
298+ test ( 'Table plain text output validation' , async ( ) => {
299+ const { editor} = testEnv ;
300+
301+ await editor . update ( ( ) => {
302+ const root = $getRoot ( ) ;
303+ const table = $createTableNodeWithDimensions ( 4 , 4 , true ) ;
304+ root . append ( table ) ;
305+ } ) ;
306+ await editor . update ( ( ) => {
307+ const root = $getRoot ( ) ;
308+ const table = root . getLastChild < TableNode > ( ) ;
309+ if ( table ) {
310+ const DOMTable = $getElementForTableNode ( editor , table ) ;
311+ if ( DOMTable ) {
312+ table
313+ ?. getCellNodeFromCords ( 0 , 0 , DOMTable )
314+ ?. getLastChild < ParagraphNode > ( )
315+ ?. append ( $createTextNode ( '1' ) ) ;
316+ table
317+ ?. getCellNodeFromCords ( 1 , 0 , DOMTable )
318+ ?. getLastChild < ParagraphNode > ( )
319+ ?. append ( $createTextNode ( '' ) ) ;
320+ table
321+ ?. getCellNodeFromCords ( 2 , 0 , DOMTable )
322+ ?. getLastChild < ParagraphNode > ( )
323+ ?. append ( $createTextNode ( '2' ) ) ;
324+ table
325+ ?. getCellNodeFromCords ( 0 , 1 , DOMTable )
326+ ?. getLastChild < ParagraphNode > ( )
327+ ?. append ( $createTextNode ( '3' ) ) ;
328+ table
329+ ?. getCellNodeFromCords ( 1 , 1 , DOMTable )
330+ ?. getLastChild < ParagraphNode > ( )
331+ ?. append ( $createTextNode ( '4' ) ) ;
332+ table
333+ ?. getCellNodeFromCords ( 2 , 1 , DOMTable )
334+ ?. getLastChild < ParagraphNode > ( )
335+ ?. append ( $createTextNode ( '' ) ) ;
336+ const selection = $createTableSelection ( ) ;
337+ selection . set (
338+ table . __key ,
339+ table ?. getCellNodeFromCords ( 0 , 0 , DOMTable ) ?. __key || '' ,
340+ table ?. getCellNodeFromCords ( 2 , 1 , DOMTable ) ?. __key || '' ,
341+ ) ;
342+ expect ( selection . getTextContent ( ) ) . toBe ( `1\t\t2\n3\t4\t\n` ) ;
343+ }
344+ }
345+ } ) ;
346+ } ) ;
297347 } ,
298348 undefined ,
299349 < TablePlugin /> ,
0 commit comments