@codemirror/view 6.9.5 → 6.9.6

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,13 @@
1
+ ## 6.9.6 (2023-04-21)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an issue where, when escape was pressed followed by a key that the editor handled, followed by tab, the tab would still move focus.
6
+
7
+ Fix an issue where, in some circumstances, the editor would ignore text changes at the end of a composition.
8
+
9
+ Allow inline widgets to be updated to a different length via `updateDOM`.
10
+
1
11
  ## 6.9.5 (2023-04-17)
2
12
 
3
13
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -856,15 +856,15 @@ class WidgetView extends ContentView {
856
856
  return true;
857
857
  }
858
858
  become(other) {
859
- if (other.length == this.length && other instanceof WidgetView && other.side == this.side) {
860
- if (this.widget.constructor == other.widget.constructor) {
861
- if (!this.widget.compare(other.widget))
862
- this.markDirty(true);
863
- if (this.dom && !this.prevWidget)
864
- this.prevWidget = this.widget;
865
- this.widget = other.widget;
866
- return true;
867
- }
859
+ if (other instanceof WidgetView && other.side == this.side &&
860
+ this.widget.constructor == other.widget.constructor) {
861
+ if (!this.widget.compare(other.widget))
862
+ this.markDirty(true);
863
+ if (this.dom && !this.prevWidget)
864
+ this.prevWidget = this.widget;
865
+ this.widget = other.widget;
866
+ this.length = other.length;
867
+ return true;
868
868
  }
869
869
  return false;
870
870
  }
@@ -3631,6 +3631,8 @@ class InputState {
3631
3631
  this.lastKeyTime = Date.now();
3632
3632
  if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)
3633
3633
  return true;
3634
+ if (event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0)
3635
+ view.inputState.lastEscPress = 0;
3634
3636
  // Chrome for Android usually doesn't fire proper key events, but
3635
3637
  // occasionally does, usually surrounded by a bunch of complicated
3636
3638
  // composition changes. When an enter or backspace key event is
@@ -3900,8 +3902,6 @@ handlers.keydown = (view, event) => {
3900
3902
  view.inputState.setSelectionOrigin("select");
3901
3903
  if (event.keyCode == 27)
3902
3904
  view.inputState.lastEscPress = Date.now();
3903
- else if (modifierCodes.indexOf(event.keyCode) < 0)
3904
- view.inputState.lastEscPress = 0;
3905
3905
  };
3906
3906
  handlers.touchstart = (view, e) => {
3907
3907
  view.inputState.lastTouchTime = Date.now();
@@ -4203,13 +4203,23 @@ handlers.compositionend = view => {
4203
4203
  view.inputState.compositionPendingKey = true;
4204
4204
  view.inputState.compositionPendingChange = view.observer.pendingRecords().length > 0;
4205
4205
  view.inputState.compositionFirstChange = null;
4206
- if (browser.chrome && browser.android)
4206
+ if (browser.chrome && browser.android) {
4207
+ // Delay flushing for a bit on Android because it'll often fire a
4208
+ // bunch of contradictory changes in a row at end of compositon
4207
4209
  view.observer.flushSoon();
4208
- setTimeout(() => {
4209
- // Force the composition state to be cleared if it hasn't already been
4210
- if (view.inputState.composing < 0 && view.docView.compositionDeco.size)
4211
- view.update([]);
4212
- }, 50);
4210
+ }
4211
+ else if (view.inputState.compositionPendingChange) {
4212
+ // If we found pending records, schedule a flush.
4213
+ Promise.resolve().then(() => view.observer.flush());
4214
+ }
4215
+ else {
4216
+ // Otherwise, make sure that, if no changes come in soon, the
4217
+ // composition view is cleared.
4218
+ setTimeout(() => {
4219
+ if (view.inputState.composing < 0 && view.docView.compositionDeco.size)
4220
+ view.update([]);
4221
+ }, 50);
4222
+ }
4213
4223
  };
4214
4224
  handlers.contextmenu = view => {
4215
4225
  view.inputState.lastContextMenu = Date.now();
package/dist/index.js CHANGED
@@ -852,15 +852,15 @@ class WidgetView extends ContentView {
852
852
  return true;
853
853
  }
854
854
  become(other) {
855
- if (other.length == this.length && other instanceof WidgetView && other.side == this.side) {
856
- if (this.widget.constructor == other.widget.constructor) {
857
- if (!this.widget.compare(other.widget))
858
- this.markDirty(true);
859
- if (this.dom && !this.prevWidget)
860
- this.prevWidget = this.widget;
861
- this.widget = other.widget;
862
- return true;
863
- }
855
+ if (other instanceof WidgetView && other.side == this.side &&
856
+ this.widget.constructor == other.widget.constructor) {
857
+ if (!this.widget.compare(other.widget))
858
+ this.markDirty(true);
859
+ if (this.dom && !this.prevWidget)
860
+ this.prevWidget = this.widget;
861
+ this.widget = other.widget;
862
+ this.length = other.length;
863
+ return true;
864
864
  }
865
865
  return false;
866
866
  }
@@ -3625,6 +3625,8 @@ class InputState {
3625
3625
  this.lastKeyTime = Date.now();
3626
3626
  if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)
3627
3627
  return true;
3628
+ if (event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0)
3629
+ view.inputState.lastEscPress = 0;
3628
3630
  // Chrome for Android usually doesn't fire proper key events, but
3629
3631
  // occasionally does, usually surrounded by a bunch of complicated
3630
3632
  // composition changes. When an enter or backspace key event is
@@ -3894,8 +3896,6 @@ handlers.keydown = (view, event) => {
3894
3896
  view.inputState.setSelectionOrigin("select");
3895
3897
  if (event.keyCode == 27)
3896
3898
  view.inputState.lastEscPress = Date.now();
3897
- else if (modifierCodes.indexOf(event.keyCode) < 0)
3898
- view.inputState.lastEscPress = 0;
3899
3899
  };
3900
3900
  handlers.touchstart = (view, e) => {
3901
3901
  view.inputState.lastTouchTime = Date.now();
@@ -4197,13 +4197,23 @@ handlers.compositionend = view => {
4197
4197
  view.inputState.compositionPendingKey = true;
4198
4198
  view.inputState.compositionPendingChange = view.observer.pendingRecords().length > 0;
4199
4199
  view.inputState.compositionFirstChange = null;
4200
- if (browser.chrome && browser.android)
4200
+ if (browser.chrome && browser.android) {
4201
+ // Delay flushing for a bit on Android because it'll often fire a
4202
+ // bunch of contradictory changes in a row at end of compositon
4201
4203
  view.observer.flushSoon();
4202
- setTimeout(() => {
4203
- // Force the composition state to be cleared if it hasn't already been
4204
- if (view.inputState.composing < 0 && view.docView.compositionDeco.size)
4205
- view.update([]);
4206
- }, 50);
4204
+ }
4205
+ else if (view.inputState.compositionPendingChange) {
4206
+ // If we found pending records, schedule a flush.
4207
+ Promise.resolve().then(() => view.observer.flush());
4208
+ }
4209
+ else {
4210
+ // Otherwise, make sure that, if no changes come in soon, the
4211
+ // composition view is cleared.
4212
+ setTimeout(() => {
4213
+ if (view.inputState.composing < 0 && view.docView.compositionDeco.size)
4214
+ view.update([]);
4215
+ }, 50);
4216
+ }
4207
4217
  };
4208
4218
  handlers.contextmenu = view => {
4209
4219
  view.inputState.lastContextMenu = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.9.5",
3
+ "version": "6.9.6",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",