@codemirror/state 6.1.3 → 6.2.0
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 +12 -0
- package/dist/index.cjs +19 -20
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -20
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 6.2.0 (2022-12-26)
|
|
2
|
+
|
|
3
|
+
### New features
|
|
4
|
+
|
|
5
|
+
`EditorSelection.range` now accepts an optional 4th argument to specify the bidi level of the range's head position.
|
|
6
|
+
|
|
7
|
+
## 6.1.4 (2022-11-15)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Fix a bug that caused the `openStart` value passed to span iterators to be incorrect around widgets in some circumstances.
|
|
12
|
+
|
|
1
13
|
## 6.1.3 (2022-11-10)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -1516,10 +1516,11 @@ class EditorSelection {
|
|
|
1516
1516
|
/**
|
|
1517
1517
|
Create a selection range.
|
|
1518
1518
|
*/
|
|
1519
|
-
static range(anchor, head, goalColumn) {
|
|
1520
|
-
let
|
|
1521
|
-
|
|
1522
|
-
|
|
1519
|
+
static range(anchor, head, goalColumn, bidiLevel) {
|
|
1520
|
+
let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */) |
|
|
1521
|
+
(bidiLevel == null ? 3 : Math.min(2, bidiLevel));
|
|
1522
|
+
return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | 8 /* RangeFlag.AssocAfter */ | flags)
|
|
1523
|
+
: SelectionRange.create(anchor, head, (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0) | flags);
|
|
1523
1524
|
}
|
|
1524
1525
|
/**
|
|
1525
1526
|
@internal
|
|
@@ -3362,23 +3363,24 @@ class RangeSet {
|
|
|
3362
3363
|
*/
|
|
3363
3364
|
minPointSize = -1) {
|
|
3364
3365
|
let cursor = new SpanCursor(sets, null, minPointSize).goto(from), pos = from;
|
|
3365
|
-
let
|
|
3366
|
+
let openRanges = cursor.openStart;
|
|
3366
3367
|
for (;;) {
|
|
3367
3368
|
let curTo = Math.min(cursor.to, to);
|
|
3368
3369
|
if (cursor.point) {
|
|
3369
|
-
|
|
3370
|
-
|
|
3370
|
+
let active = cursor.activeForPoint(cursor.to);
|
|
3371
|
+
let openCount = cursor.pointFrom < from ? active.length + 1 : Math.min(active.length, openRanges);
|
|
3372
|
+
iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);
|
|
3373
|
+
openRanges = Math.min(cursor.openEnd(curTo), active.length);
|
|
3371
3374
|
}
|
|
3372
3375
|
else if (curTo > pos) {
|
|
3373
|
-
iterator.span(pos, curTo, cursor.active,
|
|
3374
|
-
|
|
3376
|
+
iterator.span(pos, curTo, cursor.active, openRanges);
|
|
3377
|
+
openRanges = cursor.openEnd(curTo);
|
|
3375
3378
|
}
|
|
3376
3379
|
if (cursor.to > to)
|
|
3377
|
-
|
|
3380
|
+
return openRanges + (cursor.point && cursor.to > to ? 1 : 0);
|
|
3378
3381
|
pos = cursor.to;
|
|
3379
3382
|
cursor.next();
|
|
3380
3383
|
}
|
|
3381
|
-
return open;
|
|
3382
3384
|
}
|
|
3383
3385
|
/**
|
|
3384
3386
|
Create a range set for the given range or array of ranges. By
|
|
@@ -3682,6 +3684,8 @@ class SpanCursor {
|
|
|
3682
3684
|
this.pointRank = 0;
|
|
3683
3685
|
this.to = -1000000000 /* C.Far */;
|
|
3684
3686
|
this.endSide = 0;
|
|
3687
|
+
// The amount of open active ranges at the start of the iterator.
|
|
3688
|
+
// Not including points.
|
|
3685
3689
|
this.openStart = -1;
|
|
3686
3690
|
this.cursor = HeapCursor.from(sets, skip, minPoint);
|
|
3687
3691
|
}
|
|
@@ -3722,7 +3726,7 @@ class SpanCursor {
|
|
|
3722
3726
|
next() {
|
|
3723
3727
|
let from = this.to, wasPoint = this.point;
|
|
3724
3728
|
this.point = null;
|
|
3725
|
-
let trackOpen = this.openStart < 0 ? [] : null
|
|
3729
|
+
let trackOpen = this.openStart < 0 ? [] : null;
|
|
3726
3730
|
for (;;) {
|
|
3727
3731
|
let a = this.minActive;
|
|
3728
3732
|
if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
|
|
@@ -3748,8 +3752,6 @@ class SpanCursor {
|
|
|
3748
3752
|
let nextVal = this.cursor.value;
|
|
3749
3753
|
if (!nextVal.point) { // Opening a range
|
|
3750
3754
|
this.addActive(trackOpen);
|
|
3751
|
-
if (this.cursor.from < from && this.cursor.to > from)
|
|
3752
|
-
trackExtra++;
|
|
3753
3755
|
this.cursor.next();
|
|
3754
3756
|
}
|
|
3755
3757
|
else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
|
|
@@ -3762,8 +3764,6 @@ class SpanCursor {
|
|
|
3762
3764
|
this.pointRank = this.cursor.rank;
|
|
3763
3765
|
this.to = this.cursor.to;
|
|
3764
3766
|
this.endSide = nextVal.endSide;
|
|
3765
|
-
if (this.cursor.from < from)
|
|
3766
|
-
trackExtra = 1;
|
|
3767
3767
|
this.cursor.next();
|
|
3768
3768
|
this.forward(this.to, this.endSide);
|
|
3769
3769
|
break;
|
|
@@ -3771,10 +3771,9 @@ class SpanCursor {
|
|
|
3771
3771
|
}
|
|
3772
3772
|
}
|
|
3773
3773
|
if (trackOpen) {
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
openStart++;
|
|
3777
|
-
this.openStart = openStart + trackExtra;
|
|
3774
|
+
this.openStart = 0;
|
|
3775
|
+
for (let i = trackOpen.length - 1; i >= 0 && trackOpen[i] < from; i--)
|
|
3776
|
+
this.openStart++;
|
|
3778
3777
|
}
|
|
3779
3778
|
}
|
|
3780
3779
|
activeForPoint(to) {
|
package/dist/index.d.ts
CHANGED
|
@@ -476,7 +476,7 @@ declare class EditorSelection {
|
|
|
476
476
|
/**
|
|
477
477
|
Create a selection range.
|
|
478
478
|
*/
|
|
479
|
-
static range(anchor: number, head: number, goalColumn?: number): SelectionRange;
|
|
479
|
+
static range(anchor: number, head: number, goalColumn?: number, bidiLevel?: number): SelectionRange;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
482
|
declare type FacetConfig<Input, Output> = {
|
package/dist/index.js
CHANGED
|
@@ -1511,10 +1511,11 @@ class EditorSelection {
|
|
|
1511
1511
|
/**
|
|
1512
1512
|
Create a selection range.
|
|
1513
1513
|
*/
|
|
1514
|
-
static range(anchor, head, goalColumn) {
|
|
1515
|
-
let
|
|
1516
|
-
|
|
1517
|
-
|
|
1514
|
+
static range(anchor, head, goalColumn, bidiLevel) {
|
|
1515
|
+
let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */) |
|
|
1516
|
+
(bidiLevel == null ? 3 : Math.min(2, bidiLevel));
|
|
1517
|
+
return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | 8 /* RangeFlag.AssocAfter */ | flags)
|
|
1518
|
+
: SelectionRange.create(anchor, head, (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0) | flags);
|
|
1518
1519
|
}
|
|
1519
1520
|
/**
|
|
1520
1521
|
@internal
|
|
@@ -3356,23 +3357,24 @@ class RangeSet {
|
|
|
3356
3357
|
*/
|
|
3357
3358
|
minPointSize = -1) {
|
|
3358
3359
|
let cursor = new SpanCursor(sets, null, minPointSize).goto(from), pos = from;
|
|
3359
|
-
let
|
|
3360
|
+
let openRanges = cursor.openStart;
|
|
3360
3361
|
for (;;) {
|
|
3361
3362
|
let curTo = Math.min(cursor.to, to);
|
|
3362
3363
|
if (cursor.point) {
|
|
3363
|
-
|
|
3364
|
-
|
|
3364
|
+
let active = cursor.activeForPoint(cursor.to);
|
|
3365
|
+
let openCount = cursor.pointFrom < from ? active.length + 1 : Math.min(active.length, openRanges);
|
|
3366
|
+
iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);
|
|
3367
|
+
openRanges = Math.min(cursor.openEnd(curTo), active.length);
|
|
3365
3368
|
}
|
|
3366
3369
|
else if (curTo > pos) {
|
|
3367
|
-
iterator.span(pos, curTo, cursor.active,
|
|
3368
|
-
|
|
3370
|
+
iterator.span(pos, curTo, cursor.active, openRanges);
|
|
3371
|
+
openRanges = cursor.openEnd(curTo);
|
|
3369
3372
|
}
|
|
3370
3373
|
if (cursor.to > to)
|
|
3371
|
-
|
|
3374
|
+
return openRanges + (cursor.point && cursor.to > to ? 1 : 0);
|
|
3372
3375
|
pos = cursor.to;
|
|
3373
3376
|
cursor.next();
|
|
3374
3377
|
}
|
|
3375
|
-
return open;
|
|
3376
3378
|
}
|
|
3377
3379
|
/**
|
|
3378
3380
|
Create a range set for the given range or array of ranges. By
|
|
@@ -3676,6 +3678,8 @@ class SpanCursor {
|
|
|
3676
3678
|
this.pointRank = 0;
|
|
3677
3679
|
this.to = -1000000000 /* C.Far */;
|
|
3678
3680
|
this.endSide = 0;
|
|
3681
|
+
// The amount of open active ranges at the start of the iterator.
|
|
3682
|
+
// Not including points.
|
|
3679
3683
|
this.openStart = -1;
|
|
3680
3684
|
this.cursor = HeapCursor.from(sets, skip, minPoint);
|
|
3681
3685
|
}
|
|
@@ -3716,7 +3720,7 @@ class SpanCursor {
|
|
|
3716
3720
|
next() {
|
|
3717
3721
|
let from = this.to, wasPoint = this.point;
|
|
3718
3722
|
this.point = null;
|
|
3719
|
-
let trackOpen = this.openStart < 0 ? [] : null
|
|
3723
|
+
let trackOpen = this.openStart < 0 ? [] : null;
|
|
3720
3724
|
for (;;) {
|
|
3721
3725
|
let a = this.minActive;
|
|
3722
3726
|
if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
|
|
@@ -3742,8 +3746,6 @@ class SpanCursor {
|
|
|
3742
3746
|
let nextVal = this.cursor.value;
|
|
3743
3747
|
if (!nextVal.point) { // Opening a range
|
|
3744
3748
|
this.addActive(trackOpen);
|
|
3745
|
-
if (this.cursor.from < from && this.cursor.to > from)
|
|
3746
|
-
trackExtra++;
|
|
3747
3749
|
this.cursor.next();
|
|
3748
3750
|
}
|
|
3749
3751
|
else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
|
|
@@ -3756,8 +3758,6 @@ class SpanCursor {
|
|
|
3756
3758
|
this.pointRank = this.cursor.rank;
|
|
3757
3759
|
this.to = this.cursor.to;
|
|
3758
3760
|
this.endSide = nextVal.endSide;
|
|
3759
|
-
if (this.cursor.from < from)
|
|
3760
|
-
trackExtra = 1;
|
|
3761
3761
|
this.cursor.next();
|
|
3762
3762
|
this.forward(this.to, this.endSide);
|
|
3763
3763
|
break;
|
|
@@ -3765,10 +3765,9 @@ class SpanCursor {
|
|
|
3765
3765
|
}
|
|
3766
3766
|
}
|
|
3767
3767
|
if (trackOpen) {
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
openStart++;
|
|
3771
|
-
this.openStart = openStart + trackExtra;
|
|
3768
|
+
this.openStart = 0;
|
|
3769
|
+
for (let i = trackOpen.length - 1; i >= 0 && trackOpen[i] < from; i--)
|
|
3770
|
+
this.openStart++;
|
|
3772
3771
|
}
|
|
3773
3772
|
}
|
|
3774
3773
|
activeForPoint(to) {
|