@codemirror/autocomplete 6.16.1 → 6.16.3

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 CHANGED
@@ -1,3 +1,15 @@
1
+ ## 6.16.3 (2024-06-19)
2
+
3
+ ### Bug fixes
4
+
5
+ Avoid adding an `aria-autocomplete` attribute to the editor when there are no active sources active.
6
+
7
+ ## 6.16.2 (2024-05-31)
8
+
9
+ ### Bug fixes
10
+
11
+ Allow backslash-escaped closing braces inside snippet field names/content.
12
+
1
13
  ## 6.16.1 (2024-05-29)
2
14
 
3
15
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -852,7 +852,7 @@ class CompletionState {
852
852
  return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open);
853
853
  }
854
854
  get tooltip() { return this.open ? this.open.tooltip : null; }
855
- get attrs() { return this.open ? this.open.attrs : baseAttrs; }
855
+ get attrs() { return this.open ? this.open.attrs : this.active.length ? baseAttrs : noAttrs; }
856
856
  }
857
857
  function sameResults(a, b) {
858
858
  if (a == b)
@@ -872,6 +872,7 @@ function sameResults(a, b) {
872
872
  const baseAttrs = {
873
873
  "aria-autocomplete": "list"
874
874
  };
875
+ const noAttrs = {};
875
876
  function makeAttrs(id, selected) {
876
877
  let result = {
877
878
  "aria-autocomplete": "list",
@@ -1401,8 +1402,9 @@ class Snippet {
1401
1402
  let fields = [];
1402
1403
  let lines = [], positions = [], m;
1403
1404
  for (let line of template.split(/\r\n?|\n/)) {
1404
- while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(line)) {
1405
- let seq = m[1] ? +m[1] : null, name = m[2] || m[3] || "", found = -1;
1405
+ while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(line)) {
1406
+ let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
1407
+ let name = rawName.replace(/\\[{}]/g, m => m[1]);
1406
1408
  for (let i = 0; i < fields.length; i++) {
1407
1409
  if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
1408
1410
  found = i;
@@ -1418,7 +1420,7 @@ class Snippet {
1418
1420
  pos.field++;
1419
1421
  }
1420
1422
  positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
1421
- line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
1423
+ line = line.slice(0, m.index) + rawName + line.slice(m.index + m[0].length);
1422
1424
  }
1423
1425
  line = line.replace(/\\([{}])/g, (_, brace, index) => {
1424
1426
  for (let pos of positions)
package/dist/index.js CHANGED
@@ -850,7 +850,7 @@ class CompletionState {
850
850
  return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open);
851
851
  }
852
852
  get tooltip() { return this.open ? this.open.tooltip : null; }
853
- get attrs() { return this.open ? this.open.attrs : baseAttrs; }
853
+ get attrs() { return this.open ? this.open.attrs : this.active.length ? baseAttrs : noAttrs; }
854
854
  }
855
855
  function sameResults(a, b) {
856
856
  if (a == b)
@@ -870,6 +870,7 @@ function sameResults(a, b) {
870
870
  const baseAttrs = {
871
871
  "aria-autocomplete": "list"
872
872
  };
873
+ const noAttrs = {};
873
874
  function makeAttrs(id, selected) {
874
875
  let result = {
875
876
  "aria-autocomplete": "list",
@@ -1399,8 +1400,9 @@ class Snippet {
1399
1400
  let fields = [];
1400
1401
  let lines = [], positions = [], m;
1401
1402
  for (let line of template.split(/\r\n?|\n/)) {
1402
- while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(line)) {
1403
- let seq = m[1] ? +m[1] : null, name = m[2] || m[3] || "", found = -1;
1403
+ while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(line)) {
1404
+ let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
1405
+ let name = rawName.replace(/\\[{}]/g, m => m[1]);
1404
1406
  for (let i = 0; i < fields.length; i++) {
1405
1407
  if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
1406
1408
  found = i;
@@ -1416,7 +1418,7 @@ class Snippet {
1416
1418
  pos.field++;
1417
1419
  }
1418
1420
  positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
1419
- line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
1421
+ line = line.slice(0, m.index) + rawName + line.slice(m.index + m[0].length);
1420
1422
  }
1421
1423
  line = line.replace(/\\([{}])/g, (_, brace, index) => {
1422
1424
  for (let pos of positions)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/autocomplete",
3
- "version": "6.16.1",
3
+ "version": "6.16.3",
4
4
  "description": "Autocompletion for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",