@manuscripts/track-changes-plugin 1.7.2-LEAN-2832 → 1.7.2-LEAN-3046
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 +91 -81
- package/dist/index.js +91 -81
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -478,7 +478,7 @@ function deleteNode(node, pos, tr) {
|
|
|
478
478
|
*/
|
|
479
479
|
function deleteOrSetNodeDeleted(node, pos, newTr, deleteAttrs) {
|
|
480
480
|
const dataTracked = getBlockInlineTrackedData(node);
|
|
481
|
-
const inserted = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.insert
|
|
481
|
+
const inserted = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.insert);
|
|
482
482
|
const deleted = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.delete);
|
|
483
483
|
const updated = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.set_node_attributes);
|
|
484
484
|
if (inserted && inserted.authorID === deleteAttrs.authorID) {
|
|
@@ -1412,95 +1412,105 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema) {
|
|
|
1412
1412
|
const deleteAttrs = createNewDeleteAttrs(emptyAttrs);
|
|
1413
1413
|
let selectionPos = startPos;
|
|
1414
1414
|
// @TODO add custom handler / condition?
|
|
1415
|
+
let deletesCounter = 0; // counter for deletion
|
|
1415
1416
|
changes.forEach((c) => {
|
|
1416
1417
|
let step = newTr.steps[newTr.steps.length - 1];
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
mergeTrackedMarks(mapping.map(c.pos), newTr.doc, newTr, schema);
|
|
1427
|
-
}
|
|
1428
|
-
else if (c.type === 'delete-text') {
|
|
1429
|
-
const node = newTr.doc.nodeAt(mapping.map(c.pos));
|
|
1430
|
-
if (!node) {
|
|
1431
|
-
log.error(`processChangeSteps: no text node found for text-change`, c);
|
|
1432
|
-
return;
|
|
1433
|
-
}
|
|
1434
|
-
const where = deleteTextIfInserted(node, mapping.map(c.pos), newTr, schema, deleteAttrs, mapping.map(c.from), mapping.map(c.to));
|
|
1435
|
-
mergeTrackedMarks(where, newTr.doc, newTr, schema);
|
|
1436
|
-
}
|
|
1437
|
-
else if (c.type === 'merge-fragment') {
|
|
1438
|
-
let insertPos = mapping.map(c.mergePos);
|
|
1439
|
-
// The default insert position for block nodes is either the start of the merged content or the end.
|
|
1440
|
-
// Incase text was merged, this must be updated as the start or end of the node doesn't map to the
|
|
1441
|
-
// actual position of the merge. Currently the inserted content is inserted at the start or end
|
|
1442
|
-
// of the merged content, TODO reverse the start/end when end/start token?
|
|
1443
|
-
if (c.node.isText) {
|
|
1444
|
-
// When merging text we must delete text in the same go as well, as the from/to boundary goes through
|
|
1445
|
-
// the text node.
|
|
1446
|
-
insertPos = deleteTextIfInserted(c.node, mapping.map(c.pos), newTr, schema, deleteAttrs, mapping.map(c.from), mapping.map(c.to));
|
|
1418
|
+
switch (c.type) {
|
|
1419
|
+
case "delete-node":
|
|
1420
|
+
deletesCounter++; // increase the counter for deleted nodes
|
|
1421
|
+
let trackedData = getBlockInlineTrackedData(c.node);
|
|
1422
|
+
const inserted = trackedData === null || trackedData === void 0 ? void 0 : trackedData.find((d) => d.operation === exports.CHANGE_OPERATION.insert);
|
|
1423
|
+
// For inserted node: the top node and its content (children nodes) is deleted in the first step
|
|
1424
|
+
if (inserted && deletesCounter > 1)
|
|
1425
|
+
return false;
|
|
1426
|
+
deleteOrSetNodeDeleted(c.node, mapping.map(c.pos), newTr, deleteAttrs);
|
|
1447
1427
|
const newestStep = newTr.steps[newTr.steps.length - 1];
|
|
1448
1428
|
if (step !== newestStep) {
|
|
1449
1429
|
mapping.appendMap(newestStep.getMap());
|
|
1450
1430
|
step = newestStep;
|
|
1451
1431
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
const stepResult = newTr.maybeStep(newStep);
|
|
1460
|
-
if (stepResult.failed) {
|
|
1461
|
-
log.error(`processChangeSteps: insert-slice ReplaceStep failed "${stepResult.failed}"`, newStep);
|
|
1462
|
-
return;
|
|
1463
|
-
}
|
|
1464
|
-
mergeTrackedMarks(mapping.map(c.from), newTr.doc, newTr, schema);
|
|
1465
|
-
const to = mapping.map(c.to) + c.slice.size;
|
|
1466
|
-
mergeTrackedMarks(mapping.map(c.to) + (to < newTr.doc.nodeSize ? c.slice.size : 0), newTr.doc, newTr, schema);
|
|
1467
|
-
selectionPos = mapping.map(c.to) + c.slice.size;
|
|
1468
|
-
}
|
|
1469
|
-
else if (c.type === 'update-node-attrs') {
|
|
1470
|
-
const oldDataTracked = getBlockInlineTrackedData(c.node) || [];
|
|
1471
|
-
const oldUpdate = oldDataTracked.reverse().find((d) => {
|
|
1472
|
-
// reversing to start from the most recent change
|
|
1473
|
-
if (d.operation === exports.CHANGE_OPERATION.set_node_attributes &&
|
|
1474
|
-
(d.status === exports.CHANGE_STATUS.pending || d.status === exports.CHANGE_STATUS.rejected)) {
|
|
1475
|
-
return true;
|
|
1432
|
+
mergeTrackedMarks(mapping.map(c.pos), newTr.doc, newTr, schema);
|
|
1433
|
+
break;
|
|
1434
|
+
case "delete-text":
|
|
1435
|
+
const node = newTr.doc.nodeAt(mapping.map(c.pos));
|
|
1436
|
+
if (!node) {
|
|
1437
|
+
log.error(`processChangeSteps: no text node found for text-change`, c);
|
|
1438
|
+
return;
|
|
1476
1439
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1440
|
+
const where = deleteTextIfInserted(node, mapping.map(c.pos), newTr, schema, deleteAttrs, mapping.map(c.from), mapping.map(c.to));
|
|
1441
|
+
mergeTrackedMarks(where, newTr.doc, newTr, schema);
|
|
1442
|
+
break;
|
|
1443
|
+
case 'merge-fragment':
|
|
1444
|
+
let insertPos = mapping.map(c.mergePos);
|
|
1445
|
+
// The default insert position for block nodes is either the start of the merged content or the end.
|
|
1446
|
+
// Incase text was merged, this must be updated as the start or end of the node doesn't map to the
|
|
1447
|
+
// actual position of the merge. Currently the inserted content is inserted at the start or end
|
|
1448
|
+
// of the merged content, TODO reverse the start/end when end/start token?
|
|
1449
|
+
if (c.node.isText) {
|
|
1450
|
+
// When merging text we must delete text in the same go as well, as the from/to boundary goes through
|
|
1451
|
+
// the text node.
|
|
1452
|
+
insertPos = deleteTextIfInserted(c.node, mapping.map(c.pos), newTr, schema, deleteAttrs, mapping.map(c.from), mapping.map(c.to));
|
|
1453
|
+
const newestStep = newTr.steps[newTr.steps.length - 1];
|
|
1454
|
+
if (step !== newestStep) {
|
|
1455
|
+
mapping.appendMap(newestStep.getMap());
|
|
1456
|
+
step = newestStep;
|
|
1457
|
+
}
|
|
1492
1458
|
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1459
|
+
if (c.fragment.size > 0) {
|
|
1460
|
+
newTr.insert(insertPos, c.fragment);
|
|
1461
|
+
}
|
|
1462
|
+
break;
|
|
1463
|
+
case 'insert-slice':
|
|
1464
|
+
const newStep = new prosemirrorTransform.ReplaceStep(mapping.map(c.from), mapping.map(c.to), c.slice, false);
|
|
1465
|
+
const stepResult = newTr.maybeStep(newStep);
|
|
1466
|
+
if (stepResult.failed) {
|
|
1467
|
+
log.error(`processChangeSteps: insert-slice ReplaceStep failed "${stepResult.failed}"`, newStep);
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
mergeTrackedMarks(mapping.map(c.from), newTr.doc, newTr, schema);
|
|
1471
|
+
const to = mapping.map(c.to) + c.slice.size;
|
|
1472
|
+
mergeTrackedMarks(mapping.map(c.to) + (to < newTr.doc.nodeSize ? c.slice.size : 0), newTr.doc, newTr, schema);
|
|
1473
|
+
selectionPos = mapping.map(c.to) + c.slice.size;
|
|
1474
|
+
break;
|
|
1475
|
+
case 'update-node-attrs':
|
|
1476
|
+
const oldDataTracked = getBlockInlineTrackedData(c.node) || [];
|
|
1477
|
+
const oldUpdate = oldDataTracked.reverse().find((d) => {
|
|
1478
|
+
// reversing to start from the most recent change
|
|
1479
|
+
if (d.operation === exports.CHANGE_OPERATION.set_node_attributes &&
|
|
1480
|
+
(d.status === exports.CHANGE_STATUS.pending || d.status === exports.CHANGE_STATUS.rejected)) {
|
|
1481
|
+
return true;
|
|
1482
|
+
}
|
|
1483
|
+
return false;
|
|
1484
|
+
});
|
|
1485
|
+
// if the selected last change is with status "rejected" we need to use oldAttrs from it because
|
|
1486
|
+
// node's actual attributes represent the "rejected" values
|
|
1487
|
+
const lastChangeRejected = oldUpdate && oldUpdate.status === exports.CHANGE_STATUS.rejected;
|
|
1488
|
+
const sourceAttrs = (oldUpdate === null || oldUpdate === void 0 ? void 0 : oldUpdate.oldAttrs) || c.node.attrs;
|
|
1489
|
+
const { dataTracked, ...restAttrs } = sourceAttrs;
|
|
1490
|
+
const oldAttrs = lastChangeRejected ? oldUpdate.oldAttrs : restAttrs;
|
|
1491
|
+
const newDataTracked = [
|
|
1492
|
+
...oldDataTracked.filter((d) => !oldUpdate || d.id !== oldUpdate.id || lastChangeRejected),
|
|
1493
|
+
];
|
|
1494
|
+
const newUpdate = oldUpdate && oldUpdate.status !== exports.CHANGE_STATUS.rejected
|
|
1495
|
+
? {
|
|
1496
|
+
...oldUpdate,
|
|
1497
|
+
updatedAt: emptyAttrs.updatedAt,
|
|
1498
|
+
}
|
|
1499
|
+
: addTrackIdIfDoesntExist(createNewUpdateAttrs(emptyAttrs, lastChangeRejected ? oldAttrs : c.node.attrs));
|
|
1500
|
+
// Dont add update changes if there exists already an insert change for this node
|
|
1501
|
+
if ((JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) ||
|
|
1502
|
+
c.node.type === c.node.type.schema.nodes.citation) &&
|
|
1503
|
+
!oldDataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.insert && d.status === exports.CHANGE_STATUS.pending)) {
|
|
1504
|
+
newDataTracked.push(newUpdate);
|
|
1505
|
+
}
|
|
1506
|
+
newTr.setNodeMarkup(mapping.map(c.pos), undefined, {
|
|
1507
|
+
...c.newAttrs,
|
|
1508
|
+
dataTracked: newDataTracked.length > 0 ? newDataTracked : null,
|
|
1509
|
+
}, c.node.marks);
|
|
1510
|
+
break;
|
|
1511
|
+
default:
|
|
1512
|
+
log.error(`processChangeSteps: unknown change type`, c);
|
|
1513
|
+
return;
|
|
1504
1514
|
}
|
|
1505
1515
|
const newestStep = newTr.steps[newTr.steps.length - 1];
|
|
1506
1516
|
if (step !== newestStep) {
|
package/dist/index.js
CHANGED
|
@@ -470,7 +470,7 @@ function deleteNode(node, pos, tr) {
|
|
|
470
470
|
*/
|
|
471
471
|
function deleteOrSetNodeDeleted(node, pos, newTr, deleteAttrs) {
|
|
472
472
|
const dataTracked = getBlockInlineTrackedData(node);
|
|
473
|
-
const inserted = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === CHANGE_OPERATION.insert
|
|
473
|
+
const inserted = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === CHANGE_OPERATION.insert);
|
|
474
474
|
const deleted = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === CHANGE_OPERATION.delete);
|
|
475
475
|
const updated = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === CHANGE_OPERATION.set_node_attributes);
|
|
476
476
|
if (inserted && inserted.authorID === deleteAttrs.authorID) {
|
|
@@ -1404,95 +1404,105 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema) {
|
|
|
1404
1404
|
const deleteAttrs = createNewDeleteAttrs(emptyAttrs);
|
|
1405
1405
|
let selectionPos = startPos;
|
|
1406
1406
|
// @TODO add custom handler / condition?
|
|
1407
|
+
let deletesCounter = 0; // counter for deletion
|
|
1407
1408
|
changes.forEach((c) => {
|
|
1408
1409
|
let step = newTr.steps[newTr.steps.length - 1];
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
mergeTrackedMarks(mapping.map(c.pos), newTr.doc, newTr, schema);
|
|
1419
|
-
}
|
|
1420
|
-
else if (c.type === 'delete-text') {
|
|
1421
|
-
const node = newTr.doc.nodeAt(mapping.map(c.pos));
|
|
1422
|
-
if (!node) {
|
|
1423
|
-
log.error(`processChangeSteps: no text node found for text-change`, c);
|
|
1424
|
-
return;
|
|
1425
|
-
}
|
|
1426
|
-
const where = deleteTextIfInserted(node, mapping.map(c.pos), newTr, schema, deleteAttrs, mapping.map(c.from), mapping.map(c.to));
|
|
1427
|
-
mergeTrackedMarks(where, newTr.doc, newTr, schema);
|
|
1428
|
-
}
|
|
1429
|
-
else if (c.type === 'merge-fragment') {
|
|
1430
|
-
let insertPos = mapping.map(c.mergePos);
|
|
1431
|
-
// The default insert position for block nodes is either the start of the merged content or the end.
|
|
1432
|
-
// Incase text was merged, this must be updated as the start or end of the node doesn't map to the
|
|
1433
|
-
// actual position of the merge. Currently the inserted content is inserted at the start or end
|
|
1434
|
-
// of the merged content, TODO reverse the start/end when end/start token?
|
|
1435
|
-
if (c.node.isText) {
|
|
1436
|
-
// When merging text we must delete text in the same go as well, as the from/to boundary goes through
|
|
1437
|
-
// the text node.
|
|
1438
|
-
insertPos = deleteTextIfInserted(c.node, mapping.map(c.pos), newTr, schema, deleteAttrs, mapping.map(c.from), mapping.map(c.to));
|
|
1410
|
+
switch (c.type) {
|
|
1411
|
+
case "delete-node":
|
|
1412
|
+
deletesCounter++; // increase the counter for deleted nodes
|
|
1413
|
+
let trackedData = getBlockInlineTrackedData(c.node);
|
|
1414
|
+
const inserted = trackedData === null || trackedData === void 0 ? void 0 : trackedData.find((d) => d.operation === CHANGE_OPERATION.insert);
|
|
1415
|
+
// For inserted node: the top node and its content (children nodes) is deleted in the first step
|
|
1416
|
+
if (inserted && deletesCounter > 1)
|
|
1417
|
+
return false;
|
|
1418
|
+
deleteOrSetNodeDeleted(c.node, mapping.map(c.pos), newTr, deleteAttrs);
|
|
1439
1419
|
const newestStep = newTr.steps[newTr.steps.length - 1];
|
|
1440
1420
|
if (step !== newestStep) {
|
|
1441
1421
|
mapping.appendMap(newestStep.getMap());
|
|
1442
1422
|
step = newestStep;
|
|
1443
1423
|
}
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
const stepResult = newTr.maybeStep(newStep);
|
|
1452
|
-
if (stepResult.failed) {
|
|
1453
|
-
log.error(`processChangeSteps: insert-slice ReplaceStep failed "${stepResult.failed}"`, newStep);
|
|
1454
|
-
return;
|
|
1455
|
-
}
|
|
1456
|
-
mergeTrackedMarks(mapping.map(c.from), newTr.doc, newTr, schema);
|
|
1457
|
-
const to = mapping.map(c.to) + c.slice.size;
|
|
1458
|
-
mergeTrackedMarks(mapping.map(c.to) + (to < newTr.doc.nodeSize ? c.slice.size : 0), newTr.doc, newTr, schema);
|
|
1459
|
-
selectionPos = mapping.map(c.to) + c.slice.size;
|
|
1460
|
-
}
|
|
1461
|
-
else if (c.type === 'update-node-attrs') {
|
|
1462
|
-
const oldDataTracked = getBlockInlineTrackedData(c.node) || [];
|
|
1463
|
-
const oldUpdate = oldDataTracked.reverse().find((d) => {
|
|
1464
|
-
// reversing to start from the most recent change
|
|
1465
|
-
if (d.operation === CHANGE_OPERATION.set_node_attributes &&
|
|
1466
|
-
(d.status === CHANGE_STATUS.pending || d.status === CHANGE_STATUS.rejected)) {
|
|
1467
|
-
return true;
|
|
1424
|
+
mergeTrackedMarks(mapping.map(c.pos), newTr.doc, newTr, schema);
|
|
1425
|
+
break;
|
|
1426
|
+
case "delete-text":
|
|
1427
|
+
const node = newTr.doc.nodeAt(mapping.map(c.pos));
|
|
1428
|
+
if (!node) {
|
|
1429
|
+
log.error(`processChangeSteps: no text node found for text-change`, c);
|
|
1430
|
+
return;
|
|
1468
1431
|
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1432
|
+
const where = deleteTextIfInserted(node, mapping.map(c.pos), newTr, schema, deleteAttrs, mapping.map(c.from), mapping.map(c.to));
|
|
1433
|
+
mergeTrackedMarks(where, newTr.doc, newTr, schema);
|
|
1434
|
+
break;
|
|
1435
|
+
case 'merge-fragment':
|
|
1436
|
+
let insertPos = mapping.map(c.mergePos);
|
|
1437
|
+
// The default insert position for block nodes is either the start of the merged content or the end.
|
|
1438
|
+
// Incase text was merged, this must be updated as the start or end of the node doesn't map to the
|
|
1439
|
+
// actual position of the merge. Currently the inserted content is inserted at the start or end
|
|
1440
|
+
// of the merged content, TODO reverse the start/end when end/start token?
|
|
1441
|
+
if (c.node.isText) {
|
|
1442
|
+
// When merging text we must delete text in the same go as well, as the from/to boundary goes through
|
|
1443
|
+
// the text node.
|
|
1444
|
+
insertPos = deleteTextIfInserted(c.node, mapping.map(c.pos), newTr, schema, deleteAttrs, mapping.map(c.from), mapping.map(c.to));
|
|
1445
|
+
const newestStep = newTr.steps[newTr.steps.length - 1];
|
|
1446
|
+
if (step !== newestStep) {
|
|
1447
|
+
mapping.appendMap(newestStep.getMap());
|
|
1448
|
+
step = newestStep;
|
|
1449
|
+
}
|
|
1484
1450
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1451
|
+
if (c.fragment.size > 0) {
|
|
1452
|
+
newTr.insert(insertPos, c.fragment);
|
|
1453
|
+
}
|
|
1454
|
+
break;
|
|
1455
|
+
case 'insert-slice':
|
|
1456
|
+
const newStep = new ReplaceStep(mapping.map(c.from), mapping.map(c.to), c.slice, false);
|
|
1457
|
+
const stepResult = newTr.maybeStep(newStep);
|
|
1458
|
+
if (stepResult.failed) {
|
|
1459
|
+
log.error(`processChangeSteps: insert-slice ReplaceStep failed "${stepResult.failed}"`, newStep);
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
mergeTrackedMarks(mapping.map(c.from), newTr.doc, newTr, schema);
|
|
1463
|
+
const to = mapping.map(c.to) + c.slice.size;
|
|
1464
|
+
mergeTrackedMarks(mapping.map(c.to) + (to < newTr.doc.nodeSize ? c.slice.size : 0), newTr.doc, newTr, schema);
|
|
1465
|
+
selectionPos = mapping.map(c.to) + c.slice.size;
|
|
1466
|
+
break;
|
|
1467
|
+
case 'update-node-attrs':
|
|
1468
|
+
const oldDataTracked = getBlockInlineTrackedData(c.node) || [];
|
|
1469
|
+
const oldUpdate = oldDataTracked.reverse().find((d) => {
|
|
1470
|
+
// reversing to start from the most recent change
|
|
1471
|
+
if (d.operation === CHANGE_OPERATION.set_node_attributes &&
|
|
1472
|
+
(d.status === CHANGE_STATUS.pending || d.status === CHANGE_STATUS.rejected)) {
|
|
1473
|
+
return true;
|
|
1474
|
+
}
|
|
1475
|
+
return false;
|
|
1476
|
+
});
|
|
1477
|
+
// if the selected last change is with status "rejected" we need to use oldAttrs from it because
|
|
1478
|
+
// node's actual attributes represent the "rejected" values
|
|
1479
|
+
const lastChangeRejected = oldUpdate && oldUpdate.status === CHANGE_STATUS.rejected;
|
|
1480
|
+
const sourceAttrs = (oldUpdate === null || oldUpdate === void 0 ? void 0 : oldUpdate.oldAttrs) || c.node.attrs;
|
|
1481
|
+
const { dataTracked, ...restAttrs } = sourceAttrs;
|
|
1482
|
+
const oldAttrs = lastChangeRejected ? oldUpdate.oldAttrs : restAttrs;
|
|
1483
|
+
const newDataTracked = [
|
|
1484
|
+
...oldDataTracked.filter((d) => !oldUpdate || d.id !== oldUpdate.id || lastChangeRejected),
|
|
1485
|
+
];
|
|
1486
|
+
const newUpdate = oldUpdate && oldUpdate.status !== CHANGE_STATUS.rejected
|
|
1487
|
+
? {
|
|
1488
|
+
...oldUpdate,
|
|
1489
|
+
updatedAt: emptyAttrs.updatedAt,
|
|
1490
|
+
}
|
|
1491
|
+
: addTrackIdIfDoesntExist(createNewUpdateAttrs(emptyAttrs, lastChangeRejected ? oldAttrs : c.node.attrs));
|
|
1492
|
+
// Dont add update changes if there exists already an insert change for this node
|
|
1493
|
+
if ((JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) ||
|
|
1494
|
+
c.node.type === c.node.type.schema.nodes.citation) &&
|
|
1495
|
+
!oldDataTracked.find((d) => d.operation === CHANGE_OPERATION.insert && d.status === CHANGE_STATUS.pending)) {
|
|
1496
|
+
newDataTracked.push(newUpdate);
|
|
1497
|
+
}
|
|
1498
|
+
newTr.setNodeMarkup(mapping.map(c.pos), undefined, {
|
|
1499
|
+
...c.newAttrs,
|
|
1500
|
+
dataTracked: newDataTracked.length > 0 ? newDataTracked : null,
|
|
1501
|
+
}, c.node.marks);
|
|
1502
|
+
break;
|
|
1503
|
+
default:
|
|
1504
|
+
log.error(`processChangeSteps: unknown change type`, c);
|
|
1505
|
+
return;
|
|
1496
1506
|
}
|
|
1497
1507
|
const newestStep = newTr.steps[newTr.steps.length - 1];
|
|
1498
1508
|
if (step !== newestStep) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/track-changes-plugin",
|
|
3
|
-
"version": "1.7.2-LEAN-
|
|
3
|
+
"version": "1.7.2-LEAN-3046",
|
|
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",
|