当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript phosphor-commandpalette.StandardPaletteModel类代码示例

本文整理汇总了TypeScript中phosphor-commandpalette.StandardPaletteModel的典型用法代码示例。如果您正苦于以下问题:TypeScript StandardPaletteModel类的具体用法?TypeScript StandardPaletteModel怎么用?TypeScript StandardPaletteModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StandardPaletteModel类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: main

function main() {
  let p1 = new CommandPalette();
  let m1 = new StandardPaletteModel();
  m1.addItems(EMPIRES.map(createOptions));
  p1.model = m1;

  let p2 = new CommandPalette();
  let m2 = new StandardPaletteModel();
  m2.addItems(LANGUAGES.map(createOptions));
  p2.model = m2;

  let output = new Widget();
  output.id = 'output';

  let palettes = new BoxPanel();
  palettes.direction = BoxPanel.LeftToRight;
  palettes.spacing = 4;

  let outer = new BoxPanel();
  outer.id = 'main';
  outer.direction = BoxPanel.TopToBottom;
  outer.spacing = 4;

  BoxPanel.setStretch(p1, 1);
  BoxPanel.setStretch(p2, 1);

  BoxPanel.setSizeBasis(output, 60);
  BoxPanel.setStretch(palettes, 1);

  palettes.addChild(p1);
  palettes.addChild(p2);

  outer.addChild(palettes);
  outer.addChild(output);

  outer.attach(document.body);

  window.onresize = () => { outer.update(); };
}
开发者ID:rlugojr,项目名称:phosphor-commandpalette,代码行数:39,代码来源:index.ts

示例2: createApp

