@manuscripts/track-changes-plugin 1.7.18 → 1.7.19

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.
@@ -50,9 +50,10 @@ function trackTransaction(tr, oldState, newTr, authorID) {
50
50
  continue;
51
51
  }
52
52
  const invertedStep = step.invert(tr.docs[i]);
53
+ const isDelete = step.from !== step.to && step.slice.content.size < invertedStep.slice.content.size;
53
54
  const thisStepMapping = tr.mapping.slice(i + 1);
54
55
  const newStep = new prosemirror_transform_1.ReplaceStep(thisStepMapping.map(invertedStep.from), thisStepMapping.map(invertedStep.to), invertedStep.slice);
55
- const stepResult = newTr.maybeStep(newStep);
56
+ const stepResult = newTr.maybeStep(isDelete ? invertedStep : newStep);
56
57
  let [steps, startPos] = (0, trackReplaceStep_1.trackReplaceStep)(step, oldState, newTr, emptyAttrs, stepResult, tr.docs[i]);
57
58
  if (steps.length === 1) {
58
59
  const step = steps[0];
@@ -60,8 +61,10 @@ function trackTransaction(tr, oldState, newTr, authorID) {
60
61
  continue;
61
62
  }
62
63
  }
63
- startPos = thisStepMapping.map(startPos);
64
- steps = (0, mapChangeStep_1.mapChangeSteps)(steps, thisStepMapping);
64
+ if (!isDelete) {
65
+ startPos = thisStepMapping.map(startPos);
66
+ steps = (0, mapChangeStep_1.mapChangeSteps)(steps, thisStepMapping);
67
+ }
65
68
  logger_1.log.info('CHANGES: ', steps);
66
69
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
67
70
  const inserted = steps.filter((s) => s.type === 'insert-slice');
@@ -44,9 +44,10 @@ export function trackTransaction(tr, oldState, newTr, authorID) {
44
44
  continue;
45
45
  }
46
46
  const invertedStep = step.invert(tr.docs[i]);
47
+ const isDelete = step.from !== step.to && step.slice.content.size < invertedStep.slice.content.size;
47
48
  const thisStepMapping = tr.mapping.slice(i + 1);
48
49
  const newStep = new ReplaceStep(thisStepMapping.map(invertedStep.from), thisStepMapping.map(invertedStep.to), invertedStep.slice);
49
- const stepResult = newTr.maybeStep(newStep);
50
+ const stepResult = newTr.maybeStep(isDelete ? invertedStep : newStep);
50
51
  let [steps, startPos] = trackReplaceStep(step, oldState, newTr, emptyAttrs, stepResult, tr.docs[i]);
51
52
  if (steps.length === 1) {
52
53
  const step = steps[0];
@@ -54,8 +55,10 @@ export function trackTransaction(tr, oldState, newTr, authorID) {
54
55
  continue;
55
56
  }
56
57
  }
57
- startPos = thisStepMapping.map(startPos);
58
- steps = mapChangeSteps(steps, thisStepMapping);
58
+ if (!isDelete) {
59
+ startPos = thisStepMapping.map(startPos);
60
+ steps = mapChangeSteps(steps, thisStepMapping);
61
+ }
59
62
  log.info('CHANGES: ', steps);
60
63
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
61
64
  const inserted = steps.filter((s) => s.type === 'insert-slice');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuscripts/track-changes-plugin",
3
- "version": "1.7.18",
3
+ "version": "1.7.19",
4
4
  "author": "Atypon Systems LLC",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/Atypon-OpenSource/manuscripts-track-changes-plugin",
@@ -69,4 +69,4 @@
69
69
  "resolutions": {
70
70
  "eslint-mdx": "2.0.5"
71
71
  }
72
- }
72
+ }