@atlaskit/editor-plugin-type-ahead 22.1.0 → 22.1.1
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 +9 -0
- package/dist/cjs/ui/ListRow.js +4 -2
- package/dist/cjs/ui/registered-menu/RegisteredTypeAheadMenu.compiled.css +3 -2
- package/dist/cjs/ui/registered-menu/RegisteredTypeAheadMenu.js +12 -4
- package/dist/cjs/ui/registered-menu/TypeAheadMenuRenderer.js +9 -2
- package/dist/cjs/ui/registered-menu/createTypeAheadRowRenderer.js +2 -0
- package/dist/es2019/ui/ListRow.js +6 -2
- package/dist/es2019/ui/registered-menu/RegisteredTypeAheadMenu.compiled.css +3 -2
- package/dist/es2019/ui/registered-menu/RegisteredTypeAheadMenu.js +12 -4
- package/dist/es2019/ui/registered-menu/TypeAheadMenuRenderer.js +10 -2
- package/dist/es2019/ui/registered-menu/createTypeAheadRowRenderer.js +2 -0
- package/dist/esm/ui/ListRow.js +4 -2
- package/dist/esm/ui/registered-menu/RegisteredTypeAheadMenu.compiled.css +3 -2
- package/dist/esm/ui/registered-menu/RegisteredTypeAheadMenu.js +12 -4
- package/dist/esm/ui/registered-menu/TypeAheadMenuRenderer.js +9 -2
- package/dist/esm/ui/registered-menu/createTypeAheadRowRenderer.js +2 -0
- package/dist/types/ui/ListRow.d.ts +1 -0
- package/dist/types/ui/registered-menu/createTypeAheadRowRenderer.d.ts +2 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-type-ahead
|
|
2
2
|
|
|
3
|
+
## 22.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7306003a7565b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7306003a7565b) -
|
|
8
|
+
Fix modal dismissal, category spacing, measured list height, and viewport-aware menu placement
|
|
9
|
+
under platform_editor_slash_command.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 22.1.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/dist/cjs/ui/ListRow.js
CHANGED
|
@@ -24,6 +24,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
24
24
|
var ListRow = exports.ListRow = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
25
25
|
var children = _ref.children,
|
|
26
26
|
measure = _ref.measure,
|
|
27
|
+
onMeasured = _ref.onMeasured,
|
|
27
28
|
index = _ref.index,
|
|
28
29
|
style = _ref.style,
|
|
29
30
|
isVisible = _ref.isVisible,
|
|
@@ -36,13 +37,14 @@ var ListRow = exports.ListRow = /*#__PURE__*/(0, _react.forwardRef)(function (_r
|
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
var observer = new ResizeObserver(function () {
|
|
39
|
-
|
|
40
|
+
measure();
|
|
41
|
+
onMeasured === null || onMeasured === void 0 || onMeasured();
|
|
40
42
|
});
|
|
41
43
|
observer.observe(childElementRef.current);
|
|
42
44
|
return function () {
|
|
43
45
|
return observer.disconnect();
|
|
44
46
|
};
|
|
45
|
-
}, [isScrolling, isVisible, measure]);
|
|
47
|
+
}, [isScrolling, isVisible, measure, onMeasured]);
|
|
46
48
|
return (
|
|
47
49
|
/*#__PURE__*/
|
|
48
50
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
.
|
|
2
|
-
._1rjc1b66{padding-block:var(--ds-space-050,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
1
|
+
._2rko1mok{border-radius:var(--ds-radius-large,8px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
3
2
|
._18m915vq{overflow-y:hidden}
|
|
4
3
|
._1bsbnklw{width:20pc}
|
|
4
|
+
._1q51u2gc{padding-block-start:var(--ds-space-100,8px)}
|
|
5
5
|
._1reo15vq{overflow-x:hidden}
|
|
6
|
+
._85i512x7{padding-block-end:var(--ds-space-075,6px)}
|
|
6
7
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
7
8
|
._vchhusvi{box-sizing:border-box}
|
|
@@ -14,6 +14,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
var _reactIntl = require("react-intl");
|
|
16
16
|
var _registeredMenuModel = require("@atlaskit/editor-common/quick-insert/registered-menu-model");
|
|
17
|
+
var _useMenuPopupSizing = require("@atlaskit/editor-common/quick-insert/use-menu-popup-sizing");
|
|
17
18
|
var _typeAheadIsSectionOverflowItemKey = require("@atlaskit/editor-common/type-ahead-is-section-overflow-item-key");
|
|
18
19
|
var _typeAheadSurfaceContext = require("@atlaskit/editor-common/type-ahead-surface-context");
|
|
19
20
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
@@ -28,10 +29,10 @@ var _TypeAheadMenuRenderer = require("./TypeAheadMenuRenderer");
|
|
|
28
29
|
var _TypeAheadProvider = require("./TypeAheadProvider");
|
|
29
30
|
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); }
|
|
30
31
|
var styles = {
|
|
31
|
-
menu: "
|
|
32
|
+
menu: "_2rko1mok _1reo15vq _18m915vq _bfhk1bhr _vchhusvi _16qs130s _1q51u2gc _85i512x7 _1bsbnklw"
|
|
32
33
|
};
|
|
33
34
|
var DEFAULT_MENU_MAX_HEIGHT = 480;
|
|
34
|
-
var MENU_VERTICAL_PADDING =
|
|
35
|
+
var MENU_VERTICAL_PADDING = 14;
|
|
35
36
|
var MENU_WIDTH = 320;
|
|
36
37
|
var POPUP_OFFSET = [0, 8];
|
|
37
38
|
var EMPTY_COMPONENTS = [];
|
|
@@ -57,6 +58,13 @@ var RegisteredTypeAheadMenu = exports.RegisteredTypeAheadMenu = function Registe
|
|
|
57
58
|
setQuery = _ref.setQuery,
|
|
58
59
|
surface = _ref.surface,
|
|
59
60
|
triggerHandler = _ref.triggerHandler;
|
|
61
|
+
var menuHeight = (0, _useMenuPopupSizing.useMenuPopupSizing)({
|
|
62
|
+
target: anchorElement,
|
|
63
|
+
boundariesElement: popupsBoundariesElement,
|
|
64
|
+
scrollableElement: popupsScrollableElement,
|
|
65
|
+
maxHeight: maxHeight,
|
|
66
|
+
offset: POPUP_OFFSET[1]
|
|
67
|
+
});
|
|
60
68
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
61
69
|
formatMessage = _useIntl.formatMessage;
|
|
62
70
|
var generatedId = (0, _react.useId)();
|
|
@@ -172,7 +180,7 @@ var RegisteredTypeAheadMenu = exports.RegisteredTypeAheadMenu = function Registe
|
|
|
172
180
|
}), /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
173
181
|
ariaLabel: null,
|
|
174
182
|
boundariesElement: popupsBoundariesElement,
|
|
175
|
-
fitHeight:
|
|
183
|
+
fitHeight: menuHeight,
|
|
176
184
|
fitWidth: MENU_WIDTH,
|
|
177
185
|
mountTo: popupsMountPoint,
|
|
178
186
|
offset: POPUP_OFFSET,
|
|
@@ -191,7 +199,7 @@ var RegisteredTypeAheadMenu = exports.RegisteredTypeAheadMenu = function Registe
|
|
|
191
199
|
Item: surface.Item,
|
|
192
200
|
listLabel: surface.listLabel,
|
|
193
201
|
listId: listId,
|
|
194
|
-
maxHeight: Math.max(0,
|
|
202
|
+
maxHeight: Math.max(0, menuHeight - MENU_VERTICAL_PADDING),
|
|
195
203
|
model: menuModel,
|
|
196
204
|
onItemHover: setSelectedItemIndex,
|
|
197
205
|
selectedItemIndex: selectedItemIndex
|
|
@@ -12,6 +12,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _reactIntl = require("react-intl");
|
|
13
13
|
var _CellMeasurer = require("react-virtualized/dist/commonjs/CellMeasurer");
|
|
14
14
|
var _List = require("react-virtualized/dist/commonjs/List");
|
|
15
|
+
var _useMenuListHeight2 = require("@atlaskit/editor-common/quick-insert/use-menu-list-height");
|
|
15
16
|
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
16
17
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
17
18
|
var _createTypeAheadRowRenderer = require("./createTypeAheadRowRenderer");
|
|
@@ -24,7 +25,8 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
24
25
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
25
26
|
var LIST_WIDTH = 320;
|
|
26
27
|
var ESTIMATED_ROW_HEIGHT = 56;
|
|
27
|
-
|
|
28
|
+
// 40px item + 8px block padding + 1px separator.
|
|
29
|
+
var MENU_FOOTER_HEIGHT = 49;
|
|
28
30
|
var TypeAheadMenuRenderer = exports.TypeAheadMenuRenderer = function TypeAheadMenuRenderer(_ref) {
|
|
29
31
|
var _model$root$component;
|
|
30
32
|
var Item = _ref.Item,
|
|
@@ -82,6 +84,9 @@ var TypeAheadMenuRenderer = exports.TypeAheadMenuRenderer = function TypeAheadMe
|
|
|
82
84
|
return "".concat(type, ":").concat(key);
|
|
83
85
|
}).join('\0');
|
|
84
86
|
}, [rows]);
|
|
87
|
+
var _useMenuListHeight = (0, _useMenuListHeight2.useMenuListHeight)(cache, rows.length, rowKeySignature),
|
|
88
|
+
measuredHeight = _useMenuListHeight.height,
|
|
89
|
+
updateHeight = _useMenuListHeight.updateHeight;
|
|
85
90
|
(0, _react.useLayoutEffect)(function () {
|
|
86
91
|
var _listRef$current, _listRef$current2;
|
|
87
92
|
cache.clearAll();
|
|
@@ -96,6 +101,7 @@ var TypeAheadMenuRenderer = exports.TypeAheadMenuRenderer = function TypeAheadMe
|
|
|
96
101
|
}, [selectedRowIndex]);
|
|
97
102
|
var renderRow = (0, _createTypeAheadRowRenderer.createTypeAheadRowRenderer)({
|
|
98
103
|
cache: cache,
|
|
104
|
+
onMeasured: updateHeight,
|
|
99
105
|
itemIndexByRowIndex: itemIndexByRowIndex,
|
|
100
106
|
Item: Item,
|
|
101
107
|
listId: listId,
|
|
@@ -119,7 +125,8 @@ var TypeAheadMenuRenderer = exports.TypeAheadMenuRenderer = function TypeAheadMe
|
|
|
119
125
|
role: hasListboxContent ? 'listbox' : undefined
|
|
120
126
|
}, rows.length > 0 ? /*#__PURE__*/_react.default.createElement(_List.List, {
|
|
121
127
|
containerRole: "presentation",
|
|
122
|
-
height: Math.min(
|
|
128
|
+
height: Math.min(measuredHeight, listMaxHeight),
|
|
129
|
+
onRowsRendered: updateHeight,
|
|
123
130
|
overscanRowCount: 3,
|
|
124
131
|
ref: listRef,
|
|
125
132
|
role: "presentation",
|
|
@@ -13,6 +13,7 @@ var _TypeAheadSectionRow = require("./TypeAheadSectionRow");
|
|
|
13
13
|
var noOp = function noOp() {};
|
|
14
14
|
var createTypeAheadRowRenderer = exports.createTypeAheadRowRenderer = function createTypeAheadRowRenderer(_ref) {
|
|
15
15
|
var cache = _ref.cache,
|
|
16
|
+
onMeasured = _ref.onMeasured,
|
|
16
17
|
itemIndexByRowIndex = _ref.itemIndexByRowIndex,
|
|
17
18
|
Item = _ref.Item,
|
|
18
19
|
listId = _ref.listId,
|
|
@@ -44,6 +45,7 @@ var createTypeAheadRowRenderer = exports.createTypeAheadRowRenderer = function c
|
|
|
44
45
|
isScrolling: isScrolling,
|
|
45
46
|
isVisible: isVisible,
|
|
46
47
|
measure: measure,
|
|
48
|
+
onMeasured: onMeasured,
|
|
47
49
|
onMouseMove: noOp,
|
|
48
50
|
style: style
|
|
49
51
|
}, registration.type === 'menu-section' ? /*#__PURE__*/_react.default.createElement(_TypeAheadSectionRow.TypeAheadSectionRow, {
|
|
@@ -16,6 +16,7 @@ import React, { useEffect, useRef, forwardRef } from 'react';
|
|
|
16
16
|
export const ListRow = /*#__PURE__*/forwardRef(({
|
|
17
17
|
children,
|
|
18
18
|
measure,
|
|
19
|
+
onMeasured,
|
|
19
20
|
index,
|
|
20
21
|
style,
|
|
21
22
|
isVisible,
|
|
@@ -28,10 +29,13 @@ export const ListRow = /*#__PURE__*/forwardRef(({
|
|
|
28
29
|
if (!childElementRef.current || !isVisible || isScrolling) {
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
|
-
const observer = new ResizeObserver(() =>
|
|
32
|
+
const observer = new ResizeObserver(() => {
|
|
33
|
+
measure();
|
|
34
|
+
onMeasured === null || onMeasured === void 0 ? void 0 : onMeasured();
|
|
35
|
+
});
|
|
32
36
|
observer.observe(childElementRef.current);
|
|
33
37
|
return () => observer.disconnect();
|
|
34
|
-
}, [isScrolling, isVisible, measure]);
|
|
38
|
+
}, [isScrolling, isVisible, measure, onMeasured]);
|
|
35
39
|
return (
|
|
36
40
|
/*#__PURE__*/
|
|
37
41
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
.
|
|
2
|
-
._1rjc1b66{padding-block:var(--ds-space-050,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
1
|
+
._2rko1mok{border-radius:var(--ds-radius-large,8px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
3
2
|
._18m915vq{overflow-y:hidden}
|
|
4
3
|
._1bsbnklw{width:20pc}
|
|
4
|
+
._1q51u2gc{padding-block-start:var(--ds-space-100,8px)}
|
|
5
5
|
._1reo15vq{overflow-x:hidden}
|
|
6
|
+
._85i512x7{padding-block-end:var(--ds-space-075,6px)}
|
|
6
7
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
7
8
|
._vchhusvi{box-sizing:border-box}
|
|
@@ -4,6 +4,7 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
4
4
|
import React, { useCallback, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
5
5
|
import { useIntl } from 'react-intl';
|
|
6
6
|
import { buildQuickInsertMenuModel, getMatchingQuickInsertComponents, selectQuickInsertCategoryItems } from '@atlaskit/editor-common/quick-insert/registered-menu-model';
|
|
7
|
+
import { useMenuPopupSizing } from '@atlaskit/editor-common/quick-insert/use-menu-popup-sizing';
|
|
7
8
|
import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
|
|
8
9
|
import { TYPE_AHEAD_SURFACE_CONTEXT } from '@atlaskit/editor-common/type-ahead-surface-context';
|
|
9
10
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
@@ -17,10 +18,10 @@ import { getTypeAheadItemId } from './getTypeAheadItemId';
|
|
|
17
18
|
import { TypeAheadMenuRenderer } from './TypeAheadMenuRenderer';
|
|
18
19
|
import { TypeAheadProvider } from './TypeAheadProvider';
|
|
19
20
|
const styles = {
|
|
20
|
-
menu: "
|
|
21
|
+
menu: "_2rko1mok _1reo15vq _18m915vq _bfhk1bhr _vchhusvi _16qs130s _1q51u2gc _85i512x7 _1bsbnklw"
|
|
21
22
|
};
|
|
22
23
|
const DEFAULT_MENU_MAX_HEIGHT = 480;
|
|
23
|
-
const MENU_VERTICAL_PADDING =
|
|
24
|
+
const MENU_VERTICAL_PADDING = 14;
|
|
24
25
|
const MENU_WIDTH = 320;
|
|
25
26
|
const POPUP_OFFSET = [0, 8];
|
|
26
27
|
const EMPTY_COMPONENTS = [];
|
|
@@ -44,6 +45,13 @@ export const RegisteredTypeAheadMenu = ({
|
|
|
44
45
|
triggerHandler
|
|
45
46
|
}) => {
|
|
46
47
|
var _api$uiControlRegistr2, _api$uiControlRegistr3;
|
|
48
|
+
const menuHeight = useMenuPopupSizing({
|
|
49
|
+
target: anchorElement,
|
|
50
|
+
boundariesElement: popupsBoundariesElement,
|
|
51
|
+
scrollableElement: popupsScrollableElement,
|
|
52
|
+
maxHeight,
|
|
53
|
+
offset: POPUP_OFFSET[1]
|
|
54
|
+
});
|
|
47
55
|
const {
|
|
48
56
|
formatMessage
|
|
49
57
|
} = useIntl();
|
|
@@ -140,7 +148,7 @@ export const RegisteredTypeAheadMenu = ({
|
|
|
140
148
|
}), /*#__PURE__*/React.createElement(Popup, {
|
|
141
149
|
ariaLabel: null,
|
|
142
150
|
boundariesElement: popupsBoundariesElement,
|
|
143
|
-
fitHeight:
|
|
151
|
+
fitHeight: menuHeight,
|
|
144
152
|
fitWidth: MENU_WIDTH,
|
|
145
153
|
mountTo: popupsMountPoint,
|
|
146
154
|
offset: POPUP_OFFSET,
|
|
@@ -159,7 +167,7 @@ export const RegisteredTypeAheadMenu = ({
|
|
|
159
167
|
Item: surface.Item,
|
|
160
168
|
listLabel: surface.listLabel,
|
|
161
169
|
listId: listId,
|
|
162
|
-
maxHeight: Math.max(0,
|
|
170
|
+
maxHeight: Math.max(0, menuHeight - MENU_VERTICAL_PADDING),
|
|
163
171
|
model: menuModel,
|
|
164
172
|
onItemHover: setSelectedItemIndex,
|
|
165
173
|
selectedItemIndex: selectedItemIndex
|
|
@@ -2,6 +2,7 @@ import React, { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
|
|
4
4
|
import { List } from 'react-virtualized/dist/commonjs/List';
|
|
5
|
+
import { useMenuListHeight } from '@atlaskit/editor-common/quick-insert/use-menu-list-height';
|
|
5
6
|
import { typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
6
7
|
import { Box, Text } from '@atlaskit/primitives/compiled';
|
|
7
8
|
import { createTypeAheadRowRenderer } from './createTypeAheadRowRenderer';
|
|
@@ -10,7 +11,8 @@ import { PassThrough } from './PassThrough';
|
|
|
10
11
|
import { TypeAheadMenuFooter } from './TypeAheadMenuFooter';
|
|
11
12
|
const LIST_WIDTH = 320;
|
|
12
13
|
const ESTIMATED_ROW_HEIGHT = 56;
|
|
13
|
-
|
|
14
|
+
// 40px item + 8px block padding + 1px separator.
|
|
15
|
+
const MENU_FOOTER_HEIGHT = 49;
|
|
14
16
|
export const TypeAheadMenuRenderer = ({
|
|
15
17
|
Item,
|
|
16
18
|
listLabel,
|
|
@@ -53,6 +55,10 @@ export const TypeAheadMenuRenderer = ({
|
|
|
53
55
|
key,
|
|
54
56
|
type
|
|
55
57
|
}) => `${type}:${key}`).join('\0'), [rows]);
|
|
58
|
+
const {
|
|
59
|
+
height: measuredHeight,
|
|
60
|
+
updateHeight
|
|
61
|
+
} = useMenuListHeight(cache, rows.length, rowKeySignature);
|
|
56
62
|
useLayoutEffect(() => {
|
|
57
63
|
var _listRef$current, _listRef$current2;
|
|
58
64
|
cache.clearAll();
|
|
@@ -67,6 +73,7 @@ export const TypeAheadMenuRenderer = ({
|
|
|
67
73
|
}, [selectedRowIndex]);
|
|
68
74
|
const renderRow = createTypeAheadRowRenderer({
|
|
69
75
|
cache,
|
|
76
|
+
onMeasured: updateHeight,
|
|
70
77
|
itemIndexByRowIndex,
|
|
71
78
|
Item,
|
|
72
79
|
listId,
|
|
@@ -88,7 +95,8 @@ export const TypeAheadMenuRenderer = ({
|
|
|
88
95
|
role: hasListboxContent ? 'listbox' : undefined
|
|
89
96
|
}, rows.length > 0 ? /*#__PURE__*/React.createElement(List, {
|
|
90
97
|
containerRole: "presentation",
|
|
91
|
-
height: Math.min(
|
|
98
|
+
height: Math.min(measuredHeight, listMaxHeight),
|
|
99
|
+
onRowsRendered: updateHeight,
|
|
92
100
|
overscanRowCount: 3,
|
|
93
101
|
ref: listRef,
|
|
94
102
|
role: "presentation",
|
|
@@ -6,6 +6,7 @@ import { TypeAheadSectionRow } from './TypeAheadSectionRow';
|
|
|
6
6
|
const noOp = () => {};
|
|
7
7
|
export const createTypeAheadRowRenderer = ({
|
|
8
8
|
cache,
|
|
9
|
+
onMeasured,
|
|
9
10
|
itemIndexByRowIndex,
|
|
10
11
|
Item,
|
|
11
12
|
listId,
|
|
@@ -38,6 +39,7 @@ export const createTypeAheadRowRenderer = ({
|
|
|
38
39
|
isScrolling: isScrolling,
|
|
39
40
|
isVisible: isVisible,
|
|
40
41
|
measure: measure,
|
|
42
|
+
onMeasured: onMeasured,
|
|
41
43
|
onMouseMove: noOp,
|
|
42
44
|
style: style
|
|
43
45
|
}, registration.type === 'menu-section' ? /*#__PURE__*/React.createElement(TypeAheadSectionRow, {
|
package/dist/esm/ui/ListRow.js
CHANGED
|
@@ -16,6 +16,7 @@ import React, { useEffect, useRef, forwardRef } from 'react';
|
|
|
16
16
|
export var ListRow = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
17
17
|
var children = _ref.children,
|
|
18
18
|
measure = _ref.measure,
|
|
19
|
+
onMeasured = _ref.onMeasured,
|
|
19
20
|
index = _ref.index,
|
|
20
21
|
style = _ref.style,
|
|
21
22
|
isVisible = _ref.isVisible,
|
|
@@ -28,13 +29,14 @@ export var ListRow = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
var observer = new ResizeObserver(function () {
|
|
31
|
-
|
|
32
|
+
measure();
|
|
33
|
+
onMeasured === null || onMeasured === void 0 || onMeasured();
|
|
32
34
|
});
|
|
33
35
|
observer.observe(childElementRef.current);
|
|
34
36
|
return function () {
|
|
35
37
|
return observer.disconnect();
|
|
36
38
|
};
|
|
37
|
-
}, [isScrolling, isVisible, measure]);
|
|
39
|
+
}, [isScrolling, isVisible, measure, onMeasured]);
|
|
38
40
|
return (
|
|
39
41
|
/*#__PURE__*/
|
|
40
42
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
.
|
|
2
|
-
._1rjc1b66{padding-block:var(--ds-space-050,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
1
|
+
._2rko1mok{border-radius:var(--ds-radius-large,8px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
3
2
|
._18m915vq{overflow-y:hidden}
|
|
4
3
|
._1bsbnklw{width:20pc}
|
|
4
|
+
._1q51u2gc{padding-block-start:var(--ds-space-100,8px)}
|
|
5
5
|
._1reo15vq{overflow-x:hidden}
|
|
6
|
+
._85i512x7{padding-block-end:var(--ds-space-075,6px)}
|
|
6
7
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
7
8
|
._vchhusvi{box-sizing:border-box}
|
|
@@ -6,6 +6,7 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
6
6
|
import React, { useCallback, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
7
7
|
import { useIntl } from 'react-intl';
|
|
8
8
|
import { buildQuickInsertMenuModel, getMatchingQuickInsertComponents, selectQuickInsertCategoryItems } from '@atlaskit/editor-common/quick-insert/registered-menu-model';
|
|
9
|
+
import { useMenuPopupSizing } from '@atlaskit/editor-common/quick-insert/use-menu-popup-sizing';
|
|
9
10
|
import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
|
|
10
11
|
import { TYPE_AHEAD_SURFACE_CONTEXT } from '@atlaskit/editor-common/type-ahead-surface-context';
|
|
11
12
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
@@ -19,10 +20,10 @@ import { getTypeAheadItemId } from './getTypeAheadItemId';
|
|
|
19
20
|
import { TypeAheadMenuRenderer } from './TypeAheadMenuRenderer';
|
|
20
21
|
import { TypeAheadProvider } from './TypeAheadProvider';
|
|
21
22
|
var styles = {
|
|
22
|
-
menu: "
|
|
23
|
+
menu: "_2rko1mok _1reo15vq _18m915vq _bfhk1bhr _vchhusvi _16qs130s _1q51u2gc _85i512x7 _1bsbnklw"
|
|
23
24
|
};
|
|
24
25
|
var DEFAULT_MENU_MAX_HEIGHT = 480;
|
|
25
|
-
var MENU_VERTICAL_PADDING =
|
|
26
|
+
var MENU_VERTICAL_PADDING = 14;
|
|
26
27
|
var MENU_WIDTH = 320;
|
|
27
28
|
var POPUP_OFFSET = [0, 8];
|
|
28
29
|
var EMPTY_COMPONENTS = [];
|
|
@@ -48,6 +49,13 @@ export var RegisteredTypeAheadMenu = function RegisteredTypeAheadMenu(_ref) {
|
|
|
48
49
|
setQuery = _ref.setQuery,
|
|
49
50
|
surface = _ref.surface,
|
|
50
51
|
triggerHandler = _ref.triggerHandler;
|
|
52
|
+
var menuHeight = useMenuPopupSizing({
|
|
53
|
+
target: anchorElement,
|
|
54
|
+
boundariesElement: popupsBoundariesElement,
|
|
55
|
+
scrollableElement: popupsScrollableElement,
|
|
56
|
+
maxHeight: maxHeight,
|
|
57
|
+
offset: POPUP_OFFSET[1]
|
|
58
|
+
});
|
|
51
59
|
var _useIntl = useIntl(),
|
|
52
60
|
formatMessage = _useIntl.formatMessage;
|
|
53
61
|
var generatedId = useId();
|
|
@@ -163,7 +171,7 @@ export var RegisteredTypeAheadMenu = function RegisteredTypeAheadMenu(_ref) {
|
|
|
163
171
|
}), /*#__PURE__*/React.createElement(Popup, {
|
|
164
172
|
ariaLabel: null,
|
|
165
173
|
boundariesElement: popupsBoundariesElement,
|
|
166
|
-
fitHeight:
|
|
174
|
+
fitHeight: menuHeight,
|
|
167
175
|
fitWidth: MENU_WIDTH,
|
|
168
176
|
mountTo: popupsMountPoint,
|
|
169
177
|
offset: POPUP_OFFSET,
|
|
@@ -182,7 +190,7 @@ export var RegisteredTypeAheadMenu = function RegisteredTypeAheadMenu(_ref) {
|
|
|
182
190
|
Item: surface.Item,
|
|
183
191
|
listLabel: surface.listLabel,
|
|
184
192
|
listId: listId,
|
|
185
|
-
maxHeight: Math.max(0,
|
|
193
|
+
maxHeight: Math.max(0, menuHeight - MENU_VERTICAL_PADDING),
|
|
186
194
|
model: menuModel,
|
|
187
195
|
onItemHover: setSelectedItemIndex,
|
|
188
196
|
selectedItemIndex: selectedItemIndex
|
|
@@ -7,6 +7,7 @@ import React, { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
|
|
|
7
7
|
import { useIntl } from 'react-intl';
|
|
8
8
|
import { CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
|
|
9
9
|
import { List } from 'react-virtualized/dist/commonjs/List';
|
|
10
|
+
import { useMenuListHeight } from '@atlaskit/editor-common/quick-insert/use-menu-list-height';
|
|
10
11
|
import { typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
11
12
|
import { Box, Text } from '@atlaskit/primitives/compiled';
|
|
12
13
|
import { createTypeAheadRowRenderer } from './createTypeAheadRowRenderer';
|
|
@@ -15,7 +16,8 @@ import { PassThrough } from './PassThrough';
|
|
|
15
16
|
import { TypeAheadMenuFooter } from './TypeAheadMenuFooter';
|
|
16
17
|
var LIST_WIDTH = 320;
|
|
17
18
|
var ESTIMATED_ROW_HEIGHT = 56;
|
|
18
|
-
|
|
19
|
+
// 40px item + 8px block padding + 1px separator.
|
|
20
|
+
var MENU_FOOTER_HEIGHT = 49;
|
|
19
21
|
export var TypeAheadMenuRenderer = function TypeAheadMenuRenderer(_ref) {
|
|
20
22
|
var _model$root$component;
|
|
21
23
|
var Item = _ref.Item,
|
|
@@ -73,6 +75,9 @@ export var TypeAheadMenuRenderer = function TypeAheadMenuRenderer(_ref) {
|
|
|
73
75
|
return "".concat(type, ":").concat(key);
|
|
74
76
|
}).join('\0');
|
|
75
77
|
}, [rows]);
|
|
78
|
+
var _useMenuListHeight = useMenuListHeight(cache, rows.length, rowKeySignature),
|
|
79
|
+
measuredHeight = _useMenuListHeight.height,
|
|
80
|
+
updateHeight = _useMenuListHeight.updateHeight;
|
|
76
81
|
useLayoutEffect(function () {
|
|
77
82
|
var _listRef$current, _listRef$current2;
|
|
78
83
|
cache.clearAll();
|
|
@@ -87,6 +92,7 @@ export var TypeAheadMenuRenderer = function TypeAheadMenuRenderer(_ref) {
|
|
|
87
92
|
}, [selectedRowIndex]);
|
|
88
93
|
var renderRow = createTypeAheadRowRenderer({
|
|
89
94
|
cache: cache,
|
|
95
|
+
onMeasured: updateHeight,
|
|
90
96
|
itemIndexByRowIndex: itemIndexByRowIndex,
|
|
91
97
|
Item: Item,
|
|
92
98
|
listId: listId,
|
|
@@ -110,7 +116,8 @@ export var TypeAheadMenuRenderer = function TypeAheadMenuRenderer(_ref) {
|
|
|
110
116
|
role: hasListboxContent ? 'listbox' : undefined
|
|
111
117
|
}, rows.length > 0 ? /*#__PURE__*/React.createElement(List, {
|
|
112
118
|
containerRole: "presentation",
|
|
113
|
-
height: Math.min(
|
|
119
|
+
height: Math.min(measuredHeight, listMaxHeight),
|
|
120
|
+
onRowsRendered: updateHeight,
|
|
114
121
|
overscanRowCount: 3,
|
|
115
122
|
ref: listRef,
|
|
116
123
|
role: "presentation",
|
|
@@ -6,6 +6,7 @@ import { TypeAheadSectionRow } from './TypeAheadSectionRow';
|
|
|
6
6
|
var noOp = function noOp() {};
|
|
7
7
|
export var createTypeAheadRowRenderer = function createTypeAheadRowRenderer(_ref) {
|
|
8
8
|
var cache = _ref.cache,
|
|
9
|
+
onMeasured = _ref.onMeasured,
|
|
9
10
|
itemIndexByRowIndex = _ref.itemIndexByRowIndex,
|
|
10
11
|
Item = _ref.Item,
|
|
11
12
|
listId = _ref.listId,
|
|
@@ -37,6 +38,7 @@ export var createTypeAheadRowRenderer = function createTypeAheadRowRenderer(_ref
|
|
|
37
38
|
isScrolling: isScrolling,
|
|
38
39
|
isVisible: isVisible,
|
|
39
40
|
measure: measure,
|
|
41
|
+
onMeasured: onMeasured,
|
|
40
42
|
onMouseMove: noOp,
|
|
41
43
|
style: style
|
|
42
44
|
}, registration.type === 'menu-section' ? /*#__PURE__*/React.createElement(TypeAheadSectionRow, {
|
|
@@ -17,5 +17,6 @@ import type { ListRowProps } from 'react-virtualized';
|
|
|
17
17
|
export declare const ListRow: React.ForwardRefExoticComponent<{
|
|
18
18
|
children: ReactNode;
|
|
19
19
|
measure: () => void;
|
|
20
|
+
onMeasured?: () => void;
|
|
20
21
|
onMouseMove: MouseEventHandler<HTMLDivElement>;
|
|
21
22
|
} & Pick<ListRowProps, 'index' | 'isScrolling' | 'isVisible' | 'style'> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -2,12 +2,13 @@ import type { CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeas
|
|
|
2
2
|
import type { ListRowRenderer } from 'react-virtualized/dist/commonjs/List';
|
|
3
3
|
import type { RegisterMenuItem, RegisterMenuSection } from '@atlaskit/editor-ui-control-model/types';
|
|
4
4
|
import type { TypeAheadItemComponent } from './typeAheadMenuTypes';
|
|
5
|
-
export declare const createTypeAheadRowRenderer: ({ cache, itemIndexByRowIndex, Item, listId, onItemHover, rows, selectedItemIndex, }: {
|
|
5
|
+
export declare const createTypeAheadRowRenderer: ({ cache, onMeasured, itemIndexByRowIndex, Item, listId, onItemHover, rows, selectedItemIndex, }: {
|
|
6
6
|
cache: CellMeasurerCache;
|
|
7
7
|
Item: TypeAheadItemComponent;
|
|
8
8
|
itemIndexByRowIndex: Map<number, number>;
|
|
9
9
|
listId: string;
|
|
10
10
|
onItemHover: (itemIndex: number) => void;
|
|
11
|
+
onMeasured: () => void;
|
|
11
12
|
rows: Array<RegisterMenuItem | RegisterMenuSection>;
|
|
12
13
|
selectedItemIndex: number;
|
|
13
14
|
}) => ListRowRenderer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-type-ahead",
|
|
3
|
-
"version": "22.1.
|
|
3
|
+
"version": "22.1.1",
|
|
4
4
|
"description": "Type-ahead plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@atlaskit/primitives": "^22.5.0",
|
|
43
43
|
"@atlaskit/prosemirror-history": "^1.2.0",
|
|
44
44
|
"@atlaskit/prosemirror-input-rules": "^4.1.0",
|
|
45
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
45
|
+
"@atlaskit/tmp-editor-statsig": "^209.0.0",
|
|
46
46
|
"@atlaskit/tokens": "^20.0.0",
|
|
47
47
|
"@atlaskit/visually-hidden": "^4.4.0",
|
|
48
48
|
"@babel/runtime": "^7.0.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"w3c-keyname": "^2.1.8"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@atlaskit/editor-common": "^125.
|
|
57
|
+
"@atlaskit/editor-common": "^125.4.0",
|
|
58
58
|
"react": "^18.2.0 || ^19.2.0",
|
|
59
59
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
60
60
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|