@manuscripts/track-changes-plugin 1.6.1 → 1.7.0

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,7 +22,8 @@ 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"
25
+ applyAndRemoveChanges = "track-changes-apply-remove-changes",
26
+ updateMetaNode = "track-changes-update-meta-node"
26
27
  }
27
28
  export declare type TrackChangesActionParams = {
28
29
  [TrackChangesAction.skipTrack]: boolean;
@@ -34,6 +35,7 @@ export declare type TrackChangesActionParams = {
34
35
  };
35
36
  [TrackChangesAction.refreshChanges]: boolean;
36
37
  [TrackChangesAction.applyAndRemoveChanges]: boolean;
38
+ [TrackChangesAction.updateMetaNode]: boolean;
37
39
  };
38
40
  /**
39
41
  * Gets the value of a meta field, action payload, of a defined track-changes action.
package/dist/index.cjs CHANGED
@@ -19,6 +19,7 @@ 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";
22
23
  })(TrackChangesAction || (TrackChangesAction = {}));
23
24
  /**
24
25
  * Gets the value of a meta field, action payload, of a defined track-changes action.
@@ -1137,7 +1138,7 @@ function deleteAndMergeSplitNodes(from, to, gap, startDoc, newTr, schema, trackA
1137
1138
  * See the License for the specific language governing permissions and
1138
1139
  * limitations under the License.
1139
1140
  */
1140
- function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1141
+ function trackReplaceAroundStep(step, oldState, tr, newTr, attrs) {
1141
1142
  log.info('###### ReplaceAroundStep ######');
1142
1143
  // @ts-ignore
1143
1144
  const { from, to, gapFrom, gapTo, insert, slice, structure, } = step;
@@ -1158,14 +1159,18 @@ function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1158
1159
  log.info('DELETE STEPS: ', deleteSteps);
1159
1160
  // We only want to insert when there something inside the gap (actually would this be always true?)
1160
1161
  // or insert slice wasn't just start/end tokens (which we already merged inside deleteAndMergeSplitBlockNodes)
1161
- if (gap.size > 0 || (!structure && newSliceContent.size > 0)) {
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)) {
1162
1167
  log.info('newSliceContent', newSliceContent);
1163
1168
  // Since deleteAndMergeSplitBlockNodes modified the slice to not to contain any merged nodes,
1164
1169
  // the sides should be equal. TODO can they be other than 0?
1165
1170
  const openStart = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openStart;
1166
1171
  const openEnd = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openEnd;
1167
1172
  let insertedSlice = new prosemirrorModel.Slice(setFragmentAsInserted(newSliceContent, createNewInsertAttrs(attrs), oldState.schema), openStart, openEnd);
1168
- if (gap.size > 0) {
1173
+ if (gap.size > 0 || tr.getMeta(TrackChangesAction.updateMetaNode)) {
1169
1174
  log.info('insertedSlice before inserted gap', insertedSlice);
1170
1175
  insertedSlice = insertedSlice.insertAt(insertedSlice.size === 0 ? 0 : insert, gap.content);
1171
1176
  log.info('insertedSlice after inserted gap', insertedSlice);
@@ -1724,7 +1729,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
1724
1729
  }
1725
1730
  }
1726
1731
  else if (step instanceof prosemirrorTransform.ReplaceAroundStep) {
1727
- let steps = trackReplaceAroundStep(step, oldState, newTr, emptyAttrs);
1732
+ let steps = trackReplaceAroundStep(step, oldState, tr, newTr, emptyAttrs);
1728
1733
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
1729
1734
  const inserted = steps.filter((s) => s.type === 'insert-slice');
1730
1735
  log.info('INSERT STEPS: ', inserted);
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ 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";
14
15
  })(TrackChangesAction || (TrackChangesAction = {}));
15
16
  /**
16
17
  * Gets the value of a meta field, action payload, of a defined track-changes action.
@@ -1129,7 +1130,7 @@ function deleteAndMergeSplitNodes(from, to, gap, startDoc, newTr, schema, trackA
1129
1130
  * See the License for the specific language governing permissions and
1130
1131
  * limitations under the License.
1131
1132
  */
1132
- function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1133
+ function trackReplaceAroundStep(step, oldState, tr, newTr, attrs) {
1133
1134
  log.info('###### ReplaceAroundStep ######');
1134
1135
  // @ts-ignore
1135
1136
  const { from, to, gapFrom, gapTo, insert, slice, structure, } = step;
@@ -1150,14 +1151,18 @@ function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1150
1151
  log.info('DELETE STEPS: ', deleteSteps);
1151
1152
  // We only want to insert when there something inside the gap (actually would this be always true?)
1152
1153
  // or insert slice wasn't just start/end tokens (which we already merged inside deleteAndMergeSplitBlockNodes)
1153
- if (gap.size > 0 || (!structure && newSliceContent.size > 0)) {
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)) {
1154
1159
  log.info('newSliceContent', newSliceContent);
1155
1160
  // Since deleteAndMergeSplitBlockNodes modified the slice to not to contain any merged nodes,
1156
1161
  // the sides should be equal. TODO can they be other than 0?
1157
1162
  const openStart = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openStart;
1158
1163
  const openEnd = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openEnd;
1159
1164
  let insertedSlice = new Slice(setFragmentAsInserted(newSliceContent, createNewInsertAttrs(attrs), oldState.schema), openStart, openEnd);
1160
- if (gap.size > 0) {
1165
+ if (gap.size > 0 || tr.getMeta(TrackChangesAction.updateMetaNode)) {
1161
1166
  log.info('insertedSlice before inserted gap', insertedSlice);
1162
1167
  insertedSlice = insertedSlice.insertAt(insertedSlice.size === 0 ? 0 : insert, gap.content);
1163
1168
  log.info('insertedSlice after inserted gap', insertedSlice);
@@ -1716,7 +1721,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
1716
1721
  }
1717
1722
  }
1718
1723
  else if (step instanceof ReplaceAroundStep) {
1719
- let steps = trackReplaceAroundStep(step, oldState, newTr, emptyAttrs);
1724
+ let steps = trackReplaceAroundStep(step, oldState, tr, newTr, emptyAttrs);
1720
1725
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
1721
1726
  const inserted = steps.filter((s) => s.type === 'insert-slice');
1722
1727
  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, newTr: Transaction, attrs: NewEmptyAttrs): ChangeStep[];
5
+ export declare function trackReplaceAroundStep(step: ReplaceAroundStep, oldState: EditorState, tr: Transaction, 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",
3
+ "version": "1.7.0",
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",