@manuscripts/track-changes-plugin 1.8.6-LEAN-4102.1 → 1.8.6-LEAN-4102.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/dist/cjs/ChangeSet.js +25 -18
- package/dist/es/ChangeSet.js +25 -18
- package/dist/types/ChangeSet.d.ts +4 -3
- package/package.json +1 -1
package/dist/cjs/ChangeSet.js
CHANGED
|
@@ -38,23 +38,13 @@ class ChangeSet {
|
|
|
38
38
|
get changeTree() {
|
|
39
39
|
const rootNodes = [];
|
|
40
40
|
let currentNodeChange;
|
|
41
|
-
|
|
42
|
-
this.changes.forEach((c, index) => {
|
|
41
|
+
this.changes.forEach((c) => {
|
|
43
42
|
if (currentNodeChange &&
|
|
44
43
|
(c.from >= currentNodeChange.to ||
|
|
45
44
|
c.dataTracked.statusUpdateAt !== currentNodeChange.dataTracked.statusUpdateAt)) {
|
|
46
|
-
rootNodes.push(
|
|
45
|
+
rootNodes.push(currentNodeChange);
|
|
47
46
|
currentNodeChange = undefined;
|
|
48
47
|
}
|
|
49
|
-
if (this.canJoinAdjacentInlineChanges(c, index) && !currentNodeChange) {
|
|
50
|
-
currentInlineChange = currentInlineChange ? [...currentInlineChange, c] : [c];
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
else if (currentInlineChange) {
|
|
54
|
-
rootNodes.push([...currentInlineChange, c]);
|
|
55
|
-
currentInlineChange = undefined;
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
48
|
if (currentNodeChange &&
|
|
59
49
|
c.from < currentNodeChange.to &&
|
|
60
50
|
!(__classPrivateFieldGet(this, _ChangeSet_instances, "m", _ChangeSet_isSameNodeChange).call(this, currentNodeChange, c) && __classPrivateFieldGet(this, _ChangeSet_instances, "m", _ChangeSet_isNotPendingOrDeleted).call(this, currentNodeChange))) {
|
|
@@ -64,7 +54,7 @@ class ChangeSet {
|
|
|
64
54
|
const result = this.matchAndAddToRootChange(rootNodes, c);
|
|
65
55
|
if (result) {
|
|
66
56
|
const { index, root } = result;
|
|
67
|
-
rootNodes[index]
|
|
57
|
+
rootNodes[index] = root;
|
|
68
58
|
}
|
|
69
59
|
else {
|
|
70
60
|
currentNodeChange = Object.assign(Object.assign({}, c), { children: [] });
|
|
@@ -74,16 +64,33 @@ class ChangeSet {
|
|
|
74
64
|
const result = this.matchAndAddToRootChange(rootNodes, c);
|
|
75
65
|
if (result) {
|
|
76
66
|
const { index, root } = result;
|
|
77
|
-
rootNodes[index]
|
|
67
|
+
rootNodes[index] = root;
|
|
78
68
|
}
|
|
79
69
|
else {
|
|
80
|
-
rootNodes.push(
|
|
70
|
+
rootNodes.push(c);
|
|
81
71
|
}
|
|
82
72
|
}
|
|
83
73
|
});
|
|
84
74
|
if (currentNodeChange) {
|
|
85
|
-
rootNodes.push(
|
|
75
|
+
rootNodes.push(currentNodeChange);
|
|
86
76
|
}
|
|
77
|
+
return rootNodes;
|
|
78
|
+
}
|
|
79
|
+
get groupChanges() {
|
|
80
|
+
const rootNodes = [];
|
|
81
|
+
let currentInlineChange;
|
|
82
|
+
this.changeTree.map((change, index) => {
|
|
83
|
+
if (this.canJoinAdjacentInlineChanges(change, index)) {
|
|
84
|
+
currentInlineChange = currentInlineChange ? [...currentInlineChange, change] : [change];
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
else if (currentInlineChange) {
|
|
88
|
+
rootNodes.push([...currentInlineChange, change]);
|
|
89
|
+
currentInlineChange = undefined;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
rootNodes.push([change]);
|
|
93
|
+
});
|
|
87
94
|
return rootNodes.filter((changes) => changes.filter((c) => c.dataTracked.operation !== change_1.CHANGE_OPERATION.reference));
|
|
88
95
|
}
|
|
89
96
|
get pending() {
|
|
@@ -130,7 +137,7 @@ class ChangeSet {
|
|
|
130
137
|
}
|
|
131
138
|
matchAndAddToRootChange(rootNodes, change) {
|
|
132
139
|
for (let i = 0; i < rootNodes.length; i++) {
|
|
133
|
-
const root = rootNodes[i]
|
|
140
|
+
const root = rootNodes[i];
|
|
134
141
|
if (root.type === 'node-change' &&
|
|
135
142
|
change.from < root.to &&
|
|
136
143
|
change.dataTracked.statusUpdateAt === root.dataTracked.statusUpdateAt) {
|
|
@@ -140,7 +147,7 @@ class ChangeSet {
|
|
|
140
147
|
}
|
|
141
148
|
}
|
|
142
149
|
canJoinAdjacentInlineChanges(change, index) {
|
|
143
|
-
const nextChange = this.
|
|
150
|
+
const nextChange = this.changeTree.at(index + 1);
|
|
144
151
|
const isInline = (c) => c.type === 'text-change' || (c.type === 'node-change' && c.node.isInline);
|
|
145
152
|
return (isInline(change) &&
|
|
146
153
|
nextChange &&
|
package/dist/es/ChangeSet.js
CHANGED
|
@@ -35,23 +35,13 @@ export class ChangeSet {
|
|
|
35
35
|
get changeTree() {
|
|
36
36
|
const rootNodes = [];
|
|
37
37
|
let currentNodeChange;
|
|
38
|
-
|
|
39
|
-
this.changes.forEach((c, index) => {
|
|
38
|
+
this.changes.forEach((c) => {
|
|
40
39
|
if (currentNodeChange &&
|
|
41
40
|
(c.from >= currentNodeChange.to ||
|
|
42
41
|
c.dataTracked.statusUpdateAt !== currentNodeChange.dataTracked.statusUpdateAt)) {
|
|
43
|
-
rootNodes.push(
|
|
42
|
+
rootNodes.push(currentNodeChange);
|
|
44
43
|
currentNodeChange = undefined;
|
|
45
44
|
}
|
|
46
|
-
if (this.canJoinAdjacentInlineChanges(c, index) && !currentNodeChange) {
|
|
47
|
-
currentInlineChange = currentInlineChange ? [...currentInlineChange, c] : [c];
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
else if (currentInlineChange) {
|
|
51
|
-
rootNodes.push([...currentInlineChange, c]);
|
|
52
|
-
currentInlineChange = undefined;
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
45
|
if (currentNodeChange &&
|
|
56
46
|
c.from < currentNodeChange.to &&
|
|
57
47
|
!(__classPrivateFieldGet(this, _ChangeSet_instances, "m", _ChangeSet_isSameNodeChange).call(this, currentNodeChange, c) && __classPrivateFieldGet(this, _ChangeSet_instances, "m", _ChangeSet_isNotPendingOrDeleted).call(this, currentNodeChange))) {
|
|
@@ -61,7 +51,7 @@ export class ChangeSet {
|
|
|
61
51
|
const result = this.matchAndAddToRootChange(rootNodes, c);
|
|
62
52
|
if (result) {
|
|
63
53
|
const { index, root } = result;
|
|
64
|
-
rootNodes[index]
|
|
54
|
+
rootNodes[index] = root;
|
|
65
55
|
}
|
|
66
56
|
else {
|
|
67
57
|
currentNodeChange = Object.assign(Object.assign({}, c), { children: [] });
|
|
@@ -71,16 +61,33 @@ export class ChangeSet {
|
|
|
71
61
|
const result = this.matchAndAddToRootChange(rootNodes, c);
|
|
72
62
|
if (result) {
|
|
73
63
|
const { index, root } = result;
|
|
74
|
-
rootNodes[index]
|
|
64
|
+
rootNodes[index] = root;
|
|
75
65
|
}
|
|
76
66
|
else {
|
|
77
|
-
rootNodes.push(
|
|
67
|
+
rootNodes.push(c);
|
|
78
68
|
}
|
|
79
69
|
}
|
|
80
70
|
});
|
|
81
71
|
if (currentNodeChange) {
|
|
82
|
-
rootNodes.push(
|
|
72
|
+
rootNodes.push(currentNodeChange);
|
|
83
73
|
}
|
|
74
|
+
return rootNodes;
|
|
75
|
+
}
|
|
76
|
+
get groupChanges() {
|
|
77
|
+
const rootNodes = [];
|
|
78
|
+
let currentInlineChange;
|
|
79
|
+
this.changeTree.map((change, index) => {
|
|
80
|
+
if (this.canJoinAdjacentInlineChanges(change, index)) {
|
|
81
|
+
currentInlineChange = currentInlineChange ? [...currentInlineChange, change] : [change];
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
else if (currentInlineChange) {
|
|
85
|
+
rootNodes.push([...currentInlineChange, change]);
|
|
86
|
+
currentInlineChange = undefined;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
rootNodes.push([change]);
|
|
90
|
+
});
|
|
84
91
|
return rootNodes.filter((changes) => changes.filter((c) => c.dataTracked.operation !== CHANGE_OPERATION.reference));
|
|
85
92
|
}
|
|
86
93
|
get pending() {
|
|
@@ -127,7 +134,7 @@ export class ChangeSet {
|
|
|
127
134
|
}
|
|
128
135
|
matchAndAddToRootChange(rootNodes, change) {
|
|
129
136
|
for (let i = 0; i < rootNodes.length; i++) {
|
|
130
|
-
const root = rootNodes[i]
|
|
137
|
+
const root = rootNodes[i];
|
|
131
138
|
if (root.type === 'node-change' &&
|
|
132
139
|
change.from < root.to &&
|
|
133
140
|
change.dataTracked.statusUpdateAt === root.dataTracked.statusUpdateAt) {
|
|
@@ -137,7 +144,7 @@ export class ChangeSet {
|
|
|
137
144
|
}
|
|
138
145
|
}
|
|
139
146
|
canJoinAdjacentInlineChanges(change, index) {
|
|
140
|
-
const nextChange = this.
|
|
147
|
+
const nextChange = this.changeTree.at(index + 1);
|
|
141
148
|
const isInline = (c) => c.type === 'text-change' || (c.type === 'node-change' && c.node.isInline);
|
|
142
149
|
return (isInline(change) &&
|
|
143
150
|
nextChange &&
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { IncompleteChange, NodeAttrChange, NodeChange, ReferenceChange,
|
|
1
|
+
import { IncompleteChange, NodeAttrChange, NodeChange, ReferenceChange, TextChange, TrackedAttrs, TrackedChange } from './types/change';
|
|
2
2
|
export declare class ChangeSet {
|
|
3
3
|
#private;
|
|
4
4
|
constructor(changes?: (TrackedChange | IncompleteChange)[]);
|
|
5
5
|
get changes(): TrackedChange[];
|
|
6
6
|
get invalidChanges(): (TrackedChange | IncompleteChange)[];
|
|
7
|
-
get changeTree(): TrackedChange[]
|
|
7
|
+
get changeTree(): TrackedChange[];
|
|
8
|
+
get groupChanges(): TrackedChange[][];
|
|
8
9
|
get pending(): TrackedChange[];
|
|
9
10
|
get textChanges(): TrackedChange[];
|
|
10
11
|
get nodeChanges(): TrackedChange[];
|
|
@@ -17,7 +18,7 @@ export declare class ChangeSet {
|
|
|
17
18
|
get(id: string): TrackedChange | IncompleteChange | undefined;
|
|
18
19
|
getIn(ids: string[]): (TrackedChange | IncompleteChange)[];
|
|
19
20
|
getNotIn(ids: string[]): (TrackedChange | IncompleteChange)[];
|
|
20
|
-
matchAndAddToRootChange(rootNodes:
|
|
21
|
+
matchAndAddToRootChange(rootNodes: TrackedChange[], change: TrackedChange): {
|
|
21
22
|
index: number;
|
|
22
23
|
root: NodeChange;
|
|
23
24
|
} | undefined;
|
package/package.json
CHANGED