1
1
import {
2
- JupyterFrontEnd , JupyterFrontEndPlugin
2
+ JupyterFrontEnd , JupyterFrontEndPlugin , IRouter
3
3
} from '@jupyterlab/application' ;
4
4
import { ILauncher } from '@jupyterlab/launcher' ;
5
5
import { IFrame } from '@jupyterlab/apputils' ;
@@ -11,14 +11,15 @@ import {IDocumentManager} from '@jupyterlab/docmanager';
11
11
const extension : JupyterFrontEndPlugin < void > = {
12
12
id : 'exampleLoader' ,
13
13
autoStart : true ,
14
- requires : [ ILauncher , IDocumentManager ] ,
14
+ requires : [ ILauncher , IDocumentManager , IRouter ] ,
15
15
activate : loadExamples
16
16
} ;
17
17
18
18
export default extension ;
19
19
20
20
export function loadExamples (
21
- app : JupyterFrontEnd , launcher : ILauncher , docmanager : IDocumentManager ) : Promise < void > {
21
+ app : JupyterFrontEnd , launcher : ILauncher ,
22
+ docmanager : IDocumentManager , router : IRouter ) : Promise < void > {
22
23
23
24
// create new commands and add them to app.commands
24
25
function appendNewCommand ( item : any ) {
@@ -53,6 +54,11 @@ export function loadExamples(
53
54
} ) ;
54
55
}
55
56
57
+ router . register ( {
58
+ command : 'vires:copyRouter' ,
59
+ pattern : / ( \? c o p y | \& c o p y ) ( [ ^ ? ] + ) /
60
+ } ) ;
61
+
56
62
/*appendNewCommand({
57
63
name: 'Example Loader',
58
64
target: 'widget',
@@ -80,6 +86,18 @@ export function loadExamples(
80
86
}
81
87
} ) ;
82
88
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
+
83
101
console . log ( docmanager ) ;
84
102
85
103
launcher . add ( {
0 commit comments