plugin.ts 908 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. 'use strict';
  4. import {
  5. FileBrowserWidget, FileHandler
  6. } from 'jupyter-js-filebrowser';
  7. import {
  8. Container, Token
  9. } from 'phosphor-di';
  10. import {
  11. Widget
  12. } from 'phosphor-widget';
  13. import {
  14. IServicesProvider, IFileOpener, IFileHandler
  15. } from '../index';
  16. /**
  17. * Register the plugin contributions.
  18. *
  19. * @param container - The di container for type registration.
  20. *
  21. * #### Notes
  22. * This is called automatically when the plugin is loaded.
  23. */
  24. export
  25. function resolve(container: Container): Promise<IFileHandler> {
  26. return container.resolve({
  27. requires: [IServicesProvider, IFileOpener],
  28. create: (services: IServicesProvider, opener: IFileOpener) => {
  29. let handler = new FileHandler(services.contentsManager);
  30. opener.registerDefault(handler);
  31. return handler;
  32. }
  33. });
  34. }