@codemirror/view 6.28.0 → 6.28.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,21 @@
1
+ ## 6.28.2 (2024-06-21)
2
+
3
+ ### Bug fixes
4
+
5
+ Only use `EditContext` on Chrome versions that support passing it an inverted selection range.
6
+
7
+ Fix an issue that prevented non-inclusive block widgets from having their `updateDOM` method called when changed.
8
+
9
+ Re-enable `EditContext` use on Chrome 126 and up.
10
+
11
+ ## 6.28.1 (2024-06-12)
12
+
13
+ ### Bug fixes
14
+
15
+ Disable `EditContext` by default again, to work around a regression where Chrome's implementation doesn't support inverted selections.
16
+
17
+ Make sure `EditorView.editable` is respected when `EditContext` is used.
18
+
1
19
  ## 6.28.0 (2024-06-10)
2
20
 
3
21
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -1297,7 +1297,10 @@ class LineView extends ContentView {
1297
1297
  }
1298
1298
  return rect;
1299
1299
  }
1300
- become(_other) { return false; }
1300
+ become(other) {
1301
+ return other instanceof LineView && this.children.length == 0 && other.children.length == 0 &&
1302
+ attrsEq(this.attrs, other.attrs) && this.breakAfter == other.breakAfter;
1303
+ }
1301
1304
  covers() { return true; }
1302
1305
  static find(docView, pos) {
1303
1306
  for (let i = 0, off = 0; i < docView.children.length; i++) {
@@ -6639,9 +6642,12 @@ class DOMObserver {
6639
6642
  else
6640
6643
  this.flush();
6641
6644
  });
6642
- if (window.EditContext && view.constructor.EDIT_CONTEXT !== false) {
6645
+ if (window.EditContext && view.constructor.EDIT_CONTEXT !== false &&
6646
+ // Chrome <126 doesn't support inverted selections in edit context (#1392)
6647
+ !(browser.chrome && browser.chrome_version < 126)) {
6643
6648
  this.editContext = new EditContextManager(view);
6644
- view.contentDOM.editContext = this.editContext.editContext;
6649
+ if (view.state.facet(editable))
6650
+ view.contentDOM.editContext = this.editContext.editContext;
6645
6651
  }
6646
6652
  if (useCharData)
6647
6653
  this.onCharData = (event) => {
@@ -7005,8 +7011,11 @@ class DOMObserver {
7005
7011
  win.document.removeEventListener("selectionchange", this.onSelectionChange);
7006
7012
  }
7007
7013
  update(update) {
7008
- if (this.editContext)
7014
+ if (this.editContext) {
7009
7015
  this.editContext.update(update);
7016
+ if (update.startState.facet(editable) != update.state.facet(editable))
7017
+ update.view.contentDOM.editContext = update.state.facet(editable) ? this.editContext.editContext : null;
7018
+ }
7010
7019
  }
7011
7020
  destroy() {
7012
7021
  var _a, _b, _c;
package/dist/index.js CHANGED
@@ -1295,7 +1295,10 @@ class LineView extends ContentView {
1295
1295
  }
1296
1296
  return rect;
1297
1297
  }
1298
- become(_other) { return false; }
1298
+ become(other) {
1299
+ return other instanceof LineView && this.children.length == 0 && other.children.length == 0 &&
1300
+ attrsEq(this.attrs, other.attrs) && this.breakAfter == other.breakAfter;
1301
+ }
1299
1302
  covers() { return true; }
1300
1303
  static find(docView, pos) {
1301
1304
  for (let i = 0, off = 0; i < docView.children.length; i++) {
@@ -6634,9 +6637,12 @@ class DOMObserver {
6634
6637
  else
6635
6638
  this.flush();
6636
6639
  });
6637
- if (window.EditContext && view.constructor.EDIT_CONTEXT !== false) {
6640
+ if (window.EditContext && view.constructor.EDIT_CONTEXT !== false &&
6641
+ // Chrome <126 doesn't support inverted selections in edit context (#1392)
6642
+ !(browser.chrome && browser.chrome_version < 126)) {
6638
6643
  this.editContext = new EditContextManager(view);
6639
- view.contentDOM.editContext = this.editContext.editContext;
6644
+ if (view.state.facet(editable))
6645
+ view.contentDOM.editContext = this.editContext.editContext;
6640
6646
  }
6641
6647
  if (useCharData)
6642
6648
  this.onCharData = (event) => {
@@ -7000,8 +7006,11 @@ class DOMObserver {
7000
7006
  win.document.removeEventListener("selectionchange", this.onSelectionChange);
7001
7007
  }
7002
7008
  update(update) {
7003
- if (this.editContext)
7009
+ if (this.editContext) {
7004
7010
  this.editContext.update(update);
7011
+ if (update.startState.facet(editable) != update.state.facet(editable))
7012
+ update.view.contentDOM.editContext = update.state.facet(editable) ? this.editContext.editContext : null;
7013
+ }
7005
7014
  }
7006
7015
  destroy() {
7007
7016
  var _a, _b, _c;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.28.0",
3
+ "version": "6.28.2",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",