@codemirror/view 6.38.1 → 6.38.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.38.2 (2025-09-01)
2
+
3
+ ### Bug fixes
4
+
5
+ Re-enable falling dispatching keys by key code for Cmd-Alt- combinations on macOS.
6
+
7
+ Make sure all pointer selections skip atomic ranges.
8
+
1
9
  ## 6.38.1 (2025-07-15)
2
10
 
3
11
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -3802,6 +3802,29 @@ function skipAtomicRanges(atoms, pos, bias) {
3802
3802
  return pos;
3803
3803
  }
3804
3804
  }
3805
+ function skipAtomsForSelection(atoms, sel) {
3806
+ let ranges = null;
3807
+ for (let i = 0; i < sel.ranges.length; i++) {
3808
+ let range = sel.ranges[i], updated = null;
3809
+ if (range.empty) {
3810
+ let pos = skipAtomicRanges(atoms, range.from, 0);
3811
+ if (pos != range.from)
3812
+ updated = state.EditorSelection.cursor(pos, -1);
3813
+ }
3814
+ else {
3815
+ let from = skipAtomicRanges(atoms, range.from, -1);
3816
+ let to = skipAtomicRanges(atoms, range.to, 1);
3817
+ if (from != range.from || to != range.to)
3818
+ updated = state.EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);
3819
+ }
3820
+ if (updated) {
3821
+ if (!ranges)
3822
+ ranges = sel.ranges.slice();
3823
+ ranges[i] = updated;
3824
+ }
3825
+ }
3826
+ return ranges ? state.EditorSelection.create(ranges, sel.mainIndex) : sel;
3827
+ }
3805
3828
  function skipAtoms(view, oldPos, pos) {
3806
3829
  let newPos = skipAtomicRanges(view.state.facet(atomicRanges).map(f => f(view)), pos.from, oldPos.head > pos.from ? -1 : 1);
3807
3830
  return newPos == pos.from ? pos : state.EditorSelection.cursor(newPos, newPos < pos.from ? 1 : -1);
@@ -4037,6 +4060,8 @@ function applyDOMChange(view, domChange) {
4037
4060
  if (view.inputState.lastSelectionOrigin == "select")
4038
4061
  scrollIntoView = true;
4039
4062
  userEvent = view.inputState.lastSelectionOrigin;
4063
+ if (userEvent == "select.pointer")
4064
+ newSel = skipAtomsForSelection(view.state.facet(atomicRanges).map(f => f(view)), newSel);
4040
4065
  }
4041
4066
  view.dispatch({ selection: newSel, scrollIntoView, userEvent });
4042
4067
  return true;
@@ -4514,31 +4539,8 @@ class MouseSelection {
4514
4539
  if (this.dragging === false)
4515
4540
  this.select(this.lastEvent);
4516
4541
  }
4517
- skipAtoms(sel) {
4518
- let ranges = null;
4519
- for (let i = 0; i < sel.ranges.length; i++) {
4520
- let range = sel.ranges[i], updated = null;
4521
- if (range.empty) {
4522
- let pos = skipAtomicRanges(this.atoms, range.from, 0);
4523
- if (pos != range.from)
4524
- updated = state.EditorSelection.cursor(pos, -1);
4525
- }
4526
- else {
4527
- let from = skipAtomicRanges(this.atoms, range.from, -1);
4528
- let to = skipAtomicRanges(this.atoms, range.to, 1);
4529
- if (from != range.from || to != range.to)
4530
- updated = state.EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);
4531
- }
4532
- if (updated) {
4533
- if (!ranges)
4534
- ranges = sel.ranges.slice();
4535
- ranges[i] = updated;
4536
- }
4537
- }
4538
- return ranges ? state.EditorSelection.create(ranges, sel.mainIndex) : sel;
4539
- }
4540
4542
  select(event) {
4541
- let { view } = this, selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));
4543
+ let { view } = this, selection = skipAtomsForSelection(this.atoms, this.style.get(event, this.extend, this.multiple));
4542
4544
  if (this.mustSelect || !selection.eq(view.state.selection, this.dragging === false))
4543
4545
  this.view.dispatch({
4544
4546
  selection,
@@ -4691,6 +4693,9 @@ handlers.mousedown = (view, event) => {
4691
4693
  return mouseSel.dragging === false;
4692
4694
  }
4693
4695
  }
4696
+ else {
4697
+ view.inputState.setSelectionOrigin("select.pointer");
4698
+ }
4694
4699
  return false;
4695
4700
  };
