@@ -546,6 +546,140 @@ const tableWithColspansAndRowspans = {
546546 any
547547> ;
548548
549+ const invalidTableShape = {
550+ type : "table" ,
551+ id : "table-0" ,
552+ props : {
553+ textColor : "default" ,
554+ } ,
555+ content : {
556+ type : "tableContent" ,
557+ columnWidths : [ 100 , 100 ] ,
558+ rows : [
559+ {
560+ cells : [
561+ {
562+ type : "tableCell" ,
563+ content : [
564+ {
565+ type : "text" ,
566+ text : "Table Cell" ,
567+ styles : { } ,
568+ props : {
569+ backgroundColor : "default" ,
570+ textColor : "default" ,
571+ textAlignment : "left" ,
572+ } ,
573+ } ,
574+ ] ,
575+ props : {
576+ backgroundColor : "default" ,
577+ textColor : "default" ,
578+ textAlignment : "left" ,
579+ } ,
580+ } ,
581+ ] ,
582+ } ,
583+ {
584+ cells : [
585+ {
586+ type : "tableCell" ,
587+ content : [
588+ {
589+ type : "text" ,
590+ text : "Table Cell" ,
591+ styles : { } ,
592+ props : {
593+ backgroundColor : "default" ,
594+ textColor : "default" ,
595+ textAlignment : "left" ,
596+ } ,
597+ } ,
598+ ] ,
599+ props : {
600+ backgroundColor : "default" ,
601+ textColor : "default" ,
602+ textAlignment : "left" ,
603+ } ,
604+ } ,
605+ ] ,
606+ } ,
607+ {
608+ cells : [
609+ {
610+ type : "tableCell" ,
611+ content : [
612+ {
613+ type : "text" ,
614+ text : "Table Cell" ,
615+ styles : { } ,
616+ props : {
617+ backgroundColor : "default" ,
618+ textColor : "default" ,
619+ textAlignment : "left" ,
620+ } ,
621+ } ,
622+ ] ,
623+ props : {
624+ backgroundColor : "default" ,
625+ textColor : "default" ,
626+ textAlignment : "left" ,
627+ } ,
628+ } ,
629+ {
630+ type : "tableCell" ,
631+ content : [
632+ {
633+ type : "text" ,
634+ text : "Table Cell" ,
635+ styles : { } ,
636+ props : {
637+ backgroundColor : "default" ,
638+ textColor : "default" ,
639+ textAlignment : "left" ,
640+ } ,
641+ } ,
642+ ] ,
643+ props : {
644+ colspan : 2 ,
645+ backgroundColor : "default" ,
646+ textColor : "default" ,
647+ textAlignment : "left" ,
648+ } ,
649+ } ,
650+ {
651+ type : "tableCell" ,
652+ content : [
653+ {
654+ type : "text" ,
655+ text : "Table x" ,
656+ styles : { } ,
657+ props : {
658+ backgroundColor : "default" ,
659+ textColor : "default" ,
660+ textAlignment : "left" ,
661+ } ,
662+ } ,
663+ ] ,
664+ props : {
665+ backgroundColor : "default" ,
666+ textColor : "default" ,
667+ textAlignment : "left" ,
668+ } ,
669+ } ,
670+ ] ,
671+ } ,
672+ ] ,
673+ } ,
674+ children : [ ] ,
675+ } satisfies Block <
676+ {
677+ table : DefaultBlockSchema [ "table" ] ;
678+ } ,
679+ any ,
680+ any
681+ > ;
682+
549683/**
550684 * Normal table
551685 * | 1-1 | 1-2 | 1-3 | 1-4 |
@@ -882,6 +1016,12 @@ describe("Test getAbsoluteTableCellIndices", () => {
8821016 cell : tableWithComplexRowspansAndColspans . content . rows [ 2 ] . cells [ 2 ] ,
8831017 } ) ;
8841018 } ) ;
1019+
1020+ it ( "should not crash at an invalid table shape" , ( ) => {
1021+ expect ( ( ) =>
1022+ getAbsoluteTableCells ( { row : 2 , col : 2 } , invalidTableShape ) ,
1023+ ) . not . toThrow ( ) ;
1024+ } ) ;
8851025} ) ;
8861026
8871027describe ( "Test getRelativeTableCellIndices" , ( ) => {
0 commit comments