A JupyterLab extension for widgets based on Yjs.
Project description
JupyterLab extension for widgets based on Yjs
Requirements
- JupyterLab == 4.0.0b0
Installation
You can install yjs-widgets using pip:
pip install yjs-widgets
Usage
import { IJupyterYModel } from './types';
import { JupyterYModel } from './model';
import { IJupyterYWidgetManager } from './notebookrenderer/types';
import {
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';
class MyWidget {
constructor(yModel: IJupyterYModel, node: HTMLElement) {
this.yModel = yModel;
this.node = node;
yModel.sharedModel.attrsChanged.connect(() => {
this._attrsChanged();
});
node.textContent = 'Hello world!';
}
_attrsChanged(): void {
const foo: string = this.yModel.sharedModel.getAttr('foo') as string;
const bar: string = this.yModel.sharedModel.getAttr('bar') as string;
this.node.textContent = `foo=${foo}, bar=${bar}`;
}
yModel: IJupyterYModel;
node: HTMLElement;
}
export const foo: JupyterFrontEndPlugin<void> = {
id: 'foo:bar',
autoStart: true,
requires: [IJupyterYWidgetManager],
activate: (app: JupyterFrontEnd, wm: IJupyterYWidgetManager): void => {
wm.registerWidget('MyWidget', JupyterYModel, MyWidget);
}
};
Contributing
yjs-widgets is an open-source project, and contributions are always welcome. If you would like to contribute, please fork the repository and submit a pull request.
See CONTRIBUTING for dev installation instructions.
License
yjs-widgets is licensed under the BSD 3-Clause License. See the LICENSE file for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yjs_widgets-0.3.5.tar.gz
(162.2 kB
view details)
Built Distribution
File details
Details for the file yjs_widgets-0.3.5.tar.gz
.
File metadata
- Download URL: yjs_widgets-0.3.5.tar.gz
- Upload date:
- Size: 162.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0039f4b043cdeeab7af676e57b1e451531964e71f5ba992800bc09fdc5ba3616 |
|
MD5 | 18be42bb781aafb886ebbf9ddced82f9 |
|
BLAKE2b-256 | dd9a43aa1eee3548555f705a7be11c8f82960623a4e913074cce8858cbf42bf2 |
File details
Details for the file yjs_widgets-0.3.5-py3-none-any.whl
.
File metadata
- Download URL: yjs_widgets-0.3.5-py3-none-any.whl
- Upload date:
- Size: 72.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7f1b81b75403efefcb35730fc2dbfad216b7158454fe5c4481d32129b05bd0e |
|
MD5 | fa2de1234eebcef29eca38275b725d8e |
|
BLAKE2b-256 | 3b433ac21f8898ee5090249d4577b80ede2aa1bb706be30e298fab7c3fba30fa |