prosemirror-changeset 2.1.0 → 2.2.0-beta.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 +12 -0
- package/README.md +28 -22
- package/dist/index.cjs +696 -0
- package/dist/index.d.ts +118 -0
- package/dist/{changeset.js → index.es.js} +11 -18
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +679 -0
- package/dist/index.js.map +1 -0
- package/package.json +18 -18
- package/src/{change.js → change.ts} +63 -53
- package/src/{changeset.js → changeset.ts} +73 -67
- package/src/{diff.js → diff.ts} +10 -8
- package/src/{simplify.js → simplify.ts} +17 -17
- package/test/{test-changed-range.js → test-changed-range.ts} +8 -7
- package/test/{test-changes.js → test-changes.ts} +10 -8
- package/test/{test-diff.js → test-diff.ts} +6 -5
- package/test/{test-merge.js → test-merge.ts} +4 -4
- package/test/{test-simplify.js → test-simplify.ts} +7 -6
- package/dist/changeset.js.map +0 -1
- package/rollup.config.js +0 -12
- package/test/mocha.opts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 2.1.2 (2019-11-20)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Rename ES module files to use a .js extension, since Webpack gets confused by .mjs
|
|
6
|
+
|
|
7
|
+
## 2.1.1 (2019-11-19)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
The file referred to in the package's `module` field now is compiled down to ES5.
|
|
12
|
+
|
|
1
13
|
## 2.1.0 (2019-11-08)
|
|
2
14
|
|
|
3
15
|
### New features
|
package/README.md
CHANGED
|
@@ -19,13 +19,12 @@ It is possible to associate arbitrary data values with such spans, for
|
|
|
19
19
|
example to track the user that made the change, the timestamp at which
|
|
20
20
|
it was made, or the step data necessary to invert it again.
|
|
21
21
|
|
|
22
|
-
### class Change
|
|
22
|
+
### class Change`<Data = any>`
|
|
23
23
|
|
|
24
24
|
A replaced range with metadata associated with it.
|
|
25
25
|
|
|
26
26
|
* **`fromA`**`: number`\
|
|
27
|
-
The start of the range deleted/replaced in the old
|
|
28
|
-
document.
|
|
27
|
+
The start of the range deleted/replaced in the old document.
|
|
29
28
|
|
|
30
29
|
* **`toA`**`: number`\
|
|
31
30
|
The end of the range in the old document.
|
|
@@ -36,35 +35,42 @@ A replaced range with metadata associated with it.
|
|
|
36
35
|
* **`toB`**`: number`\
|
|
37
36
|
The end of the range in the new document.
|
|
38
37
|
|
|
39
|
-
* **`deleted`**`: [
|
|
40
|
-
Data associated with the deleted content. The length
|
|
41
|
-
|
|
38
|
+
* **`deleted`**`: readonly Span[]`\
|
|
39
|
+
Data associated with the deleted content. The length of these
|
|
40
|
+
spans adds up to `this.toA - this.fromA`.
|
|
42
41
|
|
|
43
|
-
* **`inserted`**`: [
|
|
44
|
-
Data associated with the inserted content. Length
|
|
45
|
-
|
|
42
|
+
* **`inserted`**`: readonly Span[]`\
|
|
43
|
+
Data associated with the inserted content. Length adds up to
|
|
44
|
+
`this.toB - this.toA`.
|
|
46
45
|
|
|
46
|
+
* `static `**`merge`**`<Data>(x: readonly Change[], y: readonly Change[], combine: fn(dataA: Data, dataB: Data) → Data) → readonly Change[]`\
|
|
47
|
+
This merges two changesets (the end document of x should be the
|
|
48
|
+
start document of y) into a single one spanning the start of x to
|
|
49
|
+
the end of y.
|
|
47
50
|
|
|
48
|
-
|
|
51
|
+
|
|
52
|
+
### class Span`<Data = any>`
|
|
49
53
|
|
|
50
54
|
Stores metadata for a part of a change.
|
|
51
55
|
|
|
52
|
-
* **`length`**`: number
|
|
56
|
+
* **`length`**`: number`\
|
|
57
|
+
The length of this span.
|
|
53
58
|
|
|
54
|
-
* **`data`**`:
|
|
59
|
+
* **`data`**`: Data`\
|
|
60
|
+
The data associated with this span.
|
|
55
61
|
|
|
56
62
|
|
|
57
|
-
### class ChangeSet
|
|
63
|
+
### class ChangeSet`<Data = any>`
|
|
58
64
|
|
|
59
|
-
A change set tracks the changes to a document from a given
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
A change set tracks the changes to a document from a given point
|
|
66
|
+
in the past. It condenses a number of step maps down to a flat
|
|
67
|
+
sequence of replacements, and simplifies replacments that
|
|
62
68
|
partially undo themselves by comparing their content.
|
|
63
69
|
|
|
64
|
-
* **`changes`**`: [
|
|
70
|
+
* **`changes`**`: readonly Change[]`\
|
|
65
71
|
Replaced regions.
|
|
66
72
|
|
|
67
|
-
* **`addSteps`**`(newDoc: Node, maps: [
|
|
73
|
+
* **`addSteps`**`(newDoc: Node, maps: readonly StepMap[], data: Data | readonly Data[]) → ChangeSet`\
|
|
68
74
|
Computes a new changeset by adding the given step maps and
|
|
69
75
|
metadata (either as an array, per-map, or as a single value to be
|
|
70
76
|
associated with all maps) to the current set. Will not mutate the
|
|
@@ -79,25 +85,25 @@ partially undo themselves by comparing their content.
|
|
|
79
85
|
* **`startDoc`**`: Node`\
|
|
80
86
|
The starting document of the change set.
|
|
81
87
|
|
|
82
|
-
* **`map`**`(f: fn(range:
|
|
88
|
+
* **`map`**`(f: fn(range: Span) → Data) → ChangeSet`\
|
|
83
89
|
Map the span's data values in the given set through a function
|
|
84
90
|
and construct a new set with the resulting data.
|
|
85
91
|
|
|
86
|
-
* **`changedRange`**`(b: ChangeSet, maps
|
|
92
|
+
* **`changedRange`**`(b: ChangeSet, maps?: readonly StepMap[]) → {from: number, to: number}`\
|
|
87
93
|
Compare two changesets and return the range in which they are
|
|
88
94
|
changed, if any. If the document changed between the maps, pass
|
|
89
95
|
the maps for the steps that changed it as second argument, and
|
|
90
96
|
make sure the method is called on the old set and passed the new
|
|
91
97
|
set. The returned positions will be in new document coordinates.
|
|
92
98
|
|
|
93
|
-
* `static `**`create
|
|
99
|
+
* `static `**`create`**`<Data = any>(doc: Node, combine?: fn(dataA: Data, dataB: Data) → Data = (a, b) => a === b ? a : null as any) → ChangeSet`\
|
|
94
100
|
Create a changeset with the given base object and configuration.
|
|
95
101
|
The `combine` function is used to compare and combine metadata—it
|
|
96
102
|
should return null when metadata isn't compatible, and a combined
|
|
97
103
|
version for a merged range when it is.
|
|
98
104
|
|
|
99
105
|
|
|
100
|
-
* **`simplifyChanges`**`(changes: [
|
|
106
|
+
* **`simplifyChanges`**`(changes: readonly Change[], doc: Node) → Change[]`\
|
|
101
107
|
Simplifies a set of changes for presentation. This makes the
|
|
102
108
|
assumption that having both insertions and deletions within a word
|
|
103
109
|
is confusing, and, when such changes occur without a word boundary
|