@manuscripts/track-changes-plugin 1.7.10-LEAN-3136-2MB → 1.7.10
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.
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.trackTransaction = void 0;
|
|
4
4
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
5
|
-
const prosemirror_state_2 = require("prosemirror-state");
|
|
6
5
|
const prosemirror_transform_1 = require("prosemirror-transform");
|
|
7
6
|
const diffChangeSteps_1 = require("../change-steps/diffChangeSteps");
|
|
8
7
|
const processChangeSteps_1 = require("../change-steps/processChangeSteps");
|
|
@@ -22,8 +21,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
22
21
|
statusUpdateAt: 0,
|
|
23
22
|
status: change_1.CHANGE_STATUS.pending,
|
|
24
23
|
};
|
|
25
|
-
const wasNodeSelection = tr.selection instanceof
|
|
26
|
-
const setsNewSelection = tr.selectionSet;
|
|
24
|
+
const wasNodeSelection = tr.selection instanceof prosemirror_state_1.NodeSelection;
|
|
27
25
|
let iters = 0;
|
|
28
26
|
logger_1.log.info('ORIGINAL transaction', tr);
|
|
29
27
|
for (let i = tr.steps.length - 1; i >= 0; i--) {
|
|
@@ -60,7 +58,7 @@ function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
60
58
|
steps = (0, diffChangeSteps_1.diffChangeSteps)(deleted, inserted);
|
|
61
59
|
logger_1.log.info('DIFFED STEPS: ', steps);
|
|
62
60
|
const [mapping, selectionPos] = (0, processChangeSteps_1.processChangeSteps)(steps, startPos || tr.selection.head, newTr, emptyAttrs, oldState.schema);
|
|
63
|
-
if (!wasNodeSelection
|
|
61
|
+
if (!wasNodeSelection) {
|
|
64
62
|
const sel = getSelectionStaticConstructor(tr.selection);
|
|
65
63
|
const near = sel.near(newTr.doc.resolve(selectionPos), -1);
|
|
66
64
|
newTr.setSelection(near);
|
|
@@ -78,13 +76,9 @@ function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
78
76
|
tr.getMeta('inputType') && newTr.setMeta('inputType', tr.getMeta('inputType'));
|
|
79
77
|
tr.getMeta('uiEvent') && newTr.setMeta('uiEvent', tr.getMeta('uiEvent'));
|
|
80
78
|
}
|
|
81
|
-
if (setsNewSelection && tr.selection instanceof prosemirror_state_1.TextSelection) {
|
|
82
|
-
const newPos = newTr.doc.resolve(tr.selection.from);
|
|
83
|
-
newTr.setSelection(new prosemirror_state_1.TextSelection(newPos));
|
|
84
|
-
}
|
|
85
79
|
if (wasNodeSelection) {
|
|
86
80
|
console.log('%c Getting into node select! ', 'background: #222; color: #bada55');
|
|
87
|
-
const mappedPos = newTr.mapping.map(tr.selection.from);
|
|
81
|
+
const mappedPos = newTr.mapping.map(tr.selection.from, -1);
|
|
88
82
|
const sel = getSelectionStaticConstructor(tr.selection);
|
|
89
83
|
newTr.setSelection(sel.create(newTr.doc, mappedPos));
|
|
90
84
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TextSelection } from 'prosemirror-state';
|
|
2
1
|
import { NodeSelection as NodeSelectionClass } from 'prosemirror-state';
|
|
3
2
|
import { ReplaceAroundStep, ReplaceStep } from 'prosemirror-transform';
|
|
4
3
|
import { diffChangeSteps } from '../change-steps/diffChangeSteps';
|
|
@@ -20,7 +19,6 @@ export function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
20
19
|
status: CHANGE_STATUS.pending,
|
|
21
20
|
};
|
|
22
21
|
const wasNodeSelection = tr.selection instanceof NodeSelectionClass;
|
|
23
|
-
const setsNewSelection = tr.selectionSet;
|
|
24
22
|
let iters = 0;
|
|
25
23
|
log.info('ORIGINAL transaction', tr);
|
|
26
24
|
for (let i = tr.steps.length - 1; i >= 0; i--) {
|
|
@@ -57,7 +55,7 @@ export function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
57
55
|
steps = diffChangeSteps(deleted, inserted);
|
|
58
56
|
log.info('DIFFED STEPS: ', steps);
|
|
59
57
|
const [mapping, selectionPos] = processChangeSteps(steps, startPos || tr.selection.head, newTr, emptyAttrs, oldState.schema);
|
|
60
|
-
if (!wasNodeSelection
|
|
58
|
+
if (!wasNodeSelection) {
|
|
61
59
|
const sel = getSelectionStaticConstructor(tr.selection);
|
|
62
60
|
const near = sel.near(newTr.doc.resolve(selectionPos), -1);
|
|
63
61
|
newTr.setSelection(near);
|
|
@@ -75,13 +73,9 @@ export function trackTransaction(tr, oldState, newTr, authorID) {
|
|
|
75
73
|
tr.getMeta('inputType') && newTr.setMeta('inputType', tr.getMeta('inputType'));
|
|
76
74
|
tr.getMeta('uiEvent') && newTr.setMeta('uiEvent', tr.getMeta('uiEvent'));
|
|
77
75
|
}
|
|
78
|
-
if (setsNewSelection && tr.selection instanceof TextSelection) {
|
|
79
|
-
const newPos = newTr.doc.resolve(tr.selection.from);
|
|
80
|
-
newTr.setSelection(new TextSelection(newPos));
|
|
81
|
-
}
|
|
82
76
|
if (wasNodeSelection) {
|
|
83
77
|
console.log('%c Getting into node select! ', 'background: #222; color: #bada55');
|
|
84
|
-
const mappedPos = newTr.mapping.map(tr.selection.from);
|
|
78
|
+
const mappedPos = newTr.mapping.map(tr.selection.from, -1);
|
|
85
79
|
const sel = getSelectionStaticConstructor(tr.selection);
|
|
86
80
|
newTr.setSelection(sel.create(newTr.doc, mappedPos));
|
|
87
81
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EditorState, Transaction } from 'prosemirror-state';
|
|
1
|
+
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
2
|
export declare function trackTransaction(tr: Transaction, oldState: EditorState, newTr: Transaction, authorID: string): Transaction;
|
package/package.json
CHANGED