@codemirror/state 6.2.0 → 6.2.1
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 +6 -0
- package/LICENSE +1 -1
- package/dist/index.cjs +24 -21
- package/dist/index.d.ts +17 -10
- package/dist/index.js +24 -21
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (C) 2018-2021 by Marijn Haverbeke <
|
|
3
|
+
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/index.cjs
CHANGED
|
@@ -6,10 +6,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
The data structure for documents. @nonabstract
|
|
7
7
|
*/
|
|
8
8
|
class Text {
|
|
9
|
-
/**
|
|
10
|
-
@internal
|
|
11
|
-
*/
|
|
12
|
-
constructor() { }
|
|
13
9
|
/**
|
|
14
10
|
Get the line description around the given position.
|
|
15
11
|
*/
|
|
@@ -104,7 +100,8 @@ class Text {
|
|
|
104
100
|
return new LineCursor(inner);
|
|
105
101
|
}
|
|
106
102
|
/**
|
|
107
|
-
|
|
103
|
+
Return the document as a string, using newline characters to
|
|
104
|
+
separate lines.
|
|
108
105
|
*/
|
|
109
106
|
toString() { return this.sliceString(0); }
|
|
110
107
|
/**
|
|
@@ -117,6 +114,10 @@ class Text {
|
|
|
117
114
|
return lines;
|
|
118
115
|
}
|
|
119
116
|
/**
|
|
117
|
+
@internal
|
|
118
|
+
*/
|
|
119
|
+
constructor() { }
|
|
120
|
+
/**
|
|
120
121
|
Create a `Text` instance for the given array of lines.
|
|
121
122
|
*/
|
|
122
123
|
static of(text) {
|
|
@@ -2161,7 +2162,10 @@ class StateEffect {
|
|
|
2161
2162
|
is(type) { return this.type == type; }
|
|
2162
2163
|
/**
|
|
2163
2164
|
Define a new effect type. The type parameter indicates the type
|
|
2164
|
-
of values that his effect holds.
|
|
2165
|
+
of values that his effect holds. It should be a type that
|
|
2166
|
+
doesn't include `undefined`, since that is used in
|
|
2167
|
+
[mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is
|
|
2168
|
+
removed.
|
|
2165
2169
|
*/
|
|
2166
2170
|
static define(spec = {}) {
|
|
2167
2171
|
return new StateEffectType(spec.map || (v => v));
|
|
@@ -3305,8 +3309,7 @@ class RangeSet {
|
|
|
3305
3309
|
static compare(oldSets, newSets,
|
|
3306
3310
|
/**
|
|
3307
3311
|
This indicates how the underlying data changed between these
|
|
3308
|
-
ranges, and is needed to synchronize the iteration.
|
|
3309
|
-
`to` are coordinates in the _new_ space, after these changes.
|
|
3312
|
+
ranges, and is needed to synchronize the iteration.
|
|
3310
3313
|
*/
|
|
3311
3314
|
textDiff, comparator,
|
|
3312
3315
|
/**
|
|
@@ -3417,6 +3420,18 @@ A range set builder is a data structure that helps build up a
|
|
|
3417
3420
|
an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
|
|
3418
3421
|
*/
|
|
3419
3422
|
class RangeSetBuilder {
|
|
3423
|
+
finishChunk(newArrays) {
|
|
3424
|
+
this.chunks.push(new Chunk(this.from, this.to, this.value, this.maxPoint));
|
|
3425
|
+
this.chunkPos.push(this.chunkStart);
|
|
3426
|
+
this.chunkStart = -1;
|
|
3427
|
+
this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint);
|
|
3428
|
+
this.maxPoint = -1;
|
|
3429
|
+
if (newArrays) {
|
|
3430
|
+
this.from = [];
|
|
3431
|
+
this.to = [];
|
|
3432
|
+
this.value = [];
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3420
3435
|
/**
|
|
3421
3436
|
Create an empty builder.
|
|
3422
3437
|
*/
|
|
@@ -3434,18 +3449,6 @@ class RangeSetBuilder {
|
|
|
3434
3449
|
this.setMaxPoint = -1;
|
|
3435
3450
|
this.nextLayer = null;
|
|
3436
3451
|
}
|
|
3437
|
-
finishChunk(newArrays) {
|
|
3438
|
-
this.chunks.push(new Chunk(this.from, this.to, this.value, this.maxPoint));
|
|
3439
|
-
this.chunkPos.push(this.chunkStart);
|
|
3440
|
-
this.chunkStart = -1;
|
|
3441
|
-
this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint);
|
|
3442
|
-
this.maxPoint = -1;
|
|
3443
|
-
if (newArrays) {
|
|
3444
|
-
this.from = [];
|
|
3445
|
-
this.to = [];
|
|
3446
|
-
this.value = [];
|
|
3447
|
-
}
|
|
3448
|
-
}
|
|
3449
3452
|
/**
|
|
3450
3453
|
Add a range. Ranges should be added in sorted (by `from` and
|
|
3451
3454
|
`value.startSide`) order.
|
|
@@ -3805,7 +3808,7 @@ function compare(a, startA, b, startB, length, comparator) {
|
|
|
3805
3808
|
let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
|
|
3806
3809
|
if (a.point || b.point) {
|
|
3807
3810
|
if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
|
|
3808
|
-
sameValues(a.activeForPoint(a.to
|
|
3811
|
+
sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))
|
|
3809
3812
|
comparator.comparePoint(pos, clipEnd, a.point, b.point);
|
|
3810
3813
|
}
|
|
3811
3814
|
else {
|
package/dist/index.d.ts
CHANGED
|
@@ -85,6 +85,11 @@ declare abstract class Text implements Iterable<string> {
|
|
|
85
85
|
*/
|
|
86
86
|
iterLines(from?: number, to?: number): TextIterator;
|
|
87
87
|
/**
|
|
88
|
+
Return the document as a string, using newline characters to
|
|
89
|
+
separate lines.
|
|
90
|
+
*/
|
|
91
|
+
toString(): string;
|
|
92
|
+
/**
|
|
88
93
|
Convert the document to an array of lines (which can be
|
|
89
94
|
deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
|
|
90
95
|
*/
|
|
@@ -252,7 +257,7 @@ plain object describing a change (a deletion, insertion, or
|
|
|
252
257
|
replacement, depending on which fields are present), a [change
|
|
253
258
|
set](https://codemirror.net/6/docs/ref/#state.ChangeSet), or an array of change specs.
|
|
254
259
|
*/
|
|
255
|
-
|
|
260
|
+
type ChangeSpec = {
|
|
256
261
|
from: number;
|
|
257
262
|
to?: number;
|
|
258
263
|
insert?: string | Text;
|
|
@@ -479,7 +484,7 @@ declare class EditorSelection {
|
|
|
479
484
|
static range(anchor: number, head: number, goalColumn?: number, bidiLevel?: number): SelectionRange;
|
|
480
485
|
}
|
|
481
486
|
|
|
482
|
-
|
|
487
|
+
type FacetConfig<Input, Output> = {
|
|
483
488
|
/**
|
|
484
489
|
How to combine the input values into a single output value. When
|
|
485
490
|
not given, the array of input values becomes the output. This
|
|
@@ -559,8 +564,8 @@ declare class Facet<Input, Output = readonly Input[]> {
|
|
|
559
564
|
from<T extends Input>(field: StateField<T>): Extension;
|
|
560
565
|
from<T>(field: StateField<T>, get: (value: T) => Input): Extension;
|
|
561
566
|
}
|
|
562
|
-
|
|
563
|
-
|
|
567
|
+
type Slot<T> = Facet<any, T> | StateField<T> | "doc" | "selection";
|
|
568
|
+
type StateFieldSpec<Value> = {
|
|
564
569
|
/**
|
|
565
570
|
Creates the initial value for the field when a state is created.
|
|
566
571
|
*/
|
|
@@ -635,7 +640,7 @@ providers](https://codemirror.net/6/docs/ref/#state.Facet.of), or objects with a
|
|
|
635
640
|
`extension` property. Extensions can be nested in arrays
|
|
636
641
|
arbitrarily deep—they will be flattened when processed.
|
|
637
642
|
*/
|
|
638
|
-
|
|
643
|
+
type Extension = {
|
|
639
644
|
extension: Extension;
|
|
640
645
|
} | readonly Extension[];
|
|
641
646
|
/**
|
|
@@ -780,7 +785,10 @@ declare class StateEffect<Value> {
|
|
|
780
785
|
is<T>(type: StateEffectType<T>): this is StateEffect<T>;
|
|
781
786
|
/**
|
|
782
787
|
Define a new effect type. The type parameter indicates the type
|
|
783
|
-
of values that his effect holds.
|
|
788
|
+
of values that his effect holds. It should be a type that
|
|
789
|
+
doesn't include `undefined`, since that is used in
|
|
790
|
+
[mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is
|
|
791
|
+
removed.
|
|
784
792
|
*/
|
|
785
793
|
static define<Value = null>(spec?: StateEffectSpec<Value>): StateEffectType<Value>;
|
|
786
794
|
/**
|
|
@@ -1317,7 +1325,7 @@ Subtype of [`Command`](https://codemirror.net/6/docs/ref/#view.Command) that doe
|
|
|
1317
1325
|
to the actual editor view. Mostly useful to define commands that
|
|
1318
1326
|
can be run and tested outside of a browser environment.
|
|
1319
1327
|
*/
|
|
1320
|
-
|
|
1328
|
+
type StateCommand = (target: {
|
|
1321
1329
|
state: EditorState;
|
|
1322
1330
|
dispatch: (transaction: Transaction) => void;
|
|
1323
1331
|
}) => boolean;
|
|
@@ -1459,7 +1467,7 @@ interface RangeCursor<T> {
|
|
|
1459
1467
|
*/
|
|
1460
1468
|
to: number;
|
|
1461
1469
|
}
|
|
1462
|
-
|
|
1470
|
+
type RangeSetUpdate<T extends RangeValue> = {
|
|
1463
1471
|
/**
|
|
1464
1472
|
An array of ranges to add. If given, this should be sorted by
|
|
1465
1473
|
`from` position and `startSide` unless
|
|
@@ -1538,8 +1546,7 @@ declare class RangeSet<T extends RangeValue> {
|
|
|
1538
1546
|
static compare<T extends RangeValue>(oldSets: readonly RangeSet<T>[], newSets: readonly RangeSet<T>[],
|
|
1539
1547
|
/**
|
|
1540
1548
|
This indicates how the underlying data changed between these
|
|
1541
|
-
ranges, and is needed to synchronize the iteration.
|
|
1542
|
-
`to` are coordinates in the _new_ space, after these changes.
|
|
1549
|
+
ranges, and is needed to synchronize the iteration.
|
|
1543
1550
|
*/
|
|
1544
1551
|
textDiff: ChangeDesc, comparator: RangeComparator<T>,
|
|
1545
1552
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
The data structure for documents. @nonabstract
|
|
3
3
|
*/
|
|
4
4
|
class Text {
|
|
5
|
-
/**
|
|
6
|
-
@internal
|
|
7
|
-
*/
|
|
8
|
-
constructor() { }
|
|
9
5
|
/**
|
|
10
6
|
Get the line description around the given position.
|
|
11
7
|
*/
|
|
@@ -100,7 +96,8 @@ class Text {
|
|
|
100
96
|
return new LineCursor(inner);
|
|
101
97
|
}
|
|
102
98
|
/**
|
|
103
|
-
|
|
99
|
+
Return the document as a string, using newline characters to
|
|
100
|
+
separate lines.
|
|
104
101
|
*/
|
|
105
102
|
toString() { return this.sliceString(0); }
|
|
106
103
|
/**
|
|
@@ -113,6 +110,10 @@ class Text {
|
|
|
113
110
|
return lines;
|
|
114
111
|
}
|
|
115
112
|
/**
|
|
113
|
+
@internal
|
|
114
|
+
*/
|
|
115
|
+
constructor() { }
|
|
116
|
+
/**
|
|
116
117
|
Create a `Text` instance for the given array of lines.
|
|
117
118
|
*/
|
|
118
119
|
static of(text) {
|
|
@@ -2156,7 +2157,10 @@ class StateEffect {
|
|
|
2156
2157
|
is(type) { return this.type == type; }
|
|
2157
2158
|
/**
|
|
2158
2159
|
Define a new effect type. The type parameter indicates the type
|
|
2159
|
-
of values that his effect holds.
|
|
2160
|
+
of values that his effect holds. It should be a type that
|
|
2161
|
+
doesn't include `undefined`, since that is used in
|
|
2162
|
+
[mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is
|
|
2163
|
+
removed.
|
|
2160
2164
|
*/
|
|
2161
2165
|
static define(spec = {}) {
|
|
2162
2166
|
return new StateEffectType(spec.map || (v => v));
|
|
@@ -3299,8 +3303,7 @@ class RangeSet {
|
|
|
3299
3303
|
static compare(oldSets, newSets,
|
|
3300
3304
|
/**
|
|
3301
3305
|
This indicates how the underlying data changed between these
|
|
3302
|
-
ranges, and is needed to synchronize the iteration.
|
|
3303
|
-
`to` are coordinates in the _new_ space, after these changes.
|
|
3306
|
+
ranges, and is needed to synchronize the iteration.
|
|
3304
3307
|
*/
|
|
3305
3308
|
textDiff, comparator,
|
|
3306
3309
|
/**
|
|
@@ -3411,6 +3414,18 @@ A range set builder is a data structure that helps build up a
|
|
|
3411
3414
|
an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
|
|
3412
3415
|
*/
|
|
3413
3416
|
class RangeSetBuilder {
|
|
3417
|
+
finishChunk(newArrays) {
|
|
3418
|
+
this.chunks.push(new Chunk(this.from, this.to, this.value, this.maxPoint));
|
|
3419
|
+
this.chunkPos.push(this.chunkStart);
|
|
3420
|
+
this.chunkStart = -1;
|
|
3421
|
+
this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint);
|
|
3422
|
+
this.maxPoint = -1;
|
|
3423
|
+
if (newArrays) {
|
|
3424
|
+
this.from = [];
|
|
3425
|
+
this.to = [];
|
|
3426
|
+
this.value = [];
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3414
3429
|
/**
|
|
3415
3430
|
Create an empty builder.
|
|
3416
3431
|
*/
|
|
@@ -3428,18 +3443,6 @@ class RangeSetBuilder {
|
|
|
3428
3443
|
this.setMaxPoint = -1;
|
|
3429
3444
|
this.nextLayer = null;
|
|
3430
3445
|
}
|
|
3431
|
-
finishChunk(newArrays) {
|
|
3432
|
-
this.chunks.push(new Chunk(this.from, this.to, this.value, this.maxPoint));
|
|
3433
|
-
this.chunkPos.push(this.chunkStart);
|
|
3434
|
-
this.chunkStart = -1;
|
|
3435
|
-
this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint);
|
|
3436
|
-
this.maxPoint = -1;
|
|
3437
|
-
if (newArrays) {
|
|
3438
|
-
this.from = [];
|
|
3439
|
-
this.to = [];
|
|
3440
|
-
this.value = [];
|
|
3441
|
-
}
|
|
3442
|
-
}
|
|
3443
3446
|
/**
|
|
3444
3447
|
Add a range. Ranges should be added in sorted (by `from` and
|
|
3445
3448
|
`value.startSide`) order.
|
|
@@ -3799,7 +3802,7 @@ function compare(a, startA, b, startB, length, comparator) {
|
|
|
3799
3802
|
let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
|
|
3800
3803
|
if (a.point || b.point) {
|
|
3801
3804
|
if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
|
|
3802
|
-
sameValues(a.activeForPoint(a.to
|
|
3805
|
+
sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))
|
|
3803
3806
|
comparator.comparePoint(pos, clipEnd, a.point, b.point);
|
|
3804
3807
|
}
|
|
3805
3808
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemirror/state",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "Editor state data structures for the CodeMirror code editor",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "cm-runtests",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"author": {
|
|
14
14
|
"name": "Marijn Haverbeke",
|
|
15
|
-
"email": "
|
|
15
|
+
"email": "marijn@haverbeke.berlin",
|
|
16
16
|
"url": "http://marijnhaverbeke.nl"
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|