Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Story for generic document factory #290

Closed
fcollonval opened this issue Nov 18, 2021 · 7 comments
Closed

Story for generic document factory #290

fcollonval opened this issue Nov 18, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@fcollonval
Copy link
Member

Problem

This was first brought at the JLab team meeting by @bollwyvl

Nick modified ipydrawio to support retrolab. This resulted in quite some hack to replace the file editor by the custom document from ipydrawio factory.

It will be nice if custom factories can be supported out of the box.

Proposed Solution

As retrolab is single document oriented set through URL, one idea could be to support generic URL pattern <baseURL>/retro/<factory name>/?path=<path>. This will support:

  • multiple factories for the same path
  • unique URL (that can be shared, saved,...)

The challenge is likely to be on the list of core plugins that need to be loaded on that page - we may need to support customization of the base modules in app/index.js, to change how core packages are distributed and to support dynamic plugin load.

@fcollonval fcollonval added the enhancement New feature or request label Nov 18, 2021
@jtpio
Copy link
Member

jtpio commented Nov 18, 2021

Thanks @fcollonval for opening this.

one idea could be to support generic URL pattern

Or maybe via a query string parameter such as ?factory=, so it also works with JupyterLite.

Probaby the doc manager plugin defined here could be slightly tweaked to open widgets with a different factory:

/**
* A plugin to open document in a new browser tab.
*
* TODO: remove and use a custom doc manager?
*/
const opener: JupyterFrontEndPlugin<void> = {
id: '@retrolab/docmanager-extension:opener',
requires: [IDocumentManager],
autoStart: true,
activate: (app: JupyterFrontEnd, docManager: IDocumentManager) => {
const baseUrl = PageConfig.getBaseUrl();
// patch the `docManager.open` option to prevent the default behavior
const docOpen = docManager.open;
docManager.open = (
path: string,
widgetName = 'default',
kernel?: Partial<Kernel.IModel>,
options?: DocumentRegistry.IOpenOptions
): IDocumentWidget | undefined => {
const ref = options?.ref;
if (ref === '_noref') {
docOpen.call(docManager, path, widgetName, kernel, options);
return;
}
const ext = PathExt.extname(path);
const route = ext === '.ipynb' ? 'notebooks' : 'edit';
window.open(`${baseUrl}retro/${route}/${path}`);
return undefined;
};
}
};

@bollwyvl
Copy link
Contributor

bollwyvl commented Nov 18, 2021 via email

@fcollonval
Copy link
Member Author

query string parameter such as ?factory=, so it also works with JupyterLite

👍 to get Lite happier 😄

@meeseeksmachine
Copy link

This issue has been mentioned on Jupyter Community Forum. There might be relevant details there:

https://discourse.jupyter.org/t/how-to-open-myst-markdown-on-retrolab-with-jupytext/12763/2

@jtpio
Copy link
Member

jtpio commented Mar 18, 2022

Thinking about this more, we'll probably want to make it generic enough so it can open other arbitrary widgets in new browser tabs. For example the new settings editor.

@jtpio
Copy link
Member

jtpio commented Mar 18, 2022

Just opened jupyter/notebook#6315 to start exploring this.

@jtpio
Copy link
Member

jtpio commented Apr 4, 2022

Closing as fixed by jupyter/notebook#6315, which added initial support for this.

Let's continue in the Notebook repo with follow-up issues and PRs: https://github.com/jupyter/notebook/

@jtpio jtpio closed this as completed Apr 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants