@codemirror/autocomplete 6.15.0 → 6.16.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 +12 -5
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +12 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -348,6 +348,7 @@ const completionConfig = state.Facet.define({
|
|
|
348
348
|
combine(configs) {
|
|
349
349
|
return state.combineConfig(configs, {
|
|
350
350
|
activateOnTyping: true,
|
|
351
|
+
activateOnCompletion: () => false,
|
|
351
352
|
activateOnTypingDelay: 100,
|
|
352
353
|
selectOnOpen: true,
|
|
353
354
|
override: null,
|
|
@@ -882,7 +883,12 @@ function makeAttrs(id, selected) {
|
|
|
882
883
|
return result;
|
|
883
884
|
}
|
|
884
885
|
const none = [];
|
|
885
|
-
function getUserEvent(tr) {
|
|
886
|
+
function getUserEvent(tr, conf) {
|
|
887
|
+
if (tr.isUserEvent("input.complete")) {
|
|
888
|
+
let completion = tr.annotation(pickedCompletion);
|
|
889
|
+
if (completion && conf.activateOnCompletion(completion))
|
|
890
|
+
return "input";
|
|
891
|
+
}
|
|
886
892
|
return tr.isUserEvent("input.type") ? "input" : tr.isUserEvent("delete.backward") ? "delete" : null;
|
|
887
893
|
}
|
|
888
894
|
class ActiveSource {
|
|
@@ -893,7 +899,7 @@ class ActiveSource {
|
|
|
893
899
|
}
|
|
894
900
|
hasResult() { return false; }
|
|
895
901
|
update(tr, conf) {
|
|
896
|
-
let event = getUserEvent(tr), value = this;
|
|
902
|
+
let event = getUserEvent(tr, conf), value = this;
|
|
897
903
|
if (event)
|
|
898
904
|
value = value.handleUserEvent(tr, event, conf);
|
|
899
905
|
else if (tr.docChanged)
|
|
@@ -1072,10 +1078,11 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
|
|
|
1072
1078
|
}
|
|
1073
1079
|
update(update) {
|
|
1074
1080
|
let cState = update.state.field(completionState);
|
|
1081
|
+
let conf = update.state.facet(completionConfig);
|
|
1075
1082
|
if (!update.selectionSet && !update.docChanged && update.startState.field(completionState) == cState)
|
|
1076
1083
|
return;
|
|
1077
1084
|
let doesReset = update.transactions.some(tr => {
|
|
1078
|
-
return (tr.selection || tr.docChanged) && !getUserEvent(tr);
|
|
1085
|
+
return (tr.selection || tr.docChanged) && !getUserEvent(tr, conf);
|
|
1079
1086
|
});
|
|
1080
1087
|
for (let i = 0; i < this.running.length; i++) {
|
|
1081
1088
|
let query = this.running[i];
|
|
@@ -1100,12 +1107,12 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
|
|
|
1100
1107
|
clearTimeout(this.debounceUpdate);
|
|
1101
1108
|
if (update.transactions.some(tr => tr.effects.some(e => e.is(startCompletionEffect))))
|
|
1102
1109
|
this.pendingStart = true;
|
|
1103
|
-
let delay = this.pendingStart ? 50 :
|
|
1110
|
+
let delay = this.pendingStart ? 50 : conf.activateOnTypingDelay;
|
|
1104
1111
|
this.debounceUpdate = cState.active.some(a => a.state == 1 /* State.Pending */ && !this.running.some(q => q.active.source == a.source))
|
|
1105
1112
|
? setTimeout(() => this.startUpdate(), delay) : -1;
|
|
1106
1113
|
if (this.composing != 0 /* CompositionState.None */)
|
|
1107
1114
|
for (let tr of update.transactions) {
|
|
1108
|
-
if (getUserEvent(tr) == "input")
|
|
1115
|
+
if (getUserEvent(tr, conf) == "input")
|
|
1109
1116
|
this.composing = 2 /* CompositionState.Changed */;
|
|
1110
1117
|
else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection)
|
|
1111
1118
|
this.composing = 3 /* CompositionState.ChangedAndMoved */;
|
package/dist/index.d.cts
CHANGED
|
@@ -294,6 +294,11 @@ interface CompletionConfig {
|
|
|
294
294
|
*/
|
|
295
295
|
activateOnTyping?: boolean;
|
|
296
296
|
/**
|
|
297
|
+
When given, if a completion that matches the predicate is
|
|
298
|
+
picked, reactivate completion again as if it was typed normally.
|
|
299
|
+
*/
|
|
300
|
+
activateOnCompletion?: (completion: Completion) => boolean;
|
|
301
|
+
/**
|
|
297
302
|
The amount of time to wait for further typing before querying
|
|
298
303
|
completion sources via
|
|
299
304
|
[`activateOnTyping`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.activateOnTyping).
|
package/dist/index.d.ts
CHANGED
|
@@ -294,6 +294,11 @@ interface CompletionConfig {
|
|
|
294
294
|
*/
|
|
295
295
|
activateOnTyping?: boolean;
|
|
296
296
|
/**
|
|
297
|
+
When given, if a completion that matches the predicate is
|
|
298
|
+
picked, reactivate completion again as if it was typed normally.
|
|
299
|
+
*/
|
|
300
|
+
activateOnCompletion?: (completion: Completion) => boolean;
|
|
301
|
+
/**
|
|
297
302
|
The amount of time to wait for further typing before querying
|
|
298
303
|
completion sources via
|
|
299
304
|
[`activateOnTyping`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.activateOnTyping).
|
package/dist/index.js
CHANGED
|
@@ -346,6 +346,7 @@ const completionConfig = /*@__PURE__*/Facet.define({
|
|
|
346
346
|
combine(configs) {
|
|
347
347
|
return combineConfig(configs, {
|
|
348
348
|
activateOnTyping: true,
|
|
349
|
+
activateOnCompletion: () => false,
|
|
349
350
|
activateOnTypingDelay: 100,
|
|
350
351
|
selectOnOpen: true,
|
|
351
352
|
override: null,
|
|
@@ -880,7 +881,12 @@ function makeAttrs(id, selected) {
|
|
|
880
881
|
return result;
|
|
881
882
|
}
|
|
882
883
|
const none = [];
|
|
883
|
-
function getUserEvent(tr) {
|
|
884
|
+
function getUserEvent(tr, conf) {
|
|
885
|
+
if (tr.isUserEvent("input.complete")) {
|
|
886
|
+
let completion = tr.annotation(pickedCompletion);
|
|
887
|
+
if (completion && conf.activateOnCompletion(completion))
|
|
888
|
+
return "input";
|
|
889
|
+
}
|
|
884
890
|
return tr.isUserEvent("input.type") ? "input" : tr.isUserEvent("delete.backward") ? "delete" : null;
|
|
885
891
|
}
|
|
886
892
|
class ActiveSource {
|
|
@@ -891,7 +897,7 @@ class ActiveSource {
|
|
|
891
897
|
}
|
|
892
898
|
hasResult() { return false; }
|
|
893
899
|
update(tr, conf) {
|
|
894
|
-
let event = getUserEvent(tr), value = this;
|
|
900
|
+
let event = getUserEvent(tr, conf), value = this;
|
|
895
901
|
if (event)
|
|
896
902
|
value = value.handleUserEvent(tr, event, conf);
|
|
897
903
|
else if (tr.docChanged)
|
|
@@ -1070,10 +1076,11 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
1070
1076
|
}
|
|
1071
1077
|
update(update) {
|
|
1072
1078
|
let cState = update.state.field(completionState);
|
|
1079
|
+
let conf = update.state.facet(completionConfig);
|
|
1073
1080
|
if (!update.selectionSet && !update.docChanged && update.startState.field(completionState) == cState)
|
|
1074
1081
|
return;
|
|
1075
1082
|
let doesReset = update.transactions.some(tr => {
|
|
1076
|
-
return (tr.selection || tr.docChanged) && !getUserEvent(tr);
|
|
1083
|
+
return (tr.selection || tr.docChanged) && !getUserEvent(tr, conf);
|
|
1077
1084
|
});
|
|
1078
1085
|
for (let i = 0; i < this.running.length; i++) {
|
|
1079
1086
|
let query = this.running[i];
|
|
@@ -1098,12 +1105,12 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
1098
1105
|
clearTimeout(this.debounceUpdate);
|
|
1099
1106
|
if (update.transactions.some(tr => tr.effects.some(e => e.is(startCompletionEffect))))
|
|
1100
1107
|
this.pendingStart = true;
|
|
1101
|
-
let delay = this.pendingStart ? 50 :
|
|
1108
|
+
let delay = this.pendingStart ? 50 : conf.activateOnTypingDelay;
|
|
1102
1109
|
this.debounceUpdate = cState.active.some(a => a.state == 1 /* State.Pending */ && !this.running.some(q => q.active.source == a.source))
|
|
1103
1110
|
? setTimeout(() => this.startUpdate(), delay) : -1;
|
|
1104
1111
|
if (this.composing != 0 /* CompositionState.None */)
|
|
1105
1112
|
for (let tr of update.transactions) {
|
|
1106
|
-
if (getUserEvent(tr) == "input")
|
|
1113
|
+
if (getUserEvent(tr, conf) == "input")
|
|
1107
1114
|
this.composing = 2 /* CompositionState.Changed */;
|
|
1108
1115
|
else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection)
|
|
1109
1116
|
this.composing = 3 /* CompositionState.ChangedAndMoved */;
|