···4646 protected createNewWidget(
4747 context: DocumentRegistry.IContext<DocumentModel>
4848 ): BlocklyEditor {
4949+ // Set a map to the model. The widgets manager expects a Notebook model
5050+ // but the only notebook property it uses is the metadata.
5151+ context.model['metadata'] = new Map();
4952 const manager = new BlocklyManager(
5053 this._registry,
5154 context.sessionContext,
+17
packages/blockly/src/layout.ts
···5757 this._manager.changed.connect(this._onManagerChanged, this);
5858 }
59596060+ /*
6161+ * The code cell.
6262+ */
6363+ get cell(): CodeCell {
6464+ return this._cell;
6565+ }
6666+6767+ /*
6868+ * The current workspace.
6969+ */
6070 get workspace(): Blockly.Workspace {
6171 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6272 // @ts-ignore
6373 return Blockly.serialization.workspaces.save(this._workspace);
6474 }
65757676+ /*
7777+ * Set a new workspace.
7878+ */
6679 set workspace(workspace: Blockly.Workspace) {
6780 const data = workspace === null ? { variables: [] } : workspace;
6881 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
···138151 return finalToplevelInit;
139152 }
140153154154+ /*
155155+ * Generates and runs the code from the current workspace.
156156+ */
141157 run(): void {
142158 // Get extra code from the blocks in the workspace.
143159 const extra_init = this.getBlocksToplevelInit();
144160 // Serializing our workspace into the chosen language generator.
145161 const code =
146162 extra_init + this._manager.generator.workspaceToCode(this._workspace);
163163+ //const code = "import ipywidgets as widgets\nwidgets.IntSlider()";
147164 this._cell.model.sharedModel.setSource(code);
148165149166 // Execute the code using the kernel, by using a static method from the
+17
packages/blockly/src/widget.ts
···1919 SelectToolbox,
2020 Spacer
2121} from './toolbar';
2222+import { CodeCell } from '@jupyterlab/cells';
22232324/**
2425 * DocumentWidget: widget that represents the view or editor for a file type.
···8081 */
8182export class BlocklyPanel extends SplitPanel {
8283 private _context: DocumentRegistry.IContext<DocumentModel>;
8484+ private _rendermime: IRenderMimeRegistry;
83858486 /**
8587 * Construct a `BlocklyPanel`.
···9698 });
9799 this.addClass('jp-BlocklyPanel');
98100 this._context = context;
101101+ this._rendermime = rendermime;
99102100103 // Load the content of the file when the context is ready
101104 this._context.ready.then(() => this._load());
102105 // Connect to the save signal
103106 this._context.saveState.connect(this._onSave, this);
107107+ }
108108+109109+ /*
110110+ * The code cell.
111111+ */
112112+ get cell(): CodeCell {
113113+ return (this.layout as BlocklyLayout).cell;
114114+ }
115115+116116+ /*
117117+ * The rendermime instance used in the code cell.
118118+ */
119119+ get rendermime(): IRenderMimeRegistry {
120120+ return this._rendermime;
104121 }
105122106123 /**