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

Make the upstream DocumentManager more customizable #6344

Closed
Tracked by #6558
jtpio opened this issue Apr 5, 2022 · 0 comments · Fixed by #6566
Closed
Tracked by #6558

Make the upstream DocumentManager more customizable #6344

jtpio opened this issue Apr 5, 2022 · 0 comments · Fixed by #6566
Milestone

Comments

@jtpio
Copy link
Member

jtpio commented Apr 5, 2022

Currently the docManager.open method is patched here to be able to open documents in new browser tabs:

// 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);
let route = 'edit';
if (
(widgetName === 'default' && ext === '.ipynb') ||
widgetName === 'Notebook'
) {
route = 'notebooks';
}
let url = `${baseUrl}${route}/${path}`;
// append ?factory only if it's not the default
if (widgetName !== 'default') {
url = `${url}?factory=${widgetName}`;
}
window.open(url);
return undefined;
};
}

Ideally we could instead provide another IDocumentManager to the system which would extend the base DocumentManager, but override the open method and define the current logic there.

@jtpio jtpio added this to the 7.0 milestone Apr 5, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant