@atlaskit/editor-plugin-track-changes 2.5.0 → 2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-track-changes
2
2
 
3
+ ## 2.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`834a792f74e9c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/834a792f74e9c) -
8
+ [EDITOR-1254] Check if the document has changed from the baseline before allowing users to toggle
9
+ "Showing the diff"
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 2.5.0
4
16
 
5
17
  ### Minor Changes
@@ -0,0 +1,44 @@
1
+ {
2
+ "extends": "../../../../tsconfig.entry-points.passionfruit.json",
3
+ "compilerOptions": {
4
+ "target": "es5",
5
+ "outDir": "../../../../../passionfruit/tsDist/@atlaskit__editor-plugin-track-changes/app",
6
+ "rootDir": "../",
7
+ "composite": true
8
+ },
9
+ "include": [
10
+ "../src/**/*.ts",
11
+ "../src/**/*.tsx"
12
+ ],
13
+ "exclude": [
14
+ "../src/**/__tests__/*",
15
+ "../src/**/*.test.*",
16
+ "../src/**/test.*",
17
+ "../src/**/examples.*",
18
+ "../src/**/examples/*",
19
+ "../src/**/examples/**/*",
20
+ "../src/**/*.stories.*",
21
+ "../src/**/stories/*",
22
+ "../src/**/stories/**/*"
23
+ ],
24
+ "references": [
25
+ {
26
+ "path": "../../../design-system/button/afm-passionfruit/tsconfig.json"
27
+ },
28
+ {
29
+ "path": "../../editor-plugin-history/afm-passionfruit/tsconfig.json"
30
+ },
31
+ {
32
+ "path": "../../editor-plugin-primary-toolbar/afm-passionfruit/tsconfig.json"
33
+ },
34
+ {
35
+ "path": "../../editor-plugin-show-diff/afm-passionfruit/tsconfig.json"
36
+ },
37
+ {
38
+ "path": "../../../design-system/icon-lab/afm-passionfruit/tsconfig.json"
39
+ },
40
+ {
41
+ "path": "../../editor-common/afm-passionfruit/tsconfig.json"
42
+ }
43
+ ]
44
+ }
@@ -70,11 +70,21 @@ var createTrackChangesPlugin = exports.createTrackChangesPlugin = function creat
70
70
  var isDocChanged = tr.docChanged && tr.steps.some(function (step) {
71
71
  return step instanceof _transform.ReplaceStep || step instanceof _transform.ReplaceAroundStep;
72
72
  });
73
- if (!isDocChanged || tr.getMeta('isRemote') || tr.getMeta('addToHistory') === false) {
73
+ if (!isDocChanged || tr.getMeta('isRemote')) {
74
74
  // If no document changes, return the old changeSet
75
75
  return state;
76
76
  }
77
77
 
78
+ // For undo/redo operations (addToHistory === false), we still need to check if we're back at baseline
79
+ if (tr.getMeta('addToHistory') === false) {
80
+ // This is likely an undo/redo operation, check if current doc matches baseline
81
+ var _baselineDoc = getBaselineFromSteps(tr.doc, state.steps);
82
+ var _hasChangesFromBaseline = !tr.doc.eq(_baselineDoc);
83
+ return _objectSpread(_objectSpread({}, state), {}, {
84
+ isShowDiffAvailable: _hasChangesFromBaseline
85
+ });
86
+ }
87
+
78
88
  // If we don't have the history plugin don't limit the change tracking
79
89
  var historyState = api === null || api === void 0 || (_api$history = api.history) === null || _api$history === void 0 ? void 0 : _api$history.sharedState.currentState();
80
90
  var currentAllocation = historyState ?
@@ -89,12 +99,16 @@ var createTrackChangesPlugin = exports.createTrackChangesPlugin = function creat
89
99
  allocations = _filterSteps.allocations,
90
100
  steps = _filterSteps.steps;
91
101
 
102
+ // Calculate if there are actual changes by comparing current doc with baseline
103
+ var baselineDoc = getBaselineFromSteps(tr.doc, steps);
104
+ var hasChangesFromBaseline = !tr.doc.eq(baselineDoc);
105
+
92
106
  // Create a new ChangeSet based on document changes
93
107
  return _objectSpread(_objectSpread({}, state), {}, {
94
108
  allocations: allocations,
95
109
  steps: steps,
96
110
  shouldChangesBeDisplayed: false,
97
- isShowDiffAvailable: true
111
+ isShowDiffAvailable: hasChangesFromBaseline
98
112
  });
99
113
  }
100
114
  },
@@ -47,11 +47,22 @@ export const createTrackChangesPlugin = api => {
47
47
  };
48
48
  }
49
49
  const isDocChanged = tr.docChanged && tr.steps.some(step => step instanceof ReplaceStep || step instanceof ReplaceAroundStep);
