@@ -30,6 +30,11 @@ import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
3030
3131import { ILauncher } from '@jupyterlab/launcher' ;
3232
33+ import {
34+ undoIcon ,
35+ redoIcon ,
36+ } from '@jupyterlab/ui-components' ;
37+
3338import { CommandRegistry } from '@lumino/commands' ;
3439
3540import { Token } from '@lumino/coreutils' ;
@@ -514,8 +519,8 @@ function addCommands(app: JupyterFrontEnd, tracker: IDrawioTracker): void {
514519 // Select vertices, select edges, select all, select none
515520 // lock/unlock
516521 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
519524 { name : 'cut' , label : 'Cut' } , //Ctrl+X
520525 { name : 'copy' , label : 'Copy' } , //Ctrl+C
521526 { name : 'paste' , label : 'Paste' } , //Ctrl+V
@@ -559,6 +564,56 @@ function addCommands(app: JupyterFrontEnd, tracker: IDrawioTracker): void {
559564 }
560565 } ) ;
561566 } ) ;
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+ } ) ;
562617
563618 // View MENU
564619 //Not Working:
0 commit comments