@atlaskit/editor-plugin-insert-block 7.0.14 → 7.0.16
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/ui/ElementBrowser/InsertMenu.js +111 -43
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +94 -33
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +110 -42
- package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +9 -0
- package/dist/types-ts4.5/ui/ElementBrowser/InsertMenu.d.ts +9 -0
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-insert-block
|
|
2
2
|
|
|
3
|
+
## 7.0.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 7.0.15
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`c1691aca7fb1d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c1691aca7fb1d) -
|
|
14
|
+
[ux] Update and standardise insert menu ordering behaviour to support localisation
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 7.0.14
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -4,12 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = exports.DEFAULT_HEIGHT = void 0;
|
|
7
|
+
exports.filterForPinWhiteboardsExperiment = exports.default = exports.DEFAULT_HEIGHT = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
13
|
var _react = require("react");
|
|
14
14
|
var _react2 = require("@emotion/react");
|
|
15
15
|
var _reactIntlNext = require("react-intl-next");
|
|
@@ -29,6 +29,113 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
29
29
|
* @jsx jsx
|
|
30
30
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
31
31
|
var DEFAULT_HEIGHT = exports.DEFAULT_HEIGHT = 560;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Exported helper to allow testing of InsertMenu whiteboard pinning logic. NOTE: this is
|
|
35
|
+
*not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
|
|
36
|
+
method that can be used to get suggestions -> once all experiments are cleaned up,
|
|
37
|
+
they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
|
|
38
|
+
*/
|
|
39
|
+
var filterForPinWhiteboardsExperiment = exports.filterForPinWhiteboardsExperiment = function filterForPinWhiteboardsExperiment(featuredItems, formatMessage) {
|
|
40
|
+
// Legacy path fallback -- prior comments as follows:
|
|
41
|
+
/**
|
|
42
|
+
* // Part of ATLAS-95399 to pin whiteboards to the top of the InsertMenu
|
|
43
|
+
// Need to check if whiteboard options are available, and filter for the cohort
|
|
44
|
+
// Takes the original featuredItems list and returns one with the right whiteboard option at the top
|
|
45
|
+
*/
|
|
46
|
+
if ((0, _platformFeatureFlags.fg)('confluence-whiteboards-quick-insert-eligible')) {
|
|
47
|
+
var DIAGRAM_TITLE = 'Create diagram',
|
|
48
|
+
BLANK_TITLE = 'Create whiteboard';
|
|
49
|
+
var featuredWhiteboardsPresent = featuredItems.filter(function (item) {
|
|
50
|
+
return [DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
51
|
+
}).length === 2;
|
|
52
|
+
if (featuredWhiteboardsPresent) {
|
|
53
|
+
var pinWhiteboardActionToTop = function pinWhiteboardActionToTop(items, title) {
|
|
54
|
+
// find the requested item by title, give it the appropriate description, and bring it to the top of the list
|
|
55
|
+
var index = items.findIndex(function (item) {
|
|
56
|
+
return item.title === title;
|
|
57
|
+
});
|
|
58
|
+
var filteredList = items.filter(function (item) {
|
|
59
|
+
return ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
60
|
+
});
|
|
61
|
+
if (index === -1) {
|
|
62
|
+
return filteredList;
|
|
63
|
+
}
|
|
64
|
+
var featuredItem = _objectSpread({}, items[index]);
|
|
65
|
+
featuredItem.description = formatMessage(_quickInsert.messages.featuredWhiteboardDescription);
|
|
66
|
+
return [featuredItem].concat((0, _toConsumableArray2.default)(filteredList));
|
|
67
|
+
};
|
|
68
|
+
if ((0, _expValEquals.expValEquals)('confluence_whiteboards_quick_insert', 'cohort', 'test_blank')) {
|
|
69
|
+
return pinWhiteboardActionToTop(featuredItems, BLANK_TITLE);
|
|
70
|
+
}
|
|
71
|
+
if ((0, _expValEquals.expValEquals)('confluence_whiteboards_quick_insert', 'cohort', 'test_diagram')) {
|
|
72
|
+
return pinWhiteboardActionToTop(featuredItems, DIAGRAM_TITLE);
|
|
73
|
+
}
|
|
74
|
+
// NOTE this is not desirable/the OG behaviour, but given we've shipped the test_diagram variant,
|
|
75
|
+
return featuredItems.filter(function (item) {
|
|
76
|
+
return ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
if ((0, _platformFeatureFlags.fg)('confluence-whiteboards-quick-insert-l10n-eligible')) {
|
|
80
|
+
/** BEGIN locale agnostic path */
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* EXTREMELY IMPORTANT: we must not drop diagram for those who already receive
|
|
84
|
+
* the 'insert diagram to the top' treatment.
|
|
85
|
+
*
|
|
86
|
+
* Our heuristic to check that this is only targeting users where they haven't
|
|
87
|
+
* gotten the experience, is if we _cannot_ find the blank board experience in
|
|
88
|
+
* the list, matching purely on title.
|
|
89
|
+
*
|
|
90
|
+
* e.g. `featuredWhiteboardsPresent` = false, given it matches on title.
|
|
91
|
+
*
|
|
92
|
+
* The side-effect of this, is that there's a small chance/edge case of users
|
|
93
|
+
* who toggle between locales, and receive different experiences.
|
|
94
|
+
*
|
|
95
|
+
* Hopefully we can make a call early on this experiment, and eliminate this
|
|
96
|
+
* code path.
|
|
97
|
+
*/
|
|
98
|
+
var WHITEBOARD_KEY = 'whiteboard-extension:create-whiteboard';
|
|
99
|
+
var DIAGRAM_KEY = 'whiteboard-extension:create-diagram';
|
|
100
|
+
var isBlank = function isBlank(item) {
|
|
101
|
+
return item.key === WHITEBOARD_KEY;
|
|
102
|
+
};
|
|
103
|
+
var isDiagram = function isDiagram(item) {
|
|
104
|
+
return item.key === DIAGRAM_KEY;
|
|
105
|
+
};
|
|
106
|
+
var hasBoth = featuredItems.some(isBlank) && featuredItems.some(isDiagram);
|
|
107
|
+
if (hasBoth) {
|
|
108
|
+
var pin = function pin(key) {
|
|
109
|
+
var idx = featuredItems.findIndex(function (item) {
|
|
110
|
+
return item.key === key;
|
|
111
|
+
});
|
|
112
|
+
var filtered = featuredItems.filter(function (item) {
|
|
113
|
+
return !isBlank(item) && !isDiagram(item);
|
|
114
|
+
});
|
|
115
|
+
if (idx === -1) {
|
|
116
|
+
return filtered;
|
|
117
|
+
}
|
|
118
|
+
var picked = _objectSpread(_objectSpread({}, featuredItems[idx]), {}, {
|
|
119
|
+
description: formatMessage(_quickInsert.messages.featuredWhiteboardDescription)
|
|
120
|
+
});
|
|
121
|
+
return [picked].concat((0, _toConsumableArray2.default)(filtered));
|
|
122
|
+
};
|
|
123
|
+
if ((0, _expValEquals.expValEquals)('confluence_whiteboards_quick_insert_localised', 'cohort', 'test_blank')) {
|
|
124
|
+
return pin(WHITEBOARD_KEY);
|
|
125
|
+
}
|
|
126
|
+
if ((0, _expValEquals.expValEquals)('confluence_whiteboards_quick_insert_localised', 'cohort', 'test_diagram')) {
|
|
127
|
+
return pin(DIAGRAM_KEY);
|
|
128
|
+
}
|
|
129
|
+
if ((0, _expValEquals.expValEquals)('confluence_whiteboards_quick_insert_localised', 'cohort', 'control')) {
|
|
130
|
+
return featuredItems;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** END locale agnostic path */
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return featuredItems;
|
|
138
|
+
};
|
|
32
139
|
var selector = function selector(states) {
|
|
33
140
|
var _states$connectivityS;
|
|
34
141
|
return {
|
|
@@ -114,45 +221,6 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
114
221
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(pluginInjectionApi, ['connectivity'], selector),
|
|
115
222
|
connectivityMode = _useSharedPluginState.connectivityMode;
|
|
116
223
|
var getItems = (0, _react.useCallback)(function (query, category) {
|
|
117
|
-
var filterForPinWhiteboardsExperiment = function filterForPinWhiteboardsExperiment(featuredItems) {
|
|
118
|
-
// Part of ATLAS-95399 to pin whiteboards to the top of the InsertMenu
|
|
119
|
-
// Need to check if whiteboard options are available, and filter for the cohort
|
|
120
|
-
// Takes the original featuredItems list and returns one with the right whiteboard option at the top
|
|
121
|
-
if ((0, _platformFeatureFlags.fg)('confluence-whiteboards-quick-insert-eligible')) {
|
|
122
|
-
var DIAGRAM_TITLE = 'Create diagram',
|
|
123
|
-
BLANK_TITLE = 'Create whiteboard';
|
|
124
|
-
var featuredWhiteboardsPresent = featuredItems.filter(function (item) {
|
|
125
|
-
return [DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
126
|
-
}).length === 2;
|
|
127
|
-
if (featuredWhiteboardsPresent) {
|
|
128
|
-
var pinWhiteboardActionToTop = function pinWhiteboardActionToTop(featuredItems, title) {
|
|
129
|
-
// find the requested item by title, give it the appropriate description, and bring it to the top of the list
|
|
130
|
-
var index = featuredItems.findIndex(function (item) {
|
|
131
|
-
return item.title === title;
|
|
132
|
-
});
|
|
133
|
-
var filteredList = featuredItems.filter(function (item) {
|
|
134
|
-
return ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
135
|
-
});
|
|
136
|
-
if (index === -1) {
|
|
137
|
-
return filteredList;
|
|
138
|
-
}
|
|
139
|
-
var featuredItem = _objectSpread({}, featuredItems[index]);
|
|
140
|
-
featuredItem.description = formatMessage(_quickInsert.messages.featuredWhiteboardDescription);
|
|
141
|
-
return [featuredItem].concat((0, _toConsumableArray2.default)(filteredList));
|
|
142
|
-
};
|
|
143
|
-
if ((0, _expValEquals.expValEquals)('confluence_whiteboards_quick_insert', 'cohort', 'test_blank')) {
|
|
144
|
-
return pinWhiteboardActionToTop(featuredItems, BLANK_TITLE);
|
|
145
|
-
} else if ((0, _expValEquals.expValEquals)('confluence_whiteboards_quick_insert', 'cohort', 'test_diagram')) {
|
|
146
|
-
return pinWhiteboardActionToTop(featuredItems, DIAGRAM_TITLE);
|
|
147
|
-
} else {
|
|
148
|
-
return featuredItems.filter(function (item) {
|
|
149
|
-
return ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return featuredItems;
|
|
155
|
-
};
|
|
156
224
|
var result;
|
|
157
225
|
/**
|
|
158
226
|
* @warning The results if there is a query are not the same as the results if there is no query.
|
|
@@ -182,7 +250,7 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
182
250
|
})) !== null && _pluginInjectionApi$q4 !== void 0 ? _pluginInjectionApi$q4 : [];
|
|
183
251
|
var unfilteredResult = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
184
252
|
// need to filter on the concatenated list so whiteboards are at the top
|
|
185
|
-
result = filterForPinWhiteboardsExperiment(unfilteredResult);
|
|
253
|
+
result = filterForPinWhiteboardsExperiment(unfilteredResult, formatMessage);
|
|
186
254
|
}
|
|
187
255
|
setItemCount(result.length);
|
|
188
256
|
return result;
|
|
@@ -19,6 +19,99 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
19
19
|
import { N0, N30A, N60A } from '@atlaskit/theme/colors';
|
|
20
20
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
21
21
|
export const DEFAULT_HEIGHT = 560;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Exported helper to allow testing of InsertMenu whiteboard pinning logic. NOTE: this is
|
|
25
|
+
*not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
|
|
26
|
+
method that can be used to get suggestions -> once all experiments are cleaned up,
|
|
27
|
+
they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
|
|
28
|
+
*/
|
|
29
|
+
export const filterForPinWhiteboardsExperiment = (featuredItems, formatMessage) => {
|
|
30
|
+
// Legacy path fallback -- prior comments as follows:
|
|
31
|
+
/**
|
|
32
|
+
* // Part of ATLAS-95399 to pin whiteboards to the top of the InsertMenu
|
|
33
|
+
// Need to check if whiteboard options are available, and filter for the cohort
|
|
34
|
+
// Takes the original featuredItems list and returns one with the right whiteboard option at the top
|
|
35
|
+
*/
|
|
36
|
+
if (fg('confluence-whiteboards-quick-insert-eligible')) {
|
|
37
|
+
const [DIAGRAM_TITLE, BLANK_TITLE] = ['Create diagram', 'Create whiteboard'];
|
|
38
|
+
const featuredWhiteboardsPresent = featuredItems.filter(item => [DIAGRAM_TITLE, BLANK_TITLE].includes(item.title)).length === 2;
|
|
39
|
+
if (featuredWhiteboardsPresent) {
|
|
40
|
+
const pinWhiteboardActionToTop = (items, title) => {
|
|
41
|
+
// find the requested item by title, give it the appropriate description, and bring it to the top of the list
|
|
42
|
+
const index = items.findIndex(item => item.title === title);
|
|
43
|
+
const filteredList = items.filter(item => ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title));
|
|
44
|
+
if (index === -1) {
|
|
45
|
+
return filteredList;
|
|
46
|
+
}
|
|
47
|
+
const featuredItem = {
|
|
48
|
+
...items[index]
|
|
49
|
+
};
|
|
50
|
+
featuredItem.description = formatMessage(messages.featuredWhiteboardDescription);
|
|
51
|
+
return [featuredItem, ...filteredList];
|
|
52
|
+
};
|
|
53
|
+
if (expValEquals('confluence_whiteboards_quick_insert', 'cohort', 'test_blank')) {
|
|
54
|
+
return pinWhiteboardActionToTop(featuredItems, BLANK_TITLE);
|
|
55
|
+
}
|
|
56
|
+
if (expValEquals('confluence_whiteboards_quick_insert', 'cohort', 'test_diagram')) {
|
|
57
|
+
return pinWhiteboardActionToTop(featuredItems, DIAGRAM_TITLE);
|
|
58
|
+
}
|
|
59
|
+
// NOTE this is not desirable/the OG behaviour, but given we've shipped the test_diagram variant,
|
|
60
|
+
return featuredItems.filter(item => ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title));
|
|
61
|
+
} else {
|
|
62
|
+
if (fg('confluence-whiteboards-quick-insert-l10n-eligible')) {
|
|
63
|
+
/** BEGIN locale agnostic path */
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* EXTREMELY IMPORTANT: we must not drop diagram for those who already receive
|
|
67
|
+
* the 'insert diagram to the top' treatment.
|
|
68
|
+
*
|
|
69
|
+
* Our heuristic to check that this is only targeting users where they haven't
|
|
70
|
+
* gotten the experience, is if we _cannot_ find the blank board experience in
|
|
71
|
+
* the list, matching purely on title.
|
|
72
|
+
*
|
|
73
|
+
* e.g. `featuredWhiteboardsPresent` = false, given it matches on title.
|
|
74
|
+
*
|
|
75
|
+
* The side-effect of this, is that there's a small chance/edge case of users
|
|
76
|
+
* who toggle between locales, and receive different experiences.
|
|
77
|
+
*
|
|
78
|
+
* Hopefully we can make a call early on this experiment, and eliminate this
|
|
79
|
+
* code path.
|
|
80
|
+
*/
|
|
81
|
+
const WHITEBOARD_KEY = 'whiteboard-extension:create-whiteboard';
|
|
82
|
+
const DIAGRAM_KEY = 'whiteboard-extension:create-diagram';
|
|
83
|
+
const isBlank = item => item.key === WHITEBOARD_KEY;
|
|
84
|
+
const isDiagram = item => item.key === DIAGRAM_KEY;
|
|
85
|
+
const hasBoth = featuredItems.some(isBlank) && featuredItems.some(isDiagram);
|
|
86
|
+
if (hasBoth) {
|
|
87
|
+
const pin = key => {
|
|
88
|
+
const idx = featuredItems.findIndex(item => item.key === key);
|
|
89
|
+
const filtered = featuredItems.filter(item => !isBlank(item) && !isDiagram(item));
|
|
90
|
+
if (idx === -1) {
|
|
91
|
+
return filtered;
|
|
92
|
+
}
|
|
93
|
+
const picked = {
|
|
94
|
+
...featuredItems[idx],
|
|
95
|
+
description: formatMessage(messages.featuredWhiteboardDescription)
|
|
96
|
+
};
|
|
97
|
+
return [picked, ...filtered];
|
|
98
|
+
};
|
|
99
|
+
if (expValEquals('confluence_whiteboards_quick_insert_localised', 'cohort', 'test_blank')) {
|
|
100
|
+
return pin(WHITEBOARD_KEY);
|
|
101
|
+
}
|
|
102
|
+
if (expValEquals('confluence_whiteboards_quick_insert_localised', 'cohort', 'test_diagram')) {
|
|
103
|
+
return pin(DIAGRAM_KEY);
|
|
104
|
+
}
|
|
105
|
+
if (expValEquals('confluence_whiteboards_quick_insert_localised', 'cohort', 'control')) {
|
|
106
|
+
return featuredItems;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** END locale agnostic path */
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return featuredItems;
|
|
114
|
+
};
|
|
22
115
|
const selector = states => {
|
|
23
116
|
var _states$connectivityS;
|
|
24
117
|
return {
|
|
@@ -93,38 +186,6 @@ const InsertMenu = ({
|
|
|
93
186
|
connectivityMode
|
|
94
187
|
} = useSharedPluginStateWithSelector(pluginInjectionApi, ['connectivity'], selector);
|
|
95
188
|
const getItems = useCallback((query, category) => {
|
|
96
|
-
const filterForPinWhiteboardsExperiment = featuredItems => {
|
|
97
|
-
// Part of ATLAS-95399 to pin whiteboards to the top of the InsertMenu
|
|
98
|
-
// Need to check if whiteboard options are available, and filter for the cohort
|
|
99
|
-
// Takes the original featuredItems list and returns one with the right whiteboard option at the top
|
|
100
|
-
if (fg('confluence-whiteboards-quick-insert-eligible')) {
|
|
101
|
-
const [DIAGRAM_TITLE, BLANK_TITLE] = ['Create diagram', 'Create whiteboard'];
|
|
102
|
-
const featuredWhiteboardsPresent = featuredItems.filter(item => [DIAGRAM_TITLE, BLANK_TITLE].includes(item.title)).length === 2;
|
|
103
|
-
if (featuredWhiteboardsPresent) {
|
|
104
|
-
const pinWhiteboardActionToTop = (featuredItems, title) => {
|
|
105
|
-
// find the requested item by title, give it the appropriate description, and bring it to the top of the list
|
|
106
|
-
const index = featuredItems.findIndex(item => item.title === title);
|
|
107
|
-
const filteredList = featuredItems.filter(item => ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title));
|
|
108
|
-
if (index === -1) {
|
|
109
|
-
return filteredList;
|
|
110
|
-
}
|
|
111
|
-
const featuredItem = {
|
|
112
|
-
...featuredItems[index]
|
|
113
|
-
};
|
|
114
|
-
featuredItem.description = formatMessage(messages.featuredWhiteboardDescription);
|
|
115
|
-
return [featuredItem, ...filteredList];
|
|
116
|
-
};
|
|
117
|
-
if (expValEquals('confluence_whiteboards_quick_insert', 'cohort', 'test_blank')) {
|
|
118
|
-
return pinWhiteboardActionToTop(featuredItems, BLANK_TITLE);
|
|
119
|
-
} else if (expValEquals('confluence_whiteboards_quick_insert', 'cohort', 'test_diagram')) {
|
|
120
|
-
return pinWhiteboardActionToTop(featuredItems, DIAGRAM_TITLE);
|
|
121
|
-
} else {
|
|
122
|
-
return featuredItems.filter(item => ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return featuredItems;
|
|
127
|
-
};
|
|
128
189
|
let result;
|
|
129
190
|
/**
|
|
130
191
|
* @warning The results if there is a query are not the same as the results if there is no query.
|
|
@@ -152,7 +213,7 @@ const InsertMenu = ({
|
|
|
152
213
|
} : item)) !== null && _pluginInjectionApi$q5 !== void 0 ? _pluginInjectionApi$q5 : [];
|
|
153
214
|
const unfilteredResult = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
154
215
|
// need to filter on the concatenated list so whiteboards are at the top
|
|
155
|
-
result = filterForPinWhiteboardsExperiment(unfilteredResult);
|
|
216
|
+
result = filterForPinWhiteboardsExperiment(unfilteredResult, formatMessage);
|
|
156
217
|
}
|
|
157
218
|
setItemCount(result.length);
|
|
158
219
|
return result;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
5
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
5
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
6
|
var _excluded = ["children"];
|
|
7
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -26,6 +26,113 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
26
26
|
import { N0, N30A, N60A } from '@atlaskit/theme/colors';
|
|
27
27
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
28
28
|
export var DEFAULT_HEIGHT = 560;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Exported helper to allow testing of InsertMenu whiteboard pinning logic. NOTE: this is
|
|
32
|
+
*not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
|
|
33
|
+
method that can be used to get suggestions -> once all experiments are cleaned up,
|
|
34
|
+
they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
|
|
35
|
+
*/
|
|
36
|
+
export var filterForPinWhiteboardsExperiment = function filterForPinWhiteboardsExperiment(featuredItems, formatMessage) {
|
|
37
|
+
// Legacy path fallback -- prior comments as follows:
|
|
38
|
+
/**
|
|
39
|
+
* // Part of ATLAS-95399 to pin whiteboards to the top of the InsertMenu
|
|
40
|
+
// Need to check if whiteboard options are available, and filter for the cohort
|
|
41
|
+
// Takes the original featuredItems list and returns one with the right whiteboard option at the top
|
|
42
|
+
*/
|
|
43
|
+
if (fg('confluence-whiteboards-quick-insert-eligible')) {
|
|
44
|
+
var DIAGRAM_TITLE = 'Create diagram',
|
|
45
|
+
BLANK_TITLE = 'Create whiteboard';
|
|
46
|
+
var featuredWhiteboardsPresent = featuredItems.filter(function (item) {
|
|
47
|
+
return [DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
48
|
+
}).length === 2;
|
|
49
|
+
if (featuredWhiteboardsPresent) {
|
|
50
|
+
var pinWhiteboardActionToTop = function pinWhiteboardActionToTop(items, title) {
|
|
51
|
+
// find the requested item by title, give it the appropriate description, and bring it to the top of the list
|
|
52
|
+
var index = items.findIndex(function (item) {
|
|
53
|
+
return item.title === title;
|
|
54
|
+
});
|
|
55
|
+
var filteredList = items.filter(function (item) {
|
|
56
|
+
return ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
57
|
+
});
|
|
58
|
+
if (index === -1) {
|
|
59
|
+
return filteredList;
|
|
60
|
+
}
|
|
61
|
+
var featuredItem = _objectSpread({}, items[index]);
|
|
62
|
+
featuredItem.description = formatMessage(messages.featuredWhiteboardDescription);
|
|
63
|
+
return [featuredItem].concat(_toConsumableArray(filteredList));
|
|
64
|
+
};
|
|
65
|
+
if (expValEquals('confluence_whiteboards_quick_insert', 'cohort', 'test_blank')) {
|
|
66
|
+
return pinWhiteboardActionToTop(featuredItems, BLANK_TITLE);
|
|
67
|
+
}
|
|
68
|
+
if (expValEquals('confluence_whiteboards_quick_insert', 'cohort', 'test_diagram')) {
|
|
69
|
+
return pinWhiteboardActionToTop(featuredItems, DIAGRAM_TITLE);
|
|
70
|
+
}
|
|
71
|
+
// NOTE this is not desirable/the OG behaviour, but given we've shipped the test_diagram variant,
|
|
72
|
+
return featuredItems.filter(function (item) {
|
|
73
|
+
return ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
if (fg('confluence-whiteboards-quick-insert-l10n-eligible')) {
|
|
77
|
+
/** BEGIN locale agnostic path */
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* EXTREMELY IMPORTANT: we must not drop diagram for those who already receive
|
|
81
|
+
* the 'insert diagram to the top' treatment.
|
|
82
|
+
*
|
|
83
|
+
* Our heuristic to check that this is only targeting users where they haven't
|
|
84
|
+
* gotten the experience, is if we _cannot_ find the blank board experience in
|
|
85
|
+
* the list, matching purely on title.
|
|
86
|
+
*
|
|
87
|
+
* e.g. `featuredWhiteboardsPresent` = false, given it matches on title.
|
|
88
|
+
*
|
|
89
|
+
* The side-effect of this, is that there's a small chance/edge case of users
|
|
90
|
+
* who toggle between locales, and receive different experiences.
|
|
91
|
+
*
|
|
92
|
+
* Hopefully we can make a call early on this experiment, and eliminate this
|
|
93
|
+
* code path.
|
|
94
|
+
*/
|
|
95
|
+
var WHITEBOARD_KEY = 'whiteboard-extension:create-whiteboard';
|
|
96
|
+
var DIAGRAM_KEY = 'whiteboard-extension:create-diagram';
|
|
97
|
+
var isBlank = function isBlank(item) {
|
|
98
|
+
return item.key === WHITEBOARD_KEY;
|
|
99
|
+
};
|
|
100
|
+
var isDiagram = function isDiagram(item) {
|
|
101
|
+
return item.key === DIAGRAM_KEY;
|
|
102
|
+
};
|
|
103
|
+
var hasBoth = featuredItems.some(isBlank) && featuredItems.some(isDiagram);
|
|
104
|
+
if (hasBoth) {
|
|
105
|
+
var pin = function pin(key) {
|
|
106
|
+
var idx = featuredItems.findIndex(function (item) {
|
|
107
|
+
return item.key === key;
|
|
108
|
+
});
|
|
109
|
+
var filtered = featuredItems.filter(function (item) {
|
|
110
|
+
return !isBlank(item) && !isDiagram(item);
|
|
111
|
+
});
|
|
112
|
+
if (idx === -1) {
|
|
113
|
+
return filtered;
|
|
114
|
+
}
|
|
115
|
+
var picked = _objectSpread(_objectSpread({}, featuredItems[idx]), {}, {
|
|
116
|
+
description: formatMessage(messages.featuredWhiteboardDescription)
|
|
117
|
+
});
|
|
118
|
+
return [picked].concat(_toConsumableArray(filtered));
|
|
119
|
+
};
|
|
120
|
+
if (expValEquals('confluence_whiteboards_quick_insert_localised', 'cohort', 'test_blank')) {
|
|
121
|
+
return pin(WHITEBOARD_KEY);
|
|
122
|
+
}
|
|
123
|
+
if (expValEquals('confluence_whiteboards_quick_insert_localised', 'cohort', 'test_diagram')) {
|
|
124
|
+
return pin(DIAGRAM_KEY);
|
|
125
|
+
}
|
|
126
|
+
if (expValEquals('confluence_whiteboards_quick_insert_localised', 'cohort', 'control')) {
|
|
127
|
+
return featuredItems;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** END locale agnostic path */
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return featuredItems;
|
|
135
|
+
};
|
|
29
136
|
var selector = function selector(states) {
|
|
30
137
|
var _states$connectivityS;
|
|
31
138
|
return {
|
|
@@ -111,45 +218,6 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
111
218
|
var _useSharedPluginState = useSharedPluginStateWithSelector(pluginInjectionApi, ['connectivity'], selector),
|
|
112
219
|
connectivityMode = _useSharedPluginState.connectivityMode;
|
|
113
220
|
var getItems = useCallback(function (query, category) {
|
|
114
|
-
var filterForPinWhiteboardsExperiment = function filterForPinWhiteboardsExperiment(featuredItems) {
|
|
115
|
-
// Part of ATLAS-95399 to pin whiteboards to the top of the InsertMenu
|
|
116
|
-
// Need to check if whiteboard options are available, and filter for the cohort
|
|
117
|
-
// Takes the original featuredItems list and returns one with the right whiteboard option at the top
|
|
118
|
-
if (fg('confluence-whiteboards-quick-insert-eligible')) {
|
|
119
|
-
var DIAGRAM_TITLE = 'Create diagram',
|
|
120
|
-
BLANK_TITLE = 'Create whiteboard';
|
|
121
|
-
var featuredWhiteboardsPresent = featuredItems.filter(function (item) {
|
|
122
|
-
return [DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
123
|
-
}).length === 2;
|
|
124
|
-
if (featuredWhiteboardsPresent) {
|
|
125
|
-
var pinWhiteboardActionToTop = function pinWhiteboardActionToTop(featuredItems, title) {
|
|
126
|
-
// find the requested item by title, give it the appropriate description, and bring it to the top of the list
|
|
127
|
-
var index = featuredItems.findIndex(function (item) {
|
|
128
|
-
return item.title === title;
|
|
129
|
-
});
|
|
130
|
-
var filteredList = featuredItems.filter(function (item) {
|
|
131
|
-
return ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
132
|
-
});
|
|
133
|
-
if (index === -1) {
|
|
134
|
-
return filteredList;
|
|
135
|
-
}
|
|
136
|
-
var featuredItem = _objectSpread({}, featuredItems[index]);
|
|
137
|
-
featuredItem.description = formatMessage(messages.featuredWhiteboardDescription);
|
|
138
|
-
return [featuredItem].concat(_toConsumableArray(filteredList));
|
|
139
|
-
};
|
|
140
|
-
if (expValEquals('confluence_whiteboards_quick_insert', 'cohort', 'test_blank')) {
|
|
141
|
-
return pinWhiteboardActionToTop(featuredItems, BLANK_TITLE);
|
|
142
|
-
} else if (expValEquals('confluence_whiteboards_quick_insert', 'cohort', 'test_diagram')) {
|
|
143
|
-
return pinWhiteboardActionToTop(featuredItems, DIAGRAM_TITLE);
|
|
144
|
-
} else {
|
|
145
|
-
return featuredItems.filter(function (item) {
|
|
146
|
-
return ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return featuredItems;
|
|
152
|
-
};
|
|
153
221
|
var result;
|
|
154
222
|
/**
|
|
155
223
|
* @warning The results if there is a query are not the same as the results if there is no query.
|
|
@@ -179,7 +247,7 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
179
247
|
})) !== null && _pluginInjectionApi$q4 !== void 0 ? _pluginInjectionApi$q4 : [];
|
|
180
248
|
var unfilteredResult = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
181
249
|
// need to filter on the concatenated list so whiteboards are at the top
|
|
182
|
-
result = filterForPinWhiteboardsExperiment(unfilteredResult);
|
|
250
|
+
result = filterForPinWhiteboardsExperiment(unfilteredResult, formatMessage);
|
|
183
251
|
}
|
|
184
252
|
setItemCount(result.length);
|
|
185
253
|
return result;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
3
|
+
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
4
|
import type { InsertMenuProps } from './types';
|
|
3
5
|
export declare const DEFAULT_HEIGHT = 560;
|
|
6
|
+
/**
|
|
7
|
+
* Exported helper to allow testing of InsertMenu whiteboard pinning logic. NOTE: this is
|
|
8
|
+
*not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
|
|
9
|
+
method that can be used to get suggestions -> once all experiments are cleaned up,
|
|
10
|
+
they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
|
|
11
|
+
*/
|
|
12
|
+
export declare const filterForPinWhiteboardsExperiment: (featuredItems: QuickInsertItem[], formatMessage: (msg: MessageDescriptor) => string) => QuickInsertItem[];
|
|
4
13
|
declare const InsertMenu: ({ editorView, dropdownItems, showElementBrowserLink, onInsert, toggleVisiblity, pluginInjectionApi, isFullPageAppearance, }: InsertMenuProps) => jsx.JSX.Element;
|
|
5
14
|
export default InsertMenu;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
3
|
+
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
4
|
import type { InsertMenuProps } from './types';
|
|
3
5
|
export declare const DEFAULT_HEIGHT = 560;
|
|
6
|
+
/**
|
|
7
|
+
* Exported helper to allow testing of InsertMenu whiteboard pinning logic. NOTE: this is
|
|
8
|
+
*not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
|
|
9
|
+
method that can be used to get suggestions -> once all experiments are cleaned up,
|
|
10
|
+
they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
|
|
11
|
+
*/
|
|
12
|
+
export declare const filterForPinWhiteboardsExperiment: (featuredItems: QuickInsertItem[], formatMessage: (msg: MessageDescriptor) => string) => QuickInsertItem[];
|
|
4
13
|
declare const InsertMenu: ({ editorView, dropdownItems, showElementBrowserLink, onInsert, toggleVisiblity, pluginInjectionApi, isFullPageAppearance, }: InsertMenuProps) => jsx.JSX.Element;
|
|
5
14
|
export default InsertMenu;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-insert-block",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.16",
|
|
4
4
|
"description": "Insert block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@atlaskit/editor-plugin-hyperlink": "^8.1.0",
|
|
43
43
|
"@atlaskit/editor-plugin-image-upload": "^6.0.0",
|
|
44
44
|
"@atlaskit/editor-plugin-layout": "^6.1.0",
|
|
45
|
-
"@atlaskit/editor-plugin-media": "^8.
|
|
45
|
+
"@atlaskit/editor-plugin-media": "^8.3.0",
|
|
46
46
|
"@atlaskit/editor-plugin-media-insert": "^13.1.0",
|
|
47
47
|
"@atlaskit/editor-plugin-mentions": "^8.2.0",
|
|
48
48
|
"@atlaskit/editor-plugin-metrics": "^7.1.0",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"@atlaskit/editor-plugin-toolbar": "^3.3.0",
|
|
58
58
|
"@atlaskit/editor-plugin-type-ahead": "^6.5.0",
|
|
59
59
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
60
|
-
"@atlaskit/editor-shared-styles": "^3.
|
|
61
|
-
"@atlaskit/editor-toolbar": "^0.
|
|
60
|
+
"@atlaskit/editor-shared-styles": "^3.8.0",
|
|
61
|
+
"@atlaskit/editor-toolbar": "^0.16.0",
|
|
62
62
|
"@atlaskit/editor-toolbar-model": "^0.2.0",
|
|
63
63
|
"@atlaskit/emoji": "^69.6.0",
|
|
64
64
|
"@atlaskit/heading": "^5.2.0",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
68
68
|
"@atlaskit/primitives": "^16.0.0",
|
|
69
69
|
"@atlaskit/theme": "^21.0.0",
|
|
70
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
70
|
+
"@atlaskit/tmp-editor-statsig": "^13.18.0",
|
|
71
71
|
"@atlaskit/tokens": "^7.0.0",
|
|
72
|
-
"@atlaskit/tooltip": "^20.
|
|
72
|
+
"@atlaskit/tooltip": "^20.6.0",
|
|
73
73
|
"@babel/runtime": "^7.0.0",
|
|
74
74
|
"@emotion/react": "^11.7.1",
|
|
75
75
|
"bind-event-listener": "^3.0.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"react-virtualized": "^9.22.6"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@atlaskit/editor-common": "^110.
|
|
81
|
+
"@atlaskit/editor-common": "^110.16.0",
|
|
82
82
|
"react": "^18.2.0",
|
|
83
83
|
"react-dom": "^18.2.0",
|
|
84
84
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -139,6 +139,9 @@
|
|
|
139
139
|
"confluence-whiteboards-quick-insert-eligible": {
|
|
140
140
|
"type": "boolean"
|
|
141
141
|
},
|
|
142
|
+
"confluence-whiteboards-quick-insert-l10n-eligible": {
|
|
143
|
+
"type": "boolean"
|
|
144
|
+
},
|
|
142
145
|
"platform_editor_remove_unused_block_insert_props": {
|
|
143
146
|
"type": "boolean"
|
|
144
147
|
}
|