@atlaskit/editor-plugin-type-ahead 2.0.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/cjs/ui/TypeAheadList.js +27 -9
- package/dist/cjs/ui/TypeAheadMenu.js +8 -2
- package/dist/cjs/ui/TypeAheadPopup.js +33 -4
- package/dist/cjs/ui/ViewMore.js +42 -0
- package/dist/cjs/ui/modern/TypeAheadPopup.js +38 -10
- package/dist/es2019/ui/TypeAheadList.js +27 -9
- package/dist/es2019/ui/TypeAheadMenu.js +9 -3
- package/dist/es2019/ui/TypeAheadPopup.js +33 -4
- package/dist/es2019/ui/ViewMore.js +36 -0
- package/dist/es2019/ui/modern/TypeAheadPopup.js +45 -15
- package/dist/esm/ui/TypeAheadList.js +27 -9
- package/dist/esm/ui/TypeAheadMenu.js +9 -3
- package/dist/esm/ui/TypeAheadPopup.js +33 -4
- package/dist/esm/ui/ViewMore.js +34 -0
- package/dist/esm/ui/modern/TypeAheadPopup.js +42 -13
- package/dist/types/ui/TypeAheadList.d.ts +2 -0
- package/dist/types/ui/TypeAheadPopup.d.ts +1 -0
- package/dist/types/ui/ViewMore.d.ts +8 -0
- package/dist/types-ts4.5/ui/TypeAheadList.d.ts +2 -0
- package/dist/types-ts4.5/ui/TypeAheadPopup.d.ts +1 -0
- package/dist/types-ts4.5/ui/ViewMore.d.ts +8 -0
- package/package.json +6 -6
- package/dist/cjs/ui/modern/ViewAllButton.js +0 -76
- package/dist/es2019/ui/modern/ViewAllButton.js +0 -66
- package/dist/esm/ui/modern/ViewAllButton.js +0 -66
- package/dist/types/ui/modern/ViewAllButton.d.ts +0 -13
- package/dist/types-ts4.5/ui/modern/ViewAllButton.d.ts +0 -13
|
@@ -1,25 +1,30 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/ui-styling-standard/use-compiled */
|
|
1
2
|
/**
|
|
2
3
|
* @jsxRuntime classic
|
|
3
4
|
* @jsx jsx
|
|
4
5
|
*/
|
|
5
6
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
7
|
import { css, jsx } from '@emotion/react';
|
|
9
8
|
import rafSchedule from 'raf-schd';
|
|
9
|
+
import { useIntl } from 'react-intl-next';
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
12
|
+
|
|
10
13
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
14
|
+
import { elementInsertSidePanel } from '@atlaskit/editor-common/messages';
|
|
11
15
|
import { findOverflowScrollParent, Popup } from '@atlaskit/editor-common/ui';
|
|
12
|
-
import { QuickInsertPanel } from '@atlaskit/editor-element-browser';
|
|
16
|
+
import { SideInsertPanel, QuickInsertPanel } from '@atlaskit/editor-element-browser';
|
|
13
17
|
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
|
|
18
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
14
19
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
20
|
import { N0, N50A, N60A } from '@atlaskit/theme/colors';
|
|
16
21
|
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../../pm-plugins/constants';
|
|
17
22
|
import { TypeAheadErrorFallback } from '../TypeAheadErrorFallback';
|
|
18
|
-
import { ViewAllButton } from './ViewAllButton';
|
|
19
23
|
const DEFAULT_TYPEAHEAD_MENU_HEIGHT = 520;
|
|
20
24
|
// const DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW = 480;
|
|
21
25
|
|
|
22
26
|
const ITEM_PADDING = 12;
|
|
27
|
+
const INSERT_PANEL_WIDTH = 320;
|
|
23
28
|
const typeAheadContent = css({
|
|
24
29
|
background: `var(--ds-surface-overlay, ${N0})`,
|
|
25
30
|
borderRadius: "var(--ds-border-radius, 3px)",
|
|
@@ -53,6 +58,9 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
|
|
|
53
58
|
setSelectedItem
|
|
54
59
|
} = props;
|
|
55
60
|
const ref = useRef(null);
|
|
61
|
+
const {
|
|
62
|
+
formatMessage
|
|
63
|
+
} = useIntl();
|
|
56
64
|
const defaultMenuHeight = DEFAULT_TYPEAHEAD_MENU_HEIGHT;
|
|
57
65
|
const startTime = useMemo(() => performance.now(),
|
|
58
66
|
// In case those props changes
|
|
@@ -257,11 +265,37 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
|
|
|
257
265
|
element === null || element === void 0 ? void 0 : element.removeEventListener('keydown', escape);
|
|
258
266
|
};
|
|
259
267
|
}, [ref, cancel]);
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
268
|
+
const handleViewAllItemsClick = useCallback(() => {
|
|
269
|
+
var _api$contextPanel, _api$contextPanel$act;
|
|
270
|
+
const showContextPanel = api === null || api === void 0 ? void 0 : (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : (_api$contextPanel$act = _api$contextPanel.actions) === null || _api$contextPanel$act === void 0 ? void 0 : _api$contextPanel$act.showPanel;
|
|
271
|
+
if (!showContextPanel || !items) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Opens main editor controls side panel
|
|
276
|
+
showContextPanel({
|
|
277
|
+
id: 'editor-element-insert-sidebar-panel',
|
|
278
|
+
headerComponentElements: {
|
|
279
|
+
headerLabel: elementInsertSidePanel.title,
|
|
280
|
+
HeaderIcon: () => jsx(AddIcon, {
|
|
281
|
+
label: formatMessage(elementInsertSidePanel.title)
|
|
282
|
+
})
|
|
283
|
+
},
|
|
284
|
+
BodyComponent: () => {
|
|
285
|
+
return jsx(SideInsertPanel, {
|
|
286
|
+
items: items,
|
|
287
|
+
onItemInsert: onItemInsert
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}, 'push', INSERT_PANEL_WIDTH);
|
|
291
|
+
|
|
292
|
+
// Closes typeahead
|
|
293
|
+
cancel({
|
|
294
|
+
addPrefixTrigger: true,
|
|
295
|
+
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
|
|
296
|
+
forceFocusOnEditor: true
|
|
297
|
+
});
|
|
298
|
+
}, [api, cancel, formatMessage, items, onItemInsert]);
|
|
265
299
|
return jsx(Popup, {
|
|
266
300
|
zIndex: akEditorFloatingDialogZIndex,
|
|
267
301
|
target: anchorElement,
|
|
@@ -286,12 +320,8 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
|
|
|
286
320
|
items: items,
|
|
287
321
|
onItemInsert: onItemInsert,
|
|
288
322
|
query: query,
|
|
289
|
-
setSelectedItem: setSelectedItem
|
|
290
|
-
|
|
291
|
-
items: items,
|
|
292
|
-
editorApi: api,
|
|
293
|
-
onItemInsert: onItemInsert,
|
|
294
|
-
onPanelOpen: handlePanelOpen
|
|
323
|
+
setSelectedItem: setSelectedItem,
|
|
324
|
+
onViewAllItemsClick: Boolean(api === null || api === void 0 ? void 0 : api.contextPanel) ? handleViewAllItemsClick : undefined
|
|
295
325
|
}))));
|
|
296
326
|
});
|
|
297
327
|
TypeAheadPopup.displayName = 'TypeAheadPopup';
|
|
@@ -11,8 +11,10 @@ import { css, jsx } from '@emotion/react';
|
|
|
11
11
|
import { injectIntl, useIntl } from 'react-intl-next';
|
|
12
12
|
import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
|
|
13
13
|
import { List } from 'react-virtualized/dist/commonjs/List';
|
|
14
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
14
15
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
15
16
|
import { MenuGroup } from '@atlaskit/menu';
|
|
17
|
+
import { Text, Box } from '@atlaskit/primitives';
|
|
16
18
|
import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
|
|
17
19
|
import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
|
|
18
20
|
import { getTypeAheadListAriaLabels, moveSelectedIndex } from '../pm-plugins/utils';
|
|
@@ -50,7 +52,8 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
50
52
|
decorationElement = _ref2.decorationElement,
|
|
51
53
|
triggerHandler = _ref2.triggerHandler,
|
|
52
54
|
moreElementsInQuickInsertViewEnabled = _ref2.moreElementsInQuickInsertViewEnabled,
|
|
53
|
-
api = _ref2.api
|
|
55
|
+
api = _ref2.api,
|
|
56
|
+
showViewMore = _ref2.showViewMore;
|
|
54
57
|
var listRef = useRef();
|
|
55
58
|
var listContainerRef = useRef(null);
|
|
56
59
|
var lastVisibleIndexes = useRef({
|
|
@@ -277,13 +280,21 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
277
280
|
return null;
|
|
278
281
|
}
|
|
279
282
|
var menuGroupId = ((_decorationElement$qu2 = decorationElement.querySelector("[role='combobox']")) === null || _decorationElement$qu2 === void 0 ? void 0 : _decorationElement$qu2.getAttribute('aria-controls')) || TYPE_AHEAD_DECORATION_ELEMENT_ID;
|
|
280
|
-
|
|
281
|
-
"
|
|
282
|
-
|
|
283
|
-
}, jsx(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}, jsx(
|
|
283
|
+
var EmptyResultView = jsx(Box, {
|
|
284
|
+
paddingBlock: "space.150",
|
|
285
|
+
paddingInline: "space.250"
|
|
286
|
+
}, jsx(Text, {
|
|
287
|
+
align: "center",
|
|
288
|
+
as: "p"
|
|
289
|
+
}, intl.formatMessage(typeAheadListMessages.emptySearchResults)), jsx(Text, {
|
|
290
|
+
align: "center",
|
|
291
|
+
as: "p"
|
|
292
|
+
}, intl.formatMessage(typeAheadListMessages.emptySearchResultsSuggestion, {
|
|
293
|
+
buttonName: jsx(Text, {
|
|
294
|
+
weight: "medium"
|
|
295
|
+
}, intl.formatMessage(messages.viewMore))
|
|
296
|
+
})));
|
|
297
|
+
var ListContent = jsx(List, {
|
|
287
298
|
rowRenderer: renderRow,
|
|
288
299
|
ref: listRef,
|
|
289
300
|
rowCount: items.length,
|
|
@@ -313,7 +324,14 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
313
324
|
}
|
|
314
325
|
}
|
|
315
326
|
}), moreElementsInQuickInsertViewEnabled && list]
|
|
316
|
-
})
|
|
327
|
+
});
|
|
328
|
+
return jsx(MenuGroup, {
|
|
329
|
+
"aria-label": popupAriaLabel,
|
|
330
|
+
"aria-relevant": "additions removals"
|
|
331
|
+
}, jsx("div", {
|
|
332
|
+
id: menuGroupId,
|
|
333
|
+
ref: listContainerRef
|
|
334
|
+
}, !showViewMore || items.length ? ListContent : EmptyResultView, jsx(TypeaheadAssistiveTextPureComponent, {
|
|
317
335
|
numberOfResults: items.length.toString()
|
|
318
336
|
})));
|
|
319
337
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
3
|
+
import { SelectItemMode, TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
5
|
import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
|
|
5
6
|
import { useItemInsert } from './hooks/use-item-insert';
|
|
6
7
|
import { TypeAheadPopup } from './TypeAheadPopup';
|
|
@@ -70,7 +71,11 @@ export var TypeAheadMenu = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
}, [isOpen, query, onItemMatch]);
|
|
73
|
-
|
|
74
|
+
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
var openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
|
|
77
|
+
var showViewMore = (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT && !!openElementBrowserModal && editorExperiment('platform_editor_controls', 'variant1');
|
|
78
|
+
if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || !showViewMore && items.length === 0 && !errorInfo) {
|
|
74
79
|
return null;
|
|
75
80
|
}
|
|
76
81
|
return /*#__PURE__*/React.createElement(TypeAheadPopup, {
|
|
@@ -88,6 +93,7 @@ export var TypeAheadMenu = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
88
93
|
decorationSet: decorationSet,
|
|
89
94
|
isEmptyQuery: !query,
|
|
90
95
|
cancel: cancel,
|
|
91
|
-
api: api
|
|
96
|
+
api: api,
|
|
97
|
+
showViewMore: showViewMore
|
|
92
98
|
});
|
|
93
99
|
});
|
|
@@ -18,7 +18,9 @@ import { N0, N50A, N60A } from '@atlaskit/theme/colors';
|
|
|
18
18
|
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
|
|
19
19
|
import { TypeAheadErrorFallback } from './TypeAheadErrorFallback';
|
|
20
20
|
import { TypeAheadList } from './TypeAheadList';
|
|
21
|
+
import { ViewMore } from './ViewMore';
|
|
21
22
|
var DEFAULT_TYPEAHEAD_MENU_HEIGHT = 380;
|
|
23
|
+
var VIEWMORE_BUTTON_HEIGHT = 53;
|
|
22
24
|
var DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW = 480;
|
|
23
25
|
var ITEM_PADDING = 12;
|
|
24
26
|
var typeAheadContent = css({
|
|
@@ -35,6 +37,10 @@ var typeAheadContent = css({
|
|
|
35
37
|
var typeAheadContentOverride = css({
|
|
36
38
|
maxHeight: "".concat(DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW, "px")
|
|
37
39
|
});
|
|
40
|
+
var typeAheadWrapperWithViewMoreOverride = css({
|
|
41
|
+
display: 'flex',
|
|
42
|
+
flexDirection: 'column'
|
|
43
|
+
});
|
|
38
44
|
var Highlight = function Highlight(_ref) {
|
|
39
45
|
var state = _ref.state,
|
|
40
46
|
triggerHandler = _ref.triggerHandler;
|
|
@@ -57,7 +63,8 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
57
63
|
onItemInsert = props.onItemInsert,
|
|
58
64
|
isEmptyQuery = props.isEmptyQuery,
|
|
59
65
|
cancel = props.cancel,
|
|
60
|
-
api = props.api
|
|
66
|
+
api = props.api,
|
|
67
|
+
showViewMore = props.showViewMore;
|
|
61
68
|
var ref = useRef(null);
|
|
62
69
|
var _useSharedPluginState = useSharedPluginState(api, ['featureFlags']),
|
|
63
70
|
featureFlagsState = _useSharedPluginState.featureFlagsState;
|
|
@@ -119,6 +126,12 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
119
126
|
_useState2 = _slicedToArray(_useState, 2),
|
|
120
127
|
fitHeight = _useState2[0],
|
|
121
128
|
setFitHeight = _useState2[1];
|
|
129
|
+
var fitHeightWithViewMore = useMemo(function () {
|
|
130
|
+
if (showViewMore) {
|
|
131
|
+
return fitHeight - VIEWMORE_BUTTON_HEIGHT;
|
|
132
|
+
}
|
|
133
|
+
return fitHeight;
|
|
134
|
+
}, [fitHeight, showViewMore]);
|
|
122
135
|
var getFitHeight = useCallback(function () {
|
|
123
136
|
if (!anchorElement || !popupsMountPoint) {
|
|
124
137
|
return;
|
|
@@ -258,6 +271,19 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
258
271
|
element === null || element === void 0 || element.removeEventListener('keydown', escape);
|
|
259
272
|
};
|
|
260
273
|
}, [ref, cancel]);
|
|
274
|
+
|
|
275
|
+
// @ts-ignore
|
|
276
|
+
var openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
|
|
277
|
+
var onViewMoreClick = useCallback(function () {
|
|
278
|
+
// TODO: when clean up, remove config in quick insert plugin
|
|
279
|
+
// platform/packages/editor/editor-plugin-quick-insert/src/quickInsertPlugin.tsx (typeAhead.openElementBrowserModal)
|
|
280
|
+
openElementBrowserModal === null || openElementBrowserModal === void 0 || openElementBrowserModal();
|
|
281
|
+
cancel({
|
|
282
|
+
addPrefixTrigger: false,
|
|
283
|
+
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
|
|
284
|
+
forceFocusOnEditor: false
|
|
285
|
+
});
|
|
286
|
+
}, [openElementBrowserModal, cancel]);
|
|
261
287
|
return jsx(Popup, {
|
|
262
288
|
zIndex: akEditorFloatingDialogZIndex,
|
|
263
289
|
target: anchorElement,
|
|
@@ -270,7 +296,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
270
296
|
ariaLabel: null,
|
|
271
297
|
preventOverflow: true
|
|
272
298
|
}, jsx("div", {
|
|
273
|
-
css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride]
|
|
299
|
+
css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride, showViewMore && typeAheadWrapperWithViewMoreOverride]
|
|
274
300
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
275
301
|
,
|
|
276
302
|
tabIndex: 0
|
|
@@ -285,12 +311,15 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
285
311
|
items: items,
|
|
286
312
|
selectedIndex: selectedIndex,
|
|
287
313
|
onItemClick: onItemInsert,
|
|
288
|
-
fitHeight:
|
|
314
|
+
fitHeight: fitHeightWithViewMore,
|
|
289
315
|
editorView: editorView,
|
|
290
316
|
decorationElement: anchorElement,
|
|
291
317
|
triggerHandler: triggerHandler,
|
|
292
318
|
moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
|
|
293
|
-
api: api
|
|
319
|
+
api: api,
|
|
320
|
+
showViewMore: showViewMore
|
|
321
|
+
}), showViewMore && jsx(ViewMore, {
|
|
322
|
+
onClick: onViewMoreClick
|
|
294
323
|
}))));
|
|
295
324
|
});
|
|
296
325
|
TypeAheadPopup.displayName = 'TypeAheadPopup';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import { useIntl } from 'react-intl-next';
|
|
8
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
+
import ShowMoreHorizontalIcon from '@atlaskit/icon/core/migration/show-more-horizontal--editor-more';
|
|
10
|
+
import { ButtonItem, Section } from '@atlaskit/menu';
|
|
11
|
+
import { N30 } from '@atlaskit/theme/colors';
|
|
12
|
+
var buttonStyles = css({
|
|
13
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
14
|
+
'& > button:hover': {
|
|
15
|
+
backgroundColor: "var(--ds-background-neutral-subtle-hovered, ".concat(N30, ")")
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export var ViewMore = function ViewMore(_ref) {
|
|
19
|
+
var onClick = _ref.onClick;
|
|
20
|
+
var _useIntl = useIntl(),
|
|
21
|
+
formatMessage = _useIntl.formatMessage;
|
|
22
|
+
return jsx(Section, {
|
|
23
|
+
hasSeparator: true
|
|
24
|
+
}, jsx("span", {
|
|
25
|
+
css: buttonStyles
|
|
26
|
+
}, jsx(ButtonItem, {
|
|
27
|
+
onClick: onClick,
|
|
28
|
+
iconBefore: jsx(ShowMoreHorizontalIcon, {
|
|
29
|
+
label: ""
|
|
30
|
+
}),
|
|
31
|
+
"aria-describedby": formatMessage(messages.viewMore),
|
|
32
|
+
"data-testid": "quick-insert-view-more-elements-item"
|
|
33
|
+
}, formatMessage(messages.viewMore))));
|
|
34
|
+
};
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
/* eslint-disable @atlaskit/ui-styling-standard/use-compiled */
|
|
2
3
|
/**
|
|
3
4
|
* @jsxRuntime classic
|
|
4
5
|
* @jsx jsx
|
|
5
6
|
*/
|
|
6
7
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
8
|
import { css, jsx } from '@emotion/react';
|
|
10
9
|
import rafSchedule from 'raf-schd';
|
|
10
|
+
import { useIntl } from 'react-intl-next';
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
13
|
+
|
|
11
14
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
15
|
+
import { elementInsertSidePanel } from '@atlaskit/editor-common/messages';
|
|
12
16
|
import { findOverflowScrollParent, Popup } from '@atlaskit/editor-common/ui';
|
|
13
|
-
import { QuickInsertPanel } from '@atlaskit/editor-element-browser';
|
|
17
|
+
import { SideInsertPanel, QuickInsertPanel } from '@atlaskit/editor-element-browser';
|
|
14
18
|
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
|
|
19
|
+
import AddIcon from '@atlaskit/icon/core/add';
|
|
15
20
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
21
|
import { N0, N50A, N60A } from '@atlaskit/theme/colors';
|
|
17
22
|
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../../pm-plugins/constants';
|
|
18
23
|
import { TypeAheadErrorFallback } from '../TypeAheadErrorFallback';
|
|
19
|
-
import { ViewAllButton } from './ViewAllButton';
|
|
20
24
|
var DEFAULT_TYPEAHEAD_MENU_HEIGHT = 520;
|
|
21
25
|
// const DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW = 480;
|
|
22
26
|
|
|
23
27
|
var ITEM_PADDING = 12;
|
|
28
|
+
var INSERT_PANEL_WIDTH = 320;
|
|
24
29
|
var typeAheadContent = css({
|
|
25
30
|
background: "var(--ds-surface-overlay, ".concat(N0, ")"),
|
|
26
31
|
borderRadius: "var(--ds-border-radius, 3px)",
|
|
@@ -52,6 +57,8 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
52
57
|
query = props.query,
|
|
53
58
|
setSelectedItem = props.setSelectedItem;
|
|
54
59
|
var ref = useRef(null);
|
|
60
|
+
var _useIntl = useIntl(),
|
|
61
|
+
formatMessage = _useIntl.formatMessage;
|
|
55
62
|
var defaultMenuHeight = DEFAULT_TYPEAHEAD_MENU_HEIGHT;
|
|
56
63
|
var startTime = useMemo(function () {
|
|
57
64
|
return performance.now();
|
|
@@ -253,13 +260,39 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
253
260
|
element === null || element === void 0 || element.removeEventListener('keydown', escape);
|
|
254
261
|
};
|
|
255
262
|
}, [ref, cancel]);
|
|
256
|
-
var
|
|
257
|
-
|
|
263
|
+
var handleViewAllItemsClick = useCallback(function () {
|
|
264
|
+
var _api$contextPanel;
|
|
265
|
+
var showContextPanel = api === null || api === void 0 || (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 || (_api$contextPanel = _api$contextPanel.actions) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.showPanel;
|
|
266
|
+
if (!showContextPanel || !items) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Opens main editor controls side panel
|
|
271
|
+
showContextPanel({
|
|
272
|
+
id: 'editor-element-insert-sidebar-panel',
|
|
273
|
+
headerComponentElements: {
|
|
274
|
+
headerLabel: elementInsertSidePanel.title,
|
|
275
|
+
HeaderIcon: function HeaderIcon() {
|
|
276
|
+
return jsx(AddIcon, {
|
|
277
|
+
label: formatMessage(elementInsertSidePanel.title)
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
BodyComponent: function BodyComponent() {
|
|
282
|
+
return jsx(SideInsertPanel, {
|
|
283
|
+
items: items,
|
|
284
|
+
onItemInsert: onItemInsert
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}, 'push', INSERT_PANEL_WIDTH);
|
|
288
|
+
|
|
289
|
+
// Closes typeahead
|
|
290
|
+
cancel({
|
|
258
291
|
addPrefixTrigger: true,
|
|
259
292
|
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
|
|
260
293
|
forceFocusOnEditor: true
|
|
261
294
|
});
|
|
262
|
-
}, [cancel]);
|
|
295
|
+
}, [api, cancel, formatMessage, items, onItemInsert]);
|
|
263
296
|
return jsx(Popup, {
|
|
264
297
|
zIndex: akEditorFloatingDialogZIndex,
|
|
265
298
|
target: anchorElement,
|
|
@@ -284,12 +317,8 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
284
317
|
items: items,
|
|
285
318
|
onItemInsert: onItemInsert,
|
|
286
319
|
query: query,
|
|
287
|
-
setSelectedItem: setSelectedItem
|
|
288
|
-
|
|
289
|
-
items: items,
|
|
290
|
-
editorApi: api,
|
|
291
|
-
onItemInsert: onItemInsert,
|
|
292
|
-
onPanelOpen: handlePanelOpen
|
|
320
|
+
setSelectedItem: setSelectedItem,
|
|
321
|
+
onViewAllItemsClick: Boolean(api === null || api === void 0 ? void 0 : api.contextPanel) ? handleViewAllItemsClick : undefined
|
|
293
322
|
}))));
|
|
294
323
|
});
|
|
295
324
|
TypeAheadPopup.displayName = 'TypeAheadPopup';
|
|
@@ -19,6 +19,7 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
|
|
|
19
19
|
triggerHandler?: TypeAheadHandler | undefined;
|
|
20
20
|
moreElementsInQuickInsertViewEnabled?: boolean | undefined;
|
|
21
21
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
22
|
+
showViewMore?: boolean | undefined;
|
|
22
23
|
} & WrappedComponentProps>> & {
|
|
23
24
|
WrappedComponent: React.ComponentType<{
|
|
24
25
|
items: Array<TypeAheadItem>;
|
|
@@ -30,5 +31,6 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
|
|
|
30
31
|
triggerHandler?: TypeAheadHandler | undefined;
|
|
31
32
|
moreElementsInQuickInsertViewEnabled?: boolean | undefined;
|
|
32
33
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
34
|
+
showViewMore?: boolean | undefined;
|
|
33
35
|
} & WrappedComponentProps>;
|
|
34
36
|
};
|
|
@@ -30,6 +30,7 @@ type TypeAheadPopupProps = {
|
|
|
30
30
|
forceFocusOnEditor: boolean;
|
|
31
31
|
}) => void;
|
|
32
32
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
33
|
+
showViewMore?: boolean;
|
|
33
34
|
};
|
|
34
35
|
export declare const TypeAheadPopup: React.MemoExoticComponent<(props: TypeAheadPopupProps) => jsx.JSX.Element>;
|
|
35
36
|
export {};
|
|
@@ -19,6 +19,7 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
|
|
|
19
19
|
triggerHandler?: TypeAheadHandler | undefined;
|
|
20
20
|
moreElementsInQuickInsertViewEnabled?: boolean | undefined;
|
|
21
21
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
22
|
+
showViewMore?: boolean | undefined;
|
|
22
23
|
} & WrappedComponentProps>> & {
|
|
23
24
|
WrappedComponent: React.ComponentType<{
|
|
24
25
|
items: Array<TypeAheadItem>;
|
|
@@ -30,5 +31,6 @@ export declare const TypeAheadList: React.FC<import("react-intl-next").WithIntlP
|
|
|
30
31
|
triggerHandler?: TypeAheadHandler | undefined;
|
|
31
32
|
moreElementsInQuickInsertViewEnabled?: boolean | undefined;
|
|
32
33
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
34
|
+
showViewMore?: boolean | undefined;
|
|
33
35
|
} & WrappedComponentProps>;
|
|
34
36
|
};
|
|
@@ -30,6 +30,7 @@ type TypeAheadPopupProps = {
|
|
|
30
30
|
forceFocusOnEditor: boolean;
|
|
31
31
|
}) => void;
|
|
32
32
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
33
|
+
showViewMore?: boolean;
|
|
33
34
|
};
|
|
34
35
|
export declare const TypeAheadPopup: React.MemoExoticComponent<(props: TypeAheadPopupProps) => jsx.JSX.Element>;
|
|
35
36
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-type-ahead",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Type-ahead plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/adf-schema": "^47.
|
|
37
|
-
"@atlaskit/editor-common": "^100.
|
|
36
|
+
"@atlaskit/adf-schema": "^47.6.0",
|
|
37
|
+
"@atlaskit/editor-common": "^100.5.0",
|
|
38
38
|
"@atlaskit/editor-element-browser": "^0.1.0",
|
|
39
|
-
"@atlaskit/editor-plugin-analytics": "^2.
|
|
39
|
+
"@atlaskit/editor-plugin-analytics": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-connectivity": "^2.0.0",
|
|
41
41
|
"@atlaskit/editor-plugin-context-panel": "^3.0.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@atlaskit/primitives": "^14.1.0",
|
|
49
49
|
"@atlaskit/prosemirror-input-rules": "^3.3.0",
|
|
50
50
|
"@atlaskit/theme": "^17.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^3.
|
|
52
|
-
"@atlaskit/tokens": "^4.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^3.4.0",
|
|
52
|
+
"@atlaskit/tokens": "^4.3.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
54
54
|
"@emotion/react": "^11.7.1",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.ViewAllButton = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactIntlNext = require("react-intl-next");
|
|
11
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
|
-
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
13
|
-
var _editorElementBrowser = require("@atlaskit/editor-element-browser");
|
|
14
|
-
var _add = _interopRequireDefault(require("@atlaskit/icon/core/add"));
|
|
15
|
-
var _primitives = require("@atlaskit/primitives");
|
|
16
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
-
var viewAllButtonStyles = (0, _primitives.xcss)({
|
|
19
|
-
background: "var(--ds-background-input-pressed, #FFFFFF)",
|
|
20
|
-
position: 'sticky',
|
|
21
|
-
bottom: '-4px',
|
|
22
|
-
width: '100%',
|
|
23
|
-
height: '40px',
|
|
24
|
-
color: 'color.text.subtle',
|
|
25
|
-
fontWeight: "var(--ds-font-weight-medium, 500)",
|
|
26
|
-
':hover': {
|
|
27
|
-
textDecoration: 'underline'
|
|
28
|
-
},
|
|
29
|
-
':active': {
|
|
30
|
-
color: 'color.text'
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
var INSERT_PANEL_WIDTH = 320;
|
|
34
|
-
var ViewAllButton = exports.ViewAllButton = function ViewAllButton(_ref) {
|
|
35
|
-
var items = _ref.items,
|
|
36
|
-
editorApi = _ref.editorApi,
|
|
37
|
-
onItemInsert = _ref.onItemInsert,
|
|
38
|
-
onPanelOpen = _ref.onPanelOpen;
|
|
39
|
-
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
40
|
-
formatMessage = _useIntl.formatMessage;
|
|
41
|
-
var handleClick = (0, _react.useCallback)(function () {
|
|
42
|
-
var _editorApi$contextPan;
|
|
43
|
-
var showContextPanel = editorApi === null || editorApi === void 0 || (_editorApi$contextPan = editorApi.contextPanel) === null || _editorApi$contextPan === void 0 || (_editorApi$contextPan = _editorApi$contextPan.actions) === null || _editorApi$contextPan === void 0 ? void 0 : _editorApi$contextPan.showPanel;
|
|
44
|
-
if (!showContextPanel || !items) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Opens main editor controls side panel
|
|
49
|
-
showContextPanel({
|
|
50
|
-
id: 'editor-element-insert-sidebar-panel',
|
|
51
|
-
headerComponentElements: {
|
|
52
|
-
headerLabel: _messages.elementInsertSidePanel.title,
|
|
53
|
-
HeaderIcon: function HeaderIcon() {
|
|
54
|
-
return /*#__PURE__*/_react.default.createElement(_add.default, {
|
|
55
|
-
label: formatMessage(_messages.elementInsertSidePanel.title)
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
BodyComponent: function BodyComponent() {
|
|
60
|
-
return /*#__PURE__*/_react.default.createElement(_editorElementBrowser.SideInsertPanel, {
|
|
61
|
-
items: items,
|
|
62
|
-
onItemInsert: onItemInsert
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}, 'push', INSERT_PANEL_WIDTH);
|
|
66
|
-
|
|
67
|
-
// Closes typeahead
|
|
68
|
-
if (onPanelOpen) {
|
|
69
|
-
onPanelOpen();
|
|
70
|
-
}
|
|
71
|
-
}, [editorApi, formatMessage, items, onItemInsert, onPanelOpen]);
|
|
72
|
-
return /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
|
|
73
|
-
xcss: viewAllButtonStyles,
|
|
74
|
-
onClick: handleClick
|
|
75
|
-
}, formatMessage(_typeAhead.typeAheadListMessages.viewAllInserts));
|
|
76
|
-
};
|