Communication between a host page and a JupyterLite instance running in an IFrame for sending code. #15953
Unanswered
gautamsarawagi
asked this question in
Q&A
Replies: 2 comments
-
Are you using jupyterlite or pure JupyterLab? Jupyterlite's repository is: https://github.com/jupyterlite/jupyterlite |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes, I am using jupyterlite but need the extensions to be built with jupyterlab that's why. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I came across this code : https://jupyterlite.readthedocs.io/en/stable/howto/configure/advanced/iframe.html
But this is for managing the themes. I would like to update this to send codes from the hostpage to the iframe for that I found that I can send it using the codeEditor but getting some error. My code for this:
`import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
import { CodeEditor } from '@jupyterlab/codeeditor';
/**
Initialization data for the jupyterlab-iframe-bridge-example extension.
*/
const plugin: JupyterFrontEndPlugin = {
id: 'jupyterlab-iframe-bridge-example:plugin',
autoStart: true,
activate: (app: JupyterFrontEnd) => {
console.log('JupyterLab extension jupyterlab-iframe-bridge-example is activated!');
/* Incoming messages management */
window.addEventListener('message', (event) => {
if (event.data.type === 'from-host-to-iframe') {
console.log('Code received in the iframe:', event.data.code);
const editor = CodeEditor.CodeMirrorEditor.findInstance('jp-repl-snippet-editor');
if (editor) {
editor.editor.setValue(event.data.code);
editor.editor.focus();
}
}
});
},
};
export default plugin;`
Beta Was this translation helpful? Give feedback.
All reactions