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


TypeScript documentsearch.ISearchProviderRegistry类代码示例

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


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

示例1: activateCsv

/**
 * Activate cssviewer extension for CSV files
 */
function activateCsv(
  app: JupyterFrontEnd,
  restorer: ILayoutRestorer,
  themeManager: IThemeManager,
  mainMenu: IMainMenu,
  searchregistry: ISearchProviderRegistry = null
): void {
  const factory = new CSVViewerFactory({
    name: FACTORY_CSV,
    fileTypes: ['csv'],
    defaultFor: ['csv'],
    readOnly: true
  });
  const tracker = new InstanceTracker<IDocumentWidget<CSVViewer>>({
    namespace: 'csvviewer'
  });

  // The current styles for the data grids.
  let style: DataGrid.IStyle = Private.LIGHT_STYLE;
  let rendererConfig: TextRenderConfig = Private.LIGHT_TEXT_CONFIG;

  // Handle state restoration.
  restorer.restore(tracker, {
    command: 'docmanager:open',
    args: widget => ({ path: widget.context.path, factory: FACTORY_CSV }),
    name: widget => widget.context.path
  });

  app.docRegistry.addWidgetFactory(factory);
  let ft = app.docRegistry.getFileType('csv');
  factory.widgetCreated.connect((sender, widget) => {
    // Track the widget.
    void tracker.add(widget);
    // Notify the instance tracker if restore data needs to update.
    widget.context.pathChanged.connect(() => {
      void tracker.save(widget);
    });

    if (ft) {
      widget.title.iconClass = ft.iconClass;
      widget.title.iconLabel = ft.iconLabel;
    }
    // Set the theme for the new widget.
    widget.content.style = style;
    widget.content.rendererConfig = rendererConfig;
  });

  // Keep the themes up-to-date.
  const updateThemes = () => {
    const isLight = themeManager.isLight(themeManager.theme);
    style = isLight ? Private.LIGHT_STYLE : Private.DARK_STYLE;
    rendererConfig = isLight
      ? Private.LIGHT_TEXT_CONFIG
      : Private.DARK_TEXT_CONFIG;
    tracker.forEach(grid => {
      grid.content.style = style;
      grid.content.rendererConfig = rendererConfig;
    });
  };
  themeManager.themeChanged.connect(updateThemes);

  addMenuEntries(mainMenu, tracker);
  if (searchregistry) {
    searchregistry.registerProvider('csv', CSVSearchProvider);
  }
}
开发者ID:afshin,项目名称:jupyterlab,代码行数:69,代码来源:index.ts

示例2:

 labShell.activeChanged.connect((_, args) => {
   const oldWidget = args.oldValue;
   const newWidget = args.newValue;
   if (newWidget && registry.getProviderForWidget(newWidget) !== undefined) {
     newWidget.addClass(SEARCHABLE_CLASS);
   }
   if (oldWidget) {
     oldWidget.removeClass(SEARCHABLE_CLASS);
   }
 });
开发者ID:jupyter,项目名称:jupyterlab,代码行数:10,代码来源:index.ts


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