@codemirror/state 6.5.2 → 6.5.3
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 +8 -0
- package/dist/index.cjs +17 -8
- package/dist/index.d.cts +16 -6
- package/dist/index.d.ts +16 -6
- package/dist/index.js +17 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 6.5.3 (2025-12-22)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an issue where `RangeValue.eq` could get called with a value of a different class.
|
|
6
|
+
|
|
7
|
+
`EditorState.charCategorizer` now only uses the highest-precedence set of word characters from the language data, to allow overriding these.
|
|
8
|
+
|
|
1
9
|
## 6.5.2 (2025-02-03)
|
|
2
10
|
|
|
3
11
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -2827,7 +2827,8 @@ class EditorState {
|
|
|
2827
2827
|
- Other (anything else)
|
|
2828
2828
|
*/
|
|
2829
2829
|
charCategorizer(at) {
|
|
2830
|
-
|
|
2830
|
+
let chars = this.languageDataAt("wordChars", at);
|
|
2831
|
+
return makeCategorizer(chars.length ? chars[0] : "");
|
|
2831
2832
|
}
|
|
2832
2833
|
/**
|
|
2833
2834
|
Find the word at the given position, meaning the range
|
|
@@ -3013,6 +3014,9 @@ class RangeValue {
|
|
|
3013
3014
|
RangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;
|
|
3014
3015
|
RangeValue.prototype.point = false;
|
|
3015
3016
|
RangeValue.prototype.mapMode = exports.MapMode.TrackDel;
|
|
3017
|
+
function cmpVal(a, b) {
|
|
3018
|
+
return a == b || a.constructor == b.constructor && a.eq(b);
|
|
3019
|
+
}
|
|
3016
3020
|
/**
|
|
3017
3021
|
A range associates a value with a range of positions.
|
|
3018
3022
|
*/
|
|
@@ -3319,7 +3323,7 @@ class RangeSet {
|
|
|
3319
3323
|
for (;;) {
|
|
3320
3324
|
if (sideA.to != sideB.to ||
|
|
3321
3325
|
!sameValues(sideA.active, sideB.active) ||
|
|
3322
|
-
sideA.point && (!sideB.point || !sideA.point
|
|
3326
|
+
sideA.point && (!sideB.point || !cmpVal(sideA.point, sideB.point)))
|
|
3323
3327
|
return false;
|
|
3324
3328
|
if (sideA.to > to)
|
|
3325
3329
|
return true;
|
|
@@ -3794,22 +3798,27 @@ function compare(a, startA, b, startB, length, comparator) {
|
|
|
3794
3798
|
b.goto(startB);
|
|
3795
3799
|
let endB = startB + length;
|
|
3796
3800
|
let pos = startB, dPos = startB - startA;
|
|
3797
|
-
|
|
3801
|
+
let bounds = !!comparator.boundChange;
|
|
3802
|
+
for (let boundChange = false;;) {
|
|
3798
3803
|
let dEnd = (a.to + dPos) - b.to, diff = dEnd || a.endSide - b.endSide;
|
|
3799
3804
|
let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
|
|
3800
|
-
|
|
3801
|
-
|
|
3805
|
+
let point = a.point || b.point;
|
|
3806
|
+
if (point) {
|
|
3807
|
+
if (!(a.point && b.point && cmpVal(a.point, b.point) &&
|
|
3802
3808
|
sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))
|
|
3803
3809
|
comparator.comparePoint(pos, clipEnd, a.point, b.point);
|
|
3810
|
+
boundChange = false;
|
|
3804
3811
|
}
|
|
3805
3812
|
else {
|
|
3813
|
+
if (boundChange)
|
|
3814
|
+
comparator.boundChange(pos);
|
|
3806
3815
|
if (clipEnd > pos && !sameValues(a.active, b.active))
|
|
3807
3816
|
comparator.compareRange(pos, clipEnd, a.active, b.active);
|
|
3817
|
+
if (bounds && clipEnd < endB && (dEnd || a.openEnd(end) != b.openEnd(end)))
|
|
3818
|
+
boundChange = true;
|
|
3808
3819
|
}
|
|
3809
3820
|
if (end > endB)
|
|
3810
3821
|
break;
|
|
3811
|
-
if ((dEnd || a.openEnd != b.openEnd) && comparator.boundChange)
|
|
3812
|
-
comparator.boundChange(end);
|
|
3813
3822
|
pos = end;
|
|
3814
3823
|
if (diff <= 0)
|
|
3815
3824
|
a.next();
|
|
@@ -3821,7 +3830,7 @@ function sameValues(a, b) {
|
|
|
3821
3830
|
if (a.length != b.length)
|
|
3822
3831
|
return false;
|
|
3823
3832
|
for (let i = 0; i < a.length; i++)
|
|
3824
|
-
if (a[i] != b[i] && !a[i]
|
|
3833
|
+
if (a[i] != b[i] && !cmpVal(a[i], b[i]))
|
|
3825
3834
|
return false;
|
|
3826
3835
|
return true;
|
|
3827
3836
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -221,12 +221,13 @@ declare class ChangeDesc {
|
|
|
221
221
|
position pointing into the new document.
|
|
222
222
|
|
|
223
223
|
`assoc` indicates which side the position should be associated
|
|
224
|
-
with. When it is negative
|
|
225
|
-
|
|
224
|
+
with. When it is negative, the mapping will try to keep the
|
|
225
|
+
position close to the character before it (if any), and will
|
|
226
226
|
move it before insertions at that point or replacements across
|
|
227
|
-
that point. When it is positive, the position is associated
|
|
228
|
-
the character after it, and will be moved forward for
|
|
229
|
-
|
|
227
|
+
that point. When it is zero or positive, the position is associated
|
|
228
|
+
with the character after it, and will be moved forward for
|
|
229
|
+
*/
|
|
230
|
+
/**
|
|
230
231
|
|
|
231
232
|
`mode` determines whether deletions should be
|
|
232
233
|
[reported](https://codemirror.net/6/docs/ref/#state.MapMode). It defaults to
|
|
@@ -1488,7 +1489,11 @@ interface RangeCursor<T> {
|
|
|
1488
1489
|
/**
|
|
1489
1490
|
Move the iterator forward.
|
|
1490
1491
|
*/
|
|
1491
|
-
next
|
|
1492
|
+
next(): void;
|
|
1493
|
+
/**
|
|
1494
|
+
Jump the cursor to the given position.
|
|
1495
|
+
*/
|
|
1496
|
+
goto(pos: number): void;
|
|
1492
1497
|
/**
|
|
1493
1498
|
The next range's value. Holds `null` when the cursor has reached
|
|
1494
1499
|
its end.
|
|
@@ -1502,6 +1507,11 @@ interface RangeCursor<T> {
|
|
|
1502
1507
|
The next end position.
|
|
1503
1508
|
*/
|
|
1504
1509
|
to: number;
|
|
1510
|
+
/**
|
|
1511
|
+
The position of the set that this range comes from in the array
|
|
1512
|
+
of sets being iterated over.
|
|
1513
|
+
*/
|
|
1514
|
+
rank: number;
|
|
1505
1515
|
}
|
|
1506
1516
|
type RangeSetUpdate<T extends RangeValue> = {
|
|
1507
1517
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -221,12 +221,13 @@ declare class ChangeDesc {
|
|
|
221
221
|
position pointing into the new document.
|
|
222
222
|
|
|
223
223
|
`assoc` indicates which side the position should be associated
|
|
224
|
-
with. When it is negative
|
|
225
|
-
|
|
224
|
+
with. When it is negative, the mapping will try to keep the
|
|
225
|
+
position close to the character before it (if any), and will
|
|
226
226
|
move it before insertions at that point or replacements across
|
|
227
|
-
that point. When it is positive, the position is associated
|
|
228
|
-
the character after it, and will be moved forward for
|
|
229
|
-
|
|
227
|
+
that point. When it is zero or positive, the position is associated
|
|
228
|
+
with the character after it, and will be moved forward for
|
|
229
|
+
*/
|
|
230
|
+
/**
|
|
230
231
|
|
|
231
232
|
`mode` determines whether deletions should be
|
|
232
233
|
[reported](https://codemirror.net/6/docs/ref/#state.MapMode). It defaults to
|
|
@@ -1488,7 +1489,11 @@ interface RangeCursor<T> {
|
|
|
1488
1489
|
/**
|
|
1489
1490
|
Move the iterator forward.
|
|
1490
1491
|
*/
|
|
1491
|
-
next
|
|
1492
|
+
next(): void;
|
|
1493
|
+
/**
|
|
1494
|
+
Jump the cursor to the given position.
|
|
1495
|
+
*/
|
|
1496
|
+
goto(pos: number): void;
|
|
1492
1497
|
/**
|
|
1493
1498
|
The next range's value. Holds `null` when the cursor has reached
|
|
1494
1499
|
its end.
|
|
@@ -1502,6 +1507,11 @@ interface RangeCursor<T> {
|
|
|
1502
1507
|
The next end position.
|
|
1503
1508
|
*/
|
|
1504
1509
|
to: number;
|
|
1510
|
+
/**
|
|
1511
|
+
The position of the set that this range comes from in the array
|
|
1512
|
+
of sets being iterated over.
|
|
1513
|
+
*/
|
|
1514
|
+
rank: number;
|
|
1505
1515
|
}
|
|
1506
1516
|
type RangeSetUpdate<T extends RangeValue> = {
|
|
1507
1517
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2823,7 +2823,8 @@ class EditorState {
|
|
|
2823
2823
|
- Other (anything else)
|
|
2824
2824
|
*/
|
|
2825
2825
|
charCategorizer(at) {
|
|
2826
|
-
|
|
2826
|
+
let chars = this.languageDataAt("wordChars", at);
|
|
2827
|
+
return makeCategorizer(chars.length ? chars[0] : "");
|
|
2827
2828
|
}
|
|
2828
2829
|
/**
|
|
2829
2830
|
Find the word at the given position, meaning the range
|
|
@@ -3009,6 +3010,9 @@ class RangeValue {
|
|
|
3009
3010
|
RangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;
|
|
3010
3011
|
RangeValue.prototype.point = false;
|
|
3011
3012
|
RangeValue.prototype.mapMode = MapMode.TrackDel;
|
|
3013
|
+
function cmpVal(a, b) {
|
|
3014
|
+
return a == b || a.constructor == b.constructor && a.eq(b);
|
|
3015
|
+
}
|
|
3012
3016
|
/**
|
|
3013
3017
|
A range associates a value with a range of positions.
|
|
3014
3018
|
*/
|
|
@@ -3315,7 +3319,7 @@ class RangeSet {
|
|
|
3315
3319
|
for (;;) {
|
|
3316
3320
|
if (sideA.to != sideB.to ||
|
|
3317
3321
|
!sameValues(sideA.active, sideB.active) ||
|
|
3318
|
-
sideA.point && (!sideB.point || !sideA.point
|
|
3322
|
+
sideA.point && (!sideB.point || !cmpVal(sideA.point, sideB.point)))
|
|
3319
3323
|
return false;
|
|
3320
3324
|
if (sideA.to > to)
|
|
3321
3325
|
return true;
|
|
@@ -3790,22 +3794,27 @@ function compare(a, startA, b, startB, length, comparator) {
|
|
|
3790
3794
|
b.goto(startB);
|
|
3791
3795
|
let endB = startB + length;
|
|
3792
3796
|
let pos = startB, dPos = startB - startA;
|
|
3793
|
-
|
|
3797
|
+
let bounds = !!comparator.boundChange;
|
|
3798
|
+
for (let boundChange = false;;) {
|
|
3794
3799
|
let dEnd = (a.to + dPos) - b.to, diff = dEnd || a.endSide - b.endSide;
|
|
3795
3800
|
let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
|
|
3796
|
-
|
|
3797
|
-
|
|
3801
|
+
let point = a.point || b.point;
|
|
3802
|
+
if (point) {
|
|
3803
|
+
if (!(a.point && b.point && cmpVal(a.point, b.point) &&
|
|
3798
3804
|
sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))
|
|
3799
3805
|
comparator.comparePoint(pos, clipEnd, a.point, b.point);
|
|
3806
|
+
boundChange = false;
|
|
3800
3807
|
}
|
|
3801
3808
|
else {
|
|
3809
|
+
if (boundChange)
|
|
3810
|
+
comparator.boundChange(pos);
|
|
3802
3811
|
if (clipEnd > pos && !sameValues(a.active, b.active))
|
|
3803
3812
|
comparator.compareRange(pos, clipEnd, a.active, b.active);
|
|
3813
|
+
if (bounds && clipEnd < endB && (dEnd || a.openEnd(end) != b.openEnd(end)))
|
|
3814
|
+
boundChange = true;
|
|
3804
3815
|
}
|
|
3805
3816
|
if (end > endB)
|
|
3806
3817
|
break;
|
|
3807
|
-
if ((dEnd || a.openEnd != b.openEnd) && comparator.boundChange)
|
|
3808
|
-
comparator.boundChange(end);
|
|
3809
3818
|
pos = end;
|
|
3810
3819
|
if (diff <= 0)
|
|
3811
3820
|
a.next();
|
|
@@ -3817,7 +3826,7 @@ function sameValues(a, b) {
|
|
|
3817
3826
|
if (a.length != b.length)
|
|
3818
3827
|
return false;
|
|
3819
3828
|
for (let i = 0; i < a.length; i++)
|
|
3820
|
-
if (a[i] != b[i] && !a[i]
|
|
3829
|
+
if (a[i] != b[i] && !cmpVal(a[i], b[i]))
|
|
3821
3830
|
return false;
|
|
3822
3831
|
return true;
|
|
3823
3832
|
}
|