11import {
2- JupyterFrontEnd , JupyterFrontEndPlugin
2+ JupyterFrontEnd , JupyterFrontEndPlugin , IRouter
33} from '@jupyterlab/application' ;
44import { ILauncher } from '@jupyterlab/launcher' ;
55import { IFrame } from '@jupyterlab/apputils' ;
@@ -11,14 +11,15 @@ import {IDocumentManager} from '@jupyterlab/docmanager';
1111const extension : JupyterFrontEndPlugin < void > = {
1212 id : 'exampleLoader' ,
1313 autoStart : true ,
14- requires : [ ILauncher , IDocumentManager ] ,
14+ requires : [ ILauncher , IDocumentManager , IRouter ] ,
1515 activate : loadExamples
1616} ;
1717
1818export default extension ;
1919
2020export function loadExamples (
21- app : JupyterFrontEnd , launcher : ILauncher , docmanager : IDocumentManager ) : Promise < void > {
21+ app : JupyterFrontEnd , launcher : ILauncher ,
22+ docmanager : IDocumentManager , router : IRouter ) : Promise < void > {
2223
2324 // create new commands and add them to app.commands
2425 function appendNewCommand ( item : any ) {
@@ -53,6 +54,11 @@ export function loadExamples(
5354 } ) ;
5455 }
5556
57+ router . register ( {
58+ command : 'vires:copyRouter' ,
59+ pattern : / ( \? c o p y | \& c o p y ) ( [ ^ ? ] + ) /
60+ } ) ;
61+
5662 /*appendNewCommand({
5763 name: 'Example Loader',
5864 target: 'widget',
@@ -80,6 +86,18 @@ export function loadExamples(
8086 }
8187 } ) ;
8288
89+ app . commands . addCommand ( 'vires:copyRouter' , {
90+ label : 'Router command for copy functionality' ,
91+ iconClass : 'templateIcon' ,
92+ execute : ( args ) => {
93+ const path = ( args . search as string ) . replace ( '?copy' , '' ) ;
94+ docmanager . copy ( path , '' )
95+ . then ( ( result ) => {
96+ docmanager . open ( result . path ) ;
97+ } ) ;
98+ }
99+ } ) ;
100+
83101 console . log ( docmanager ) ;
84102
85103 launcher . add ( {
0 commit comments