Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,8 @@ dmypy.json

# Yarn cache
.yarn/

# Miscellaneous
playground/

.vscode/
4 changes: 2 additions & 2 deletions jupyter_rtc_core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class RtcExtensionApp(ExtensionApp):
# this can be deleted prior to initial release.
(r"jupyter-rtc-core/get-example/?", RouteHandler),
# global awareness websocket
(r"api/collaboration/room/JupyterLab:globalAwareness/?", GlobalAwarenessWebsocket),
#(r"api/collaboration/room/JupyterLab:globalAwareness/?", GlobalAwarenessWebsocket),
# ydoc websocket
(r"api/collaboration/room/(.*)", YRoomWebsocket)
#(r"api/collaboration/room/(.*)", YRoomWebsocket)
]

def initialize(self):
Expand Down
26 changes: 24 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
} from '@jupyterlab/application';

import { ISettingRegistry } from '@jupyterlab/settingregistry';

import { IEditorServices } from '@jupyterlab/codeeditor';
import { requestAPI } from './handler';
import { NotebookPanel } from '@jupyterlab/notebook';
import { YNotebookContentFactory } from './notebook';

/**
* Initialization data for the @jupyter/rtc-core extension.
Expand Down Expand Up @@ -41,4 +43,24 @@ const plugin: JupyterFrontEndPlugin<void> = {
}
};

export default plugin;
/**
* The notebook cell factory provider.
*/
const factory: JupyterFrontEndPlugin<NotebookPanel.IContentFactory> = {
id: '@jupyter-rtc-core/notebook-extension:factory',
description: 'Provides the notebook cell factory.',
provides: NotebookPanel.IContentFactory,
requires: [IEditorServices],
autoStart: true,
activate: (app: JupyterFrontEnd, editorServices: IEditorServices) => {
const editorFactory = editorServices.factoryService.newInlineEditor;
return new YNotebookContentFactory({ editorFactory });
}
};

const plugins: JupyterFrontEndPlugin<any>[] = [
plugin,
factory
];

export default plugins;
22 changes: 22 additions & 0 deletions src/notebook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { CodeCell, CodeCellLayout } from '@jupyterlab/cells';
import { NotebookPanel } from '@jupyterlab/notebook';
import { KernelMessage } from '@jupyterlab/services'

class YCodeCell extends CodeCell {
/**
* Construct a code cell widget.
*/
constructor(options: CodeCell.IOptions) {
super({ layout: new CodeCellLayout(), ...options, placeholder: true });
this["_output"]["_onIOPub"] = (msg: KernelMessage.IIOPubMessage) => {
const log = { ...msg.content, output_type: msg.header.msg_type };
console.log(log)
}
}
}

export class YNotebookContentFactory extends NotebookPanel.ContentFactory {
createCodeCell(options: CodeCell.IOptions): YCodeCell {
return new YCodeCell(options).initializeState()
}
}