@@ -178,6 +178,18 @@ const extension: JupyterFrontEndPlugin<IDashboardTracker> = {
178178 rank : 6 ,
179179 } ) ;
180180
181+ app . contextMenu . addItem ( {
182+ command : CommandIDs . toggleInfiniteScroll ,
183+ selector : '.pr-JupyterDashboard' ,
184+ rank : 7 ,
185+ } ) ;
186+
187+ app . contextMenu . addItem ( {
188+ command : CommandIDs . trimDashboard ,
189+ selector : '.pr-JupyterDashboard' ,
190+ rank : 8 ,
191+ } ) ;
192+
181193 app . contextMenu . addItem ( {
182194 command : CommandIDs . deleteOutput ,
183195 selector : '.pr-EditableWidget' ,
@@ -191,11 +203,17 @@ const extension: JupyterFrontEndPlugin<IDashboardTracker> = {
191203 } ) ;
192204
193205 app . contextMenu . addItem ( {
194- type : 'separator' ,
206+ command : CommandIDs . toggleWidgetMode ,
195207 selector : '.pr-EditableWidget' ,
196208 rank : 2 ,
197209 } ) ;
198210
211+ app . contextMenu . addItem ( {
212+ type : 'separator' ,
213+ selector : '.pr-EditableWidget' ,
214+ rank : 3 ,
215+ } ) ;
216+
199217 app . contextMenu . addItem ( {
200218 command : CommandIDs . openFromMetadata ,
201219 selector : '.jp-Notebook' ,
@@ -372,6 +390,7 @@ function addCommands(
372390 widget . fitContent ( ) ;
373391 }
374392 } ,
393+ isVisible : ( args ) => outputTracker . currentWidget . mode === 'free-edit' ,
375394 isToggled : ( args ) => outputTracker . currentWidget . fitToContent ,
376395 } ) ;
377396
@@ -398,7 +417,7 @@ function addCommands(
398417 execute : ( args ) => {
399418 const dashboard = dashboardTracker . currentWidget ;
400419 if ( dashboard . model . mode === 'present' ) {
401- dashboard . model . mode = 'edit' ;
420+ dashboard . model . mode = 'free- edit' ;
402421 } else {
403422 dashboard . model . mode = 'present' ;
404423 }
@@ -585,7 +604,6 @@ function addCommands(
585604 cellId : metadata . id ,
586605 pos : metadata . pos
587606 } ;
588- console . log ( 'widget added' , widgetInfo ) ;
589607 widgetstore . addWidget ( widgetInfo ) ;
590608 }
591609 }
@@ -616,7 +634,44 @@ function addCommands(
616634 }
617635 return false ;
618636 }
619- } )
637+ } ) ;
638+
639+ commands . addCommand ( CommandIDs . toggleWidgetMode , {
640+ label : 'Snap to Grid' ,
641+ isToggled : ( args ) => {
642+ const widget = outputTracker . currentWidget ;
643+ return widget . mode === 'grid-edit' ;
644+ } ,
645+ execute : ( args ) => {
646+ const widget = outputTracker . currentWidget ;
647+ if ( widget . mode === 'grid-edit' ) {
648+ widget . mode = 'free-edit' ;
649+ } else if ( widget . mode === 'free-edit' ) {
650+ widget . mode = 'grid-edit' ;
651+ }
652+ }
653+ } ) ;
654+
655+ commands . addCommand ( CommandIDs . toggleInfiniteScroll , {
656+ label : 'Infinite Scroll' ,
657+ isToggled : ( args ) => dashboardTracker . currentWidget ?. model . scrollMode === 'infinite' ,
658+ execute : ( args ) => {
659+ const dashboard = dashboardTracker . currentWidget ;
660+ if ( dashboard . model . scrollMode === 'infinite' ) {
661+ dashboard . model . scrollMode = 'constrained' ;
662+ } else {
663+ dashboard . model . scrollMode = 'infinite' ;
664+ }
665+ }
666+ } ) ;
667+
668+ commands . addCommand ( CommandIDs . trimDashboard , {
669+ label : 'Trim Dashboard' ,
670+ execute : ( args ) => {
671+ const dashboard = dashboardTracker . currentWidget ;
672+ ( dashboard . layout as DashboardLayout ) . trimDashboard ( ) ;
673+ }
674+ } ) ;
620675}
621676
622677/**
0 commit comments