@@ -10,7 +10,9 @@ import * as Blockly from 'blockly';
10
10
import { BlocklyRegistry } from './registry' ;
11
11
12
12
/**
13
- * BlocklyManager
13
+ * BlocklyManager the manager for each document
14
+ * to select the toolbox and the generator that the
15
+ * user wants to use on a specific document.
14
16
*/
15
17
export class BlocklyManager {
16
18
private _toolbox : JSONObject ;
@@ -34,34 +36,64 @@ export class BlocklyManager {
34
36
this . _sessionContext . kernelChanged . connect ( this . _onKernelChanged , this ) ;
35
37
}
36
38
39
+ /**
40
+ * Returns the selected toolbox.
41
+ */
37
42
get toolbox ( ) : JSONObject {
38
43
return this . _toolbox ;
39
44
}
40
45
46
+ /**
47
+ * Returns the name of the selected kernel.
48
+ */
41
49
get kernel ( ) : string | undefined {
42
50
return this . _selectedKernel ?. name || 'No kernel' ;
43
51
}
44
52
53
+ /**
54
+ * Returns the selected generator.
55
+ */
45
56
get generator ( ) : Blockly . Generator {
46
57
return this . _generator ;
47
58
}
48
59
60
+ /**
61
+ * Signal triggered when the manager changes.
62
+ */
49
63
get changed ( ) : ISignal < this, BlocklyManager . Change > {
50
64
return this . _changed ;
51
65
}
52
66
67
+ /**
68
+ * Dispose.
69
+ */
53
70
dispose ( ) : void {
54
71
this . _sessionContext . kernelChanged . disconnect ( this . _onKernelChanged , this ) ;
55
72
}
56
73
74
+ /**
75
+ * Set the selected toolbox.
76
+ *
77
+ * @argument name The name of the toolbox.
78
+ */
57
79
setToolbox ( name : string ) {
58
80
this . _toolbox = this . _registry . toolboxes . get ( name ) ;
59
81
}
60
82
83
+ /**
84
+ * Set the selected kernel.
85
+ *
86
+ * @argument name The name of the kernel.
87
+ */
61
88
selectKernel ( name : string ) {
62
89
this . _sessionContext . changeKernel ( { name } ) ;
63
90
}
64
91
92
+ /**
93
+ * Set the selected toolbox.
94
+ *
95
+ * @returns the list of available kernels for Blockly
96
+ */
65
97
listKernels ( ) : { label : string ; value : string } [ ] {
66
98
const specs = this . _sessionContext . specsManager . specs . kernelspecs ;
67
99
const list : { label : string ; value : string } [ ] = [ ] ;
@@ -88,6 +120,14 @@ export class BlocklyManager {
88
120
}
89
121
}
90
122
123
+ /**
124
+ * BlocklyManager the manager for each document
125
+ * to select the toolbox and the generator that the
126
+ * user wants to use on a specific document.
127
+ */
91
128
export namespace BlocklyManager {
129
+ /**
130
+ * The argument of the signal manager changed.
131
+ */
92
132
export type Change = 'toolbox' | 'kernel' ;
93
133
}
0 commit comments