QuantStack / QuantStack/yjs-widgets

yjs-widgets does not play well with Lumino widgets

Open
#8 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10
Forks
10
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the JupyterYWidget renderer and the renderModel/createYWidget path shown in the issue, then review the comment thread for the intended API. Determine how the node is created and attached, and verify that a Lumino-based widget can be constructed and attached through the proposed flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.