Skip to content

Commit

Permalink
JSON viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Oct 23, 2024
1 parent 3ca79e7 commit 1de03b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion python/jupytercad_core/src/jcadplugin/modelfactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class JupyterCadJcadModelFactory
* @returns The content type
*/
get contentType(): Contents.ContentType {
return 'jcad';
return 'JupyterCAD';
}

/**
Expand Down
26 changes: 19 additions & 7 deletions python/jupytercad_core/src/jcadplugin/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';

import { JupyterCadWidgetFactory } from '../factory';
import { JupyterCadJcadModelFactory } from './modelfactory';
import { MimeDocumentFactory } from '@jupyterlab/docregistry';

const FACTORY = 'JupyterCAD .jcad Viewer';
const FACTORY = 'JupyterCAD';
const PALETTE_CATEGORY = 'JupyterCAD';

namespace CommandIDs {
Expand All @@ -58,8 +59,8 @@ const activate = (
const widgetFactory = new JupyterCadWidgetFactory({
name: FACTORY,
modelName: 'jupytercad-jcadmodel',
fileTypes: ['jcad'],
defaultFor: ['jcad'],
fileTypes: [FACTORY],
defaultFor: [FACTORY],
tracker,
commands: app.commands,
workerRegistry,
Expand All @@ -70,22 +71,33 @@ const activate = (
mimeTypeService: editorServices.mimeTypeService,
consoleTracker
});

// Registering the widget factory
app.docRegistry.addWidgetFactory(widgetFactory);

const factory = new MimeDocumentFactory({
dataType: 'json',
rendermime,
modelName: 'jupytercad-jcadmodel',
name: 'JSON Editor',
primaryFileType: app.docRegistry.getFileType('json'),
fileTypes: [FACTORY],
});
app.docRegistry.addWidgetFactory(factory);

// Creating and registering the model factory for our custom DocumentModel
const modelFactory = new JupyterCadJcadModelFactory({
annotationModel
});
app.docRegistry.addModelFactory(modelFactory);
// register the filetype
app.docRegistry.addFileType({
name: 'jcad',
displayName: 'JCAD',
name: FACTORY,
displayName: FACTORY,
mimeTypes: ['text/json'],
extensions: ['.jcad', '.JCAD'],
fileFormat: 'text',
contentType: 'jcad',
contentType: FACTORY,
icon: logoIcon
});

Expand All @@ -94,7 +106,7 @@ const activate = (
};
if (drive) {
drive.sharedModelFactory.registerDocumentFactory(
'jcad',
FACTORY,
jcadSharedModelFactory
);
}
Expand Down

0 comments on commit 1de03b0

Please sign in to comment.