function createApp(sessionsManager: NotebookSessionManager, specs: IKernelSpecIds): void {
  // Initialize the keymap manager with the bindings.
  let keymap = new KeymapManager();
  let useCapture = true;

  // Setup the keydown listener for the document.
  document.addEventListener('keydown', event => {
    keymap.processKeydownEvent(event);
  }, useCapture);

  const transformers = [
    new JavascriptRenderer(),
    new MarkdownRenderer(),
    new HTMLRenderer(),
    new ImageRenderer(),
    new SVGRenderer(),
    new LatexRenderer(),
    new TextRenderer()
  ];
  let renderers: MimeMap<IRenderer<Widget>> = {};
  let order: string[] = [];
  for (let t of transformers) {
    for (let m of t.mimetypes) {
      renderers[m] = t;
      order.push(m);
    }
  }
  let rendermime = new RenderMime<Widget>(renderers, order);

  let opener = {
    open: (widget: DocumentWrapper) => {
      // Do nothing for sibling widgets for now.
    }
  };

  let contentsManager = new ContentsManager();
  let docRegistry = new DocumentRegistry();
  let docManager = new DocumentManager(
    docRegistry, contentsManager, sessionsManager, specs, opener
  );
  let mFactory = new NotebookModelFactory();
  let clipboard = new MimeData();
  let wFactory = new NotebookWidgetFactory(rendermime, clipboard);
  docRegistry.registerModelFactory(mFactory);
  docRegistry.registerWidgetFactory(wFactory, {
    displayName: 'Notebook',
    modelName: 'notebook',
    fileExtensions: ['.ipynb'],
    defaultFor: ['.ipynb'],
    preferKernel: true,
    canStartKernel: true
  });

  let doc = docManager.open(NOTEBOOK);
  let nbWidget: NotebookPanel;
  doc.populated.connect((d, widget) => {
    nbWidget = widget as NotebookPanel;
  });

  let pModel = new StandardPaletteModel();
  let palette = new CommandPalette();
  palette.model = pModel;

  let panel = new SplitPanel();
  panel.id = 'main';
  panel.orientation = SplitPanel.Horizontal;
  panel.spacing = 0;
  SplitPanel.setStretch(palette, 0);
  panel.attach(document.body);
  panel.addChild(palette);
  panel.addChild(doc);
  SplitPanel.setStretch(doc, 1);
  window.onresize = () => panel.update();

  let saveHandler = () => nbWidget.context.save();
  let interruptHandler = () => {
    if (nbWidget.context.kernel) {
      nbWidget.context.kernel.interrupt();
    }
  };
  let restartHandler = () => nbWidget.restart();
  let switchHandler = () => {
    selectKernelForContext(nbWidget.context, nbWidget.node);
  };
  let runAdvanceHandler = () => {
    NotebookActions.runAndAdvance(nbWidget.content, nbWidget.context.kernel);
  };
  let editHandler = () => { nbWidget.content.mode = 'edit'; };
  let commandHandler = () => { nbWidget.content.mode = 'command'; };
  let codeHandler = () => {
    NotebookActions.changeCellType(nbWidget.content, 'code');
  };
  let markdownHandler = () => {
    NotebookActions.changeCellType(nbWidget.content, 'markdown');
  };
  let rawHandler = () => {
    NotebookActions.changeCellType(nbWidget.content, 'raw');
  };
  let selectBelowHandler = () => {
    NotebookActions.selectBelow(nbWidget.content);
//.........这里部分代码省略.........
开发者ID:jots,项目名称:jupyterlab,代码行数:101,代码来源:index.ts

示例3: main

function main(): void {
  // Initialize the keymap manager with the bindings.
  var keymap = new KeymapManager();

  // Setup the keydown listener for the document.
  document.addEventListener('keydown', event => {
    keymap.processKeydownEvent(event);
  });
  // TODO: check out static example from the history
  // and make that a separate example.

  let contents = new ContentsManager(SERVER_URL);
  let nbModel = new NotebookModel();
  let nbManager = new NotebookManager(nbModel, contents);
  let rendermime = new RenderMime<Widget>();
  const transformers = [
    new JavascriptRenderer(),
    new HTMLRenderer(),
    new ImageRenderer(),
    new SVGRenderer(),
    new LatexRenderer(),
    new ConsoleTextRenderer(),
    new TextRenderer()
  ];

  for (let t of transformers) {
    for (let m of t.mimetypes) {
      rendermime.order.push(m);
      rendermime.renderers[m] = t;
    }
  }

  let nbWidget = new NotebookPanel(nbManager, rendermime);
  nbWidget.title.text = NOTEBOOK;

  let pModel = new StandardPaletteModel();
  let palette = new CommandPalette();
  palette.model = pModel;

  let panel = new SplitPanel();
  panel.id = 'main';
  panel.orientation = SplitPanel.Horizontal;
  SplitPanel.setStretch(palette, 1);
  SplitPanel.setStretch(nbWidget, 2);
  panel.attach(document.body);
  panel.addChild(palette);
  panel.addChild(nbWidget);
  window.onresize = () => { panel.update(); };

  let kernelspecs: IKernelSpecIds;

  let items: IStandardPaletteItemOptions[] = [
  {
    category: 'Notebook',
    text: 'Save',
    shortcut: 'Accel S',
    handler: () => { nbManager.save() ; }
  },
  {
    category: 'Notebook',
    text: 'Switch Kernel',
    handler: () => {
      if (!kernelspecs) {
        return;
      }
      selectKernel(nbWidget.node, nbModel, kernelspecs);
    }
  },
  {
    category: 'Notebook',
    text: 'Interrupt Kernel',
    shortcut: 'I I',
    handler: () => { nbManager.interrupt() ; }
  },
  {
    category: 'Notebook',
    text: 'Restart Kernel',
    shortcut: '0 0',
    handler: () => { nbManager.restart() ; }
  },
  {
    category: 'Notebook',
    text: 'Trust Notebook',
    handler: () => {
      trustNotebook(nbModel, nbWidget.node);
    }
  },
  {
    category: 'Notebook Cell',
    text: 'Run and Advance',
    shortcut: 'Shift Enter',
    handler: () => { nbManager.runAndAdvance(); }
  },
  {
    category: 'Notebook Cell',
    text: 'Run Selected',
    handler: () => { nbManager.run(); }
  },
  {
    category: 'Notebook Cell',
//.........这里部分代码省略.........
开发者ID:ellisonbg,项目名称:jupyter-js-notebook,代码行数:101,代码来源:index.ts

示例4: startApp

function startApp(session: ISession) {
  // Initialize the keymap manager with the bindings.
  let keymap = new KeymapManager();

  // Setup the keydown listener for the document.
  document.addEventListener('keydown', event => {
    keymap.processKeydownEvent(event);
  });

  const transformers = [
    new JavascriptRenderer(),
    new MarkdownRenderer(),
    new HTMLRenderer(),
    new ImageRenderer(),
    new SVGRenderer(),
    new LatexRenderer(),
    new TextRenderer()
  ];
  let renderers: MimeMap<IRenderer<Widget>> = {};
  let order: string[] = [];
  for (let t of transformers) {
    for (let m of t.mimetypes) {
      renderers[m] = t;
      order.push(m);
    }
  }
  let rendermime = new RenderMime<Widget>(renderers, order);

  let consolePanel = new ConsolePanel(session, rendermime);
  consolePanel.title.text = TITLE;

  let pModel = new StandardPaletteModel();
  let palette = new CommandPalette();
  palette.model = pModel;

  let panel = new SplitPanel();
  panel.id = 'main';
  panel.orientation = SplitPanel.Horizontal;
  panel.spacing = 0;
  SplitPanel.setStretch(palette, 0);
  SplitPanel.setStretch(consolePanel, 1);
  panel.attach(document.body);
  panel.addChild(palette);
  panel.addChild(consolePanel);
  window.onresize = () => { panel.update(); };

  let items: IStandardPaletteItemOptions[] = [
    {
      category: 'Console',
      text: 'Clear',
      shortcut: 'Accel R',
      handler: () => { consolePanel.content.clear(); }
    },
    {
      category: 'Console',
      text: 'Execute Prompt',
      shortcut: 'Shift Enter',
      handler: () => { consolePanel.content.execute(); }
    }
  ];
  pModel.addItems(items);

  let bindings = [
    {
      selector: '.jp-Console',
      sequence: ['Accel R'],
      handler: () => { consolePanel.content.clear(); }
    },
    {
      selector: '.jp-Console',
      sequence: ['Shift Enter'],
      handler: () => { consolePanel.content.execute(); }
    }
  ];
  keymap.add(bindings);
}
开发者ID:jacpan,项目名称:jupyterlab,代码行数:76,代码来源:index.ts

示例5: main

function main(): void {
  // Initialize the keymap manager with the bindings.
  var keymap = new KeymapManager();
  let useCapture = true;

  // Setup the keydown listener for the document.
  document.addEventListener('keydown', event => {
    keymap.processKeydownEvent(event);
  }, useCapture);
  // TODO: check out static example from the history
  // and make that a separate example.

  let contents = new ContentsManager();
  let sessions = new NotebookSessionManager();
  let rendermime = new RenderMime<Widget>();
  const transformers = [
    new JavascriptRenderer(),
    new MarkdownRenderer(),
    new HTMLRenderer(),
    new ImageRenderer(),
    new SVGRenderer(),
    new LatexRenderer(),
    new ConsoleTextRenderer(),
    new TextRenderer()
  ];

  for (let t of transformers) {
    for (let m of t.mimetypes) {
      rendermime.order.push(m);
      rendermime.renderers[m] = t;
    }
  }

  let handler = new NotebookFileHandler(contents, sessions, rendermime);
  let nbWidget = handler.open(NOTEBOOK);
  let nbModel = nbWidget.model;
  let nbManager = nbWidget.manager;

  let pModel = new StandardPaletteModel();
  let palette = new CommandPalette();
  palette.model = pModel;

  let panel = new SplitPanel();
  panel.id = 'main';
  panel.orientation = SplitPanel.Horizontal;
  panel.spacing = 0;
  SplitPanel.setStretch(palette, 0);
  SplitPanel.setStretch(nbWidget, 1);
  panel.attach(document.body);
  panel.addChild(palette);
  panel.addChild(nbWidget);
  window.onresize = () => { panel.update(); };

  let kernelspecs: IKernelSpecIds;

  let items: IStandardPaletteItemOptions[] = [
  {
    category: 'Notebook',
    text: 'Save',
    shortcut: 'Accel S',
    handler: () => { nbManager.save() ; }
  },
  {
    category: 'Notebook',
    text: 'Switch Kernel',
    handler: () => {
      if (!kernelspecs) {
        return;
      }
      selectKernel(nbWidget.node, nbModel.kernelspec.name, kernelspecs)
        .then(name => {
          if (name) {
            nbModel.session.changeKernel({name});
          }
        });
    }
  },
  {
    category: 'Notebook',
    text: 'Interrupt Kernel',
    shortcut: 'I I',
    handler: () => { nbManager.interrupt() ; }
  },
  {
    category: 'Notebook',
    text: 'Restart Kernel',
    shortcut: '0 0',
    handler: () => { nbManager.restart() ; }
  },
  {
    category: 'Notebook',
    text: 'Trust Notebook',
    handler: () => {
      trustNotebook(nbModel, nbWidget.node);
    }
  },
  {
    category: 'Notebook Cell',
    text: 'Run and Advance',
    shortcut: 'Shift Enter',
//.........这里部分代码省略.........
开发者ID:SimonBiggs,项目名称:jupyter-js-notebook,代码行数:101,代码来源:index.ts

示例6: main

function main(): void {
  // Initialize the keymap manager with the bindings.
  var keymap = new KeymapManager();

  // Setup the keydown listener for the document.
  document.addEventListener('keydown', event => {
    keymap.processKeydownEvent(event);
  });

  let contents = new ContentsManager(SERVER_URL);
  let rendermime = new RenderMime<Widget>();
  const transformers = [
    new JavascriptRenderer(),
    new HTMLRenderer(),
    new ImageRenderer(),
    new SVGRenderer(),
    new LatexRenderer(),
    new ConsoleTextRenderer(),
    new TextRenderer(),
    new MarkdownRenderer()
  ];

  for (let t of transformers) {
    for (let m of t.mimetypes) {
      rendermime.order.push(m);
      rendermime.renderers[m] = t;
    }
  }

  let consoleModel = new ConsoleModel();
  let consoleWidget = new ConsolePanel(consoleModel, rendermime);
  consoleWidget.title.text = TITLE;

  let pModel = new StandardPaletteModel();
  let palette = new CommandPalette();
  palette.model = pModel;

  let panel = new SplitPanel();
  panel.id = 'main';
  panel.orientation = SplitPanel.Horizontal;
  panel.spacing = 0;
  SplitPanel.setStretch(palette, 0);
  SplitPanel.setStretch(consoleWidget, 1);
  panel.attach(document.body);
  panel.addChild(palette);
  panel.addChild(consoleWidget);
  window.onresize = () => { panel.update(); };

  let kernelspecs: IKernelSpecIds;

  let items: IStandardPaletteItemOptions[] = [
    {
      category: 'Console',
      text: 'Execute Prompt',
      shortcut: 'Shift Enter',
      handler: () => { consoleModel.run(); }
    }
  ];
  pModel.addItems(items);

  let bindings = [
    {
      selector: '.jp-Console',
      sequence: ['Shift Enter'],
      handler: () => { consoleModel.run(); }
    }
  ]
  keymap.add(bindings);

  getKernelSpecs({}).then(specs => {
    kernelspecs = specs;
    let kernelName = specs.default;
    let language = specs.default;
    console.log('specs', specs);
    return startNewSession({
      notebookPath: 'fake_path',
      kernelName: findKernel(kernelName, language, specs),
      baseUrl: SERVER_URL
    });
  }).then(session => consoleModel.session = session);
}
开发者ID:SimonBiggs,项目名称:jupyter-js-notebook,代码行数:81,代码来源:index.ts


注:本文中的phosphor-commandpalette.StandardPaletteModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。