@codemirror/view 6.38.0 → 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 +16 -0
- package/dist/index.cjs +34 -27
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -27
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
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
|
+
|
|
9
|
+
## 6.38.1 (2025-07-15)
|
|
10
|
+
|
|
11
|
+
### Bug fixes
|
|
12
|
+
|
|
13
|
+
Make the keymap not dispatch Alt key combos on macOS by key code, because those are generally used to type special characters.
|
|
14
|
+
|
|
15
|
+
Fix a layout bug that could occur with very narrow editors.
|
|
16
|
+
|
|
1
17
|
## 6.38.0 (2025-06-27)
|
|
2
18
|
|
|
3
19
|
### New features
|
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.
|
|
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) {
|
|
@@ -5095,7 +5100,7 @@ class HeightOracle {
|
|
|
5095
5100
|
heightForLine(length) {
|
|
5096
5101
|
if (!this.lineWrapping)
|
|
5097
5102
|
return this.lineHeight;
|
|
5098
|
-
let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
|
|
5103
|
+
let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / Math.max(1, this.lineLength - 5)));
|
|
5099
5104
|
return lines * this.lineHeight;
|
|
5100
5105
|
}
|
|
5101
5106
|
setDoc(doc) { this.doc = doc; return this; }
|
|
@@ -6066,7 +6071,7 @@ class ViewState {
|
|
|
6066
6071
|
refresh = true;
|
|
6067
6072
|
if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
|
|
6068
6073
|
let { lineHeight, charWidth, textHeight } = view.docView.measureTextSize();
|
|
6069
|
-
refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, contentWidth / charWidth, lineHeights);
|
|
6074
|
+
refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, Math.max(5, contentWidth / charWidth), lineHeights);
|
|
6070
6075
|
if (refresh) {
|
|
6071
6076
|
view.docView.minWidth = 0;
|
|
6072
6077
|
result |= 16 /* UpdateFlag.Geometry */;
|
|
@@ -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
|
*/
|
|
@@ -8802,6 +8807,8 @@ function runHandlers(map, event, view, scope) {
|
|
|
8802
8807
|
else if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&
|
|
8803
8808
|
// Ctrl-Alt may be used for AltGr on Windows
|
|
8804
8809
|
!(browser.windows && event.ctrlKey && event.altKey) &&
|
|
8810
|
+
// Alt-combinations on macOS tend to be typed characters
|
|
8811
|
+
!(browser.mac && event.altKey && !(event.ctrlKey || event.metaKey)) &&
|
|
8805
8812
|
(baseName = w3cKeyname.base[event.keyCode]) && baseName != name) {
|
|
8806
8813
|
if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {
|
|
8807
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.
|
|
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) {
|
|
@@ -5091,7 +5096,7 @@ class HeightOracle {
|
|
|
5091
5096
|
heightForLine(length) {
|
|
5092
5097
|
if (!this.lineWrapping)
|
|
5093
5098
|
return this.lineHeight;
|
|
5094
|
-
let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
|
|
5099
|
+
let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / Math.max(1, this.lineLength - 5)));
|
|
5095
5100
|
return lines * this.lineHeight;
|
|
5096
5101
|
}
|
|
5097
5102
|
setDoc(doc) { this.doc = doc; return this; }
|
|
@@ -6061,7 +6066,7 @@ class ViewState {
|
|
|
6061
6066
|
refresh = true;
|
|
6062
6067
|
if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
|
|
6063
6068
|
let { lineHeight, charWidth, textHeight } = view.docView.measureTextSize();
|
|
6064
|
-
refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, contentWidth / charWidth, lineHeights);
|
|
6069
|
+
refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, Math.max(5, contentWidth / charWidth), lineHeights);
|
|
6065
6070
|
if (refresh) {
|
|
6066
6071
|
view.docView.minWidth = 0;
|
|
6067
6072
|
result |= 16 /* UpdateFlag.Geometry */;
|
|
@@ -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
|
*/
|
|
@@ -8797,6 +8802,8 @@ function runHandlers(map, event, view, scope) {
|
|
|
8797
8802
|
else if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&
|
|
8798
8803
|
// Ctrl-Alt may be used for AltGr on Windows
|
|
8799
8804
|
!(browser.windows && event.ctrlKey && event.altKey) &&
|
|
8805
|
+
// Alt-combinations on macOS tend to be typed characters
|
|
8806
|
+
!(browser.mac && event.altKey && !(event.ctrlKey || event.metaKey)) &&
|
|
8800
8807
|
(baseName = base[event.keyCode]) && baseName != name) {
|
|
8801
8808
|
if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {
|
|
8802
8809
|
handled = true;
|