4696
4701
  function rangeForClick(view, pos, bias, type) {
@@ -8016,7 +8021,7 @@ class EditorView {
8016
8021
  }
8017
8022
  /**
8018
8023
  Find the line block (see
8019
- [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
8024
+ [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt)) at the given
8020
8025
  height, again interpreted relative to the [top of the
8021
8026
  document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
8022
8027
  */
@@ -8803,7 +8808,7 @@ function runHandlers(map, event, view, scope) {
8803
8808
  // Ctrl-Alt may be used for AltGr on Windows
8804
8809
  !(browser.windows && event.ctrlKey && event.altKey) &&
8805
8810
  // Alt-combinations on macOS tend to be typed characters
8806
- !(browser.mac && event.altKey && !event.ctrlKey) &&
8811
+ !(browser.mac && event.altKey && !(event.ctrlKey || event.metaKey)) &&
8807
8812
  (baseName = w3cKeyname.base[event.keyCode]) && baseName != name) {
8808
8813
  if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {
8809
8814
  handled = true;
package/dist/index.d.cts CHANGED
@@ -871,7 +871,7 @@ declare class EditorView {
871
871
  elementAtHeight(height: number): BlockInfo;
872
872
  /**
873
873
  Find the line block (see
874
- [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
874
+ [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt)) at the given
875
875
  height, again interpreted relative to the [top of the
876
876
  document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
877
877
  */
package/dist/index.d.ts CHANGED
@@ -871,7 +871,7 @@ declare class EditorView {
871
871
  elementAtHeight(height: number): BlockInfo;
872
872
  /**
873
873
  Find the line block (see
874
- [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
874
+ [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt)) at the given
875
875
  height, again interpreted relative to the [top of the
876
876
  document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
877
877
  */
package/dist/index.js CHANGED
@@ -3798,6 +3798,29 @@ function skipAtomicRanges(atoms, pos, bias) {
3798
3798
  return pos;
3799
3799
  }
3800
3800
  }
3801
+ function skipAtomsForSelection(atoms, sel) {
3802
+ let ranges = null;
3803
+ for (let i = 0; i < sel.ranges.length; i++) {
3804
+ let range = sel.ranges[i], updated = null;
3805
+ if (range.empty) {
3806
+ let pos = skipAtomicRanges(atoms, range.from, 0);
3807
+ if (pos != range.from)
3808
+ updated = EditorSelection.cursor(pos, -1);
3809
+ }
3810
+ else {
3811
+ let from = skipAtomicRanges(atoms, range.from, -1);
3812
+ let to = skipAtomicRanges(atoms, range.to, 1);
3813
+ if (from != range.from || to != range.to)
3814
+ updated = EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);
3815
+ }
3816
+ if (updated) {
3817
+ if (!ranges)
3818
+ ranges = sel.ranges.slice();
3819
+ ranges[i] = updated;
3820
+ }
3821
+ }
3822
+ return ranges ? EditorSelection.create(ranges, sel.mainIndex) : sel;
3823
+ }
3801
3824
  function skipAtoms(view, oldPos, pos) {
3802
3825
  let newPos = skipAtomicRanges(view.state.facet(atomicRanges).map(f => f(view)), pos.from, oldPos.head > pos.from ? -1 : 1);
3803
3826
  return newPos == pos.from ? pos : EditorSelection.cursor(newPos, newPos < pos.from ? 1 : -1);
@@ -4033,6 +4056,8 @@ function applyDOMChange(view, domChange) {
4033
4056
  if (view.inputState.lastSelectionOrigin == "select")
4034
4057
  scrollIntoView = true;
4035
4058
  userEvent = view.inputState.lastSelectionOrigin;
4059
+ if (userEvent == "select.pointer")
4060
+ newSel = skipAtomsForSelection(view.state.facet(atomicRanges).map(f => f(view)), newSel);
4036
4061
  }
4037
4062
  view.dispatch({ selection: newSel, scrollIntoView, userEvent });
4038
4063
  return true;
@@ -4510,31 +4535,8 @@ class MouseSelection {
4510
4535
  if (this.dragging === false)
4511
4536
  this.select(this.lastEvent);
4512
4537
  }
4513
- skipAtoms(sel) {
4514
- let ranges = null;
4515
- for (let i = 0; i < sel.ranges.length; i++) {
4516
- let range = sel.ranges[i], updated = null;
4517
- if (range.empty) {
4518
- let pos = skipAtomicRanges(this.atoms, range.from, 0);
4519
- if (pos != range.from)
4520
- updated = EditorSelection.cursor(pos, -1);
4521
- }
4522
- else {
4523
- let from = skipAtomicRanges(this.atoms, range.from, -1);
4524
- let to = skipAtomicRanges(this.atoms, range.to, 1);
4525
- if (from != range.from || to != range.to)
4526
- updated = EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);
4527
- }
4528
- if (updated) {
4529
- if (!ranges)
4530
- ranges = sel.ranges.slice();
4531
- ranges[i] = updated;
4532
- }
4533
- }
4534
- return ranges ? EditorSelection.create(ranges, sel.mainIndex) : sel;
4535
- }
4536
4538
  select(event) {
4537
- let { view } = this, selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));
4539
+ let { view } = this, selection = skipAtomsForSelection(this.atoms, this.style.get(event, this.extend, this.multiple));
4538
4540
  if (this.mustSelect || !selection.eq(view.state.selection, this.dragging === false))
4539
4541
  this.view.dispatch({
4540
4542
  selection,
@@ -4687,6 +4689,9 @@ handlers.mousedown = (view, event) => {
4687
4689
  return mouseSel.dragging === false;
4688
4690
  }
4689
4691
  }
4692
+ else {
4693
+ view.inputState.setSelectionOrigin("select.pointer");
4694
+ }
4690
4695
  return false;
4691
4696
  };
4692
4697
  function rangeForClick(view, pos, bias, type) {
@@ -8011,7 +8016,7 @@ class EditorView {
8011
8016
  }
8012
8017
  /**
8013
8018
  Find the line block (see
8014
- [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
8019
+ [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt)) at the given
8015
8020
  height, again interpreted relative to the [top of the
8016
8021
  document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
8017
8022
  */
@@ -8798,7 +8803,7 @@ function runHandlers(map, event, view, scope) {
8798
8803
  // Ctrl-Alt may be used for AltGr on Windows
8799
8804
  !(browser.windows && event.ctrlKey && event.altKey) &&
8800
8805
  // Alt-combinations on macOS tend to be typed characters
8801
- !(browser.mac && event.altKey && !event.ctrlKey) &&
8806
+ !(browser.mac && event.altKey && !(event.ctrlKey || event.metaKey)) &&
8802
8807
  (baseName = base[event.keyCode]) && baseName != name) {
8803
8808
  if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {
8804
8809
  handled = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.38.1",
3
+ "version": "6.38.2",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",