@codemirror/view 6.2.1 → 6.2.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,9 @@
1
+ ## 6.2.2 (2022-08-31)
2
+
3
+ ### Bug fixes
4
+
5
+ Don't reset the selection for selection change events that were suppressed by a node view.
6
+
1
7
  ## 6.2.1 (2022-08-25)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -5562,14 +5562,18 @@ class DOMObserver {
5562
5562
  }
5563
5563
  }
5564
5564
  onSelectionChange(event) {
5565
+ let wasChanged = this.selectionChanged;
5565
5566
  if (!this.readSelectionRange() || this.delayedAndroidKey)
5566
5567
  return;
5567
5568
  let { view } = this, sel = this.selectionRange;
5568
5569
  if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(view.dom, sel))
5569
5570
  return;
5570
5571
  let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
5571
- if (context && context.ignoreEvent(event))
5572
+ if (context && context.ignoreEvent(event)) {
5573
+ if (!wasChanged)
5574
+ this.selectionChanged = false;
5572
5575
  return;
5576
+ }
5573
5577
  // Deletions on IE11 fire their events in the wrong order, giving
5574
5578
  // us a selection change event before the DOM changes are
5575
5579
  // reported.
@@ -6900,6 +6904,11 @@ the editor's vertical layout structure. The ones provided as
6900
6904
  functions are called _after_ the new viewport has been computed,
6901
6905
  and thus **must not** introduce block widgets or replacing
6902
6906
  decorations that cover line breaks.
6907
+
6908
+ If you want decorated ranges to behave like atomic units for
6909
+ cursor motion and deletion purposes, also provide the range set
6910
+ containing the decorations to
6911
+ [`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).
6903
6912
  */
6904
6913
  EditorView.decorations = decorations;
6905
6914
  /**
package/dist/index.d.ts CHANGED
@@ -1054,6 +1054,11 @@ declare class EditorView {
1054
1054
  functions are called _after_ the new viewport has been computed,
1055
1055
  and thus **must not** introduce block widgets or replacing
1056
1056
  decorations that cover line breaks.
1057
+
1058
+ If you want decorated ranges to behave like atomic units for
1059
+ cursor motion and deletion purposes, also provide the range set
1060
+ containing the decorations to
1061
+ [`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).
1057
1062
  */
1058
1063
  static decorations: Facet<DecorationSet | ((view: EditorView) => DecorationSet), readonly (DecorationSet | ((view: EditorView) => DecorationSet))[]>;
1059
1064
  /**
package/dist/index.js CHANGED
@@ -5555,14 +5555,18 @@ class DOMObserver {
5555
5555
  }
5556
5556
  }
5557
5557
  onSelectionChange(event) {
5558
+ let wasChanged = this.selectionChanged;
5558
5559
  if (!this.readSelectionRange() || this.delayedAndroidKey)
5559
5560
  return;
5560
5561
  let { view } = this, sel = this.selectionRange;
5561
5562
  if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(view.dom, sel))
5562
5563
  return;
5563
5564
  let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
5564
- if (context && context.ignoreEvent(event))
5565
+ if (context && context.ignoreEvent(event)) {
5566
+ if (!wasChanged)
5567
+ this.selectionChanged = false;
5565
5568
  return;
5569
+ }
5566
5570
  // Deletions on IE11 fire their events in the wrong order, giving
5567
5571
  // us a selection change event before the DOM changes are
5568
5572
  // reported.
@@ -6893,6 +6897,11 @@ the editor's vertical layout structure. The ones provided as
6893
6897
  functions are called _after_ the new viewport has been computed,
6894
6898
  and thus **must not** introduce block widgets or replacing
6895
6899
  decorations that cover line breaks.
6900
+
6901
+ If you want decorated ranges to behave like atomic units for
6902
+ cursor motion and deletion purposes, also provide the range set
6903
+ containing the decorations to
6904
+ [`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).
6896
6905
  */
6897
6906
  EditorView.decorations = decorations;
6898
6907
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.2.1",
3
+ "version": "6.2.2",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",