@atlaskit/editor-plugin-quick-insert 27.0.5 → 27.1.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 +17 -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 +3 -3
- 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
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/* RegistryElementBrowser.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
4
|
import "./RegistryElementBrowser.compiled.css";
|
|
4
5
|
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
5
8
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
9
|
import { useIntl } from 'react-intl';
|
|
7
10
|
import IconButton from '@atlaskit/button/icon/button';
|
|
8
11
|
import { messages } from '@atlaskit/editor-common/quick-insert';
|
|
9
12
|
import { MENU, RECOMMENDED_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
|
|
13
|
+
import { useQuickInsertSearchAnalytics } from '@atlaskit/editor-common/quick-insert/use-search-analytics';
|
|
10
14
|
import { getMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-get-menu-footer-section-key';
|
|
11
15
|
import { getSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-get-section-overflow-item-key';
|
|
12
16
|
import Heading from '@atlaskit/heading/heading';
|
|
@@ -28,6 +32,7 @@ var categoryColumnGap = "calc(".concat("var(--ds-space-200, 16px)", " + ", "var(
|
|
|
28
32
|
var browserLayoutStyles = null;
|
|
29
33
|
var headerContentStyles = null;
|
|
30
34
|
var headerSearchStyles = null;
|
|
35
|
+
var EMPTY_ITEMS = [];
|
|
31
36
|
var resultsId = 'registry-element-browser-results';
|
|
32
37
|
var modalTestId = 'registry-element-browser-modal';
|
|
33
38
|
var getRenderedColumnCount = function getRenderedColumnCount(options) {
|
|
@@ -39,9 +44,10 @@ var getRenderedColumnCount = function getRenderedColumnCount(options) {
|
|
|
39
44
|
return nextRowIndex > 0 ? nextRowIndex : options.length;
|
|
40
45
|
};
|
|
41
46
|
export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
|
|
42
|
-
var _model$fallbackItems$, _model$
|
|
47
|
+
var _model$fallbackItems, _model$fallbackItems$, _model$fallbackItems2;
|
|
43
48
|
var components = _ref.components,
|
|
44
49
|
emptyStateHandler = _ref.emptyStateHandler,
|
|
50
|
+
fireAnalyticsEvent = _ref.fireAnalyticsEvent,
|
|
45
51
|
defaultSection = _ref.defaultSection,
|
|
46
52
|
helpUrl = _ref.helpUrl,
|
|
47
53
|
editorView = _ref.editorView,
|
|
@@ -56,8 +62,19 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
|
|
|
56
62
|
onSelect = _ref.onSelect;
|
|
57
63
|
var _useIntl = useIntl(),
|
|
58
64
|
formatMessage = _useIntl.formatMessage;
|
|
59
|
-
var
|
|
60
|
-
|
|
65
|
+
var _useState = useState({
|
|
66
|
+
query: '',
|
|
67
|
+
section: defaultSection
|
|
68
|
+
}),
|
|
69
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
70
|
+
browserState = _useState2[0],
|
|
71
|
+
setBrowserState = _useState2[1];
|
|
72
|
+
var query = browserState.query,
|
|
73
|
+
section = browserState.section,
|
|
74
|
+
selectedRegistration = browserState.selectedRegistration;
|
|
75
|
+
var selectedRegistrationRef = useRef(undefined);
|
|
76
|
+
var browserModel = useMemo(function () {
|
|
77
|
+
var model = createRegistryElementBrowserModel(components, {
|
|
61
78
|
footerKey: getMenuFooterSectionKey(MENU.key),
|
|
62
79
|
overflowKeys: new Set(components.filter(function (component) {
|
|
63
80
|
return component.type === 'menu-section';
|
|
@@ -67,67 +84,147 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
|
|
|
67
84
|
recommendedSectionKey: RECOMMENDED_SECTION.key,
|
|
68
85
|
rootKey: MENU.key
|
|
69
86
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
var effectiveSection = section && model.sections.some(function (_ref2) {
|
|
88
|
+
var key = _ref2.key;
|
|
89
|
+
return key === section;
|
|
90
|
+
}) ? section : undefined;
|
|
91
|
+
return {
|
|
92
|
+
model: model,
|
|
93
|
+
effectiveSection: effectiveSection,
|
|
94
|
+
items: getRegistryElementBrowserItems({
|
|
95
|
+
formatMessage: formatMessage,
|
|
96
|
+
model: model,
|
|
97
|
+
query: query,
|
|
98
|
+
section: effectiveSection
|
|
99
|
+
})
|
|
100
|
+
};
|
|
101
|
+
}, [components, formatMessage, query, section]);
|
|
102
|
+
var model = browserModel.model,
|
|
103
|
+
effectiveSection = browserModel.effectiveSection,
|
|
104
|
+
items = browserModel.items;
|
|
105
|
+
var visibleItems = items.length === 0 && !isLoading && query.trim().length > 0 ? (_model$fallbackItems = model.fallbackItems) !== null && _model$fallbackItems !== void 0 ? _model$fallbackItems : EMPTY_ITEMS : items;
|
|
106
|
+
var isSelectedRegistrationCurrent = Boolean(selectedRegistration && browserState.selectionIsOffline === isOffline && visibleItems.some(function (_ref3) {
|
|
107
|
+
var registration = _ref3.registration;
|
|
108
|
+
return registration === selectedRegistration;
|
|
109
|
+
}));
|
|
110
|
+
var selectedKey = isSelectedRegistrationCurrent ? selectedRegistration === null || selectedRegistration === void 0 ? void 0 : selectedRegistration.key : undefined;
|
|
111
|
+
var invalidSection = Boolean(section && section !== effectiveSection);
|
|
112
|
+
var invalidSelection = Boolean(selectedRegistration && !isSelectedRegistrationCurrent);
|
|
113
|
+
if (isOpen && (invalidSection || invalidSelection)) {
|
|
114
|
+
setBrowserState(_objectSpread(_objectSpread({}, browserState), {}, {
|
|
115
|
+
section: effectiveSection,
|
|
116
|
+
selectedRegistration: undefined,
|
|
117
|
+
selectionIsOffline: undefined,
|
|
118
|
+
invalidation: {
|
|
119
|
+
section: invalidSection ? section : undefined,
|
|
120
|
+
selection: invalidSelection
|
|
121
|
+
}
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
85
124
|
var searchInputRef = useRef(null);
|
|
86
125
|
var selectedCategoryRef = useRef(null);
|
|
126
|
+
var focusedCategoryRef = useRef();
|
|
127
|
+
var handledInvalidationRef = useRef(browserState.invalidation);
|
|
87
128
|
var wasOpen = useRef(false);
|
|
88
|
-
var previousIsOffline = useRef(isOffline);
|
|
89
129
|
useEffect(function () {
|
|
90
130
|
if (isOpen && !wasOpen.current) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
131
|
+
selectedRegistrationRef.current = undefined;
|
|
132
|
+
setBrowserState({
|
|
133
|
+
query: '',
|
|
134
|
+
section: getInitialRegistryElementBrowserSection(model, defaultSection),
|
|
135
|
+
selectedRegistration: undefined
|
|
136
|
+
});
|
|
96
137
|
onClearSelection();
|
|
97
138
|
}
|
|
98
139
|
wasOpen.current = isOpen;
|
|
99
140
|
}, [defaultSection, isOpen, model, onClearSelection]);
|
|
100
|
-
var items = useMemo(function () {
|
|
101
|
-
return getRegistryElementBrowserItems({
|
|
102
|
-
formatMessage: formatMessage,
|
|
103
|
-
model: model,
|
|
104
|
-
query: query,
|
|
105
|
-
section: section
|
|
106
|
-
});
|
|
107
|
-
}, [formatMessage, model, query, section]);
|
|
108
|
-
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);
|
|
109
141
|
useEffect(function () {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
142
|
+
var _searchInputRef$curre;
|
|
143
|
+
var invalidation = browserState.invalidation;
|
|
144
|
+
if (!isOpen || !invalidation || handledInvalidationRef.current === invalidation) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
handledInvalidationRef.current = invalidation;
|
|
148
|
+
selectedRegistrationRef.current = undefined;
|
|
149
|
+
onClearSelection();
|
|
150
|
+
var ownerDocument = (_searchInputRef$curre = searchInputRef.current) === null || _searchInputRef$curre === void 0 ? void 0 : _searchInputRef$curre.ownerDocument;
|
|
151
|
+
var activeElement = ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.activeElement;
|
|
152
|
+
if (invalidation.section && focusedCategoryRef.current === invalidation.section && activeElement === (ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body)) {
|
|
153
|
+
var _selectedCategoryRef$;
|
|
154
|
+
(_selectedCategoryRef$ = selectedCategoryRef.current) === null || _selectedCategoryRef$ === void 0 || _selectedCategoryRef$.focus();
|
|
155
|
+
} else if (invalidation.selection && (activeElement === (ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body) || activeElement !== null && activeElement !== void 0 && activeElement.closest('[role="option"]'))) {
|
|
156
|
+
var _searchInputRef$curre2;
|
|
157
|
+
(_searchInputRef$curre2 = searchInputRef.current) === null || _searchInputRef$curre2 === void 0 || _searchInputRef$curre2.focus();
|
|
113
158
|
}
|
|
114
|
-
|
|
115
|
-
|
|
159
|
+
}, [browserState.invalidation, isOpen, onClearSelection]);
|
|
160
|
+
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);
|
|
161
|
+
var flushSearchAnalytics = useQuickInsertSearchAnalytics({
|
|
162
|
+
query: query,
|
|
163
|
+
resultCount: items.length,
|
|
164
|
+
surface: 'element-browser',
|
|
165
|
+
category: effectiveSection !== null && effectiveSection !== void 0 ? effectiveSection : 'all',
|
|
166
|
+
isOpen: isOpen && !isLoading,
|
|
167
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
168
|
+
});
|
|
169
|
+
var closeBrowser = useCallback(function () {
|
|
170
|
+
flushSearchAnalytics();
|
|
171
|
+
onClose();
|
|
172
|
+
}, [flushSearchAnalytics, onClose]);
|
|
173
|
+
var onSearchFocus = useCallback(function () {
|
|
174
|
+
focusedCategoryRef.current = undefined;
|
|
175
|
+
}, []);
|
|
176
|
+
var onBrowserFocusCapture = useCallback(function (event) {
|
|
177
|
+
var _category$dataset$sec;
|
|
178
|
+
var categories = event.currentTarget.querySelector('[data-testid="registry-element-browser-categories"]');
|
|
179
|
+
var category = event.target instanceof HTMLElement && categories !== null && categories !== void 0 && categories.contains(event.target) ? event.target.closest('[data-section]') : null;
|
|
180
|
+
focusedCategoryRef.current = category ? (_category$dataset$sec = category.dataset.section) !== null && _category$dataset$sec !== void 0 ? _category$dataset$sec : '' : undefined;
|
|
181
|
+
}, []);
|
|
116
182
|
var onSearchChange = useCallback(function (event) {
|
|
117
|
-
|
|
118
|
-
|
|
183
|
+
var nextQuery = event.currentTarget.value;
|
|
184
|
+
selectedRegistrationRef.current = undefined;
|
|
185
|
+
setBrowserState(function (current) {
|
|
186
|
+
return _objectSpread(_objectSpread({}, current), {}, {
|
|
187
|
+
query: nextQuery,
|
|
188
|
+
selectedRegistration: undefined
|
|
189
|
+
});
|
|
190
|
+
});
|
|
119
191
|
onClearSelection();
|
|
120
192
|
}, [onClearSelection]);
|
|
121
193
|
var onSectionClick = useCallback(function (event) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
194
|
+
var nextSection = event.currentTarget.dataset.section || undefined;
|
|
195
|
+
selectedRegistrationRef.current = undefined;
|
|
196
|
+
setBrowserState({
|
|
197
|
+
query: '',
|
|
198
|
+
section: nextSection,
|
|
199
|
+
selectedRegistration: undefined
|
|
200
|
+
});
|
|
125
201
|
onClearSelection();
|
|
126
202
|
}, [onClearSelection]);
|
|
127
203
|
var onRegistrySelect = useCallback(function (key, handler) {
|
|
128
|
-
|
|
204
|
+
var _model$items$find;
|
|
205
|
+
var registration = (_model$items$find = model.items.find(function (_ref4) {
|
|
206
|
+
var registration = _ref4.registration;
|
|
207
|
+
return registration.key === key;
|
|
208
|
+
})) === null || _model$items$find === void 0 ? void 0 : _model$items$find.registration;
|
|
209
|
+
selectedRegistrationRef.current = registration;
|
|
210
|
+
setBrowserState(function (current) {
|
|
211
|
+
return _objectSpread(_objectSpread({}, current), {}, {
|
|
212
|
+
selectedRegistration: registration,
|
|
213
|
+
selectionIsOffline: isOffline
|
|
214
|
+
});
|
|
215
|
+
});
|
|
129
216
|
onSelect(handler);
|
|
130
|
-
}, [onSelect]);
|
|
217
|
+
}, [isOffline, model.items, onSelect]);
|
|
218
|
+
var confirmInsert = useCallback(function () {
|
|
219
|
+
var selectedRegistration = selectedRegistrationRef.current;
|
|
220
|
+
if (!selectedRegistration || !visibleItems.some(function (_ref5) {
|
|
221
|
+
var registration = _ref5.registration;
|
|
222
|
+
return registration === selectedRegistration;
|
|
223
|
+
})) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
onConfirmInsert();
|
|
227
|
+
}, [onConfirmInsert, visibleItems]);
|
|
131
228
|
var onModalOpenComplete = useCallback(function (node) {
|
|
132
229
|
node.style.borderRadius = "var(--ds-radius-large, 8px)";
|
|
133
230
|
var footer = node.querySelector("[data-testid=\"".concat(modalTestId, "--footer\"]"));
|
|
@@ -140,9 +237,9 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
|
|
|
140
237
|
}, []);
|
|
141
238
|
var onKeyDown = useCallback(function (event) {
|
|
142
239
|
if (event.key === 'Tab' && event.shiftKey && event.target instanceof HTMLElement && event.target.getAttribute('role') === 'option') {
|
|
143
|
-
var _selectedCategoryRef
|
|
240
|
+
var _selectedCategoryRef$2;
|
|
144
241
|
event.preventDefault();
|
|
145
|
-
(_selectedCategoryRef$ = selectedCategoryRef.current) === null || _selectedCategoryRef$ === void 0 || _selectedCategoryRef
|
|
242
|
+
(_selectedCategoryRef$2 = selectedCategoryRef.current) === null || _selectedCategoryRef$2 === void 0 || _selectedCategoryRef$2.focus();
|
|
146
243
|
return;
|
|
147
244
|
}
|
|
148
245
|
if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
@@ -170,15 +267,15 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
|
|
|
170
267
|
nextOption.focus();
|
|
171
268
|
nextOption.click();
|
|
172
269
|
} else if (nextIndex < 0 && currentIndex >= 0) {
|
|
173
|
-
var _searchInputRef$
|
|
270
|
+
var _searchInputRef$curre3;
|
|
174
271
|
event.preventDefault();
|
|
175
|
-
(_searchInputRef$
|
|
272
|
+
(_searchInputRef$curre3 = searchInputRef.current) === null || _searchInputRef$curre3 === void 0 || _searchInputRef$curre3.focus();
|
|
176
273
|
}
|
|
177
274
|
return;
|
|
178
275
|
}
|
|
179
276
|
if (event.key === 'Escape') {
|
|
180
277
|
event.preventDefault();
|
|
181
|
-
|
|
278
|
+
closeBrowser();
|
|
182
279
|
return;
|
|
183
280
|
}
|
|
184
281
|
if (event.key === 'Enter') {
|
|
@@ -186,22 +283,22 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
|
|
|
186
283
|
var focusedOption = event.target instanceof HTMLElement ? event.target.closest('[role="option"]') : null;
|
|
187
284
|
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])');
|
|
188
285
|
var optionToActivate = focusedOption !== null && focusedOption !== void 0 ? focusedOption : firstOption;
|
|
189
|
-
if (
|
|
286
|
+
if (isSelectedRegistrationCurrent || optionToActivate) {
|
|
190
287
|
event.preventDefault();
|
|
191
|
-
if (!
|
|
288
|
+
if (!isSelectedRegistrationCurrent) {
|
|
192
289
|
optionToActivate === null || optionToActivate === void 0 || optionToActivate.click();
|
|
193
290
|
}
|
|
194
|
-
|
|
291
|
+
confirmInsert();
|
|
195
292
|
}
|
|
196
293
|
}
|
|
197
|
-
}, [
|
|
294
|
+
}, [closeBrowser, confirmInsert, isSelectedRegistrationCurrent]);
|
|
198
295
|
return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(Modal, {
|
|
199
296
|
label: formatMessage({
|
|
200
297
|
defaultMessage: 'Insert elements',
|
|
201
298
|
id: 'editor.quick-insert.title'
|
|
202
299
|
}),
|
|
203
300
|
height: "664px",
|
|
204
|
-
onClose:
|
|
301
|
+
onClose: closeBrowser,
|
|
205
302
|
onCloseComplete: onCloseComplete,
|
|
206
303
|
onOpenComplete: onModalOpenComplete,
|
|
207
304
|
testId: modalTestId,
|
|
@@ -227,6 +324,7 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
|
|
|
227
324
|
}),
|
|
228
325
|
isCompact: true,
|
|
229
326
|
name: "registry-element-browser-search",
|
|
327
|
+
onFocus: onSearchFocus,
|
|
230
328
|
onChange: onSearchChange,
|
|
231
329
|
onKeyDown: onKeyDown,
|
|
232
330
|
ref: searchInputRef,
|
|
@@ -235,12 +333,13 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
|
|
|
235
333
|
appearance: "subtle",
|
|
236
334
|
icon: CrossIcon,
|
|
237
335
|
label: formatMessage(messages.close),
|
|
238
|
-
onClick:
|
|
336
|
+
onClick: closeBrowser,
|
|
239
337
|
spacing: "compact"
|
|
240
338
|
})))), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement("div", {
|
|
339
|
+
onFocusCapture: onBrowserFocusCapture,
|
|
241
340
|
className: ax(["_zulp1fka _18zr1b66 _1e0c11p5 _yv0e1xuv _1q511b66 _lk4ji47z"])
|
|
242
341
|
}, /*#__PURE__*/React.createElement(RegistryElementBrowserCategories, {
|
|
243
|
-
section:
|
|
342
|
+
section: effectiveSection,
|
|
244
343
|
sections: model.sections,
|
|
245
344
|
onSectionClick: onSectionClick,
|
|
246
345
|
selectedButtonRef: selectedCategoryRef
|
|
@@ -253,15 +352,15 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
|
|
|
253
352
|
fallbackItems: model.fallbackItems,
|
|
254
353
|
query: query,
|
|
255
354
|
resultsId: resultsId,
|
|
256
|
-
section:
|
|
355
|
+
section: effectiveSection,
|
|
257
356
|
selectedKey: selectedKey,
|
|
258
357
|
onKeyDown: onKeyDown,
|
|
259
358
|
onSelect: onRegistrySelect
|
|
260
359
|
}))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(RegistryElementBrowserFooter, {
|
|
261
360
|
helpUrl: helpUrl,
|
|
262
|
-
isInsertEnabled:
|
|
263
|
-
onClose:
|
|
264
|
-
onConfirmInsert:
|
|
361
|
+
isInsertEnabled: isSelectedRegistrationCurrent,
|
|
362
|
+
onClose: closeBrowser,
|
|
363
|
+
onConfirmInsert: confirmInsert,
|
|
265
364
|
resultCount: resultCount
|
|
266
365
|
}))));
|
|
267
366
|
};
|
|
@@ -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,27 +1,18 @@
|
|
|
1
1
|
/* RegistryElementBrowserSearchResults.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import "./RegistryElementBrowserSearchResults.compiled.css";
|
|
4
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
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; }
|
|
6
|
-
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; }
|
|
7
4
|
import React, { useMemo } from 'react';
|
|
8
5
|
import { useIntl } from 'react-intl';
|
|
9
|
-
import
|
|
6
|
+
import { QuickInsertEmptyState } from '@atlaskit/editor-common/quick-insert/empty-state';
|
|
10
7
|
import { QuickInsertProvider } from '@atlaskit/editor-common/quick-insert/provider';
|
|
11
|
-
import { Text } from '@atlaskit/primitives/compiled';
|
|
12
8
|
|
|
13
9
|
// oxlint-disable-next-line eslint/no-redeclare
|
|
14
10
|
|
|
15
|
-
import NotFoundIllustration from './NotFoundIllustration';
|
|
16
11
|
var resultsGridStyles = null;
|
|
17
12
|
var emptyStateGridItemStyles = null;
|
|
18
13
|
var styles = {
|
|
19
14
|
fallbackMarketplace: "_1i531l7x _15a5nqa1 _uwhke4h9 _19pkpxbi _ca0qpxbi"
|
|
20
15
|
};
|
|
21
|
-
var emptyStateWrapperStyles = null;
|
|
22
|
-
var emptyStateHeadingStyles = null;
|
|
23
|
-
var emptyStateSubheadingStyles = null;
|
|
24
|
-
var emptyStateLinkStyles = null;
|
|
25
16
|
var RegistryElementBrowserItem = function RegistryElementBrowserItem(_ref) {
|
|
26
17
|
var editorView = _ref.editorView,
|
|
27
18
|
isOffline = _ref.isOffline,
|
|
@@ -54,7 +45,6 @@ var RegistryElementBrowserItem = function RegistryElementBrowserItem(_ref) {
|
|
|
54
45
|
}, /*#__PURE__*/React.createElement(Component, undefined, null));
|
|
55
46
|
};
|
|
56
47
|
export var RegistryElementBrowserSearchResults = function RegistryElementBrowserSearchResults(_ref2) {
|
|
57
|
-
var _emptyStateHandler;
|
|
58
48
|
var editorView = _ref2.editorView,
|
|
59
49
|
emptyStateHandler = _ref2.emptyStateHandler,
|
|
60
50
|
fallbackItems = _ref2.fallbackItems,
|
|
@@ -77,34 +67,12 @@ export var RegistryElementBrowserSearchResults = function RegistryElementBrowser
|
|
|
77
67
|
});
|
|
78
68
|
var displayedItems = hasFallbackItems && fallbackItems ? fallbackItems : items;
|
|
79
69
|
var shouldRenderEmptyState = items.length === 0 && !isLoading;
|
|
80
|
-
var emptyState = shouldRenderEmptyState ?
|
|
70
|
+
var emptyState = shouldRenderEmptyState ? emptyStateHandler === null || emptyStateHandler === void 0 ? void 0 : emptyStateHandler({
|
|
81
71
|
mode: 'full',
|
|
82
72
|
searchTerm: query,
|
|
83
|
-
selectedCategory: section
|
|
84
|
-
}, hasFallbackItems ? {
|
|
73
|
+
selectedCategory: section,
|
|
85
74
|
showNoResultsMessage: false
|
|
86
|
-
} :
|
|
87
|
-
className: ax(["_4cvr1h6o _1e0c1txw _2lx21bp4 _1bah1h6o _1bsb1osq"])
|
|
88
|
-
}, /*#__PURE__*/React.createElement(NotFoundIllustration, null), /*#__PURE__*/React.createElement("div", {
|
|
89
|
-
className: ax(["_11c81af2 _syazi7uo _19pk1ejb"])
|
|
90
|
-
}, formatMessage({
|
|
91
|
-
defaultMessage: 'Nothing matches your search',
|
|
92
|
-
id: 'editor.quick-insert.empty'
|
|
93
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
94
|
-
className: ax(["_19pkpxbi _p12f1kdj _y3gn1h6o"])
|
|
95
|
-
}, /*#__PURE__*/React.createElement(Text, null, formatMessage({
|
|
96
|
-
defaultMessage: 'Try searching with a different term or discover new apps for Atlassian products.',
|
|
97
|
-
id: 'editor.quick-insert.empty-description'
|
|
98
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
99
|
-
className: ax(["_19pkutpp"])
|
|
100
|
-
}, /*#__PURE__*/React.createElement(LinkButton, {
|
|
101
|
-
appearance: "primary",
|
|
102
|
-
href: "https://marketplace.atlassian.com/search?category=Macros&hosting=cloud&product=confluence",
|
|
103
|
-
target: "_blank"
|
|
104
|
-
}, formatMessage({
|
|
105
|
-
defaultMessage: 'Explore Atlassian Marketplace',
|
|
106
|
-
id: 'editor.quick-insert.explore-marketplace'
|
|
107
|
-
}))))) : null;
|
|
75
|
+
}) : null;
|
|
108
76
|
return /*#__PURE__*/React.createElement("div", {
|
|
109
77
|
"data-testid": "registry-element-browser-results",
|
|
110
78
|
id: resultsId,
|
|
@@ -130,7 +98,9 @@ export var RegistryElementBrowserSearchResults = function RegistryElementBrowser
|
|
|
130
98
|
key: item.registration.key,
|
|
131
99
|
onSelect: onSelect
|
|
132
100
|
});
|
|
133
|
-
})),
|
|
134
|
-
|
|
101
|
+
})), shouldRenderEmptyState && !hasFallbackItems && query.trim().length > 0 && /*#__PURE__*/React.createElement(QuickInsertEmptyState, {
|
|
102
|
+
mode: "full"
|
|
103
|
+
}), emptyState && /*#__PURE__*/React.createElement("div", {
|
|
104
|
+
className: ax(["_yyhyjvu9 _1ul9idpf _1bsb1osq", styles.fallbackMarketplace])
|
|
135
105
|
}, emptyState));
|
|
136
106
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { useCallback, useEffect,
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums';
|
|
4
4
|
import { isOfflineMode } from '@atlaskit/editor-common/connectivity/isOfflineMode';
|
|
5
5
|
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
@@ -8,8 +8,12 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/useSha
|
|
|
8
8
|
import { closeElementBrowser } from '../../pm-plugins/commands';
|
|
9
9
|
import { pluginKey } from '../../pm-plugins/plugin-key';
|
|
10
10
|
import { RegistryElementBrowser } from './RegistryElementBrowser';
|
|
11
|
+
var EMPTY_COMPONENTS = [];
|
|
12
|
+
var subscribeToNothing = function subscribeToNothing() {
|
|
13
|
+
return function () {};
|
|
14
|
+
};
|
|
11
15
|
export var RegistryElementBrowserContainer = function RegistryElementBrowserContainer(_ref) {
|
|
12
|
-
var _pluginKey$getState;
|
|
16
|
+
var _pluginInjectionAPI$u2, _pluginInjectionAPI$u3, _pluginInjectionAPI$a2, _pluginKey$getState;
|
|
13
17
|
var editorView = _ref.editorView,
|
|
14
18
|
pluginInjectionAPI = _ref.pluginInjectionAPI,
|
|
15
19
|
helpUrl = _ref.helpUrl;
|
|
@@ -24,12 +28,15 @@ export var RegistryElementBrowserContainer = function RegistryElementBrowserCont
|
|
|
24
28
|
currentEmptyStateHandler = _useSharedPluginState.emptyStateHandler,
|
|
25
29
|
isElementBrowserOpen = _useSharedPluginState.isElementBrowserOpen,
|
|
26
30
|
mode = _useSharedPluginState.mode;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
var getRegistrySnapshot = useCallback(function () {
|
|
32
|
+
var _pluginInjectionAPI$u;
|
|
33
|
+
if (!isElementBrowserOpen) {
|
|
34
|
+
return EMPTY_COMPONENTS;
|
|
35
|
+
}
|
|
36
|
+
var components = pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$u = pluginInjectionAPI.uiControlRegistry) === null || _pluginInjectionAPI$u === void 0 ? void 0 : _pluginInjectionAPI$u.actions.getComponents(MENU.key);
|
|
37
|
+
return components !== null && components !== void 0 && components.length ? components : EMPTY_COMPONENTS;
|
|
32
38
|
}, [isElementBrowserOpen, pluginInjectionAPI]);
|
|
39
|
+
var components = 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);
|
|
33
40
|
var _useState = useState(),
|
|
34
41
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
42
|
emptyStateHandler = _useState2[0],
|
|
@@ -120,6 +127,7 @@ export var RegistryElementBrowserContainer = function RegistryElementBrowserCont
|
|
|
120
127
|
}, [onClose]);
|
|
121
128
|
return /*#__PURE__*/React.createElement(RegistryElementBrowser, {
|
|
122
129
|
components: components,
|
|
130
|
+
fireAnalyticsEvent: pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$a2 = pluginInjectionAPI.analytics) === null || _pluginInjectionAPI$a2 === void 0 ? void 0 : _pluginInjectionAPI$a2.actions.fireAnalyticsEvent,
|
|
123
131
|
emptyStateHandler: emptyStateHandler,
|
|
124
132
|
helpUrl: helpUrl,
|
|
125
133
|
defaultSection: (_pluginKey$getState = pluginKey.getState(editorView.state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.elementBrowserInitialCategory,
|
|
@@ -47,7 +47,7 @@ var _getDescendantItems = function getDescendantItems(components, parentKey, anc
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Builds the Element Browser's
|
|
50
|
+
* Builds the Element Browser's view of the resolved Quick Insert registry.
|
|
51
51
|
* The caller provides only components rooted at the Quick Insert menu surface.
|
|
52
52
|
*/
|
|
53
53
|
export var createRegistryElementBrowserModel = function createRegistryElementBrowserModel(components, _ref) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics/api';
|
|
6
7
|
import type { QuickInsertSelectionHandler } from '@atlaskit/editor-common/quick-insert/context';
|
|
7
8
|
import type { EmptyStateHandler } from '@atlaskit/editor-common/types/empty-state-handler';
|
|
8
9
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -12,6 +13,7 @@ type Props = {
|
|
|
12
13
|
defaultSection?: string;
|
|
13
14
|
editorView: EditorView;
|
|
14
15
|
emptyStateHandler?: EmptyStateHandler;
|
|
16
|
+
fireAnalyticsEvent?: EditorAnalyticsAPI['fireAnalyticsEvent'];
|
|
15
17
|
helpUrl?: string;
|
|
16
18
|
isLoading?: boolean;
|
|
17
19
|
isOffline: boolean;
|
|
@@ -22,5 +24,5 @@ type Props = {
|
|
|
22
24
|
onConfirmInsert: () => void;
|
|
23
25
|
onSelect: (handler: QuickInsertSelectionHandler) => void;
|
|
24
26
|
};
|
|
25
|
-
export declare const RegistryElementBrowser: ({ components, emptyStateHandler, defaultSection, helpUrl, editorView, isLoading, isOffline, isOpen, onClearSelection, onClose, onCloseComplete, onConfirmInsert, onSelect, }: Props) => React.JSX.Element | null;
|
|
27
|
+
export declare const RegistryElementBrowser: ({ components, emptyStateHandler, fireAnalyticsEvent, defaultSection, helpUrl, editorView, isLoading, isOffline, isOpen, onClearSelection, onClose, onCloseComplete, onConfirmInsert, onSelect, }: Props) => React.JSX.Element | null;
|
|
26
28
|
export {};
|
|
@@ -15,7 +15,7 @@ export type RegistryElementBrowserModel = {
|
|
|
15
15
|
sections: RegistryElementBrowserSection[];
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Builds the Element Browser's
|
|
18
|
+
* Builds the Element Browser's view of the resolved Quick Insert registry.
|
|
19
19
|
* The caller provides only components rooted at the Quick Insert menu surface.
|
|
20
20
|
*/
|
|
21
21
|
export declare const createRegistryElementBrowserModel: (components: RegisterComponent[], { footerKey, overflowKeys, recommendedSectionKey, rootKey, }: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-quick-insert",
|
|
3
|
-
"version": "27.0
|
|
3
|
+
"version": "27.1.0",
|
|
4
4
|
"description": "Quick insert plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@atlaskit/modal-dialog": "^17.0.0",
|
|
43
43
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
45
|
-
"@atlaskit/primitives": "^22.
|
|
45
|
+
"@atlaskit/primitives": "^22.6.0",
|
|
46
46
|
"@atlaskit/textfield": "^10.2.0",
|
|
47
47
|
"@atlaskit/tmp-editor-statsig": "^240.0.0",
|
|
48
48
|
"@atlaskit/tokens": "^20.6.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@emotion/react": "^11.7.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@atlaskit/editor-common": "^131.
|
|
55
|
+
"@atlaskit/editor-common": "^131.4.0",
|
|
56
56
|
"react": "^18.2.0 || ^19.2.0",
|
|
57
57
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
58
58
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|