@codemirror/autocomplete 6.1.1 → 6.2.0
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 +6 -0
- package/dist/index.cjs +6 -5
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 6.2.0 (2022-09-13)
|
|
2
|
+
|
|
3
|
+
### New features
|
|
4
|
+
|
|
5
|
+
Autocompletion now takes an `interactionDelay` option that can be used to control the delay between the time where completion opens and the time where commands like `acceptCompletion` affect it.
|
|
6
|
+
|
|
1
7
|
## 6.1.1 (2022-09-08)
|
|
2
8
|
|
|
3
9
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -331,7 +331,8 @@ const completionConfig = state.Facet.define({
|
|
|
331
331
|
aboveCursor: false,
|
|
332
332
|
icons: true,
|
|
333
333
|
addToOptions: [],
|
|
334
|
-
compareCompletions: (a, b) => a.label.localeCompare(b.label)
|
|
334
|
+
compareCompletions: (a, b) => a.label.localeCompare(b.label),
|
|
335
|
+
interactionDelay: 75
|
|
335
336
|
}, {
|
|
336
337
|
defaultKeymap: (a, b) => a && b,
|
|
337
338
|
closeOnBlur: (a, b) => a && b,
|
|
@@ -826,7 +827,6 @@ const completionState = state.StateField.define({
|
|
|
826
827
|
]
|
|
827
828
|
});
|
|
828
829
|
|
|
829
|
-
const CompletionInteractMargin = 75;
|
|
830
830
|
/**
|
|
831
831
|
Returns a command that moves the completion selection forward or
|
|
832
832
|
backward by the given amount.
|
|
@@ -834,7 +834,8 @@ backward by the given amount.
|
|
|
834
834
|
function moveCompletionSelection(forward, by = "option") {
|
|
835
835
|
return (view$1) => {
|
|
836
836
|
let cState = view$1.state.field(completionState, false);
|
|
837
|
-
if (!cState || !cState.open ||
|
|
837
|
+
if (!cState || !cState.open ||
|
|
838
|
+
Date.now() - cState.open.timestamp < view$1.state.facet(completionConfig).interactionDelay)
|
|
838
839
|
return false;
|
|
839
840
|
let step = 1, tooltip;
|
|
840
841
|
if (by == "page" && (tooltip = view.getTooltip(view$1, cState.open.tooltip)))
|
|
@@ -855,8 +856,8 @@ Accept the current completion.
|
|
|
855
856
|
*/
|
|
856
857
|
const acceptCompletion = (view) => {
|
|
857
858
|
let cState = view.state.field(completionState, false);
|
|
858
|
-
if (view.state.readOnly || !cState || !cState.open ||
|
|
859
|
-
cState.open.
|
|
859
|
+
if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 ||
|
|
860
|
+
Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
|
|
860
861
|
return false;
|
|
861
862
|
applyCompletion(view, cState.open.options[cState.open.selected]);
|
|
862
863
|
return true;
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,13 @@ interface CompletionConfig {
|
|
|
78
78
|
[`localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
|
|
79
79
|
*/
|
|
80
80
|
compareCompletions?: (a: Completion, b: Completion) => number;
|
|
81
|
+
/**
|
|
82
|
+
By default, commands relating to an open completion only take
|
|
83
|
+
effect 75 milliseconds after the completion opened, so that key
|
|
84
|
+
presses made before the user is aware of the tooltip don't go to
|
|
85
|
+
the tooltip. This option can be used to configure that delay.
|
|
86
|
+
*/
|
|
87
|
+
interactionDelay?: number;
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
/**
|
package/dist/index.js
CHANGED
|
@@ -327,7 +327,8 @@ const completionConfig = /*@__PURE__*/Facet.define({
|
|
|
327
327
|
aboveCursor: false,
|
|
328
328
|
icons: true,
|
|
329
329
|
addToOptions: [],
|
|
330
|
-
compareCompletions: (a, b) => a.label.localeCompare(b.label)
|
|
330
|
+
compareCompletions: (a, b) => a.label.localeCompare(b.label),
|
|
331
|
+
interactionDelay: 75
|
|
331
332
|
}, {
|
|
332
333
|
defaultKeymap: (a, b) => a && b,
|
|
333
334
|
closeOnBlur: (a, b) => a && b,
|
|
@@ -822,7 +823,6 @@ const completionState = /*@__PURE__*/StateField.define({
|
|
|
822
823
|
]
|
|
823
824
|
});
|
|
824
825
|
|
|
825
|
-
const CompletionInteractMargin = 75;
|
|
826
826
|
/**
|
|
827
827
|
Returns a command that moves the completion selection forward or
|
|
828
828
|
backward by the given amount.
|
|
@@ -830,7 +830,8 @@ backward by the given amount.
|
|
|
830
830
|
function moveCompletionSelection(forward, by = "option") {
|
|
831
831
|
return (view) => {
|
|
832
832
|
let cState = view.state.field(completionState, false);
|
|
833
|
-
if (!cState || !cState.open ||
|
|
833
|
+
if (!cState || !cState.open ||
|
|
834
|
+
Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
|
|
834
835
|
return false;
|
|
835
836
|
let step = 1, tooltip;
|
|
836
837
|
if (by == "page" && (tooltip = getTooltip(view, cState.open.tooltip)))
|
|
@@ -851,8 +852,8 @@ Accept the current completion.
|
|
|
851
852
|
*/
|
|
852
853
|
const acceptCompletion = (view) => {
|
|
853
854
|
let cState = view.state.field(completionState, false);
|
|
854
|
-
if (view.state.readOnly || !cState || !cState.open ||
|
|
855
|
-
cState.open.
|
|
855
|
+
if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 ||
|
|
856
|
+
Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
|
|
856
857
|
return false;
|
|
857
858
|
applyCompletion(view, cState.open.options[cState.open.selected]);
|
|
858
859
|
return true;
|