@manuscripts/track-changes-plugin 1.7.1 → 1.7.2-LEAN-2832

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 CHANGED
@@ -162,13 +162,14 @@ const enableDebug = (enabled) => {
162
162
  }
163
163
  };
164
164
 
165
- var _ChangeSet_changes;
165
+ var _ChangeSet_instances, _ChangeSet_changes, _ChangeSet_isSameNodeChange, _ChangeSet_isNotPendingOrDeleted;
166
166
  /**
167
167
  * ChangeSet is a data structure to contain the tracked changes with some utility methods and computed
168
168
  * values to allow easier operability.
169
169
  */
170
170
  class ChangeSet {
171
171
  constructor(changes = []) {
172
+ _ChangeSet_instances.add(this);
172
173
  _ChangeSet_changes.set(this, void 0);
173
174
  __classPrivateFieldSet(this, _ChangeSet_changes, changes, "f");
174
175
  }
@@ -199,7 +200,10 @@ class ChangeSet {
199
200
  rootNodes.push(currentNodeChange);
200
201
  currentNodeChange = undefined;
201
202
  }
202
- if (currentNodeChange && c.from < currentNodeChange.to) {
203
+ if (currentNodeChange &&
204
+ c.from < currentNodeChange.to &&
205
+ !(__classPrivateFieldGet(this, _ChangeSet_instances, "m", _ChangeSet_isSameNodeChange).call(this, currentNodeChange, c) &&
206
+ __classPrivateFieldGet(this, _ChangeSet_instances, "m", _ChangeSet_isNotPendingOrDeleted).call(this, currentNodeChange))) {
203
207
  currentNodeChange.children.push(c);
204
208
  }
205
209
  else if (c.type === 'node-change') {
@@ -321,7 +325,12 @@ class ChangeSet {
321
325
  return change.type === 'node-attr-change';
322
326
  }
323
327
  }
324
- _ChangeSet_changes = new WeakMap();
328
+ _ChangeSet_changes = new WeakMap(), _ChangeSet_instances = new WeakSet(), _ChangeSet_isSameNodeChange = function _ChangeSet_isSameNodeChange(currentChange, nextChange) {
329
+ return currentChange.from === nextChange.from && currentChange.to === nextChange.to;
330
+ }, _ChangeSet_isNotPendingOrDeleted = function _ChangeSet_isNotPendingOrDeleted(change) {
331
+ return (change.dataTracked.operation !== exports.CHANGE_OPERATION.delete &&
332
+ change.dataTracked.status !== exports.CHANGE_STATUS.pending);
333
+ };
325
334
 
326
335
  /*!
327
336
  * © 2021 Atypon Systems LLC
@@ -469,7 +478,7 @@ function deleteNode(node, pos, tr) {
469
478
  */
470
479
  function deleteOrSetNodeDeleted(node, pos, newTr, deleteAttrs) {
471
480
  const dataTracked = getBlockInlineTrackedData(node);
472
- 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 && d.status === exports.CHANGE_STATUS.pending);
473
482
  const deleted = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.delete);
474
483
  const updated = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.set_node_attributes);
475
484
  if (inserted && inserted.authorID === deleteAttrs.authorID) {
@@ -1483,8 +1492,9 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema) {
1483
1492
  }
1484
1493
  : addTrackIdIfDoesntExist(createNewUpdateAttrs(emptyAttrs, lastChangeRejected ? oldAttrs : c.node.attrs));
1485
1494
  // Dont add update changes if there exists already an insert change for this node
1486
- if (JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) &&
1487
- !oldDataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.insert)) {
1495
+ if ((JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) ||
1496
+ c.node.type === c.node.type.schema.nodes.citation) &&
1497
+ !oldDataTracked.find((d) => d.operation === exports.CHANGE_OPERATION.insert && d.status === exports.CHANGE_STATUS.pending)) {
1488
1498
  newDataTracked.push(newUpdate);
1489
1499
  }
