跳转到主要内容

基于Yjs的控件JupyterLab扩展。

项目描述

JupyterLab扩展,基于Yjs的控件

需求

  • JupyterLab == 4.0.0b0

安装

您可以使用pip安装yjs-widgets

pip install yjs-widgets

用法

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);
  }
};

贡献

yjs-widgets是一个开源项目,我们始终欢迎贡献。如果您想贡献,请fork仓库并提交pull request。

有关开发安装说明,请参阅CONTRIBUTING

许可证

yjs-widgets采用BSD 3-Clause许可证。有关更多信息,请参阅LICENSE文件。

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

yjs_widgets-0.3.6.tar.gz (161.0 kB 查看哈希)

上传于 源代码

构建发行版

yjs_widgets-0.3.6-py3-none-any.whl (17.7 kB 查看哈希值)

上传于 Python 3

由以下支持