@@ -30,6 +30,11 @@ import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
30
30
31
31
import { ILauncher } from '@jupyterlab/launcher' ;
32
32
33
+ import {
34
+ undoIcon ,
35
+ redoIcon ,
36
+ } from '@jupyterlab/ui-components' ;
37
+
33
38
import { CommandRegistry } from '@lumino/commands' ;
34
39
35
40
import { Token } from '@lumino/coreutils' ;
@@ -514,8 +519,8 @@ function addCommands(app: JupyterFrontEnd, tracker: IDrawioTracker): void {
514
519
// Select vertices, select edges, select all, select none
515
520
// lock/unlock
516
521
const editCommands = [
517
- { name : 'undo' , label : 'Undo' } , //Ctrl+Z
518
- { name : 'redo' , label : 'Redo' } , //Ctrl+Shift+Z
522
+ // { name: 'undo', label: 'Undo' }, //Ctrl+Z
523
+ // { name: 'redo', label: 'Redo' }, //Ctrl+Shift+Z
519
524
{ name : 'cut' , label : 'Cut' } , //Ctrl+X
520
525
{ name : 'copy' , label : 'Copy' } , //Ctrl+C
521
526
{ name : 'paste' , label : 'Paste' } , //Ctrl+V
@@ -559,6 +564,56 @@ function addCommands(app: JupyterFrontEnd, tracker: IDrawioTracker): void {
559
564
}
560
565
} ) ;
561
566
} ) ;
567
+ app . commands . addCommand ( 'drawio:command/undo' , {
568
+ label : 'Undo' ,
569
+ caption : 'Undo (Ctrl+Z)' ,
570
+ icon : undoIcon ,
571
+ isEnabled : ( ) => {
572
+ if (
573
+ tracker . currentWidget !== null &&
574
+ tracker . currentWidget === app . shell . currentWidget
575
+ ) {
576
+ const wdg = app . shell . currentWidget as DrawIODocumentWidget ;
577
+ return wdg . getAction ( 'undo' ) . enabled ;
578
+ } else {
579
+ return false ;
580
+ }
581
+ } ,
582
+ execute : ( ) => {
583
+ if (
584
+ tracker . currentWidget !== null &&
585
+ tracker . currentWidget === app . shell . currentWidget
586
+ ) {
587
+ const wdg = app . shell . currentWidget as DrawIODocumentWidget ;
588
+ wdg . getAction ( 'undo' ) . funct ( ) ;
589
+ }
590
+ }
591
+ } ) ;
592
+ app . commands . addCommand ( 'drawio:command/redo' , {
593
+ label : 'Redo' ,
594
+ caption : 'redo (Ctrl+Shift+Z)' ,
595
+ icon : redoIcon ,
596
+ isEnabled : ( ) => {
597
+ if (
598
+ tracker . currentWidget !== null &&
599
+ tracker . currentWidget === app . shell . currentWidget
600
+ ) {
601
+ const wdg = app . shell . currentWidget as DrawIODocumentWidget ;
602
+ return wdg . getAction ( 'redo' ) . enabled ;
603
+ } else {
604
+ return false ;
605
+ }
606
+ } ,
607
+ execute : ( ) => {
608
+ if (
609
+ tracker . currentWidget !== null &&
610
+ tracker . currentWidget === app . shell . currentWidget
611
+ ) {
612
+ const wdg = app . shell . currentWidget as DrawIODocumentWidget ;
613
+ wdg . getAction ( 'redo' ) . funct ( ) ;
614
+ }
615
+ }
616
+ } ) ;
562
617
563
618
// View MENU
564
619
//Not Working:
0 commit comments