@manuscripts/article-editor 4.2.8 → 4.2.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.
Files changed (103) hide show
  1. package/dist/cjs/EditorApp.js +8 -1
  2. package/dist/cjs/EditorApp.js.map +1 -1
  3. package/dist/cjs/Main.js +3 -3
  4. package/dist/cjs/Main.js.map +1 -1
  5. package/dist/cjs/components/inspector/SnapshotsList.js +14 -2
  6. package/dist/cjs/components/inspector/SnapshotsList.js.map +1 -1
  7. package/dist/cjs/components/projects/EditorElement.js +5 -4
  8. package/dist/cjs/components/projects/EditorElement.js.map +1 -1
  9. package/dist/cjs/components/projects/Inspector.js +6 -0
  10. package/dist/cjs/components/projects/Inspector.js.map +1 -1
  11. package/dist/cjs/components/projects/ManuscriptPageContainer.js +4 -3
  12. package/dist/cjs/components/projects/ManuscriptPageContainer.js.map +1 -1
  13. package/dist/cjs/components/tools/CompareDocumentsModal.js +170 -0
  14. package/dist/cjs/components/tools/CompareDocumentsModal.js.map +1 -0
  15. package/dist/cjs/components/track-changes/SortByDropdown.js +1 -1
  16. package/dist/cjs/components/track-changes/TrackChangesPanel.js +16 -3
  17. package/dist/cjs/components/track-changes/TrackChangesPanel.js.map +1 -1
  18. package/dist/cjs/components/track-changes/suggestion-list/Suggestion.js +7 -3
  19. package/dist/cjs/components/track-changes/suggestion-list/Suggestion.js.map +1 -1
  20. package/dist/cjs/components/track-changes/suggestion-list/SuggestionList.js +6 -2
  21. package/dist/cjs/components/track-changes/suggestion-list/SuggestionList.js.map +1 -1
  22. package/dist/cjs/hooks/use-compare-documents.js +69 -0
  23. package/dist/cjs/hooks/use-compare-documents.js.map +1 -0
  24. package/dist/cjs/hooks/use-create-editor.js +30 -13
  25. package/dist/cjs/hooks/use-create-editor.js.map +1 -1
  26. package/dist/cjs/index.js +3 -3
  27. package/dist/cjs/index.js.map +1 -1
  28. package/dist/cjs/lib/change-handlers.js +10 -1
  29. package/dist/cjs/lib/change-handlers.js.map +1 -1
  30. package/dist/cjs/lib/comparison/compare-documents.js +53 -0
  31. package/dist/cjs/lib/comparison/compare-documents.js.map +1 -0
  32. package/dist/cjs/lib/comparison/compare-paragraph-like.js +388 -0
  33. package/dist/cjs/lib/comparison/compare-paragraph-like.js.map +1 -0
  34. package/dist/cjs/lib/comparison/compare-table-element.js +567 -0
  35. package/dist/cjs/lib/comparison/compare-table-element.js.map +1 -0
  36. package/dist/cjs/lib/comparison/create-dataTracked-attrs.js +60 -0
  37. package/dist/cjs/lib/comparison/create-dataTracked-attrs.js.map +1 -0
  38. package/dist/cjs/lib/comparison/distribute-nodes.js +131 -0
  39. package/dist/cjs/lib/comparison/distribute-nodes.js.map +1 -0
  40. package/dist/cjs/lib/comparison/rebuild-nodes-tree.js +76 -0
  41. package/dist/cjs/lib/comparison/rebuild-nodes-tree.js.map +1 -0
  42. package/dist/cjs/store/Store.js +7 -2
  43. package/dist/cjs/store/Store.js.map +1 -1
  44. package/dist/es/EditorApp.js +8 -1
  45. package/dist/es/EditorApp.js.map +1 -1
  46. package/dist/es/Main.js +3 -3
  47. package/dist/es/Main.js.map +1 -1
  48. package/dist/es/components/inspector/SnapshotsList.js +15 -3
  49. package/dist/es/components/inspector/SnapshotsList.js.map +1 -1
  50. package/dist/es/components/projects/EditorElement.js +5 -4
  51. package/dist/es/components/projects/EditorElement.js.map +1 -1
  52. package/dist/es/components/projects/Inspector.js +6 -0
  53. package/dist/es/components/projects/Inspector.js.map +1 -1
  54. package/dist/es/components/projects/ManuscriptPageContainer.js +4 -3
  55. package/dist/es/components/projects/ManuscriptPageContainer.js.map +1 -1
  56. package/dist/es/components/tools/CompareDocumentsModal.js +140 -0
  57. package/dist/es/components/tools/CompareDocumentsModal.js.map +1 -0
  58. package/dist/es/components/track-changes/SortByDropdown.js +1 -1
  59. package/dist/es/components/track-changes/TrackChangesPanel.js +16 -3
  60. package/dist/es/components/track-changes/TrackChangesPanel.js.map +1 -1
  61. package/dist/es/components/track-changes/suggestion-list/Suggestion.js +7 -3
  62. package/dist/es/components/track-changes/suggestion-list/Suggestion.js.map +1 -1
  63. package/dist/es/components/track-changes/suggestion-list/SuggestionList.js +6 -2
  64. package/dist/es/components/track-changes/suggestion-list/SuggestionList.js.map +1 -1
  65. package/dist/es/hooks/use-compare-documents.js +65 -0
  66. package/dist/es/hooks/use-compare-documents.js.map +1 -0
  67. package/dist/es/hooks/use-create-editor.js +31 -14
  68. package/dist/es/hooks/use-create-editor.js.map +1 -1
  69. package/dist/es/index.js +3 -3
  70. package/dist/es/index.js.map +1 -1
  71. package/dist/es/lib/change-handlers.js +10 -1
  72. package/dist/es/lib/change-handlers.js.map +1 -1
  73. package/dist/es/lib/comparison/compare-documents.js +48 -0
  74. package/dist/es/lib/comparison/compare-documents.js.map +1 -0
  75. package/dist/es/lib/comparison/compare-paragraph-like.js +378 -0
  76. package/dist/es/lib/comparison/compare-paragraph-like.js.map +1 -0
  77. package/dist/es/lib/comparison/compare-table-element.js +559 -0
  78. package/dist/es/lib/comparison/compare-table-element.js.map +1 -0
  79. package/dist/es/lib/comparison/create-dataTracked-attrs.js +54 -0
  80. package/dist/es/lib/comparison/create-dataTracked-attrs.js.map +1 -0
  81. package/dist/es/lib/comparison/distribute-nodes.js +127 -0
  82. package/dist/es/lib/comparison/distribute-nodes.js.map +1 -0
  83. package/dist/es/lib/comparison/rebuild-nodes-tree.js +72 -0
  84. package/dist/es/lib/comparison/rebuild-nodes-tree.js.map +1 -0
  85. package/dist/es/store/Store.js +7 -2
  86. package/dist/es/store/Store.js.map +1 -1
  87. package/dist/types/EditorApp.d.ts +2 -1
  88. package/dist/types/Main.d.ts +1 -1
  89. package/dist/types/components/projects/ManuscriptPageContainer.d.ts +1 -1
  90. package/dist/types/components/tools/CompareDocumentsModal.d.ts +11 -0
  91. package/dist/types/components/track-changes/TrackChangesPanel.d.ts +1 -1
  92. package/dist/types/components/track-changes/suggestion-list/Suggestion.d.ts +1 -1
  93. package/dist/types/components/track-changes/suggestion-list/SuggestionList.d.ts +3 -3
  94. package/dist/types/hooks/use-compare-documents.d.ts +24 -0
  95. package/dist/types/index.d.ts +1 -1
  96. package/dist/types/lib/comparison/compare-documents.d.ts +16 -0
  97. package/dist/types/lib/comparison/compare-paragraph-like.d.ts +23 -0
  98. package/dist/types/lib/comparison/compare-table-element.d.ts +21 -0
  99. package/dist/types/lib/comparison/create-dataTracked-attrs.d.ts +15 -0
  100. package/dist/types/lib/comparison/distribute-nodes.d.ts +19 -0
  101. package/dist/types/lib/comparison/rebuild-nodes-tree.d.ts +14 -0
  102. package/dist/types/store/Store.d.ts +3 -1
  103. package/package.json +5 -3
