Skip to content

Commit

Permalink
Add utility function resolveUrl on manager
Browse files Browse the repository at this point in the history
This is needed to be able to resolve file URLs relative to the widget's
notebook.
  • Loading branch information
vidartf committed Mar 8, 2018
1 parent 5ad6f4a commit 31ad38f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/base/src/manager-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,16 @@ abstract class ManagerBase<T> {
this._models[i].then(model => { model.comm_live = false; });
});
}

/**
* Resolve a URL relative to the current notebook location.
*
* The default implementation just returns the original url.
*/
resolveUrl(url: string): Promise<string> {
return Promise.resolve(url);
}

/**
* The comm target name to register
*/
Expand Down
7 changes: 7 additions & 0 deletions packages/jupyterlab-manager/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ class WidgetManager extends ManagerBase<Widget> implements IDisposable {
this._context = null;
}

/**
* Resolve a URL relative to the current notebook location.
*/
resolveUrl(url: string): Promise<string> {
return this.context.resolveUrl(url);
}

/**
* Load a class and return a promise to the loaded object.
*/
Expand Down

0 comments on commit 31ad38f

Please sign in to comment.