@manuscripts/track-changes-plugin 1.10.9-LEAN-2023.0 → 1.10.9
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/cjs/changes/applyChanges.js +8 -2
- package/dist/cjs/changes/revertChange.js +7 -4
- package/dist/cjs/steps/trackTransaction.js +1 -1
- package/dist/es/changes/applyChanges.js +8 -2
- package/dist/es/changes/revertChange.js +8 -5
- package/dist/es/steps/trackTransaction.js +1 -1
- package/dist/types/changes/revertChange.d.ts +2 -1
- package/dist/types/compute/splitSliceIntoMergedParts.d.ts +1 -1
- package/package.json +45 -41
|
@@ -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
|
}
|
|
@@ -117,7 +117,7 @@ function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
|
|
|
117
117
|
newTr.setSelection(new prosemirror_state_1.TextSelection(newPos));
|
|
118
118
|
}
|
|
119
119
|
if (wasNodeSelection) {
|
|
120
|
-
|
|
120
|
+
console.log('%c Getting into node select! ', 'background: #222; color: #bada55');
|
|
121
121
|
const mappedPos = newTr.mapping.map(tr.selection.from, -1);
|
|
122
122
|
const sel = getSelectionStaticConstructor(tr.selection);
|
|
123
123
|
newTr.setSelection(sel.create(newTr.doc, mappedPos));
|
|
@@ -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
|
}
|
|
@@ -111,7 +111,7 @@ export function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
|
|
|
111
111
|
newTr.setSelection(new TextSelection(newPos));
|
|
112
112
|
}
|
|
113
113
|
if (wasNodeSelection) {
|
|
114
|
-
log
|
|
114
|
+
console.log('%c Getting into node select! ', 'background: #222; color: #bada55');
|
|
115
115
|
const mappedPos = newTr.mapping.map(tr.selection.from, -1);
|
|
116
116
|
const sel = getSelectionStaticConstructor(tr.selection);
|
|
117
117
|
newTr.setSelection(sel.create(newTr.doc, mappedPos));
|
|
@@ -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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Node as PMNode } from 'prosemirror-model';
|
|
2
2
|
import { ExposedFragment, ExposedSlice } from '../types/pm';
|
|
3
3
|
export declare function splitSliceIntoMergedParts(insertSlice: ExposedSlice, mergeEqualSides?: boolean): {
|
|
4
|
-
updatedSliceNodes:
|
|
4
|
+
updatedSliceNodes: PMNode[];
|
|
5
5
|
firstMergedNode: {
|
|
6
6
|
mergedNodeContent: ExposedFragment;
|
|
7
7
|
unmergedContent: ExposedFragment | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/track-changes-plugin",
|
|
3
|
-
"version": "1.10.9
|
|
3
|
+
"version": "1.10.9",
|
|
4
4
|
"author": "Atypon Systems LLC",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/Atypon-OpenSource/manuscripts-track-changes-plugin",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"src/styles.css"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "npm-run-all --parallel build:*",
|
|
15
|
+
"build": "npm-run-all --parallel 'build:* --project tsconfig.json'",
|
|
16
16
|
"build:cjs": "tsc --outDir dist/cjs --module commonjs",
|
|
17
17
|
"build:es": "tsc --outDir dist/es --declarationDir dist/types --declaration",
|
|
18
|
-
"dev": "npm-run-all --parallel 'build:* --watch'",
|
|
18
|
+
"dev": "npm-run-all --parallel 'build:* --project tsconfig.json --watch'",
|
|
19
19
|
"test": "jest --runInBand",
|
|
20
20
|
"test-rs": "jest -i test/diff/diff.test.ts",
|
|
21
21
|
"format": "prettier --write \"*.+(js|json|yml|yaml|ts|md|graphql|mdx)\" src/ test/",
|
|
@@ -24,45 +24,49 @@
|
|
|
24
24
|
"lint:fix": "eslint --fix --ext .js,.ts, ./src ./test",
|
|
25
25
|
"prepare": "husky install"
|
|
26
26
|
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"debug": "4.4.1",
|
|
29
|
-
"prosemirror-commands": "1.7.1",
|
|
30
|
-
"prosemirror-history": "1.4.1",
|
|
31
|
-
"prosemirror-model": "1.25.0",
|
|
32
|
-
"prosemirror-state": "1.4.3",
|
|
33
|
-
"prosemirror-transform": "1.10.4",
|
|
34
|
-
"prosemirror-view": "1.40.0"
|
|
35
|
-
},
|
|
36
27
|
"devDependencies": {
|
|
37
|
-
"@manuscripts/eslint-config": "0.5.1",
|
|
28
|
+
"@manuscripts/eslint-config": "^0.5.1",
|
|
38
29
|
"@manuscripts/transform": "3.0.48",
|
|
39
|
-
"@types/debug": "4.1.
|
|
40
|
-
"@types/jest": "27.5.
|
|
41
|
-
"@types/node": "
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
43
|
-
"@typescript-eslint/parser": "5.
|
|
44
|
-
"eslint": "8.
|
|
45
|
-
"eslint-config-prettier": "8.
|
|
46
|
-
"eslint-plugin-header": "3.1.1",
|
|
47
|
-
"eslint-plugin-import": "2.
|
|
48
|
-
"eslint-plugin-jest": "27.
|
|
49
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
50
|
-
"eslint-plugin-mdx": "2.
|
|
51
|
-
"eslint-plugin-
|
|
52
|
-
"eslint-plugin-
|
|
53
|
-
"eslint-plugin-
|
|
54
|
-
"eslint-plugin-react": "
|
|
55
|
-
"eslint-plugin-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"jest": "
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
30
|
+
"@types/debug": "^4.1.7",
|
|
31
|
+
"@types/jest": "27.5.1",
|
|
32
|
+
"@types/node": "^18.7.18",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^5.47.0",
|
|
34
|
+
"@typescript-eslint/parser": "^5.47.0",
|
|
35
|
+
"eslint": "^8.46.0",
|
|
36
|
+
"eslint-config-prettier": "^8.5.0",
|
|
37
|
+
"eslint-plugin-header": "^3.1.1",
|
|
38
|
+
"eslint-plugin-import": "^2.26.0",
|
|
39
|
+
"eslint-plugin-jest": "^27.1.7",
|
|
40
|
+
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
41
|
+
"eslint-plugin-mdx": "2.0.4",
|
|
42
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
43
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
44
|
+
"eslint-plugin-react": "^7.31.11",
|
|
45
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
46
|
+
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
47
|
+
"husky": "^8.0.1",
|
|
48
|
+
"jest": "27.5.1",
|
|
49
|
+
"jest-environment-jsdom": "27.5.1",
|
|
50
|
+
"jsdom": "^20.0.0",
|
|
51
|
+
"npm-run-all": "^4.1.5",
|
|
52
|
+
"prettier": "^2.8.1",
|
|
53
|
+
"ts-jest": "27.1.4",
|
|
54
|
+
"tslib": "^2.4.0",
|
|
55
|
+
"typescript": "^4.8.3"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"debug": "^4.3.4",
|
|
59
|
+
"prosemirror-commands": "^1.5.0",
|
|
60
|
+
"prosemirror-example-setup": "^1.2.1",
|
|
61
|
+
"prosemirror-history": "^1.4.1",
|
|
62
|
+
"prosemirror-keymap": "^1.2.0",
|
|
63
|
+
"prosemirror-model": "^1.18.3",
|
|
64
|
+
"prosemirror-schema-list": "^1.2.2",
|
|
65
|
+
"prosemirror-state": "^1.4.2",
|
|
66
|
+
"prosemirror-transform": "^1.7.0",
|
|
67
|
+
"prosemirror-view": "^1.29.1"
|
|
68
|
+
},
|
|
69
|
+
"resolutions": {
|
|
70
|
+
"eslint-mdx": "2.0.5"
|
|
67
71
|
}
|
|
68
72
|
}
|