plugin.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. 'use strict';
  4. import {
  5. TerminalWidget, ITerminalOptions
  6. } from 'jupyter-js-terminal';
  7. import {
  8. Container, Token
  9. } from 'phosphor-di';
  10. import {
  11. ITerminalProvider
  12. } from './index';
  13. import './plugin.css';
  14. /**
  15. * Register the plugin contributions.
  16. *
  17. * @param container - The di container for type registration.
  18. *
  19. * #### Notes
  20. * This is called automatically when the plugin is loaded.
  21. */
  22. export
  23. function register(container: Container): void {
  24. container.register(ITerminalProvider, TerminalProvider);
  25. }
  26. /**
  27. * An implementation of an ITerminalProvider.
  28. */
  29. class TerminalProvider implements ITerminalProvider {
  30. /**
  31. * The dependencies required by the editor factory.
  32. */
  33. static requires: Token<any>[] = [];
  34. /**
  35. * Create a new editor factory instance.
  36. */
  37. static create(): ITerminalProvider {
  38. return new TerminalProvider();
  39. }
  40. /**
  41. * Create a new Terminal instance.
  42. */
  43. createTerminal(options?: ITerminalOptions): TerminalWidget {
  44. return new TerminalWidget(options);
  45. }
  46. }