@manuscripts/track-changes-plugin 1.6.1-LEAN-2737 → 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/actions.d.ts CHANGED
@@ -22,8 +22,7 @@ export declare enum TrackChangesAction {
22
22
  setPluginStatus = "track-changes-set-track-status",
23
23
  setChangeStatuses = "track-changes-set-change-statuses",
24
24
  refreshChanges = "track-changes-refresh-changes",
25
- applyAndRemoveChanges = "track-changes-apply-remove-changes",
26
- updateMetaNode = "track-changes-update-meta-node"
25
+ applyAndRemoveChanges = "track-changes-apply-remove-changes"
27
26
  }
28
27
  export declare type TrackChangesActionParams = {
29
28
  [TrackChangesAction.skipTrack]: boolean;
@@ -35,7 +34,6 @@ export declare type TrackChangesActionParams = {
35
34
  };
36
35
  [TrackChangesAction.refreshChanges]: boolean;
37
36
  [TrackChangesAction.applyAndRemoveChanges]: boolean;
38
- [TrackChangesAction.updateMetaNode]: boolean;
39
37
  };
40
38
  /**
41
39
  * Gets the value of a meta field, action payload, of a defined track-changes action.
package/dist/index.cjs CHANGED
@@ -19,7 +19,6 @@ var TrackChangesAction;
19
19
  TrackChangesAction["setChangeStatuses"] = "track-changes-set-change-statuses";
20
20
  TrackChangesAction["refreshChanges"] = "track-changes-refresh-changes";
21
21
  TrackChangesAction["applyAndRemoveChanges"] = "track-changes-apply-remove-changes";
22
- TrackChangesAction["updateMetaNode"] = "track-changes-update-meta-node";
23
22
  })(TrackChangesAction || (TrackChangesAction = {}));
24
23
  /**
25
24
  * Gets the value of a meta field, action payload, of a defined track-changes action.
@@ -1138,7 +1137,7 @@ function deleteAndMergeSplitNodes(from, to, gap, startDoc, newTr, schema, trackA
1138
1137
  * See the License for the specific language governing permissions and
1139
1138
  * limitations under the License.
1140
1139
  */
