@atlaskit/editor-plugin-insert-block 28.0.5 → 29.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 +20 -0
- package/dist/cjs/ui/registered-insert-menu/RegisteredInsertMenu.js +113 -16
- package/dist/cjs/ui/registered-insert-menu/RegisteredInsertMenuContent.js +12 -9
- package/dist/cjs/ui/registered-insert-menu/RegisteredInsertMenuItem.js +7 -2
- package/dist/cjs/ui/registered-insert-menu/RegisteredInsertMenuList.compiled.css +2 -0
- package/dist/cjs/ui/registered-insert-menu/RegisteredInsertMenuList.js +137 -51
- package/dist/es2019/ui/registered-insert-menu/RegisteredInsertMenu.js +98 -11
- package/dist/es2019/ui/registered-insert-menu/RegisteredInsertMenuContent.js +11 -7
- package/dist/es2019/ui/registered-insert-menu/RegisteredInsertMenuItem.js +7 -2
- package/dist/es2019/ui/registered-insert-menu/RegisteredInsertMenuList.compiled.css +2 -0
- package/dist/es2019/ui/registered-insert-menu/RegisteredInsertMenuList.js +99 -21
- package/dist/esm/ui/registered-insert-menu/RegisteredInsertMenu.js +113 -16
- package/dist/esm/ui/registered-insert-menu/RegisteredInsertMenuContent.js +13 -10
- package/dist/esm/ui/registered-insert-menu/RegisteredInsertMenuItem.js +7 -2
- package/dist/esm/ui/registered-insert-menu/RegisteredInsertMenuList.compiled.css +2 -0
- package/dist/esm/ui/registered-insert-menu/RegisteredInsertMenuList.js +138 -52
- package/dist/types/ui/registered-insert-menu/RegisteredInsertMenu.d.ts +3 -1
- package/dist/types/ui/registered-insert-menu/RegisteredInsertMenuItem.d.ts +1 -0
- package/dist/types/ui/registered-insert-menu/RegisteredInsertMenuList.d.ts +7 -2
- package/package.json +32 -32
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useCallback, useContext, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useContext, useSyncExternalStore } from 'react';
|
|
3
2
|
import { MENU } from '@atlaskit/editor-common/quick-insert/keys';
|
|
4
3
|
import { PlainOutsideClickTargetRefContext } from '@atlaskit/editor-common/ui';
|
|
5
4
|
import withOuterListeners from '@atlaskit/editor-common/with-outer-listeners';
|
|
6
5
|
import { RegisteredInsertMenu } from './RegisteredInsertMenu';
|
|
6
|
+
var EMPTY_COMPONENTS = [];
|
|
7
|
+
var subscribeToNothing = function subscribeToNothing() {
|
|
8
|
+
return function () {};
|
|
9
|
+
};
|
|
7
10
|
var RegisteredInsertMenuContainer = function RegisteredInsertMenuContainer(_ref) {
|
|
8
11
|
var children = _ref.children;
|
|
9
12
|
var setOutsideClickTargetRef = useContext(PlainOutsideClickTargetRefContext);
|
|
@@ -13,7 +16,7 @@ var RegisteredInsertMenuContainer = function RegisteredInsertMenuContainer(_ref)
|
|
|
13
16
|
};
|
|
14
17
|
var RegisteredInsertMenuWithListeners = withOuterListeners(RegisteredInsertMenuContainer);
|
|
15
18
|
export var RegisteredInsertMenuContent = function RegisteredInsertMenuContent(_ref2) {
|
|
16
|
-
var _api$quickInsert, _api$quickInsert2;
|
|
19
|
+
var _api$uiControlRegistr2, _api$uiControlRegistr3, _api$quickInsert, _api$analytics, _api$quickInsert2;
|
|
17
20
|
var api = _ref2.api,
|
|
18
21
|
editorView = _ref2.editorView,
|
|
19
22
|
isOffline = _ref2.isOffline,
|
|
@@ -22,13 +25,12 @@ export var RegisteredInsertMenuContent = function RegisteredInsertMenuContent(_r
|
|
|
22
25
|
onDismiss = _ref2.onDismiss,
|
|
23
26
|
onSelect = _ref2.onSelect,
|
|
24
27
|
target = _ref2.target;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
components = _useState2[0];
|
|
28
|
+
var getComponents = useCallback(function () {
|
|
29
|
+
var _api$uiControlRegistr;
|
|
30
|
+
var components = api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.getComponents(MENU.key);
|
|
31
|
+
return components !== null && components !== void 0 && components.length ? components : EMPTY_COMPONENTS;
|
|
32
|
+
}, [api]);
|
|
33
|
+
var components = useSyncExternalStore((_api$uiControlRegistr2 = api === null || api === void 0 || (_api$uiControlRegistr3 = api.uiControlRegistry) === null || _api$uiControlRegistr3 === void 0 ? void 0 : _api$uiControlRegistr3.actions.subscribe) !== null && _api$uiControlRegistr2 !== void 0 ? _api$uiControlRegistr2 : subscribeToNothing, getComponents, getComponents);
|
|
32
34
|
var onClickOutside = useCallback(function (event) {
|
|
33
35
|
if (event.target instanceof Node && target !== null && target !== void 0 && target.contains(event.target)) {
|
|
34
36
|
return;
|
|
@@ -41,6 +43,7 @@ export var RegisteredInsertMenuContent = function RegisteredInsertMenuContent(_r
|
|
|
41
43
|
components: components,
|
|
42
44
|
editorView: editorView,
|
|
43
45
|
emptyStateHandler: api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || (_api$quickInsert = _api$quickInsert.sharedState.currentState()) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.emptyStateHandler,
|
|
46
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent,
|
|
44
47
|
getItemRank: api === null || api === void 0 || (_api$quickInsert2 = api.quickInsert) === null || _api$quickInsert2 === void 0 || (_api$quickInsert2 = _api$quickInsert2.sharedState.currentState()) === null || _api$quickInsert2 === void 0 ? void 0 : _api$quickInsert2.getItemRank,
|
|
45
48
|
isOffline: isOffline,
|
|
46
49
|
maxHeight: maxHeight,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import React, { useCallback, useMemo } from 'react';
|
|
1
|
+
import React, { createContext, useCallback, useContext, useMemo } from 'react';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums';
|
|
3
3
|
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
4
4
|
import { QuickInsertProvider } from '@atlaskit/editor-common/quick-insert/provider';
|
|
5
|
+
// Preview updates must remain live while react-virtualized caches row elements during scrolling.
|
|
6
|
+
export var RegisteredInsertMenuPreviewContext = /*#__PURE__*/createContext(undefined);
|
|
5
7
|
export var RegisteredInsertMenuItem = function RegisteredInsertMenuItem(_ref) {
|
|
6
8
|
var _registration$compone;
|
|
7
9
|
var editorView = _ref.editorView,
|
|
@@ -13,6 +15,8 @@ export var RegisteredInsertMenuItem = function RegisteredInsertMenuItem(_ref) {
|
|
|
13
15
|
registration = _ref.registration,
|
|
14
16
|
surfaceContext = _ref.surfaceContext;
|
|
15
17
|
var Component = (_registration$compone = registration.component) !== null && _registration$compone !== void 0 ? _registration$compone : React.Fragment;
|
|
18
|
+
var activePreviewItemKey = useContext(RegisteredInsertMenuPreviewContext);
|
|
19
|
+
var isPreviewActive = activePreviewItemKey === registration.key;
|
|
16
20
|
var select = useCallback(function (selectionHandler) {
|
|
17
21
|
// Close first so a registered item may safely focus the editor or open its picker.
|
|
18
22
|
onClose();
|
|
@@ -37,6 +41,7 @@ export var RegisteredInsertMenuItem = function RegisteredInsertMenuItem(_ref) {
|
|
|
37
41
|
isOffline: isOffline,
|
|
38
42
|
item: {
|
|
39
43
|
id: id,
|
|
44
|
+
isPreviewActive: isPreviewActive,
|
|
40
45
|
isSelected: isSelected
|
|
41
46
|
},
|
|
42
47
|
menuOpenId: menuOpenId,
|
|
@@ -44,7 +49,7 @@ export var RegisteredInsertMenuItem = function RegisteredInsertMenuItem(_ref) {
|
|
|
44
49
|
surface: 'toolbar',
|
|
45
50
|
surfaceContext: surfaceContext
|
|
46
51
|
};
|
|
47
|
-
}, [editorView, id, isOffline, isSelected, menuOpenId, select, surfaceContext]);
|
|
52
|
+
}, [editorView, id, isOffline, isPreviewActive, isSelected, menuOpenId, select, surfaceContext]);
|
|
48
53
|
return /*#__PURE__*/React.createElement(QuickInsertProvider, {
|
|
49
54
|
value: contextValue
|
|
50
55
|
}, /*#__PURE__*/React.createElement(Component, null, null));
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
._1e0c1txw{display:flex}
|
|
5
5
|
._1i531l7x{border-top-color:var(--ds-border,#0b120e24)}
|
|
6
6
|
._1o9zidpf{flex-shrink:0}
|
|
7
|
+
._1q51u2gc{padding-block-start:var(--ds-space-100,8px)}
|
|
7
8
|
._1tkeidpf{min-height:0}
|
|
8
9
|
._2lx21bp4{flex-direction:column}
|
|
10
|
+
._85i5u2gc{padding-block-end:var(--ds-space-100,8px)}
|
|
9
11
|
._uwhke4h9{border-top-width:var(--ds-border-width,1px)}
|
|
@@ -10,10 +10,11 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
10
10
|
import React, { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
|
|
11
11
|
import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
|
|
12
12
|
import { List } from 'react-virtualized/dist/commonjs/List';
|
|
13
|
+
import { QuickInsertEmptyState } from '@atlaskit/editor-common/quick-insert/empty-state';
|
|
13
14
|
import { getQuickInsertMenuRows } from '@atlaskit/editor-common/quick-insert/registered-menu-model';
|
|
14
15
|
import { useMenuListHeight } from '@atlaskit/editor-common/quick-insert/use-menu-list-height';
|
|
15
16
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
16
|
-
import { RegisteredInsertMenuItem } from './RegisteredInsertMenuItem';
|
|
17
|
+
import { RegisteredInsertMenuItem, RegisteredInsertMenuPreviewContext } from './RegisteredInsertMenuItem';
|
|
17
18
|
var ESTIMATED_ROW_HEIGHT = 44;
|
|
18
19
|
// 44px item + 1px separator.
|
|
19
20
|
var MENU_FOOTER_HEIGHT = 45;
|
|
@@ -26,24 +27,77 @@ var listAriaProps = {
|
|
|
26
27
|
var styles = {
|
|
27
28
|
content: "_1e0c1txw _2lx21bp4 _1tkeidpf",
|
|
28
29
|
scrollable: "_16jlkb7n _1tkeidpf _18m91wug",
|
|
29
|
-
footer: "
|
|
30
|
+
footer: "_1o9zidpf",
|
|
31
|
+
footerWithDivider: "_1i531l7x _15a5nqa1 _uwhke4h9 _1o9zidpf",
|
|
32
|
+
externalControls: "_1i531l7x _15a5nqa1 _uwhke4h9 _1q51u2gc _85i5u2gc"
|
|
30
33
|
};
|
|
31
|
-
|
|
32
|
-
var _model$root$component, _model$root;
|
|
34
|
+
var RegisteredInsertMenuItemRow = function RegisteredInsertMenuItemRow(_ref) {
|
|
33
35
|
var editorView = _ref.editorView,
|
|
34
|
-
|
|
36
|
+
id = _ref.id,
|
|
35
37
|
isOffline = _ref.isOffline,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
maxHeight = _ref.maxHeight,
|
|
38
|
+
isSelected = _ref.isSelected,
|
|
39
|
+
itemIndex = _ref.itemIndex,
|
|
39
40
|
menuOpenId = _ref.menuOpenId,
|
|
40
|
-
model = _ref.model,
|
|
41
41
|
onClose = _ref.onClose,
|
|
42
|
-
|
|
42
|
+
onItemFocus = _ref.onItemFocus,
|
|
43
|
+
onItemBlur = _ref.onItemBlur,
|
|
43
44
|
onItemHover = _ref.onItemHover,
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
onItemLeave = _ref.onItemLeave,
|
|
46
|
+
registration = _ref.registration,
|
|
46
47
|
surfaceContext = _ref.surfaceContext;
|
|
48
|
+
useLayoutEffect(function () {
|
|
49
|
+
return function () {
|
|
50
|
+
return onItemLeave(registration.key);
|
|
51
|
+
};
|
|
52
|
+
}, [onItemLeave, registration.key]);
|
|
53
|
+
var onBlur = useCallback(function (event) {
|
|
54
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
55
|
+
onItemBlur(registration.key);
|
|
56
|
+
}
|
|
57
|
+
}, [onItemBlur, registration.key]);
|
|
58
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
onBlur: onBlur,
|
|
60
|
+
onFocus: function onFocus() {
|
|
61
|
+
return onItemFocus(itemIndex, registration.key);
|
|
62
|
+
},
|
|
63
|
+
onMouseLeave: function onMouseLeave() {
|
|
64
|
+
return onItemLeave(registration.key);
|
|
65
|
+
},
|
|
66
|
+
onMouseMove: function onMouseMove() {
|
|
67
|
+
return onItemHover(itemIndex, registration.key);
|
|
68
|
+
}
|
|
69
|
+
}, /*#__PURE__*/React.createElement(RegisteredInsertMenuItem, {
|
|
70
|
+
editorView: editorView,
|
|
71
|
+
id: id,
|
|
72
|
+
isOffline: isOffline,
|
|
73
|
+
isSelected: isSelected,
|
|
74
|
+
menuOpenId: menuOpenId,
|
|
75
|
+
onClose: onClose,
|
|
76
|
+
registration: registration,
|
|
77
|
+
surfaceContext: surfaceContext
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
export var RegisteredInsertMenuList = function RegisteredInsertMenuList(_ref2) {
|
|
81
|
+
var _model$root$component, _model$root;
|
|
82
|
+
var editorView = _ref2.editorView,
|
|
83
|
+
emptyStateHandler = _ref2.emptyStateHandler,
|
|
84
|
+
isOffline = _ref2.isOffline,
|
|
85
|
+
listId = _ref2.listId,
|
|
86
|
+
listLabel = _ref2.listLabel,
|
|
87
|
+
maxHeight = _ref2.maxHeight,
|
|
88
|
+
menuOpenId = _ref2.menuOpenId,
|
|
89
|
+
model = _ref2.model,
|
|
90
|
+
onClose = _ref2.onClose,
|
|
91
|
+
onItemFocus = _ref2.onItemFocus,
|
|
92
|
+
onItemBlur = _ref2.onItemBlur,
|
|
93
|
+
query = _ref2.query,
|
|
94
|
+
onItemHover = _ref2.onItemHover,
|
|
95
|
+
onItemLeave = _ref2.onItemLeave,
|
|
96
|
+
onItemVisibilityChange = _ref2.onItemVisibilityChange,
|
|
97
|
+
onRenderedItemsChange = _ref2.onRenderedItemsChange,
|
|
98
|
+
selectedItemIndex = _ref2.selectedItemIndex,
|
|
99
|
+
surfaceContext = _ref2.surfaceContext,
|
|
100
|
+
activePreviewItemKey = _ref2.activePreviewItemKey;
|
|
47
101
|
var Root = (_model$root$component = (_model$root = model.root) === null || _model$root === void 0 ? void 0 : _model$root.component) !== null && _model$root$component !== void 0 ? _model$root$component : React.Fragment;
|
|
48
102
|
var listRef = useRef(null);
|
|
49
103
|
var setListRef = useCallback(function (list) {
|
|
@@ -88,9 +142,9 @@ export var RegisteredInsertMenuList = function RegisteredInsertMenuList(_ref) {
|
|
|
88
142
|
return -1;
|
|
89
143
|
}, [itemIndexByRowIndex, selectedItemIndex]);
|
|
90
144
|
var rowKeySignature = useMemo(function () {
|
|
91
|
-
return rows.map(function (
|
|
92
|
-
var key =
|
|
93
|
-
type =
|
|
145
|
+
return rows.map(function (_ref3) {
|
|
146
|
+
var key = _ref3.key,
|
|
147
|
+
type = _ref3.type;
|
|
94
148
|
return "".concat(type, ":").concat(key);
|
|
95
149
|
}).join('\0');
|
|
96
150
|
}, [rows]);
|
|
@@ -103,61 +157,75 @@ export var RegisteredInsertMenuList = function RegisteredInsertMenuList(_ref) {
|
|
|
103
157
|
(_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.recomputeRowHeights();
|
|
104
158
|
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 || _listRef$current2.scrollToPosition(0);
|
|
105
159
|
}, [cache, rowKeySignature]);
|
|
106
|
-
var onRowsRendered = useCallback(function (
|
|
160
|
+
var onRowsRendered = useCallback(function (_ref4) {
|
|
107
161
|
var _indexes$, _indexes;
|
|
108
|
-
var overscanStartIndex =
|
|
109
|
-
overscanStopIndex =
|
|
162
|
+
var overscanStartIndex = _ref4.overscanStartIndex,
|
|
163
|
+
overscanStopIndex = _ref4.overscanStopIndex,
|
|
164
|
+
startIndex = _ref4.startIndex,
|
|
165
|
+
stopIndex = _ref4.stopIndex;
|
|
166
|
+
if (activePreviewItemKey) {
|
|
167
|
+
var previewRowIndex = rows.findIndex(function (_ref5) {
|
|
168
|
+
var key = _ref5.key;
|
|
169
|
+
return key === activePreviewItemKey;
|
|
170
|
+
});
|
|
171
|
+
if (previewRowIndex < startIndex || previewRowIndex > stopIndex) {
|
|
172
|
+
onItemVisibilityChange(activePreviewItemKey, false);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
110
175
|
updateHeight();
|
|
111
|
-
var indexes = _toConsumableArray(itemIndexByRowIndex).filter(function (
|
|
112
|
-
var
|
|
113
|
-
rowIndex =
|
|
176
|
+
var indexes = _toConsumableArray(itemIndexByRowIndex).filter(function (_ref6) {
|
|
177
|
+
var _ref7 = _slicedToArray(_ref6, 1),
|
|
178
|
+
rowIndex = _ref7[0];
|
|
114
179
|
return rowIndex >= overscanStartIndex && rowIndex <= overscanStopIndex;
|
|
115
|
-
}).map(function (
|
|
116
|
-
var
|
|
117
|
-
itemIndex =
|
|
180
|
+
}).map(function (_ref8) {
|
|
181
|
+
var _ref9 = _slicedToArray(_ref8, 2),
|
|
182
|
+
itemIndex = _ref9[1];
|
|
118
183
|
return itemIndex;
|
|
119
184
|
});
|
|
120
185
|
onRenderedItemsChange({
|
|
121
186
|
startIndex: (_indexes$ = indexes[0]) !== null && _indexes$ !== void 0 ? _indexes$ : -1,
|
|
122
187
|
stopIndex: (_indexes = indexes[indexes.length - 1]) !== null && _indexes !== void 0 ? _indexes : -1
|
|
123
188
|
});
|
|
124
|
-
}, [itemIndexByRowIndex, onRenderedItemsChange, updateHeight]);
|
|
125
|
-
var
|
|
189
|
+
}, [activePreviewItemKey, itemIndexByRowIndex, onItemVisibilityChange, onRenderedItemsChange, rows, updateHeight]);
|
|
190
|
+
var onScrollableContentScroll = useCallback(function (event) {
|
|
191
|
+
if (event.target === event.currentTarget && activePreviewItemKey) {
|
|
192
|
+
onItemVisibilityChange(activePreviewItemKey, false);
|
|
193
|
+
}
|
|
194
|
+
}, [activePreviewItemKey, onItemVisibilityChange]);
|
|
195
|
+
var renderRow = useCallback(function (_ref0) {
|
|
126
196
|
var _registration$compone;
|
|
127
|
-
var index =
|
|
128
|
-
key =
|
|
129
|
-
parent =
|
|
130
|
-
style =
|
|
197
|
+
var index = _ref0.index,
|
|
198
|
+
key = _ref0.key,
|
|
199
|
+
parent = _ref0.parent,
|
|
200
|
+
style = _ref0.style;
|
|
131
201
|
var registration = rows[index];
|
|
132
202
|
if (!registration) {
|
|
133
203
|
return null;
|
|
134
204
|
}
|
|
135
205
|
var itemIndex = itemIndexByRowIndex.get(index);
|
|
136
|
-
var rowContent = registration.type === 'menu-section' ? ( /*#__PURE__*/React.createElement((_registration$compone = registration.component) !== null && _registration$compone !== void 0 ? _registration$compone : React.Fragment, null, null)) : /*#__PURE__*/React.createElement(
|
|
137
|
-
onFocus: function onFocus() {
|
|
138
|
-
return onItemHover(itemIndex !== null && itemIndex !== void 0 ? itemIndex : 0);
|
|
139
|
-
},
|
|
140
|
-
onMouseMove: function onMouseMove() {
|
|
141
|
-
return onItemHover(itemIndex !== null && itemIndex !== void 0 ? itemIndex : 0);
|
|
142
|
-
}
|
|
143
|
-
}, /*#__PURE__*/React.createElement(RegisteredInsertMenuItem, {
|
|
206
|
+
var rowContent = registration.type === 'menu-section' ? ( /*#__PURE__*/React.createElement((_registration$compone = registration.component) !== null && _registration$compone !== void 0 ? _registration$compone : React.Fragment, null, null)) : /*#__PURE__*/React.createElement(RegisteredInsertMenuItemRow, {
|
|
144
207
|
editorView: editorView,
|
|
145
208
|
id: "".concat(listId, "-").concat(itemIndex),
|
|
146
209
|
isOffline: isOffline,
|
|
147
210
|
isSelected: itemIndex === selectedItemIndex,
|
|
211
|
+
itemIndex: itemIndex !== null && itemIndex !== void 0 ? itemIndex : 0,
|
|
148
212
|
menuOpenId: menuOpenId,
|
|
149
213
|
onClose: onClose,
|
|
214
|
+
onItemFocus: onItemFocus,
|
|
215
|
+
onItemBlur: onItemBlur,
|
|
216
|
+
onItemHover: onItemHover,
|
|
217
|
+
onItemLeave: onItemLeave,
|
|
150
218
|
registration: registration,
|
|
151
219
|
surfaceContext: surfaceContext
|
|
152
|
-
})
|
|
220
|
+
});
|
|
153
221
|
return /*#__PURE__*/React.createElement(CellMeasurer, {
|
|
154
222
|
key: key,
|
|
155
223
|
cache: cache,
|
|
156
224
|
parent: parent,
|
|
157
225
|
columnIndex: 0,
|
|
158
226
|
rowIndex: index
|
|
159
|
-
}, function (
|
|
160
|
-
var registerChild =
|
|
227
|
+
}, function (_ref1) {
|
|
228
|
+
var registerChild = _ref1.registerChild;
|
|
161
229
|
return /*#__PURE__*/React.createElement("div", {
|
|
162
230
|
ref: function ref(element) {
|
|
163
231
|
return registerChild === null || registerChild === void 0 ? void 0 : registerChild(element !== null && element !== void 0 ? element : undefined);
|
|
@@ -165,12 +233,21 @@ export var RegisteredInsertMenuList = function RegisteredInsertMenuList(_ref) {
|
|
|
165
233
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
166
234
|
,
|
|
167
235
|
style: style
|
|
168
|
-
},
|
|
236
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
237
|
+
paddingBlockEnd: index === rows.length - 1 ? 'space.100' : undefined
|
|
238
|
+
}, rowContent));
|
|
169
239
|
});
|
|
170
|
-
}, [cache, editorView, isOffline, itemIndexByRowIndex, listId, menuOpenId, onClose, onItemHover, rows, selectedItemIndex, surfaceContext]);
|
|
240
|
+
}, [cache, editorView, isOffline, itemIndexByRowIndex, listId, menuOpenId, onClose, onItemFocus, onItemBlur, onItemHover, onItemLeave, rows, selectedItemIndex, surfaceContext]);
|
|
171
241
|
var footerItemIndex = itemIndexByRowIndex.size;
|
|
172
242
|
var footerItemId = "".concat(listId, "-").concat(footerItemIndex);
|
|
173
243
|
var hasExternalControls = model.fallbackItems !== undefined && emptyStateHandler !== undefined;
|
|
244
|
+
var hasNoSearchResults = query !== '' && rows.length === 0;
|
|
245
|
+
var externalControls = hasExternalControls && emptyStateHandler ? emptyStateHandler({
|
|
246
|
+
mode: 'inline',
|
|
247
|
+
searchTerm: query,
|
|
248
|
+
showNoResultsMessage: false
|
|
249
|
+
}) : null;
|
|
250
|
+
var showFooterDivider = !hasNoSearchResults || Boolean(externalControls);
|
|
174
251
|
var listMaxHeight = Math.max(0, maxHeight - MENU_SEARCH_HEIGHT - (model.footer ? MENU_FOOTER_HEIGHT : 0));
|
|
175
252
|
var contentStyle = {
|
|
176
253
|
maxHeight: Math.max(0, maxHeight - MENU_SEARCH_HEIGHT)
|
|
@@ -178,9 +255,13 @@ export var RegisteredInsertMenuList = function RegisteredInsertMenuList(_ref) {
|
|
|
178
255
|
var onFooterItemHover = useCallback(function () {
|
|
179
256
|
return onItemHover(footerItemIndex);
|
|
180
257
|
}, [footerItemIndex, onItemHover]);
|
|
258
|
+
var onFooterItemFocus = useCallback(function () {
|
|
259
|
+
return onItemFocus(footerItemIndex);
|
|
260
|
+
}, [footerItemIndex, onItemFocus]);
|
|
181
261
|
var footer = model.footer ? /*#__PURE__*/React.createElement(Box, {
|
|
182
|
-
|
|
183
|
-
|
|
262
|
+
testId: "registered-insert-menu-footer",
|
|
263
|
+
xcss: showFooterDivider ? styles.footerWithDivider : styles.footer,
|
|
264
|
+
onFocus: onFooterItemFocus,
|
|
184
265
|
onMouseMove: onFooterItemHover
|
|
185
266
|
}, /*#__PURE__*/React.createElement(RegisteredInsertMenuItem, {
|
|
186
267
|
editorView: editorView,
|
|
@@ -195,11 +276,14 @@ export var RegisteredInsertMenuList = function RegisteredInsertMenuList(_ref) {
|
|
|
195
276
|
if (!model.root) {
|
|
196
277
|
return null;
|
|
197
278
|
}
|
|
198
|
-
return /*#__PURE__*/React.createElement(Root, null, /*#__PURE__*/React.createElement(
|
|
279
|
+
return /*#__PURE__*/React.createElement(Root, null, /*#__PURE__*/React.createElement(RegisteredInsertMenuPreviewContext.Provider, {
|
|
280
|
+
value: activePreviewItemKey
|
|
281
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
199
282
|
xcss: styles.content,
|
|
200
283
|
style: contentStyle
|
|
201
284
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
202
|
-
xcss: styles.scrollable
|
|
285
|
+
xcss: styles.scrollable,
|
|
286
|
+
onScroll: onScrollableContentScroll
|
|
203
287
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
204
288
|
"aria-label": listLabel,
|
|
205
289
|
"aria-owns": model.footer ? footerItemId : undefined,
|
|
@@ -221,9 +305,11 @@ export var RegisteredInsertMenuList = function RegisteredInsertMenuList(_ref) {
|
|
|
221
305
|
scrollToAlignment: "auto",
|
|
222
306
|
scrollToIndex: selectedRowIndex,
|
|
223
307
|
width: LIST_WIDTH
|
|
224
|
-
}))),
|
|
225
|
-
mode:
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
308
|
+
}))), hasNoSearchResults && /*#__PURE__*/React.createElement(QuickInsertEmptyState, {
|
|
309
|
+
mode: "inline",
|
|
310
|
+
spacing: "compact"
|
|
311
|
+
}), externalControls && /*#__PURE__*/React.createElement(Box, {
|
|
312
|
+
testId: "registered-insert-menu-external-controls",
|
|
313
|
+
xcss: styles.externalControls
|
|
314
|
+
}, externalControls)), footer)));
|
|
229
315
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics/api';
|
|
2
3
|
import type { RegisteredItemRankResolver } from '@atlaskit/editor-common/type-ahead/item-rank';
|
|
3
4
|
import type { EmptyStateHandler } from '@atlaskit/editor-common/types';
|
|
4
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -7,11 +8,12 @@ type Props = {
|
|
|
7
8
|
components: RegisterComponent[];
|
|
8
9
|
editorView: EditorView;
|
|
9
10
|
emptyStateHandler?: EmptyStateHandler;
|
|
11
|
+
fireAnalyticsEvent?: EditorAnalyticsAPI['fireAnalyticsEvent'];
|
|
10
12
|
getItemRank?: RegisteredItemRankResolver;
|
|
11
13
|
isOffline: boolean;
|
|
12
14
|
maxHeight?: number;
|
|
13
15
|
onClose: () => void;
|
|
14
16
|
onSelect: () => void;
|
|
15
17
|
};
|
|
16
|
-
export declare const RegisteredInsertMenu: ({ components, emptyStateHandler, getItemRank, editorView, isOffline, maxHeight, onClose, onSelect, }: Props) => React.JSX.Element;
|
|
18
|
+
export declare const RegisteredInsertMenu: ({ components, emptyStateHandler, fireAnalyticsEvent, getItemRank, editorView, isOffline, maxHeight, onClose, onSelect, }: Props) => React.JSX.Element;
|
|
17
19
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
import type { SurfaceContext, RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
|
|
4
|
+
export declare const RegisteredInsertMenuPreviewContext: React.Context<string | undefined>;
|
|
4
5
|
type Props = {
|
|
5
6
|
editorView: EditorView;
|
|
6
7
|
id: string;
|
|
@@ -4,6 +4,7 @@ import type { EmptyStateHandler } from '@atlaskit/editor-common/types';
|
|
|
4
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
6
6
|
type Props = {
|
|
7
|
+
activePreviewItemKey?: string;
|
|
7
8
|
editorView: EditorView;
|
|
8
9
|
emptyStateHandler?: EmptyStateHandler;
|
|
9
10
|
isOffline: boolean;
|
|
@@ -13,7 +14,11 @@ type Props = {
|
|
|
13
14
|
menuOpenId: symbol;
|
|
14
15
|
model: QuickInsertMenuModel;
|
|
15
16
|
onClose: () => void;
|
|
16
|
-
|
|
17
|
+
onItemBlur: (itemKey: string) => void;
|
|
18
|
+
onItemFocus: (index: number, itemKey?: string) => void;
|
|
19
|
+
onItemHover: (index: number, itemKey?: string) => void;
|
|
20
|
+
onItemLeave: (itemKey: string) => void;
|
|
21
|
+
onItemVisibilityChange: (itemKey: string, isVisible: boolean) => void;
|
|
17
22
|
onRenderedItemsChange: (range: {
|
|
18
23
|
startIndex: number;
|
|
19
24
|
stopIndex: number;
|
|
@@ -22,5 +27,5 @@ type Props = {
|
|
|
22
27
|
selectedItemIndex: number;
|
|
23
28
|
surfaceContext: SurfaceContext;
|
|
24
29
|
};
|
|
25
|
-
export declare const RegisteredInsertMenuList: ({ editorView, emptyStateHandler, isOffline, listId, listLabel, maxHeight, menuOpenId, model, onClose, query, onItemHover, onRenderedItemsChange, selectedItemIndex, surfaceContext, }: Props) => React.JSX.Element | null;
|
|
30
|
+
export declare const RegisteredInsertMenuList: ({ editorView, emptyStateHandler, isOffline, listId, listLabel, maxHeight, menuOpenId, model, onClose, onItemFocus, onItemBlur, query, onItemHover, onItemLeave, onItemVisibilityChange, onRenderedItemsChange, selectedItemIndex, surfaceContext, activePreviewItemKey, }: Props) => React.JSX.Element | null;
|
|
26
31
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-insert-block",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "29.0.0",
|
|
4
4
|
"description": "Insert block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,44 +23,44 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@atlaskit/browser-apis": "^1.2.0",
|
|
25
25
|
"@atlaskit/css": "^1.1.0",
|
|
26
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
27
|
-
"@atlaskit/editor-plugin-block-type": "^
|
|
28
|
-
"@atlaskit/editor-plugin-code-block": "^
|
|
29
|
-
"@atlaskit/editor-plugin-connectivity": "^
|
|
30
|
-
"@atlaskit/editor-plugin-date": "^
|
|
31
|
-
"@atlaskit/editor-plugin-emoji": "^
|
|
32
|
-
"@atlaskit/editor-plugin-expand": "^
|
|
33
|
-
"@atlaskit/editor-plugin-extension": "^
|
|
34
|
-
"@atlaskit/editor-plugin-feature-flags": "^
|
|
35
|
-
"@atlaskit/editor-plugin-hyperlink": "^
|
|
36
|
-
"@atlaskit/editor-plugin-image-upload": "^
|
|
37
|
-
"@atlaskit/editor-plugin-layout": "^
|
|
38
|
-
"@atlaskit/editor-plugin-media": "^
|
|
39
|
-
"@atlaskit/editor-plugin-media-insert": "^
|
|
40
|
-
"@atlaskit/editor-plugin-mentions": "^
|
|
41
|
-
"@atlaskit/editor-plugin-metrics": "^
|
|
42
|
-
"@atlaskit/editor-plugin-panel": "^
|
|
43
|
-
"@atlaskit/editor-plugin-placeholder-text": "^
|
|
44
|
-
"@atlaskit/editor-plugin-primary-toolbar": "^
|
|
45
|
-
"@atlaskit/editor-plugin-quick-insert": "^
|
|
46
|
-
"@atlaskit/editor-plugin-rule": "^
|
|
47
|
-
"@atlaskit/editor-plugin-status": "^
|
|
48
|
-
"@atlaskit/editor-plugin-table": "^
|
|
49
|
-
"@atlaskit/editor-plugin-tasks-and-decisions": "^
|
|
50
|
-
"@atlaskit/editor-plugin-toolbar": "^
|
|
51
|
-
"@atlaskit/editor-plugin-type-ahead": "^
|
|
52
|
-
"@atlaskit/editor-plugin-ui-control-registry": "^
|
|
26
|
+
"@atlaskit/editor-plugin-analytics": "^28.0.0",
|
|
27
|
+
"@atlaskit/editor-plugin-block-type": "^32.0.0",
|
|
28
|
+
"@atlaskit/editor-plugin-code-block": "^30.0.0",
|
|
29
|
+
"@atlaskit/editor-plugin-connectivity": "^28.0.0",
|
|
30
|
+
"@atlaskit/editor-plugin-date": "^30.0.0",
|
|
31
|
+
"@atlaskit/editor-plugin-emoji": "^29.0.0",
|
|
32
|
+
"@atlaskit/editor-plugin-expand": "^29.0.0",
|
|
33
|
+
"@atlaskit/editor-plugin-extension": "^31.0.0",
|
|
34
|
+
"@atlaskit/editor-plugin-feature-flags": "^27.0.0",
|
|
35
|
+
"@atlaskit/editor-plugin-hyperlink": "^30.0.0",
|
|
36
|
+
"@atlaskit/editor-plugin-image-upload": "^28.0.0",
|
|
37
|
+
"@atlaskit/editor-plugin-layout": "^29.0.0",
|
|
38
|
+
"@atlaskit/editor-plugin-media": "^30.0.0",
|
|
39
|
+
"@atlaskit/editor-plugin-media-insert": "^46.0.0",
|
|
40
|
+
"@atlaskit/editor-plugin-mentions": "^30.0.0",
|
|
41
|
+
"@atlaskit/editor-plugin-metrics": "^29.0.0",
|
|
42
|
+
"@atlaskit/editor-plugin-panel": "^30.0.0",
|
|
43
|
+
"@atlaskit/editor-plugin-placeholder-text": "^29.0.0",
|
|
44
|
+
"@atlaskit/editor-plugin-primary-toolbar": "^29.0.0",
|
|
45
|
+
"@atlaskit/editor-plugin-quick-insert": "^28.0.0",
|
|
46
|
+
"@atlaskit/editor-plugin-rule": "^28.0.0",
|
|
47
|
+
"@atlaskit/editor-plugin-status": "^29.0.0",
|
|
48
|
+
"@atlaskit/editor-plugin-table": "^40.0.0",
|
|
49
|
+
"@atlaskit/editor-plugin-tasks-and-decisions": "^31.0.0",
|
|
50
|
+
"@atlaskit/editor-plugin-toolbar": "^25.0.0",
|
|
51
|
+
"@atlaskit/editor-plugin-type-ahead": "^29.0.0",
|
|
52
|
+
"@atlaskit/editor-plugin-ui-control-registry": "^22.0.0",
|
|
53
53
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
54
|
-
"@atlaskit/editor-shared-styles": "^4.
|
|
54
|
+
"@atlaskit/editor-shared-styles": "^4.5.0",
|
|
55
55
|
"@atlaskit/editor-toolbar": "^2.8.0",
|
|
56
56
|
"@atlaskit/editor-toolbar-model": "^1.2.0",
|
|
57
57
|
"@atlaskit/editor-ui-control-model": "^2.10.0",
|
|
58
|
-
"@atlaskit/emoji": "^
|
|
58
|
+
"@atlaskit/emoji": "^73.0.0",
|
|
59
59
|
"@atlaskit/icon": "^38.0.0",
|
|
60
60
|
"@atlaskit/icon-lab": "^7.11.0",
|
|
61
61
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
62
62
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
63
|
-
"@atlaskit/primitives": "^22.
|
|
63
|
+
"@atlaskit/primitives": "^22.6.0",
|
|
64
64
|
"@atlaskit/textfield": "^10.2.0",
|
|
65
65
|
"@atlaskit/tmp-editor-statsig": "^240.0.0",
|
|
66
66
|
"@atlaskit/tokens": "^20.6.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"react-virtualized": "^9.22.6"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"@atlaskit/editor-common": "^
|
|
75
|
+
"@atlaskit/editor-common": "^132.0.0",
|
|
76
76
|
"react": "^18.2.0 || ^19.2.0",
|
|
77
77
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
78
78
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|