@manuscripts/track-changes-plugin 1.6.1-LEAN-2752 → 1.6.1-LEAN-2850
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/index.cjs +12 -33
- package/dist/index.js +12 -33
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -530,7 +530,9 @@ function updateChangeAttrs(tr, change, trackedAttrs, schema) {
|
|
|
530
530
|
return tr;
|
|
531
531
|
}
|
|
532
532
|
const { operation } = trackedAttrs;
|
|
533
|
-
const oldTrackData = change.type === 'text-change'
|
|
533
|
+
const oldTrackData = change.type === 'text-change'
|
|
534
|
+
? getTextNodeTrackedMarkData(node, schema)
|
|
535
|
+
: getBlockInlineTrackedData(node);
|
|
534
536
|
if (!operation) {
|
|
535
537
|
log.warn('updateChangeAttrs: unable to determine operation of change ', change);
|
|
536
538
|
}
|
|
@@ -551,15 +553,7 @@ function updateChangeAttrs(tr, change, trackedAttrs, schema) {
|
|
|
551
553
|
tr.setNodeMarkup(change.from, undefined, { ...node.attrs, dataTracked: null }, node.marks);
|
|
552
554
|
}
|
|
553
555
|
else if (change.type === 'node-change' || change.type === 'node-attr-change') {
|
|
554
|
-
const
|
|
555
|
-
const targetDataTracked = trackedDataSource.find((t) => change.id === t.id);
|
|
556
|
-
const newDataTracked = trackedDataSource.map((oldTrack) => {
|
|
557
|
-
if (targetDataTracked) {
|
|
558
|
-
if (oldTrack.id === targetDataTracked.id) {
|
|
559
|
-
return { ...oldTrack, ...trackedAttrs };
|
|
560
|
-
}
|
|
561
|
-
return oldTrack;
|
|
562
|
-
}
|
|
556
|
+
const newDataTracked = (getBlockInlineTrackedData(node) || []).map((oldTrack) => {
|
|
563
557
|
if (oldTrack.operation === operation) {
|
|
564
558
|
return { ...oldTrack, ...trackedAttrs };
|
|
565
559
|
}
|
|
@@ -957,7 +951,7 @@ function createNewUpdateAttrs(attrs, oldAttrs) {
|
|
|
957
951
|
return {
|
|
958
952
|
...attrs,
|
|
959
953
|
operation: exports.CHANGE_OPERATION.set_node_attributes,
|
|
960
|
-
oldAttrs:
|
|
954
|
+
oldAttrs: restAttrs,
|
|
961
955
|
};
|
|
962
956
|
}
|
|
963
957
|
|
|
@@ -1204,8 +1198,7 @@ function trackReplaceAroundStep(step, oldState, newTr, attrs) {
|
|
|
1204
1198
|
*/
|
|
1205
1199
|
function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepDoc) {
|
|
1206
1200
|
log.info('###### ReplaceStep ######');
|
|
1207
|
-
let selectionPos = 0;
|
|
1208
|
-
const changeSteps = [];
|
|
1201
|
+
let selectionPos = 0, changeSteps = [];
|
|
1209
1202
|
// Invert the transaction step to prevent it from actually deleting or inserting anything
|
|
1210
1203
|
step.getMap().forEach((fromA, toA, fromB, toB) => {
|
|
1211
1204
|
var _a, _b;
|
|
@@ -1429,32 +1422,18 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema) {
|
|
|
1429
1422
|
}
|
|
1430
1423
|
else if (c.type === 'update-node-attrs') {
|
|
1431
1424
|
const oldDataTracked = getBlockInlineTrackedData(c.node) || [];
|
|
1432
|
-
const oldUpdate = oldDataTracked.
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
return true;
|
|
1437
|
-
}
|
|
1438
|
-
return false;
|
|
1439
|
-
});
|
|
1440
|
-
// if the selected last change is with status "rejected" we need to use oldAttrs from it because
|
|
1441
|
-
// node's actual attributes represent the "rejected" values
|
|
1442
|
-
const lastChangeRejected = oldUpdate && oldUpdate.status === exports.CHANGE_STATUS.rejected;
|
|
1443
|
-
const sourceAttrs = (oldUpdate === null || oldUpdate === void 0 ? void 0 : oldUpdate.oldAttrs) || c.node.attrs;
|
|
1444
|
-
const { dataTracked, ...restAttrs } = sourceAttrs;
|
|
1445
|
-
const oldAttrs = lastChangeRejected ? oldUpdate.oldAttrs : restAttrs;
|
|
1446
|
-
const newDataTracked = [
|
|
1447
|
-
...oldDataTracked.filter((d) => !oldUpdate || d.id !== oldUpdate.id || lastChangeRejected),
|
|
1448
|
-
];
|
|
1449
|
-
const newUpdate = oldUpdate && oldUpdate.status !== exports.CHANGE_STATUS.rejected
|
|
1425
|
+
const oldUpdate = oldDataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.set_node_attributes && d.status === exports.CHANGE_STATUS.pending);
|
|
1426
|
+
const { dataTracked, ...oldAttrs } = (oldUpdate === null || oldUpdate === void 0 ? void 0 : oldUpdate.oldAttrs) || c.node.attrs;
|
|
1427
|
+
const newDataTracked = [...oldDataTracked.filter((d) => !oldUpdate || d.id !== oldUpdate.id)];
|
|
1428
|
+
const newUpdate = oldUpdate
|
|
1450
1429
|
? {
|
|
1451
1430
|
...oldUpdate,
|
|
1452
1431
|
updatedAt: emptyAttrs.updatedAt,
|
|
1453
1432
|
}
|
|
1454
|
-
: addTrackIdIfDoesntExist(createNewUpdateAttrs(emptyAttrs,
|
|
1433
|
+
: addTrackIdIfDoesntExist(createNewUpdateAttrs(emptyAttrs, c.node.attrs));
|
|
1455
1434
|
// Dont add update changes if there exists already an insert change for this node
|
|
1456
1435
|
if (JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) &&
|
|
1457
|
-
!oldDataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.insert)) {
|
|
1436
|
+
!oldDataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.insert && d.status === exports.CHANGE_STATUS.pending)) {
|
|
1458
1437
|
newDataTracked.push(newUpdate);
|
|
1459
1438
|
}
|
|
1460
1439
|
newTr.setNodeMarkup(mapping.map(c.pos), undefined, {
|
package/dist/index.js
CHANGED
|
@@ -522,7 +522,9 @@ function updateChangeAttrs(tr, change, trackedAttrs, schema) {
|
|
|
522
522
|
return tr;
|
|
523
523
|
}
|
|
524
524
|
const { operation } = trackedAttrs;
|
|
525
|
-
const oldTrackData = change.type === 'text-change'
|
|
525
|
+
const oldTrackData = change.type === 'text-change'
|
|
526
|
+
? getTextNodeTrackedMarkData(node, schema)
|
|
527
|
+
: getBlockInlineTrackedData(node);
|
|
526
528
|
if (!operation) {
|
|
527
529
|
log.warn('updateChangeAttrs: unable to determine operation of change ', change);
|
|
528
530
|
}
|
|
@@ -543,15 +545,7 @@ function updateChangeAttrs(tr, change, trackedAttrs, schema) {
|
|
|
543
545
|
tr.setNodeMarkup(change.from, undefined, { ...node.attrs, dataTracked: null }, node.marks);
|
|
544
546
|
}
|
|
545
547
|
else if (change.type === 'node-change' || change.type === 'node-attr-change') {
|
|
546
|
-
const
|
|
547
|
-
const targetDataTracked = trackedDataSource.find((t) => change.id === t.id);
|
|
548
|
-
const newDataTracked = trackedDataSource.map((oldTrack) => {
|
|
549
|
-
if (targetDataTracked) {
|
|
550
|
-
if (oldTrack.id === targetDataTracked.id) {
|
|
551
|
-
return { ...oldTrack, ...trackedAttrs };
|
|
552
|
-
}
|
|
553
|
-
return oldTrack;
|
|
554
|
-
}
|
|
548
|
+
const newDataTracked = (getBlockInlineTrackedData(node) || []).map((oldTrack) => {
|
|
555
549
|
if (oldTrack.operation === operation) {
|
|
556
550
|
return { ...oldTrack, ...trackedAttrs };
|
|
557
551
|
}
|
|
@@ -949,7 +943,7 @@ function createNewUpdateAttrs(attrs, oldAttrs) {
|
|
|
949
943
|
return {
|
|
950
944
|
...attrs,
|
|
951
945
|
operation: CHANGE_OPERATION.set_node_attributes,
|
|
952
|
-
oldAttrs:
|
|
946
|
+
oldAttrs: restAttrs,
|
|
953
947
|
};
|
|
954
948
|
}
|
|
955
949
|
|
|
@@ -1196,8 +1190,7 @@ function trackReplaceAroundStep(step, oldState, newTr, attrs) {
|
|
|
1196
1190
|
*/
|
|
1197
1191
|
function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepDoc) {
|
|
1198
1192
|
log.info('###### ReplaceStep ######');
|
|
1199
|
-
let selectionPos = 0;
|
|
1200
|
-
const changeSteps = [];
|
|
1193
|
+
let selectionPos = 0, changeSteps = [];
|
|
1201
1194
|
// Invert the transaction step to prevent it from actually deleting or inserting anything
|
|
1202
1195
|
step.getMap().forEach((fromA, toA, fromB, toB) => {
|
|
1203
1196
|
var _a, _b;
|
|
@@ -1421,32 +1414,18 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema) {
|
|
|
1421
1414
|
}
|
|
1422
1415
|
else if (c.type === 'update-node-attrs') {
|
|
1423
1416
|
const oldDataTracked = getBlockInlineTrackedData(c.node) || [];
|
|
1424
|
-
const oldUpdate = oldDataTracked.
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
return true;
|
|
1429
|
-
}
|
|
1430
|
-
return false;
|
|
1431
|
-
});
|
|
1432
|
-
// if the selected last change is with status "rejected" we need to use oldAttrs from it because
|
|
1433
|
-
// node's actual attributes represent the "rejected" values
|
|
1434
|
-
const lastChangeRejected = oldUpdate && oldUpdate.status === CHANGE_STATUS.rejected;
|
|
1435
|
-
const sourceAttrs = (oldUpdate === null || oldUpdate === void 0 ? void 0 : oldUpdate.oldAttrs) || c.node.attrs;
|
|
1436
|
-
const { dataTracked, ...restAttrs } = sourceAttrs;
|
|
1437
|
-
const oldAttrs = lastChangeRejected ? oldUpdate.oldAttrs : restAttrs;
|
|
1438
|
-
const newDataTracked = [
|
|
1439
|
-
...oldDataTracked.filter((d) => !oldUpdate || d.id !== oldUpdate.id || lastChangeRejected),
|
|
1440
|
-
];
|
|
1441
|
-
const newUpdate = oldUpdate && oldUpdate.status !== CHANGE_STATUS.rejected
|
|
1417
|
+
const oldUpdate = oldDataTracked.find((d) => d.operation === CHANGE_OPERATION.set_node_attributes && d.status === CHANGE_STATUS.pending);
|
|
1418
|
+
const { dataTracked, ...oldAttrs } = (oldUpdate === null || oldUpdate === void 0 ? void 0 : oldUpdate.oldAttrs) || c.node.attrs;
|
|
1419
|
+
const newDataTracked = [...oldDataTracked.filter((d) => !oldUpdate || d.id !== oldUpdate.id)];
|
|
1420
|
+
const newUpdate = oldUpdate
|
|
1442
1421
|
? {
|
|
1443
1422
|
...oldUpdate,
|
|
1444
1423
|
updatedAt: emptyAttrs.updatedAt,
|
|
1445
1424
|
}
|
|
1446
|
-
: addTrackIdIfDoesntExist(createNewUpdateAttrs(emptyAttrs,
|
|
1425
|
+
: addTrackIdIfDoesntExist(createNewUpdateAttrs(emptyAttrs, c.node.attrs));
|
|
1447
1426
|
// Dont add update changes if there exists already an insert change for this node
|
|
1448
1427
|
if (JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) &&
|
|
1449
|
-
!oldDataTracked.find((d) => d.operation === CHANGE_OPERATION.insert)) {
|
|
1428
|
+
!oldDataTracked.find((d) => d.operation === CHANGE_OPERATION.insert && d.status === CHANGE_STATUS.pending)) {
|
|
1450
1429
|
newDataTracked.push(newUpdate);
|
|
1451
1430
|
}
|
|
1452
1431
|
newTr.setNodeMarkup(mapping.map(c.pos), undefined, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/track-changes-plugin",
|
|
3
|
-
"version": "1.6.1-LEAN-
|
|
3
|
+
"version": "1.6.1-LEAN-2850",
|
|
4
4
|
"author": "Atypon Systems LLC",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/Atypon-OpenSource/manuscripts-quarterback/tree/main/quarterback-packages/track-changes-plugin",
|