@manuscripts/track-changes-plugin 0.4.3 → 0.4.4-LEAN-1839-v2
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 +8 -21
- package/dist/index.js +8 -21
- package/package.json +5 -2
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) {
|
|
@@ -1681,6 +1662,12 @@ function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
1681
1662
|
return;
|
|
1682
1663
|
}
|
|
1683
1664
|
else if (step instanceof prosemirrorTransform.ReplaceStep) {
|
|
1665
|
+
const { slice } = step;
|
|
1666
|
+
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 &&
|
|
1667
|
+
isHighlightMarkerNode(slice.content.content[0])) {
|
|
1668
|
+
// don't track highlight marker nodes
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1684
1671
|
let [steps, startPos] = trackReplaceStep(step, oldState, newTr, emptyAttrs);
|
|
1685
1672
|
log.info('CHANGES: ', steps);
|
|
1686
1673
|
// deleted and merged really...
|
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) {
|
|
@@ -1673,6 +1654,12 @@ function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
1673
1654
|
return;
|
|
1674
1655
|
}
|
|
1675
1656
|
else if (step instanceof ReplaceStep) {
|
|
1657
|
+
const { slice } = step;
|
|
1658
|
+
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 &&
|
|
1659
|
+
isHighlightMarkerNode(slice.content.content[0])) {
|
|
1660
|
+
// don't track highlight marker nodes
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1676
1663
|
let [steps, startPos] = trackReplaceStep(step, oldState, newTr, emptyAttrs);
|
|
1677
1664
|
log.info('CHANGES: ', steps);
|
|
1678
1665
|
// deleted and merged really...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/track-changes-plugin",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4-LEAN-1839-v2",
|
|
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
|
-
".":
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
}
|
|
15
18
|
},
|
|
16
19
|
"files": [
|
|
17
20
|
"dist",
|