50
- if (!isDocChanged || tr.getMeta('isRemote') || tr.getMeta('addToHistory') === false) {
50
+ if (!isDocChanged || tr.getMeta('isRemote')) {
51
51
  // If no document changes, return the old changeSet
52
52
  return state;
53
53
  }
54
54
 
55
+ // For undo/redo operations (addToHistory === false), we still need to check if we're back at baseline
56
+ if (tr.getMeta('addToHistory') === false) {
57
+ // This is likely an undo/redo operation, check if current doc matches baseline
58
+ const baselineDoc = getBaselineFromSteps(tr.doc, state.steps);
59
+ const hasChangesFromBaseline = !tr.doc.eq(baselineDoc);
60
+ return {
61
+ ...state,
62
+ isShowDiffAvailable: hasChangesFromBaseline
63
+ };
64
+ }
65
+
55
66
  // If we don't have the history plugin don't limit the change tracking
56
67
  const historyState = api === null || api === void 0 ? void 0 : (_api$history = api.history) === null || _api$history === void 0 ? void 0 : _api$history.sharedState.currentState();
57
68
  const currentAllocation = historyState ?
@@ -65,13 +76,17 @@ export const createTrackChangesPlugin = api => {
65
76
  steps
66
77
  } = filterSteps(concatSteps, state.allocations.add(currentAllocation));
67
78
 
79
+ // Calculate if there are actual changes by comparing current doc with baseline
80
+ const baselineDoc = getBaselineFromSteps(tr.doc, steps);
81
+ const hasChangesFromBaseline = !tr.doc.eq(baselineDoc);
82
+
68
83
  // Create a new ChangeSet based on document changes
69
84
  return {
70
85
  ...state,
71
86
  allocations,
72
87
  steps,
73
88
  shouldChangesBeDisplayed: false,
74
- isShowDiffAvailable: true
89
+ isShowDiffAvailable: hasChangesFromBaseline
75
90
  };
76
91
  }
77
92
  },
@@ -63,11 +63,21 @@ export var createTrackChangesPlugin = function createTrackChangesPlugin(api) {
63
63
  var isDocChanged = tr.docChanged && tr.steps.some(function (step) {
64
64
  return step instanceof ReplaceStep || step instanceof ReplaceAroundStep;
65
65
  });
66
- if (!isDocChanged || tr.getMeta('isRemote') || tr.getMeta('addToHistory') === false) {
66
+ if (!isDocChanged || tr.getMeta('isRemote')) {
67
67
  // If no document changes, return the old changeSet
68
68
  return state;
69
69
  }
70
70
 
71
+ // For undo/redo operations (addToHistory === false), we still need to check if we're back at baseline
72
+ if (tr.getMeta('addToHistory') === false) {
73
+ // This is likely an undo/redo operation, check if current doc matches baseline
74
+ var _baselineDoc = getBaselineFromSteps(tr.doc, state.steps);
75
+ var _hasChangesFromBaseline = !tr.doc.eq(_baselineDoc);
76
+ return _objectSpread(_objectSpread({}, state), {}, {
77
+ isShowDiffAvailable: _hasChangesFromBaseline
78
+ });
79
+ }
80
+
71
81
  // If we don't have the history plugin don't limit the change tracking
72
82
  var historyState = api === null || api === void 0 || (_api$history = api.history) === null || _api$history === void 0 ? void 0 : _api$history.sharedState.currentState();
73
83
  var currentAllocation = historyState ?
@@ -82,12 +92,16 @@ export var createTrackChangesPlugin = function createTrackChangesPlugin(api) {
82
92
  allocations = _filterSteps.allocations,
83
93
  steps = _filterSteps.steps;
84
94
 
95
+ // Calculate if there are actual changes by comparing current doc with baseline
96
+ var baselineDoc = getBaselineFromSteps(tr.doc, steps);
97
+ var hasChangesFromBaseline = !tr.doc.eq(baselineDoc);
98
+
85
99
  // Create a new ChangeSet based on document changes
86
100
  return _objectSpread(_objectSpread({}, state), {}, {
87
101
  allocations: allocations,
88
102
  steps: steps,
89
103
  shouldChangesBeDisplayed: false,
90
- isShowDiffAvailable: true
104
+ isShowDiffAvailable: hasChangesFromBaseline
91
105
  });
92
106
  }
93
107
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-track-changes",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -41,7 +41,7 @@
41
41
  "react-intl-next": "npm:react-intl@^5.18.1"
42
42
  },
43
43
  "peerDependencies": {
44
- "@atlaskit/editor-common": "^107.20.0",
44
+ "@atlaskit/editor-common": "^107.21.0",
45
45
  "react": "^18.2.0"
46
46
  },
47
47
  "techstack": {