index.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. 'use strict';
  4. import * as CodeMirror
  5. from 'codemirror';
  6. import {
  7. CodeMirrorWidget
  8. } from 'phosphor-codemirror';
  9. import {
  10. Token
  11. } from 'phosphor-di';
  12. /**
  13. * A handler for creating and manipulating Jupyter editors.
  14. */
  15. export
  16. interface IEditorHandler {
  17. /**
  18. * Create a new IEditor instance.
  19. */
  20. createEditor(options?: CodeMirror.EditorConfiguration): CodeMirrorWidget;
  21. /**
  22. * Set the editor mode by name. This will lode the mode file
  23. * as needed.
  24. */
  25. setModeByName(widget: CodeMirrorWidget, mode: string): void;
  26. /**
  27. * Set the editor mode by file name. This will lode the mode file
  28. * as needed.
  29. */
  30. setModeByFileName(widget: CodeMirrorWidget, filename: string): void;
  31. /**
  32. * Set the editor mode by mime type. This will lode the mode file
  33. * as needed.
  34. */
  35. setModeByMIMEType(widget: CodeMirrorWidget, mime: string): void;
  36. /**
  37. * A convenience method to get the text from the editor.
  38. */
  39. getText(widget: CodeMirrorWidget, text: string): string;
  40. /**
  41. * A convenience method to set the text on the editor.
  42. */
  43. setText(widget: CodeMirrorWidget, text: string): void;
  44. }
  45. /**
  46. * The dependency token for the `IEditorHandler` interface.
  47. */
  48. export
  49. const IEditorHandler = new Token<IEditorHandler>('jupyter-js-plugins.IEditorHandler');