@manuscripts/track-changes-plugin 2.0.10 → 2.0.12
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 +17 -0
- package/dist/cjs/actions.js +2 -0
- package/dist/cjs/change-steps/processChangeSteps.js +16 -9
- package/dist/cjs/changes/applyChanges.js +56 -12
- package/dist/cjs/changes/updateChangeAttrs.js +7 -0
- package/dist/cjs/changes/updateChangesStatus.js +2 -2
- package/dist/cjs/compute/setFragmentAsInserted.js +2 -2
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/mutate/deleteNode.js +20 -2
- package/dist/cjs/mutate/dropStructureChange.js +106 -0
- package/dist/cjs/steps/trackReplaceStep.js +13 -8
- package/dist/cjs/steps/trackTransaction.js +30 -7
- package/dist/cjs/types/change.js +1 -0
- package/dist/cjs/utils/track-utils.js +35 -4
- package/dist/es/ChangeSet.js +17 -0
- package/dist/es/actions.js +2 -0
- package/dist/es/change-steps/processChangeSteps.js +16 -9
- package/dist/es/changes/applyChanges.js +58 -14
- package/dist/es/changes/updateChangeAttrs.js +6 -0
- package/dist/es/changes/updateChangesStatus.js +2 -2
- package/dist/es/compute/setFragmentAsInserted.js +2 -2
- package/dist/es/index.js +1 -1
- package/dist/es/mutate/deleteNode.js +18 -2
- package/dist/es/mutate/dropStructureChange.js +100 -0
- package/dist/es/steps/trackReplaceStep.js +14 -9
- package/dist/es/steps/trackTransaction.js +31 -8
- package/dist/es/types/change.js +1 -0
- package/dist/es/utils/track-utils.js +31 -3
- package/dist/types/ChangeSet.d.ts +2 -1
- package/dist/types/actions.d.ts +8 -2
- package/dist/types/changes/updateChangeAttrs.d.ts +1 -0
- package/dist/types/compute/setFragmentAsInserted.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/mutate/deleteNode.d.ts +1 -0
- package/dist/types/mutate/dropStructureChange.d.ts +6 -0
- package/dist/types/types/change.d.ts +8 -2
- package/dist/types/types/track.d.ts +6 -2
- package/dist/types/utils/track-utils.d.ts +6 -3
- package/package.json +1 -1
package/dist/cjs/ChangeSet.js
CHANGED
|
@@ -89,6 +89,9 @@ class ChangeSet {
|
|
|
89
89
|
currentInlineChange = undefined;
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
+
if (this.joinRelatedStructuralChanges(rootNodes, change)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
92
95
|
rootNodes.push([change]);
|
|
93
96
|
});
|
|
94
97
|
return rootNodes.filter((changes) => changes.filter((c) => c.dataTracked.operation !== change_1.CHANGE_OPERATION.reference &&
|
|
@@ -161,6 +164,20 @@ class ChangeSet {
|
|
|
161
164
|
change.to === nextChange.from &&
|
|
162
165
|
hasMatchingOperation(change, nextChange));
|
|
163
166
|
}
|
|
167
|
+
joinRelatedStructuralChanges(rootNodes, change) {
|
|
168
|
+
if (change.dataTracked.operation !== change_1.CHANGE_OPERATION.structure) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const index = rootNodes.findIndex((c) => c[0].dataTracked.operation === change_1.CHANGE_OPERATION.structure &&
|
|
172
|
+
c[0].dataTracked.moveNodeId === change.dataTracked.moveNodeId);
|
|
173
|
+
if (index !== -1) {
|
|
174
|
+
rootNodes[index] = [...rootNodes[index], change];
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
rootNodes.push([change]);
|
|
178
|
+
}
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
164
181
|
static flattenTreeToIds(changes) {
|
|
165
182
|
return changes.flatMap((c) => (this.isNodeChange(c) ? [c.id, ...c.children.map((c) => c.id)] : c.id));
|
|
166
183
|
}
|
package/dist/cjs/actions.js
CHANGED
|
@@ -12,6 +12,8 @@ var TrackChangesAction;
|
|
|
12
12
|
TrackChangesAction["setChangeStatuses"] = "track-changes-set-change-statuses";
|
|
13
13
|
TrackChangesAction["refreshChanges"] = "track-changes-refresh-changes";
|
|
14
14
|
TrackChangesAction["updateMetaNode"] = "track-changes-update-meta-node";
|
|
15
|
+
TrackChangesAction["structuralChangeAction"] = "track-changes-structural-change-action";
|
|
16
|
+
TrackChangesAction["indentationAction"] = "track-changes-indentation-action";
|
|
15
17
|
})(TrackChangesAction || (exports.TrackChangesAction = TrackChangesAction = {}));
|
|
16
18
|
function hasAction(tr) {
|
|
17
19
|
return Object.values(TrackChangesAction).some((action) => !!tr.getMeta(action));
|
|
@@ -59,7 +59,7 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema, delete
|
|
|
59
59
|
let selectionPos = startPos;
|
|
60
60
|
let deletesCounter = 0;
|
|
61
61
|
let isInserted = false;
|
|
62
|
-
let
|
|
62
|
+
let prevDelete;
|
|
63
63
|
changes.forEach((c) => {
|
|
64
64
|
let step = newTr.steps[newTr.steps.length - 1];
|
|
65
65
|
switch (c.type) {
|
|
@@ -68,10 +68,12 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema, delete
|
|
|
68
68
|
const prevDeletedNodeInserted = isInserted;
|
|
69
69
|
const trackedData = (0, nodeHelpers_1.getBlockInlineTrackedData)(c.node);
|
|
70
70
|
const inserted = trackedData === null || trackedData === void 0 ? void 0 : trackedData.find((d) => d.operation === change_1.CHANGE_OPERATION.insert);
|
|
71
|
-
|
|
71
|
+
const structure = trackedData === null || trackedData === void 0 ? void 0 : trackedData.find((c) => c.operation === change_1.CHANGE_OPERATION.structure &&
|
|
72
|
+
deleteAttrs.moveNodeId &&
|
|
73
|
+
c.moveNodeId !== deleteAttrs.moveNodeId);
|
|
72
74
|
let childOfDeleted = false;
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
+
if (prevDelete) {
|
|
76
|
+
prevDelete.node.descendants((node) => {
|
|
75
77
|
if (childOfDeleted) {
|
|
76
78
|
return false;
|
|
77
79
|
}
|
|
@@ -80,15 +82,20 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema, delete
|
|
|
80
82
|
}
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
const isMoveOperation = !!emptyAttrs.moveNodeId;
|
|
86
|
+
if ((prevDelete &&
|
|
87
|
+
c.pos < prevDelete.nodeEnd &&
|
|
88
|
+
isInserted &&
|
|
89
|
+
deletesCounter > 1 &&
|
|
90
|
+
!isMoveOperation) ||
|
|
91
|
+
(childOfDeleted && prevDeletedNodeInserted)) {
|
|
86
92
|
return false;
|
|
87
93
|
}
|
|
88
94
|
(0, deleteNode_1.deleteOrSetNodeDeleted)(c.node, mapping.map(c.pos), newTr, deleteAttrs);
|
|
89
|
-
|
|
95
|
+
prevDelete = c;
|
|
96
|
+
isInserted = !!inserted || !!structure || (!trackedData && isInserted);
|
|
90
97
|
const newestStep = newTr.steps[newTr.steps.length - 1];
|
|
91
|
-
if (isInserted) {
|
|
98
|
+
if (isInserted || structure) {
|
|
92
99
|
deletedNodeMapping.appendMap(newestStep.getMap());
|
|
93
100
|
}
|
|
94
101
|
if (step !== newestStep) {
|
|
@@ -10,6 +10,21 @@ const change_1 = require("../types/change");
|
|
|
10
10
|
const logger_1 = require("../utils/logger");
|
|
11
11
|
const revertChange_1 = require("./revertChange");
|
|
12
12
|
const updateChangeAttrs_1 = require("./updateChangeAttrs");
|
|
13
|
+
function collectMoveNodeIds(containerNode, primaryMoveNodeId) {
|
|
14
|
+
const moveNodeIds = new Set();
|
|
15
|
+
moveNodeIds.add(primaryMoveNodeId);
|
|
16
|
+
containerNode.descendants((childNode) => {
|
|
17
|
+
const dataTracked = childNode.attrs.dataTracked;
|
|
18
|
+
if (Array.isArray(dataTracked)) {
|
|
19
|
+
dataTracked.forEach((trackingData) => {
|
|
20
|
+
if (trackingData.moveNodeId) {
|
|
21
|
+
moveNodeIds.add(trackingData.moveNodeId);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return moveNodeIds;
|
|
27
|
+
}
|
|
13
28
|
function getUpdatedDataTracked(dataTracked, changeId) {
|
|
14
29
|
if (!dataTracked) {
|
|
15
30
|
return null;
|
|
@@ -26,7 +41,11 @@ function applyAcceptedRejectedChanges(tr, schema, changes, changeSet, deleteMap
|
|
|
26
41
|
return c1.dataTracked.updatedAt - c2.dataTracked.updatedAt;
|
|
27
42
|
});
|
|
28
43
|
changes.forEach((change) => {
|
|
29
|
-
if (change.dataTracked.operation === change_1.CHANGE_OPERATION.move
|
|
44
|
+
if (change.dataTracked.operation === change_1.CHANGE_OPERATION.move ||
|
|
45
|
+
change.dataTracked.operation === change_1.CHANGE_OPERATION.structure) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (change.dataTracked.operation === change_1.CHANGE_OPERATION.delete && change.dataTracked.moveNodeId) {
|
|
30
49
|
return;
|
|
31
50
|
}
|
|
32
51
|
const { pos: from, deleted } = deleteMap.mapResult(change.from);
|
|
@@ -56,7 +75,7 @@ function applyAcceptedRejectedChanges(tr, schema, changes, changeSet, deleteMap
|
|
|
56
75
|
deleteMap.appendMap(tr.steps[tr.steps.length - 1].getMap());
|
|
57
76
|
}
|
|
58
77
|
else if (ChangeSet_1.ChangeSet.isNodeChange(change) && noChangeNeeded) {
|
|
59
|
-
const attrs = Object.assign(Object.assign({}, node.attrs), { dataTracked:
|
|
78
|
+
const attrs = Object.assign(Object.assign({}, node.attrs), { dataTracked: (0, deleteNode_1.keepDeleteWithMoveNodeId)(node) });
|
|
60
79
|
tr.setNodeMarkup(from, undefined, attrs, node.marks);
|
|
61
80
|
if (node.isAtom) {
|
|
62
81
|
tr.removeMark(from, deleteMap.map(change.to), schema.marks.tracked_insert);
|
|
@@ -82,7 +101,8 @@ function applyAcceptedRejectedChanges(tr, schema, changes, changeSet, deleteMap
|
|
|
82
101
|
}
|
|
83
102
|
});
|
|
84
103
|
changes.forEach((change) => {
|
|
85
|
-
if (change.dataTracked.operation !== change_1.CHANGE_OPERATION.move
|
|
104
|
+
if (change.dataTracked.operation !== change_1.CHANGE_OPERATION.move &&
|
|
105
|
+
change.dataTracked.operation !== change_1.CHANGE_OPERATION.structure) {
|
|
86
106
|
return;
|
|
87
107
|
}
|
|
88
108
|
const { pos: from, deleted } = deleteMap.mapResult(change.from);
|
|
@@ -94,25 +114,49 @@ function applyAcceptedRejectedChanges(tr, schema, changes, changeSet, deleteMap
|
|
|
94
114
|
return;
|
|
95
115
|
}
|
|
96
116
|
if (change.dataTracked.status === change_1.CHANGE_STATUS.accepted) {
|
|
97
|
-
const
|
|
117
|
+
const attrs = Object.assign(Object.assign({}, node.attrs), { dataTracked: getUpdatedDataTracked(node.attrs.dataTracked, change.id) });
|
|
118
|
+
tr.setNodeMarkup(from, undefined, attrs, node.marks);
|
|
119
|
+
const originalChanges = changeSet.changes.filter((c) => c.dataTracked.moveNodeId === change.dataTracked.moveNodeId &&
|
|
98
120
|
c.dataTracked.operation === change_1.CHANGE_OPERATION.delete);
|
|
99
|
-
if (
|
|
100
|
-
|
|
121
|
+
if (originalChanges.length === 0) {
|
|
122
|
+
logger_1.log.warn('No original change found for move operation', { change });
|
|
123
|
+
}
|
|
124
|
+
originalChanges.forEach((originalChange) => {
|
|
125
|
+
const { pos: originalFrom, deleted } = deleteMap.mapResult(originalChange.from);
|
|
126
|
+
if (deleted) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
101
129
|
const originalNode = tr.doc.nodeAt(originalFrom);
|
|
102
|
-
const attrs = Object.assign(Object.assign({}, node.attrs), { dataTracked: getUpdatedDataTracked(node.attrs.dataTracked, change.id) });
|
|
103
|
-
tr.setNodeMarkup(from, undefined, attrs, node.marks);
|
|
104
130
|
if (originalNode) {
|
|
105
131
|
tr.delete(originalFrom, originalFrom + originalNode.nodeSize);
|
|
106
132
|
deleteMap.appendMap(tr.steps[tr.steps.length - 1].getMap());
|
|
107
133
|
}
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
logger_1.log.warn('No original change found for move operation', { change });
|
|
111
|
-
}
|
|
134
|
+
});
|
|
112
135
|
}
|
|
113
136
|
else if (change.dataTracked.status === change_1.CHANGE_STATUS.rejected) {
|
|
137
|
+
const moveNodeIdsToRestore = collectMoveNodeIds(node, change.dataTracked.moveNodeId);
|
|
114
138
|
tr.delete(from, from + node.nodeSize);
|
|
115
139
|
deleteMap.appendMap(tr.steps[tr.steps.length - 1].getMap());
|
|
140
|
+
changeSet.changes
|
|
141
|
+
.filter((c) => c.dataTracked.operation === change_1.CHANGE_OPERATION.delete &&
|
|
142
|
+
c.dataTracked.moveNodeId &&
|
|
143
|
+
moveNodeIdsToRestore.has(c.dataTracked.moveNodeId) &&
|
|
144
|
+
ChangeSet_1.ChangeSet.isNodeChange(c))
|
|
145
|
+
.forEach((orig) => {
|
|
146
|
+
const { pos } = deleteMap.mapResult(orig.from);
|
|
147
|
+
const node = tr.doc.nodeAt(pos);
|
|
148
|
+
if (!node) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const dataTracked = node.attrs.dataTracked || [];
|
|
152
|
+
const hasMoved = dataTracked.some((d) => d.operation === change_1.CHANGE_OPERATION.move && d.status === change_1.CHANGE_STATUS.pending);
|
|
153
|
+
if (hasMoved) {
|
|
154
|
+
tr.delete(pos, pos + node.nodeSize);
|
|
155
|
+
deleteMap.appendMap(tr.steps[tr.steps.length - 1].getMap());
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
(0, updateChangeAttrs_1.restoreNode)(tr, node, pos, schema);
|
|
159
|
+
});
|
|
116
160
|
}
|
|
117
161
|
});
|
|
118
162
|
return deleteMap;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateChangeAttrs = updateChangeAttrs;
|
|
4
4
|
exports.updateChangeChildrenAttributes = updateChangeChildrenAttributes;
|
|
5
|
+
exports.restoreNode = restoreNode;
|
|
5
6
|
const ChangeSet_1 = require("../ChangeSet");
|
|
6
7
|
const nodeHelpers_1 = require("../compute/nodeHelpers");
|
|
7
8
|
const change_1 = require("../types/change");
|
|
@@ -83,3 +84,9 @@ function updateChangeChildrenAttributes(changes, tr, mapping) {
|
|
|
83
84
|
}
|
|
84
85
|
});
|
|
85
86
|
}
|
|
87
|
+
function restoreNode(tr, node, pos, schema) {
|
|
88
|
+
const updatedAttrs = Object.assign(Object.assign({}, node.attrs), { dataTracked: null });
|
|
89
|
+
tr.setNodeMarkup(pos, undefined, updatedAttrs, node.marks);
|
|
90
|
+
tr.removeMark(pos, pos + node.nodeSize, schema.marks.tracked_insert);
|
|
91
|
+
tr.removeMark(pos, pos + node.nodeSize, schema.marks.tracked_delete);
|
|
92
|
+
}
|
|
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.updateChangesStatus = updateChangesStatus;
|
|
19
19
|
const prosemirror_history_1 = require("prosemirror-history");
|
|
20
20
|
const ChangeSet_1 = require("../ChangeSet");
|
|
21
|
+
const dropStructureChange_1 = require("../mutate/dropStructureChange");
|
|
21
22
|
const change_1 = require("../types/change");
|
|
22
23
|
const applyChanges_1 = require("./applyChanges");
|
|
23
24
|
const updateChangeAttrs_1 = require("./updateChangeAttrs");
|
|
@@ -46,9 +47,7 @@ function updateChangesStatus(createdTr, changeSet, ids, status, userID, oldState
|
|
|
46
47
|
c.dataTracked.operation === 'delete' &&
|
|
47
48
|
c.dataTracked.moveNodeId === change.dataTracked.moveNodeId);
|
|
48
49
|
if (oldChange && ChangeSet_1.ChangeSet.isNodeChange(oldChange)) {
|
|
49
|
-
createdTr = (0, updateChangeAttrs_1.updateChangeAttrs)(createdTr, oldChange, Object.assign(Object.assign({}, oldChange.dataTracked), { status, statusUpdateAt: changeTime, reviewedByID: userID }), oldState.schema);
|
|
50
50
|
oldChange.children.forEach((child) => {
|
|
51
|
-
createdTr = (0, updateChangeAttrs_1.updateChangeAttrs)(createdTr, child, Object.assign(Object.assign({}, child.dataTracked), { status, statusUpdateAt: changeTime, reviewedByID: userID }), oldState.schema);
|
|
52
51
|
if (ChangeSet_1.ChangeSet.isTextChange(child)) {
|
|
53
52
|
textChanges.push(child);
|
|
54
53
|
}
|
|
@@ -64,6 +63,7 @@ function updateChangesStatus(createdTr, changeSet, ids, status, userID, oldState
|
|
|
64
63
|
});
|
|
65
64
|
const mapping = (0, applyChanges_1.applyAcceptedRejectedChanges)(createdTr, oldState.schema, nonTextChanges, changeSet);
|
|
66
65
|
(0, applyChanges_1.applyAcceptedRejectedChanges)(createdTr, oldState.schema, textChanges, changeSet, mapping);
|
|
66
|
+
(0, dropStructureChange_1.dropOrphanChanges)(createdTr);
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
69
|
ids.forEach((changeId) => {
|
|
@@ -95,10 +95,10 @@ function setFragmentAsWrapChange(inserted, attrs, schema) {
|
|
|
95
95
|
});
|
|
96
96
|
return prosemirror_model_1.Fragment.from(content);
|
|
97
97
|
}
|
|
98
|
-
function setFragmentAsMoveChange(fragment,
|
|
98
|
+
function setFragmentAsMoveChange(fragment, moveAttrs) {
|
|
99
99
|
const content = [];
|
|
100
100
|
fragment.forEach((node) => {
|
|
101
|
-
content.push(node.type.create(Object.assign(Object.assign({}, node.attrs), { dataTracked: [(0, nodeHelpers_1.addTrackIdIfDoesntExist)(
|
|
101
|
+
content.push(node.type.create(Object.assign(Object.assign({}, node.attrs), { dataTracked: [(0, nodeHelpers_1.addTrackIdIfDoesntExist)(moveAttrs)] }), node.content, node.marks));
|
|
102
102
|
});
|
|
103
103
|
return prosemirror_model_1.Fragment.from(content);
|
|
104
104
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -36,12 +36,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.ChangeSet = exports.enableDebug = exports.trackCommands = exports.skipTracking = exports.trackChangesPlugin = exports.trackChangesPluginKey = void 0;
|
|
39
|
+
exports.ChangeSet = exports.enableDebug = exports.trackCommands = exports.TrackChangesAction = exports.setAction = exports.skipTracking = exports.trackChangesPlugin = exports.trackChangesPluginKey = void 0;
|
|
40
40
|
var plugin_1 = require("./plugin");
|
|
41
41
|
Object.defineProperty(exports, "trackChangesPluginKey", { enumerable: true, get: function () { return plugin_1.trackChangesPluginKey; } });
|
|
42
42
|
Object.defineProperty(exports, "trackChangesPlugin", { enumerable: true, get: function () { return plugin_1.trackChangesPlugin; } });
|
|
43
43
|
var actions_1 = require("./actions");
|
|
44
44
|
Object.defineProperty(exports, "skipTracking", { enumerable: true, get: function () { return actions_1.skipTracking; } });
|
|
45
|
+
Object.defineProperty(exports, "setAction", { enumerable: true, get: function () { return actions_1.setAction; } });
|
|
46
|
+
Object.defineProperty(exports, "TrackChangesAction", { enumerable: true, get: function () { return actions_1.TrackChangesAction; } });
|
|
45
47
|
exports.trackCommands = __importStar(require("./commands"));
|
|
46
48
|
var logger_1 = require("./utils/logger");
|
|
47
49
|
Object.defineProperty(exports, "enableDebug", { enumerable: true, get: function () { return logger_1.enableDebug; } });
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keepDeleteWithMoveNodeId = void 0;
|
|
3
4
|
exports.deleteNode = deleteNode;
|
|
4
5
|
exports.deleteOrSetNodeDeleted = deleteOrSetNodeDeleted;
|
|
5
6
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
6
7
|
const nodeHelpers_1 = require("../compute/nodeHelpers");
|
|
7
8
|
const change_1 = require("../types/change");
|
|
8
9
|
const logger_1 = require("../utils/logger");
|
|
10
|
+
const dropStructureChange_1 = require("./dropStructureChange");
|
|
9
11
|
function deleteNode(node, pos, tr) {
|
|
10
12
|
var _a;
|
|
11
13
|
const startPos = tr.doc.resolve(pos + 1);
|
|
@@ -22,7 +24,14 @@ function deleteOrSetNodeDeleted(node, pos, newTr, deleteAttrs) {
|
|
|
22
24
|
const dataTracked = (0, nodeHelpers_1.getBlockInlineTrackedData)(node);
|
|
23
25
|
const inserted = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => (d.operation === change_1.CHANGE_OPERATION.insert || d.operation === change_1.CHANGE_OPERATION.wrap_with_node) &&
|
|
24
26
|
(d.status === change_1.CHANGE_STATUS.pending || d.status === change_1.CHANGE_STATUS.accepted));
|
|
25
|
-
const updated = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === change_1.CHANGE_OPERATION.set_node_attributes ||
|
|
27
|
+
const updated = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === change_1.CHANGE_OPERATION.set_node_attributes ||
|
|
28
|
+
d.operation === change_1.CHANGE_OPERATION.reference ||
|
|
29
|
+
(d.operation === change_1.CHANGE_OPERATION.delete && d.moveNodeId));
|
|
30
|
+
const structure = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((c) => c.operation === change_1.CHANGE_OPERATION.structure);
|
|
31
|
+
if (deleteAttrs.moveNodeId && structure && structure.moveNodeId !== deleteAttrs.moveNodeId) {
|
|
32
|
+
return newTr.delete(pos, pos + node.nodeSize);
|
|
33
|
+
}
|
|
34
|
+
const moved = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === change_1.CHANGE_OPERATION.move && d.status === change_1.CHANGE_STATUS.pending);
|
|
26
35
|
if (inserted) {
|
|
27
36
|
return deleteNode(node, pos, newTr);
|
|
28
37
|
}
|
|
@@ -35,5 +44,14 @@ function deleteOrSetNodeDeleted(node, pos, newTr, deleteAttrs) {
|
|
|
35
44
|
return;
|
|
36
45
|
}
|
|
37
46
|
const newDeleted = (0, nodeHelpers_1.addTrackIdIfDoesntExist)(deleteAttrs);
|
|
38
|
-
newTr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, node.attrs), { dataTracked: updated ? [newDeleted, updated] : [newDeleted] }), node.marks);
|
|
47
|
+
newTr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, node.attrs), { dataTracked: updated ? [newDeleted, updated] : moved ? [newDeleted, moved] : [newDeleted] }), node.marks);
|
|
48
|
+
if (!deleteAttrs.moveNodeId && (structure === null || structure === void 0 ? void 0 : structure.moveNodeId)) {
|
|
49
|
+
(0, dropStructureChange_1.dropStructuralChangeShadow)(structure.moveNodeId, newTr);
|
|
50
|
+
}
|
|
39
51
|
}
|
|
52
|
+
const keepDeleteWithMoveNodeId = (node) => {
|
|
53
|
+
var _a;
|
|
54
|
+
const dataTracked = (_a = (0, nodeHelpers_1.getBlockInlineTrackedData)(node)) === null || _a === void 0 ? void 0 : _a.filter((c) => c.operation === change_1.CHANGE_OPERATION.delete && c.moveNodeId);
|
|
55
|
+
return (dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.length) ? dataTracked : null;
|
|
56
|
+
};
|
|
57
|
+
exports.keepDeleteWithMoveNodeId = keepDeleteWithMoveNodeId;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.joinStructureChanges = exports.dropOrphanChanges = exports.dropStructuralChangeShadow = void 0;
|
|
15
|
+
const prosemirror_model_1 = require("prosemirror-model");
|
|
16
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
17
|
+
const findChanges_1 = require("../changes/findChanges");
|
|
18
|
+
const updateChangeAttrs_1 = require("../changes/updateChangeAttrs");
|
|
19
|
+
const nodeHelpers_1 = require("../compute/nodeHelpers");
|
|
20
|
+
const setFragmentAsInserted_1 = require("../compute/setFragmentAsInserted");
|
|
21
|
+
const change_1 = require("../types/change");
|
|
22
|
+
const track_utils_1 = require("../utils/track-utils");
|
|
23
|
+
const dropStructuralChangeShadow = (moveNodeId, tr) => {
|
|
24
|
+
const changeSet = (0, findChanges_1.findChanges)(prosemirror_state_1.EditorState.create({ doc: tr.doc }));
|
|
25
|
+
const changes = changeSet.changes.filter((c) => c.type === 'node-change' && c.dataTracked.moveNodeId === moveNodeId);
|
|
26
|
+
const shadow = changes.filter((c) => c.dataTracked.operation === change_1.CHANGE_OPERATION.delete);
|
|
27
|
+
const structures = changes.filter((c) => c.dataTracked.operation === change_1.CHANGE_OPERATION.structure);
|
|
28
|
+
structures.map((c) => {
|
|
29
|
+
tr.setNodeMarkup(c.from, undefined, Object.assign(Object.assign({}, c.node.attrs), { dataTracked: null }));
|
|
30
|
+
});
|
|
31
|
+
if (shadow.length > 0) {
|
|
32
|
+
tr.delete(shadow[0].from, shadow[shadow.length - 1].to);
|
|
33
|
+
}
|
|
34
|
+
return tr;
|
|
35
|
+
};
|
|
36
|
+
exports.dropStructuralChangeShadow = dropStructuralChangeShadow;
|
|
37
|
+
const dropOrphanChanges = (newTr, dropDataTracked) => {
|
|
38
|
+
const changeSet = (0, findChanges_1.findChanges)(prosemirror_state_1.EditorState.create({ doc: newTr.doc }));
|
|
39
|
+
const shadowIds = new Set();
|
|
40
|
+
const changesIds = new Set();
|
|
41
|
+
changeSet.changes.forEach((c) => {
|
|
42
|
+
if (c.dataTracked.moveNodeId && c.dataTracked.operation === change_1.CHANGE_OPERATION.delete) {
|
|
43
|
+
shadowIds.add(c.dataTracked.moveNodeId);
|
|
44
|
+
}
|
|
45
|
+
if (c.dataTracked.operation === change_1.CHANGE_OPERATION.structure ||
|
|
46
|
+
c.dataTracked.operation === change_1.CHANGE_OPERATION.move) {
|
|
47
|
+
changesIds.add(c.dataTracked.moveNodeId);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (!shadowIds.size && !changesIds.size) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
changeSet.changes.forEach((c) => {
|
|
54
|
+
if (c.dataTracked.moveNodeId &&
|
|
55
|
+
!(shadowIds.has(c.dataTracked.moveNodeId) && changesIds.has(c.dataTracked.moveNodeId))) {
|
|
56
|
+
if (c.dataTracked.operation === change_1.CHANGE_OPERATION.delete || dropDataTracked) {
|
|
57
|
+
if (c.type === 'text-change') {
|
|
58
|
+
newTr.removeMark(c.from, c.to, newTr.doc.type.schema.marks.tracked_delete);
|
|
59
|
+
}
|
|
60
|
+
else if (c.type === 'node-change') {
|
|
61
|
+
newTr.setNodeMarkup(c.from, undefined, Object.assign(Object.assign({}, c.node.attrs), { dataTracked: null }));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (c.type === 'node-change') {
|
|
65
|
+
const _a = c.dataTracked, { id, moveNodeId } = _a, attrs = __rest(_a, ["id", "moveNodeId"]);
|
|
66
|
+
newTr.replaceWith(c.from, c.to, (0, setFragmentAsInserted_1.setFragmentAsInserted)(prosemirror_model_1.Fragment.from(c.node), (0, track_utils_1.createNewInsertAttrs)(attrs), newTr.doc.type.schema));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
exports.dropOrphanChanges = dropOrphanChanges;
|
|
72
|
+
const groupStructureChanges = (tr, toNode) => {
|
|
73
|
+
const moveNodeIds = new Set();
|
|
74
|
+
const [insertStep, deleteStep] = tr.steps;
|
|
75
|
+
const fromNodes = tr.docs[1].slice(deleteStep.from, deleteStep.to).content;
|
|
76
|
+
const ignoredNode = tr.docs[1].nodeAt(deleteStep.from);
|
|
77
|
+
prosemirror_model_1.Fragment.from(toNode)
|
|
78
|
+
.append(insertStep.slice.content)
|
|
79
|
+
.append(fromNodes)
|
|
80
|
+
.descendants((node) => {
|
|
81
|
+
var _a;
|
|
82
|
+
const moveNodeId = (_a = ((0, nodeHelpers_1.getBlockInlineTrackedData)(node) || []).find((c) => c.operation === change_1.CHANGE_OPERATION.structure)) === null || _a === void 0 ? void 0 : _a.moveNodeId;
|
|
83
|
+
moveNodeId && moveNodeIds.add(moveNodeId);
|
|
84
|
+
});
|
|
85
|
+
return moveNodeIds;
|
|
86
|
+
};
|
|
87
|
+
const joinStructureChanges = (attrs, sliceContent, content, tr, newTr) => {
|
|
88
|
+
var _a, _b, _c;
|
|
89
|
+
const moveNodeId = attrs.moveNodeId;
|
|
90
|
+
let toNode = tr.docs[0].resolve(tr.steps[0].from).node();
|
|
91
|
+
toNode = ((_a = toNode === null || toNode === void 0 ? void 0 : toNode.type.spec.attrs) === null || _a === void 0 ? void 0 : _a.dataTracked) ? toNode : null;
|
|
92
|
+
const idsSet = groupStructureChanges(tr, toNode);
|
|
93
|
+
const changeSet = (0, findChanges_1.findChanges)(prosemirror_state_1.EditorState.create({ doc: newTr.doc }));
|
|
94
|
+
const relatedChanges = changeSet.changes.filter((c) => c.dataTracked.moveNodeId && idsSet.has(c.dataTracked.moveNodeId));
|
|
95
|
+
relatedChanges.map((c) => (0, updateChangeAttrs_1.updateChangeAttrs)(newTr, c, Object.assign(Object.assign({}, c.dataTracked), { moveNodeId }), newTr.doc.type.schema));
|
|
96
|
+
const toInsertChange = toNode && ((_b = (0, nodeHelpers_1.getBlockInlineTrackedData)(toNode)) === null || _b === void 0 ? void 0 : _b.find((c) => c.operation === change_1.CHANGE_OPERATION.insert));
|
|
97
|
+
const fromInsertChange = sliceContent.firstChild &&
|
|
98
|
+
((_c = (0, nodeHelpers_1.getBlockInlineTrackedData)(sliceContent.firstChild)) === null || _c === void 0 ? void 0 : _c.find((c) => c.operation === change_1.CHANGE_OPERATION.insert));
|
|
99
|
+
if (toInsertChange || fromInsertChange) {
|
|
100
|
+
return (0, setFragmentAsInserted_1.setFragmentAsInserted)(content, (0, track_utils_1.createNewInsertAttrs)(attrs), newTr.doc.type.schema);
|
|
101
|
+
}
|
|
102
|
+
return (0, track_utils_1.updateBlockNodesAttrs)(sliceContent, (_, node) => {
|
|
103
|
+
return Object.assign(Object.assign({}, _), { dataTracked: [(0, nodeHelpers_1.addTrackIdIfDoesntExist)((0, track_utils_1.createNewStructureAttrs)(Object.assign(Object.assign({}, attrs), { moveNodeId })))] });
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
exports.joinStructureChanges = joinStructureChanges;
|
|
@@ -35,8 +35,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.trackReplaceStep = trackReplaceStep;
|
|
37
37
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
38
|
+
const actions_1 = require("../actions");
|
|
38
39
|
const setFragmentAsInserted_1 = require("../compute/setFragmentAsInserted");
|
|
39
40
|
const deleteAndMergeSplitNodes_1 = require("../mutate/deleteAndMergeSplitNodes");
|
|
41
|
+
const dropStructureChange_1 = require("../mutate/dropStructureChange");
|
|
40
42
|
const logger_1 = require("../utils/logger");
|
|
41
43
|
const trackUtils = __importStar(require("../utils/track-utils"));
|
|
42
44
|
const track_utils_1 = require("../utils/track-utils");
|
|
@@ -46,11 +48,10 @@ function trackReplaceStep(step, oldState, newTr, attrsTemplate, stepResult, curr
|
|
|
46
48
|
const changeSteps = [];
|
|
47
49
|
const attrs = Object.assign({}, attrsTemplate);
|
|
48
50
|
if (moveID) {
|
|
49
|
-
console.log('Detected Node Moving ReplaceStep and assigning the following movenodeID: ' + moveID);
|
|
50
51
|
attrs.moveNodeId = moveID;
|
|
51
52
|
}
|
|
52
53
|
step.getMap().forEach((fromA, toA, fromB, toB) => {
|
|
53
|
-
var _a, _b, _c;
|
|
54
|
+
var _a, _b, _c, _d;
|
|
54
55
|
logger_1.log.info(`changed ranges: ${fromA} ${toA} ${fromB} ${toB}`);
|
|
55
56
|
const { slice } = step;
|
|
56
57
|
logger_1.log.info('TR: steps before applying delete', [...newTr.steps]);
|
|
@@ -77,16 +78,20 @@ function trackReplaceStep(step, oldState, newTr, attrsTemplate, stepResult, curr
|
|
|
77
78
|
if (!backSpacedText && newSliceContent.size > 0) {
|
|
78
79
|
logger_1.log.info('newSliceContent', newSliceContent);
|
|
79
80
|
let fragment = (0, setFragmentAsInserted_1.setFragmentAsInserted)(newSliceContent, trackUtils.createNewInsertAttrs(attrs), oldState.schema);
|
|
80
|
-
if ((0, track_utils_1.
|
|
81
|
+
if ((0, track_utils_1.isStructureSteps)(tr)) {
|
|
82
|
+
fragment = (0, dropStructureChange_1.joinStructureChanges)(attrs, newSliceContent, fragment, tr, newTr);
|
|
83
|
+
}
|
|
84
|
+
else if ((0, track_utils_1.isSplitStep)(step, oldState.selection, tr.getMeta('uiEvent'))) {
|
|
81
85
|
fragment = (0, setFragmentAsInserted_1.setFragmentAsNodeSplit)(newTr.doc.resolve(step.from), newTr, fragment, attrs);
|
|
82
86
|
}
|
|
83
|
-
if (moveID) {
|
|
84
|
-
|
|
87
|
+
else if (moveID) {
|
|
88
|
+
const indentationType = (_a = (0, actions_1.getAction)(tr, actions_1.TrackChangesAction.indentationAction)) === null || _a === void 0 ? void 0 : _a.action;
|
|
89
|
+
fragment = (0, setFragmentAsInserted_1.setFragmentAsMoveChange)(newSliceContent, trackUtils.createNewMoveAttrs(attrs, indentationType));
|
|
85
90
|
}
|
|
86
91
|
const openStart = slice.openStart !== slice.openEnd ? 0 : slice.openStart;
|
|
87
92
|
const openEnd = slice.openStart !== slice.openEnd ? 0 : slice.openEnd;
|
|
88
93
|
const textWasDeleted = !!changeSteps.length && !(fromA === fromB);
|
|
89
|
-
const isBlock = !!((
|
|
94
|
+
const isBlock = !!((_b = fragment.firstChild) === null || _b === void 0 ? void 0 : _b.isBlock);
|
|
90
95
|
changeSteps.push({
|
|
91
96
|
type: 'insert-slice',
|
|
92
97
|
from: textWasDeleted ? fromB : isBlock ? toA : fromA,
|
|
@@ -96,8 +101,8 @@ function trackReplaceStep(step, oldState, newTr, attrsTemplate, stepResult, curr
|
|
|
96
101
|
});
|
|
97
102
|
}
|
|
98
103
|
else {
|
|
99
|
-
const isDeleteEvent = ((
|
|
100
|
-
const isDeleteContentForward = ((
|
|
104
|
+
const isDeleteEvent = ((_c = window.event) === null || _c === void 0 ? void 0 : _c.code) === 'Delete';
|
|
105
|
+
const isDeleteContentForward = ((_d = window.event) === null || _d === void 0 ? void 0 : _d.inputType) === 'deleteContentForward';
|
|
101
106
|
selectionPos = isDeleteEvent || isDeleteContentForward ? toA : fromA;
|
|
102
107
|
}
|
|
103
108
|
});
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.trackTransaction = trackTransaction;
|
|
7
7
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
8
8
|
const prosemirror_transform_1 = require("prosemirror-transform");
|
|
9
|
+
const actions_1 = require("../actions");
|
|
9
10
|
const diffChangeSteps_1 = require("../change-steps/diffChangeSteps");
|
|
10
11
|
const processChangeSteps_1 = require("../change-steps/processChangeSteps");
|
|
11
12
|
const updateChangeAttrs_1 = require("../changes/updateChangeAttrs");
|
|
@@ -21,7 +22,7 @@ const trackReplaceStep_1 = require("./trackReplaceStep");
|
|
|
21
22
|
const getSelectionStaticConstructor = (sel) => Object.getPrototypeOf(sel).constructor;
|
|
22
23
|
const isHighlightMarkerNode = (node) => node && node.type === node.type.schema.nodes.highlight_marker;
|
|
23
24
|
function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
|
|
24
|
-
var _a, _b, _c, _d, _e;
|
|
25
|
+
var _a, _b, _c, _d, _e, _f;
|
|
25
26
|
const emptyAttrs = {
|
|
26
27
|
authorID,
|
|
27
28
|
reviewedByID: null,
|
|
@@ -30,13 +31,23 @@ function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
|
|
|
30
31
|
statusUpdateAt: 0,
|
|
31
32
|
status: change_1.CHANGE_STATUS.pending,
|
|
32
33
|
};
|
|
34
|
+
const action = (_a = (0, actions_1.getAction)(tr, actions_1.TrackChangesAction.indentationAction)) === null || _a === void 0 ? void 0 : _a.action;
|
|
35
|
+
const isIndentation = action === 'indent' || action === 'unindent';
|
|
33
36
|
const wasNodeSelection = tr.selection instanceof prosemirror_state_1.NodeSelection;
|
|
34
37
|
const setsNewSelection = tr.selectionSet;
|
|
35
38
|
const deletedNodeMapping = new prosemirror_transform_1.Mapping();
|
|
36
39
|
let iters = 0;
|
|
37
40
|
logger_1.log.info('ORIGINAL transaction', tr);
|
|
38
41
|
let trContext = {};
|
|
39
|
-
|
|
42
|
+
let movingStepsAssociated = (0, track_utils_1.HasMoveOperations)(tr);
|
|
43
|
+
if (isIndentation) {
|
|
44
|
+
const moveId = (0, uuidv4_1.uuidv4)();
|
|
45
|
+
tr.steps.forEach((step) => {
|
|
46
|
+
if (step instanceof prosemirror_transform_1.ReplaceStep) {
|
|
47
|
+
movingStepsAssociated.set(step, moveId);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
40
51
|
(0, track_utils_1.handleDirectPendingMoveDeletions)(tr, newTr, movingStepsAssociated);
|
|
41
52
|
const cleanSteps = (0, track_utils_1.filterMeaninglessMoveSteps)(tr, movingStepsAssociated);
|
|
42
53
|
for (let i = cleanSteps.length - 1; i >= 0; i--) {
|
|
@@ -57,13 +68,13 @@ function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
|
|
|
57
68
|
}
|
|
58
69
|
else if (step instanceof prosemirror_transform_1.ReplaceStep) {
|
|
59
70
|
const { slice } = step;
|
|
60
|
-
if (((
|
|
71
|
+
if (((_c = (_b = slice === null || slice === void 0 ? void 0 : slice.content) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.length) === 1 && isHighlightMarkerNode(slice.content.content[0])) {
|
|
61
72
|
continue;
|
|
62
73
|
}
|
|
63
74
|
const invertedStep = step.invert(tr.docs[i]);
|
|
64
75
|
const isDelete = step.from !== step.to && step.slice.content.size < invertedStep.slice.content.size;
|
|
65
76
|
let thisStepMapping = tr.mapping.slice(i + 1, i + 1);
|
|
66
|
-
if (isDelete) {
|
|
77
|
+
if (isDelete || (0, track_utils_1.isStructureSteps)(tr)) {
|
|
67
78
|
thisStepMapping = deletedNodeMapping;
|
|
68
79
|
}
|
|
69
80
|
const newStep = new prosemirror_transform_1.ReplaceStep(thisStepMapping.map(invertedStep.from), thisStepMapping.map(invertedStep.to), invertedStep.slice);
|
|
@@ -71,7 +82,7 @@ function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
|
|
|
71
82
|
let [steps, startPos] = (0, trackReplaceStep_1.trackReplaceStep)(step, oldState, newTr, emptyAttrs, stepResult, tr.docs[i], tr, movingStepsAssociated.get(step));
|
|
72
83
|
if (steps.length === 1) {
|
|
73
84
|
const step = steps[0];
|
|
74
|
-
if (isHighlightMarkerNode((step === null || step === void 0 ? void 0 : step.node) || ((
|
|
85
|
+
if (isHighlightMarkerNode((step === null || step === void 0 ? void 0 : step.node) || ((_e = (_d = step === null || step === void 0 ? void 0 : step.slice) === null || _d === void 0 ? void 0 : _d.content) === null || _e === void 0 ? void 0 : _e.content[0]))) {
|
|
75
86
|
continue;
|
|
76
87
|
}
|
|
77
88
|
}
|
|
@@ -104,7 +115,7 @@ function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
|
|
|
104
115
|
const [mapping, selectionPos] = (0, processChangeSteps_1.processChangeSteps)(changeSteps, tr.selection.from, newTr, emptyAttrs, oldState.schema, deletedNodeMapping);
|
|
105
116
|
}
|
|
106
117
|
else if (step instanceof prosemirror_transform_1.AddMarkStep) {
|
|
107
|
-
const dataTracked = (
|
|
118
|
+
const dataTracked = (_f = (0, nodeHelpers_1.getNodeTrackedData)(newTr.doc.nodeAt(step.from), oldState.schema)) === null || _f === void 0 ? void 0 : _f.pop();
|
|
108
119
|
if (dataTracked) {
|
|
109
120
|
(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);
|
|
110
121
|
}
|
|
@@ -113,7 +124,19 @@ function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
|
|
|
113
124
|
tr.getMeta('uiEvent') && newTr.setMeta('uiEvent', tr.getMeta('uiEvent'));
|
|
114
125
|
}
|
|
115
126
|
if (setsNewSelection && tr.selection instanceof prosemirror_state_1.TextSelection) {
|
|
116
|
-
|
|
127
|
+
let from = tr.selection.from;
|
|
128
|
+
if ((0, track_utils_1.isStructureSteps)(tr)) {
|
|
129
|
+
const selectionMapping = new prosemirror_transform_1.Mapping();
|
|
130
|
+
tr.steps.map((step) => {
|
|
131
|
+
const isDeleteStep = step instanceof prosemirror_transform_1.ReplaceStep && step.from !== step.to && step.slice.size === 0;
|
|
132
|
+
if (isDeleteStep) {
|
|
133
|
+
selectionMapping.appendMap(step.getMap().invert());
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
selectionMapping.appendMapping(deletedNodeMapping);
|
|
137
|
+
from = selectionMapping.map(tr.selection.from);
|
|
138
|
+
}
|
|
139
|
+
const newPos = newTr.doc.resolve(from);
|
|
117
140
|
newTr.setSelection(new prosemirror_state_1.TextSelection(newPos));
|
|
118
141
|
}
|
|
119
142
|
if (wasNodeSelection) {
|
package/dist/cjs/types/change.js
CHANGED
|
@@ -25,6 +25,7 @@ var CHANGE_OPERATION;
|
|
|
25
25
|
CHANGE_OPERATION["node_split"] = "node_split";
|
|
26
26
|
CHANGE_OPERATION["reference"] = "reference";
|
|
27
27
|
CHANGE_OPERATION["move"] = "move";
|
|
28
|
+
CHANGE_OPERATION["structure"] = "structure";
|
|
28
29
|
})(CHANGE_OPERATION || (exports.CHANGE_OPERATION = CHANGE_OPERATION = {}));
|
|
29
30
|
var CHANGE_STATUS;
|
|
30
31
|
(function (CHANGE_STATUS) {
|