1490
1500
  newTr.setNodeMarkup(mapping.map(c.pos), undefined, {
package/dist/index.js CHANGED
@@ -154,13 +154,14 @@ const enableDebug = (enabled) => {
154
154
  }
155
155
  };
156
156
 
157
- var _ChangeSet_changes;
157
+ var _ChangeSet_instances, _ChangeSet_changes, _ChangeSet_isSameNodeChange, _ChangeSet_isNotPendingOrDeleted;
158
158
  /**
159
159
  * ChangeSet is a data structure to contain the tracked changes with some utility methods and computed
160
160
  * values to allow easier operability.
161
161
  */
162
162
  class ChangeSet {
163
163
  constructor(changes = []) {
164
+ _ChangeSet_instances.add(this);
164
165
  _ChangeSet_changes.set(this, void 0);
165
166
  __classPrivateFieldSet(this, _ChangeSet_changes, changes, "f");
166
167
  }
@@ -191,7 +192,10 @@ class ChangeSet {
191
192
  rootNodes.push(currentNodeChange);
192
193
  currentNodeChange = undefined;
193
194
  }
194
- if (currentNodeChange && c.from < currentNodeChange.to) {
195
+ if (currentNodeChange &&
196
+ c.from < currentNodeChange.to &&
197
+ !(__classPrivateFieldGet(this, _ChangeSet_instances, "m", _ChangeSet_isSameNodeChange).call(this, currentNodeChange, c) &&
198
+ __classPrivateFieldGet(this, _ChangeSet_instances, "m", _ChangeSet_isNotPendingOrDeleted).call(this, currentNodeChange))) {
195
199
  currentNodeChange.children.push(c);
196
200
  }
197
201
  else if (c.type === 'node-change') {
@@ -313,7 +317,12 @@ class ChangeSet {
313
317
  return change.type === 'node-attr-change';
314
318
  }
315
319
  }
316
- _ChangeSet_changes = new WeakMap();
320
+ _ChangeSet_changes = new WeakMap(), _ChangeSet_instances = new WeakSet(), _ChangeSet_isSameNodeChange = function _ChangeSet_isSameNodeChange(currentChange, nextChange) {
321
+ return currentChange.from === nextChange.from && currentChange.to === nextChange.to;
322
+ }, _ChangeSet_isNotPendingOrDeleted = function _ChangeSet_isNotPendingOrDeleted(change) {
323
+ return (change.dataTracked.operation !== CHANGE_OPERATION.delete &&
324
+ change.dataTracked.status !== CHANGE_STATUS.pending);
325
+ };
317
326
 
318
327
  /*!
319
328
  * © 2021 Atypon Systems LLC
@@ -461,7 +470,7 @@ function deleteNode(node, pos, tr) {
461
470
  */
462
471
  function deleteOrSetNodeDeleted(node, pos, newTr, deleteAttrs) {
463
472
  const dataTracked = getBlockInlineTrackedData(node);
464
- 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 && d.status === CHANGE_STATUS.pending);
465
474
  const deleted = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === CHANGE_OPERATION.delete);
466
475
  const updated = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.find((d) => d.operation === CHANGE_OPERATION.set_node_attributes);
467
476
  if (inserted && inserted.authorID === deleteAttrs.authorID) {
@@ -1475,8 +1484,9 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema) {
1475
1484
  }
1476
1485
  : addTrackIdIfDoesntExist(createNewUpdateAttrs(emptyAttrs, lastChangeRejected ? oldAttrs : c.node.attrs));
1477
1486
  // Dont add update changes if there exists already an insert change for this node
1478
- if (JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) &&
1479
- !oldDataTracked.find((d) => d.operation === CHANGE_OPERATION.insert)) {
1487
+ if ((JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) ||
1488
+ c.node.type === c.node.type.schema.nodes.citation) &&
1489
+ !oldDataTracked.find((d) => d.operation === CHANGE_OPERATION.insert && d.status === CHANGE_STATUS.pending)) {
1480
1490
  newDataTracked.push(newUpdate);
1481
1491
  }
1482
1492
  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.7.1",
3
+ "version": "1.7.2-LEAN-2832",
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",