@manuscripts/track-changes-plugin 1.7.16-LEAN-3731.0 → 1.7.16

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.
@@ -121,9 +121,9 @@ function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema) {
121
121
  const sourceAttrs = (oldUpdate === null || oldUpdate === void 0 ? void 0 : oldUpdate.oldAttrs) || c.node.attrs;
122
122
  const { dataTracked } = sourceAttrs, restAttrs = __rest(sourceAttrs, ["dataTracked"]);
123
123
  const oldAttrs = lastChangeRejected ? oldUpdate.oldAttrs : restAttrs;
124
- const newDataTracked = [
125
- ...oldDataTracked.filter((d) => !oldUpdate || d.id !== oldUpdate.id || lastChangeRejected),
126
- ];
124
+ const newDataTracked = c.node.type != c.node.type.schema.nodes.list
125
+ ? [...oldDataTracked.filter((d) => !oldUpdate || d.id !== oldUpdate.id || lastChangeRejected)]
126
+ : [];
127
127
  const newUpdate = oldUpdate && oldUpdate.status !== change_1.CHANGE_STATUS.rejected
128
128
  ? Object.assign(Object.assign({}, oldUpdate), { updatedAt: emptyAttrs.updatedAt }) : (0, nodeHelpers_1.addTrackIdIfDoesntExist)(trackUtils.createNewUpdateAttrs(emptyAttrs, lastChangeRejected ? oldAttrs : c.node.attrs));
129
129
  if ((JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) ||
@@ -30,16 +30,16 @@ const setFragmentAsInserted_1 = require("../compute/setFragmentAsInserted");
30
30
  const deleteAndMergeSplitNodes_1 = require("../mutate/deleteAndMergeSplitNodes");
31
31
  const logger_1 = require("../utils/logger");
32
32
  const trackUtils = __importStar(require("../utils/track-utils"));
33
- function trackReplaceAroundStep(step, oldState, tr, newTr, attrs) {
33
+ function trackReplaceAroundStep(step, oldState, tr, newTr, attrs, currentStepDoc) {
34
34
  logger_1.log.info('###### ReplaceAroundStep ######');
35
35
  const { from, to, gapFrom, gapTo, insert, slice, structure, } = step;
36
- const newStep = step.invert(oldState.doc);
36
+ const newStep = step.invert(currentStepDoc);
37
37
  const stepResult = newTr.maybeStep(newStep);
38
38
  if (stepResult.failed) {
39
39
  logger_1.log.error(`inverting ReplaceAroundStep failed: "${stepResult.failed}"`, newStep);
40
40
  return [];
41
41
  }
42
- const gap = oldState.doc.slice(gapFrom, gapTo);
42
+ const gap = currentStepDoc.slice(gapFrom, gapTo);
43
43
  logger_1.log.info('RETAINED GAP CONTENT', gap);
44
44
  const { sliceWasSplit, newSliceContent, steps: deleteSteps, } = (0, deleteAndMergeSplitNodes_1.deleteAndMergeSplitNodes)(from, to, { start: gapFrom, end: gapTo }, newTr.doc, newTr, oldState.schema, attrs, slice);
45
45
  const steps = deleteSteps;
@@ -71,7 +71,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
71
71
  }
72
72
  }
73
73
  else if (step instanceof prosemirror_transform_1.ReplaceAroundStep) {
74
- let steps = (0, trackReplaceAroundStep_1.trackReplaceAroundStep)(step, oldState, tr, newTr, emptyAttrs);
74
+ let steps = (0, trackReplaceAroundStep_1.trackReplaceAroundStep)(step, oldState, tr, newTr, emptyAttrs, tr.docs[i]);
75
75
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
76
76
  const inserted = steps.filter((s) => s.type === 'insert-slice');
77
77
  logger_1.log.info('INSERT STEPS: ', inserted);
@@ -95,9 +95,9 @@ export function processChangeSteps(changes, startPos, newTr, emptyAttrs, schema)
95
95
  const sourceAttrs = (oldUpdate === null || oldUpdate === void 0 ? void 0 : oldUpdate.oldAttrs) || c.node.attrs;
96
96
  const { dataTracked } = sourceAttrs, restAttrs = __rest(sourceAttrs, ["dataTracked"]);
97
97
  const oldAttrs = lastChangeRejected ? oldUpdate.oldAttrs : restAttrs;
98
- const newDataTracked = [
99
- ...oldDataTracked.filter((d) => !oldUpdate || d.id !== oldUpdate.id || lastChangeRejected),
100
- ];
98
+ const newDataTracked = c.node.type != c.node.type.schema.nodes.list
99
+ ? [...oldDataTracked.filter((d) => !oldUpdate || d.id !== oldUpdate.id || lastChangeRejected)]
100
+ : [];
101
101
  const newUpdate = oldUpdate && oldUpdate.status !== CHANGE_STATUS.rejected
102
102
  ? Object.assign(Object.assign({}, oldUpdate), { updatedAt: emptyAttrs.updatedAt }) : addTrackIdIfDoesntExist(trackUtils.createNewUpdateAttrs(emptyAttrs, lastChangeRejected ? oldAttrs : c.node.attrs));
103
103
  if ((JSON.stringify(oldAttrs) !== JSON.stringify(c.newAttrs) ||
@@ -4,16 +4,16 @@ import { setFragmentAsInserted } from '../compute/setFragmentAsInserted';
4
4
  import { deleteAndMergeSplitNodes } from '../mutate/deleteAndMergeSplitNodes';
5
5
  import { log } from '../utils/logger';
6
6
  import * as trackUtils from '../utils/track-utils';
7
- export function trackReplaceAroundStep(step, oldState, tr, newTr, attrs) {
7
+ export function trackReplaceAroundStep(step, oldState, tr, newTr, attrs, currentStepDoc) {
8
8
  log.info('###### ReplaceAroundStep ######');
9
9
  const { from, to, gapFrom, gapTo, insert, slice, structure, } = step;
10
- const newStep = step.invert(oldState.doc);
10
+ const newStep = step.invert(currentStepDoc);
11
11
  const stepResult = newTr.maybeStep(newStep);
12
12
  if (stepResult.failed) {
13
13
  log.error(`inverting ReplaceAroundStep failed: "${stepResult.failed}"`, newStep);
14
14
  return [];
15
15
  }
16
- const gap = oldState.doc.slice(gapFrom, gapTo);
16
+ const gap = currentStepDoc.slice(gapFrom, gapTo);
17
17
  log.info('RETAINED GAP CONTENT', gap);
18
18
  const { sliceWasSplit, newSliceContent, steps: deleteSteps, } = deleteAndMergeSplitNodes(from, to, { start: gapFrom, end: gapTo }, newTr.doc, newTr, oldState.schema, attrs, slice);
19
19
  const steps = deleteSteps;
@@ -68,7 +68,7 @@ export function trackTransaction(tr, oldState, newTr, authorID) {
68
68
  }
69
69
  }
70
70
  else if (step instanceof ReplaceAroundStep) {
71
- let steps = trackReplaceAroundStep(step, oldState, tr, newTr, emptyAttrs);
71
+ let steps = trackReplaceAroundStep(step, oldState, tr, newTr, emptyAttrs, tr.docs[i]);
72
72
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
73
73
  const inserted = steps.filter((s) => s.type === 'insert-slice');
74
74
  log.info('INSERT STEPS: ', inserted);
@@ -1,5 +1,6 @@
1
+ import { Node as PMNode } from 'prosemirror-model';
1
2
  import type { EditorState, Transaction } from 'prosemirror-state';
2
3
  import { ReplaceAroundStep } from 'prosemirror-transform';
3
4
  import { ChangeStep } from '../types/step';
4
5
  import { NewEmptyAttrs } from '../types/track';
5
- export declare function trackReplaceAroundStep(step: ReplaceAroundStep, oldState: EditorState, tr: Transaction, newTr: Transaction, attrs: NewEmptyAttrs): ChangeStep[];
6
+ export declare function trackReplaceAroundStep(step: ReplaceAroundStep, oldState: EditorState, tr: Transaction, newTr: Transaction, attrs: NewEmptyAttrs, currentStepDoc: PMNode): ChangeStep[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuscripts/track-changes-plugin",
3
- "version": "1.7.16-LEAN-3731.0",
3
+ "version": "1.7.16",
4
4
  "author": "Atypon Systems LLC",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/Atypon-OpenSource/manuscripts-track-changes-plugin",