How to use the @jupyterlab/codemirror.Mode.getModeInfo function in @jupyterlab/codemirror

To help you get started, we’ve selected a few @jupyterlab/codemirror 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 GoogleCloudPlatform / healthcare-data-harmonization / tools / notebook / wstl-syntax-highlighting / src / index.ts View on Github external
{regex: /\/\/.*/, token: 'comment'},
      // Language operators.
      {regex: /[-+\/*=<>!~?@]+|and|or|\[\*\]/, token: 'operator'},
      // Indent and dedent properties guide autoindentation.
      {regex: /[\{\[\(]/, indent: true},
      {regex: /[\}\]\)]/, dedent: true},
      {regex: /[a-z$][\w$]*/, token: 'variable'},
    ],
    // The meta property contains global information about the mode. It
    // can contain properties like lineComment, which are supported by
    // all modes, and also directives like dontIndentStates, which are
    // specific to simple modes.
    meta: {dontIndentStates: ['comment'], lineComment: '//'}
  });
  CodeMirror.defineMIME(WHISTLE_MODE_MIME_TYPE, WHISTLE_MODE);
  Mode.getModeInfo().push({
    ext: [WHISTLE_EXT],
    mime: WHISTLE_MODE_MIME_TYPE,
    mode: WHISTLE_MODE,
    name: WHISTLE_MODE
  });
  app.docRegistry.addFileType({
    name: 'wstl',
    displayName: 'Whistle File',
    extensions: ['.wstl'],
    mimeTypes: [WHISTLE_MODE_MIME_TYPE],
    iconClass: 'jp-MaterialIcon reactivecore_icon',
    iconLabel: '',
    contentType: 'file',
    fileFormat: 'text'
  });
}
github jupyterlab / jupyterlab / packages / codemirror-extension / src / index.ts View on Github external
}
    },
    isEnabled,
    isToggled: args => {
      let widget = tracker.currentWidget;
      if (!widget) {
        return false;
      }
      let mime = widget.content.model.mimeType;
      let spec = Mode.findByMIME(mime);
      let name = spec && spec.name;
      return args['name'] === name;
    }
  });

  Mode.getModeInfo()
    .sort((a, b) => {
      let aName = a.name || '';
      let bName = b.name || '';
      return aName.localeCompare(bName);
    })
    .forEach(spec => {
      // Avoid mode name with a curse word.
      if (spec.mode.indexOf('brainf') === 0) {
        return;
      }
      modeMenu.addItem({
        command: CommandIDs.changeMode,
        args: { ...spec }
      });
    });
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / codemirror-extension / src / index.ts View on Github external
}
    },
    isEnabled,
    isToggled: args => {
      let widget = tracker.currentWidget;
      if (!widget) {
        return false;
      }
      let mime = widget.content.model.mimeType;
      let spec = Mode.findByMIME(mime);
      let name = spec && spec.name;
      return args['name'] === name;
    }
  });

  Mode.getModeInfo()
    .sort((a, b) => {
      let aName = a.name || '';
      let bName = b.name || '';
      return aName.localeCompare(bName);
    })
    .forEach(spec => {
      // Avoid mode name with a curse word.
      if (spec.mode.indexOf('brainf') === 0) {
        return;
      }
      modeMenu.addItem({
        command: CommandIDs.changeMode,
        args: { ...spec }
      });
    });
github yuvipanda / simplest-notebook / packages / codemirror-extension / src / index.ts View on Github external
}
      },
      isEnabled: hasWidget,
      isToggled: args => {
        let widget = tracker.currentWidget;
        if (!widget) {
          return false;
        }
        let mime = widget.model.mimeType;
        let spec = Mode.findByMIME(mime);
        let mode = spec && spec.mode;
        return args['mode'] === mode;
      }
    });

    Mode.getModeInfo().sort((a, b) => {
      return a.name.localeCompare(b.name);
    }).forEach(spec => {
      modeMenu.addItem({
        command: CommandIDs.changeMode,
        args: {...spec}
      });
    });

    [
     'jupyter', 'default', 'abcdef', 'base16-dark', 'base16-light',
     'hopscotch', 'material', 'mbo', 'mdn-like', 'seti', 'the-matrix',
     'xq-light', 'zenburn'
    ].forEach(name => themeMenu.addItem({
      command: CommandIDs.changeTheme,
      args: { theme: name }
    }));