Skip to content

Commit 1de03b0

Browse files
committed
JSON viewer
1 parent 3ca79e7 commit 1de03b0

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

python/jupytercad_core/src/jcadplugin/modelfactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class JupyterCadJcadModelFactory
3737
* @returns The content type
3838
*/
3939
get contentType(): Contents.ContentType {
40-
return 'jcad';
40+
return 'JupyterCAD';
4141
}
4242

4343
/**

python/jupytercad_core/src/jcadplugin/plugins.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
3131

3232
import { JupyterCadWidgetFactory } from '../factory';
3333
import { JupyterCadJcadModelFactory } from './modelfactory';
34+
import { MimeDocumentFactory } from '@jupyterlab/docregistry';
3435

35-
const FACTORY = 'JupyterCAD .jcad Viewer';
36+
const FACTORY = 'JupyterCAD';
3637
const PALETTE_CATEGORY = 'JupyterCAD';
3738

3839
namespace CommandIDs {
@@ -58,8 +59,8 @@ const activate = (
5859
const widgetFactory = new JupyterCadWidgetFactory({
5960
name: FACTORY,
6061
modelName: 'jupytercad-jcadmodel',
61-
fileTypes: ['jcad'],
62-
defaultFor: ['jcad'],
62+
fileTypes: [FACTORY],
63+
defaultFor: [FACTORY],
6364
tracker,
6465
commands: app.commands,
6566
workerRegistry,
@@ -70,22 +71,33 @@ const activate = (
7071
mimeTypeService: editorServices.mimeTypeService,
7172
consoleTracker
7273
});
74+
7375
// Registering the widget factory
7476
app.docRegistry.addWidgetFactory(widgetFactory);
7577

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+
7688
// Creating and registering the model factory for our custom DocumentModel
7789
const modelFactory = new JupyterCadJcadModelFactory({
7890
annotationModel
7991
});
8092
app.docRegistry.addModelFactory(modelFactory);
8193
// register the filetype
8294
app.docRegistry.addFileType({
83-
name: 'jcad',
84-
displayName: 'JCAD',
95+
name: FACTORY,
96+
displayName: FACTORY,
8597
mimeTypes: ['text/json'],
8698
extensions: ['.jcad', '.JCAD'],
8799
fileFormat: 'text',
88-
contentType: 'jcad',
100+
contentType: FACTORY,
89101
icon: logoIcon
90102
});
91103

@@ -94,7 +106,7 @@ const activate = (
94106
};
95107
if (drive) {
96108
drive.sharedModelFactory.registerDocumentFactory(
97-
'jcad',
109+
FACTORY,
98110
jcadSharedModelFactory
99111
);
100112
}

0 commit comments

Comments
 (0)