@manuscripts/track-changes-plugin 1.10.8 → 1.10.9-LEAN-4339.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.
|
@@ -18,7 +18,13 @@ function getUpdatedDataTracked(dataTracked, changeId) {
|
|
|
18
18
|
}
|
|
19
19
|
exports.getUpdatedDataTracked = getUpdatedDataTracked;
|
|
20
20
|
function applyAcceptedRejectedChanges(tr, schema, changes, changeSet, deleteMap = new prosemirror_transform_1.Mapping()) {
|
|
21
|
-
changes.sort((c1, c2) =>
|
|
21
|
+
changes.sort((c1, c2) => {
|
|
22
|
+
if ((c1.type === 'node-change' && c1.node.type === schema.nodes.list) ||
|
|
23
|
+
(c2.type === 'node-change' && c2.node.type === schema.nodes.list)) {
|
|
24
|
+
return -1;
|
|
25
|
+
}
|
|
26
|
+
return c1.dataTracked.updatedAt - c2.dataTracked.updatedAt;
|
|
27
|
+
});
|
|
22
28
|
changes.forEach((change) => {
|
|
23
29
|
if (change.dataTracked.operation === change_1.CHANGE_OPERATION.move) {
|
|
24
30
|
return;
|
|
@@ -38,7 +44,7 @@ function applyAcceptedRejectedChanges(tr, schema, changes, changeSet, deleteMap
|
|
|
38
44
|
return (0, revertChange_1.revertSplitNodeChange)(tr, change, changeSet);
|
|
39
45
|
}
|
|
40
46
|
if (change.dataTracked.operation === change_1.CHANGE_OPERATION.wrap_with_node) {
|
|
41
|
-
return (0, revertChange_1.revertWrapNodeChange)(tr, change);
|
|
47
|
+
return (0, revertChange_1.revertWrapNodeChange)(tr, change, deleteMap);
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
if (ChangeSet_1.ChangeSet.isTextChange(change) && noChangeNeeded) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.revertWrapNodeChange = exports.revertSplitNodeChange = void 0;
|
|
4
|
+
const prosemirror_model_1 = require("prosemirror-model");
|
|
4
5
|
const prosemirror_transform_1 = require("prosemirror-transform");
|
|
5
6
|
const nodeHelpers_1 = require("../compute/nodeHelpers");
|
|
6
7
|
const applyChanges_1 = require("./applyChanges");
|
|
@@ -26,17 +27,18 @@ function revertSplitNodeChange(tr, change, changeSet) {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
exports.revertSplitNodeChange = revertSplitNodeChange;
|
|
29
|
-
function revertWrapNodeChange(tr, change) {
|
|
30
|
+
function revertWrapNodeChange(tr, change, deleteMap) {
|
|
30
31
|
const from = tr.mapping.map(change.from);
|
|
31
32
|
const to = tr.mapping.map(change.to);
|
|
32
33
|
const node = tr.doc.nodeAt(from);
|
|
33
34
|
if (node === null || node === void 0 ? void 0 : node.isInline) {
|
|
34
|
-
tr.
|
|
35
|
+
tr.step(new prosemirror_transform_1.ReplaceAroundStep(from, to, from + 1, to - 1, prosemirror_model_1.Slice.empty, 0));
|
|
36
|
+
deleteMap.appendMap(tr.steps[tr.steps.length - 1].getMap());
|
|
35
37
|
}
|
|
36
38
|
else {
|
|
37
39
|
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
38
|
-
const $fromPos = tr.doc.resolve(pos);
|
|
39
|
-
const $toPos = tr.doc.resolve(pos + node.nodeSize - 1);
|
|
40
|
+
const $fromPos = tr.doc.resolve(tr.mapping.map(pos));
|
|
41
|
+
const $toPos = tr.doc.resolve(tr.mapping.map(pos + node.nodeSize - 1));
|
|
40
42
|
const nodeRange = $fromPos.blockRange($toPos);
|
|
41
43
|
if (!nodeRange) {
|
|
42
44
|
return;
|
|
@@ -44,6 +46,7 @@ function revertWrapNodeChange(tr, change) {
|
|
|
44
46
|
const targetLiftDepth = (0, prosemirror_transform_1.liftTarget)(nodeRange);
|
|
45
47
|
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
46
48
|
tr.lift(nodeRange, targetLiftDepth);
|
|
49
|
+
deleteMap.appendMap(tr.steps[tr.steps.length - 1].getMap());
|
|
47
50
|
}
|
|
48
51
|
});
|
|
49
52
|
}
|
|
@@ -14,7 +14,13 @@ export function getUpdatedDataTracked(dataTracked, changeId) {
|
|
|
14
14
|
return newDataTracked.length ? newDataTracked : null;
|
|
15
15
|
}
|
|
16
16
|
export function applyAcceptedRejectedChanges(tr, schema, changes, changeSet, deleteMap = new Mapping()) {
|
|
17
|
-
changes.sort((c1, c2) =>
|
|
17
|
+
changes.sort((c1, c2) => {
|
|
18
|
+
if ((c1.type === 'node-change' && c1.node.type === schema.nodes.list) ||
|
|
19
|
+
(c2.type === 'node-change' && c2.node.type === schema.nodes.list)) {
|
|
20
|
+
return -1;
|
|
21
|
+
}
|
|
22
|
+
return c1.dataTracked.updatedAt - c2.dataTracked.updatedAt;
|
|
23
|
+
});
|
|
18
24
|
changes.forEach((change) => {
|
|
19
25
|
if (change.dataTracked.operation === CHANGE_OPERATION.move) {
|
|
20
26
|
return;
|
|
@@ -34,7 +40,7 @@ export function applyAcceptedRejectedChanges(tr, schema, changes, changeSet, del
|
|
|
34
40
|
return revertSplitNodeChange(tr, change, changeSet);
|
|
35
41
|
}
|
|
36
42
|
if (change.dataTracked.operation === CHANGE_OPERATION.wrap_with_node) {
|
|
37
|
-
return revertWrapNodeChange(tr, change);
|
|
43
|
+
return revertWrapNodeChange(tr, change, deleteMap);
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
if (ChangeSet.isTextChange(change) && noChangeNeeded) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Slice } from 'prosemirror-model';
|
|
2
|
+
import { liftTarget, ReplaceAroundStep } from 'prosemirror-transform';
|
|
2
3
|
import { getBlockInlineTrackedData } from '../compute/nodeHelpers';
|
|
3
4
|
import { getUpdatedDataTracked } from './applyChanges';
|
|
4
5
|
export function revertSplitNodeChange(tr, change, changeSet) {
|
|
@@ -22,17 +23,18 @@ export function revertSplitNodeChange(tr, change, changeSet) {
|
|
|
22
23
|
tr.setNodeMarkup(tr.mapping.map(deleteChange.from), undefined, getUpdatedDataTracked(node.attrs.dataTracked, deleteChange.id));
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
export function revertWrapNodeChange(tr, change) {
|
|
26
|
+
export function revertWrapNodeChange(tr, change, deleteMap) {
|
|
26
27
|
const from = tr.mapping.map(change.from);
|
|
27
28
|
const to = tr.mapping.map(change.to);
|
|
28
29
|
const node = tr.doc.nodeAt(from);
|
|
29
30
|
if (node === null || node === void 0 ? void 0 : node.isInline) {
|
|
30
|
-
tr.
|
|
31
|
+
tr.step(new ReplaceAroundStep(from, to, from + 1, to - 1, Slice.empty, 0));
|
|
32
|
+
deleteMap.appendMap(tr.steps[tr.steps.length - 1].getMap());
|
|
31
33
|
}
|
|
32
34
|
else {
|
|
33
35
|
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
34
|
-
const $fromPos = tr.doc.resolve(pos);
|
|
35
|
-
const $toPos = tr.doc.resolve(pos + node.nodeSize - 1);
|
|
36
|
+
const $fromPos = tr.doc.resolve(tr.mapping.map(pos));
|
|
37
|
+
const $toPos = tr.doc.resolve(tr.mapping.map(pos + node.nodeSize - 1));
|
|
36
38
|
const nodeRange = $fromPos.blockRange($toPos);
|
|
37
39
|
if (!nodeRange) {
|
|
38
40
|
return;
|
|
@@ -40,6 +42,7 @@ export function revertWrapNodeChange(tr, change) {
|
|
|
40
42
|
const targetLiftDepth = liftTarget(nodeRange);
|
|
41
43
|
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
42
44
|
tr.lift(nodeRange, targetLiftDepth);
|
|
45
|
+
deleteMap.appendMap(tr.steps[tr.steps.length - 1].getMap());
|
|
43
46
|
}
|
|
44
47
|
});
|
|
45
48
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Transaction } from 'prosemirror-state';
|
|
2
|
+
import { Mapping } from 'prosemirror-transform';
|
|
2
3
|
import { ChangeSet } from '../ChangeSet';
|
|
3
4
|
import { IncompleteChange } from '../types/change';
|
|
4
5
|
export declare function revertSplitNodeChange(tr: Transaction, change: IncompleteChange, changeSet: ChangeSet): void;
|
|
5
|
-
export declare function revertWrapNodeChange(tr: Transaction, change: IncompleteChange): void;
|
|
6
|
+
export declare function revertWrapNodeChange(tr: Transaction, change: IncompleteChange, deleteMap: Mapping): void;
|
package/package.json
CHANGED