@atlaskit/editor-common 134.13.0 → 134.15.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 +25 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/quick-insert/QuickInsertPreviewContent.compiled.css +1 -0
- package/dist/cjs/quick-insert/QuickInsertPreviewContent.js +8 -5
- package/dist/cjs/quick-insert/messages.js +30 -0
- package/dist/cjs/registered-menu/PreviewItemIndexContext.js +12 -0
- package/dist/cjs/registered-menu/RegisteredMenuList.js +8 -12
- package/dist/cjs/registered-menu/RegisteredMenuListItemRow.js +11 -11
- package/dist/cjs/registered-menu/useRegisteredMenu.js +59 -39
- package/dist/cjs/registered-menu/useRegisteredMenuSelection.js +4 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/quick-insert/QuickInsertPreviewContent.compiled.css +1 -0
- package/dist/es2019/quick-insert/QuickInsertPreviewContent.js +8 -5
- package/dist/es2019/quick-insert/messages.js +30 -0
- package/dist/es2019/registered-menu/PreviewItemIndexContext.js +6 -0
- package/dist/es2019/registered-menu/RegisteredMenuList.js +7 -10
- package/dist/es2019/registered-menu/RegisteredMenuListItemRow.js +11 -11
- package/dist/es2019/registered-menu/useRegisteredMenu.js +51 -32
- package/dist/es2019/registered-menu/useRegisteredMenuSelection.js +2 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/quick-insert/QuickInsertPreviewContent.compiled.css +1 -0
- package/dist/esm/quick-insert/QuickInsertPreviewContent.js +8 -5
- package/dist/esm/quick-insert/messages.js +30 -0
- package/dist/esm/registered-menu/PreviewItemIndexContext.js +6 -0
- package/dist/esm/registered-menu/RegisteredMenuList.js +8 -12
- package/dist/esm/registered-menu/RegisteredMenuListItemRow.js +11 -11
- package/dist/esm/registered-menu/useRegisteredMenu.js +60 -39
- package/dist/esm/registered-menu/useRegisteredMenuSelection.js +4 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/quick-insert/messages.d.ts +1 -1
- package/dist/types/quick-insert/preview.d.ts +6 -0
- package/dist/types/registered-menu/PreviewItemIndexContext.d.ts +2 -0
- package/dist/types/registered-menu/RegisteredMenuList.d.ts +8 -7
- package/dist/types/registered-menu/RegisteredMenuListItemRow.d.ts +5 -5
- package/dist/types/registered-menu/useRegisteredMenu.d.ts +7 -6
- package/dist/types/registered-menu/useRegisteredMenuSelection.d.ts +2 -0
- package/package.json +2 -2
- package/dist/cjs/registered-menu/ActiveMenuItemKeyContext.js +0 -11
- package/dist/es2019/registered-menu/ActiveMenuItemKeyContext.js +0 -5
- package/dist/esm/registered-menu/ActiveMenuItemKeyContext.js +0 -5
- package/dist/types/registered-menu/ActiveMenuItemKeyContext.d.ts +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useLayoutEffect } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { PreviewItemIndexContext } from './PreviewItemIndexContext';
|
|
3
3
|
/**
|
|
4
4
|
* Connects a rendered item to the list's active state and interaction callbacks.
|
|
5
5
|
* The list may reuse this row while scrolling, so context keeps its active styling
|
|
@@ -20,27 +20,27 @@ export const RegisteredMenuListItemRow = ({
|
|
|
20
20
|
rowIndex,
|
|
21
21
|
selectedItemIndex
|
|
22
22
|
}) => {
|
|
23
|
-
const
|
|
23
|
+
const previewItemIndex = useContext(PreviewItemIndexContext);
|
|
24
24
|
useLayoutEffect(() => {
|
|
25
|
-
onItemVisibilityChange(
|
|
26
|
-
return () => onItemVisibilityChange(
|
|
27
|
-
}, [isVisible,
|
|
25
|
+
onItemVisibilityChange(itemIndex, isVisible);
|
|
26
|
+
return () => onItemVisibilityChange(itemIndex, false);
|
|
27
|
+
}, [isVisible, itemIndex, onItemVisibilityChange]);
|
|
28
28
|
const onBlur = useCallback(event => {
|
|
29
29
|
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
30
|
-
onItemBlur(
|
|
30
|
+
onItemBlur(itemIndex);
|
|
31
31
|
}
|
|
32
|
-
}, [
|
|
32
|
+
}, [itemIndex, onItemBlur]);
|
|
33
33
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
34
|
onBlur: onBlur,
|
|
35
|
-
onFocus: () => onItemFocus(itemIndex
|
|
36
|
-
onMouseLeave: () => onItemLeave(
|
|
37
|
-
onMouseMove: () => onItemHover(itemIndex
|
|
35
|
+
onFocus: () => onItemFocus(itemIndex),
|
|
36
|
+
onMouseLeave: () => onItemLeave(itemIndex),
|
|
37
|
+
onMouseMove: () => onItemHover(itemIndex)
|
|
38
38
|
}, /*#__PURE__*/React.createElement(Item, {
|
|
39
39
|
id: getItemId({
|
|
40
40
|
itemIndex,
|
|
41
41
|
rowIndex
|
|
42
42
|
}),
|
|
43
|
-
isActive:
|
|
43
|
+
isActive: previewItemIndex === itemIndex,
|
|
44
44
|
isSelected: itemIndex === selectedItemIndex,
|
|
45
45
|
registration: registration
|
|
46
46
|
}));
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { getComponentIdentity } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
3
3
|
import { useRegisteredMenuSelection } from './useRegisteredMenuSelection';
|
|
4
|
+
|
|
5
|
+
/** An open preview always belongs to the selected item, so only whether it's open is stored. */
|
|
6
|
+
|
|
4
7
|
const getSelectableItemIdentity = (item, scope) => JSON.stringify([scope.type, scope.type === 'section' ? scope.sectionKey : undefined, getComponentIdentity(item)]);
|
|
5
8
|
/**
|
|
6
9
|
* Connects menu rows to keyboard selection and tracks which item is active through
|
|
@@ -53,70 +56,86 @@ export const useRegisteredMenu = ({
|
|
|
53
56
|
resetKey
|
|
54
57
|
});
|
|
55
58
|
const {
|
|
59
|
+
getSelectedIndex,
|
|
56
60
|
selectedIndex: selectedItemIndex,
|
|
57
61
|
selectionSource,
|
|
58
62
|
select
|
|
59
63
|
} = selection;
|
|
60
|
-
const [activation,
|
|
61
|
-
const
|
|
64
|
+
const [activation, setActivation] = useState();
|
|
65
|
+
const isPreviewOpen = (activation === null || activation === void 0 ? void 0 : activation.model) === model && activation.resetKey === resetKey;
|
|
62
66
|
useLayoutEffect(() => {
|
|
63
|
-
|
|
67
|
+
setActivation(undefined);
|
|
64
68
|
}, [model, resetKey]);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Closes the preview when the event comes from the selected item, optionally only for one source.
|
|
72
|
+
* Rows report leaving, blur and visibility from effects, including cleanups. Reading the latest
|
|
73
|
+
* selection keeps this callback stable, so a selection change doesn't re-run those effects and
|
|
74
|
+
* a row's cleanup can't close the preview that just moved to another row.
|
|
75
|
+
*/
|
|
76
|
+
const closePreviewFor = useCallback((index, source) => {
|
|
77
|
+
if (index !== getSelectedIndex()) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
setActivation(current => current && (source === undefined || current.source === source) ? undefined : current);
|
|
81
|
+
}, [getSelectedIndex]);
|
|
82
|
+
|
|
83
|
+
// Only listed items show a preview; the footer comes after them.
|
|
84
|
+
const hasPreview = useCallback(index => index < selectableItems.length, [selectableItems]);
|
|
65
85
|
const activateKeyboardItem = useCallback(index => {
|
|
66
|
-
|
|
67
|
-
setItemActivation(item ? {
|
|
68
|
-
itemKey: item.key,
|
|
86
|
+
setActivation(hasPreview(index) ? {
|
|
69
87
|
model,
|
|
70
88
|
resetKey,
|
|
71
89
|
source: 'keyboard'
|
|
72
90
|
} : undefined);
|
|
73
|
-
}, [model, resetKey
|
|
91
|
+
}, [hasPreview, model, resetKey]);
|
|
74
92
|
const selectNext = useCallback(() => {
|
|
75
93
|
activateKeyboardItem(selection.selectNext());
|
|
76
94
|
}, [selection.selectNext, activateKeyboardItem]);
|
|
77
95
|
const selectPrevious = useCallback(() => {
|
|
78
96
|
activateKeyboardItem(selection.selectPrevious());
|
|
79
97
|
}, [selection.selectPrevious, activateKeyboardItem]);
|
|
80
|
-
const onItemHover = useCallback(
|
|
98
|
+
const onItemHover = useCallback(index => {
|
|
81
99
|
select(index, 'pointer');
|
|
82
|
-
|
|
83
|
-
if (
|
|
100
|
+
setActivation(current => {
|
|
101
|
+
if (!hasPreview(index)) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
if ((current === null || current === void 0 ? void 0 : current.model) === model && current.resetKey === resetKey && current.source === 'pointer') {
|
|
84
105
|
return current;
|
|
85
106
|
}
|
|
86
|
-
return
|
|
87
|
-
itemKey,
|
|
107
|
+
return {
|
|
88
108
|
model,
|
|
89
109
|
resetKey,
|
|
90
110
|
source: 'pointer'
|
|
91
|
-
}
|
|
111
|
+
};
|
|
92
112
|
});
|
|
93
|
-
}, [model, resetKey, select]);
|
|
94
|
-
const onItemFocus = useCallback(
|
|
113
|
+
}, [hasPreview, model, resetKey, select]);
|
|
114
|
+
const onItemFocus = useCallback(index => {
|
|
115
|
+
const isSelectedItem = index === selectedItemIndex;
|
|
95
116
|
// A press focuses the item the pointer already selected. Scrolling it then would move it before the click lands.
|
|
96
|
-
select(index,
|
|
97
|
-
|
|
98
|
-
if (
|
|
117
|
+
select(index, isSelectedItem && selectionSource === 'pointer' ? 'pointer' : 'keyboard');
|
|
118
|
+
setActivation(current => {
|
|
119
|
+
if (!hasPreview(index)) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
if (isSelectedItem && (current === null || current === void 0 ? void 0 : current.model) === model && current.resetKey === resetKey) {
|
|
99
123
|
return current;
|
|
100
124
|
}
|
|
101
|
-
return
|
|
102
|
-
itemKey,
|
|
125
|
+
return {
|
|
103
126
|
model,
|
|
104
127
|
resetKey,
|
|
105
128
|
source: 'keyboard'
|
|
106
|
-
}
|
|
129
|
+
};
|
|
107
130
|
});
|
|
108
|
-
}, [model, resetKey, select, selectedItemIndex, selectionSource]);
|
|
109
|
-
const onItemLeave = useCallback(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const onItemBlur = useCallback(itemKey => {
|
|
113
|
-
setItemActivation(current => (current === null || current === void 0 ? void 0 : current.itemKey) === itemKey ? undefined : current);
|
|
114
|
-
}, []);
|
|
115
|
-
const onItemVisibilityChange = useCallback((itemKey, isVisible) => {
|
|
131
|
+
}, [hasPreview, model, resetKey, select, selectedItemIndex, selectionSource]);
|
|
132
|
+
const onItemLeave = useCallback(index => closePreviewFor(index, 'pointer'), [closePreviewFor]);
|
|
133
|
+
const onItemBlur = useCallback(index => closePreviewFor(index), [closePreviewFor]);
|
|
134
|
+
const onItemVisibilityChange = useCallback((index, isVisible) => {
|
|
116
135
|
if (!isVisible) {
|
|
117
|
-
|
|
136
|
+
closePreviewFor(index, 'pointer');
|
|
118
137
|
}
|
|
119
|
-
}, []);
|
|
138
|
+
}, [closePreviewFor]);
|
|
120
139
|
return {
|
|
121
140
|
rows,
|
|
122
141
|
selectableItems,
|
|
@@ -125,7 +144,7 @@ export const useRegisteredMenu = ({
|
|
|
125
144
|
select,
|
|
126
145
|
selectNext,
|
|
127
146
|
selectPrevious,
|
|
128
|
-
|
|
147
|
+
isPreviewOpen,
|
|
129
148
|
onItemHover,
|
|
130
149
|
onItemFocus,
|
|
131
150
|
onItemLeave,
|
|
@@ -58,7 +58,9 @@ export const useRegisteredMenuSelection = ({
|
|
|
58
58
|
select(previousIndex, 'keyboard');
|
|
59
59
|
return previousIndex;
|
|
60
60
|
}, [itemCount, select]);
|
|
61
|
+
const getSelectedIndex = useCallback(() => selectedIndexRef.current, []);
|
|
61
62
|
return {
|
|
63
|
+
getSelectedIndex,
|
|
62
64
|
selectedIndex,
|
|
63
65
|
selectionSource,
|
|
64
66
|
select,
|
|
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
13
13
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
14
14
|
import Layer from '../Layer';
|
|
15
15
|
const packageName = "@atlaskit/editor-common";
|
|
16
|
-
const packageVersion = "134.
|
|
16
|
+
const packageVersion = "134.14.0";
|
|
17
17
|
const halfFocusRing = 1;
|
|
18
18
|
const dropOffset = '0, 8';
|
|
19
19
|
// Ignored via go/ees005
|
|
@@ -19,7 +19,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
|
|
|
19
19
|
var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
|
|
20
20
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
21
21
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
22
|
-
var packageVersion = "134.
|
|
22
|
+
var packageVersion = "134.14.0";
|
|
23
23
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
24
24
|
// Remove URL as it has UGC
|
|
25
25
|
// Ignored via go/ees007
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
._4t3i1osq{height:100%}
|
|
28
28
|
._4t3i68cl{height:90pt}
|
|
29
29
|
._4t3i7vkz{height:1pc}
|
|
30
|
+
._5ral1dfr{object-fit:cover}
|
|
30
31
|
._5ral1f51{object-fit:contain}
|
|
31
32
|
._6rthu2gc{margin-block-end:var(--ds-space-100,8px)}
|
|
32
33
|
._bfhkhfxm{background-color:var(--ds-surface-sunken,#f8f8f8)}
|
|
@@ -21,13 +21,14 @@ var layoutStyles = {
|
|
|
21
21
|
var styles = {
|
|
22
22
|
root: "_1e0c1txw _2lx21bp4 _16jlkb7n _1ul9idpf",
|
|
23
23
|
content: "_zulpu2gc _1e0c1txw _2lx21bp4 _16jlkb7n",
|
|
24
|
-
title: "_11c81qyo _16jlidpf _1o9zkb7n _i0dl1wug
|
|
24
|
+
title: "_11c81qyo _16jlidpf _1o9zkb7n _i0dl1wug _syazi7uo _1ul9idpf _1i4qfg65",
|
|
25
25
|
clampedTitle: "_1reo15vq _18m915vq _1e0ccj1k _sudp1e54 _1yyjcs5v",
|
|
26
26
|
description: "_11c8fhey _1reo15vq _18m915vq _syazi7uo _1e0ccj1k _1i4qfg65 _sudp1e54 _1yyjegat",
|
|
27
27
|
unclampedDescription: "_11c8fhey _syazi7uo _1i4qfg65",
|
|
28
28
|
disabledText: "_syaz1gmx",
|
|
29
29
|
imageArea: "_2rko12b0 _1reo15vq _18m915vq _bfhkhfxm _4t3i68cl _6rthu2gc _1bsb1osq",
|
|
30
30
|
image: "_1e0c1ule _4t3i1osq _5ral1f51 _1bsb1osq",
|
|
31
|
+
imageCover: "_5ral1dfr",
|
|
31
32
|
imageHidden: "_3um015vq",
|
|
32
33
|
attribution: "_zulp1b66 _4cvr1h6o _syazazsu _1e0c1txw _1pfh1wug _1i4qfg65",
|
|
33
34
|
compactAttribution: "_11c8wadc",
|
|
@@ -39,7 +40,7 @@ var styles = {
|
|
|
39
40
|
* Element Browser tiles. It fills its container; callers own its width and accessible name.
|
|
40
41
|
*/
|
|
41
42
|
export var QuickInsertPreviewContent = function QuickInsertPreviewContent(_ref) {
|
|
42
|
-
var _preview$attribution, _preview$attribution2;
|
|
43
|
+
var _preview$attribution, _preview$attribution2, _preview$image;
|
|
43
44
|
var description = _ref.description,
|
|
44
45
|
icon = _ref.icon,
|
|
45
46
|
id = _ref.id,
|
|
@@ -76,7 +77,8 @@ export var QuickInsertPreviewContent = function QuickInsertPreviewContent(_ref)
|
|
|
76
77
|
className: ax([styles.root])
|
|
77
78
|
}, imageUrl && /*#__PURE__*/React.createElement(PreviewImage, {
|
|
78
79
|
key: imageUrl,
|
|
79
|
-
imageUrl: imageUrl
|
|
80
|
+
imageUrl: imageUrl,
|
|
81
|
+
objectFit: (_preview$image = preview.image) === null || _preview$image === void 0 ? void 0 : _preview$image.objectFit
|
|
80
82
|
}), /*#__PURE__*/React.createElement("div", {
|
|
81
83
|
className: ax([styles.content])
|
|
82
84
|
}, shortcut ? /*#__PURE__*/React.createElement(Inline, {
|
|
@@ -103,7 +105,8 @@ export var QuickInsertPreviewContent = function QuickInsertPreviewContent(_ref)
|
|
|
103
105
|
}))))));
|
|
104
106
|
};
|
|
105
107
|
var PreviewImage = function PreviewImage(_ref2) {
|
|
106
|
-
var imageUrl = _ref2.imageUrl
|
|
108
|
+
var imageUrl = _ref2.imageUrl,
|
|
109
|
+
objectFit = _ref2.objectFit;
|
|
107
110
|
var _useState = useState(false),
|
|
108
111
|
_useState2 = _slicedToArray(_useState, 2),
|
|
109
112
|
hasFailed = _useState2[0],
|
|
@@ -130,6 +133,6 @@ var PreviewImage = function PreviewImage(_ref2) {
|
|
|
130
133
|
onError: function onError() {
|
|
131
134
|
return setHasFailed(true);
|
|
132
135
|
},
|
|
133
|
-
className: ax([styles.image, !hasLoaded && styles.imageHidden])
|
|
136
|
+
className: ax([styles.image, objectFit === 'cover' && styles.imageCover, !hasLoaded && styles.imageHidden])
|
|
134
137
|
}));
|
|
135
138
|
};
|
|
@@ -204,5 +204,35 @@ export var messages = defineMessages({
|
|
|
204
204
|
id: 'editor-common.quick-insert.previewAttributionMicrosoft.ai-non-final',
|
|
205
205
|
defaultMessage: 'Microsoft',
|
|
206
206
|
description: 'Microsoft company name shown as the creator in a slash-command preview attribution.'
|
|
207
|
+
},
|
|
208
|
+
elementBrowserAllElements: {
|
|
209
|
+
id: 'editor.quick-insert.all-elements',
|
|
210
|
+
defaultMessage: 'All elements',
|
|
211
|
+
description: 'Heading above the remaining elements in the element browser All category, shown below the Recommended elements.'
|
|
212
|
+
},
|
|
213
|
+
elementBrowserCategoriesLabel: {
|
|
214
|
+
id: 'editor.quick-insert.categories-label',
|
|
215
|
+
defaultMessage: 'Element categories',
|
|
216
|
+
description: 'Accessible label for the group of category buttons in the element browser sidebar, read by screen readers.'
|
|
217
|
+
},
|
|
218
|
+
elementBrowserResultsAvailable: {
|
|
219
|
+
id: 'editor.quick-insert.results-available',
|
|
220
|
+
defaultMessage: '{count, plural, one {# result available} other {# results available}}',
|
|
221
|
+
description: 'Shown in the element browser footer. Tells the user how many elements match the current search and category.'
|
|
222
|
+
},
|
|
223
|
+
elementBrowserResultsLabel: {
|
|
224
|
+
id: 'editor.quick-insert.results-label',
|
|
225
|
+
defaultMessage: 'Element results',
|
|
226
|
+
description: 'Accessible label for the list of elements in the element browser, read by screen readers.'
|
|
227
|
+
},
|
|
228
|
+
elementBrowserSearch: {
|
|
229
|
+
id: 'editor.quick-insert.search',
|
|
230
|
+
defaultMessage: 'Search elements',
|
|
231
|
+
description: 'Accessible label for the search field at the top of the element browser, used to filter the elements that can be inserted.'
|
|
232
|
+
},
|
|
233
|
+
elementBrowserTitle: {
|
|
234
|
+
id: 'editor.quick-insert.title',
|
|
235
|
+
defaultMessage: 'Insert elements',
|
|
236
|
+
description: 'Title of the element browser dialog, where users browse and insert elements such as tables, panels and macros.'
|
|
207
237
|
}
|
|
208
238
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
// The list caches rendered rows while scrolling, so those rows may not receive
|
|
3
|
+
// updated props. We pass the index of the item showing its preview through context
|
|
4
|
+
// so their styling updates without rebuilding the wrappers that measure row height.
|
|
5
|
+
// Each row compares it with its own index, which a cached row still has right.
|
|
6
|
+
export var PreviewItemIndexContext = /*#__PURE__*/createContext(undefined);
|
|
@@ -6,8 +6,8 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
6
6
|
import React, { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
|
|
7
7
|
import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
|
|
8
8
|
import { List } from 'react-virtualized/dist/commonjs/List';
|
|
9
|
-
import { ActiveMenuItemKeyContext } from './ActiveMenuItemKeyContext';
|
|
10
9
|
import { MeasuredRow } from './MeasuredRow';
|
|
10
|
+
import { PreviewItemIndexContext } from './PreviewItemIndexContext';
|
|
11
11
|
import { RegisteredMenuListItemRow } from './RegisteredMenuListItemRow';
|
|
12
12
|
import { useMenuListHeight } from './useMenuListHeight';
|
|
13
13
|
var ESTIMATED_ROW_HEIGHT = 44;
|
|
@@ -15,7 +15,8 @@ export var RegisteredMenuList = function RegisteredMenuList(_ref) {
|
|
|
15
15
|
var rows = _ref.rows,
|
|
16
16
|
Item = _ref.Item,
|
|
17
17
|
selectedItemIndex = _ref.selectedItemIndex,
|
|
18
|
-
|
|
18
|
+
_ref$isPreviewOpen = _ref.isPreviewOpen,
|
|
19
|
+
isPreviewOpen = _ref$isPreviewOpen === void 0 ? false : _ref$isPreviewOpen,
|
|
19
20
|
maxHeight = _ref.maxHeight,
|
|
20
21
|
width = _ref.width,
|
|
21
22
|
getItemId = _ref.getItemId,
|
|
@@ -117,13 +118,8 @@ export var RegisteredMenuList = function RegisteredMenuList(_ref) {
|
|
|
117
118
|
overscanStopIndex = _ref3.overscanStopIndex,
|
|
118
119
|
startIndex = _ref3.startIndex,
|
|
119
120
|
stopIndex = _ref3.stopIndex;
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
return row.type === 'menu-item' && row.key === activeItemKey;
|
|
123
|
-
});
|
|
124
|
-
if (activeRowIndex >= 0 && (activeRowIndex < startIndex || activeRowIndex > stopIndex)) {
|
|
125
|
-
onItemVisibilityChange(activeItemKey, false);
|
|
126
|
-
}
|
|
121
|
+
if (isPreviewOpen && selectedRowIndex >= 0 && (selectedRowIndex < startIndex || selectedRowIndex > stopIndex)) {
|
|
122
|
+
onItemVisibilityChange(selectedItemIndex, false);
|
|
127
123
|
}
|
|
128
124
|
updateHeight();
|
|
129
125
|
var indexes = _toConsumableArray(itemIndexByRowIndex).filter(function (_ref4) {
|
|
@@ -139,7 +135,7 @@ export var RegisteredMenuList = function RegisteredMenuList(_ref) {
|
|
|
139
135
|
startIndex: (_indexes$ = indexes[0]) !== null && _indexes$ !== void 0 ? _indexes$ : -1,
|
|
140
136
|
stopIndex: (_indexes = indexes[indexes.length - 1]) !== null && _indexes !== void 0 ? _indexes : -1
|
|
141
137
|
});
|
|
142
|
-
}, [
|
|
138
|
+
}, [isPreviewOpen, itemIndexByRowIndex, onItemVisibilityChange, onRenderedItemsChange, selectedItemIndex, selectedRowIndex, updateHeight]);
|
|
143
139
|
var renderRow = useCallback(function (_ref8) {
|
|
144
140
|
var index = _ref8.index,
|
|
145
141
|
key = _ref8.key,
|
|
@@ -199,8 +195,8 @@ export var RegisteredMenuList = function RegisteredMenuList(_ref) {
|
|
|
199
195
|
if (rows.length === 0) {
|
|
200
196
|
return null;
|
|
201
197
|
}
|
|
202
|
-
return /*#__PURE__*/React.createElement(
|
|
203
|
-
value:
|
|
198
|
+
return /*#__PURE__*/React.createElement(PreviewItemIndexContext.Provider, {
|
|
199
|
+
value: isPreviewOpen ? selectedItemIndex : undefined
|
|
204
200
|
}, /*#__PURE__*/React.createElement(List, {
|
|
205
201
|
"aria-readonly": ariaReadonly,
|
|
206
202
|
containerRole: containerRole,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useLayoutEffect } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { PreviewItemIndexContext } from './PreviewItemIndexContext';
|
|
3
3
|
/**
|
|
4
4
|
* Connects a rendered item to the list's active state and interaction callbacks.
|
|
5
5
|
* The list may reuse this row while scrolling, so context keeps its active styling
|
|
@@ -19,35 +19,35 @@ export var RegisteredMenuListItemRow = function RegisteredMenuListItemRow(_ref)
|
|
|
19
19
|
registration = _ref.registration,
|
|
20
20
|
rowIndex = _ref.rowIndex,
|
|
21
21
|
selectedItemIndex = _ref.selectedItemIndex;
|
|
22
|
-
var
|
|
22
|
+
var previewItemIndex = useContext(PreviewItemIndexContext);
|
|
23
23
|
useLayoutEffect(function () {
|
|
24
|
-
onItemVisibilityChange(
|
|
24
|
+
onItemVisibilityChange(itemIndex, isVisible);
|
|
25
25
|
return function () {
|
|
26
|
-
return onItemVisibilityChange(
|
|
26
|
+
return onItemVisibilityChange(itemIndex, false);
|
|
27
27
|
};
|
|
28
|
-
}, [isVisible,
|
|
28
|
+
}, [isVisible, itemIndex, onItemVisibilityChange]);
|
|
29
29
|
var onBlur = useCallback(function (event) {
|
|
30
30
|
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
31
|
-
onItemBlur(
|
|
31
|
+
onItemBlur(itemIndex);
|
|
32
32
|
}
|
|
33
|
-
}, [
|
|
33
|
+
}, [itemIndex, onItemBlur]);
|
|
34
34
|
return /*#__PURE__*/React.createElement("div", {
|
|
35
35
|
onBlur: onBlur,
|
|
36
36
|
onFocus: function onFocus() {
|
|
37
|
-
return onItemFocus(itemIndex
|
|
37
|
+
return onItemFocus(itemIndex);
|
|
38
38
|
},
|
|
39
39
|
onMouseLeave: function onMouseLeave() {
|
|
40
|
-
return onItemLeave(
|
|
40
|
+
return onItemLeave(itemIndex);
|
|
41
41
|
},
|
|
42
42
|
onMouseMove: function onMouseMove() {
|
|
43
|
-
return onItemHover(itemIndex
|
|
43
|
+
return onItemHover(itemIndex);
|
|
44
44
|
}
|
|
45
45
|
}, /*#__PURE__*/React.createElement(Item, {
|
|
46
46
|
id: getItemId({
|
|
47
47
|
itemIndex: itemIndex,
|
|
48
48
|
rowIndex: rowIndex
|
|
49
49
|
}),
|
|
50
|
-
isActive:
|
|
50
|
+
isActive: previewItemIndex === itemIndex,
|
|
51
51
|
isSelected: itemIndex === selectedItemIndex,
|
|
52
52
|
registration: registration
|
|
53
53
|
}));
|
|
@@ -4,6 +4,9 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
4
4
|
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { getComponentIdentity } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
6
6
|
import { useRegisteredMenuSelection } from './useRegisteredMenuSelection';
|
|
7
|
+
|
|
8
|
+
/** An open preview always belongs to the selected item, so only whether it's open is stored. */
|
|
9
|
+
|
|
7
10
|
var getSelectableItemIdentity = function getSelectableItemIdentity(item, scope) {
|
|
8
11
|
return JSON.stringify([scope.type, scope.type === 'section' ? scope.sectionKey : undefined, getComponentIdentity(item)]);
|
|
9
12
|
};
|
|
@@ -62,78 +65,96 @@ export var useRegisteredMenu = function useRegisteredMenu(_ref) {
|
|
|
62
65
|
identities: selectableItemIdentities,
|
|
63
66
|
resetKey: resetKey
|
|
64
67
|
});
|
|
65
|
-
var
|
|
68
|
+
var getSelectedIndex = selection.getSelectedIndex,
|
|
69
|
+
selectedItemIndex = selection.selectedIndex,
|
|
66
70
|
selectionSource = selection.selectionSource,
|
|
67
71
|
select = selection.select;
|
|
68
72
|
var _useState = useState(),
|
|
69
73
|
_useState2 = _slicedToArray(_useState, 2),
|
|
70
74
|
activation = _useState2[0],
|
|
71
|
-
|
|
72
|
-
var
|
|
75
|
+
setActivation = _useState2[1];
|
|
76
|
+
var isPreviewOpen = (activation === null || activation === void 0 ? void 0 : activation.model) === model && activation.resetKey === resetKey;
|
|
73
77
|
useLayoutEffect(function () {
|
|
74
|
-
|
|
78
|
+
setActivation(undefined);
|
|
75
79
|
}, [model, resetKey]);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Closes the preview when the event comes from the selected item, optionally only for one source.
|
|
83
|
+
* Rows report leaving, blur and visibility from effects, including cleanups. Reading the latest
|
|
84
|
+
* selection keeps this callback stable, so a selection change doesn't re-run those effects and
|
|
85
|
+
* a row's cleanup can't close the preview that just moved to another row.
|
|
86
|
+
*/
|
|
87
|
+
var closePreviewFor = useCallback(function (index, source) {
|
|
88
|
+
if (index !== getSelectedIndex()) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
setActivation(function (current) {
|
|
92
|
+
return current && (source === undefined || current.source === source) ? undefined : current;
|
|
93
|
+
});
|
|
94
|
+
}, [getSelectedIndex]);
|
|
95
|
+
|
|
96
|
+
// Only listed items show a preview; the footer comes after them.
|
|
97
|
+
var hasPreview = useCallback(function (index) {
|
|
98
|
+
return index < selectableItems.length;
|
|
99
|
+
}, [selectableItems]);
|
|
76
100
|
var activateKeyboardItem = useCallback(function (index) {
|
|
77
|
-
|
|
78
|
-
setItemActivation(item ? {
|
|
79
|
-
itemKey: item.key,
|
|
101
|
+
setActivation(hasPreview(index) ? {
|
|
80
102
|
model: model,
|
|
81
103
|
resetKey: resetKey,
|
|
82
104
|
source: 'keyboard'
|
|
83
105
|
} : undefined);
|
|
84
|
-
}, [model, resetKey
|
|
106
|
+
}, [hasPreview, model, resetKey]);
|
|
85
107
|
var selectNext = useCallback(function () {
|
|
86
108
|
activateKeyboardItem(selection.selectNext());
|
|
87
109
|
}, [selection.selectNext, activateKeyboardItem]);
|
|
88
110
|
var selectPrevious = useCallback(function () {
|
|
89
111
|
activateKeyboardItem(selection.selectPrevious());
|
|
90
112
|
}, [selection.selectPrevious, activateKeyboardItem]);
|
|
91
|
-
var onItemHover = useCallback(function (index
|
|
113
|
+
var onItemHover = useCallback(function (index) {
|
|
92
114
|
select(index, 'pointer');
|
|
93
|
-
|
|
94
|
-
if (
|
|
115
|
+
setActivation(function (current) {
|
|
116
|
+
if (!hasPreview(index)) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
if ((current === null || current === void 0 ? void 0 : current.model) === model && current.resetKey === resetKey && current.source === 'pointer') {
|
|
95
120
|
return current;
|
|
96
121
|
}
|
|
97
|
-
return
|
|
98
|
-
itemKey: itemKey,
|
|
122
|
+
return {
|
|
99
123
|
model: model,
|
|
100
124
|
resetKey: resetKey,
|
|
101
125
|
source: 'pointer'
|
|
102
|
-
}
|
|
126
|
+
};
|
|
103
127
|
});
|
|
104
|
-
}, [model, resetKey, select]);
|
|
105
|
-
var onItemFocus = useCallback(function (index
|
|
128
|
+
}, [hasPreview, model, resetKey, select]);
|
|
129
|
+
var onItemFocus = useCallback(function (index) {
|
|
130
|
+
var isSelectedItem = index === selectedItemIndex;
|
|
106
131
|
// A press focuses the item the pointer already selected. Scrolling it then would move it before the click lands.
|
|
107
|
-
select(index,
|
|
108
|
-
|
|
109
|
-
if (
|
|
132
|
+
select(index, isSelectedItem && selectionSource === 'pointer' ? 'pointer' : 'keyboard');
|
|
133
|
+
setActivation(function (current) {
|
|
134
|
+
if (!hasPreview(index)) {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
if (isSelectedItem && (current === null || current === void 0 ? void 0 : current.model) === model && current.resetKey === resetKey) {
|
|
110
138
|
return current;
|
|
111
139
|
}
|
|
112
|
-
return
|
|
113
|
-
itemKey: itemKey,
|
|
140
|
+
return {
|
|
114
141
|
model: model,
|
|
115
142
|
resetKey: resetKey,
|
|
116
143
|
source: 'keyboard'
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}, [model, resetKey, select, selectedItemIndex, selectionSource]);
|
|
120
|
-
var onItemLeave = useCallback(function (itemKey) {
|
|
121
|
-
setItemActivation(function (current) {
|
|
122
|
-
return (current === null || current === void 0 ? void 0 : current.source) === 'pointer' && current.itemKey === itemKey ? undefined : current;
|
|
123
|
-
});
|
|
124
|
-
}, []);
|
|
125
|
-
var onItemBlur = useCallback(function (itemKey) {
|
|
126
|
-
setItemActivation(function (current) {
|
|
127
|
-
return (current === null || current === void 0 ? void 0 : current.itemKey) === itemKey ? undefined : current;
|
|
144
|
+
};
|
|
128
145
|
});
|
|
129
|
-
}, []);
|
|
130
|
-
var
|
|
146
|
+
}, [hasPreview, model, resetKey, select, selectedItemIndex, selectionSource]);
|
|
147
|
+
var onItemLeave = useCallback(function (index) {
|
|
148
|
+
return closePreviewFor(index, 'pointer');
|
|
149
|
+
}, [closePreviewFor]);
|
|
150
|
+
var onItemBlur = useCallback(function (index) {
|
|
151
|
+
return closePreviewFor(index);
|
|
152
|
+
}, [closePreviewFor]);
|
|
153
|
+
var onItemVisibilityChange = useCallback(function (index, isVisible) {
|
|
131
154
|
if (!isVisible) {
|
|
132
|
-
|
|
133
|
-
return (current === null || current === void 0 ? void 0 : current.source) === 'pointer' && current.itemKey === itemKey ? undefined : current;
|
|
134
|
-
});
|
|
155
|
+
closePreviewFor(index, 'pointer');
|
|
135
156
|
}
|
|
136
|
-
}, []);
|
|
157
|
+
}, [closePreviewFor]);
|
|
137
158
|
return {
|
|
138
159
|
rows: rows,
|
|
139
160
|
selectableItems: selectableItems,
|
|
@@ -142,7 +163,7 @@ export var useRegisteredMenu = function useRegisteredMenu(_ref) {
|
|
|
142
163
|
select: select,
|
|
143
164
|
selectNext: selectNext,
|
|
144
165
|
selectPrevious: selectPrevious,
|
|
145
|
-
|
|
166
|
+
isPreviewOpen: isPreviewOpen,
|
|
146
167
|
onItemHover: onItemHover,
|
|
147
168
|
onItemFocus: onItemFocus,
|
|
148
169
|
onItemLeave: onItemLeave,
|
|
@@ -66,7 +66,11 @@ export var useRegisteredMenuSelection = function useRegisteredMenuSelection(_ref
|
|
|
66
66
|
select(previousIndex, 'keyboard');
|
|
67
67
|
return previousIndex;
|
|
68
68
|
}, [itemCount, select]);
|
|
69
|
+
var getSelectedIndex = useCallback(function () {
|
|
70
|
+
return selectedIndexRef.current;
|
|
71
|
+
}, []);
|
|
69
72
|
return {
|
|
73
|
+
getSelectedIndex: getSelectedIndex,
|
|
70
74
|
selectedIndex: selectedIndex,
|
|
71
75
|
selectionSource: selectionSource,
|
|
72
76
|
select: select,
|
|
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
20
20
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
21
21
|
import Layer from '../Layer';
|
|
22
22
|
var packageName = "@atlaskit/editor-common";
|
|
23
|
-
var packageVersion = "134.
|
|
23
|
+
var packageVersion = "134.14.0";
|
|
24
24
|
var halfFocusRing = 1;
|
|
25
25
|
var dropOffset = '0, 8';
|
|
26
26
|
// Ignored via go/ees005
|
|
@@ -3,5 +3,5 @@ type Messages<Keys extends string> = Record<Keys, MessageDescriptor & {
|
|
|
3
3
|
defaultMessage: string;
|
|
4
4
|
id: string;
|
|
5
5
|
}>;
|
|
6
|
-
export declare const messages: Messages<'admin' | 'AI' | 'all' | 'browse' | 'categoryBlockTemplates' | 'categoryCreate' | 'categoryDataAndCharts' | 'categoryEmbed' | 'categoryMedia' | 'categoryOther' | 'categoryRecommended' | 'categoryRovo' | 'categoryStructure' | 'categoryTextFormatting' | 'searchResults' | 'noSearchResults' | 'previewAttributionBy' | 'previewAttributionAtlassian' | 'previewAttributionAssets' | 'previewAttributionConfluence' | 'previewAttributionFeedback' | 'previewAttributionFocus' | 'previewAttributionJira' | 'previewAttributionJiraServiceManagement' | 'previewAttributionMicrosoft' | 'previewAttributionStudio' | 'previewAttributionTalent' | 'previewAttributionTrello' | 'close' | 'communication' | 'confluence-content' | 'development' | 'external-content' | 'featuredWhiteboardDescription' | 'formatting' | 'help' | 'insert' | 'media' | 'navigation' | 'reporting' | 'visuals'>;
|
|
6
|
+
export declare const messages: Messages<'admin' | 'AI' | 'all' | 'browse' | 'categoryBlockTemplates' | 'categoryCreate' | 'categoryDataAndCharts' | 'categoryEmbed' | 'categoryMedia' | 'categoryOther' | 'categoryRecommended' | 'categoryRovo' | 'categoryStructure' | 'categoryTextFormatting' | 'searchResults' | 'noSearchResults' | 'previewAttributionBy' | 'previewAttributionAtlassian' | 'previewAttributionAssets' | 'previewAttributionConfluence' | 'previewAttributionFeedback' | 'previewAttributionFocus' | 'previewAttributionJira' | 'previewAttributionJiraServiceManagement' | 'previewAttributionMicrosoft' | 'previewAttributionStudio' | 'previewAttributionTalent' | 'previewAttributionTrello' | 'close' | 'communication' | 'confluence-content' | 'development' | 'external-content' | 'featuredWhiteboardDescription' | 'formatting' | 'help' | 'insert' | 'media' | 'navigation' | 'reporting' | 'visuals' | 'elementBrowserAllElements' | 'elementBrowserCategoriesLabel' | 'elementBrowserResultsAvailable' | 'elementBrowserResultsLabel' | 'elementBrowserSearch' | 'elementBrowserTitle'>;
|
|
7
7
|
export {};
|
|
@@ -4,6 +4,12 @@ import type { MessageDescriptor } from 'react-intl';
|
|
|
4
4
|
export type PreviewImage = {
|
|
5
5
|
dark?: string;
|
|
6
6
|
light: string;
|
|
7
|
+
/**
|
|
8
|
+
* How the image fills the preview's fixed-height image area, as CSS `object-fit`. Defaults to
|
|
9
|
+
* `contain`, which shows the whole image. Use `cover` only for images whose edges are
|
|
10
|
+
* background, since it crops whatever doesn't fit the area's shape.
|
|
11
|
+
*/
|
|
12
|
+
objectFit?: 'contain' | 'cover';
|
|
7
13
|
};
|
|
8
14
|
export type QuickInsertPreview = {
|
|
9
15
|
attribution?: {
|