@manuscripts/track-changes-plugin 1.5.1-LEAN-2431 → 1.5.2-LEAN-2529
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 +7 -12
- package/dist/index.js +7 -12
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1200,6 +1200,7 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1200
1200
|
let selectionPos = 0, changeSteps = [];
|
|
1201
1201
|
// Invert the transaction step to prevent it from actually deleting or inserting anything
|
|
1202
1202
|
step.getMap().forEach((fromA, toA, fromB, toB) => {
|
|
1203
|
+
var _a, _b;
|
|
1203
1204
|
log.info(`changed ranges: ${fromA} ${toA} ${fromB} ${toB}`);
|
|
1204
1205
|
const { slice } = step;
|
|
1205
1206
|
log.info('TR: steps before applying delete', [...newTr.steps]);
|
|
@@ -1217,14 +1218,13 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1217
1218
|
// console.log(JSON.parse(JSON.stringify(changeSteps)))
|
|
1218
1219
|
function sameThingBackSpaced() {
|
|
1219
1220
|
/*
|
|
1220
|
-
When deleting text with backspace and getting to the point of when a space and a character before
|
|
1221
|
+
When deleting text with backspace and getting to the point of when a space and a character before a deleted piece of text is deleted
|
|
1221
1222
|
the prosemirror would interpret it as moving the <del> node (this is a tracked deletion) one characted behind.
|
|
1222
|
-
It normally results in [delete, delete, insert] set of ChangSteps where 1st delete is for the delete done by
|
|
1223
|
+
It normally results in [delete, delete, insert] set of ChangSteps where the 1st delete is for the delete done by
|
|
1223
1224
|
the backspace key, the second delete and the insert are a misinterpretation of the moved text. So these last 2 steps have to be caught
|
|
1224
1225
|
and removed as they are not meaningful.
|
|
1225
1226
|
*/
|
|
1226
1227
|
if (changeSteps.length == 2 && newSliceContent.size > 0) {
|
|
1227
|
-
// or jus thangeSteps.length == 2
|
|
1228
1228
|
const correspondingDeletion = changeSteps.find(
|
|
1229
1229
|
// @ts-ignore
|
|
1230
1230
|
(step) => step.node.text === newSliceContent.content[0].text // @TODO - get more precise proof of match. E.g.: position approximation
|
|
@@ -1240,22 +1240,14 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1240
1240
|
const textWasDeleted = !!changeSteps.length;
|
|
1241
1241
|
if (!backSpacedText && newSliceContent.size > 0) {
|
|
1242
1242
|
log.info('newSliceContent', newSliceContent);
|
|
1243
|
-
//
|
|
1244
|
-
// console.log('Sliced Content:')
|
|
1245
|
-
// console.log(newSliceContent)
|
|
1246
1243
|
// Since deleteAndMergeSplitBlockNodes modified the slice to not to contain any merged nodes,
|
|
1247
1244
|
// the sides should be equal. TODO can they be other than 0?
|
|
1248
|
-
// the sides should be equal. TODO can they be other than 0?
|
|
1249
|
-
//
|
|
1250
1245
|
const openStart = slice.openStart !== slice.openEnd ? 0 : slice.openStart;
|
|
1251
1246
|
const openEnd = slice.openStart !== slice.openEnd ? 0 : slice.openEnd;
|
|
1252
1247
|
changeSteps.push({
|
|
1253
1248
|
type: 'insert-slice',
|
|
1254
1249
|
from: textWasDeleted ? fromB : toA,
|
|
1255
1250
|
to: textWasDeleted ? toB - 1 : toA,
|
|
1256
|
-
/* it's not entirely clear why using "fromB" is needed at all but in cases where there areno content deleted before
|
|
1257
|
-
- it will gointo infinite loop if toB -1 is used
|
|
1258
|
-
*/
|
|
1259
1251
|
sliceWasSplit,
|
|
1260
1252
|
slice: new prosemirrorModel.Slice(setFragmentAsInserted(newSliceContent, createNewInsertAttrs(attrs), oldState.schema), openStart, openEnd),
|
|
1261
1253
|
});
|
|
@@ -1263,7 +1255,10 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1263
1255
|
else {
|
|
1264
1256
|
// Incase only deletion was applied, check whether tracked marks around deleted content can be merged
|
|
1265
1257
|
// mergeTrackedMarks(adjustedInsertPos, newTr.doc, newTr, oldState.schema)
|
|
1266
|
-
|
|
1258
|
+
// When DEL is used, the selection is set to the end of the deleted content
|
|
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;
|
|
1267
1262
|
}
|
|
1268
1263
|
});
|
|
1269
1264
|
return [changeSteps, selectionPos];
|
package/dist/index.js
CHANGED
|
@@ -1192,6 +1192,7 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1192
1192
|
let selectionPos = 0, changeSteps = [];
|
|
1193
1193
|
// Invert the transaction step to prevent it from actually deleting or inserting anything
|
|
1194
1194
|
step.getMap().forEach((fromA, toA, fromB, toB) => {
|
|
1195
|
+
var _a, _b;
|
|
1195
1196
|
log.info(`changed ranges: ${fromA} ${toA} ${fromB} ${toB}`);
|
|
1196
1197
|
const { slice } = step;
|
|
1197
1198
|
log.info('TR: steps before applying delete', [...newTr.steps]);
|
|
@@ -1209,14 +1210,13 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1209
1210
|
// console.log(JSON.parse(JSON.stringify(changeSteps)))
|
|
1210
1211
|
function sameThingBackSpaced() {
|
|
1211
1212
|
/*
|
|
1212
|
-
When deleting text with backspace and getting to the point of when a space and a character before
|
|
1213
|
+
When deleting text with backspace and getting to the point of when a space and a character before a deleted piece of text is deleted
|
|
1213
1214
|
the prosemirror would interpret it as moving the <del> node (this is a tracked deletion) one characted behind.
|
|
1214
|
-
It normally results in [delete, delete, insert] set of ChangSteps where 1st delete is for the delete done by
|
|
1215
|
+
It normally results in [delete, delete, insert] set of ChangSteps where the 1st delete is for the delete done by
|
|
1215
1216
|
the backspace key, the second delete and the insert are a misinterpretation of the moved text. So these last 2 steps have to be caught
|
|
1216
1217
|
and removed as they are not meaningful.
|
|
1217
1218
|
*/
|
|
1218
1219
|
if (changeSteps.length == 2 && newSliceContent.size > 0) {
|
|
1219
|
-
// or jus thangeSteps.length == 2
|
|
1220
1220
|
const correspondingDeletion = changeSteps.find(
|
|
1221
1221
|
// @ts-ignore
|
|
1222
1222
|
(step) => step.node.text === newSliceContent.content[0].text // @TODO - get more precise proof of match. E.g.: position approximation
|
|
@@ -1232,22 +1232,14 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1232
1232
|
const textWasDeleted = !!changeSteps.length;
|
|
1233
1233
|
if (!backSpacedText && newSliceContent.size > 0) {
|
|
1234
1234
|
log.info('newSliceContent', newSliceContent);
|
|
1235
|
-
//
|
|
1236
|
-
// console.log('Sliced Content:')
|
|
1237
|
-
// console.log(newSliceContent)
|
|
1238
1235
|
// Since deleteAndMergeSplitBlockNodes modified the slice to not to contain any merged nodes,
|
|
1239
1236
|
// the sides should be equal. TODO can they be other than 0?
|
|
1240
|
-
// the sides should be equal. TODO can they be other than 0?
|
|
1241
|
-
//
|
|
1242
1237
|
const openStart = slice.openStart !== slice.openEnd ? 0 : slice.openStart;
|
|
1243
1238
|
const openEnd = slice.openStart !== slice.openEnd ? 0 : slice.openEnd;
|
|
1244
1239
|
changeSteps.push({
|
|
1245
1240
|
type: 'insert-slice',
|
|
1246
1241
|
from: textWasDeleted ? fromB : toA,
|
|
1247
1242
|
to: textWasDeleted ? toB - 1 : toA,
|
|
1248
|
-
/* it's not entirely clear why using "fromB" is needed at all but in cases where there areno content deleted before
|
|
1249
|
-
- it will gointo infinite loop if toB -1 is used
|
|
1250
|
-
*/
|
|
1251
1243
|
sliceWasSplit,
|
|
1252
1244
|
slice: new Slice(setFragmentAsInserted(newSliceContent, createNewInsertAttrs(attrs), oldState.schema), openStart, openEnd),
|
|
1253
1245
|
});
|
|
@@ -1255,7 +1247,10 @@ function trackReplaceStep(step, oldState, newTr, attrs, stepResult, currentStepD
|
|
|
1255
1247
|
else {
|
|
1256
1248
|
// Incase only deletion was applied, check whether tracked marks around deleted content can be merged
|
|
1257
1249
|
// mergeTrackedMarks(adjustedInsertPos, newTr.doc, newTr, oldState.schema)
|
|
1258
|
-
|
|
1250
|
+
// When DEL is used, the selection is set to the end of the deleted content
|
|
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;
|
|
1259
1254
|
}
|
|
1260
1255
|
});
|
|
1261
1256
|
return [changeSteps, selectionPos];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/track-changes-plugin",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2-LEAN-2529",
|
|
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,6 +61,7 @@
|
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "rollup -c",
|
|
63
63
|
"watch": "rollup -cw",
|
|
64
|
+
"dev": "yarn run watch",
|
|
64
65
|
"test": "jest --runInBand",
|
|
65
66
|
"format": "prettier --write \"*.+(js|json|yml|yaml|ts|md|graphql|mdx)\" src/ test/",
|
|
66
67
|
"typecheck": "tsc --project tsconfig.test.json --noEmit",
|