@@ -7,6 +7,7 @@ import { get } from 'svelte/store';
77import type { MenuItemType } from './ContextMenu.svelte' ;
88import type { ContextMenuTarget } from '$lib/stores/contextMenu' ;
99import { graphStore , ANNOTATION_FONT_SIZE } from '$lib/stores/graph' ;
10+ import { historyStore } from '$lib/stores/history' ;
1011import { routingStore } from '$lib/stores/routing' ;
1112import { eventStore } from '$lib/stores/events' ;
1213import { clipboardStore } from '$lib/stores/clipboard' ;
@@ -142,7 +143,7 @@ function buildNodeMenu(nodeId: string): MenuItemType[] {
142143 label : 'Delete' ,
143144 icon : 'trash' ,
144145 shortcut : 'Del' ,
145- action : ( ) => graphStore . removeNode ( nodeId )
146+ action : ( ) => historyStore . mutate ( ( ) => graphStore . removeNode ( nodeId ) )
146147 }
147148 ] ;
148149 }
@@ -191,7 +192,7 @@ function buildNodeMenu(nodeId: string): MenuItemType[] {
191192 shortcut : 'Ctrl+D' ,
192193 action : ( ) => {
193194 graphStore . selectNode ( nodeId , false ) ;
194- graphStore . duplicateSelected ( ) ;
195+ historyStore . mutate ( ( ) => graphStore . duplicateSelected ( ) ) ;
195196 }
196197 } ,
197198 {
@@ -208,7 +209,7 @@ function buildNodeMenu(nodeId: string): MenuItemType[] {
208209 label : 'Delete' ,
209210 icon : 'trash' ,
210211 shortcut : 'Del' ,
211- action : ( ) => graphStore . removeNode ( nodeId )
212+ action : ( ) => historyStore . mutate ( ( ) => graphStore . removeNode ( nodeId ) )
212213 }
213214 ) ;
214215
@@ -228,7 +229,7 @@ function buildSelectionMenu(
228229 label : `Duplicate ${ count } nodes` ,
229230 icon : 'copy' ,
230231 shortcut : 'Ctrl+D' ,
231- action : ( ) => graphStore . duplicateSelected ( )
232+ action : ( ) => historyStore . mutate ( ( ) => graphStore . duplicateSelected ( ) )
232233 } ,
233234 {
234235 label : `Copy ${ count } nodes` ,
@@ -270,7 +271,7 @@ function buildEventMenu(eventId: string): MenuItemType[] {
270271 shortcut : 'Ctrl+D' ,
271272 action : ( ) => {
272273 eventStore . selectEvent ( eventId , false ) ;
273- eventStore . duplicateSelected ( ) ;
274+ historyStore . mutate ( ( ) => eventStore . duplicateSelected ( ) ) ;
274275 }
275276 } ,
276277 {
@@ -287,7 +288,7 @@ function buildEventMenu(eventId: string): MenuItemType[] {
287288 label : 'Delete' ,
288289 icon : 'trash' ,
289290 shortcut : 'Del' ,
290- action : ( ) => eventStore . removeEvent ( eventId )
291+ action : ( ) => historyStore . mutate ( ( ) => eventStore . removeEvent ( eventId ) )
291292 }
292293 ] ;
293294}
@@ -307,7 +308,7 @@ function buildEdgeMenu(edgeId: string): MenuItemType[] {
307308 label : 'Delete' ,
308309 icon : 'trash' ,
309310 shortcut : 'Del' ,
310- action : ( ) => graphStore . removeConnection ( edgeId )
311+ action : ( ) => historyStore . mutate ( ( ) => graphStore . removeConnection ( edgeId ) )
311312 }
312313 ] ;
313314}
@@ -338,7 +339,7 @@ function buildCanvasMenu(
338339 icon : 'type' ,
339340 action : ( ) => {
340341 const flowPos = screenToFlow ( screenPosition ) ;
341- graphStore . addAnnotation ( flowPos ) ;
342+ historyStore . mutate ( ( ) => graphStore . addAnnotation ( flowPos ) ) ;
342343 }
343344 } ,
344345 DIVIDER ,
@@ -413,7 +414,7 @@ function buildAnnotationMenu(annotationId: string): MenuItemType[] {
413414 icon : 'font-size-increase' ,
414415 action : ( ) => {
415416 if ( currentFontSize < ANNOTATION_FONT_SIZE . MAX ) {
416- graphStore . updateAnnotation ( annotationId , { fontSize : currentFontSize + ANNOTATION_FONT_SIZE . STEP } ) ;
417+ historyStore . mutate ( ( ) => graphStore . updateAnnotation ( annotationId , { fontSize : currentFontSize + ANNOTATION_FONT_SIZE . STEP } ) ) ;
417418 }
418419 } ,
419420 disabled : currentFontSize >= ANNOTATION_FONT_SIZE . MAX
@@ -423,7 +424,7 @@ function buildAnnotationMenu(annotationId: string): MenuItemType[] {
423424 icon : 'font-size-decrease' ,
424425 action : ( ) => {
425426 if ( currentFontSize > ANNOTATION_FONT_SIZE . MIN ) {
426- graphStore . updateAnnotation ( annotationId , { fontSize : currentFontSize - ANNOTATION_FONT_SIZE . STEP } ) ;
427+ historyStore . mutate ( ( ) => graphStore . updateAnnotation ( annotationId , { fontSize : currentFontSize - ANNOTATION_FONT_SIZE . STEP } ) ) ;
427428 }
428429 } ,
429430 disabled : currentFontSize <= ANNOTATION_FONT_SIZE . MIN
@@ -435,7 +436,7 @@ function buildAnnotationMenu(annotationId: string): MenuItemType[] {
435436 shortcut : 'Ctrl+D' ,
436437 action : ( ) => {
437438 graphStore . selectNode ( annotationId , false ) ;
438- graphStore . duplicateSelected ( ) ;
439+ historyStore . mutate ( ( ) => graphStore . duplicateSelected ( ) ) ;
439440 }
440441 } ,
441442 {
@@ -452,7 +453,7 @@ function buildAnnotationMenu(annotationId: string): MenuItemType[] {
452453 label : 'Delete' ,
453454 icon : 'trash' ,
454455 shortcut : 'Del' ,
455- action : ( ) => graphStore . removeAnnotation ( annotationId )
456+ action : ( ) => historyStore . mutate ( ( ) => graphStore . removeAnnotation ( annotationId ) )
456457 }
457458 ] ;
458459}
0 commit comments