I am working on converting an extension we had for pre-JL 4 that serialized a notebook to JSON and then sent the JSON to a service.
In the old method we could get a hold of the notebook and serialize by executing:
Jupyter.notebook.toJSON();
I am struggling to figure out where to find the documentation that describes how to get a hold of the notebook for this purpose.
I have a plugin registered correctly and a custom command ready to go:
const plugin: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab-examples/toolbar-button:plugin',
description:
'A JupyterLab extension adding a button to the Notebook toolbar.',
autoStart: true,
activate: (app: JupyterFrontEnd, doc: DocumentRegistry) => {
// Nothing is needed
const { commands } = app;
const command = 'jlab-examples:command';
// Add a command
commands.addCommand(command, {
label: 'Submit',
caption: 'Send your notebook to be graded',
execute: (args: any) => {
console.log(`jlab-examples:command has been called.`);
**// how to get notebook model for serialization?**
}
});
}
};
The object model is difficult to parse through. I am assuming I need to get a hold of the notebook widget and from there extract the model in order to then serialize. But I could wrong here as well.
doc.getWidgetFactory("Notebook") ?
Thanks for the help.