@codemirror/autocomplete 6.18.7 → 6.19.1
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 +12 -0
- package/dist/index.cjs +21 -5
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +21 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 6.19.1 (2025-10-23)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Make sure a completion's info panel is associated with that completion in the accessibility tree.
|
|
6
|
+
|
|
7
|
+
## 6.19.0 (2025-09-26)
|
|
8
|
+
|
|
9
|
+
### New features
|
|
10
|
+
|
|
11
|
+
Completion sections may now set their rank to `dynamic` to indicate their order should be determined by the matching score of their best-matching option.
|
|
12
|
+
|
|
1
13
|
## 6.18.7 (2025-09-02)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -590,7 +590,8 @@ class CompletionTooltip {
|
|
|
590
590
|
this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
|
|
591
591
|
this.showOptions(open.options, cState.id);
|
|
592
592
|
}
|
|
593
|
-
|
|
593
|
+
let newSel = this.updateSelectedOption(open.selected);
|
|
594
|
+
if (newSel) {
|
|
594
595
|
this.destroyInfo();
|
|
595
596
|
let { completion } = open.options[open.selected];
|
|
596
597
|
let { info } = completion;
|
|
@@ -607,6 +608,7 @@ class CompletionTooltip {
|
|
|
607
608
|
}
|
|
608
609
|
else {
|
|
609
610
|
this.addInfoPane(infoResult, completion);
|
|
611
|
+
newSel.setAttribute("aria-describedby", this.info.id);
|
|
610
612
|
}
|
|
611
613
|
}
|
|
612
614
|
}
|
|
@@ -614,6 +616,7 @@ class CompletionTooltip {
|
|
|
614
616
|
this.destroyInfo();
|
|
615
617
|
let wrap = this.info = document.createElement("div");
|
|
616
618
|
wrap.className = "cm-tooltip cm-completionInfo";
|
|
619
|
+
wrap.id = "cm-completionInfo-" + Math.floor(Math.random() * 0xffff).toString(16);
|
|
617
620
|
if (content.nodeType != null) {
|
|
618
621
|
wrap.appendChild(content);
|
|
619
622
|
this.infoDestroy = null;
|
|
@@ -639,8 +642,10 @@ class CompletionTooltip {
|
|
|
639
642
|
}
|
|
640
643
|
}
|
|
641
644
|
else {
|
|
642
|
-
if (opt.hasAttribute("aria-selected"))
|
|
645
|
+
if (opt.hasAttribute("aria-selected")) {
|
|
643
646
|
opt.removeAttribute("aria-selected");
|
|
647
|
+
opt.removeAttribute("aria-describedby");
|
|
648
|
+
}
|
|
644
649
|
}
|
|
645
650
|
}
|
|
646
651
|
if (set)
|
|
@@ -754,7 +759,7 @@ function score(option) {
|
|
|
754
759
|
}
|
|
755
760
|
function sortOptions(active, state) {
|
|
756
761
|
let options = [];
|
|
757
|
-
let sections = null;
|
|
762
|
+
let sections = null, dynamicSectionScore = null;
|
|
758
763
|
let addOption = (option) => {
|
|
759
764
|
options.push(option);
|
|
760
765
|
let { section } = option.completion;
|
|
@@ -781,13 +786,24 @@ function sortOptions(active, state) {
|
|
|
781
786
|
for (let option of a.result.options)
|
|
782
787
|
if (match = matcher.match(option.label)) {
|
|
783
788
|
let matched = !option.displayLabel ? match.matched : getMatch ? getMatch(option, match.matched) : [];
|
|
784
|
-
|
|
789
|
+
let score = match.score + (option.boost || 0);
|
|
790
|
+
addOption(new Option(option, a.source, matched, score));
|
|
791
|
+
if (typeof option.section == "object" && option.section.rank === "dynamic") {
|
|
792
|
+
let { name } = option.section;
|
|
793
|
+
if (!dynamicSectionScore)
|
|
794
|
+
dynamicSectionScore = Object.create(null);
|
|
795
|
+
dynamicSectionScore[name] = Math.max(score, dynamicSectionScore[name] || -1e9);
|
|
796
|
+
}
|
|
785
797
|
}
|
|
786
798
|
}
|
|
787
799
|
}
|
|
788
800
|
if (sections) {
|
|
789
801
|
let sectionOrder = Object.create(null), pos = 0;
|
|
790
|
-
let cmp = (a, b) => {
|
|
802
|
+
let cmp = (a, b) => {
|
|
803
|
+
return (a.rank === "dynamic" && b.rank === "dynamic" ? dynamicSectionScore[b.name] - dynamicSectionScore[a.name] : 0) ||
|
|
804
|
+
(typeof a.rank == "number" ? a.rank : 1e9) - (typeof b.rank == "number" ? b.rank : 1e9) ||
|
|
805
|
+
(a.name < b.name ? -1 : 1);
|
|
806
|
+
};
|
|
791
807
|
for (let s of sections.sort(cmp)) {
|
|
792
808
|
pos -= 1e5;
|
|
793
809
|
sectionOrder[s.name] = pos;
|
package/dist/index.d.cts
CHANGED
|
@@ -106,8 +106,12 @@ interface CompletionSection {
|
|
|
106
106
|
By default, sections are ordered alphabetically by name. To
|
|
107
107
|
specify an explicit order, `rank` can be used. Sections with a
|
|
108
108
|
lower rank will be shown above sections with a higher rank.
|
|
109
|
+
|
|
110
|
+
When set to `"dynamic"`, the section's position compared to
|
|
111
|
+
other dynamic sections depends on the matching score of the
|
|
112
|
+
best-matching option in the sections.
|
|
109
113
|
*/
|
|
110
|
-
rank?: number;
|
|
114
|
+
rank?: number | "dynamic";
|
|
111
115
|
}
|
|
112
116
|
/**
|
|
113
117
|
An instance of this is passed to completion source functions.
|
package/dist/index.d.ts
CHANGED
|
@@ -106,8 +106,12 @@ interface CompletionSection {
|
|
|
106
106
|
By default, sections are ordered alphabetically by name. To
|
|
107
107
|
specify an explicit order, `rank` can be used. Sections with a
|
|
108
108
|
lower rank will be shown above sections with a higher rank.
|
|
109
|
+
|
|
110
|
+
When set to `"dynamic"`, the section's position compared to
|
|
111
|
+
other dynamic sections depends on the matching score of the
|
|
112
|
+
best-matching option in the sections.
|
|
109
113
|
*/
|
|
110
|
-
rank?: number;
|
|
114
|
+
rank?: number | "dynamic";
|
|
111
115
|
}
|
|
112
116
|
/**
|
|
113
117
|
An instance of this is passed to completion source functions.
|
package/dist/index.js
CHANGED
|
@@ -588,7 +588,8 @@ class CompletionTooltip {
|
|
|
588
588
|
this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
|
|
589
589
|
this.showOptions(open.options, cState.id);
|
|
590
590
|
}
|
|
591
|
-
|
|
591
|
+
let newSel = this.updateSelectedOption(open.selected);
|
|
592
|
+
if (newSel) {
|
|
592
593
|
this.destroyInfo();
|
|
593
594
|
let { completion } = open.options[open.selected];
|
|
594
595
|
let { info } = completion;
|
|
@@ -605,6 +606,7 @@ class CompletionTooltip {
|
|
|
605
606
|
}
|
|
606
607
|
else {
|
|
607
608
|
this.addInfoPane(infoResult, completion);
|
|
609
|
+
newSel.setAttribute("aria-describedby", this.info.id);
|
|
608
610
|
}
|
|
609
611
|
}
|
|
610
612
|
}
|
|
@@ -612,6 +614,7 @@ class CompletionTooltip {
|
|
|
612
614
|
this.destroyInfo();
|
|
613
615
|
let wrap = this.info = document.createElement("div");
|
|
614
616
|
wrap.className = "cm-tooltip cm-completionInfo";
|
|
617
|
+
wrap.id = "cm-completionInfo-" + Math.floor(Math.random() * 0xffff).toString(16);
|
|
615
618
|
if (content.nodeType != null) {
|
|
616
619
|
wrap.appendChild(content);
|
|
617
620
|
this.infoDestroy = null;
|
|
@@ -637,8 +640,10 @@ class CompletionTooltip {
|
|
|
637
640
|
}
|
|
638
641
|
}
|
|
639
642
|
else {
|
|
640
|
-
if (opt.hasAttribute("aria-selected"))
|
|
643
|
+
if (opt.hasAttribute("aria-selected")) {
|
|
641
644
|
opt.removeAttribute("aria-selected");
|
|
645
|
+
opt.removeAttribute("aria-describedby");
|
|
646
|
+
}
|
|
642
647
|
}
|
|
643
648
|
}
|
|
644
649
|
if (set)
|
|
@@ -752,7 +757,7 @@ function score(option) {
|
|
|
752
757
|
}
|
|
753
758
|
function sortOptions(active, state) {
|
|
754
759
|
let options = [];
|
|
755
|
-
let sections = null;
|
|
760
|
+
let sections = null, dynamicSectionScore = null;
|
|
756
761
|
let addOption = (option) => {
|
|
757
762
|
options.push(option);
|
|
758
763
|
let { section } = option.completion;
|
|
@@ -779,13 +784,24 @@ function sortOptions(active, state) {
|
|
|
779
784
|
for (let option of a.result.options)
|
|
780
785
|
if (match = matcher.match(option.label)) {
|
|
781
786
|
let matched = !option.displayLabel ? match.matched : getMatch ? getMatch(option, match.matched) : [];
|
|
782
|
-
|
|
787
|
+
let score = match.score + (option.boost || 0);
|
|
788
|
+
addOption(new Option(option, a.source, matched, score));
|
|
789
|
+
if (typeof option.section == "object" && option.section.rank === "dynamic") {
|
|
790
|
+
let { name } = option.section;
|
|
791
|
+
if (!dynamicSectionScore)
|
|
792
|
+
dynamicSectionScore = Object.create(null);
|
|
793
|
+
dynamicSectionScore[name] = Math.max(score, dynamicSectionScore[name] || -1e9);
|
|
794
|
+
}
|
|
783
795
|
}
|
|
784
796
|
}
|
|
785
797
|
}
|
|
786
798
|
if (sections) {
|
|
787
799
|
let sectionOrder = Object.create(null), pos = 0;
|
|
788
|
-
let cmp = (a, b) => {
|
|
800
|
+
let cmp = (a, b) => {
|
|
801
|
+
return (a.rank === "dynamic" && b.rank === "dynamic" ? dynamicSectionScore[b.name] - dynamicSectionScore[a.name] : 0) ||
|
|
802
|
+
(typeof a.rank == "number" ? a.rank : 1e9) - (typeof b.rank == "number" ? b.rank : 1e9) ||
|
|
803
|
+
(a.name < b.name ? -1 : 1);
|
|
804
|
+
};
|
|
789
805
|
for (let s of sections.sort(cmp)) {
|
|
790
806
|
pos -= 1e5;
|
|
791
807
|
sectionOrder[s.name] = pos;
|