1141
- function trackReplaceAroundStep(step, oldState, tr, newTr, attrs) {
1140
+ function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1142
1141
  log.info('###### ReplaceAroundStep ######');
1143
1142
  // @ts-ignore
1144
1143
  const { from, to, gapFrom, gapTo, insert, slice, structure, } = step;
@@ -1159,18 +1158,14 @@ function trackReplaceAroundStep(step, oldState, tr, newTr, attrs) {
1159
1158
  log.info('DELETE STEPS: ', deleteSteps);
1160
1159
  // We only want to insert when there something inside the gap (actually would this be always true?)
1161
1160
  // or insert slice wasn't just start/end tokens (which we already merged inside deleteAndMergeSplitBlockNodes)
1162
- // ^^answering above comment we could have meta node like(bibliography_item, contributor) will not have content at all,
1163
- // and that case gap will be 0, for that will use updateMetaNode to indicate that we are going just to update that node
1164
- if (gap.size > 0 ||
1165
- (!structure && newSliceContent.size > 0) ||
1166
- tr.getMeta(TrackChangesAction.updateMetaNode)) {
1161
+ if (gap.size > 0 || (!structure && newSliceContent.size > 0)) {
1167
1162
  log.info('newSliceContent', newSliceContent);
1168
1163
  // Since deleteAndMergeSplitBlockNodes modified the slice to not to contain any merged nodes,
1169
1164
  // the sides should be equal. TODO can they be other than 0?
1170
1165
  const openStart = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openStart;
1171
1166
  const openEnd = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openEnd;
1172
1167
  let insertedSlice = new prosemirrorModel.Slice(setFragmentAsInserted(newSliceContent, createNewInsertAttrs(attrs), oldState.schema), openStart, openEnd);
1173
- if (gap.size > 0 || tr.getMeta(TrackChangesAction.updateMetaNode)) {
1168
+ if (gap.size > 0) {
1174
1169
  log.info('insertedSlice before inserted gap', insertedSlice);
1175
1170
  insertedSlice = insertedSlice.insertAt(insertedSlice.size === 0 ? 0 : insert, gap.content);
1176
1171
  log.info('insertedSlice after inserted gap', insertedSlice);
@@ -1438,7 +1433,7 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema) {
1438
1433
  : addTrackIdIfDoesntExist(createNewUpdateAttrs(emptyAttrs, c.node.attrs));
1439
1434
  // Dont add update changes if there exists already an insert change for this node
1440
1435
  if (JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) &&
1441
- !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)) {
1442
1437
  newDataTracked.push(newUpdate);
1443
1438
  }
1444
1439
  newTr.setNodeMarkup(mapping.map(c.pos), undefined, {
@@ -1729,7 +1724,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
1729
1724
  }
1730
1725
  }
1731
1726
  else if (step instanceof prosemirrorTransform.ReplaceAroundStep) {
1732
- let steps = trackReplaceAroundStep(step, oldState, tr, newTr, emptyAttrs);
1727
+ let steps = trackReplaceAroundStep(step, oldState, newTr, emptyAttrs);
1733
1728
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
1734
1729
  const inserted = steps.filter((s) => s.type === 'insert-slice');
1735
1730
  log.info('INSERT STEPS: ', inserted);
package/dist/index.js CHANGED
@@ -11,7 +11,6 @@ var TrackChangesAction;
11
11
  TrackChangesAction["setChangeStatuses"] = "track-changes-set-change-statuses";
12
12
  TrackChangesAction["refreshChanges"] = "track-changes-refresh-changes";
13
13
  TrackChangesAction["applyAndRemoveChanges"] = "track-changes-apply-remove-changes";
14
- TrackChangesAction["updateMetaNode"] = "track-changes-update-meta-node";
15
14
  })(TrackChangesAction || (TrackChangesAction = {}));
16
15
  /**
17
16
  * Gets the value of a meta field, action payload, of a defined track-changes action.
@@ -1130,7 +1129,7 @@ function deleteAndMergeSplitNodes(from, to, gap, startDoc, newTr, schema, trackA
1130
1129
  * See the License for the specific language governing permissions and
1131
1130
  * limitations under the License.
1132
1131
  */
1133
- function trackReplaceAroundStep(step, oldState, tr, newTr, attrs) {
1132
+ function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1134
1133
  log.info('###### ReplaceAroundStep ######');
1135
1134
  // @ts-ignore
1136
1135
  const { from, to, gapFrom, gapTo, insert, slice, structure, } = step;
@@ -1151,18 +1150,14 @@ function trackReplaceAroundStep(step, oldState, tr, newTr, attrs) {
1151
1150
  log.info('DELETE STEPS: ', deleteSteps);
1152
1151
  // We only want to insert when there something inside the gap (actually would this be always true?)
1153
1152
  // or insert slice wasn't just start/end tokens (which we already merged inside deleteAndMergeSplitBlockNodes)
1154
- // ^^answering above comment we could have meta node like(bibliography_item, contributor) will not have content at all,
1155
- // and that case gap will be 0, for that will use updateMetaNode to indicate that we are going just to update that node
1156
- if (gap.size > 0 ||
1157
- (!structure && newSliceContent.size > 0) ||
1158
- tr.getMeta(TrackChangesAction.updateMetaNode)) {
1153
+ if (gap.size > 0 || (!structure && newSliceContent.size > 0)) {
1159
1154
  log.info('newSliceContent', newSliceContent);
1160
1155
  // Since deleteAndMergeSplitBlockNodes modified the slice to not to contain any merged nodes,
1161
1156
  // the sides should be equal. TODO can they be other than 0?
1162
1157
  const openStart = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openStart;
1163
1158
  const openEnd = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openEnd;
1164
1159
  let insertedSlice = new Slice(setFragmentAsInserted(newSliceContent, createNewInsertAttrs(attrs), oldState.schema), openStart, openEnd);
1165
- if (gap.size > 0 || tr.getMeta(TrackChangesAction.updateMetaNode)) {
1160
+ if (gap.size > 0) {
1166
1161
  log.info('insertedSlice before inserted gap', insertedSlice);
1167
1162
  insertedSlice = insertedSlice.insertAt(insertedSlice.size === 0 ? 0 : insert, gap.content);
1168
1163
  log.info('insertedSlice after inserted gap', insertedSlice);
@@ -1430,7 +1425,7 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema) {
1430
1425
  : addTrackIdIfDoesntExist(createNewUpdateAttrs(emptyAttrs, c.node.attrs));
1431
1426
  // Dont add update changes if there exists already an insert change for this node
1432
1427
  if (JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) &&
1433
- !oldDataTracked.find((d) => d.operation === CHANGE_OPERATION.insert)) {
1428
+ !oldDataTracked.find((d) => d.operation === CHANGE_OPERATION.insert && d.status === CHANGE_STATUS.pending)) {
1434
1429
  newDataTracked.push(newUpdate);
1435
1430
  }
1436
1431
  newTr.setNodeMarkup(mapping.map(c.pos), undefined, {
@@ -1721,7 +1716,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
1721
1716
  }
1722
1717
  }
1723
1718
  else if (step instanceof ReplaceAroundStep) {
1724
- let steps = trackReplaceAroundStep(step, oldState, tr, newTr, emptyAttrs);
1719
+ let steps = trackReplaceAroundStep(step, oldState, newTr, emptyAttrs);
1725
1720
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
1726
1721
  const inserted = steps.filter((s) => s.type === 'insert-slice');
1727
1722
  log.info('INSERT STEPS: ', inserted);
@@ -2,4 +2,4 @@ import type { EditorState, Transaction } from 'prosemirror-state';
2
2
  import { ReplaceAroundStep } from 'prosemirror-transform';
3
3
  import { NewEmptyAttrs } from '../types/track';
4
4
  import { ChangeStep } from '../types/step';
5
- export declare function trackReplaceAroundStep(step: ReplaceAroundStep, oldState: EditorState, tr: Transaction, newTr: Transaction, attrs: NewEmptyAttrs): ChangeStep[];
5
+ export declare function trackReplaceAroundStep(step: ReplaceAroundStep, oldState: EditorState, newTr: Transaction, attrs: NewEmptyAttrs): ChangeStep[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuscripts/track-changes-plugin",
3
- "version": "1.6.1-LEAN-2737",
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",