基于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 查看哈希值)
关闭
yjs_widgets-0.3.6.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 1fc3084ee4a6a4557635462985c28e4560f78b4b7aff6675803bc0367e2c50f9 |
|
MD5 | 6be35991316ddb1f981373f5aec20960 |
|
BLAKE2b-256 | f6fe846a245ffd5371064b0b5822d1915b0777cd5d518c49c411231695e89a6f |
关闭
yjs_widgets-0.3.6-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 979747c105e937fb8bf3ebd8b8a6016353459bad4b3321bf546c10657d9e803d |
|
MD5 | 4069b76b48e6298a4d06a7fbaa744830 |
|
BLAKE2b-256 | 30b635c2cf21de71f02230273fff532eae3879600998a7f06c395aebb862dafe |