@atlaskit/editor-plugin-show-diff 5.0.9 → 6.0.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 +14 -0
- package/dist/cjs/pm-plugins/main.js +12 -4
- package/dist/es2019/pm-plugins/main.js +12 -4
- package/dist/esm/pm-plugins/main.js +12 -4
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 6.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 5.0.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`8acefc80a7a89`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8acefc80a7a89) -
|
|
14
|
+
Fixed initial activeIndex to be undefined instead of 0, preventing auto-selection on diff
|
|
15
|
+
initialization. Also update tests accordingly
|
|
16
|
+
|
|
3
17
|
## 5.0.9
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -51,7 +51,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
|
|
|
51
51
|
// Update the plugin state with the new metadata
|
|
52
52
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
53
53
|
isDisplayingChanges: true,
|
|
54
|
-
activeIndex:
|
|
54
|
+
activeIndex: undefined
|
|
55
55
|
});
|
|
56
56
|
// Calculate and store decorations in state
|
|
57
57
|
var decorations = (0, _calculateDiffDecorations.calculateDiffDecorations)({
|
|
@@ -76,11 +76,19 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
|
|
|
76
76
|
var _decorations = getScrollableDecorations(currentPluginState.decorations);
|
|
77
77
|
if (_decorations.length > 0) {
|
|
78
78
|
var _currentPluginState$a;
|
|
79
|
-
|
|
79
|
+
// Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
|
|
80
|
+
// This allows the UI to start with no selection and only highlight on first user interaction.
|
|
81
|
+
var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : -1;
|
|
80
82
|
if (meta.action === 'SCROLL_TO_NEXT') {
|
|
81
83
|
nextIndex = (nextIndex + 1) % _decorations.length;
|
|
82
84
|
} else {
|
|
83
|
-
|
|
85
|
+
// Handle scrolling backwards from the uninitialized state.
|
|
86
|
+
// If at -1 (no selection), wrap to the last decoration.
|
|
87
|
+
if (nextIndex === -1) {
|
|
88
|
+
nextIndex = _decorations.length - 1;
|
|
89
|
+
} else {
|
|
90
|
+
nextIndex = (nextIndex - 1 + _decorations.length) % _decorations.length;
|
|
91
|
+
}
|
|
84
92
|
}
|
|
85
93
|
var activeDecoration = _decorations[nextIndex];
|
|
86
94
|
newPluginState = _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
@@ -134,7 +142,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
|
|
|
134
142
|
var pluginState = showDiffPluginKey.getState(view.state);
|
|
135
143
|
var activeIndexChanged = (pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && pluginState.activeIndex !== previousActiveIndex;
|
|
136
144
|
previousActiveIndex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex;
|
|
137
|
-
if (pluginState
|
|
145
|
+
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && activeIndexChanged) {
|
|
138
146
|
(0, _scrollToActiveDecoration.scrollToActiveDecoration)(view, getScrollableDecorations(pluginState.decorations), pluginState.activeIndex);
|
|
139
147
|
}
|
|
140
148
|
}
|
|
@@ -41,7 +41,7 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
41
41
|
...currentPluginState,
|
|
42
42
|
...meta,
|
|
43
43
|
isDisplayingChanges: true,
|
|
44
|
-
activeIndex:
|
|
44
|
+
activeIndex: undefined
|
|
45
45
|
};
|
|
46
46
|
// Calculate and store decorations in state
|
|
47
47
|
const decorations = calculateDiffDecorations({
|
|
@@ -68,11 +68,19 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
68
68
|
const decorations = getScrollableDecorations(currentPluginState.decorations);
|
|
69
69
|
if (decorations.length > 0) {
|
|
70
70
|
var _currentPluginState$a;
|
|
71
|
-
|
|
71
|
+
// Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
|
|
72
|
+
// This allows the UI to start with no selection and only highlight on first user interaction.
|
|
73
|
+
let nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : -1;
|
|
72
74
|
if (meta.action === 'SCROLL_TO_NEXT') {
|
|
73
75
|
nextIndex = (nextIndex + 1) % decorations.length;
|
|
74
76
|
} else {
|
|
75
|
-
|
|
77
|
+
// Handle scrolling backwards from the uninitialized state.
|
|
78
|
+
// If at -1 (no selection), wrap to the last decoration.
|
|
79
|
+
if (nextIndex === -1) {
|
|
80
|
+
nextIndex = decorations.length - 1;
|
|
81
|
+
} else {
|
|
82
|
+
nextIndex = (nextIndex - 1 + decorations.length) % decorations.length;
|
|
83
|
+
}
|
|
76
84
|
}
|
|
77
85
|
const activeDecoration = decorations[nextIndex];
|
|
78
86
|
newPluginState = {
|
|
@@ -129,7 +137,7 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
129
137
|
const pluginState = showDiffPluginKey.getState(view.state);
|
|
130
138
|
const activeIndexChanged = (pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && pluginState.activeIndex !== previousActiveIndex;
|
|
131
139
|
previousActiveIndex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex;
|
|
132
|
-
if (pluginState
|
|
140
|
+
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && activeIndexChanged) {
|
|
133
141
|
scrollToActiveDecoration(view, getScrollableDecorations(pluginState.decorations), pluginState.activeIndex);
|
|
134
142
|
}
|
|
135
143
|
}
|
|
@@ -44,7 +44,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
44
44
|
// Update the plugin state with the new metadata
|
|
45
45
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
46
46
|
isDisplayingChanges: true,
|
|
47
|
-
activeIndex:
|
|
47
|
+
activeIndex: undefined
|
|
48
48
|
});
|
|
49
49
|
// Calculate and store decorations in state
|
|
50
50
|
var decorations = calculateDiffDecorations({
|
|
@@ -69,11 +69,19 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
69
69
|
var _decorations = getScrollableDecorations(currentPluginState.decorations);
|
|
70
70
|
if (_decorations.length > 0) {
|
|
71
71
|
var _currentPluginState$a;
|
|
72
|
-
|
|
72
|
+
// Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
|
|
73
|
+
// This allows the UI to start with no selection and only highlight on first user interaction.
|
|
74
|
+
var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : -1;
|
|
73
75
|
if (meta.action === 'SCROLL_TO_NEXT') {
|
|
74
76
|
nextIndex = (nextIndex + 1) % _decorations.length;
|
|
75
77
|
} else {
|
|
76
|
-
|
|
78
|
+
// Handle scrolling backwards from the uninitialized state.
|
|
79
|
+
// If at -1 (no selection), wrap to the last decoration.
|
|
80
|
+
if (nextIndex === -1) {
|
|
81
|
+
nextIndex = _decorations.length - 1;
|
|
82
|
+
} else {
|
|
83
|
+
nextIndex = (nextIndex - 1 + _decorations.length) % _decorations.length;
|
|
84
|
+
}
|
|
77
85
|
}
|
|
78
86
|
var activeDecoration = _decorations[nextIndex];
|
|
79
87
|
newPluginState = _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
@@ -127,7 +135,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
127
135
|
var pluginState = showDiffPluginKey.getState(view.state);
|
|
128
136
|
var activeIndexChanged = (pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && pluginState.activeIndex !== previousActiveIndex;
|
|
129
137
|
previousActiveIndex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex;
|
|
130
|
-
if (pluginState
|
|
138
|
+
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && activeIndexChanged) {
|
|
131
139
|
scrollToActiveDecoration(view, getScrollableDecorations(pluginState.decorations), pluginState.activeIndex);
|
|
132
140
|
}
|
|
133
141
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^52.2.0",
|
|
32
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
32
|
+
"@atlaskit/editor-plugin-analytics": "^8.0.0",
|
|
33
33
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
34
34
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
35
35
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
36
|
-
"@atlaskit/tmp-editor-statsig": "^35.
|
|
36
|
+
"@atlaskit/tmp-editor-statsig": "^35.10.0",
|
|
37
37
|
"@atlaskit/tokens": "^11.1.0",
|
|
38
38
|
"@babel/runtime": "^7.0.0",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@atlassian/content-reconciliation": "^0.1.3506"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@atlaskit/editor-common": "^
|
|
47
|
+
"@atlaskit/editor-common": "^112.0.0",
|
|
48
48
|
"react": "^18.2.0"
|
|
49
49
|
},
|
|
50
50
|
"techstack": {
|