@manuscripts/track-changes-plugin 1.8.6-LEAN-4102.0 → 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
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 &&
|
|
@@ -8,16 +8,19 @@ const prosemirror_state_1 = require("prosemirror-state");
|
|
|
8
8
|
const prosemirror_transform_1 = require("prosemirror-transform");
|
|
9
9
|
const diffChangeSteps_1 = require("../change-steps/diffChangeSteps");
|
|
10
10
|
const processChangeSteps_1 = require("../change-steps/processChangeSteps");
|
|
11
|
+
const updateChangeAttrs_1 = require("../changes/updateChangeAttrs");
|
|
12
|
+
const nodeHelpers_1 = require("../compute/nodeHelpers");
|
|
11
13
|
const change_1 = require("../types/change");
|
|
12
14
|
const logger_1 = require("../utils/logger");
|
|
13
15
|
const mapChangeStep_1 = require("../utils/mapChangeStep");
|
|
16
|
+
const uuidv4_1 = require("../utils/uuidv4");
|
|
14
17
|
const trackAttrsChange_1 = __importDefault(require("./trackAttrsChange"));
|
|
15
18
|
const trackReplaceAroundStep_1 = require("./trackReplaceAroundStep");
|
|
16
19
|
const trackReplaceStep_1 = require("./trackReplaceStep");
|
|
17
20
|
const getSelectionStaticConstructor = (sel) => Object.getPrototypeOf(sel).constructor;
|
|
18
21
|
const isHighlightMarkerNode = (node) => node && node.type === node.type.schema.nodes.highlight_marker;
|
|
19
22
|
function trackTransaction(tr, oldState, newTr, authorID) {
|
|
20
|
-
var _a, _b, _c, _d;
|
|
23
|
+
var _a, _b, _c, _d, _e;
|
|
21
24
|
const emptyAttrs = {
|
|
22
25
|
authorID,
|
|
23
26
|
reviewedByID: null,
|
|
@@ -91,6 +94,12 @@ function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
91
94
|
const chnageSteps = (0, trackAttrsChange_1.default)(step, oldState, tr, newTr, emptyAttrs, tr.docs[i]);
|
|
92
95
|
const [mapping, selectionPos] = (0, processChangeSteps_1.processChangeSteps)(chnageSteps, tr.selection.from, newTr, emptyAttrs, oldState.schema);
|
|
93
96
|
}
|
|
97
|
+
else if (step instanceof prosemirror_transform_1.AddMarkStep) {
|
|
98
|
+
const dataTracked = (_e = (0, nodeHelpers_1.getNodeTrackedData)(newTr.doc.nodeAt(step.from), oldState.schema)) === null || _e === void 0 ? void 0 : _e.pop();
|
|
99
|
+
if (dataTracked) {
|
|
100
|
+
(0, updateChangeAttrs_1.updateChangeAttrs)(newTr, { id: dataTracked.id, from: step.from, to: step.to, type: 'text-change', dataTracked }, Object.assign(Object.assign({}, dataTracked), { id: (0, uuidv4_1.uuidv4)() }), oldState.schema);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
94
103
|
tr.getMeta('inputType') && newTr.setMeta('inputType', tr.getMeta('inputType'));
|
|
95
104
|
tr.getMeta('uiEvent') && newTr.setMeta('uiEvent', tr.getMeta('uiEvent'));
|
|
96
105
|
}
|
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,17 +1,20 @@
|
|
|
1
1
|
import { NodeSelection as NodeSelectionClass, TextSelection, } from 'prosemirror-state';
|
|
2
|
-
import { AttrStep, ReplaceAroundStep, ReplaceStep, } from 'prosemirror-transform';
|
|
2
|
+
import { AddMarkStep, AttrStep, ReplaceAroundStep, ReplaceStep, } from 'prosemirror-transform';
|
|
3
3
|
import { diffChangeSteps } from '../change-steps/diffChangeSteps';
|
|
4
4
|
import { processChangeSteps } from '../change-steps/processChangeSteps';
|
|
5
|
+
import { updateChangeAttrs } from '../changes/updateChangeAttrs';
|
|
6
|
+
import { getNodeTrackedData } from '../compute/nodeHelpers';
|
|
5
7
|
import { CHANGE_STATUS } from '../types/change';
|
|
6
8
|
import { log } from '../utils/logger';
|
|
7
9
|
import { mapChangeSteps } from '../utils/mapChangeStep';
|
|
10
|
+
import { uuidv4 } from '../utils/uuidv4';
|
|
8
11
|
import trackAttrsChange from './trackAttrsChange';
|
|
9
12
|
import { trackReplaceAroundStep } from './trackReplaceAroundStep';
|
|
10
13
|
import { trackReplaceStep } from './trackReplaceStep';
|
|
11
14
|
const getSelectionStaticConstructor = (sel) => Object.getPrototypeOf(sel).constructor;
|
|
12
15
|
const isHighlightMarkerNode = (node) => node && node.type === node.type.schema.nodes.highlight_marker;
|
|
13
16
|
export function trackTransaction(tr, oldState, newTr, authorID) {
|
|
14
|
-
var _a, _b, _c, _d;
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
15
18
|
const emptyAttrs = {
|
|
16
19
|
authorID,
|
|
17
20
|
reviewedByID: null,
|
|
@@ -85,6 +88,12 @@ export function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
85
88
|
const chnageSteps = trackAttrsChange(step, oldState, tr, newTr, emptyAttrs, tr.docs[i]);
|
|
86
89
|
const [mapping, selectionPos] = processChangeSteps(chnageSteps, tr.selection.from, newTr, emptyAttrs, oldState.schema);
|
|
87
90
|
}
|
|
91
|
+
else if (step instanceof AddMarkStep) {
|
|
92
|
+
const dataTracked = (_e = getNodeTrackedData(newTr.doc.nodeAt(step.from), oldState.schema)) === null || _e === void 0 ? void 0 : _e.pop();
|
|
93
|
+
if (dataTracked) {
|
|
94
|
+
updateChangeAttrs(newTr, { id: dataTracked.id, from: step.from, to: step.to, type: 'text-change', dataTracked }, Object.assign(Object.assign({}, dataTracked), { id: uuidv4() }), oldState.schema);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
88
97
|
tr.getMeta('inputType') && newTr.setMeta('inputType', tr.getMeta('inputType'));
|
|
89
98
|
tr.getMeta('uiEvent') && newTr.setMeta('uiEvent', tr.getMeta('uiEvent'));
|
|
90
99
|
}
|
|
@@ -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