@@ -4,72 +4,13 @@ import {
4
4
ILayoutRestorer
5
5
} from '@jupyterlab/application' ;
6
6
7
- // import {
8
- // ICommandPalette,
9
- // MainAreaWidget,
10
- // WidgetTracker
11
- // } from '@jupyterlab/apputils';
12
-
13
- // import { Widget } from '@lumino/widgets';
14
-
15
7
import { WidgetTracker } from '@jupyterlab/apputils' ;
16
8
17
- // import * as Blockly from 'blockly';
18
-
19
9
import { BlocklyEditorFactory } from './factory' ;
20
10
21
- // namespace CommandIDs {
22
- // export const open = 'jupyterlab-blocky:open-editor';
23
- // }
24
11
25
12
import { BlocklyEditor } from './widget' ;
26
13
27
- // const TOOLBOX = {
28
- // kind: 'flyoutToolbox',
29
- // contents : [
30
- // {
31
- // kind : 'block',
32
- // type : 'controls_if'
33
- // },
34
- // {
35
- // kind : 'block',
36
- // type : 'controls_ifelse'
37
- // },
38
- // {
39
- // kind : 'block',
40
- // type : 'logic_compare'
41
- // },
42
- // {
43
- // kind : 'block',
44
- // type : 'logic_operation'
45
- // },
46
- // {
47
- // kind : 'block',
48
- // type : 'logic_boolean'
49
- // },
50
- // {
51
- // kind : 'block',
52
- // type : 'controls_whileUntil'
53
- // },
54
- // {
55
- // kind : 'block',
56
- // type : 'controls_repeat_ext'
57
- // },
58
- // {
59
- // kind : 'block',
60
- // type : 'controls_for'
61
- // },
62
- // {
63
- // kind : 'block',
64
- // type : 'math_number'
65
- // },
66
- // {
67
- // kind : 'block',
68
- // type : 'math_arithmetic'
69
- // }
70
- // ]
71
- // };
72
-
73
14
/**
74
15
* The name of the factory that creates the editor widgets.
75
16
*/
@@ -81,59 +22,26 @@ import { BlocklyEditor } from './widget';
81
22
const plugin : JupyterFrontEndPlugin < void > = {
82
23
id : 'jupyterlab-blocky:plugin' ,
83
24
autoStart : true ,
84
- // requires: [ICommandPalette, ILayoutRestorer],
85
- // activate: (
86
- // app: JupyterFrontEnd,
87
- // palette: ICommandPalette,
88
- // restorer: ILayoutRestorer
89
- // ) => {
90
25
requires : [ ILayoutRestorer ] ,
91
26
activate : ( app : JupyterFrontEnd , restorer : ILayoutRestorer ) => {
92
27
console . log ( 'JupyterLab extension jupyterlab-blocky is activated!' ) ;
93
28
94
- // let editorPanel: MainAreaWidget | null = null;
95
-
96
- // // Namespace for the tracker
97
- // const namespace = 'documents-example';
29
+ // Namespace for the tracker
98
30
const namespace = 'jupyterlab-blocky' ;
31
+
99
32
// Creating the tracker for the document
100
- // const tracker = new WidgetTracker<MainAreaWidget>({ namespace });
101
33
const tracker = new WidgetTracker < BlocklyEditor > ( { namespace } ) ;
102
34
103
35
// Handle state restoration.
104
36
if ( restorer ) {
105
37
// When restoring the app, if the document was open, reopen it
106
38
restorer . restore ( tracker , {
107
- // command: CommandIDs.open,
108
- // name: widget => ''
109
39
command : 'docmanager:open' ,
110
40
args : widget => ( { path : widget . context . path , factory : FACTORY } ) ,
111
41
name : widget => widget . context . path
112
42
} ) ;
113
43
}
114
44
115
- // app.commands.addCommand(CommandIDs.open, {
116
- // label: 'Open Blockly Editor',
117
- // caption: 'Open Blockly Editor',
118
- // isEnabled: () => true,
119
- // execute: () => {
120
- // const content = new Widget();
121
- // content.id = 'jp-Blockly-container';
122
- // editorPanel = new MainAreaWidget({ content });
123
- // editorPanel.title.label = 'Blockly Editor';
124
-
125
- // editorPanel.disposed.connect(() => {
126
- // editorPanel = null;
127
- // workspace.dispose();
128
- // });
129
-
130
- // app.shell.add(editorPanel, 'main');
131
-
132
- // const workspace = Blockly.inject(content.node, {
133
- // toolbox: TOOLBOX
134
- // });
135
- // console.debug('Blockly:', workspace);
136
- // }
137
45
// Creating the widget factory to register it so the document manager knows about
138
46
// our new DocumentWidget
139
47
const widgetFactory = new BlocklyEditorFactory ( {
@@ -142,17 +50,12 @@ const plugin: JupyterFrontEndPlugin<void> = {
142
50
fileTypes : [ 'json' ]
143
51
} ) ;
144
52
145
- // if (palette) {
146
- // palette.addItem({
147
- // command: CommandIDs.open,
148
- // category: 'Blockly Editor'
149
53
// Add the widget to the tracker when it's created
150
54
widgetFactory . widgetCreated . connect ( ( sender , widget ) => {
151
55
// Notify the instance tracker if restore data needs to update.
152
56
widget . context . pathChanged . connect ( ( ) => {
153
57
tracker . save ( widget ) ;
154
58
} ) ;
155
- // }
156
59
tracker . add ( widget ) ;
157
60
} ) ;
158
61
// Registering the widget factory
0 commit comments