UNPKG

4.03 kBTypeScriptView Raw
1import { Printing } from '@jupyterlab/apputils';
2import { IRenderMime, IRenderMimeRegistry } from '@jupyterlab/rendermime';
3import { ITranslator } from '@jupyterlab/translation';
4import { Message } from '@lumino/messaging';
5import { Widget } from '@lumino/widgets';
6import { ABCWidgetFactory, DocumentWidget } from './default';
7import { DocumentRegistry } from './registry';
8/**
9 * A content widget for a rendered mimetype document.
10 */
11export declare class MimeContent extends Widget {
12 /**
13 * Construct a new widget.
14 */
15 constructor(options: MimeContent.IOptions);
16 /**
17 * The mimetype for this rendered content.
18 */
19 readonly mimeType: string;
20 /**
21 * Print method. Deferred to the renderer.
22 */
23 [Printing.symbol](): Printing.OptionalAsyncThunk;
24 /**
25 * A promise that resolves when the widget is ready.
26 */
27 get ready(): Promise<void>;
28 /**
29 * Set URI fragment identifier.
30 */
31 setFragment(fragment: string): void;
32 /**
33 * Dispose of the resources held by the widget.
34 */
35 dispose(): void;
36 /**
37 * Handle an `update-request` message to the widget.
38 */
39 protected onUpdateRequest(msg: Message): void;
40 /**
41 * Render the mime content.
42 */
43 private _render;
44 /**
45 * A bound change callback.
46 */
47 private _changeCallback;
48 readonly renderer: IRenderMime.IRenderer;
49 protected translator: ITranslator;
50 private _trans;
51 private _context;
52 private _fragment;
53 private _monitor;
54 private _ready;
55 private _dataType;
56 private _isRendering;
57 private _renderRequested;
58}
59/**
60 * The namespace for MimeDocument class statics.
61 */
62export declare namespace MimeContent {
63 /**
64 * The options used to initialize a MimeDocument.
65 */
66 interface IOptions {
67 /**
68 * Context
69 */
70 context: DocumentRegistry.IContext<DocumentRegistry.IModel>;
71 /**
72 * The renderer instance.
73 */
74 renderer: IRenderMime.IRenderer;
75 /**
76 * The mime type.
77 */
78 mimeType: string;
79 /**
80 * The render timeout.
81 */
82 renderTimeout: number;
83 /**
84 * Preferred data type from the model.
85 */
86 dataType?: 'string' | 'json';
87 /**
88 * The application language translator.
89 */
90 translator?: ITranslator;
91 }
92}
93/**
94 * A document widget for mime content.
95 */
96export declare class MimeDocument extends DocumentWidget<MimeContent> {
97 setFragment(fragment: string): void;
98}
99/**
100 * An implementation of a widget factory for a rendered mimetype document.
101 */
102export declare class MimeDocumentFactory extends ABCWidgetFactory<MimeDocument> {
103 /**
104 * Construct a new mimetype widget factory.
105 */
106 constructor(options: MimeDocumentFactory.IOptions<MimeDocument>);
107 /**
108 * Create a new widget given a context.
109 */
110 protected createNewWidget(context: DocumentRegistry.Context): MimeDocument;
111 private _rendermime;
112 private _renderTimeout;
113 private _dataType;
114 private _fileType;
115 private _factory;
116}
117/**
118 * The namespace for MimeDocumentFactory class statics.
119 */
120export declare namespace MimeDocumentFactory {
121 /**
122 * The options used to initialize a MimeDocumentFactory.
123 */
124 interface IOptions<T extends MimeDocument> extends DocumentRegistry.IWidgetFactoryOptions<T> {
125 /**
126 * The primary file type associated with the document.
127 */
128 primaryFileType: DocumentRegistry.IFileType | undefined;
129 /**
130 * The rendermime instance.
131 */
132 rendermime: IRenderMimeRegistry;
133 /**
134 * The render timeout.
135 */
136 renderTimeout?: number;
137 /**
138 * Preferred data type from the model.
139 */
140 dataType?: 'string' | 'json';
141 /**
142 * Optional renderer to use (overriding the renderer in the registry)
143 */
144 factory?: IRenderMime.IRendererFactory;
145 }
146}