@atlaskit/editor-plugin-quick-insert 27.0.5 → 28.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 +23 -0
- package/dist/cjs/ui/RegistryElementBrowser/RegistryElementBrowser.js +160 -61
- package/dist/cjs/ui/RegistryElementBrowser/RegistryElementBrowserSearchResults.compiled.css +1 -12
- package/dist/cjs/ui/RegistryElementBrowser/RegistryElementBrowserSearchResults.js +10 -39
- package/dist/cjs/ui/RegistryElementBrowser/index.js +14 -6
- package/dist/cjs/ui/RegistryElementBrowser/model.js +1 -1
- package/dist/es2019/ui/RegistryElementBrowser/RegistryElementBrowser.js +158 -51
- package/dist/es2019/ui/RegistryElementBrowser/RegistryElementBrowserSearchResults.compiled.css +1 -12
- package/dist/es2019/ui/RegistryElementBrowser/RegistryElementBrowserSearchResults.js +8 -36
- package/dist/es2019/ui/RegistryElementBrowser/index.js +13 -7
- package/dist/es2019/ui/RegistryElementBrowser/model.js +1 -1
- package/dist/esm/ui/RegistryElementBrowser/RegistryElementBrowser.js +160 -61
- package/dist/esm/ui/RegistryElementBrowser/RegistryElementBrowserSearchResults.compiled.css +1 -12
- package/dist/esm/ui/RegistryElementBrowser/RegistryElementBrowserSearchResults.js +8 -38
- package/dist/esm/ui/RegistryElementBrowser/index.js +15 -7
- package/dist/esm/ui/RegistryElementBrowser/model.js +1 -1
- package/dist/types/ui/RegistryElementBrowser/RegistryElementBrowser.d.ts +3 -1
- package/dist/types/ui/RegistryElementBrowser/model.d.ts +1 -1
- package/package.json +9 -9
- package/dist/cjs/ui/RegistryElementBrowser/NotFoundIllustration.js +0 -76
- package/dist/es2019/ui/RegistryElementBrowser/NotFoundIllustration.js +0 -69
- package/dist/esm/ui/RegistryElementBrowser/NotFoundIllustration.js +0 -69
- package/dist/types/ui/RegistryElementBrowser/NotFoundIllustration.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-quick-insert
|
|
2
2
|
|
|
3
|
+
## 28.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 27.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`f93da47c0d069`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f93da47c0d069) -
|
|
14
|
+
Add shared illustrated empty states and search outcome analytics for registered slash, Plus and
|
|
15
|
+
Element Browser searches under platform_editor_slash_command. Refresh resolved registrations on
|
|
16
|
+
search edits and retain eligible Ask Rovo and host Marketplace recovery. Remove duplicate top
|
|
17
|
+
spacing in the Plus menu and show its previews only for directly hovered or keyboard-selected
|
|
18
|
+
items. Subscribe all three registered entry points to live registry updates and rebuild their
|
|
19
|
+
models on search changes, keeping selection and category state valid as items arrive or disappear.
|
|
20
|
+
Omit the Plus footer divider when only the generic empty state is shown.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 27.0.5
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -9,12 +9,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
exports.RegistryElementBrowser = void 0;
|
|
10
10
|
require("./RegistryElementBrowser.compiled.css");
|
|
11
11
|
var _runtime = require("@compiled/react/runtime");
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
13
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
15
|
var _reactIntl = require("react-intl");
|
|
15
16
|
var _button = _interopRequireDefault(require("@atlaskit/button/icon/button"));
|
|
16
17
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
17
18
|
var _keys = require("@atlaskit/editor-common/quick-insert/keys");
|
|
19
|
+
var _useSearchAnalytics = require("@atlaskit/editor-common/quick-insert/use-search-analytics");
|
|
18
20
|
var _typeAheadGetMenuFooterSectionKey = require("@atlaskit/editor-common/type-ahead-get-menu-footer-section-key");
|
|
19
21
|
var _typeAheadGetSectionOverflowItemKey = require("@atlaskit/editor-common/type-ahead-get-section-overflow-item-key");
|
|
20
22
|
var _heading = _interopRequireDefault(require("@atlaskit/heading/heading"));
|
|
@@ -32,11 +34,14 @@ var _RegistryElementBrowserCategories = require("./RegistryElementBrowserCategor
|
|
|
32
34
|
var _RegistryElementBrowserFooter = require("./RegistryElementBrowserFooter");
|
|
33
35
|
var _RegistryElementBrowserSearchResults = require("./RegistryElementBrowserSearchResults");
|
|
34
36
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
37
|
+
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; }
|
|
38
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
35
39
|
var browserGridTemplateColumns = '182px minmax(0, 1fr)';
|
|
36
40
|
var categoryColumnGap = "calc(".concat("var(--ds-space-200, 16px)", " + ", "var(--ds-space-150, 12px)", ")");
|
|
37
41
|
var browserLayoutStyles = null;
|
|
38
42
|
var headerContentStyles = null;
|
|
39
43
|
var headerSearchStyles = null;
|
|
44
|
+
var EMPTY_ITEMS = [];
|
|
40
45
|
var resultsId = 'registry-element-browser-results';
|
|
41
46
|
var modalTestId = 'registry-element-browser-modal';
|
|
42
47
|
var getRenderedColumnCount = function getRenderedColumnCount(options) {
|
|
@@ -48,9 +53,10 @@ var getRenderedColumnCount = function getRenderedColumnCount(options) {
|
|
|
48
53
|
return nextRowIndex > 0 ? nextRowIndex : options.length;
|
|
49
54
|
};
|
|
50
55
|
var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryElementBrowser(_ref) {
|
|
51
|
-
var _model$fallbackItems$, _model$
|
|
56
|
+
var _model$fallbackItems, _model$fallbackItems$, _model$fallbackItems2;
|
|
52
57
|
var components = _ref.components,
|
|
53
58
|
emptyStateHandler = _ref.emptyStateHandler,
|
|
59
|
+
fireAnalyticsEvent = _ref.fireAnalyticsEvent,
|
|
54
60
|
defaultSection = _ref.defaultSection,
|
|
55
61
|
helpUrl = _ref.helpUrl,
|
|
56
62
|
editorView = _ref.editorView,
|
|
@@ -65,8 +71,19 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
|
|
|
65
71
|
onSelect = _ref.onSelect;
|
|
66
72
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
67
73
|
formatMessage = _useIntl.formatMessage;
|
|
68
|
-
var
|
|
69
|
-
|
|
74
|
+
var _useState = (0, _react.useState)({
|
|
75
|
+
query: '',
|
|
76
|
+
section: defaultSection
|
|
77
|
+
}),
|
|
78
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
79
|
+
browserState = _useState2[0],
|
|
80
|
+
setBrowserState = _useState2[1];
|
|
81
|
+
var query = browserState.query,
|
|
82
|
+
section = browserState.section,
|
|
83
|
+
selectedRegistration = browserState.selectedRegistration;
|
|
84
|
+
var selectedRegistrationRef = (0, _react.useRef)(undefined);
|
|
85
|
+
var browserModel = (0, _react.useMemo)(function () {
|
|
86
|
+
var model = (0, _model.createRegistryElementBrowserModel)(components, {
|
|
70
87
|
footerKey: (0, _typeAheadGetMenuFooterSectionKey.getMenuFooterSectionKey)(_keys.MENU.key),
|
|
71
88
|
overflowKeys: new Set(components.filter(function (component) {
|
|
72
89
|
return component.type === 'menu-section';
|
|
@@ -76,67 +93,147 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
|
|
|
76
93
|
recommendedSectionKey: _keys.RECOMMENDED_SECTION.key,
|
|
77
94
|
rootKey: _keys.MENU.key
|
|
78
95
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
var effectiveSection = section && model.sections.some(function (_ref2) {
|
|
97
|
+
var key = _ref2.key;
|
|
98
|
+
return key === section;
|
|
99
|
+
}) ? section : undefined;
|
|
100
|
+
return {
|
|
101
|
+
model: model,
|
|
102
|
+
effectiveSection: effectiveSection,
|
|
103
|
+
items: (0, _model.getRegistryElementBrowserItems)({
|
|
104
|
+
formatMessage: formatMessage,
|
|
105
|
+
model: model,
|
|
106
|
+
query: query,
|
|
107
|
+
section: effectiveSection
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
}, [components, formatMessage, query, section]);
|
|
111
|
+
var model = browserModel.model,
|
|
112
|
+
effectiveSection = browserModel.effectiveSection,
|
|
113
|
+
items = browserModel.items;
|
|
114
|
+
var visibleItems = items.length === 0 && !isLoading && query.trim().length > 0 ? (_model$fallbackItems = model.fallbackItems) !== null && _model$fallbackItems !== void 0 ? _model$fallbackItems : EMPTY_ITEMS : items;
|
|
115
|
+
var isSelectedRegistrationCurrent = Boolean(selectedRegistration && browserState.selectionIsOffline === isOffline && visibleItems.some(function (_ref3) {
|
|
116
|
+
var registration = _ref3.registration;
|
|
117
|
+
return registration === selectedRegistration;
|
|
118
|
+
}));
|
|
119
|
+
var selectedKey = isSelectedRegistrationCurrent ? selectedRegistration === null || selectedRegistration === void 0 ? void 0 : selectedRegistration.key : undefined;
|
|
120
|
+
var invalidSection = Boolean(section && section !== effectiveSection);
|
|
121
|
+
var invalidSelection = Boolean(selectedRegistration && !isSelectedRegistrationCurrent);
|
|
122
|
+
if (isOpen && (invalidSection || invalidSelection)) {
|
|
123
|
+
setBrowserState(_objectSpread(_objectSpread({}, browserState), {}, {
|
|
124
|
+
section: effectiveSection,
|
|
125
|
+
selectedRegistration: undefined,
|
|
126
|
+
selectionIsOffline: undefined,
|
|
127
|
+
invalidation: {
|
|
128
|
+
section: invalidSection ? section : undefined,
|
|
129
|
+
selection: invalidSelection
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
94
133
|
var searchInputRef = (0, _react.useRef)(null);
|
|
95
134
|
var selectedCategoryRef = (0, _react.useRef)(null);
|
|
135
|
+
var focusedCategoryRef = (0, _react.useRef)();
|
|
136
|
+
var handledInvalidationRef = (0, _react.useRef)(browserState.invalidation);
|
|
96
137
|
var wasOpen = (0, _react.useRef)(false);
|
|
97
|
-
var previousIsOffline = (0, _react.useRef)(isOffline);
|
|
98
138
|
(0, _react.useEffect)(function () {
|
|
99
139
|
if (isOpen && !wasOpen.current) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
140
|
+
selectedRegistrationRef.current = undefined;
|
|
141
|
+
setBrowserState({
|
|
142
|
+
query: '',
|
|
143
|
+
section: (0, _model.getInitialRegistryElementBrowserSection)(model, defaultSection),
|
|
144
|
+
selectedRegistration: undefined
|
|
145
|
+
});
|
|
105
146
|
onClearSelection();
|
|
106
147
|
}
|
|
107
148
|
wasOpen.current = isOpen;
|
|
108
149
|
}, [defaultSection, isOpen, model, onClearSelection]);
|
|
109
|
-
var items = (0, _react.useMemo)(function () {
|
|
110
|
-
return (0, _model.getRegistryElementBrowserItems)({
|
|
111
|
-
formatMessage: formatMessage,
|
|
112
|
-
model: model,
|
|
113
|
-
query: query,
|
|
114
|
-
section: section
|
|
115
|
-
});
|
|
116
|
-
}, [formatMessage, model, query, section]);
|
|
117
|
-
var resultCount = items.length || (!isLoading && query.trim() ? (_model$fallbackItems$ = (_model$fallbackItems = model.fallbackItems) === null || _model$fallbackItems === void 0 ? void 0 : _model$fallbackItems.length) !== null && _model$fallbackItems$ !== void 0 ? _model$fallbackItems$ : 0 : 0);
|
|
118
150
|
(0, _react.useEffect)(function () {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
151
|
+
var _searchInputRef$curre;
|
|
152
|
+
var invalidation = browserState.invalidation;
|
|
153
|
+
if (!isOpen || !invalidation || handledInvalidationRef.current === invalidation) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
handledInvalidationRef.current = invalidation;
|
|
157
|
+
selectedRegistrationRef.current = undefined;
|
|
158
|
+
onClearSelection();
|
|
159
|
+
var ownerDocument = (_searchInputRef$curre = searchInputRef.current) === null || _searchInputRef$curre === void 0 ? void 0 : _searchInputRef$curre.ownerDocument;
|
|
160
|
+
var activeElement = ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.activeElement;
|
|
161
|
+
if (invalidation.section && focusedCategoryRef.current === invalidation.section && activeElement === (ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body)) {
|
|
162
|
+
var _selectedCategoryRef$;
|
|
163
|
+
(_selectedCategoryRef$ = selectedCategoryRef.current) === null || _selectedCategoryRef$ === void 0 || _selectedCategoryRef$.focus();
|
|
164
|
+
} else if (invalidation.selection && (activeElement === (ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body) || activeElement !== null && activeElement !== void 0 && activeElement.closest('[role="option"]'))) {
|
|
165
|
+
var _searchInputRef$curre2;
|
|
166
|
+
(_searchInputRef$curre2 = searchInputRef.current) === null || _searchInputRef$curre2 === void 0 || _searchInputRef$curre2.focus();
|
|
122
167
|
}
|
|
123
|
-
|
|
124
|
-
|
|
168
|
+
}, [browserState.invalidation, isOpen, onClearSelection]);
|
|
169
|
+
var resultCount = items.length || (!isLoading && query.trim() ? (_model$fallbackItems$ = (_model$fallbackItems2 = model.fallbackItems) === null || _model$fallbackItems2 === void 0 ? void 0 : _model$fallbackItems2.length) !== null && _model$fallbackItems$ !== void 0 ? _model$fallbackItems$ : 0 : 0);
|
|
170
|
+
var flushSearchAnalytics = (0, _useSearchAnalytics.useQuickInsertSearchAnalytics)({
|
|
171
|
+
query: query,
|
|
172
|
+
resultCount: items.length,
|
|
173
|
+
surface: 'element-browser',
|
|
174
|
+
category: effectiveSection !== null && effectiveSection !== void 0 ? effectiveSection : 'all',
|
|
175
|
+
isOpen: isOpen && !isLoading,
|
|
176
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
177
|
+
});
|
|
178
|
+
var closeBrowser = (0, _react.useCallback)(function () {
|
|
179
|
+
flushSearchAnalytics();
|
|
180
|
+
onClose();
|
|
181
|
+
}, [flushSearchAnalytics, onClose]);
|
|
182
|
+
var onSearchFocus = (0, _react.useCallback)(function () {
|
|
183
|
+
focusedCategoryRef.current = undefined;
|
|
184
|
+
}, []);
|
|
185
|
+
var onBrowserFocusCapture = (0, _react.useCallback)(function (event) {
|
|
186
|
+
var _category$dataset$sec;
|
|
187
|
+
var categories = event.currentTarget.querySelector('[data-testid="registry-element-browser-categories"]');
|
|
188
|
+
var category = event.target instanceof HTMLElement && categories !== null && categories !== void 0 && categories.contains(event.target) ? event.target.closest('[data-section]') : null;
|
|
189
|
+
focusedCategoryRef.current = category ? (_category$dataset$sec = category.dataset.section) !== null && _category$dataset$sec !== void 0 ? _category$dataset$sec : '' : undefined;
|
|
190
|
+
}, []);
|
|
125
191
|
var onSearchChange = (0, _react.useCallback)(function (event) {
|
|
126
|
-
|
|
127
|
-
|
|
192
|
+
var nextQuery = event.currentTarget.value;
|
|
193
|
+
selectedRegistrationRef.current = undefined;
|
|
194
|
+
setBrowserState(function (current) {
|
|
195
|
+
return _objectSpread(_objectSpread({}, current), {}, {
|
|
196
|
+
query: nextQuery,
|
|
197
|
+
selectedRegistration: undefined
|
|
198
|
+
});
|
|
199
|
+
});
|
|
128
200
|
onClearSelection();
|
|
129
201
|
}, [onClearSelection]);
|
|
130
202
|
var onSectionClick = (0, _react.useCallback)(function (event) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
203
|
+
var nextSection = event.currentTarget.dataset.section || undefined;
|
|
204
|
+
selectedRegistrationRef.current = undefined;
|
|
205
|
+
setBrowserState({
|
|
206
|
+
query: '',
|
|
207
|
+
section: nextSection,
|
|
208
|
+
selectedRegistration: undefined
|
|
209
|
+
});
|
|
134
210
|
onClearSelection();
|
|
135
211
|
}, [onClearSelection]);
|
|
136
212
|
var onRegistrySelect = (0, _react.useCallback)(function (key, handler) {
|
|
137
|
-
|
|
213
|
+
var _model$items$find;
|
|
214
|
+
var registration = (_model$items$find = model.items.find(function (_ref4) {
|
|
215
|
+
var registration = _ref4.registration;
|
|
216
|
+
return registration.key === key;
|
|
217
|
+
})) === null || _model$items$find === void 0 ? void 0 : _model$items$find.registration;
|
|
218
|
+
selectedRegistrationRef.current = registration;
|
|
219
|
+
setBrowserState(function (current) {
|
|
220
|
+
return _objectSpread(_objectSpread({}, current), {}, {
|
|
221
|
+
selectedRegistration: registration,
|
|
222
|
+
selectionIsOffline: isOffline
|
|
223
|
+
});
|
|
224
|
+
});
|
|
138
225
|
onSelect(handler);
|
|
139
|
-
}, [onSelect]);
|
|
226
|
+
}, [isOffline, model.items, onSelect]);
|
|
227
|
+
var confirmInsert = (0, _react.useCallback)(function () {
|
|
228
|
+
var selectedRegistration = selectedRegistrationRef.current;
|
|
229
|
+
if (!selectedRegistration || !visibleItems.some(function (_ref5) {
|
|
230
|
+
var registration = _ref5.registration;
|
|
231
|
+
return registration === selectedRegistration;
|
|
232
|
+
})) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
onConfirmInsert();
|
|
236
|
+
}, [onConfirmInsert, visibleItems]);
|
|
140
237
|
var onModalOpenComplete = (0, _react.useCallback)(function (node) {
|
|
141
238
|
node.style.borderRadius = "var(--ds-radius-large, 8px)";
|
|
142
239
|
var footer = node.querySelector("[data-testid=\"".concat(modalTestId, "--footer\"]"));
|
|
@@ -149,9 +246,9 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
|
|
|
149
246
|
}, []);
|
|
150
247
|
var onKeyDown = (0, _react.useCallback)(function (event) {
|
|
151
248
|
if (event.key === 'Tab' && event.shiftKey && event.target instanceof HTMLElement && event.target.getAttribute('role') === 'option') {
|
|
152
|
-
var _selectedCategoryRef
|
|
249
|
+
var _selectedCategoryRef$2;
|
|
153
250
|
event.preventDefault();
|
|
154
|
-
(_selectedCategoryRef$ = selectedCategoryRef.current) === null || _selectedCategoryRef$ === void 0 || _selectedCategoryRef
|
|
251
|
+
(_selectedCategoryRef$2 = selectedCategoryRef.current) === null || _selectedCategoryRef$2 === void 0 || _selectedCategoryRef$2.focus();
|
|
155
252
|
return;
|
|
156
253
|
}
|
|
157
254
|
if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
@@ -179,15 +276,15 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
|
|
|
179
276
|
nextOption.focus();
|
|
180
277
|
nextOption.click();
|
|
181
278
|
} else if (nextIndex < 0 && currentIndex >= 0) {
|
|
182
|
-
var _searchInputRef$
|
|
279
|
+
var _searchInputRef$curre3;
|
|
183
280
|
event.preventDefault();
|
|
184
|
-
(_searchInputRef$
|
|
281
|
+
(_searchInputRef$curre3 = searchInputRef.current) === null || _searchInputRef$curre3 === void 0 || _searchInputRef$curre3.focus();
|
|
185
282
|
}
|
|
186
283
|
return;
|
|
187
284
|
}
|
|
188
285
|
if (event.key === 'Escape') {
|
|
189
286
|
event.preventDefault();
|
|
190
|
-
|
|
287
|
+
closeBrowser();
|
|
191
288
|
return;
|
|
192
289
|
}
|
|
193
290
|
if (event.key === 'Enter') {
|
|
@@ -195,22 +292,22 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
|
|
|
195
292
|
var focusedOption = event.target instanceof HTMLElement ? event.target.closest('[role="option"]') : null;
|
|
196
293
|
var firstOption = (_event$currentTarget$ = event.currentTarget.ownerDocument.getElementById(resultsId)) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.querySelector('[role="option"]:not([aria-disabled="true"]):not([disabled])');
|
|
197
294
|
var optionToActivate = focusedOption !== null && focusedOption !== void 0 ? focusedOption : firstOption;
|
|
198
|
-
if (
|
|
295
|
+
if (isSelectedRegistrationCurrent || optionToActivate) {
|
|
199
296
|
event.preventDefault();
|
|
200
|
-
if (!
|
|
297
|
+
if (!isSelectedRegistrationCurrent) {
|
|
201
298
|
optionToActivate === null || optionToActivate === void 0 || optionToActivate.click();
|
|
202
299
|
}
|
|
203
|
-
|
|
300
|
+
confirmInsert();
|
|
204
301
|
}
|
|
205
302
|
}
|
|
206
|
-
}, [
|
|
303
|
+
}, [closeBrowser, confirmInsert, isSelectedRegistrationCurrent]);
|
|
207
304
|
return /*#__PURE__*/_react.default.createElement(_modalTransition.default, null, isOpen && /*#__PURE__*/_react.default.createElement(_modalDialog.default, {
|
|
208
305
|
label: formatMessage({
|
|
209
306
|
defaultMessage: 'Insert elements',
|
|
210
307
|
id: 'editor.quick-insert.title'
|
|
211
308
|
}),
|
|
212
309
|
height: "664px",
|
|
213
|
-
onClose:
|
|
310
|
+
onClose: closeBrowser,
|
|
214
311
|
onCloseComplete: onCloseComplete,
|
|
215
312
|
onOpenComplete: onModalOpenComplete,
|
|
216
313
|
testId: modalTestId,
|
|
@@ -236,6 +333,7 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
|
|
|
236
333
|
}),
|
|
237
334
|
isCompact: true,
|
|
238
335
|
name: "registry-element-browser-search",
|
|
336
|
+
onFocus: onSearchFocus,
|
|
239
337
|
onChange: onSearchChange,
|
|
240
338
|
onKeyDown: onKeyDown,
|
|
241
339
|
ref: searchInputRef,
|
|
@@ -244,12 +342,13 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
|
|
|
244
342
|
appearance: "subtle",
|
|
245
343
|
icon: _cross.default,
|
|
246
344
|
label: formatMessage(_quickInsert.messages.close),
|
|
247
|
-
onClick:
|
|
345
|
+
onClick: closeBrowser,
|
|
248
346
|
spacing: "compact"
|
|
249
347
|
})))), /*#__PURE__*/_react.default.createElement(_modalBody.default, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
348
|
+
onFocusCapture: onBrowserFocusCapture,
|
|
250
349
|
className: (0, _runtime.ax)(["_zulp1fka _18zr1b66 _1e0c11p5 _yv0e1xuv _1q511b66 _lk4ji47z"])
|
|
251
350
|
}, /*#__PURE__*/_react.default.createElement(_RegistryElementBrowserCategories.RegistryElementBrowserCategories, {
|
|
252
|
-
section:
|
|
351
|
+
section: effectiveSection,
|
|
253
352
|
sections: model.sections,
|
|
254
353
|
onSectionClick: onSectionClick,
|
|
255
354
|
selectedButtonRef: selectedCategoryRef
|
|
@@ -262,15 +361,15 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
|
|
|
262
361
|
fallbackItems: model.fallbackItems,
|
|
263
362
|
query: query,
|
|
264
363
|
resultsId: resultsId,
|
|
265
|
-
section:
|
|
364
|
+
section: effectiveSection,
|
|
266
365
|
selectedKey: selectedKey,
|
|
267
366
|
onKeyDown: onKeyDown,
|
|
268
367
|
onSelect: onRegistrySelect
|
|
269
368
|
}))), /*#__PURE__*/_react.default.createElement(_modalFooter.default, null, /*#__PURE__*/_react.default.createElement(_RegistryElementBrowserFooter.RegistryElementBrowserFooter, {
|
|
270
369
|
helpUrl: helpUrl,
|
|
271
|
-
isInsertEnabled:
|
|
272
|
-
onClose:
|
|
273
|
-
onConfirmInsert:
|
|
370
|
+
isInsertEnabled: isSelectedRegistrationCurrent,
|
|
371
|
+
onClose: closeBrowser,
|
|
372
|
+
onConfirmInsert: confirmInsert,
|
|
274
373
|
resultCount: resultCount
|
|
275
374
|
}))));
|
|
276
375
|
};
|
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
._11c81af2{font:var(--ds-font-heading-medium,normal 653 20px/24px "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
|
|
2
1
|
._zulpu2gc{gap:var(--ds-space-100,8px)}
|
|
3
|
-
._yyhyjvu9{grid-column:1/-1}
|
|
4
|
-
._15a5nqa1{border-top-style:solid}
|
|
5
|
-
._19pk1ejb{margin-top:var(--ds-space-300,24px)}
|
|
2
|
+
._yyhyjvu9{grid-column:1/-1}._15a5nqa1{border-top-style:solid}
|
|
6
3
|
._19pkpxbi{margin-top:var(--ds-space-200,1pc)}
|
|
7
|
-
._19pkutpp{margin-top:var(--ds-space-150,9pt)}
|
|
8
|
-
._1bah1h6o{justify-content:center}
|
|
9
4
|
._1bsb1osq{width:100%}
|
|
10
5
|
._1e0c11p5{display:grid}
|
|
11
|
-
._1e0c1txw{display:flex}
|
|
12
6
|
._1i531l7x{border-top-color:var(--ds-border,#0b120e24)}
|
|
13
7
|
._1ul9idpf{min-width:0}
|
|
14
|
-
._2lx21bp4{flex-direction:column}
|
|
15
|
-
._4cvr1h6o{align-items:center}
|
|
16
8
|
._4cvrv2br{align-items:start}
|
|
17
9
|
._ae4vv2br{align-content:start}
|
|
18
10
|
._ca0qpxbi{padding-top:var(--ds-space-200,1pc)}
|
|
19
|
-
._p12f1kdj{max-width:25pc}
|
|
20
|
-
._syazi7uo{color:var(--ds-text,#292a2e)}
|
|
21
11
|
._uwhke4h9{border-top-width:var(--ds-border-width,1px)}
|
|
22
|
-
._y3gn1h6o{text-align:center}
|
|
23
12
|
._yv0ei47z{grid-template-columns:minmax(0,1fr)}
|
|
24
13
|
@media (min-width:550px) and (max-width:1023px){._16409sye{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
25
14
|
@media (min-width:1024px){._g98o1koq{grid-template-columns:repeat(3,232px)}}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* RegistryElementBrowserSearchResults.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
5
|
Object.defineProperty(exports, "__esModule", {
|
|
7
6
|
value: true
|
|
@@ -9,25 +8,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
8
|
exports.RegistryElementBrowserSearchResults = void 0;
|
|
10
9
|
require("./RegistryElementBrowserSearchResults.compiled.css");
|
|
11
10
|
var _runtime = require("@compiled/react/runtime");
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
12
|
var _reactIntl = require("react-intl");
|
|
15
|
-
var
|
|
13
|
+
var _emptyState = require("@atlaskit/editor-common/quick-insert/empty-state");
|
|
16
14
|
var _provider = require("@atlaskit/editor-common/quick-insert/provider");
|
|
17
|
-
var _compiled = require("@atlaskit/primitives/compiled");
|
|
18
|
-
var _NotFoundIllustration = _interopRequireDefault(require("./NotFoundIllustration"));
|
|
19
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
// oxlint-disable-next-line eslint/no-redeclare
|
|
17
|
+
|
|
22
18
|
var resultsGridStyles = null;
|
|
23
19
|
var emptyStateGridItemStyles = null;
|
|
24
20
|
var styles = {
|
|
25
21
|
fallbackMarketplace: "_1i531l7x _15a5nqa1 _uwhke4h9 _19pkpxbi _ca0qpxbi"
|
|
26
22
|
};
|
|
27
|
-
var emptyStateWrapperStyles = null;
|
|
28
|
-
var emptyStateHeadingStyles = null;
|
|
29
|
-
var emptyStateSubheadingStyles = null;
|
|
30
|
-
var emptyStateLinkStyles = null;
|
|
31
23
|
var RegistryElementBrowserItem = function RegistryElementBrowserItem(_ref) {
|
|
32
24
|
var editorView = _ref.editorView,
|
|
33
25
|
isOffline = _ref.isOffline,
|
|
@@ -60,7 +52,6 @@ var RegistryElementBrowserItem = function RegistryElementBrowserItem(_ref) {
|
|
|
60
52
|
}, /*#__PURE__*/_react.default.createElement(Component, undefined, null));
|
|
61
53
|
};
|
|
62
54
|
var RegistryElementBrowserSearchResults = exports.RegistryElementBrowserSearchResults = function RegistryElementBrowserSearchResults(_ref2) {
|
|
63
|
-
var _emptyStateHandler;
|
|
64
55
|
var editorView = _ref2.editorView,
|
|
65
56
|
emptyStateHandler = _ref2.emptyStateHandler,
|
|
66
57
|
fallbackItems = _ref2.fallbackItems,
|
|
@@ -83,34 +74,12 @@ var RegistryElementBrowserSearchResults = exports.RegistryElementBrowserSearchRe
|
|
|
83
74
|
});
|
|
84
75
|
var displayedItems = hasFallbackItems && fallbackItems ? fallbackItems : items;
|
|
85
76
|
var shouldRenderEmptyState = items.length === 0 && !isLoading;
|
|
86
|
-
var emptyState = shouldRenderEmptyState ?
|
|
77
|
+
var emptyState = shouldRenderEmptyState ? emptyStateHandler === null || emptyStateHandler === void 0 ? void 0 : emptyStateHandler({
|
|
87
78
|
mode: 'full',
|
|
88
79
|
searchTerm: query,
|
|
89
|
-
selectedCategory: section
|
|
90
|
-
}, hasFallbackItems ? {
|
|
80
|
+
selectedCategory: section,
|
|
91
81
|
showNoResultsMessage: false
|
|
92
|
-
} :
|
|
93
|
-
className: (0, _runtime.ax)(["_4cvr1h6o _1e0c1txw _2lx21bp4 _1bah1h6o _1bsb1osq"])
|
|
94
|
-
}, /*#__PURE__*/_react.default.createElement(_NotFoundIllustration.default, null), /*#__PURE__*/_react.default.createElement("div", {
|
|
95
|
-
className: (0, _runtime.ax)(["_11c81af2 _syazi7uo _19pk1ejb"])
|
|
96
|
-
}, formatMessage({
|
|
97
|
-
defaultMessage: 'Nothing matches your search',
|
|
98
|
-
id: 'editor.quick-insert.empty'
|
|
99
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
100
|
-
className: (0, _runtime.ax)(["_19pkpxbi _p12f1kdj _y3gn1h6o"])
|
|
101
|
-
}, /*#__PURE__*/_react.default.createElement(_compiled.Text, null, formatMessage({
|
|
102
|
-
defaultMessage: 'Try searching with a different term or discover new apps for Atlassian products.',
|
|
103
|
-
id: 'editor.quick-insert.empty-description'
|
|
104
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
105
|
-
className: (0, _runtime.ax)(["_19pkutpp"])
|
|
106
|
-
}, /*#__PURE__*/_react.default.createElement(_link.default, {
|
|
107
|
-
appearance: "primary",
|
|
108
|
-
href: "https://marketplace.atlassian.com/search?category=Macros&hosting=cloud&product=confluence",
|
|
109
|
-
target: "_blank"
|
|
110
|
-
}, formatMessage({
|
|
111
|
-
defaultMessage: 'Explore Atlassian Marketplace',
|
|
112
|
-
id: 'editor.quick-insert.explore-marketplace'
|
|
113
|
-
}))))) : null;
|
|
82
|
+
}) : null;
|
|
114
83
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
115
84
|
"data-testid": "registry-element-browser-results",
|
|
116
85
|
id: resultsId,
|
|
@@ -136,7 +105,9 @@ var RegistryElementBrowserSearchResults = exports.RegistryElementBrowserSearchRe
|
|
|
136
105
|
key: item.registration.key,
|
|
137
106
|
onSelect: onSelect
|
|
138
107
|
});
|
|
139
|
-
})),
|
|
140
|
-
|
|
108
|
+
})), shouldRenderEmptyState && !hasFallbackItems && query.trim().length > 0 && /*#__PURE__*/_react.default.createElement(_emptyState.QuickInsertEmptyState, {
|
|
109
|
+
mode: "full"
|
|
110
|
+
}), emptyState && /*#__PURE__*/_react.default.createElement("div", {
|
|
111
|
+
className: (0, _runtime.ax)(["_yyhyjvu9 _1ul9idpf _1bsb1osq", styles.fallbackMarketplace])
|
|
141
112
|
}, emptyState));
|
|
142
113
|
};
|
|
@@ -17,8 +17,12 @@ var _commands = require("../../pm-plugins/commands");
|
|
|
17
17
|
var _pluginKey = require("../../pm-plugins/plugin-key");
|
|
18
18
|
var _RegistryElementBrowser = require("./RegistryElementBrowser");
|
|
19
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
|
+
var EMPTY_COMPONENTS = [];
|
|
21
|
+
var subscribeToNothing = function subscribeToNothing() {
|
|
22
|
+
return function () {};
|
|
23
|
+
};
|
|
20
24
|
var RegistryElementBrowserContainer = exports.RegistryElementBrowserContainer = function RegistryElementBrowserContainer(_ref) {
|
|
21
|
-
var _pluginKey$getState;
|
|
25
|
+
var _pluginInjectionAPI$u2, _pluginInjectionAPI$u3, _pluginInjectionAPI$a2, _pluginKey$getState;
|
|
22
26
|
var editorView = _ref.editorView,
|
|
23
27
|
pluginInjectionAPI = _ref.pluginInjectionAPI,
|
|
24
28
|
helpUrl = _ref.helpUrl;
|
|
@@ -33,12 +37,15 @@ var RegistryElementBrowserContainer = exports.RegistryElementBrowserContainer =
|
|
|
33
37
|
currentEmptyStateHandler = _useSharedPluginState.emptyStateHandler,
|
|
34
38
|
isElementBrowserOpen = _useSharedPluginState.isElementBrowserOpen,
|
|
35
39
|
mode = _useSharedPluginState.mode;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
var getRegistrySnapshot = (0, _react.useCallback)(function () {
|
|
41
|
+
var _pluginInjectionAPI$u;
|
|
42
|
+
if (!isElementBrowserOpen) {
|
|
43
|
+
return EMPTY_COMPONENTS;
|
|
44
|
+
}
|
|
45
|
+
var components = pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$u = pluginInjectionAPI.uiControlRegistry) === null || _pluginInjectionAPI$u === void 0 ? void 0 : _pluginInjectionAPI$u.actions.getComponents(_keys.MENU.key);
|
|
46
|
+
return components !== null && components !== void 0 && components.length ? components : EMPTY_COMPONENTS;
|
|
41
47
|
}, [isElementBrowserOpen, pluginInjectionAPI]);
|
|
48
|
+
var components = (0, _react.useSyncExternalStore)(isElementBrowserOpen ? (_pluginInjectionAPI$u2 = pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$u3 = pluginInjectionAPI.uiControlRegistry) === null || _pluginInjectionAPI$u3 === void 0 ? void 0 : _pluginInjectionAPI$u3.actions.subscribe) !== null && _pluginInjectionAPI$u2 !== void 0 ? _pluginInjectionAPI$u2 : subscribeToNothing : subscribeToNothing, getRegistrySnapshot, getRegistrySnapshot);
|
|
42
49
|
var _useState = (0, _react.useState)(),
|
|
43
50
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
44
51
|
emptyStateHandler = _useState2[0],
|
|
@@ -129,6 +136,7 @@ var RegistryElementBrowserContainer = exports.RegistryElementBrowserContainer =
|
|
|
129
136
|
}, [onClose]);
|
|
130
137
|
return /*#__PURE__*/_react.default.createElement(_RegistryElementBrowser.RegistryElementBrowser, {
|
|
131
138
|
components: components,
|
|
139
|
+
fireAnalyticsEvent: pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$a2 = pluginInjectionAPI.analytics) === null || _pluginInjectionAPI$a2 === void 0 ? void 0 : _pluginInjectionAPI$a2.actions.fireAnalyticsEvent,
|
|
132
140
|
emptyStateHandler: emptyStateHandler,
|
|
133
141
|
helpUrl: helpUrl,
|
|
134
142
|
defaultSection: (_pluginKey$getState = _pluginKey.pluginKey.getState(editorView.state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.elementBrowserInitialCategory,
|
|
@@ -54,7 +54,7 @@ var _getDescendantItems = function getDescendantItems(components, parentKey, anc
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* Builds the Element Browser's
|
|
57
|
+
* Builds the Element Browser's view of the resolved Quick Insert registry.
|
|
58
58
|
* The caller provides only components rooted at the Quick Insert menu surface.
|
|
59
59
|
*/
|
|
60
60
|
var createRegistryElementBrowserModel = exports.createRegistryElementBrowserModel = function createRegistryElementBrowserModel(components, _ref) {
|