/* ----------------------------------------------------------------------------- | Copyright (c) Jupyter Development Team. | Distributed under the terms of the Modified BSD License. |----------------------------------------------------------------------------*/ import { ActivityMonitor } from '@jupyterlab/coreutils'; import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; import { ABCWidgetFactory, DocumentWidget } from '@jupyterlab/docregistry'; import type { ITranslator } from '@jupyterlab/translation'; import { nullTranslator } from '@jupyterlab/translation'; import { IFrame, ReactWidget, refreshIcon, ToolbarButton, ToolbarButtonComponent, UseSignal } from '@jupyterlab/ui-components'; import type { ISignal } from '@lumino/signaling'; import { Signal } from '@lumino/signaling'; import type { Widget } from '@lumino/widgets'; import * as React from 'react'; /** * The timeout to wait for change activity to have ceased before rendering. */ const RENDER_TIMEOUT = 1000; /** * The CSS class to add to the HTMLViewer Widget. */ const CSS_CLASS = 'jp-HTMLViewer'; const UNTRUSTED_LINK_STYLE = (options: { warning: string }) => ``; /** * A viewer widget for HTML documents. * * #### Notes * The iframed HTML document can pose a potential security risk, * since it can execute Javascript, and make same-origin requests * to the server, thereby executing arbitrary Javascript. * * Here, we sandbox the iframe so that it can't execute Javascript * or launch any popups. We allow one exception: 'allow-same-origin' * requests, so that local HTML documents can access CSS, images, * etc from the files system. */ export class HTMLViewer extends DocumentWidget