@manuscripts/track-changes-plugin 1.7.17 → 1.7.18-LEAN-3840.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.
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2023 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __rest = (this && this.__rest) || function (s, e) {
18
+ var t = {};
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
+ t[p] = s[p];
21
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
+ t[p[i]] = s[p[i]];
25
+ }
26
+ return t;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const logger_1 = require("../utils/logger");
30
+ function trackAttrsChange(step, oldState, tr, newTr, attrs, currentStepDoc) {
31
+ const newStep = step.invert(currentStepDoc);
32
+ const stepResult = newTr.maybeStep(newStep);
33
+ if (stepResult.failed) {
34
+ logger_1.log.error(`inverting ReplaceAroundStep failed: "${stepResult.failed}"`, newStep);
35
+ return [];
36
+ }
37
+ const node = currentStepDoc.nodeAt(step.pos);
38
+ if (!node) {
39
+ return [];
40
+ }
41
+ const _a = node.attrs || {}, { dataTracked } = _a, newAttrs = __rest(_a, ["dataTracked"]);
42
+ const changeStep = {
43
+ pos: step.pos,
44
+ type: 'update-node-attrs',
45
+ node,
46
+ newAttrs: Object.assign(Object.assign({}, newAttrs), { [step.attr]: step.value }),
47
+ };
48
+ return [changeStep];
49
+ }
50
+ exports.default = trackAttrsChange;
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.trackTransaction = void 0;
4
7
  const prosemirror_state_1 = require("prosemirror-state");
@@ -8,6 +11,7 @@ const processChangeSteps_1 = require("../change-steps/processChangeSteps");
8
11
  const change_1 = require("../types/change");
9
12
  const logger_1 = require("../utils/logger");
10
13
  const mapChangeStep_1 = require("../utils/mapChangeStep");
14
+ const trackAttrsChange_1 = __importDefault(require("./trackAttrsChange"));
11
15
  const trackReplaceAroundStep_1 = require("./trackReplaceAroundStep");
12
16
  const trackReplaceStep_1 = require("./trackReplaceStep");
13
17
  const getSelectionStaticConstructor = (sel) => Object.getPrototypeOf(sel).constructor;
@@ -79,6 +83,10 @@ function trackTransaction(tr, oldState, newTr, authorID) {
79
83
  logger_1.log.info('DIFFED STEPS: ', steps);
80
84
  const [mapping, selectionPos] = (0, processChangeSteps_1.processChangeSteps)(steps, tr.selection.from, newTr, emptyAttrs, oldState.schema);
81
85
  }
86
+ else if (step instanceof prosemirror_transform_1.AttrStep) {
87
+ const chnageSteps = (0, trackAttrsChange_1.default)(step, oldState, tr, newTr, emptyAttrs, tr.docs[i]);
88
+ const [mapping, selectionPos] = (0, processChangeSteps_1.processChangeSteps)(chnageSteps, tr.selection.from, newTr, emptyAttrs, oldState.schema);
89
+ }
82
90
  tr.getMeta('inputType') && newTr.setMeta('inputType', tr.getMeta('inputType'));
83
91
  tr.getMeta('uiEvent') && newTr.setMeta('uiEvent', tr.getMeta('uiEvent'));
84
92
  }
@@ -0,0 +1,48 @@
1
+ /*!
2
+ * © 2023 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ var __rest = (this && this.__rest) || function (s, e) {
17
+ var t = {};
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
+ t[p] = s[p];
20
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
+ t[p[i]] = s[p[i]];
24
+ }
25
+ return t;
26
+ };
27
+ import { log } from '../utils/logger';
28
+ function trackAttrsChange(step, oldState, tr, newTr, attrs, currentStepDoc) {
29
+ const newStep = step.invert(currentStepDoc);
30
+ const stepResult = newTr.maybeStep(newStep);
31
+ if (stepResult.failed) {
32
+ log.error(`inverting ReplaceAroundStep failed: "${stepResult.failed}"`, newStep);
33
+ return [];
34
+ }
35
+ const node = currentStepDoc.nodeAt(step.pos);
36
+ if (!node) {
37
+ return [];
38
+ }
39
+ const _a = node.attrs || {}, { dataTracked } = _a, newAttrs = __rest(_a, ["dataTracked"]);
40
+ const changeStep = {
41
+ pos: step.pos,
42
+ type: 'update-node-attrs',
43
+ node,
44
+ newAttrs: Object.assign(Object.assign({}, newAttrs), { [step.attr]: step.value }),
45
+ };
46
+ return [changeStep];
47
+ }
48
+ export default trackAttrsChange;
@@ -1,10 +1,11 @@
1
1
  import { NodeSelection as NodeSelectionClass, TextSelection, } from 'prosemirror-state';
2
- import { ReplaceAroundStep, ReplaceStep } from 'prosemirror-transform';
2
+ import { AttrStep, ReplaceAroundStep, ReplaceStep, } from 'prosemirror-transform';
3
3
  import { diffChangeSteps } from '../change-steps/diffChangeSteps';
4
4
  import { processChangeSteps } from '../change-steps/processChangeSteps';
5
5
  import { CHANGE_STATUS } from '../types/change';
6
6
  import { log } from '../utils/logger';
7
7
  import { mapChangeSteps } from '../utils/mapChangeStep';
8
+ import trackAttrsChange from './trackAttrsChange';
8
9
  import { trackReplaceAroundStep } from './trackReplaceAroundStep';
9
10
  import { trackReplaceStep } from './trackReplaceStep';
10
11
  const getSelectionStaticConstructor = (sel) => Object.getPrototypeOf(sel).constructor;
@@ -76,6 +77,10 @@ export function trackTransaction(tr, oldState, newTr, authorID) {
76
77
  log.info('DIFFED STEPS: ', steps);
77
78
  const [mapping, selectionPos] = processChangeSteps(steps, tr.selection.from, newTr, emptyAttrs, oldState.schema);
78
79
  }
80
+ else if (step instanceof AttrStep) {
81
+ const chnageSteps = trackAttrsChange(step, oldState, tr, newTr, emptyAttrs, tr.docs[i]);
82
+ const [mapping, selectionPos] = processChangeSteps(chnageSteps, tr.selection.from, newTr, emptyAttrs, oldState.schema);
83
+ }
79
84
  tr.getMeta('inputType') && newTr.setMeta('inputType', tr.getMeta('inputType'));
80
85
  tr.getMeta('uiEvent') && newTr.setMeta('uiEvent', tr.getMeta('uiEvent'));
81
86
  }
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * © 2023 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Node as PMNode } from 'prosemirror-model';
17
+ import { EditorState, Transaction } from 'prosemirror-state';
18
+ import { AttrStep } from 'prosemirror-transform';
19
+ import { ChangeStep } from '../types/step';
20
+ import { NewEmptyAttrs } from '../types/track';
21
+ declare function trackAttrsChange(step: AttrStep, oldState: EditorState, tr: Transaction, newTr: Transaction, attrs: NewEmptyAttrs, currentStepDoc: PMNode): ChangeStep[];
22
+ export default trackAttrsChange;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuscripts/track-changes-plugin",
3
- "version": "1.7.17",
3
+ "version": "1.7.18-LEAN-3840.0",
4
4
  "author": "Atypon Systems LLC",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/Atypon-OpenSource/manuscripts-track-changes-plugin",