Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yjs-widgets does not play well with Lumino widgets #8

Open
martinRenou opened this issue Jun 8, 2023 · 5 comments
Open

yjs-widgets does not play well with Lumino widgets #8

martinRenou opened this issue Jun 8, 2023 · 5 comments

Comments

@martinRenou
Copy link
Member

Issue

One cannot easily create a yjs-widgets based on Lumino. Because the node element that the Renderer provides is not yet attached:

class YJupyterCADWidget implements IJupyterYWidget {
  constructor(yModel: JupyterYModel, node: HTMLElement) {
    this.yModel = yModel;
    this.node = node;

    const widget = new LuminoWidget();

    // The following does not work! Because this.node is not yet attached to the DOM
    Widget.attach(widget, this.node);
  }

  yModel: JupyterYModel;
  node: HTMLElement;
}

Fix proposition

I would like to suggest modifying the JupyterYWidget to get closer to the logic we have in ipywidgets. Basically, the Widget class would be expected to have a node element that would either be a Lumino Widget:

  async renderModel(mimeModel: IRenderMime.IMimeModel): Promise<void> {
    const modelId = mimeModel.data[this._mimeType]!['model_id'];

    this._yModel = this._modelFactory.getYModel(modelId);
    if (!this._yModel) {
      return;
    }

    const widget = this._modelFactory.createYWidget(modelId);
    this.addWidget(widget.node)
  }
@davidbrochart
Copy link
Member

I trust you on this one! I don't know Lumino.

@martinRenou
Copy link
Member Author

Honestly I'm not sure forcing a Lumino would be the best way to go. But at the same time Lumino is all over the place in JupyterLab so...

@davidbrochart
Copy link
Member

I mean yjs-widgets is already misleading, right? It's all about JupyterLab.
You mean people making e.g. React widgets won't be able to use yjs-widgets?

@martinRenou
Copy link
Member Author

They would, you can make a Lumino widget that contains a react component.

It's all about JupyterLab.

Ok let's go with the fix I suggested above then?

@davidbrochart
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants