Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
restorer: ILayoutRestorer | null
): IHTMLViewerTracker {
// Add an HTML file type to the docregistry.
const ft: DocumentRegistry.IFileType = {
name: 'html',
contentType: 'file',
fileFormat: 'text',
displayName: 'HTML File',
extensions: ['.html'],
mimeTypes: ['text/html'],
iconClass: ICON_NAME
};
app.docRegistry.addFileType(ft);
// Create a new viewer factory.
const factory = new HTMLViewerFactory({
name: 'HTML Viewer',
fileTypes: ['html'],
defaultFor: ['html'],
readOnly: true
});
// Create a widget tracker for HTML documents.
const tracker = new WidgetTracker({
namespace: 'htmlviewer'
});
// Handle state restoration.
if (restorer) {
void restorer.restore(tracker, {
command: 'docmanager:open',
args: widget => ({ path: widget.context.path, factory: 'HTML Viewer' }),