@@ -0,0 +1,127 @@
1
+ // Creates a unique key for a node
2
+ const createNodeKey = (node, index = 0) => {
3
+ const id = node.attrs.id || node.attrs.objectId;
4
+ if (id) {
5
+ return `${node.type.name}:${id}`;
6
+ }
7
+ return `${node.type.name}:${index}`;
8
+ };
9
+ // Distributes the nodes for comparison
10
+ // It creates a map of nodes with their original and comparison nodes
11
+ // Add status to the nodes to indicate if they are deleted, inserted or unchanged, and children nodes
12
+ // Status helps to prevent unnecessary calculations
13
+ export const distributeNodesForComparison = (originalNodes, comparisonNodes) => {
14
+ const distributedMap = new Map();
15
+ const processChildNodes = (node, isOriginal, parentMap, orderMap) => {
16
+ if (node.content && node.content.childCount > 0) {
17
+ // Create an ordered array to track position
18
+ const childKeys = [];
19
+ let count = 0;
20
+ node.content.forEach((childNode, index) => {
21
+ const key = createNodeKey(childNode, count++);
22
+ childKeys.push(key);
23
+ // Store the position in the order map
24
+ if (!isOriginal) {
25
+ orderMap.set(key, index);
26
+ }
27
+ if (!parentMap.has(key)) {
28
+ parentMap.set(key, {
29
+ originalNode: isOriginal ? childNode : undefined,
30
+ comparisonNode: isOriginal ? undefined : childNode,
31
+ children: new Map(),
32
+ status: isOriginal ? 'deleted' : 'inserted',
33
+ });
34
+ }
35
+ else {
36
+ const existingEntry = parentMap.get(key);
37
+ if (isOriginal) {
38
+ existingEntry.originalNode = childNode;
39
+ }
40
+ else {
41
+ existingEntry.comparisonNode = childNode;
42
+ }
43
+ if (existingEntry.originalNode && existingEntry.comparisonNode) {
44
+ existingEntry.status = 'unchanged';
45
+ }
46
+ if (!existingEntry.children) {
47
+ existingEntry.children = new Map();
48
+ }
49
+ }
50
+ // Recursively process children of this node
51
+ const childOrderMap = new Map();
52
+ processChildNodes(childNode, isOriginal, parentMap.get(key).children, childOrderMap);
53
+ });
54
+ // When processing the comparison document, reorder the map based on the order of nodes
55
+ if (!isOriginal) {
56
+ const orderedMap = new Map();
57
+ const sortedKeys = [...parentMap.keys()].sort((a, b) => {
58
+ const posA = orderMap.get(a) ?? Number.MAX_VALUE;
59
+ const posB = orderMap.get(b) ?? Number.MAX_VALUE;
60
+ return posA - posB;
61
+ });
62
+ // Rebuild the map in correct order
63
+ for (const key of sortedKeys) {
64
+ orderedMap.set(key, parentMap.get(key));
65
+ }
66
+ // Clear the original map and replace with ordered entries
67
+ parentMap.clear();
68
+ for (const [key, value] of orderedMap.entries()) {
69
+ parentMap.set(key, value);
70
+ }
71
+ }
72
+ }
73
+ };
74
+ // First pass: original nodes
75
+ const topLevelOrderMap = new Map();
76
+ originalNodes.forEach((node, index) => {
77
+ const key = createNodeKey(node);
78
+ distributedMap.set(key, {
79
+ originalNode: node,
80
+ children: new Map(),
81
+ status: 'deleted', // Initially marked as deleted until we find a match
82
+ });
83
+ // Store original order
84
+ topLevelOrderMap.set(key, index);
85
+ const childOrderMap = new Map();
86
+ processChildNodes(node, true, distributedMap.get(key).children, childOrderMap);
87
+ });
88
+ // Second pass: comparison nodes
89
+ const comparisonOrderMap = new Map();
90
+ comparisonNodes.forEach((node, index) => {
91
+ const key = createNodeKey(node);
92
+ comparisonOrderMap.set(key, index);
93
+ if (distributedMap.has(key)) {
94
+ const existingEntry = distributedMap.get(key);
95
+ existingEntry.comparisonNode = node;
96
+ existingEntry.status = 'unchanged';
97
+ if (!existingEntry.children) {
98
+ existingEntry.children = new Map();
99
+ }
100
+ }
101
+ else {
102
+ distributedMap.set(key, {
103
+ comparisonNode: node,
104
+ children: new Map(),
105
+ status: 'inserted',
106
+ });
107
+ }
108
+ // Process children for body and backmatter nodes
109
+ const childOrderMap = new Map();
110
+ processChildNodes(node, false, distributedMap.get(key).children, childOrderMap);
111
+ });
112
+ // Final step: reorder the top-level map based on the comparison document
113
+ const finalOrderedMap = new Map();
114
+ // Sort keys based on their position in the comparison document
115
+ const sortedKeys = [...distributedMap.keys()].sort((a, b) => {
116
+ // Use the position from comparison document, or fallback to original if not in comparison
117
+ const posA = comparisonOrderMap.get(a) ?? topLevelOrderMap.get(a) ?? Number.MAX_VALUE;
118
+ const posB = comparisonOrderMap.get(b) ?? topLevelOrderMap.get(b) ?? Number.MAX_VALUE;
119
+ return posA - posB;
120
+ });
121
+ // Rebuild the map in sorted order
122
+ for (const key of sortedKeys) {
123
+ finalOrderedMap.set(key, distributedMap.get(key));
124
+ }
125
+ return finalOrderedMap;
126
+ };
127
+ //# sourceMappingURL=distribute-nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distribute-nodes.js","sourceRoot":"","sources":["../../../../src/lib/comparison/distribute-nodes.ts"],"names":[],"mappings":"AAoBA,kCAAkC;AAClC,MAAM,aAAa,GAAG,CAAC,IAAoB,EAAE,KAAK,GAAG,CAAC,EAAU,EAAE;IAChE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;IAC/C,IAAI,EAAE,EAAE;QACN,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,CAAA;KACjC;IACD,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAA;AACrC,CAAC,CAAA;AAED,uCAAuC;AACvC,qEAAqE;AACrE,qGAAqG;AACrG,mDAAmD;AACnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,aAA6B,E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,IAAI,GAAG,EAA0B,CAAA;aAC3D;SACF;aAAM;YACL,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE;gBACtB,cAAc,EAAE,IAAI;gBACpB,QAAQ,EAAE,IAAI,GAAG,EAA0B;gBAC3C,MAAM,EAAE,UAAU;aACnB,CAAC,CAAA;SACH;QAED,iDAAiD;QACjD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAA;QAC/C,iBAAiB,CACf,IAAI,EACJ,KAAK,EACL,cAAc,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,QAAS,EAClC,aAAa,CACd,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,yEAAyE;IACzE,MAAM,eAAe,GAAG,IAAI,GAAG,EAA0B,CAAA;IAEzD,+DAA+D;IAC/D,MAAM,UAAU,GAAG,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1D,0FAA0F;QAC1F,MAAM,IAAI,GACR,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,CAAA;QAC1E,MAAM,IAAI,GACR,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,CAAA;QAC1E,OAAO,IAAI,GAAG,IAAI,CAAA;IACpB,CAAC,CAAC,CAAA;IAEF,kCAAkC;IAClC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;QAC5B,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,CAAA;KACnD;IAED,OAAO,eAAe,CAAA;AACxB,CAAC,CAAA"}
@@ -0,0 +1,72 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { schema } from '@manuscripts/transform';
13
+ import { compareSingleNodeAttrs } from './compare-documents';
14
+ import { compareParagraphLike } from './compare-paragraph-like';
15
+ import { compareTableElement } from './compare-table-element';
16
+ import { createComparisonDeleteAttrsDataTracked, createComparisonInsertAttrsDataTracked, } from './create-dataTracked-attrs';
17
+ // Rebuilds the nodes tree from the distributed nodes, and applies the changes to the nodes
18
+ export const rebuildDocNodeTree = (nodeId, nodeMap) => {
19
+ const entry = nodeMap.get(nodeId);
20
+ if (!entry) {
21
+ throw new Error(`Node with ID "${nodeId}" not found`);
22
+ }
23
+ const baseNode = entry.comparisonNode ?? entry.originalNode;
24
+ if (!baseNode) {
25
+ throw new Error(`No node available for "${nodeId}"`);
26
+ }
27
+ const rebuiltChildren = [];
28
+ if (entry.children && !baseNode?.isTextblock) {
29
+ for (const childId of entry.children.keys()) {
30
+ const childNode = rebuildDocNodeTree(childId, entry.children);
31
+ rebuiltChildren.push(childNode);
32
+ }
33
+ }
34
+ if (entry.status === 'deleted' &&
35
+ !entry.comparisonNode?.isText &&
36
+ !entry.originalNode?.isText) {
37
+ const finalAttrs = {
38
+ ...baseNode.attrs,
39
+ dataTracked: [createComparisonDeleteAttrsDataTracked('')],
40
+ };
41
+ return baseNode.type.create(finalAttrs, rebuiltChildren.length > 0 ? rebuiltChildren : baseNode.content);
42
+ }
43
+ else if (entry.status === 'inserted' &&
44
+ !entry.comparisonNode?.isText &&
45
+ !entry.originalNode?.isText) {
46
+ const finalAttrs = {
47
+ ...baseNode.attrs,
48
+ dataTracked: [createComparisonInsertAttrsDataTracked('')],
49
+ };
50
+ return baseNode.type.create(finalAttrs, rebuiltChildren.length > 0 ? rebuiltChildren : baseNode.content);
51
+ }
52
+ else if (entry.comparisonNode?.type == schema.nodes.table_element &&
53
+ entry.originalNode?.type == schema.nodes.table_element) {
54
+ // TODO: find more generic way to handle this
55
+ return compareTableElement(entry.originalNode, entry.comparisonNode);
56
+ }
57
+ else if (entry.comparisonNode?.isAtom &&
58
+ entry.comparisonNode?.isBlock &&
59
+ entry.originalNode?.isAtom &&
60
+ entry.originalNode?.isBlock) {
61
+ return compareSingleNodeAttrs(entry.originalNode, entry.comparisonNode, baseNode.type, rebuiltChildren);
62
+ }
63
+ else if (entry.comparisonNode?.isTextblock &&
64
+ entry.originalNode?.isTextblock) {
65
+ return compareParagraphLike(entry.originalNode, entry.comparisonNode);
66
+ }
67
+ else if (entry.comparisonNode?.isBlock && entry.originalNode?.isBlock) {
68
+ return compareSingleNodeAttrs(entry.originalNode, entry.comparisonNode, baseNode.type, rebuiltChildren);
69
+ }
70
+ return baseNode.type.create({ ...baseNode.attrs }, rebuiltChildren.length > 0 ? rebuiltChildren : baseNode.content);
71
+ };
72
+ //# sourceMappingURL=rebuild-nodes-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rebuild-nodes-tree.js","sourceRoot":"","sources":["../../../../src/lib/comparison/rebuild-nodes-tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAkB,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/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AO,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,EAAE;QACvE,OAAO,sBAAsB,CAC3B,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,cAAc,EACpB,QAAQ,CAAC,IAAI,EACb,eAAe,CAChB,CAAA;KACF;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CACzB,EAAE,GAAG,QAAQ,CAAC,KAAK,EAAE,EACrB,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAChE,CAAA;AACH,CAAC,CAAA"}
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
9
  *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
