@@ -157,7 +157,7 @@ export default function ControlPanel({
157157
158158 if ( a . action === Action . ADD ) {
159159 if ( a . element === ObjectType . TABLE ) {
160- deleteTable ( a . id , false ) ;
160+ deleteTable ( a . data . table . id , false ) ;
161161 } else if ( a . element === ObjectType . AREA ) {
162162 deleteArea ( areas [ areas . length - 1 ] . id , false ) ;
163163 } else if ( a . element === ObjectType . NOTE ) {
@@ -191,7 +191,7 @@ export default function ControlPanel({
191191 } else if ( a . action === Action . DELETE ) {
192192 if ( a . element === ObjectType . TABLE ) {
193193 a . data . relationship . forEach ( ( x ) => addRelationship ( x , false ) ) ;
194- addTable ( a . data . table , false ) ;
194+ addTable ( a . data , false ) ;
195195 } else if ( a . element === ObjectType . RELATIONSHIP ) {
196196 addRelationship ( a . data , false ) ;
197197 } else if ( a . element === ObjectType . NOTE ) {
@@ -326,7 +326,7 @@ export default function ControlPanel({
326326
327327 if ( a . action === Action . ADD ) {
328328 if ( a . element === ObjectType . TABLE ) {
329- addTable ( null , false ) ;
329+ addTable ( a . data , false ) ;
330330 } else if ( a . element === ObjectType . AREA ) {
331331 addArea ( null , false ) ;
332332 } else if ( a . element === ObjectType . NOTE ) {
@@ -647,10 +647,12 @@ export default function ControlPanel({
647647 case ObjectType . TABLE : {
648648 const copiedTable = tables . find ( ( t ) => t . id === selectedElement . id ) ;
649649 addTable ( {
650- ...copiedTable ,
651- x : copiedTable . x + 20 ,
652- y : copiedTable . y + 20 ,
653- id : nanoid ( ) ,
650+ table : {
651+ ...copiedTable ,
652+ x : copiedTable . x + 20 ,
653+ y : copiedTable . y + 20 ,
654+ id : nanoid ( ) ,
655+ } ,
654656 } ) ;
655657 break ;
656658 }
@@ -709,12 +711,15 @@ export default function ControlPanel({
709711 return ;
710712 }
711713 const v = new Validator ( ) ;
714+ console . log ( obj ) ;
712715 if ( v . validate ( obj , tableSchema ) . valid ) {
713716 addTable ( {
714- ...obj ,
715- x : obj . x + 20 ,
716- y : obj . y + 20 ,
717- id : nanoid ( ) ,
717+ table : {
718+ ...obj ,
719+ x : obj . x + 20 ,
720+ y : obj . y + 20 ,
721+ id : nanoid ( ) ,
722+ } ,
718723 } ) ;
719724 } else if ( v . validate ( obj , areaSchema ) . valid ) {
720725 addArea ( {
@@ -767,6 +772,7 @@ export default function ControlPanel({
767772 setTables ( diagram . tables ) ;
768773 setRelationships ( diagram . references ) ;
769774 setAreas ( diagram . areas ) ;
775+ setGistId ( diagram . gistId ?? "" ) ;
770776 setNotes ( diagram . notes ) ;
771777 setTasks ( diagram . todos ?? [ ] ) ;
772778 setTransform ( {
0 commit comments