@manuscripts/track-changes-plugin 1.5.2-LEAN-2529 → 1.6.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.
- package/dist/index.cjs +9 -9
- package/dist/index.js +9 -9
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
|
@@ -448,7 +448,8 @@ function deleteNode(node, pos, tr) {
|
|
|
448
448
|
const resPos = tr.doc.resolve(pos);
|
|
449
449
|
// Block nodes can be deleted by just removing their start token which should then merge the text
|
|
450
450
|
// content to above node's content (if there is one)
|
|
451
|
-
|
|
451
|
+
// this will work just for the node after the first child
|
|
452
|
+
const canMergeToNodeAbove = resPos.parent !== tr.doc && resPos.nodeBefore && node.isBlock && ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.isText);
|
|
452
453
|
if (canMergeToNodeAbove) {
|
|
453
454
|
return tr.replaceWith(pos - 1, pos + 1, prosemirrorModel.Fragment.empty);
|
|
454
455
|
}
|
|
@@ -509,9 +510,9 @@ function mergeNode(node, pos, tr) {
|
|
|
509
510
|
if (prosemirrorTransform.canJoin(tr.doc, pos)) {
|
|
510
511
|
return tr.join(pos);
|
|
511
512
|
}
|
|
512
|
-
else if (
|
|
513
|
-
//
|
|
514
|
-
return
|
|
513
|
+
else if (!tr.doc.resolve(pos).nodeBefore) {
|
|
514
|
+
// for this case will just delete that node in `deleteNode.ts` as the join will not work
|
|
515
|
+
return undefined;
|
|
515
516
|
}
|
|
516
517
|
// TODO is this the same thing as join to above?
|
|
517
518
|
const resPos = tr.doc.resolve(pos);
|
|
@@ -1200,7 +1201,6 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1200
1201
|
let selectionPos = 0, changeSteps = [];
|
|
1201
1202
|
// Invert the transaction step to prevent it from actually deleting or inserting anything
|
|
1202
1203
|
step.getMap().forEach((fromA, toA, fromB, toB) => {
|
|
1203
|
-
var _a, _b;
|
|
1204
1204
|
log.info(`changed ranges: ${fromA} ${toA} ${fromB} ${toB}`);
|
|
1205
1205
|
const { slice } = step;
|
|
1206
1206
|
log.info('TR: steps before applying delete', [...newTr.steps]);
|
|
@@ -1248,6 +1248,9 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1248
1248
|
type: 'insert-slice',
|
|
1249
1249
|
from: textWasDeleted ? fromB : toA,
|
|
1250
1250
|
to: textWasDeleted ? toB - 1 : toA,
|
|
1251
|
+
/* it's not entirely clear why using "fromB" is needed at all but in cases where there areno content deleted before
|
|
1252
|
+
- it will gointo infinite loop if toB -1 is used
|
|
1253
|
+
*/
|
|
1251
1254
|
sliceWasSplit,
|
|
1252
1255
|
slice: new prosemirrorModel.Slice(setFragmentAsInserted(newSliceContent, createNewInsertAttrs(attrs), oldState.schema), openStart, openEnd),
|
|
1253
1256
|
});
|
|
@@ -1255,10 +1258,7 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1255
1258
|
else {
|
|
1256
1259
|
// Incase only deletion was applied, check whether tracked marks around deleted content can be merged
|
|
1257
1260
|
// mergeTrackedMarks(adjustedInsertPos, newTr.doc, newTr, oldState.schema)
|
|
1258
|
-
|
|
1259
|
-
// TODO: 'window.event' is deprecated, find a better way to detect the key used for deletion
|
|
1260
|
-
// @ts-ignore
|
|
1261
|
-
selectionPos = ((_a = window.event) === null || _a === void 0 ? void 0 : _a.code) === 'Delete' || ((_b = window.event) === null || _b === void 0 ? void 0 : _b.inputType) === 'deleteContentForward' ? toA : fromA;
|
|
1261
|
+
selectionPos = fromA;
|
|
1262
1262
|
}
|
|
1263
1263
|
});
|
|
1264
1264
|
return [changeSteps, selectionPos];
|
package/dist/index.js
CHANGED
|
@@ -440,7 +440,8 @@ function deleteNode(node, pos, tr) {
|
|
|
440
440
|
const resPos = tr.doc.resolve(pos);
|
|
441
441
|
// Block nodes can be deleted by just removing their start token which should then merge the text
|
|
442
442
|
// content to above node's content (if there is one)
|
|
443
|
-
|
|
443
|
+
// this will work just for the node after the first child
|
|
444
|
+
const canMergeToNodeAbove = resPos.parent !== tr.doc && resPos.nodeBefore && node.isBlock && ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.isText);
|
|
444
445
|
if (canMergeToNodeAbove) {
|
|
445
446
|
return tr.replaceWith(pos - 1, pos + 1, Fragment.empty);
|
|
446
447
|
}
|
|
@@ -501,9 +502,9 @@ function mergeNode(node, pos, tr) {
|
|
|
501
502
|
if (canJoin(tr.doc, pos)) {
|
|
502
503
|
return tr.join(pos);
|
|
503
504
|
}
|
|
504
|
-
else if (
|
|
505
|
-
//
|
|
506
|
-
return
|
|
505
|
+
else if (!tr.doc.resolve(pos).nodeBefore) {
|
|
506
|
+
// for this case will just delete that node in `deleteNode.ts` as the join will not work
|
|
507
|
+
return undefined;
|
|
507
508
|
}
|
|
508
509
|
// TODO is this the same thing as join to above?
|
|
509
510
|
const resPos = tr.doc.resolve(pos);
|
|
@@ -1192,7 +1193,6 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1192
1193
|
let selectionPos = 0, changeSteps = [];
|
|
1193
1194
|
// Invert the transaction step to prevent it from actually deleting or inserting anything
|
|
1194
1195
|
step.getMap().forEach((fromA, toA, fromB, toB) => {
|
|
1195
|
-
var _a, _b;
|
|
1196
1196
|
log.info(`changed ranges: ${fromA} ${toA} ${fromB} ${toB}`);
|
|
1197
1197
|
const { slice } = step;
|
|
1198
1198
|
log.info('TR: steps before applying delete', [...newTr.steps]);
|
|
@@ -1240,6 +1240,9 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1240
1240
|
type: 'insert-slice',
|
|
1241
1241
|
from: textWasDeleted ? fromB : toA,
|
|
1242
1242
|
to: textWasDeleted ? toB - 1 : toA,
|
|
1243
|
+
/* it's not entirely clear why using "fromB" is needed at all but in cases where there areno content deleted before
|
|
1244
|
+
- it will gointo infinite loop if toB -1 is used
|
|
1245
|
+
*/
|
|
1243
1246
|
sliceWasSplit,
|
|
1244
1247
|
slice: new Slice(setFragmentAsInserted(newSliceContent, createNewInsertAttrs(attrs), oldState.schema), openStart, openEnd),
|
|
1245
1248
|
});
|
|
@@ -1247,10 +1250,7 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1247
1250
|
else {
|
|
1248
1251
|
// Incase only deletion was applied, check whether tracked marks around deleted content can be merged
|
|
1249
1252
|
// mergeTrackedMarks(adjustedInsertPos, newTr.doc, newTr, oldState.schema)
|
|
1250
|
-
|
|
1251
|
-
// TODO: 'window.event' is deprecated, find a better way to detect the key used for deletion
|
|
1252
|
-
// @ts-ignore
|
|
1253
|
-
selectionPos = ((_a = window.event) === null || _a === void 0 ? void 0 : _a.code) === 'Delete' || ((_b = window.event) === null || _b === void 0 ? void 0 : _b.inputType) === 'deleteContentForward' ? toA : fromA;
|
|
1253
|
+
selectionPos = fromA;
|
|
1254
1254
|
}
|
|
1255
1255
|
});
|
|
1256
1256
|
return [changeSteps, selectionPos];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/track-changes-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
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",
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "rollup -c",
|
|
63
63
|
"watch": "rollup -cw",
|
|
64
|
-
"dev": "yarn run watch",
|
|
65
64
|
"test": "jest --runInBand",
|
|
66
65
|
"format": "prettier --write \"*.+(js|json|yml|yaml|ts|md|graphql|mdx)\" src/ test/",
|
|
67
66
|
"typecheck": "tsc --project tsconfig.test.json --noEmit",
|