@manuscripts/track-changes-plugin 0.4.3 → 0.4.4-LEAN-1839

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/index.cjs CHANGED
@@ -1140,27 +1140,6 @@ function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1140
1140
  log.info('###### ReplaceAroundStep ######');
1141
1141
  // @ts-ignore
1142
1142
  const { from, to, gapFrom, gapTo, insert, slice, structure, } = step;
1143
- if (from === gapFrom && to === gapTo) {
1144
- log.info('WRAPPED IN SOMETHING');
1145
- }
1146
- else if (!slice.size || slice.content.content.length === 2) {
1147
- log.info('UNWRAPPED FROM SOMETHING');
1148
- }
1149
- else if (slice.size === 2 && gapFrom - from === 1 && to - gapTo === 1) {
1150
- log.info('REPLACED WRAPPING');
1151
- }
1152
- else {
1153
- log.info('????');
1154
- }
1155
- if (gapFrom - from > to - gapTo) {
1156
- log.info('DELETED BEFORE GAP FROM');
1157
- }
1158
- else if (gapFrom - from < to - gapTo) {
1159
- log.info('DELETED AFTER GAP TO');
1160
- }
1161
- else {
1162
- log.info('EQUAL REPLACE BETWEEN GAPS');
1163
- }
1164
1143
  // Invert the transaction step to prevent it from actually deleting or inserting anything
1165
1144
  const newStep = step.invert(oldState.doc);
1166
1145
  const stepResult = newTr.maybeStep(newStep);
@@ -1639,6 +1618,7 @@ function diffChangeSteps(deleted, inserted) {
1639
1618
  * @returns
1640
1619
  */
1641
1620
  const getSelectionStaticConstructor = (sel) => Object.getPrototypeOf(sel).constructor;
1621
+ const isHighlightMarkerNode = (node) => node.type === node.type.schema.nodes.highlight_marker;
1642
1622
  /**
1643
1623
  * Inverts transactions to wrap their contents/operations with track data instead
1644
1624
  *
@@ -1668,6 +1648,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
1668
1648
  let iters = 0;
1669
1649
  log.info('ORIGINAL transaction', tr);
1670
1650
  tr.steps.forEach((step) => {
1651
+ var _a, _b;
1671
1652
  log.info('transaction step', step);
1672
1653
  iters += 1;
1673
1654
  if (iters > 20) {
@@ -1682,6 +1663,12 @@ function trackTransaction(tr, oldState, newTr, authorID) {
1682
1663
  }
1683
1664
  else if (step instanceof prosemirrorTransform.ReplaceStep) {
1684
1665
  let [steps, startPos] = trackReplaceStep(step, oldState, newTr, emptyAttrs);
1666
+ const { slice } = step;
1667
+ if (((_b = (_a = slice === null || slice === void 0 ? void 0 : slice.content) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
1668
+ isHighlightMarkerNode(slice.content.content[0])) {
1669
+ // don't track highlight marker nodes
1670
+ return;
1671
+ }
1685
1672
  log.info('CHANGES: ', steps);
1686
1673
  // deleted and merged really...
1687
1674
  const deleted = steps.filter((s) => s.type !== 'insert-slice');
package/dist/index.js CHANGED
@@ -1132,27 +1132,6 @@ function trackReplaceAroundStep(step, oldState, newTr, attrs) {
1132
1132
  log.info('###### ReplaceAroundStep ######');
1133
1133
  // @ts-ignore
1134
1134
  const { from, to, gapFrom, gapTo, insert, slice, structure, } = step;
1135
- if (from === gapFrom && to === gapTo) {
1136
- log.info('WRAPPED IN SOMETHING');
1137
- }
1138
- else if (!slice.size || slice.content.content.length === 2) {
1139
- log.info('UNWRAPPED FROM SOMETHING');
1140
- }
1141
- else if (slice.size === 2 && gapFrom - from === 1 && to - gapTo === 1) {
1142
- log.info('REPLACED WRAPPING');
1143
- }
1144
- else {
1145
- log.info('????');
1146
- }
1147
- if (gapFrom - from > to - gapTo) {
1148
- log.info('DELETED BEFORE GAP FROM');
1149
- }
1150
- else if (gapFrom - from < to - gapTo) {
1151
- log.info('DELETED AFTER GAP TO');
1152
- }
1153
- else {
1154
- log.info('EQUAL REPLACE BETWEEN GAPS');
1155
- }
1156
1135
  // Invert the transaction step to prevent it from actually deleting or inserting anything
1157
1136
  const newStep = step.invert(oldState.doc);
1158
1137
  const stepResult = newTr.maybeStep(newStep);
@@ -1631,6 +1610,7 @@ function diffChangeSteps(deleted, inserted) {
1631
1610
  * @returns
1632
1611
  */
1633
1612
  const getSelectionStaticConstructor = (sel) => Object.getPrototypeOf(sel).constructor;
1613
+ const isHighlightMarkerNode = (node) => node.type === node.type.schema.nodes.highlight_marker;
1634
1614
  /**
1635
1615
  * Inverts transactions to wrap their contents/operations with track data instead
1636
1616
  *
@@ -1660,6 +1640,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
1660
1640
  let iters = 0;
1661
1641
  log.info('ORIGINAL transaction', tr);
1662
1642
  tr.steps.forEach((step) => {
1643
+ var _a, _b;
1663
1644
  log.info('transaction step', step);
1664
1645
  iters += 1;
1665
1646
  if (iters > 20) {
@@ -1674,6 +1655,12 @@ function trackTransaction(tr, oldState, newTr, authorID) {
1674
1655
  }
1675
1656
  else if (step instanceof ReplaceStep) {
1676
1657
  let [steps, startPos] = trackReplaceStep(step, oldState, newTr, emptyAttrs);
1658
+ const { slice } = step;
1659
+ if (((_b = (_a = slice === null || slice === void 0 ? void 0 : slice.content) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
1660
+ isHighlightMarkerNode(slice.content.content[0])) {
1661
+ // don't track highlight marker nodes
1662
+ return;
1663
+ }
1677
1664
  log.info('CHANGES: ', steps);
1678
1665
  // deleted and merged really...
1679
1666
  const deleted = 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": "0.4.3",
3
+ "version": "0.4.4-LEAN-1839",
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",
@@ -11,7 +11,10 @@
11
11
  "exports": {
12
12
  "./package.json": "./package.json",
13
13
  "./src/styles.css": "./src/styles.css",
14
- ".": "./dist/index.js"
14
+ ".": {
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
17
+ }
15
18
  },
16
19
  "files": [
17
20
  "dist",