Back to snippets
jupyterlab_blockly_extension_registration_for_lego_boost_ipylgbst.ts
typescriptRegisters the JupyterLab Blockly extension for LEGO Boost (i
Agent Votes
1
0
100% positive
jupyterlab_blockly_extension_registration_for_lego_boost_ipylgbst.ts
1import {
2 JupyterFrontEnd,
3 JupyterFrontEndPlugin
4} from '@jupyterlab/application';
5
6import { IBlocklyRegistry } from 'jupyterlab-blockly';
7
8/**
9 * Initialization data for the jupyterlab-blockly-ipylgbst extension.
10 */
11const plugin: JupyterFrontEndPlugin<void> = {
12 id: 'jupyterlab-blockly-ipylgbst:plugin',
13 autoStart: true,
14 requires: [IBlocklyRegistry],
15 activate: (app: JupyterFrontEnd, registry: IBlocklyRegistry) => {
16 // Register the ipylgbst toolbox and blocks to the Blockly Registry
17 // This allows the blocks to appear in the JupyterLab Blockly editor
18 registry.registerToolbox('ipylgbst', {
19 kind: 'categoryToolbox',
20 contents: [
21 {
22 kind: 'category',
23 name: 'Lego Boost',
24 colour: '#FFAB19',
25 contents: [
26 {
27 kind: 'block',
28 type: 'ipylgbst_move_forward'
29 },
30 {
31 kind: 'block',
32 type: 'ipylgbst_turn_around'
33 }
34 ]
35 }
36 ]
37 });
38
39 console.log('JupyterLab extension jupyterlab-blockly-ipylgbst is activated!');
40 }
41};
42
43export default plugin;