Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.8k
Improve context handling#4453
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
7a5bd0078df852db400671e298d72e93f839c7c4a892d58d038167666ede2da0ff19f64aa4de658a7a4b3fc6bde1107f6912dfc8eaf12ced55f8b32631d0e18b3b7e1db7fc2dc90b59bc3496d1f7b03da78e85c3b60aaf51a6b58d11ffaafcbb1b6a6554c24b0a32345d9d5db7ecb3c8447ab04ebac5f0ae8b29b087d1d90468ec2ae892b4ba2802f672e84357b5c0799c6c455a21d5a7b618baec7d693d72fd54ce1abda5da476064212a65027e9ef12be487bb239a56e5766427a67e4efcad221040a0bf94b1ed031011dba0b63414fd43413f40163c41c13ab63726749792693810cac907afFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright (c) Jupyter Development Team. | ||
| // Distributed under the terms of the Modified BSD License. | ||
| import { | ||
| Toolbar | ||
| } from '@jupyterlab/apputils'; | ||
| import { | ||
| IDocumentWidget, DocumentRegistry | ||
| } from '@jupyterlab/docregistry'; | ||
| import { | ||
| Widget | ||
| } from '@phosphor/widgets'; | ||
| /** | ||
| * A document widget implementation. | ||
| */ | ||
| export | ||
| class DocumentWidget<T extends Widget, U extends DocumentRegistry.IModel> extends Widget implements IDocumentWidget<Widget, DocumentRegistry.IModel> { | ||
| constructor(options: IDocumentWidget.IOptions<Widget, DocumentRegistry.IModel>) { | ||
| super({node: options.node}); | ||
| this.content = options.content; | ||
| this.contentReady = options.contentReady; | ||
| this.context = options.context; | ||
| this.toolbar = options.toolbar; | ||
| // Set layout to boxpanel with appropriate sizing for toolbar | ||
| } | ||
| readonly content: Widget; | ||
| readonly contentReady: Promise<void>; | ||
| readonly context: DocumentRegistry.IContext<DocumentRegistry.IModel>; | ||
| readonly toolbar: Toolbar<Widget>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -26,7 +26,7 @@ import { | ||
| } from '@phosphor/widgets'; | ||
| import { | ||
| IClientSession, Toolbar | ||
| } from '@jupyterlab/apputils'; | ||
| import { | ||
| @@ -840,17 +840,6 @@ namespace DocumentRegistry { | ||
| readonly canStartKernel?: boolean; | ||
| } | ||
| /** | ||
| * The options used to open a widget. | ||
| */ | ||
| @@ -881,26 +870,36 @@ namespace DocumentRegistry { | ||
| * The interface for a widget factory. | ||
| */ | ||
| export | ||
| interface IWidgetFactory<T extends Widget, U extends IModel> extends IDisposable, IWidgetFactoryOptions { | ||
| /** | ||
| * A signal emitted when a new widget is created. | ||
| */ | ||
| documentWidgetCreated: ISignal<IWidgetFactory<T, U>, IDocumentWidget<T, U>>; | ||
| /** | ||
| *Create a new contentwidgetwhich will be initialized later. | ||
| */ | ||
| create(): T; | ||
| /** | ||
| *Initialize acontent widget. | ||
| * | ||
| *@returns a promise that resolves when the content widget is ready to be | ||
| *visible. | ||
| */ | ||
| initialize(context: IContext<U>, toolbar: Toolbar<Widget>, content: T): Promise<void>; | ||
| /** | ||
| * Called when a new document widget is created. Should emit the documentWidgetCreated signal. | ||
| */ | ||
| documentWidget(documentWidget: IDocumentWidget<T, U>): void; | ||
| } | ||
| /** | ||
| * A type alias for a standard widget factory. | ||
| */ | ||
| export | ||
| type WidgetFactory = IWidgetFactory<Widget, IModel>; | ||
| /** | ||
| * An interface for a widget extension. | ||
| @@ -1193,6 +1192,27 @@ namespace DocumentRegistry { | ||
| ]; | ||
| } | ||
| /** | ||
| * An interface for a document widget. | ||
| */ | ||
| export | ||
| interface IDocumentWidget<T extends Widget, U extends DocumentRegistry.IModel> extends Widget { | ||
| readonly content: T; | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. These should have inline comments (especially "ready"). ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. In documenting this promise, I say "A promise resolving when the content widget is ready to be revealed." Would "reveal" be a better name for the promise than "ready"? When the reveal promise resolves, then we reveal the document widget. | ||
| readonly contentReady: Promise<void>; | ||
| readonly context: DocumentRegistry.IContext<U>; | ||
| readonly toolbar: Toolbar<Widget>; | ||
| } | ||
| export | ||
| namespace IDocumentWidget { | ||
| export | ||
| interface IOptions<T extends Widget, U extends DocumentRegistry.IModel> extends Widget.IOptions { | ||
| readonly content: T; | ||
| readonly contentReady: Promise<void>; | ||
| readonly context: DocumentRegistry.IContext<U>; | ||
| readonly toolbar: Toolbar<Widget>; | ||
| } | ||
| } | ||
| /** | ||
| * A private namespace for DocumentRegistry data. | ||