@manuscripts/track-changes-plugin 1.6.1-LEAN-2850-v5 → 1.7.0-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,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.
@@ -1146,7 +1147,7 @@ function deleteAndMergeSplitNodes(from, to, gap, startDoc, newTr, schema, trackA
1146
1147
  * See the License for the specific language governing permissions and
1147
1148
  * limitations under the License.
1148
1149
  */
1149
- function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1150
+ function trackReplaceAroundStep(step, oldState, tr, newTr, attrs) {
1150
1151
  log.info('###### ReplaceAroundStep ######');
1151
1152
  // @ts-ignore
1152
1153
  const { from, to, gapFrom, gapTo, insert, slice, structure, } = step;
@@ -1167,14 +1168,18 @@ function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1167
1168
  log.info('DELETE STEPS: ', deleteSteps);
1168
1169
  // We only want to insert when there something inside the gap (actually would this be always true?)
1169
1170
  // or insert slice wasn't just start/end tokens (which we already merged inside deleteAndMergeSplitBlockNodes)
1170
- if (gap.size > 0 || (!structure && newSliceContent.size > 0)) {
1171
+ // ^^answering above comment we could have meta node like(bibliography_item, contributor) will not have content at all,
1172
+ // and that case gap will be 0, for that will use updateMetaNode to indicate that we are going just to update that node
1173
+ if (gap.size > 0 ||
1174
+ (!structure && newSliceContent.size > 0) ||
1175
+ tr.getMeta(TrackChangesAction.updateMetaNode)) {
1171
1176
  log.info('newSliceContent', newSliceContent);
1172
1177
  // Since deleteAndMergeSplitBlockNodes modified the slice to not to contain any merged nodes,
1173
1178
  // the sides should be equal. TODO can they be other than 0?
1174
1179
  const openStart = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openStart;
1175
1180
  const openEnd = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openEnd;
1176
1181
  let insertedSlice = new prosemirrorModel.Slice(setFragmentAsInserted(newSliceContent, createNewInsertAttrs(attrs), oldState.schema), openStart, openEnd);
1177
- if (gap.size > 0) {
1182
+ if (gap.size > 0 || tr.getMeta(TrackChangesAction.updateMetaNode)) {
1178
1183
  log.info('insertedSlice before inserted gap', insertedSlice);
1179
1184
  insertedSlice = insertedSlice.insertAt(insertedSlice.size === 0 ? 0 : insert, gap.content);
1180
1185
  log.info('insertedSlice after inserted gap', insertedSlice);
@@ -1736,7 +1741,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
1736
1741
  }
1737
1742
  }
1738
1743
  else if (step instanceof prosemirrorTransform.ReplaceAroundStep) {
1739
- let steps = trackReplaceAroundStep(step, oldState, newTr, emptyAttrs);
1744
+ let steps = trackReplaceAroundStep(step, oldState, tr, newTr, emptyAttrs);
1740
1745
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
1741
1746
  const inserted = steps.filter((s) => s.type === 'insert-slice');
1742
1747
  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.
@@ -1138,7 +1139,7 @@ function deleteAndMergeSplitNodes(from, to, gap, startDoc, newTr, schema, trackA
1138
1139
  * See the License for the specific language governing permissions and
1139
1140
  * limitations under the License.
1140
1141
  */
1141
- function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1142
+ function trackReplaceAroundStep(step, oldState, tr, newTr, attrs) {
1142
1143
  log.info('###### ReplaceAroundStep ######');
1143
1144
  // @ts-ignore
1144
1145
  const { from, to, gapFrom, gapTo, insert, slice, structure, } = step;
@@ -1159,14 +1160,18 @@ function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1159
1160
  log.info('DELETE STEPS: ', deleteSteps);
1160
1161
  // We only want to insert when there something inside the gap (actually would this be always true?)
1161
1162
  // or insert slice wasn't just start/end tokens (which we already merged inside deleteAndMergeSplitBlockNodes)
1162
- if (gap.size > 0 || (!structure && newSliceContent.size > 0)) {
1163
+ // ^^answering above comment we could have meta node like(bibliography_item, contributor) will not have content at all,
1164
+ // and that case gap will be 0, for that will use updateMetaNode to indicate that we are going just to update that node
1165
+ if (gap.size > 0 ||
1166
+ (!structure && newSliceContent.size > 0) ||
1167
+ tr.getMeta(TrackChangesAction.updateMetaNode)) {
1163
1168
  log.info('newSliceContent', newSliceContent);
1164
1169
  // Since deleteAndMergeSplitBlockNodes modified the slice to not to contain any merged nodes,
1165
1170
  // the sides should be equal. TODO can they be other than 0?
1166
1171
  const openStart = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openStart;
1167
1172
  const openEnd = slice.openStart !== slice.openEnd || newSliceContent.size === 0 ? 0 : slice.openEnd;
1168
1173
  let insertedSlice = new Slice(setFragmentAsInserted(newSliceContent, createNewInsertAttrs(attrs), oldState.schema), openStart, openEnd);
1169
- if (gap.size > 0) {
1174
+ if (gap.size > 0 || tr.getMeta(TrackChangesAction.updateMetaNode)) {
1170
1175
  log.info('insertedSlice before inserted gap', insertedSlice);
1171
1176
  insertedSlice = insertedSlice.insertAt(insertedSlice.size === 0 ? 0 : insert, gap.content);
1172
1177
  log.info('insertedSlice after inserted gap', insertedSlice);
@@ -1728,7 +1733,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
1728
1733
  }
1729
1734
  }
1730
1735
  else if (step instanceof ReplaceAroundStep) {
1731
- let steps = trackReplaceAroundStep(step, oldState, newTr, emptyAttrs);
1736
+ let steps = trackReplaceAroundStep(step, oldState, tr, newTr, emptyAttrs);
1732
1737
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
1733
1738
  const inserted = steps.filter((s) => s.type === 'insert-slice');
1734
1739
  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-LEAN-2850-v5",
3
+ "version": "1.7.0-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",