@difizen/libro-rendermime 0.0.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/es/components/html-render.d.ts +6 -0
- package/es/components/html-render.d.ts.map +1 -0
- package/es/components/html-render.js +39 -0
- package/es/components/image-render.d.ts +6 -0
- package/es/components/image-render.d.ts.map +1 -0
- package/es/components/image-render.js +36 -0
- package/es/components/index.d.ts +7 -0
- package/es/components/index.d.ts.map +1 -0
- package/es/components/index.js +6 -0
- package/es/components/latex-render.d.ts +6 -0
- package/es/components/latex-render.d.ts.map +1 -0
- package/es/components/latex-render.js +23 -0
- package/es/components/markdown-render.d.ts +6 -0
- package/es/components/markdown-render.d.ts.map +1 -0
- package/es/components/markdown-render.js +38 -0
- package/es/components/svg-render.d.ts +6 -0
- package/es/components/svg-render.d.ts.map +1 -0
- package/es/components/svg-render.js +33 -0
- package/es/components/text-render.d.ts +9 -0
- package/es/components/text-render.d.ts.map +1 -0
- package/es/components/text-render.js +44 -0
- package/es/index.d.ts +7 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +6 -0
- package/es/renderers.d.ts +42 -0
- package/es/renderers.d.ts.map +1 -0
- package/es/renderers.js +327 -0
- package/es/rendermime-factory.d.ts +30 -0
- package/es/rendermime-factory.d.ts.map +1 -0
- package/es/rendermime-factory.js +73 -0
- package/es/rendermime-module.d.ts +3 -0
- package/es/rendermime-module.d.ts.map +1 -0
- package/es/rendermime-module.js +11 -0
- package/es/rendermime-protocol.d.ts +405 -0
- package/es/rendermime-protocol.d.ts.map +1 -0
- package/es/rendermime-protocol.js +60 -0
- package/es/rendermime-registry.d.ts +135 -0
- package/es/rendermime-registry.d.ts.map +1 -0
- package/es/rendermime-registry.js +392 -0
- package/es/rendermime-utils.d.ts +87 -0
- package/es/rendermime-utils.d.ts.map +1 -0
- package/es/rendermime-utils.js +603 -0
- package/package.json +61 -0
- package/src/components/html-render.tsx +42 -0
- package/src/components/image-render.tsx +46 -0
- package/src/components/index.ts +6 -0
- package/src/components/latex-render.tsx +30 -0
- package/src/components/markdown-render.tsx +42 -0
- package/src/components/svg-render.tsx +38 -0
- package/src/components/text-render.tsx +51 -0
- package/src/index.ts +6 -0
- package/src/renderers.ts +325 -0
- package/src/rendermime-factory.ts +92 -0
- package/src/rendermime-module.ts +19 -0
- package/src/rendermime-protocol.ts +516 -0
- package/src/rendermime-registry.ts +301 -0
- package/src/rendermime-utils.ts +665 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MarkdownModule } from '@difizen/libro-markdown';
|
|
2
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
3
|
+
|
|
4
|
+
import { standardRendererFactories as initialFactories } from './rendermime-factory.js';
|
|
5
|
+
import {
|
|
6
|
+
IRenderMimeRegistryOptions,
|
|
7
|
+
RenderMimeContribution,
|
|
8
|
+
} from './rendermime-protocol.js';
|
|
9
|
+
import { RenderMimeRegistry } from './rendermime-registry.js';
|
|
10
|
+
|
|
11
|
+
export const LibroRenderMimeModule = ManaModule.create()
|
|
12
|
+
.contribution(RenderMimeContribution)
|
|
13
|
+
.register(RenderMimeRegistry, {
|
|
14
|
+
token: IRenderMimeRegistryOptions,
|
|
15
|
+
useValue: {
|
|
16
|
+
initialFactories,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
.dependOn(MarkdownModule);
|
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import type { ISanitizer } from '@difizen/libro-common';
|
|
2
|
+
import type { BaseOutputView } from '@difizen/libro-core';
|
|
3
|
+
import type { MarkdownParser } from '@difizen/libro-markdown';
|
|
4
|
+
import { Syringe } from '@difizen/mana-app';
|
|
5
|
+
|
|
6
|
+
export const DefaultRenderMimeRegistry = Symbol('RenderMimeRegistry');
|
|
7
|
+
export const IRenderMimeRegistryOptions = Symbol('IRenderMimeRegistryOptions');
|
|
8
|
+
export const RenderMimeContribution = Syringe.defineToken('RenderMimeTypeContribution');
|
|
9
|
+
export interface RenderMimeContribution {
|
|
10
|
+
canHandle: (model: BaseOutputView) => number;
|
|
11
|
+
safe: boolean;
|
|
12
|
+
renderType: string;
|
|
13
|
+
mimeTypes: string[];
|
|
14
|
+
render: React.FC<{ model: BaseOutputView; options?: Record<string, any> }>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The interface for a renderer factory.
|
|
18
|
+
*/
|
|
19
|
+
export interface IRendererFactory {
|
|
20
|
+
/**
|
|
21
|
+
* Whether the factory is a "safe" factory.
|
|
22
|
+
*
|
|
23
|
+
* #### Notes
|
|
24
|
+
* A "safe" factory produces renderer widgets which can render
|
|
25
|
+
* untrusted model data in a usable way. *All* renderers must
|
|
26
|
+
* handle untrusted data safely, but some may simply failover
|
|
27
|
+
* with a "Run cell to view output" message. A "safe" renderer
|
|
28
|
+
* is an indication that its sanitized output will be useful.
|
|
29
|
+
*/
|
|
30
|
+
readonly safe: boolean;
|
|
31
|
+
|
|
32
|
+
readonly renderType: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The mime types handled by this factory.
|
|
36
|
+
*/
|
|
37
|
+
readonly mimeTypes: readonly string[];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The default rank of the factory. If not given, defaults to 100.
|
|
41
|
+
*/
|
|
42
|
+
readonly defaultRank?: number;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Create a renderer which displays the mime data.
|
|
46
|
+
*
|
|
47
|
+
* @param options - The options used to render the data.
|
|
48
|
+
*/
|
|
49
|
+
render: React.FC<{ model: BaseOutputView; props?: Record<string, any> }>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* An object that resolves relative URLs.
|
|
54
|
+
*/
|
|
55
|
+
export interface IResolver {
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a relative url to an absolute url path.
|
|
58
|
+
*/
|
|
59
|
+
resolveUrl: (url: string) => Promise<string>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Get the download url for a given absolute url path.
|
|
63
|
+
*
|
|
64
|
+
* #### Notes
|
|
65
|
+
* This URL may include a query parameter.
|
|
66
|
+
*/
|
|
67
|
+
getDownloadUrl: (url: string) => Promise<string>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Whether the URL should be handled by the resolver
|
|
71
|
+
* or not.
|
|
72
|
+
*
|
|
73
|
+
* #### Notes
|
|
74
|
+
* This is similar to the `isLocal` check in `URL`,
|
|
75
|
+
* but can also perform additional checks on whether the
|
|
76
|
+
* resolver should handle a given URL.
|
|
77
|
+
*/
|
|
78
|
+
isLocal?: (url: string) => boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* An object that handles links on a node.
|
|
82
|
+
*/
|
|
83
|
+
export interface ILinkHandler {
|
|
84
|
+
/**
|
|
85
|
+
* Add the link handler to the node.
|
|
86
|
+
*
|
|
87
|
+
* @param node: the anchor node for which to handle the link.
|
|
88
|
+
*
|
|
89
|
+
* @param path: the path to open when the link is clicked.
|
|
90
|
+
*
|
|
91
|
+
* @param id: an optional element id to scroll to when the path is opened.
|
|
92
|
+
*/
|
|
93
|
+
handleLink: (node: HTMLElement, path: string, id?: string) => void;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Interface for generic renderer.
|
|
98
|
+
*/
|
|
99
|
+
export interface IRenderer {
|
|
100
|
+
readonly render: (container: HTMLElement, options?: any) => void;
|
|
101
|
+
readonly unrender?: (container: HTMLElement, options?: any) => void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The options used to clone a rendermime instance.
|
|
106
|
+
*/
|
|
107
|
+
export interface ICloneOptions {
|
|
108
|
+
/**
|
|
109
|
+
* The new sanitizer used to sanitize untrusted html inputs.
|
|
110
|
+
*/
|
|
111
|
+
sanitizer?: ISanitizer;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The new resolver object.
|
|
115
|
+
*/
|
|
116
|
+
resolver?: IResolver;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The new path handler.
|
|
120
|
+
*/
|
|
121
|
+
linkHandler?: ILinkHandler;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The new Markdown parser.
|
|
125
|
+
*/
|
|
126
|
+
markdownParser?: MarkdownParser;
|
|
127
|
+
|
|
128
|
+
// /**
|
|
129
|
+
// * The application language translator.
|
|
130
|
+
// */
|
|
131
|
+
// translator?: ITranslator;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface IRenderMimeRegistry {
|
|
135
|
+
/**
|
|
136
|
+
* The sanitizer used by the rendermime instance.
|
|
137
|
+
*/
|
|
138
|
+
readonly sanitizer: ISanitizer;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The object used to resolve relative urls for the rendermime instance.
|
|
142
|
+
*/
|
|
143
|
+
readonly resolver: IResolver | null;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The object used to handle path opening links.
|
|
147
|
+
*/
|
|
148
|
+
readonly linkHandler: ILinkHandler | null;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The Markdown parser for the rendermime.
|
|
152
|
+
*/
|
|
153
|
+
readonly markdownParser: MarkdownParser | null;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The ordered list of mimeTypes.
|
|
157
|
+
*/
|
|
158
|
+
readonly mimeTypes: readonly string[];
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Find the preferred mime type for a mime bundle.
|
|
162
|
+
*
|
|
163
|
+
* @param bundle - The bundle of mime data.
|
|
164
|
+
*
|
|
165
|
+
* @param safe - How to consider safe/unsafe factories. If 'ensure',
|
|
166
|
+
* it will only consider safe factories. If 'any', any factory will be
|
|
167
|
+
* considered. If 'prefer', unsafe factories will be considered, but
|
|
168
|
+
* only after the safe options have been exhausted.
|
|
169
|
+
*
|
|
170
|
+
* @returns The preferred mime type from the available factories,
|
|
171
|
+
* or `undefined` if the mime type cannot be rendered.
|
|
172
|
+
*/
|
|
173
|
+
preferredMimeType: (
|
|
174
|
+
model: BaseOutputView,
|
|
175
|
+
safe?: 'ensure' | 'prefer' | 'any',
|
|
176
|
+
) => string | undefined;
|
|
177
|
+
|
|
178
|
+
defaultPreferredMimeType: (
|
|
179
|
+
model: BaseOutputView,
|
|
180
|
+
safe?: 'ensure' | 'prefer' | 'any',
|
|
181
|
+
) => string | undefined;
|
|
182
|
+
// preferredMimeType: (
|
|
183
|
+
// bundle: ReadonlyPartialJSONObject,
|
|
184
|
+
// safe?: 'ensure' | 'prefer' | 'any',
|
|
185
|
+
// ) => Promise<string | undefined>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Create a renderer for a mime type.
|
|
189
|
+
*
|
|
190
|
+
* @param mimeType - The mime type of interest.
|
|
191
|
+
*
|
|
192
|
+
* @returns A new renderer for the given mime type.
|
|
193
|
+
*
|
|
194
|
+
* @throws An error if no factory exists for the mime type.
|
|
195
|
+
*/
|
|
196
|
+
// createRenderer: (mimeType: string, model: BaseOutputModel, host: HTMLElement) => Promise<void>;
|
|
197
|
+
createRenderer: (
|
|
198
|
+
mimeType: string,
|
|
199
|
+
model: BaseOutputView, // model: BaseOutputModel,
|
|
200
|
+
// host: HTMLElement,
|
|
201
|
+
) => React.FC<{ model: BaseOutputView }>;
|
|
202
|
+
// /**
|
|
203
|
+
// * Create a new mime model. This is a convenience method.
|
|
204
|
+
// *
|
|
205
|
+
// * @options - The options used to create the model.
|
|
206
|
+
// *
|
|
207
|
+
// * @returns A new mime model.
|
|
208
|
+
// */
|
|
209
|
+
// createModel: (options?: MimeModel.IOptions) => MimeModel;
|
|
210
|
+
|
|
211
|
+
// /**
|
|
212
|
+
// * Create a clone of this rendermime instance.
|
|
213
|
+
// *
|
|
214
|
+
// * @param options - The options for configuring the clone.
|
|
215
|
+
// *
|
|
216
|
+
// * @returns A new independent clone of the rendermime.
|
|
217
|
+
// */
|
|
218
|
+
// clone: (options?: ICloneOptions) => IRenderMimeRegistry;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Get the renderer factory registered for a mime type.
|
|
222
|
+
*
|
|
223
|
+
* @param mimeType - The mime type of interest.
|
|
224
|
+
*
|
|
225
|
+
* @returns The factory for the mime type, or `undefined`.
|
|
226
|
+
*/
|
|
227
|
+
getFactory: (mimeType: string) => IRendererFactory | undefined;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Add a renderer factory to the rendermime.
|
|
231
|
+
*
|
|
232
|
+
* @param factory - The renderer factory of interest.
|
|
233
|
+
*
|
|
234
|
+
* @param rank - The rank of the renderer. A lower rank indicates
|
|
235
|
+
* a higher priority for rendering. If not given, the rank will
|
|
236
|
+
* defer to the `defaultRank` of the factory. If no `defaultRank`
|
|
237
|
+
* is given, it will default to 100.
|
|
238
|
+
*
|
|
239
|
+
* #### Notes
|
|
240
|
+
* The renderer will replace an existing renderer for the given
|
|
241
|
+
* mimeType.
|
|
242
|
+
*/
|
|
243
|
+
addFactory: (factory: IRendererFactory, rank?: number) => void;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Remove a mime type.
|
|
247
|
+
*
|
|
248
|
+
* @param mimeType - The mime type of interest.
|
|
249
|
+
*/
|
|
250
|
+
removeMimeType: (mimeType: string) => void;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Get the rank for a given mime type.
|
|
254
|
+
*
|
|
255
|
+
* @param mimeType - The mime type of interest.
|
|
256
|
+
*
|
|
257
|
+
* @returns The rank of the mime type or undefined.
|
|
258
|
+
*/
|
|
259
|
+
getRank: (mimeType: string) => number | undefined;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Set the rank of a given mime type.
|
|
263
|
+
*
|
|
264
|
+
* @param mimeType - The mime type of interest.
|
|
265
|
+
*
|
|
266
|
+
* @param rank - The new rank to assign.
|
|
267
|
+
*
|
|
268
|
+
* #### Notes
|
|
269
|
+
* This is a no-op if the mime type is not registered.
|
|
270
|
+
*/
|
|
271
|
+
setRank: (mimeType: string, rank: number) => void;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* The options for the `renderText` function.
|
|
275
|
+
*/
|
|
276
|
+
export interface IRenderTextOptions {
|
|
277
|
+
/**
|
|
278
|
+
* The host node for the text content.
|
|
279
|
+
*/
|
|
280
|
+
host: HTMLElement;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* The html sanitizer for untrusted source.
|
|
284
|
+
*/
|
|
285
|
+
sanitizer: ISanitizer;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* The source text to render.
|
|
289
|
+
*/
|
|
290
|
+
source: string;
|
|
291
|
+
mimeType: string;
|
|
292
|
+
/**
|
|
293
|
+
* The application language translator.
|
|
294
|
+
*/
|
|
295
|
+
// translator?: ITranslator;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* The options for the `renderImage` function.
|
|
299
|
+
*/
|
|
300
|
+
export interface IRenderImageOptions {
|
|
301
|
+
/**
|
|
302
|
+
* The image node to update with the content.
|
|
303
|
+
*/
|
|
304
|
+
host: HTMLElement;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* The mime type for the image.
|
|
308
|
+
*/
|
|
309
|
+
mimeType: string;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* The base64 encoded source for the image.
|
|
313
|
+
*/
|
|
314
|
+
source: string;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The optional width for the image.
|
|
318
|
+
*/
|
|
319
|
+
width?: number;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* The optional height for the image.
|
|
323
|
+
*/
|
|
324
|
+
height?: number;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Whether an image requires a background for legibility.
|
|
328
|
+
*/
|
|
329
|
+
needsBackground?: string;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Whether the image should be unconfined.
|
|
333
|
+
*/
|
|
334
|
+
unconfined?: boolean;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* The options for the `renderHTML` function.
|
|
339
|
+
*/
|
|
340
|
+
export interface IRenderHTMLOptions {
|
|
341
|
+
/**
|
|
342
|
+
* The host node for the rendered HTML.
|
|
343
|
+
*/
|
|
344
|
+
host: HTMLElement;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* The HTML source to render.
|
|
348
|
+
*/
|
|
349
|
+
source: string;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Whether the source is trusted.
|
|
353
|
+
*/
|
|
354
|
+
trusted: boolean;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* The html sanitizer for untrusted source.
|
|
358
|
+
*/
|
|
359
|
+
sanitizer: ISanitizer;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* An optional url resolver.
|
|
363
|
+
*/
|
|
364
|
+
resolver: IResolver | null;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* An optional link handler.
|
|
368
|
+
*/
|
|
369
|
+
linkHandler: ILinkHandler | null;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Whether the node should be typeset.
|
|
373
|
+
*/
|
|
374
|
+
shouldTypeset: boolean;
|
|
375
|
+
|
|
376
|
+
// /**
|
|
377
|
+
// * The application language translator.
|
|
378
|
+
// */
|
|
379
|
+
// translator?: ITranslator;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* The options for the `renderMarkdown` function.
|
|
384
|
+
*/
|
|
385
|
+
export interface IRenderMarkdownOptions {
|
|
386
|
+
/**
|
|
387
|
+
* The host node for the rendered Markdown.
|
|
388
|
+
*/
|
|
389
|
+
host: HTMLElement;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* The Markdown source to render.
|
|
393
|
+
*/
|
|
394
|
+
source: string;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Whether the source is trusted.
|
|
398
|
+
*/
|
|
399
|
+
trusted: boolean;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* The html sanitizer for untrusted source.
|
|
403
|
+
*/
|
|
404
|
+
sanitizer: ISanitizer;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* An optional url resolver.
|
|
408
|
+
*/
|
|
409
|
+
resolver: IResolver | null;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* An optional link handler.
|
|
413
|
+
*/
|
|
414
|
+
linkHandler: ILinkHandler | null;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Whether the node should be typeset.
|
|
418
|
+
*/
|
|
419
|
+
// shouldTypeset: boolean;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* The Markdown parser.
|
|
423
|
+
*/
|
|
424
|
+
markdownParser: MarkdownParser | null;
|
|
425
|
+
|
|
426
|
+
// /**
|
|
427
|
+
// * The application language translator.
|
|
428
|
+
// */
|
|
429
|
+
// translator?: ITranslator;
|
|
430
|
+
|
|
431
|
+
cellId?: string;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* The options for the `renderSVG` function.
|
|
436
|
+
*/
|
|
437
|
+
export interface IRenderSVGOptions {
|
|
438
|
+
/**
|
|
439
|
+
* The host node for the rendered SVG.
|
|
440
|
+
*/
|
|
441
|
+
host: HTMLElement;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* The SVG source.
|
|
445
|
+
*/
|
|
446
|
+
source: string;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Whether the source is trusted.
|
|
450
|
+
*/
|
|
451
|
+
trusted: boolean;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Whether the svg should be unconfined.
|
|
455
|
+
*/
|
|
456
|
+
unconfined?: boolean;
|
|
457
|
+
|
|
458
|
+
// /**
|
|
459
|
+
// * The application language translator.
|
|
460
|
+
// */
|
|
461
|
+
// translator: ITranslator;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* The options used to initialize a rendermime instance.
|
|
466
|
+
*/
|
|
467
|
+
export interface IRenderMimeRegistryOptions {
|
|
468
|
+
/**
|
|
469
|
+
* Initial factories to add to the rendermime instance.
|
|
470
|
+
*/
|
|
471
|
+
initialFactories?: readonly IRendererFactory[];
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* The sanitizer used to sanitize untrusted html inputs.
|
|
475
|
+
*
|
|
476
|
+
* If not given, a default sanitizer will be used.
|
|
477
|
+
*/
|
|
478
|
+
sanitizer?: ISanitizer;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* The initial resolver object.
|
|
482
|
+
*
|
|
483
|
+
* The default is `null`.
|
|
484
|
+
*/
|
|
485
|
+
resolver?: IResolver;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* An optional path handler.
|
|
489
|
+
*/
|
|
490
|
+
linkHandler?: ILinkHandler;
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* An optional Markdown parser.
|
|
494
|
+
*/
|
|
495
|
+
markdownParser?: MarkdownParser;
|
|
496
|
+
|
|
497
|
+
// /**
|
|
498
|
+
// * The application language translator.
|
|
499
|
+
// */
|
|
500
|
+
// translator?: ITranslator;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* A type alias for a mime rank and tie-breaking id.
|
|
505
|
+
*/
|
|
506
|
+
export type RankPair = { readonly id: number; readonly rank: number };
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* A type alias for a mapping of mime type -> rank pair.
|
|
510
|
+
*/
|
|
511
|
+
export type RankMap = Record<string, RankPair>;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* A type alias for a mapping of mime type -> ordered factories.
|
|
515
|
+
*/
|
|
516
|
+
export type FactoryMap = Record<string, IRendererFactory>;
|