How to use the @jupyterlab/docregistry.DocumentRegistry.defaultNotebookFileType function in @jupyterlab/docregistry

To help you get started, we’ve selected a few @jupyterlab/docregistry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab-google-drive / src / contents.ts View on Github external
let baseName = 'Untitled';
    let path = '';
    let contentType: Contents.ContentType = 'notebook';
    let fileType: DocumentRegistry.IFileType;

    if (options) {
      // Add leading `.` to extension if necessary.
      ext = options.ext ? PathExt.normalizeExtension(options.ext) : ext;
      // If we are not creating in the root directory.
      path = options.path || '';
      contentType = options.type || 'notebook';
    }

    let model: Partial;
    if (contentType === 'notebook') {
      fileType = DocumentRegistry.defaultNotebookFileType;
      ext = ext || fileType.extensions[0];
      baseName = 'Untitled';
      const modelFactory = this._docRegistry.getModelFactory('Notebook');
      if (!modelFactory) {
        throw Error('No model factory is registered with the DocRegistry');
      }
      model = {
        type: fileType.contentType,
        content: modelFactory.createNew().toJSON(),
        mimetype: fileType.mimeTypes[0],
        format: fileType.fileFormat
      };
    } else if (contentType === 'file') {
      fileType = DocumentRegistry.defaultTextFileType;
      ext = ext || fileType.extensions[0];
      baseName = 'untitled';