本文整理汇总了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);
}
}
示例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);
}
});