@codemirror/autocomplete 6.9.1 → 6.9.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/CHANGELOG.md +6 -0
- package/dist/index.cjs +19 -15
- package/dist/index.js +19 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -485,22 +485,32 @@ class CompletionTooltip {
|
|
|
485
485
|
e.relatedTarget != view.contentDOM)
|
|
486
486
|
view.dispatch({ effects: closeCompletionEffect.of(null) });
|
|
487
487
|
});
|
|
488
|
-
this.
|
|
488
|
+
this.showOptions(options, cState.id);
|
|
489
|
+
}
|
|
490
|
+
mount() { this.updateSel(); }
|
|
491
|
+
showOptions(options, id) {
|
|
492
|
+
if (this.list)
|
|
493
|
+
this.list.remove();
|
|
494
|
+
this.list = this.dom.appendChild(this.createListBox(options, id, this.range));
|
|
489
495
|
this.list.addEventListener("scroll", () => {
|
|
490
496
|
if (this.info)
|
|
491
497
|
this.view.requestMeasure(this.placeInfoReq);
|
|
492
498
|
});
|
|
493
499
|
}
|
|
494
|
-
mount() { this.updateSel(); }
|
|
495
500
|
update(update) {
|
|
496
|
-
var _a
|
|
501
|
+
var _a;
|
|
497
502
|
let cState = update.state.field(this.stateField);
|
|
498
503
|
let prevState = update.startState.field(this.stateField);
|
|
499
504
|
this.updateTooltipClass(update.state);
|
|
500
505
|
if (cState != prevState) {
|
|
506
|
+
let { options, selected, disabled } = cState.open;
|
|
507
|
+
if (!prevState.open || prevState.open.options != options) {
|
|
508
|
+
this.range = rangeAroundSelected(options.length, selected, update.state.facet(completionConfig).maxRenderedOptions);
|
|
509
|
+
this.showOptions(options, cState.id);
|
|
510
|
+
}
|
|
501
511
|
this.updateSel();
|
|
502
|
-
if (
|
|
503
|
-
this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!
|
|
512
|
+
if (disabled != ((_a = prevState.open) === null || _a === void 0 ? void 0 : _a.disabled))
|
|
513
|
+
this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!disabled);
|
|
504
514
|
}
|
|
505
515
|
}
|
|
506
516
|
updateTooltipClass(state) {
|
|
@@ -524,12 +534,7 @@ class CompletionTooltip {
|
|
|
524
534
|
let cState = this.view.state.field(this.stateField), open = cState.open;
|
|
525
535
|
if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) {
|
|
526
536
|
this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
|
|
527
|
-
this.
|
|
528
|
-
this.list = this.dom.appendChild(this.createListBox(open.options, cState.id, this.range));
|
|
529
|
-
this.list.addEventListener("scroll", () => {
|
|
530
|
-
if (this.info)
|
|
531
|
-
this.view.requestMeasure(this.placeInfoReq);
|
|
532
|
-
});
|
|
537
|
+
this.showOptions(open.options, cState.id);
|
|
533
538
|
}
|
|
534
539
|
if (this.updateSelectedOption(open.selected)) {
|
|
535
540
|
this.destroyInfo();
|
|
@@ -669,8 +674,6 @@ class CompletionTooltip {
|
|
|
669
674
|
this.destroyInfo();
|
|
670
675
|
}
|
|
671
676
|
}
|
|
672
|
-
// We allocate a new function instance every time the completion
|
|
673
|
-
// changes to force redrawing/repositioning of the tooltip
|
|
674
677
|
function completionTooltip(stateField, applyCompletion) {
|
|
675
678
|
return (view) => new CompletionTooltip(view, stateField, applyCompletion);
|
|
676
679
|
}
|
|
@@ -778,7 +781,7 @@ class CompletionDialog {
|
|
|
778
781
|
}
|
|
779
782
|
return new CompletionDialog(options, makeAttrs(id, selected), {
|
|
780
783
|
pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
|
|
781
|
-
create:
|
|
784
|
+
create: createTooltip,
|
|
782
785
|
above: conf.aboveCursor,
|
|
783
786
|
}, prev ? prev.timestamp : Date.now(), selected, false);
|
|
784
787
|
}
|
|
@@ -954,6 +957,7 @@ function applyCompletion(view, option) {
|
|
|
954
957
|
apply(view, option.completion, result.from, result.to);
|
|
955
958
|
return true;
|
|
956
959
|
}
|
|
960
|
+
const createTooltip = completionTooltip(completionState, applyCompletion);
|
|
957
961
|
|
|
958
962
|
/**
|
|
959
963
|
Returns a command that moves the completion selection forward or
|
|
@@ -1562,7 +1566,7 @@ const snippetPointerHandler = view.EditorView.domEventHandlers({
|
|
|
1562
1566
|
});
|
|
1563
1567
|
|
|
1564
1568
|
function wordRE(wordChars) {
|
|
1565
|
-
let escaped = wordChars.replace(/[
|
|
1569
|
+
let escaped = wordChars.replace(/[\]\-\\]/g, "\\$&");
|
|
1566
1570
|
try {
|
|
1567
1571
|
return new RegExp(`[\\p{Alphabetic}\\p{Number}_${escaped}]+`, "ug");
|
|
1568
1572
|
}
|
package/dist/index.js
CHANGED
|
@@ -483,22 +483,32 @@ class CompletionTooltip {
|
|
|
483
483
|
e.relatedTarget != view.contentDOM)
|
|
484
484
|
view.dispatch({ effects: closeCompletionEffect.of(null) });
|
|
485
485
|
});
|
|
486
|
-
this.
|
|
486
|
+
this.showOptions(options, cState.id);
|
|
487
|
+
}
|
|
488
|
+
mount() { this.updateSel(); }
|
|
489
|
+
showOptions(options, id) {
|
|
490
|
+
if (this.list)
|
|
491
|
+
this.list.remove();
|
|
492
|
+
this.list = this.dom.appendChild(this.createListBox(options, id, this.range));
|
|
487
493
|
this.list.addEventListener("scroll", () => {
|
|
488
494
|
if (this.info)
|
|
489
495
|
this.view.requestMeasure(this.placeInfoReq);
|
|
490
496
|
});
|
|
491
497
|
}
|
|
492
|
-
mount() { this.updateSel(); }
|
|
493
498
|
update(update) {
|
|
494
|
-
var _a
|
|
499
|
+
var _a;
|
|
495
500
|
let cState = update.state.field(this.stateField);
|
|
496
501
|
let prevState = update.startState.field(this.stateField);
|
|
497
502
|
this.updateTooltipClass(update.state);
|
|
498
503
|
if (cState != prevState) {
|
|
504
|
+
let { options, selected, disabled } = cState.open;
|
|
505
|
+
if (!prevState.open || prevState.open.options != options) {
|
|
506
|
+
this.range = rangeAroundSelected(options.length, selected, update.state.facet(completionConfig).maxRenderedOptions);
|
|
507
|
+
this.showOptions(options, cState.id);
|
|
508
|
+
}
|
|
499
509
|
this.updateSel();
|
|
500
|
-
if (
|
|
501
|
-
this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!
|
|
510
|
+
if (disabled != ((_a = prevState.open) === null || _a === void 0 ? void 0 : _a.disabled))
|
|
511
|
+
this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!disabled);
|
|
502
512
|
}
|
|
503
513
|
}
|
|
504
514
|
updateTooltipClass(state) {
|
|
@@ -522,12 +532,7 @@ class CompletionTooltip {
|
|
|
522
532
|
let cState = this.view.state.field(this.stateField), open = cState.open;
|
|
523
533
|
if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) {
|
|
524
534
|
this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
|
|
525
|
-
this.
|
|
526
|
-
this.list = this.dom.appendChild(this.createListBox(open.options, cState.id, this.range));
|
|
527
|
-
this.list.addEventListener("scroll", () => {
|
|
528
|
-
if (this.info)
|
|
529
|
-
this.view.requestMeasure(this.placeInfoReq);
|
|
530
|
-
});
|
|
535
|
+
this.showOptions(open.options, cState.id);
|
|
531
536
|
}
|
|
532
537
|
if (this.updateSelectedOption(open.selected)) {
|
|
533
538
|
this.destroyInfo();
|
|
@@ -667,8 +672,6 @@ class CompletionTooltip {
|
|
|
667
672
|
this.destroyInfo();
|
|
668
673
|
}
|
|
669
674
|
}
|
|
670
|
-
// We allocate a new function instance every time the completion
|
|
671
|
-
// changes to force redrawing/repositioning of the tooltip
|
|
672
675
|
function completionTooltip(stateField, applyCompletion) {
|
|
673
676
|
return (view) => new CompletionTooltip(view, stateField, applyCompletion);
|
|
674
677
|
}
|
|
@@ -776,7 +779,7 @@ class CompletionDialog {
|
|
|
776
779
|
}
|
|
777
780
|
return new CompletionDialog(options, makeAttrs(id, selected), {
|
|
778
781
|
pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
|
|
779
|
-
create:
|
|
782
|
+
create: createTooltip,
|
|
780
783
|
above: conf.aboveCursor,
|
|
781
784
|
}, prev ? prev.timestamp : Date.now(), selected, false);
|
|
782
785
|
}
|
|
@@ -952,6 +955,7 @@ function applyCompletion(view, option) {
|
|
|
952
955
|
apply(view, option.completion, result.from, result.to);
|
|
953
956
|
return true;
|
|
954
957
|
}
|
|
958
|
+
const createTooltip = /*@__PURE__*/completionTooltip(completionState, applyCompletion);
|
|
955
959
|
|
|
956
960
|
/**
|
|
957
961
|
Returns a command that moves the completion selection forward or
|
|
@@ -1560,7 +1564,7 @@ const snippetPointerHandler = /*@__PURE__*/EditorView.domEventHandlers({
|
|
|
1560
1564
|
});
|
|
1561
1565
|
|
|
1562
1566
|
function wordRE(wordChars) {
|
|
1563
|
-
let escaped = wordChars.replace(/[
|
|
1567
|
+
let escaped = wordChars.replace(/[\]\-\\]/g, "\\$&");
|
|
1564
1568
|
try {
|
|
1565
1569
|
return new RegExp(`[\\p{Alphabetic}\\p{Number}_${escaped}]+`, "ug");
|
|
1566
1570
|
}
|