@codemirror/view 6.1.3 → 6.1.4

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.1.4 (2022-08-04)
2
+
3
+ ### Bug fixes
4
+
5
+ Make selection-restoration on focus more reliable.
6
+
1
7
  ## 6.1.3 (2022-08-03)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -5579,10 +5579,11 @@ class DOMObserver {
5579
5579
  // Detect the situation where the browser has, on focus, moved the
5580
5580
  // selection to the start of the content element. Reset it to the
5581
5581
  // position from the editor state.
5582
- if (local && !this.selectionChanged && this.selectionRange.focusNode &&
5582
+ if (local && !this.selectionChanged &&
5583
5583
  view.inputState.lastFocusTime > Date.now() - 200 &&
5584
5584
  view.inputState.lastTouchTime < Date.now() - 300 &&
5585
5585
  atElementStart(this.dom, range)) {
5586
+ this.view.inputState.lastFocusTime = 0;
5586
5587
  view.docView.updateSelection();
5587
5588
  return false;
5588
5589
  }
@@ -5730,7 +5731,6 @@ class DOMObserver {
5730
5731
  let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
5731
5732
  if (from < 0 && !newSel)
5732
5733
  return;
5733
- this.view.inputState.lastFocusTime = 0;
5734
5734
  this.selectionChanged = false;
5735
5735
  let startState = this.view.state;
5736
5736
  let handled = this.onChange(from, to, typeOver);
package/dist/index.js CHANGED
@@ -5572,10 +5572,11 @@ class DOMObserver {
5572
5572
  // Detect the situation where the browser has, on focus, moved the
5573
5573
  // selection to the start of the content element. Reset it to the
5574
5574
  // position from the editor state.
5575
- if (local && !this.selectionChanged && this.selectionRange.focusNode &&
5575
+ if (local && !this.selectionChanged &&
5576
5576
  view.inputState.lastFocusTime > Date.now() - 200 &&
5577
5577
  view.inputState.lastTouchTime < Date.now() - 300 &&
5578
5578
  atElementStart(this.dom, range)) {
5579
+ this.view.inputState.lastFocusTime = 0;
5579
5580
  view.docView.updateSelection();
5580
5581
  return false;
5581
5582
  }
@@ -5723,7 +5724,6 @@ class DOMObserver {
5723
5724
  let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
5724
5725
  if (from < 0 && !newSel)
5725
5726
  return;
5726
- this.view.inputState.lastFocusTime = 0;
5727
5727
  this.selectionChanged = false;
5728
5728
  let startState = this.view.state;
5729
5729
  let handled = this.onChange(from, to, typeOver);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.1.3",
3
+ "version": "6.1.4",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",