11
  */
12
12
  import { buildStateFromSources } from '.';
13
13
  const DEFAULT_ACTION = '_'; // making actions optional
@@ -20,7 +20,12 @@ export class GenericStore {
20
20
  this.init = async (sources) => {
21
21
  this.sources = sources;
22
22
  const state = await buildStateFromSources(sources, this.setState);
23
- this.setState({ ...this.state, ...state, isViewingMode: false });
23
+ this.setState({
24
+ ...this.state,
25
+ ...state,
26
+ isViewingMode: false,
27
+ isComparingMode: false,
28
+ });
24
29
  // listening to changes before state applied
25
30
  this.beforeAction = (action, payload, store, setState) => {
26
31
  // provide a way for the data sources to cancel the action optionally
@@ -1 +1 @@
1
- {"version":3,"file":"Store.js","sourceRoot":"","sources":["../../../src/store/Store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAkBH,OAAO,EAAE,qBAAqB,EAA2B,MAAM,GAAG,CAAA;AAyDlE,MAAM,cAAc,GAAG,GAAG,CAAA,CAAC,0BAA0B;AAErD,MAAM,cAAc,GAAG,CAAC,OAAY,EAAE,KAAY,EA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AAc,CAAC,IAAI,CAAC,KAAM,CAAC,CAAA;SACjC;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;SACrE;QACD,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,KAAK,GAAG,EAAW,CAAA;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAA;IACxB,CAAC;CACF"}
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
9
  *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
11
  */
12
12
  import { FileAttachment, FileManagement } from '@manuscripts/body-editor';
13
13
  import React from 'react';
@@ -20,6 +20,7 @@ export interface EditorAppProps {
20
20
  permittedActions: string[];
21
21
  getAuthToken: () => Promise<string | undefined>;
22
22
  observer?: ManuscriptsStateObserver;
23
+ submissionID: string;
23
24
  }
24
25
  declare const EditorApp: React.FC<EditorAppProps>;
25
26
  export default EditorApp;
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
9
  *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
11
  */
12
12
  import React from 'react';
13
13
  import { EditorAppProps } from './EditorApp';
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
9
  *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
11
  */
12
12
  import '@manuscripts/body-editor/styles/Editor.css';
13
13
  import '@manuscripts/body-editor/styles/AdvancedEditor.css';
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { SnapshotLabel } from '../../lib/doc';
3
+ export interface CompareDocumentsModalProps {
4
+ snapshots: SnapshotLabel[];
5
+ loading?: boolean;
6
+ error?: string | null;
7
+ onCompare?: (originalId: string, comparisonId: string) => void;
8
+ onCancel: () => void;
9
+ submissionID: string;
10
+ }
11
+ export declare const CompareDocumentsModal: React.FC<CompareDocumentsModalProps>;
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
9
  *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
11
  */
12
12
  import React from 'react';
13
13
  export declare const TrackChangesPanel: React.FC;
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
9
  *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2022 Atypon Systems LLC. All Rights Reserved.
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
11
  */
12
12
  import { RootChange } from '@manuscripts/track-changes-plugin';
13
13
  import React from 'react';
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
9
  *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2022 Atypon Systems LLC. All Rights Reserved.
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
11
  */
12
12
  import { RootChange, RootChanges } from '@manuscripts/track-changes-plugin';
13
13
  import React from 'react';
@@ -17,8 +17,8 @@ export interface SuggestionListProps {
17
17
  title: string;
18
18
  type: string;
19
19
  sortBy: string;
20
- onAccept(change: RootChange): void;
21
- onReject(change: RootChange): void;
20
+ onAccept(change: RootChange): void | undefined;
21
+ onReject(change: RootChange): void | undefined;
22
22
  onAcceptAll?(): void;
23
23
  onSelect?(change: RootChange): void;
24
24
  }
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { ManuscriptSnapshot } from '../lib/doc';
13
+ interface UseCompareDocumentsProps {
14
+ originalId?: string;
15
+ comparisonId?: string;
16
+ getSnapshot: (id: string) => Promise<ManuscriptSnapshot | undefined>;
17
+ }
18
+ export declare const useCompareDocuments: ({ originalId, comparisonId, getSnapshot, }: UseCompareDocumentsProps) => {
19
+ comparedDoc: import("prosemirror-model").Node | null;
20
+ isComparingMode: boolean;
21
+ isLoading: boolean;
22
+ error: string | null;
23
+ };
24
+ export {};
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
9
  *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
11
  */
12
12
  import './lib/fonts';
13
13
  import React from 'react';
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { ManuscriptNode } from '@manuscripts/transform';
13
+ import { NodeType } from 'prosemirror-model';
14
+ import { ManuscriptSnapshot } from '../doc';
15
+ export declare const compareDocuments: (originalSnapshot: ManuscriptSnapshot, comparisonSnapshot: ManuscriptSnapshot) => import("prosemirror-model").Node;
16
+ export declare const compareSingleNodeAttrs: (originalNode: ManuscriptNode, comparisonNode: ManuscriptNode, nodeType: NodeType, rebuiltChildren: ManuscriptNode[]) => ManuscriptNode;
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { ManuscriptNode } from '@manuscripts/transform';
13
+ import { NodeType } from 'prosemirror-model';
14
+ export declare const compareParagraphLike: (originalNode: ManuscriptNode, comparisonNode: ManuscriptNode) => ManuscriptNode;
15
+ export declare const containsOnlyTextNodes: (node: ManuscriptNode) => boolean;
16
+ type FlattenedChunk = {
17
+ type: 'text' | 'inline';
18
+ key: string;
19
+ node: ManuscriptNode;
20
+ };
21
+ export declare const rebuildFromDiff: (diffs: [number, string][], originalChunks: FlattenedChunk[], comparisonChunks: FlattenedChunk[]) => ManuscriptNode[];
22
+ export declare const compareTextLikeContent: (original: ManuscriptNode, comparison: ManuscriptNode, wrapperNodeType: NodeType) => ManuscriptNode;
23
+ export {};
@@ -0,0 +1,21 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { ManuscriptNode } from '@manuscripts/transform';
13
+ /**
14
+ * Compare two table elements and track changes between them.
15
+ * This is the main entry point for table comparison.
16
+ */
17
+ export declare const compareTableElement: (originalNode: ManuscriptNode, comparisonNode: ManuscriptNode) => ManuscriptNode;
18
+ /**
19
+ * Compare figcaption nodes and their content.
20
+ */
21
+ export declare const compareFigCaption: (originalNode: ManuscriptNode, comparisonNode: ManuscriptNode) => ManuscriptNode;
@@ -0,0 +1,15 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { TrackedAttrs } from '@manuscripts/track-changes-plugin';
13
+ export declare const createComparisonSetAttrsDataTracked: (authorID: string, oldAttrs: Record<string, unknown>) => TrackedAttrs;
14
+ export declare const createComparisonDeleteAttrsDataTracked: (authorID: string) => TrackedAttrs;
15
+ export declare const createComparisonInsertAttrsDataTracked: (authorID: string) => TrackedAttrs;
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { ManuscriptNode } from '@manuscripts/transform';
13
+ export type NodeComparison = {
14
+ originalNode?: ManuscriptNode;
15
+ comparisonNode?: ManuscriptNode;
16
+ children?: Map<string, NodeComparison>;
17
+ status?: 'deleted' | 'inserted' | 'unchanged';
18
+ };
19
+ export declare const distributeNodesForComparison: (originalNodes: ManuscriptNode, comparisonNodes: ManuscriptNode) => Map<string, NodeComparison>;
@@ -0,0 +1,14 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ import { ManuscriptNode } from '@manuscripts/transform';
13
+ import { NodeComparison } from './distribute-nodes';
14
+ export declare const rebuildDocNodeTree: (nodeId: string, nodeMap: Map<string, NodeComparison>) => ManuscriptNode;
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
9
  *
10
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
11
11
  */
12
12
  import { CommentKey, FileAttachment, FileManagement } from '@manuscripts/body-editor';
13
13
  import { Project, UserProfile } from '@manuscripts/json-schema';
@@ -26,6 +26,7 @@ export type state = {
26
26
  manuscriptID: string;
27
27
  projectID: string;
28
28
  userID?: string;
29
+ submissionID?: string;
29
30
  project: Project;
30
31
  refreshProject: () => Promise<void>;
31
32
  user: UserProfile;
@@ -34,6 +35,7 @@ export type state = {
34
35
  initialDocVersion: number;
35
36
  trackState?: TrackChangesState;
36
37
  isViewingMode?: boolean;
38
+ isComparingMode?: boolean;
37
39
  view?: ManuscriptEditorView;
38
40
  titleText: string;
39
41
  fileManagement: FileManagement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuscripts/article-editor",
3
- "version": "4.2.8",
3
+ "version": "4.2.10",
4
4
  "license": "CPAL-1.0",
5
5
  "description": "React components for editing and viewing manuscripts",
6
6
  "repository": "github:Atypon-OpenSource/manuscripts-article-editor",
@@ -31,7 +31,7 @@
31
31
  "@fontsource/pt-sans": "5.2.5",
32
32
  "@fontsource/pt-serif": "5.2.5",
33
33
  "@headlessui/react": "2.2.3",
34
- "@manuscripts/body-editor": "3.2.6",
34
+ "@manuscripts/body-editor": "3.2.7",
35
35
  "@manuscripts/json-schema": "2.2.12",
36
36
  "@manuscripts/style-guide": "3.1.0",
37
37
  "@manuscripts/track-changes-plugin": "2.0.1",
@@ -58,7 +58,8 @@
58
58
  "react-select": "5.10.1",
59
59
  "styled-components": "5.3.11",
60
60
  "use-sync-external-store": "1.5.0",
61
- "uuid": "9.0.1"
61
+ "uuid": "9.0.1",
62
+ "diff-match-patch": "^1.0.5"
62
63
  },
63
64
  "devDependencies": {
64
65
  "@babel/core": "7.23.7",
@@ -74,6 +75,7 @@
74
75
  "@types/styled-components": "5.1.34",
75
76
  "@types/use-sync-external-store": "1.5.0",
76
77
  "@types/uuid": "9.0.8",
78
+ "@types/diff-match-patch": "^1.0.36",
77
79
  "@typescript-eslint/eslint-plugin": "5.62.0",
78
80
  "@typescript-eslint/parser": "5.62.0",
79
81
  "babel-jest": "29.7.0",