@codemirror/state 6.3.1 → 6.3.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 CHANGED
@@ -1,3 +1,11 @@
1
+ ## 6.3.2 (2023-11-27)
2
+
3
+ ### Bug fixes
4
+
5
+ Make sure transactions cannot add multiple selections when `allowMultipleSelections` is false.
6
+
7
+ Fix a bug that caused `Text.iterLines` to not return empty lines at the end of the iterated ranges.
8
+
1
9
  ## 6.3.1 (2023-10-18)
2
10
 
3
11
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -485,7 +485,11 @@ class LineCursor {
485
485
  }
486
486
  next(skip = 0) {
487
487
  let { done, lineBreak, value } = this.inner.next(skip);
488
- if (done) {
488
+ if (done && this.afterBreak) {
489
+ this.value = "";
490
+ this.afterBreak = false;
491
+ }
492
+ else if (done) {
489
493
  this.done = true;
490
494
  this.value = "";
491
495
  }
@@ -2643,7 +2647,8 @@ class EditorState {
2643
2647
  else {
2644
2648
  startValues = tr.startState.values.slice();
2645
2649
  }
2646
- new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
2650
+ let selection = tr.startState.facet(allowMultipleSelections) ? tr.newSelection : tr.newSelection.asSingle();
2651
+ new EditorState(conf, tr.newDoc, selection, startValues, (state, slot) => slot.update(state, tr), tr);
2647
2652
  }
2648
2653
  /**
2649
2654
  Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
package/dist/index.d.cts CHANGED
@@ -574,7 +574,7 @@ declare class Facet<Input, Output = readonly Input[]> implements FacetReader<Out
574
574
  tag: Output;
575
575
  }
576
576
  /**
577
- A facet reader can be used to fetch the value of a facet, though
577
+ A facet reader can be used to fetch the value of a facet, through
578
578
  [`EditorState.facet`](https://codemirror.net/6/docs/ref/#state.EditorState.facet) or as a dependency
579
579
  in [`Facet.compute`](https://codemirror.net/6/docs/ref/#state.Facet.compute), but not to define new
580
580
  values for the facet.
package/dist/index.d.ts CHANGED
@@ -574,7 +574,7 @@ declare class Facet<Input, Output = readonly Input[]> implements FacetReader<Out
574
574
  tag: Output;
575
575
  }
576
576
  /**
577
- A facet reader can be used to fetch the value of a facet, though
577
+ A facet reader can be used to fetch the value of a facet, through
578
578
  [`EditorState.facet`](https://codemirror.net/6/docs/ref/#state.EditorState.facet) or as a dependency
579
579
  in [`Facet.compute`](https://codemirror.net/6/docs/ref/#state.Facet.compute), but not to define new
580
580
  values for the facet.
package/dist/index.js CHANGED
@@ -483,7 +483,11 @@ class LineCursor {
483
483
  }
484
484
  next(skip = 0) {
485
485
  let { done, lineBreak, value } = this.inner.next(skip);
486
- if (done) {
486
+ if (done && this.afterBreak) {
487
+ this.value = "";
488
+ this.afterBreak = false;
489
+ }
490
+ else if (done) {
487
491
  this.done = true;
488
492
  this.value = "";
489
493
  }
@@ -2639,7 +2643,8 @@ class EditorState {
2639
2643
  else {
2640
2644
  startValues = tr.startState.values.slice();
2641
2645
  }
2642
- new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
2646
+ let selection = tr.startState.facet(allowMultipleSelections) ? tr.newSelection : tr.newSelection.asSingle();
2647
+ new EditorState(conf, tr.newDoc, selection, startValues, (state, slot) => slot.update(state, tr), tr);
2643
2648
  }
2644
2649
  /**
2645
2650
  Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/state",
3
- "version": "6.3.1",
3
+ "version": "6.3.2",
4
4
  "description": "Editor state data structures for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",