index.d.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * @packageDocumentation
  3. * @module htmlviewer
  4. */
  5. import { IFrame, IWidgetTracker } from '@jupyterlab/apputils';
  6. import { ABCWidgetFactory, DocumentRegistry, DocumentWidget, IDocumentWidget } from '@jupyterlab/docregistry';
  7. import { ITranslator } from '@jupyterlab/translation';
  8. import { Token } from '@lumino/coreutils';
  9. import { ISignal } from '@lumino/signaling';
  10. /**
  11. * A class that tracks HTML viewer widgets.
  12. */
  13. export interface IHTMLViewerTracker extends IWidgetTracker<HTMLViewer> {
  14. }
  15. /**
  16. * The HTML viewer tracker token.
  17. */
  18. export declare const IHTMLViewerTracker: Token<IHTMLViewerTracker>;
  19. /**
  20. * A viewer widget for HTML documents.
  21. *
  22. * #### Notes
  23. * The iframed HTML document can pose a potential security risk,
  24. * since it can execute Javascript, and make same-origin requests
  25. * to the server, thereby executing arbitrary Javascript.
  26. *
  27. * Here, we sandbox the iframe so that it can't execute Javascript
  28. * or launch any popups. We allow one exception: 'allow-same-origin'
  29. * requests, so that local HTML documents can access CSS, images,
  30. * etc from the files system.
  31. */
  32. export declare class HTMLViewer extends DocumentWidget<IFrame> implements IDocumentWidget<IFrame> {
  33. /**
  34. * Create a new widget for rendering HTML.
  35. */
  36. constructor(options: DocumentWidget.IOptionsOptionalContent);
  37. /**
  38. * Whether the HTML document is trusted. If trusted,
  39. * it can execute Javascript in the iframe sandbox.
  40. */
  41. get trusted(): boolean;
  42. set trusted(value: boolean);
  43. /**
  44. * Emitted when the trust state of the document changes.
  45. */
  46. get trustedChanged(): ISignal<this, boolean>;
  47. /**
  48. * Dispose of resources held by the html viewer.
  49. */
  50. dispose(): void;
  51. /**
  52. * Handle and update request.
  53. */
  54. protected onUpdateRequest(): void;
  55. /**
  56. * Render HTML in IFrame into this widget's node.
  57. */
  58. private _renderModel;
  59. /**
  60. * Set a <base> element in the HTML string so that the iframe
  61. * can correctly dereference relative links.
  62. */
  63. private _setBase;
  64. protected translator: ITranslator;
  65. private _renderPending;
  66. private _parser;
  67. private _monitor;
  68. private _objectUrl;
  69. private _trustedChanged;
  70. }
  71. /**
  72. * A widget factory for HTMLViewers.
  73. */
  74. export declare class HTMLViewerFactory extends ABCWidgetFactory<HTMLViewer> {
  75. /**
  76. * Create a new widget given a context.
  77. */
  78. protected createNewWidget(context: DocumentRegistry.Context): HTMLViewer;
  79. }