瀏覽代碼

Allow MimeRenderDocuments to use base64 encoded files.

ian-r-rose 7 年之前
父節點
當前提交
16ce499a36

+ 3 - 2
packages/application/src/mimerenderers.ts

@@ -6,7 +6,7 @@ import {
 } from '@jupyterlab/apputils';
 
 import {
-  MimeDocument, MimeDocumentFactory
+  MimeDocument, MimeDocumentFactory, DocumentRegistry
 } from '@jupyterlab/docregistry';
 
 import {
@@ -80,7 +80,7 @@ function createRendermimePlugin(item: IRenderMime.IExtension): JupyterLabPlugin<
 
       if (item.fileTypes) {
         item.fileTypes.forEach(ft => {
-          app.docRegistry.addFileType(ft);
+          app.docRegistry.addFileType(ft as DocumentRegistry.IFileType);
         });
       }
 
@@ -89,6 +89,7 @@ function createRendermimePlugin(item: IRenderMime.IExtension): JupyterLabPlugin<
           renderTimeout: item.renderTimeout,
           dataType: item.dataType,
           rendermime: app.rendermime,
+          modelName: option.modelName,
           name: option.name,
           primaryFileType: registry.getFileType(option.primaryFileType),
           fileTypes: option.fileTypes,

+ 10 - 0
packages/rendermime-interfaces/src/index.ts

@@ -82,6 +82,11 @@ namespace IRenderMime {
      */
     readonly name: string;
 
+    /**
+     * The name of the document model type.
+     */
+    readonly modelName: string;
+
     /**
      * The primary file type of the widget.
      */
@@ -133,6 +138,11 @@ namespace IRenderMime {
      * The icon label for the file type.
      */
     readonly iconLabel?: string;
+
+    /**
+     * The file format for the file type ('text', 'base64', or 'json').
+     */
+    readonly fileFormat: string;
   }
 
   /**

+ 4 - 0
packages/vega2-extension/src/index.ts

@@ -133,12 +133,14 @@ const extension: IRenderMime.IExtension = {
   dataType: 'json',
   documentWidgetFactoryOptions: [{
     name: 'Vega',
+    modelName: 'text',
     primaryFileType: 'vega',
     fileTypes: ['vega', 'json'],
     defaultFor: ['vega']
   },
   {
     name: 'Vega Lite',
+    modelName: 'text',
     primaryFileType: 'vega-lite',
     fileTypes: ['vega-lite', 'json'],
     defaultFor: ['vega-lite']
@@ -146,12 +148,14 @@ const extension: IRenderMime.IExtension = {
   fileTypes: [{
     mimeTypes: [VEGA_MIME_TYPE],
     name: 'vega',
+    fileFormat: 'text',
     extensions: ['.vg', '.vg.json'],
     iconClass: 'jp-MaterialIcon jp-VegaIcon',
   },
   {
     mimeTypes: [VEGALITE_MIME_TYPE],
     name: 'vega-lite',
+    fileFormat: 'text',
     extensions: ['.vl', '.vl.json'],
     iconClass: 'jp-MaterialIcon jp-VegaIcon',
   }]