@difizen/libro-search-code-cell 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/es/code-cell-search-protocol.d.ts +26 -0
- package/es/code-cell-search-protocol.d.ts.map +1 -0
- package/es/code-cell-search-protocol.js +3 -0
- package/es/code-cell-search-provider-contribution.d.ts +18 -0
- package/es/code-cell-search-provider-contribution.d.ts.map +1 -0
- package/es/code-cell-search-provider-contribution.js +64 -0
- package/es/code-cell-search-provider.d.ts +52 -0
- package/es/code-cell-search-provider.d.ts.map +1 -0
- package/es/code-cell-search-provider.js +423 -0
- package/es/code-editor-cell-search-provider.d.ts +138 -0
- package/es/code-editor-cell-search-provider.d.ts.map +1 -0
- package/es/code-editor-cell-search-provider.js +563 -0
- package/es/index.d.ts +5 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +4 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +30 -0
- package/es/search-highlighter.d.ts +58 -0
- package/es/search-highlighter.d.ts.map +1 -0
- package/es/search-highlighter.js +241 -0
- package/package.json +57 -0
- package/src/code-cell-search-protocol.ts +40 -0
- package/src/code-cell-search-provider-contribution.ts +39 -0
- package/src/code-cell-search-provider.ts +227 -0
- package/src/code-editor-cell-search-provider.ts +377 -0
- package/src/index.spec.ts +10 -0
- package/src/index.ts +4 -0
- package/src/module.ts +46 -0
- package/src/search-highlighter.ts +207 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { LibroCodeCellView } from '@difizen/libro-code-cell';
|
|
2
|
+
import type { IPosition, SearchMatch } from '@difizen/libro-code-editor';
|
|
3
|
+
import type { BaseSearchProvider, SearchFilters } from '@difizen/libro-search';
|
|
4
|
+
import type { Event } from '@difizen/mana-app';
|
|
5
|
+
import { DisposableCollection, Emitter } from '@difizen/mana-app';
|
|
6
|
+
import type { CodeEditorSearchHighlighter } from './code-cell-search-protocol.js';
|
|
7
|
+
import { CodeEditorSearchHighlighterFactory } from './code-cell-search-protocol.js';
|
|
8
|
+
/**
|
|
9
|
+
* Search provider for cells.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CodeEditorCellSearchProvider implements BaseSearchProvider {
|
|
12
|
+
protected toDispose: DisposableCollection;
|
|
13
|
+
/**
|
|
14
|
+
* CodeMirror search highlighter
|
|
15
|
+
*/
|
|
16
|
+
protected editorHighlighter: CodeEditorSearchHighlighter;
|
|
17
|
+
/**
|
|
18
|
+
* Current match index
|
|
19
|
+
*/
|
|
20
|
+
protected currentIndex: number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Current search filters
|
|
23
|
+
*/
|
|
24
|
+
protected filters: SearchFilters | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Current search query
|
|
27
|
+
*/
|
|
28
|
+
protected query: RegExp | null;
|
|
29
|
+
protected stateChangedEmitter: Emitter<void>;
|
|
30
|
+
protected _isActive: boolean;
|
|
31
|
+
protected _isDisposed: boolean;
|
|
32
|
+
protected lastReplacementPosition: IPosition | null;
|
|
33
|
+
protected highlighterFactory: CodeEditorSearchHighlighterFactory;
|
|
34
|
+
protected cell: LibroCodeCellView;
|
|
35
|
+
/**
|
|
36
|
+
* Constructor
|
|
37
|
+
*
|
|
38
|
+
* @param cell Cell widget
|
|
39
|
+
*/
|
|
40
|
+
constructor(highlighterFactory: CodeEditorSearchHighlighterFactory, cell: LibroCodeCellView);
|
|
41
|
+
/**
|
|
42
|
+
* Get an initial query value if applicable so that it can be entered
|
|
43
|
+
* into the search box as an initial query
|
|
44
|
+
*
|
|
45
|
+
* @returns Initial value used to populate the search box.
|
|
46
|
+
*/
|
|
47
|
+
getInitialQuery(): string;
|
|
48
|
+
get disposed(): boolean;
|
|
49
|
+
protected setEditor(): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Changed signal to be emitted when search matches change.
|
|
52
|
+
*/
|
|
53
|
+
get stateChanged(): Event<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Current match index
|
|
56
|
+
*/
|
|
57
|
+
get currentMatchIndex(): number | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the cell search is active.
|
|
60
|
+
*
|
|
61
|
+
* This is used when applying search only on selected cells.
|
|
62
|
+
*/
|
|
63
|
+
get isActive(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the search provider is disposed or not.
|
|
66
|
+
*/
|
|
67
|
+
get isDisposed(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Number of matches in the cell.
|
|
70
|
+
*/
|
|
71
|
+
get matchesCount(): number;
|
|
72
|
+
get isCellSelected(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Clear currently highlighted match
|
|
75
|
+
*/
|
|
76
|
+
clearHighlight(): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Dispose the search provider
|
|
79
|
+
*/
|
|
80
|
+
dispose(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Set `isActive` status.
|
|
83
|
+
*
|
|
84
|
+
* #### Notes
|
|
85
|
+
* It will start or end the search
|
|
86
|
+
*
|
|
87
|
+
* @param v New value
|
|
88
|
+
*/
|
|
89
|
+
setIsActive(v: boolean): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Initialize the search using the provided options. Should update the UI
|
|
92
|
+
* to highlight all matches and "select" the first match.
|
|
93
|
+
*
|
|
94
|
+
* @param query A RegExp to be use to perform the search
|
|
95
|
+
* @param filters Filter parameters to pass to provider
|
|
96
|
+
*/
|
|
97
|
+
startQuery(query: RegExp | null, filters?: SearchFilters): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Stop the search and clean any UI elements.
|
|
100
|
+
*/
|
|
101
|
+
endQuery(): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Highlight the next match.
|
|
104
|
+
*
|
|
105
|
+
* @returns The next match if there is one.
|
|
106
|
+
*/
|
|
107
|
+
highlightNext(): Promise<SearchMatch | undefined>;
|
|
108
|
+
/**
|
|
109
|
+
* Highlight the previous match.
|
|
110
|
+
*
|
|
111
|
+
* @returns The previous match if there is one.
|
|
112
|
+
*/
|
|
113
|
+
highlightPrevious(): Promise<SearchMatch | undefined>;
|
|
114
|
+
/**
|
|
115
|
+
* Replace the currently selected match with the provided text.
|
|
116
|
+
*
|
|
117
|
+
* If no match is selected, it won't do anything.
|
|
118
|
+
*
|
|
119
|
+
* @param newText The replacement text.
|
|
120
|
+
* @returns Whether a replace occurred.
|
|
121
|
+
*/
|
|
122
|
+
replaceCurrentMatch(newText: string): Promise<boolean>;
|
|
123
|
+
/**
|
|
124
|
+
* Replace all matches in the cell source with the provided text
|
|
125
|
+
*
|
|
126
|
+
* @param newText The replacement text.
|
|
127
|
+
* @returns Whether a replace occurred.
|
|
128
|
+
*/
|
|
129
|
+
replaceAllMatches: (newText: string) => Promise<boolean>;
|
|
130
|
+
/**
|
|
131
|
+
* Get the current match if it exists.
|
|
132
|
+
*
|
|
133
|
+
* @returns The current match
|
|
134
|
+
*/
|
|
135
|
+
protected getCurrentMatch(): SearchMatch | undefined;
|
|
136
|
+
protected updateMatches: () => Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=code-editor-cell-search-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor-cell-search-provider.d.ts","sourceRoot":"","sources":["../src/code-editor-cell-search-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIlE,OAAO,K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