本文整理汇总了TypeScript中@jupyterlab/documentsearch.SearchProviderRegistry类的典型用法代码示例。如果您正苦于以下问题:TypeScript SearchProviderRegistry类的具体用法?TypeScript SearchProviderRegistry怎么用?TypeScript SearchProviderRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SearchProviderRegistry类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: SearchProviderRegistry
activate: (
app: JupyterFrontEnd,
palette: ICommandPalette,
mainMenu: IMainMenu | null
) => {
// Create registry, retrieve all default providers
const registry: SearchProviderRegistry = new SearchProviderRegistry();
// TODO: Should register the default providers, with an application-specific
// enabler.
const activeSearches = new Map<string, SearchInstance>();
const startCommand: string = 'documentsearch:start';
const nextCommand: string = 'documentsearch:highlightNext';
const prevCommand: string = 'documentsearch:highlightPrevious';
app.commands.addCommand(startCommand, {
label: 'FindâŚ',
isEnabled: () => {
const currentWidget = app.shell.currentWidget;
if (!currentWidget) {
return;
}
return registry.getProviderForWidget(currentWidget) !== undefined;
},
execute: () => {
const currentWidget = app.shell.currentWidget;
if (!currentWidget) {
return;
}
const widgetId = currentWidget.id;
let searchInstance = activeSearches.get(widgetId);
if (!searchInstance) {
const searchProvider = registry.getProviderForWidget(currentWidget);
if (!searchProvider) {
return;
}
searchInstance = new SearchInstance(currentWidget, searchProvider);
activeSearches.set(widgetId, searchInstance);
// find next and previous are now enabled
app.commands.notifyCommandChanged();
searchInstance.disposed.connect(() => {
activeSearches.delete(widgetId);
// find next and previous are now not enabled
app.commands.notifyCommandChanged();
});
}
searchInstance.focusInput();
}
});
app.commands.addCommand(nextCommand, {
label: 'Find Next',
isEnabled: () => {
const currentWidget = app.shell.currentWidget;
if (!currentWidget) {
return;
}
return activeSearches.has(currentWidget.id);
},
execute: async () => {
const currentWidget = app.shell.currentWidget;
if (!currentWidget) {
return;
}
const instance = activeSearches.get(currentWidget.id);
if (!instance) {
return;
}
await instance.provider.highlightNext();
instance.updateIndices();
}
});
app.commands.addCommand(prevCommand, {
label: 'Find Previous',
isEnabled: () => {
const currentWidget = app.shell.currentWidget;
if (!currentWidget) {
return;
}
return activeSearches.has(currentWidget.id);
},
execute: async () => {
const currentWidget = app.shell.currentWidget;
if (!currentWidget) {
return;
}
const instance = activeSearches.get(currentWidget.id);
if (!instance) {
return;
}
await instance.provider.highlightPrevious();
instance.updateIndices();
}
});
//.........这里部分代码省略.........
示例2:
isEnabled: () => {
const currentWidget = app.shell.currentWidget;
if (!currentWidget) {
return;
}
return registry.getProviderForWidget(currentWidget) !== undefined;
},
示例3: SearchInstance
execute: () => {
const currentWidget = app.shell.currentWidget;
if (!currentWidget) {
return;
}
const widgetId = currentWidget.id;
let searchInstance = activeSearches.get(widgetId);
if (!searchInstance) {
const searchProvider = registry.getProviderForWidget(currentWidget);
if (!searchProvider) {
return;
}
searchInstance = new SearchInstance(currentWidget, searchProvider);
activeSearches.set(widgetId, searchInstance);
// find next and previous are now enabled
app.commands.notifyCommandChanged();
searchInstance.disposed.connect(() => {
activeSearches.delete(widgetId);
// find next and previous are now not enabled
app.commands.notifyCommandChanged();
});
}
searchInstance.focusInput();
}