Skip to main content

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


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.4.tar.gz (146.3 kB view details)

Uploaded Source

Built Distribution

yjs_widgets-0.3.4-py3-none-any.whl (82.5 kB view details)

Uploaded Python 3

File details

Details for the file yjs_widgets-0.3.4.tar.gz.

File metadata

  • Download URL: yjs_widgets-0.3.4.tar.gz
  • Upload date:
  • Size: 146.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.1

File hashes

Hashes for yjs_widgets-0.3.4.tar.gz
Algorithm Hash digest
SHA256 9da098441073b275c26d2d8f258cd55d2a34d731abc24a0c3c01d69e6aa46968
MD5 a9616b523ef4280aa5806f2bd3e90d1c
BLAKE2b-256 e1847a85be44a333add40b0d0e5693eb565c6eb1faf6887da92f8629cab7f9ac

See more details on using hashes here.

File details

Details for the file yjs_widgets-0.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for yjs_widgets-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c2bb12794afdd062d2886cdf3722ef4946f07b50e2f524161271cd7e570876ff
MD5 678f4cabf641ea3d1b16702dd4ba13d5
BLAKE2b-256 de6393105351807f89dc42b7b4ae6652221fe49494af3c86dad564eba8d61bf3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page