@@ -31,8 +31,9 @@ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
31
31
32
32
import { JupyterCadWidgetFactory } from '../factory' ;
33
33
import { JupyterCadJcadModelFactory } from './modelfactory' ;
34
+ import { MimeDocumentFactory } from '@jupyterlab/docregistry' ;
34
35
35
- const FACTORY = 'JupyterCAD .jcad Viewer ' ;
36
+ const FACTORY = 'JupyterCAD' ;
36
37
const PALETTE_CATEGORY = 'JupyterCAD' ;
37
38
38
39
namespace CommandIDs {
@@ -58,8 +59,8 @@ const activate = (
58
59
const widgetFactory = new JupyterCadWidgetFactory ( {
59
60
name : FACTORY ,
60
61
modelName : 'jupytercad-jcadmodel' ,
61
- fileTypes : [ 'jcad' ] ,
62
- defaultFor : [ 'jcad' ] ,
62
+ fileTypes : [ FACTORY ] ,
63
+ defaultFor : [ FACTORY ] ,
63
64
tracker,
64
65
commands : app . commands ,
65
66
workerRegistry,
@@ -70,22 +71,33 @@ const activate = (
70
71
mimeTypeService : editorServices . mimeTypeService ,
71
72
consoleTracker
72
73
} ) ;
74
+
73
75
// Registering the widget factory
74
76
app . docRegistry . addWidgetFactory ( widgetFactory ) ;
75
77
78
+ const factory = new MimeDocumentFactory ( {
79
+ dataType : 'json' ,
80
+ rendermime,
81
+ modelName : 'jupytercad-jcadmodel' ,
82
+ name : 'JSON Editor' ,
83
+ primaryFileType : app . docRegistry . getFileType ( 'json' ) ,
84
+ fileTypes : [ FACTORY ] ,
85
+ } ) ;
86
+ app . docRegistry . addWidgetFactory ( factory ) ;
87
+
76
88
// Creating and registering the model factory for our custom DocumentModel
77
89
const modelFactory = new JupyterCadJcadModelFactory ( {
78
90
annotationModel
79
91
} ) ;
80
92
app . docRegistry . addModelFactory ( modelFactory ) ;
81
93
// register the filetype
82
94
app . docRegistry . addFileType ( {
83
- name : 'jcad' ,
84
- displayName : 'JCAD' ,
95
+ name : FACTORY ,
96
+ displayName : FACTORY ,
85
97
mimeTypes : [ 'text/json' ] ,
86
98
extensions : [ '.jcad' , '.JCAD' ] ,
87
99
fileFormat : 'text' ,
88
- contentType : 'jcad' ,
100
+ contentType : FACTORY ,
89
101
icon : logoIcon
90
102
} ) ;
91
103
@@ -94,7 +106,7 @@ const activate = (
94
106
} ;
95
107
if ( drive ) {
96
108
drive . sharedModelFactory . registerDocumentFactory (
97
- 'jcad' ,
109
+ FACTORY ,
98
110
jcadSharedModelFactory
99
111
) ;
100
112
}
0 commit comments