@atlaskit/editor-plugin-type-ahead 16.1.10 → 16.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/ui/registered-menu/RegisteredTypeAheadMenu.js +27 -7
- package/dist/cjs/ui/registered-menu/buildTypeAheadMenuModel.js +12 -5
- package/dist/cjs/ui/registered-menu/getMatchingComponents.js +10 -5
- package/dist/cjs/ui/registered-menu/quick-insert/TypeAheadQuickInsertItem.js +2 -0
- package/dist/cjs/ui/registered-menu/quick-insert/TypeAheadQuickInsertProvider.js +6 -2
- package/dist/es2019/ui/registered-menu/RegisteredTypeAheadMenu.js +16 -2
- package/dist/es2019/ui/registered-menu/buildTypeAheadMenuModel.js +12 -5
- package/dist/es2019/ui/registered-menu/getMatchingComponents.js +11 -5
- package/dist/es2019/ui/registered-menu/quick-insert/TypeAheadQuickInsertItem.js +2 -0
- package/dist/es2019/ui/registered-menu/quick-insert/TypeAheadQuickInsertProvider.js +6 -2
- package/dist/esm/ui/registered-menu/RegisteredTypeAheadMenu.js +27 -7
- package/dist/esm/ui/registered-menu/buildTypeAheadMenuModel.js +12 -5
- package/dist/esm/ui/registered-menu/getMatchingComponents.js +10 -5
- package/dist/esm/ui/registered-menu/quick-insert/TypeAheadQuickInsertItem.js +2 -0
- package/dist/esm/ui/registered-menu/quick-insert/TypeAheadQuickInsertProvider.js +6 -2
- package/dist/types/ui/registered-menu/TypeAheadContext.d.ts +3 -0
- package/dist/types/ui/registered-menu/buildTypeAheadMenuModel.d.ts +2 -2
- package/dist/types/ui/registered-menu/getMatchingComponents.d.ts +8 -2
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-type-ahead
|
|
2
2
|
|
|
3
|
+
## 16.1.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`edcef04b6350e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/edcef04b6350e) -
|
|
8
|
+
Add the Quick Insert recommendation resolver API and typed surface context support for the gated
|
|
9
|
+
`platform_editor_slash_command` Recommended menu. TypeAhead uses immutable surface context for
|
|
10
|
+
visibility and React context for registered Quick Insert rendering, while Quick Insert keeps one
|
|
11
|
+
recommendation snapshot per menu open. Fix Quick Insert declaration generation.
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 16.1.11
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 16.1.10
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -12,8 +12,10 @@ var _runtime = require("@compiled/react/runtime");
|
|
|
12
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _reactIntl = require("react-intl");
|
|
15
|
+
var _typeAheadSurfaceContext = require("@atlaskit/editor-common/type-ahead-surface-context");
|
|
15
16
|
var _typeAheadIsSectionOverflowItemKey = require("@atlaskit/editor-common/type-ahead-is-section-overflow-item-key");
|
|
16
17
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
18
|
+
var _types = require("@atlaskit/editor-ui-control-model/types");
|
|
17
19
|
var _constants = require("@atlaskit/editor-shared-styles/constants");
|
|
18
20
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
19
21
|
var _InputQuery = require("../InputQuery");
|
|
@@ -53,10 +55,20 @@ var RegisteredTypeAheadMenu = exports.RegisteredTypeAheadMenu = function Registe
|
|
|
53
55
|
var generatedId = (0, _react.useId)();
|
|
54
56
|
var listId = "".concat(surface.listIdPrefix, "-").concat(generatedId);
|
|
55
57
|
var menuRef = (0, _react.useRef)(null);
|
|
56
|
-
var _useState = (0, _react.useState)(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
var _useState = (0, _react.useState)(function () {
|
|
59
|
+
return {
|
|
60
|
+
menuOpenId: Symbol('type-ahead-menu-open')
|
|
61
|
+
};
|
|
62
|
+
}),
|
|
63
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 1),
|
|
64
|
+
typeAheadSurfaceContext = _useState2[0];
|
|
65
|
+
var surfaceContext = (0, _react.useMemo)(function () {
|
|
66
|
+
return (0, _types.createSurfaceContext)(_typeAheadSurfaceContext.TYPE_AHEAD_SURFACE_CONTEXT, typeAheadSurfaceContext);
|
|
67
|
+
}, [typeAheadSurfaceContext]);
|
|
68
|
+
var _useState3 = (0, _react.useState)(0),
|
|
69
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
70
|
+
selectedItemIndex = _useState4[0],
|
|
71
|
+
setSelectedItemIndex = _useState4[1];
|
|
60
72
|
var components = (0, _react.useMemo)(function () {
|
|
61
73
|
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
62
74
|
return (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(surface.root.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
@@ -68,8 +80,14 @@ var RegisteredTypeAheadMenu = exports.RegisteredTypeAheadMenu = function Registe
|
|
|
68
80
|
});
|
|
69
81
|
}, [components]);
|
|
70
82
|
var menuModel = (0, _react.useMemo)(function () {
|
|
71
|
-
return query === '' ? (0, _buildTypeAheadMenuModel.buildTypeAheadMenuModel)(components, surface.root, hasSectionOverflowItems ? SECTION_OVERFLOW_LIMIT : undefined) : (0, _getMatchingComponents.getMatchingComponents)(
|
|
72
|
-
|
|
83
|
+
return query === '' ? (0, _buildTypeAheadMenuModel.buildTypeAheadMenuModel)(components, surface.root, hasSectionOverflowItems ? SECTION_OVERFLOW_LIMIT : undefined, surfaceContext) : (0, _getMatchingComponents.getMatchingComponents)({
|
|
84
|
+
components: components,
|
|
85
|
+
rootComponent: surface.root,
|
|
86
|
+
query: query,
|
|
87
|
+
formatMessage: formatMessage,
|
|
88
|
+
surfaceContext: surfaceContext
|
|
89
|
+
});
|
|
90
|
+
}, [components, formatMessage, hasSectionOverflowItems, query, surfaceContext, surface.root]);
|
|
73
91
|
var rows = (0, _react.useMemo)(function () {
|
|
74
92
|
return menuModel.sections.flat();
|
|
75
93
|
}, [menuModel.sections]);
|
|
@@ -115,11 +133,13 @@ var RegisteredTypeAheadMenu = exports.RegisteredTypeAheadMenu = function Registe
|
|
|
115
133
|
api: api,
|
|
116
134
|
editorView: editorView,
|
|
117
135
|
inputMethod: surface.inputMethod,
|
|
136
|
+
menuOpenId: typeAheadSurfaceContext.menuOpenId,
|
|
118
137
|
onClose: onClose,
|
|
119
138
|
query: query,
|
|
139
|
+
surfaceContext: surfaceContext,
|
|
120
140
|
triggerHandler: triggerHandler
|
|
121
141
|
};
|
|
122
|
-
}, [api, editorView, onClose, query, surface.inputMethod, triggerHandler]);
|
|
142
|
+
}, [api, editorView, onClose, query, surface.inputMethod, surfaceContext, triggerHandler, typeAheadSurfaceContext]);
|
|
123
143
|
var noOp = (0, _react.useCallback)(function () {}, []);
|
|
124
144
|
var SurfaceProvider = surface.Provider;
|
|
125
145
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_InputQuery.InputQuery, {
|
|
@@ -12,11 +12,18 @@ var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-render
|
|
|
12
12
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
13
13
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
14
|
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; }
|
|
15
|
-
var buildTypeAheadMenuModel = exports.buildTypeAheadMenuModel = function buildTypeAheadMenuModel(components, rootComponent, sectionOverflowLimit) {
|
|
15
|
+
var buildTypeAheadMenuModel = exports.buildTypeAheadMenuModel = function buildTypeAheadMenuModel(components, rootComponent, sectionOverflowLimit, surfaceContext) {
|
|
16
16
|
var _resolveSurface = (0, _surfaceRenderer.resolveSurface)(components, rootComponent),
|
|
17
17
|
root = _resolveSurface.root,
|
|
18
18
|
childrenMap = _resolveSurface.childrenMap,
|
|
19
19
|
topLevelChildren = _resolveSurface.topLevelChildren;
|
|
20
|
+
if (!root || !(0, _surfaceRenderer.willComponentRender)(root, childrenMap, surfaceContext)) {
|
|
21
|
+
return {
|
|
22
|
+
footer: undefined,
|
|
23
|
+
root: undefined,
|
|
24
|
+
sections: []
|
|
25
|
+
};
|
|
26
|
+
}
|
|
20
27
|
var sections = [];
|
|
21
28
|
var footer;
|
|
22
29
|
var _iterator = _createForOfIteratorHelper(topLevelChildren !== null && topLevelChildren !== void 0 ? topLevelChildren : []),
|
|
@@ -25,26 +32,26 @@ var buildTypeAheadMenuModel = exports.buildTypeAheadMenuModel = function buildTy
|
|
|
25
32
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
26
33
|
var _childrenMap$get;
|
|
27
34
|
var section = _step.value;
|
|
28
|
-
if (section.type !== 'menu-section' || !(0, _surfaceRenderer.willComponentRender)(section, childrenMap)) {
|
|
35
|
+
if (section.type !== 'menu-section' || !(0, _surfaceRenderer.willComponentRender)(section, childrenMap, surfaceContext)) {
|
|
29
36
|
continue;
|
|
30
37
|
}
|
|
31
38
|
var children = (_childrenMap$get = childrenMap.get(section.key)) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : [];
|
|
32
39
|
if ((0, _typeAheadIsMenuFooterSectionKey.isMenuFooterSectionKey)(section.key)) {
|
|
33
40
|
footer = children.find(function (child) {
|
|
34
|
-
return child.type === 'menu-item' && (0, _surfaceRenderer.willComponentRender)(child, childrenMap);
|
|
41
|
+
return child.type === 'menu-item' && (0, _surfaceRenderer.willComponentRender)(child, childrenMap, surfaceContext);
|
|
35
42
|
});
|
|
36
43
|
continue;
|
|
37
44
|
}
|
|
38
45
|
var viewMoreItem = void 0;
|
|
39
46
|
for (var index = children.length - 1; index >= 0; index--) {
|
|
40
47
|
var child = children[index];
|
|
41
|
-
if ((child === null || child === void 0 ? void 0 : child.type) === 'menu-item' && (0, _typeAheadIsSectionOverflowItemKey.isSectionOverflowItemKey)(child.key) && (0, _surfaceRenderer.willComponentRender)(child, childrenMap)) {
|
|
48
|
+
if ((child === null || child === void 0 ? void 0 : child.type) === 'menu-item' && (0, _typeAheadIsSectionOverflowItemKey.isSectionOverflowItemKey)(child.key) && (0, _surfaceRenderer.willComponentRender)(child, childrenMap, surfaceContext)) {
|
|
42
49
|
viewMoreItem = child;
|
|
43
50
|
break;
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
53
|
var items = children.filter(function (child) {
|
|
47
|
-
return child.type === 'menu-item' && !(0, _typeAheadIsSectionOverflowItemKey.isSectionOverflowItemKey)(child.key) && (0, _surfaceRenderer.willComponentRender)(child, childrenMap);
|
|
54
|
+
return child.type === 'menu-item' && !(0, _typeAheadIsSectionOverflowItemKey.isSectionOverflowItemKey)(child.key) && (0, _surfaceRenderer.willComponentRender)(child, childrenMap, surfaceContext);
|
|
48
55
|
});
|
|
49
56
|
if (items.length === 0) {
|
|
50
57
|
continue;
|
|
@@ -24,15 +24,20 @@ var compareMatchedItems = function compareMatchedItems(a, b) {
|
|
|
24
24
|
* Resolves registered menu items for a non-empty query. This intentionally has
|
|
25
25
|
* no empty-query path so browse behavior remains owned by buildTypeAheadMenuModel.
|
|
26
26
|
*/
|
|
27
|
-
var getMatchingComponents = exports.getMatchingComponents = function getMatchingComponents(
|
|
27
|
+
var getMatchingComponents = exports.getMatchingComponents = function getMatchingComponents(_ref) {
|
|
28
|
+
var components = _ref.components,
|
|
29
|
+
rootComponent = _ref.rootComponent,
|
|
30
|
+
query = _ref.query,
|
|
31
|
+
formatMessage = _ref.formatMessage,
|
|
32
|
+
surfaceContext = _ref.surfaceContext;
|
|
28
33
|
var _resolveSurface = (0, _surfaceRenderer.resolveSurface)(components, rootComponent),
|
|
29
34
|
childrenMap = _resolveSurface.childrenMap,
|
|
30
35
|
root = _resolveSurface.root,
|
|
31
36
|
topLevelChildren = _resolveSurface.topLevelChildren;
|
|
32
|
-
if (!root || !topLevelChildren) {
|
|
37
|
+
if (!root || !(0, _surfaceRenderer.willComponentRender)(root, childrenMap, surfaceContext) || !topLevelChildren) {
|
|
33
38
|
return {
|
|
34
39
|
footer: undefined,
|
|
35
|
-
root:
|
|
40
|
+
root: undefined,
|
|
36
41
|
sections: []
|
|
37
42
|
};
|
|
38
43
|
}
|
|
@@ -43,7 +48,7 @@ var getMatchingComponents = exports.getMatchingComponents = function getMatching
|
|
|
43
48
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
44
49
|
var _childrenMap$get;
|
|
45
50
|
var section = _step.value;
|
|
46
|
-
if (section.type !== 'menu-section' || (0, _typeAheadIsMenuFooterSectionKey.isMenuFooterSectionKey)(section.key) || !(0, _surfaceRenderer.willComponentRender)(section, childrenMap)) {
|
|
51
|
+
if (section.type !== 'menu-section' || (0, _typeAheadIsMenuFooterSectionKey.isMenuFooterSectionKey)(section.key) || !(0, _surfaceRenderer.willComponentRender)(section, childrenMap, surfaceContext)) {
|
|
47
52
|
continue;
|
|
48
53
|
}
|
|
49
54
|
var _iterator3 = _createForOfIteratorHelper((_childrenMap$get = childrenMap.get(section.key)) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []),
|
|
@@ -52,7 +57,7 @@ var getMatchingComponents = exports.getMatchingComponents = function getMatching
|
|
|
52
57
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
53
58
|
var _item$match, _match$score;
|
|
54
59
|
var item = _step3.value;
|
|
55
|
-
if (item.type !== 'menu-item' || (0, _typeAheadIsSectionOverflowItemKey.isSectionOverflowItemKey)(item.key) || !(0, _surfaceRenderer.willComponentRender)(item, childrenMap)) {
|
|
60
|
+
if (item.type !== 'menu-item' || (0, _typeAheadIsSectionOverflowItemKey.isSectionOverflowItemKey)(item.key) || !(0, _surfaceRenderer.willComponentRender)(item, childrenMap, surfaceContext)) {
|
|
56
61
|
continue;
|
|
57
62
|
}
|
|
58
63
|
var match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
|
|
@@ -21,6 +21,8 @@ var TypeAheadQuickInsertItem = exports.TypeAheadQuickInsertItem = function TypeA
|
|
|
21
21
|
return {
|
|
22
22
|
editorView: quickInsertContext.editorView,
|
|
23
23
|
isOffline: quickInsertContext.isOffline,
|
|
24
|
+
menuOpenId: quickInsertContext.menuOpenId,
|
|
25
|
+
surfaceContext: quickInsertContext.surfaceContext,
|
|
24
26
|
item: {
|
|
25
27
|
id: id,
|
|
26
28
|
isSelected: isSelected
|
|
@@ -18,8 +18,10 @@ var TypeAheadQuickInsertProvider = exports.TypeAheadQuickInsertProvider = functi
|
|
|
18
18
|
api = _useTypeAheadContext.api,
|
|
19
19
|
editorView = _useTypeAheadContext.editorView,
|
|
20
20
|
inputMethod = _useTypeAheadContext.inputMethod,
|
|
21
|
+
menuOpenId = _useTypeAheadContext.menuOpenId,
|
|
21
22
|
onClose = _useTypeAheadContext.onClose,
|
|
22
23
|
query = _useTypeAheadContext.query,
|
|
24
|
+
surfaceContext = _useTypeAheadContext.surfaceContext,
|
|
23
25
|
triggerHandler = _useTypeAheadContext.triggerHandler;
|
|
24
26
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity'], function (_ref2) {
|
|
25
27
|
var connectivityState = _ref2.connectivityState;
|
|
@@ -43,9 +45,11 @@ var TypeAheadQuickInsertProvider = exports.TypeAheadQuickInsertProvider = functi
|
|
|
43
45
|
return {
|
|
44
46
|
editorView: editorView,
|
|
45
47
|
isOffline: isOffline,
|
|
46
|
-
|
|
48
|
+
menuOpenId: menuOpenId,
|
|
49
|
+
select: select,
|
|
50
|
+
surfaceContext: surfaceContext
|
|
47
51
|
};
|
|
48
|
-
}, [editorView, isOffline, select]);
|
|
52
|
+
}, [editorView, isOffline, menuOpenId, select, surfaceContext]);
|
|
49
53
|
return /*#__PURE__*/_react.default.createElement(_provider.QuickInsertProvider, {
|
|
50
54
|
value: contextValue
|
|
51
55
|
}, children);
|
|
@@ -3,8 +3,10 @@ import "./RegisteredTypeAheadMenu.compiled.css";
|
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React, { useCallback, useId, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { useIntl } from 'react-intl';
|
|
6
|
+
import { TYPE_AHEAD_SURFACE_CONTEXT } from '@atlaskit/editor-common/type-ahead-surface-context';
|
|
6
7
|
import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
|
|
7
8
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
9
|
+
import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
8
10
|
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles/constants';
|
|
9
11
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
10
12
|
import { InputQuery } from '../InputQuery';
|
|
@@ -44,6 +46,10 @@ export const RegisteredTypeAheadMenu = ({
|
|
|
44
46
|
const generatedId = useId();
|
|
45
47
|
const listId = `${surface.listIdPrefix}-${generatedId}`;
|
|
46
48
|
const menuRef = useRef(null);
|
|
49
|
+
const [typeAheadSurfaceContext] = useState(() => ({
|
|
50
|
+
menuOpenId: Symbol('type-ahead-menu-open')
|
|
51
|
+
}));
|
|
52
|
+
const surfaceContext = useMemo(() => createSurfaceContext(TYPE_AHEAD_SURFACE_CONTEXT, typeAheadSurfaceContext), [typeAheadSurfaceContext]);
|
|
47
53
|
const [selectedItemIndex, setSelectedItemIndex] = useState(0);
|
|
48
54
|
const components = useMemo(() => {
|
|
49
55
|
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
@@ -52,7 +58,13 @@ export const RegisteredTypeAheadMenu = ({
|
|
|
52
58
|
const hasSectionOverflowItems = useMemo(() => components.some(({
|
|
53
59
|
key
|
|
54
60
|
}) => isSectionOverflowItemKey(key)), [components]);
|
|
55
|
-
const menuModel = useMemo(() => query === '' ? buildTypeAheadMenuModel(components, surface.root, hasSectionOverflowItems ? SECTION_OVERFLOW_LIMIT : undefined) : getMatchingComponents(
|
|
61
|
+
const menuModel = useMemo(() => query === '' ? buildTypeAheadMenuModel(components, surface.root, hasSectionOverflowItems ? SECTION_OVERFLOW_LIMIT : undefined, surfaceContext) : getMatchingComponents({
|
|
62
|
+
components,
|
|
63
|
+
rootComponent: surface.root,
|
|
64
|
+
query,
|
|
65
|
+
formatMessage,
|
|
66
|
+
surfaceContext
|
|
67
|
+
}), [components, formatMessage, hasSectionOverflowItems, query, surfaceContext, surface.root]);
|
|
56
68
|
const rows = useMemo(() => menuModel.sections.flat(), [menuModel.sections]);
|
|
57
69
|
const selectableRowIndexes = useMemo(() => rows.flatMap((registration, rowIndex) => registration.type === 'menu-item' ? [rowIndex] : []), [rows]);
|
|
58
70
|
const selectableRowKeys = selectableRowIndexes.map(index => {
|
|
@@ -91,10 +103,12 @@ export const RegisteredTypeAheadMenu = ({
|
|
|
91
103
|
api,
|
|
92
104
|
editorView,
|
|
93
105
|
inputMethod: surface.inputMethod,
|
|
106
|
+
menuOpenId: typeAheadSurfaceContext.menuOpenId,
|
|
94
107
|
onClose,
|
|
95
108
|
query,
|
|
109
|
+
surfaceContext,
|
|
96
110
|
triggerHandler
|
|
97
|
-
}), [api, editorView, onClose, query, surface.inputMethod, triggerHandler]);
|
|
111
|
+
}), [api, editorView, onClose, query, surface.inputMethod, surfaceContext, triggerHandler, typeAheadSurfaceContext]);
|
|
98
112
|
const noOp = useCallback(() => {}, []);
|
|
99
113
|
const SurfaceProvider = surface.Provider;
|
|
100
114
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputQuery, {
|
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
import { isMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-is-menu-footer-section-key';
|
|
2
2
|
import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
|
|
3
3
|
import { resolveSurface, willComponentRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
4
|
-
export const buildTypeAheadMenuModel = (components, rootComponent, sectionOverflowLimit) => {
|
|
4
|
+
export const buildTypeAheadMenuModel = (components, rootComponent, sectionOverflowLimit, surfaceContext) => {
|
|
5
5
|
const {
|
|
6
6
|
root,
|
|
7
7
|
childrenMap,
|
|
8
8
|
topLevelChildren
|
|
9
9
|
} = resolveSurface(components, rootComponent);
|
|
10
|
+
if (!root || !willComponentRender(root, childrenMap, surfaceContext)) {
|
|
11
|
+
return {
|
|
12
|
+
footer: undefined,
|
|
13
|
+
root: undefined,
|
|
14
|
+
sections: []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
10
17
|
const sections = [];
|
|
11
18
|
let footer;
|
|
12
19
|
for (const section of topLevelChildren !== null && topLevelChildren !== void 0 ? topLevelChildren : []) {
|
|
13
20
|
var _childrenMap$get;
|
|
14
|
-
if (section.type !== 'menu-section' || !willComponentRender(section, childrenMap)) {
|
|
21
|
+
if (section.type !== 'menu-section' || !willComponentRender(section, childrenMap, surfaceContext)) {
|
|
15
22
|
continue;
|
|
16
23
|
}
|
|
17
24
|
const children = (_childrenMap$get = childrenMap.get(section.key)) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : [];
|
|
18
25
|
if (isMenuFooterSectionKey(section.key)) {
|
|
19
|
-
footer = children.find(child => child.type === 'menu-item' && willComponentRender(child, childrenMap));
|
|
26
|
+
footer = children.find(child => child.type === 'menu-item' && willComponentRender(child, childrenMap, surfaceContext));
|
|
20
27
|
continue;
|
|
21
28
|
}
|
|
22
29
|
let viewMoreItem;
|
|
23
30
|
for (let index = children.length - 1; index >= 0; index--) {
|
|
24
31
|
const child = children[index];
|
|
25
|
-
if ((child === null || child === void 0 ? void 0 : child.type) === 'menu-item' && isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap)) {
|
|
32
|
+
if ((child === null || child === void 0 ? void 0 : child.type) === 'menu-item' && isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap, surfaceContext)) {
|
|
26
33
|
viewMoreItem = child;
|
|
27
34
|
break;
|
|
28
35
|
}
|
|
29
36
|
}
|
|
30
|
-
const items = children.filter(child => child.type === 'menu-item' && !isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap));
|
|
37
|
+
const items = children.filter(child => child.type === 'menu-item' && !isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap, surfaceContext));
|
|
31
38
|
if (items.length === 0) {
|
|
32
39
|
continue;
|
|
33
40
|
}
|
|
@@ -11,27 +11,33 @@ const compareMatchedItems = (a, b) => a.score - b.score || a.sectionRank - b.sec
|
|
|
11
11
|
* Resolves registered menu items for a non-empty query. This intentionally has
|
|
12
12
|
* no empty-query path so browse behavior remains owned by buildTypeAheadMenuModel.
|
|
13
13
|
*/
|
|
14
|
-
export const getMatchingComponents = (
|
|
14
|
+
export const getMatchingComponents = ({
|
|
15
|
+
components,
|
|
16
|
+
rootComponent,
|
|
17
|
+
query,
|
|
18
|
+
formatMessage,
|
|
19
|
+
surfaceContext
|
|
20
|
+
}) => {
|
|
15
21
|
const {
|
|
16
22
|
childrenMap,
|
|
17
23
|
root,
|
|
18
24
|
topLevelChildren
|
|
19
25
|
} = resolveSurface(components, rootComponent);
|
|
20
|
-
if (!root || !topLevelChildren) {
|
|
26
|
+
if (!root || !willComponentRender(root, childrenMap, surfaceContext) || !topLevelChildren) {
|
|
21
27
|
return {
|
|
22
28
|
footer: undefined,
|
|
23
|
-
root,
|
|
29
|
+
root: undefined,
|
|
24
30
|
sections: []
|
|
25
31
|
};
|
|
26
32
|
}
|
|
27
33
|
const matches = new Map();
|
|
28
34
|
for (const section of topLevelChildren) {
|
|
29
|
-
if (section.type !== 'menu-section' || isMenuFooterSectionKey(section.key) || !willComponentRender(section, childrenMap)) {
|
|
35
|
+
if (section.type !== 'menu-section' || isMenuFooterSectionKey(section.key) || !willComponentRender(section, childrenMap, surfaceContext)) {
|
|
30
36
|
continue;
|
|
31
37
|
}
|
|
32
38
|
for (const item of (_childrenMap$get = childrenMap.get(section.key)) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []) {
|
|
33
39
|
var _childrenMap$get, _item$match, _match$score;
|
|
34
|
-
if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap)) {
|
|
40
|
+
if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap, surfaceContext)) {
|
|
35
41
|
continue;
|
|
36
42
|
}
|
|
37
43
|
const match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
|
|
@@ -13,6 +13,8 @@ export const TypeAheadQuickInsertItem = ({
|
|
|
13
13
|
const contextValue = useMemo(() => ({
|
|
14
14
|
editorView: quickInsertContext.editorView,
|
|
15
15
|
isOffline: quickInsertContext.isOffline,
|
|
16
|
+
menuOpenId: quickInsertContext.menuOpenId,
|
|
17
|
+
surfaceContext: quickInsertContext.surfaceContext,
|
|
16
18
|
item: {
|
|
17
19
|
id,
|
|
18
20
|
isSelected
|
|
@@ -11,8 +11,10 @@ export const TypeAheadQuickInsertProvider = ({
|
|
|
11
11
|
api,
|
|
12
12
|
editorView,
|
|
13
13
|
inputMethod,
|
|
14
|
+
menuOpenId,
|
|
14
15
|
onClose,
|
|
15
16
|
query,
|
|
17
|
+
surfaceContext,
|
|
16
18
|
triggerHandler
|
|
17
19
|
} = useTypeAheadContext();
|
|
18
20
|
const {
|
|
@@ -36,8 +38,10 @@ export const TypeAheadQuickInsertProvider = ({
|
|
|
36
38
|
const contextValue = useMemo(() => ({
|
|
37
39
|
editorView,
|
|
38
40
|
isOffline,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
menuOpenId,
|
|
42
|
+
select,
|
|
43
|
+
surfaceContext
|
|
44
|
+
}), [editorView, isOffline, menuOpenId, select, surfaceContext]);
|
|
41
45
|
return /*#__PURE__*/React.createElement(QuickInsertProvider, {
|
|
42
46
|
value: contextValue
|
|
43
47
|
}, children);
|
|
@@ -4,8 +4,10 @@ import "./RegisteredTypeAheadMenu.compiled.css";
|
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
5
|
import React, { useCallback, useId, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
6
6
|
import { useIntl } from 'react-intl';
|
|
7
|
+
import { TYPE_AHEAD_SURFACE_CONTEXT } from '@atlaskit/editor-common/type-ahead-surface-context';
|
|
7
8
|
import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
|
|
8
9
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
10
|
+
import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
9
11
|
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles/constants';
|
|
10
12
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
11
13
|
import { InputQuery } from '../InputQuery';
|
|
@@ -44,10 +46,20 @@ export var RegisteredTypeAheadMenu = function RegisteredTypeAheadMenu(_ref) {
|
|
|
44
46
|
var generatedId = useId();
|
|
45
47
|
var listId = "".concat(surface.listIdPrefix, "-").concat(generatedId);
|
|
46
48
|
var menuRef = useRef(null);
|
|
47
|
-
var _useState = useState(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
var _useState = useState(function () {
|
|
50
|
+
return {
|
|
51
|
+
menuOpenId: Symbol('type-ahead-menu-open')
|
|
52
|
+
};
|
|
53
|
+
}),
|
|
54
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
55
|
+
typeAheadSurfaceContext = _useState2[0];
|
|
56
|
+
var surfaceContext = useMemo(function () {
|
|
57
|
+
return createSurfaceContext(TYPE_AHEAD_SURFACE_CONTEXT, typeAheadSurfaceContext);
|
|
58
|
+
}, [typeAheadSurfaceContext]);
|
|
59
|
+
var _useState3 = useState(0),
|
|
60
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
61
|
+
selectedItemIndex = _useState4[0],
|
|
62
|
+
setSelectedItemIndex = _useState4[1];
|
|
51
63
|
var components = useMemo(function () {
|
|
52
64
|
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
53
65
|
return (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(surface.root.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
@@ -59,8 +71,14 @@ export var RegisteredTypeAheadMenu = function RegisteredTypeAheadMenu(_ref) {
|
|
|
59
71
|
});
|
|
60
72
|
}, [components]);
|
|
61
73
|
var menuModel = useMemo(function () {
|
|
62
|
-
return query === '' ? buildTypeAheadMenuModel(components, surface.root, hasSectionOverflowItems ? SECTION_OVERFLOW_LIMIT : undefined) : getMatchingComponents(
|
|
63
|
-
|
|
74
|
+
return query === '' ? buildTypeAheadMenuModel(components, surface.root, hasSectionOverflowItems ? SECTION_OVERFLOW_LIMIT : undefined, surfaceContext) : getMatchingComponents({
|
|
75
|
+
components: components,
|
|
76
|
+
rootComponent: surface.root,
|
|
77
|
+
query: query,
|
|
78
|
+
formatMessage: formatMessage,
|
|
79
|
+
surfaceContext: surfaceContext
|
|
80
|
+
});
|
|
81
|
+
}, [components, formatMessage, hasSectionOverflowItems, query, surfaceContext, surface.root]);
|
|
64
82
|
var rows = useMemo(function () {
|
|
65
83
|
return menuModel.sections.flat();
|
|
66
84
|
}, [menuModel.sections]);
|
|
@@ -106,11 +124,13 @@ export var RegisteredTypeAheadMenu = function RegisteredTypeAheadMenu(_ref) {
|
|
|
106
124
|
api: api,
|
|
107
125
|
editorView: editorView,
|
|
108
126
|
inputMethod: surface.inputMethod,
|
|
127
|
+
menuOpenId: typeAheadSurfaceContext.menuOpenId,
|
|
109
128
|
onClose: onClose,
|
|
110
129
|
query: query,
|
|
130
|
+
surfaceContext: surfaceContext,
|
|
111
131
|
triggerHandler: triggerHandler
|
|
112
132
|
};
|
|
113
|
-
}, [api, editorView, onClose, query, surface.inputMethod, triggerHandler]);
|
|
133
|
+
}, [api, editorView, onClose, query, surface.inputMethod, surfaceContext, triggerHandler, typeAheadSurfaceContext]);
|
|
114
134
|
var noOp = useCallback(function () {}, []);
|
|
115
135
|
var SurfaceProvider = surface.Provider;
|
|
116
136
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputQuery, {
|
|
@@ -5,11 +5,18 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
5
5
|
import { isMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-is-menu-footer-section-key';
|
|
6
6
|
import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
|
|
7
7
|
import { resolveSurface, willComponentRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
8
|
-
export var buildTypeAheadMenuModel = function buildTypeAheadMenuModel(components, rootComponent, sectionOverflowLimit) {
|
|
8
|
+
export var buildTypeAheadMenuModel = function buildTypeAheadMenuModel(components, rootComponent, sectionOverflowLimit, surfaceContext) {
|
|
9
9
|
var _resolveSurface = resolveSurface(components, rootComponent),
|
|
10
10
|
root = _resolveSurface.root,
|
|
11
11
|
childrenMap = _resolveSurface.childrenMap,
|
|
12
12
|
topLevelChildren = _resolveSurface.topLevelChildren;
|
|
13
|
+
if (!root || !willComponentRender(root, childrenMap, surfaceContext)) {
|
|
14
|
+
return {
|
|
15
|
+
footer: undefined,
|
|
16
|
+
root: undefined,
|
|
17
|
+
sections: []
|
|
18
|
+
};
|
|
19
|
+
}
|
|
13
20
|
var sections = [];
|
|
14
21
|
var footer;
|
|
15
22
|
var _iterator = _createForOfIteratorHelper(topLevelChildren !== null && topLevelChildren !== void 0 ? topLevelChildren : []),
|
|
@@ -18,26 +25,26 @@ export var buildTypeAheadMenuModel = function buildTypeAheadMenuModel(components
|
|
|
18
25
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
19
26
|
var _childrenMap$get;
|
|
20
27
|
var section = _step.value;
|
|
21
|
-
if (section.type !== 'menu-section' || !willComponentRender(section, childrenMap)) {
|
|
28
|
+
if (section.type !== 'menu-section' || !willComponentRender(section, childrenMap, surfaceContext)) {
|
|
22
29
|
continue;
|
|
23
30
|
}
|
|
24
31
|
var children = (_childrenMap$get = childrenMap.get(section.key)) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : [];
|
|
25
32
|
if (isMenuFooterSectionKey(section.key)) {
|
|
26
33
|
footer = children.find(function (child) {
|
|
27
|
-
return child.type === 'menu-item' && willComponentRender(child, childrenMap);
|
|
34
|
+
return child.type === 'menu-item' && willComponentRender(child, childrenMap, surfaceContext);
|
|
28
35
|
});
|
|
29
36
|
continue;
|
|
30
37
|
}
|
|
31
38
|
var viewMoreItem = void 0;
|
|
32
39
|
for (var index = children.length - 1; index >= 0; index--) {
|
|
33
40
|
var child = children[index];
|
|
34
|
-
if ((child === null || child === void 0 ? void 0 : child.type) === 'menu-item' && isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap)) {
|
|
41
|
+
if ((child === null || child === void 0 ? void 0 : child.type) === 'menu-item' && isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap, surfaceContext)) {
|
|
35
42
|
viewMoreItem = child;
|
|
36
43
|
break;
|
|
37
44
|
}
|
|
38
45
|
}
|
|
39
46
|
var items = children.filter(function (child) {
|
|
40
|
-
return child.type === 'menu-item' && !isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap);
|
|
47
|
+
return child.type === 'menu-item' && !isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap, surfaceContext);
|
|
41
48
|
});
|
|
42
49
|
if (items.length === 0) {
|
|
43
50
|
continue;
|
|
@@ -18,15 +18,20 @@ var compareMatchedItems = function compareMatchedItems(a, b) {
|
|
|
18
18
|
* Resolves registered menu items for a non-empty query. This intentionally has
|
|
19
19
|
* no empty-query path so browse behavior remains owned by buildTypeAheadMenuModel.
|
|
20
20
|
*/
|
|
21
|
-
export var getMatchingComponents = function getMatchingComponents(
|
|
21
|
+
export var getMatchingComponents = function getMatchingComponents(_ref) {
|
|
22
|
+
var components = _ref.components,
|
|
23
|
+
rootComponent = _ref.rootComponent,
|
|
24
|
+
query = _ref.query,
|
|
25
|
+
formatMessage = _ref.formatMessage,
|
|
26
|
+
surfaceContext = _ref.surfaceContext;
|
|
22
27
|
var _resolveSurface = resolveSurface(components, rootComponent),
|
|
23
28
|
childrenMap = _resolveSurface.childrenMap,
|
|
24
29
|
root = _resolveSurface.root,
|
|
25
30
|
topLevelChildren = _resolveSurface.topLevelChildren;
|
|
26
|
-
if (!root || !topLevelChildren) {
|
|
31
|
+
if (!root || !willComponentRender(root, childrenMap, surfaceContext) || !topLevelChildren) {
|
|
27
32
|
return {
|
|
28
33
|
footer: undefined,
|
|
29
|
-
root:
|
|
34
|
+
root: undefined,
|
|
30
35
|
sections: []
|
|
31
36
|
};
|
|
32
37
|
}
|
|
@@ -37,7 +42,7 @@ export var getMatchingComponents = function getMatchingComponents(components, ro
|
|
|
37
42
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
38
43
|
var _childrenMap$get;
|
|
39
44
|
var section = _step.value;
|
|
40
|
-
if (section.type !== 'menu-section' || isMenuFooterSectionKey(section.key) || !willComponentRender(section, childrenMap)) {
|
|
45
|
+
if (section.type !== 'menu-section' || isMenuFooterSectionKey(section.key) || !willComponentRender(section, childrenMap, surfaceContext)) {
|
|
41
46
|
continue;
|
|
42
47
|
}
|
|
43
48
|
var _iterator3 = _createForOfIteratorHelper((_childrenMap$get = childrenMap.get(section.key)) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []),
|
|
@@ -46,7 +51,7 @@ export var getMatchingComponents = function getMatchingComponents(components, ro
|
|
|
46
51
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
47
52
|
var _item$match, _match$score;
|
|
48
53
|
var item = _step3.value;
|
|
49
|
-
if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap)) {
|
|
54
|
+
if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap, surfaceContext)) {
|
|
50
55
|
continue;
|
|
51
56
|
}
|
|
52
57
|
var match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
|
|
@@ -13,6 +13,8 @@ export var TypeAheadQuickInsertItem = function TypeAheadQuickInsertItem(_ref) {
|
|
|
13
13
|
return {
|
|
14
14
|
editorView: quickInsertContext.editorView,
|
|
15
15
|
isOffline: quickInsertContext.isOffline,
|
|
16
|
+
menuOpenId: quickInsertContext.menuOpenId,
|
|
17
|
+
surfaceContext: quickInsertContext.surfaceContext,
|
|
16
18
|
item: {
|
|
17
19
|
id: id,
|
|
18
20
|
isSelected: isSelected
|
|
@@ -10,8 +10,10 @@ export var TypeAheadQuickInsertProvider = function TypeAheadQuickInsertProvider(
|
|
|
10
10
|
api = _useTypeAheadContext.api,
|
|
11
11
|
editorView = _useTypeAheadContext.editorView,
|
|
12
12
|
inputMethod = _useTypeAheadContext.inputMethod,
|
|
13
|
+
menuOpenId = _useTypeAheadContext.menuOpenId,
|
|
13
14
|
onClose = _useTypeAheadContext.onClose,
|
|
14
15
|
query = _useTypeAheadContext.query,
|
|
16
|
+
surfaceContext = _useTypeAheadContext.surfaceContext,
|
|
15
17
|
triggerHandler = _useTypeAheadContext.triggerHandler;
|
|
16
18
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['connectivity'], function (_ref2) {
|
|
17
19
|
var connectivityState = _ref2.connectivityState;
|
|
@@ -35,9 +37,11 @@ export var TypeAheadQuickInsertProvider = function TypeAheadQuickInsertProvider(
|
|
|
35
37
|
return {
|
|
36
38
|
editorView: editorView,
|
|
37
39
|
isOffline: isOffline,
|
|
38
|
-
|
|
40
|
+
menuOpenId: menuOpenId,
|
|
41
|
+
select: select,
|
|
42
|
+
surfaceContext: surfaceContext
|
|
39
43
|
};
|
|
40
|
-
}, [editorView, isOffline, select]);
|
|
44
|
+
}, [editorView, isOffline, menuOpenId, select, surfaceContext]);
|
|
41
45
|
return /*#__PURE__*/React.createElement(QuickInsertProvider, {
|
|
42
46
|
value: contextValue
|
|
43
47
|
}, children);
|
|
@@ -2,13 +2,16 @@ import type { Context } from 'react';
|
|
|
2
2
|
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { ExtractInjectionAPI, TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
5
6
|
import type { TypeAheadPlugin } from '../../typeAheadPluginType';
|
|
6
7
|
export type TypeAheadContextValue = {
|
|
7
8
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
8
9
|
editorView: EditorView;
|
|
9
10
|
inputMethod: INPUT_METHOD.QUICK_INSERT;
|
|
11
|
+
menuOpenId: symbol;
|
|
10
12
|
onClose: () => void;
|
|
11
13
|
query: string;
|
|
14
|
+
surfaceContext: SurfaceContext;
|
|
12
15
|
triggerHandler: TypeAheadHandler;
|
|
13
16
|
};
|
|
14
17
|
export declare const TypeAheadContext: Context<TypeAheadContextValue | null>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { SurfaceIdentifier } from '@atlaskit/editor-ui-control-model/surface-renderer/types';
|
|
2
|
-
import type { RegisterComponent, RegisterMenuItem, RegisterMenuSection } from '@atlaskit/editor-ui-control-model/types';
|
|
2
|
+
import type { RegisterComponent, RegisterMenuItem, RegisterMenuSection, SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
3
3
|
export type TypeAheadMenuSection = [RegisterMenuSection, ...RegisterMenuItem[]];
|
|
4
4
|
export type TypeAheadMenuModel = {
|
|
5
5
|
footer: RegisterMenuItem | undefined;
|
|
6
6
|
root: RegisterComponent | undefined;
|
|
7
7
|
sections: TypeAheadMenuSection[];
|
|
8
8
|
};
|
|
9
|
-
export declare const buildTypeAheadMenuModel: (components: RegisterComponent[], rootComponent: SurfaceIdentifier, sectionOverflowLimit?: number) => TypeAheadMenuModel;
|
|
9
|
+
export declare const buildTypeAheadMenuModel: (components: RegisterComponent[], rootComponent: SurfaceIdentifier, sectionOverflowLimit?: number, surfaceContext?: SurfaceContext) => TypeAheadMenuModel;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl';
|
|
2
2
|
import type { SurfaceIdentifier } from '@atlaskit/editor-ui-control-model/surface-renderer/types';
|
|
3
|
-
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model/types';
|
|
3
|
+
import type { RegisterComponent, SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
4
4
|
import type { TypeAheadMenuModel } from './buildTypeAheadMenuModel';
|
|
5
5
|
/**
|
|
6
6
|
* Resolves registered menu items for a non-empty query. This intentionally has
|
|
7
7
|
* no empty-query path so browse behavior remains owned by buildTypeAheadMenuModel.
|
|
8
8
|
*/
|
|
9
|
-
export declare const getMatchingComponents: (components
|
|
9
|
+
export declare const getMatchingComponents: ({ components, rootComponent, query, formatMessage, surfaceContext, }: {
|
|
10
|
+
components: RegisterComponent[];
|
|
11
|
+
formatMessage: IntlShape['formatMessage'];
|
|
12
|
+
query: string;
|
|
13
|
+
rootComponent: SurfaceIdentifier;
|
|
14
|
+
surfaceContext?: SurfaceContext;
|
|
15
|
+
}) => TypeAheadMenuModel;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-type-ahead",
|
|
3
|
-
"version": "16.1.
|
|
3
|
+
"version": "16.1.12",
|
|
4
4
|
"description": "Type-ahead plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"@atlaskit/editor-plugin-ui-control-registry": "^9.0.0",
|
|
31
31
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
32
32
|
"@atlaskit/editor-shared-styles": "^4.0.0",
|
|
33
|
-
"@atlaskit/editor-ui-control-model": "^2.
|
|
33
|
+
"@atlaskit/editor-ui-control-model": "^2.8.0",
|
|
34
34
|
"@atlaskit/feature-gate-js-client": "^6.0.0",
|
|
35
|
-
"@atlaskit/heading": "^7.
|
|
36
|
-
"@atlaskit/icon": "^37.
|
|
35
|
+
"@atlaskit/heading": "^7.1.0",
|
|
36
|
+
"@atlaskit/icon": "^37.5.0",
|
|
37
37
|
"@atlaskit/insm": "^2.0.0",
|
|
38
|
-
"@atlaskit/menu": "^10.
|
|
38
|
+
"@atlaskit/menu": "^10.1.0",
|
|
39
39
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
40
40
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
41
|
-
"@atlaskit/primitives": "^22.
|
|
41
|
+
"@atlaskit/primitives": "^22.4.0",
|
|
42
42
|
"@atlaskit/prosemirror-history": "^1.2.0",
|
|
43
43
|
"@atlaskit/prosemirror-input-rules": "^4.0.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
45
|
-
"@atlaskit/tokens": "^16.
|
|
46
|
-
"@atlaskit/visually-hidden": "^4.
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^157.0.0",
|
|
45
|
+
"@atlaskit/tokens": "^16.8.0",
|
|
46
|
+
"@atlaskit/visually-hidden": "^4.3.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0",
|
|
48
48
|
"@emotion/react": "^11.7.1",
|
|
49
49
|
"lodash": "^4.17.21",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"w3c-keyname": "^2.1.8"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^119.
|
|
56
|
+
"@atlaskit/editor-common": "^119.14.0",
|
|
57
57
|
"react": "^18.2.0 || ^19.2.0",
|
|
58
58
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
59
59
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|