@codemirror/autocomplete 0.19.1 → 0.19.5
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/CHANGELOG.md +42 -0
- package/dist/index.cjs +285 -186
- package/dist/index.d.ts +41 -4
- package/dist/index.js +286 -189
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _codemirror_state from '@codemirror/state';
|
|
1
2
|
import { EditorState, Transaction, StateCommand, Facet, Extension } from '@codemirror/state';
|
|
2
3
|
import { EditorView, KeyBinding, Command } from '@codemirror/view';
|
|
3
4
|
import * as _lezer_common from '@lezer/common';
|
|
@@ -12,7 +13,8 @@ interface CompletionConfig {
|
|
|
12
13
|
Override the completion sources used. By default, they will be
|
|
13
14
|
taken from the `"autocomplete"` [language
|
|
14
15
|
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) (which should hold
|
|
15
|
-
[completion sources](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource)
|
|
16
|
+
[completion sources](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) or arrays
|
|
17
|
+
of [completions](https://codemirror.net/6/docs/ref/#autocomplete.Completion)).
|
|
16
18
|
*/
|
|
17
19
|
override?: readonly CompletionSource[] | null;
|
|
18
20
|
/**
|
|
@@ -27,6 +29,30 @@ interface CompletionConfig {
|
|
|
27
29
|
same keys.)
|
|
28
30
|
*/
|
|
29
31
|
defaultKeymap?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
This can be used to add additional CSS classes to completion
|
|
34
|
+
options.
|
|
35
|
+
*/
|
|
36
|
+
optionClass?: (completion: Completion) => string;
|
|
37
|
+
/**
|
|
38
|
+
By default, the library will render icons based on the
|
|
39
|
+
completion's [type](https://codemirror.net/6/docs/ref/#autocomplete.Completion.type) in front of
|
|
40
|
+
each option. Set this to false to turn that off.
|
|
41
|
+
*/
|
|
42
|
+
icons?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
This option can be used to inject additional content into
|
|
45
|
+
options. The `render` function will be called for each visible
|
|
46
|
+
completion, and should produce a DOM node to show. `position`
|
|
47
|
+
determines where in the DOM the result appears, relative to
|
|
48
|
+
other added widgets and the standard content. The default icons
|
|
49
|
+
have position 20, the label position 50, and the detail position
|
|
50
|
+
70.
|
|
51
|
+
*/
|
|
52
|
+
addToOptions?: {
|
|
53
|
+
render: (completion: Completion, state: EditorState) => Node | null;
|
|
54
|
+
position: number;
|
|
55
|
+
}[];
|
|
30
56
|
}
|
|
31
57
|
|
|
32
58
|
/**
|
|
@@ -55,7 +81,9 @@ interface Completion {
|
|
|
55
81
|
its [label](https://codemirror.net/6/docs/ref/#autocomplete.Completion.label). When this holds a
|
|
56
82
|
string, the completion range is replaced by that string. When it
|
|
57
83
|
is a function, that function is called to perform the
|
|
58
|
-
completion.
|
|
84
|
+
completion. If it fires a transaction, it is responsible for
|
|
85
|
+
adding the [`pickedCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.pickedCompletion)
|
|
86
|
+
annotation to it.
|
|
59
87
|
*/
|
|
60
88
|
apply?: string | ((view: EditorView, completion: Completion, from: number, to: number) => void);
|
|
61
89
|
/**
|
|
@@ -205,11 +233,16 @@ interface CompletionResult {
|
|
|
205
233
|
`filter` to `false` to disable this, and cause your completions
|
|
206
234
|
to all be included, in the order they were given. When there are
|
|
207
235
|
other sources, unfiltered completions appear at the top of the
|
|
208
|
-
list of completions. `span` must not be given `filter` is
|
|
236
|
+
list of completions. `span` must not be given when `filter` is
|
|
209
237
|
`false`, because it only works when filtering.
|
|
210
238
|
*/
|
|
211
239
|
filter?: boolean;
|
|
212
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
This annotation is added to transactions that are produced by
|
|
243
|
+
picking a completion.
|
|
244
|
+
*/
|
|
245
|
+
declare const pickedCompletion: _codemirror_state.AnnotationType<Completion>;
|
|
213
246
|
|
|
214
247
|
/**
|
|
215
248
|
Convert a snippet template to a function that can apply it.
|
|
@@ -319,5 +352,9 @@ declare function completionStatus(state: EditorState): null | "active" | "pendin
|
|
|
319
352
|
Returns the available completions as an array.
|
|
320
353
|
*/
|
|
321
354
|
declare function currentCompletions(state: EditorState): readonly Completion[];
|
|
355
|
+
/**
|
|
356
|
+
Return the currently selected completion, if any.
|
|
357
|
+
*/
|
|
358
|
+
declare function selectedCompletion(state: EditorState): Completion | null;
|
|
322
359
|
|
|
323
|
-
export { Completion, CompletionContext, CompletionResult, CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, ifIn, ifNotIn, moveCompletionSelection, nextSnippetField, prevSnippetField, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
|
360
|
+
export { Completion, CompletionContext, CompletionResult, CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, ifIn, ifNotIn, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
|