|
@@ -1,12 +1,12 @@
|
|
|
// Copyright (c) Jupyter Development Team.
|
|
|
// Distributed under the terms of the Modified BSD License.
|
|
|
-import '../style/index.css';
|
|
|
+import '@jupyterlab/documentsearch/style/index.css';
|
|
|
|
|
|
import {
|
|
|
SearchProviderRegistry,
|
|
|
ISearchProviderRegistry
|
|
|
-} from './searchproviderregistry';
|
|
|
-import { SearchInstance } from './searchinstance';
|
|
|
+} from '@jupyterlab/documentsearch';
|
|
|
+import { SearchInstance } from '@jupyterlab/documentsearch';
|
|
|
|
|
|
import {
|
|
|
JupyterFrontEnd,
|
|
@@ -17,149 +17,7 @@ import { ICommandPalette } from '@jupyterlab/apputils';
|
|
|
|
|
|
import { IMainMenu } from '@jupyterlab/mainmenu';
|
|
|
|
|
|
-import { ISignal } from '@phosphor/signaling';
|
|
|
-
|
|
|
-export { ISearchProviderRegistry } from './searchproviderregistry';
|
|
|
-
|
|
|
-export interface ISearchMatch {
|
|
|
- /**
|
|
|
- * Text of the exact match itself
|
|
|
- */
|
|
|
- readonly text: string;
|
|
|
-
|
|
|
- /**
|
|
|
- * Fragment containing match
|
|
|
- */
|
|
|
- readonly fragment: string;
|
|
|
-
|
|
|
- /**
|
|
|
- * Line number of match
|
|
|
- */
|
|
|
- line: number;
|
|
|
-
|
|
|
- /**
|
|
|
- * Column location of match
|
|
|
- */
|
|
|
- column: number;
|
|
|
-
|
|
|
- /**
|
|
|
- * Index among the other matches
|
|
|
- */
|
|
|
- index: number;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * This interface is meant to enforce that SearchProviders implement the static
|
|
|
- * canSearchOn function.
|
|
|
- */
|
|
|
-export interface ISearchProviderConstructor {
|
|
|
- new (): ISearchProvider;
|
|
|
- /**
|
|
|
- * Report whether or not this provider has the ability to search on the given object
|
|
|
- */
|
|
|
- canSearchOn(domain: any): boolean;
|
|
|
-}
|
|
|
-
|
|
|
-export interface ISearchProvider {
|
|
|
- /**
|
|
|
- * Initialize the search using the provided options. Should update the UI
|
|
|
- * to highlight all matches and "select" whatever the first match should be.
|
|
|
- *
|
|
|
- * @param query A RegExp to be use to perform the search
|
|
|
- * @param searchTarget The widget to be searched
|
|
|
- *
|
|
|
- * @returns A promise that resolves with a list of all matches
|
|
|
- */
|
|
|
- startQuery(query: RegExp, searchTarget: any): Promise<ISearchMatch[]>;
|
|
|
-
|
|
|
- /**
|
|
|
- * Clears state of a search provider to prepare for startQuery to be called
|
|
|
- * in order to start a new query or refresh an existing one.
|
|
|
- *
|
|
|
- * @returns A promise that resolves when the search provider is ready to
|
|
|
- * begin a new search.
|
|
|
- */
|
|
|
- endQuery(): Promise<void>;
|
|
|
-
|
|
|
- /**
|
|
|
- * Resets UI state as it was before the search process began. Cleans up and
|
|
|
- * disposes of all internal state.
|
|
|
- *
|
|
|
- * @returns A promise that resolves when all state has been cleaned up.
|
|
|
- */
|
|
|
- endSearch(): Promise<void>;
|
|
|
-
|
|
|
- /**
|
|
|
- * Move the current match indicator to the next match.
|
|
|
- *
|
|
|
- * @returns A promise that resolves once the action has completed.
|
|
|
- */
|
|
|
- highlightNext(): Promise<ISearchMatch | undefined>;
|
|
|
-
|
|
|
- /**
|
|
|
- * Move the current match indicator to the previous match.
|
|
|
- *
|
|
|
- * @returns A promise that resolves once the action has completed.
|
|
|
- */
|
|
|
- highlightPrevious(): Promise<ISearchMatch | undefined>;
|
|
|
-
|
|
|
- /**
|
|
|
- * The same list of matches provided by the startQuery promise resoluton
|
|
|
- */
|
|
|
- readonly matches: ISearchMatch[];
|
|
|
-
|
|
|
- /**
|
|
|
- * Signal indicating that something in the search has changed, so the UI should update
|
|
|
- */
|
|
|
- readonly changed: ISignal<ISearchProvider, void>;
|
|
|
-
|
|
|
- /**
|
|
|
- * The current index of the selected match.
|
|
|
- */
|
|
|
- readonly currentMatchIndex: number | null;
|
|
|
-}
|
|
|
-
|
|
|
-export interface IDisplayState {
|
|
|
- /**
|
|
|
- * The index of the currently selected match
|
|
|
- */
|
|
|
- currentIndex: number;
|
|
|
-
|
|
|
- /**
|
|
|
- * The total number of matches found in the document
|
|
|
- */
|
|
|
- totalMatches: number;
|
|
|
-
|
|
|
- /**
|
|
|
- * Should the search be case sensitive?
|
|
|
- */
|
|
|
- caseSensitive: boolean;
|
|
|
-
|
|
|
- /**
|
|
|
- * Should the search string be treated as a RegExp?
|
|
|
- */
|
|
|
- useRegex: boolean;
|
|
|
-
|
|
|
- /**
|
|
|
- * The text in the entry
|
|
|
- */
|
|
|
- inputText: string;
|
|
|
-
|
|
|
- /**
|
|
|
- * The query constructed from the text and the case/regex flags
|
|
|
- */
|
|
|
- query: RegExp;
|
|
|
-
|
|
|
- /**
|
|
|
- * An error message (used for bad regex syntax)
|
|
|
- */
|
|
|
- errorMessage: string;
|
|
|
-
|
|
|
- /**
|
|
|
- * Should the focus forced into the input on the next render?
|
|
|
- */
|
|
|
- forceFocus: boolean;
|
|
|
-}
|
|
|
+export { ISearchProviderRegistry } from '@jupyterlab/documentsearch';
|
|
|
|
|
|
/**
|
|
|
* Initialization data for the document-search extension.
|