當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Mode.getModeInfo方法代碼示例

本文整理匯總了TypeScript中@jupyterlab/codemirror.Mode.getModeInfo方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Mode.getModeInfo方法的具體用法?TypeScript Mode.getModeInfo怎麽用?TypeScript Mode.getModeInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@jupyterlab/codemirror.Mode的用法示例。


在下文中一共展示了Mode.getModeInfo方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: activateEditorCommands


//.........這裏部分代碼省略.........
        return;
      }
      let editor = widget.content.editor as CodeMirrorEditor;
      editor.execCommand('jumpToLine');
    },
    isEnabled
  });

  commands.addCommand(CommandIDs.changeMode, {
    label: args => args['name'] as string,
    execute: args => {
      let name = args['name'] as string;
      let widget = tracker.currentWidget;
      if (name && widget) {
        let spec = Mode.findByName(name);
        if (spec) {
          widget.content.model.mimeType = spec.mime;
        }
      }
    },
    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 }
      });
    });

  [
    'jupyter',
    'default',
    'abcdef',
    'base16-dark',
    'base16-light',
    'hopscotch',
    'material',
    'mbo',
    'mdn-like',
    'seti',
    'solarized dark',
    'solarized light',
    'the-matrix',
    'xq-light',
    'zenburn'
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:67,代碼來源:index.ts

示例2: createMenu


//.........這裏部分代碼省略.........
    });

    commands.addCommand(CommandIDs.findAndReplace, {
      label: 'Find & Replace',
      execute: () => {
        let widget = tracker.currentWidget;
        if (!widget) {
          return;
        }
        let editor = widget.editor as CodeMirrorEditor;
        editor.execCommand('replace');
      },
      isEnabled: hasWidget
    });

    commands.addCommand(CommandIDs.changeMode, {
      label: args => args['name'] as string,
      execute: args => {
        let name = args['name'] as string;
        let widget = tracker.currentWidget;
        if (name && widget) {
          let spec = Mode.findByName(name);
          if (spec) {
            widget.model.mimeType = spec.mime;
          }
        }
      },
      isEnabled: hasWidget,
      isToggled: args => {
        let widget = tracker.currentWidget;
        if (!widget) {
          return false;
        }
        let mime = widget.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}
      });
    });

    [
     '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 }
    }));

    ['default', 'sublime', 'vim', 'emacs'].forEach(name => {
      keyMapMenu.addItem({
        command: CommandIDs.changeKeyMap,
        args: { keyMap: name }
      });
    });

    let args: JSONObject = {
      insertSpaces: false, size: 4, name: 'Indent with Tab'
    };
    let command = 'fileeditor:change-tabs';
    tabMenu.addItem({ command, args });
    palette.addItem({ command, args, category: 'Editor' });

    for (let size of [1, 2, 4, 8]) {
      let args: JSONObject = {
        insertSpaces: true, size, name: `Spaces: ${size} `
      };
      tabMenu.addItem({ command, args });
      palette.addItem({ command, args, category: 'Editor' });
    }

    menu.addItem({ type: 'submenu', submenu: modeMenu });
    menu.addItem({ type: 'submenu', submenu: tabMenu });
    menu.addItem({ command: CommandIDs.find });
    menu.addItem({ command: CommandIDs.findAndReplace });
    menu.addItem({ type: 'separator' });
    menu.addItem({ command: 'fileeditor:toggle-line-numbers' });
    menu.addItem({ command: 'fileeditor:toggle-line-wrap' });
    menu.addItem({ command: 'fileeditor:toggle-match-brackets' });
    menu.addItem({ command: 'fileeditor:toggle-autoclosing-brackets' });
    menu.addItem({ type: 'submenu', submenu: keyMapMenu });
    menu.addItem({ type: 'submenu', submenu: themeMenu });

    return menu;
  }
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:101,代碼來源:index.ts


注:本文中的@jupyterlab/codemirror.Mode.getModeInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。