@manuscripts/track-changes-plugin 0.4.4 → 0.4.5
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 +15 -0
- package/dist/index.js +15 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1618,6 +1618,7 @@ function diffChangeSteps(deleted, inserted) {
|
|
|
1618
1618
|
* @returns
|
|
1619
1619
|
*/
|
|
1620
1620
|
const getSelectionStaticConstructor = (sel) => Object.getPrototypeOf(sel).constructor;
|
|
1621
|
+
const isHighlightMarkerNode = (node) => node && node.type === node.type.schema.nodes.highlight_marker;
|
|
1621
1622
|
/**
|
|
1622
1623
|
* Inverts transactions to wrap their contents/operations with track data instead
|
|
1623
1624
|
*
|
|
@@ -1647,6 +1648,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
1647
1648
|
let iters = 0;
|
|
1648
1649
|
log.info('ORIGINAL transaction', tr);
|
|
1649
1650
|
tr.steps.forEach((step) => {
|
|
1651
|
+
var _a, _b, _c, _d;
|
|
1650
1652
|
log.info('transaction step', step);
|
|
1651
1653
|
iters += 1;
|
|
1652
1654
|
if (iters > 20) {
|
|
@@ -1660,7 +1662,20 @@ function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
1660
1662
|
return;
|
|
1661
1663
|
}
|
|
1662
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
|
+
}
|
|
1663
1671
|
let [steps, startPos] = trackReplaceStep(step, oldState, newTr, emptyAttrs);
|
|
1672
|
+
if (steps.length === 1) {
|
|
1673
|
+
const step = steps[0]; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1674
|
+
if (isHighlightMarkerNode((step === null || step === void 0 ? void 0 : step.node) || ((_d = (_c = step === null || step === void 0 ? void 0 : step.slice) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.content[0]))) {
|
|
1675
|
+
// don't track deleted highlight marker nodes
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1664
1679
|
log.info('CHANGES: ', steps);
|
|
1665
1680
|
// deleted and merged really...
|
|
1666
1681
|
const deleted = steps.filter((s) => s.type !== 'insert-slice');
|
package/dist/index.js
CHANGED
|
@@ -1610,6 +1610,7 @@ function diffChangeSteps(deleted, inserted) {
|
|
|
1610
1610
|
* @returns
|
|
1611
1611
|
*/
|
|
1612
1612
|
const getSelectionStaticConstructor = (sel) => Object.getPrototypeOf(sel).constructor;
|
|
1613
|
+
const isHighlightMarkerNode = (node) => node && node.type === node.type.schema.nodes.highlight_marker;
|
|
1613
1614
|
/**
|
|
1614
1615
|
* Inverts transactions to wrap their contents/operations with track data instead
|
|
1615
1616
|
*
|
|
@@ -1639,6 +1640,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
1639
1640
|
let iters = 0;
|
|
1640
1641
|
log.info('ORIGINAL transaction', tr);
|
|
1641
1642
|
tr.steps.forEach((step) => {
|
|
1643
|
+
var _a, _b, _c, _d;
|
|
1642
1644
|
log.info('transaction step', step);
|
|
1643
1645
|
iters += 1;
|
|
1644
1646
|
if (iters > 20) {
|
|
@@ -1652,7 +1654,20 @@ function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
1652
1654
|
return;
|
|
1653
1655
|
}
|
|
1654
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
|
+
}
|
|
1655
1663
|
let [steps, startPos] = trackReplaceStep(step, oldState, newTr, emptyAttrs);
|
|
1664
|
+
if (steps.length === 1) {
|
|
1665
|
+
const step = steps[0]; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1666
|
+
if (isHighlightMarkerNode((step === null || step === void 0 ? void 0 : step.node) || ((_d = (_c = step === null || step === void 0 ? void 0 : step.slice) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.content[0]))) {
|
|
1667
|
+
// don't track deleted highlight marker nodes
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1656
1671
|
log.info('CHANGES: ', steps);
|
|
1657
1672
|
// deleted and merged really...
|
|
1658
1673
|
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
|
+
"version": "0.4.5",
|
|
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",
|