@atlaskit/editor-plugin-type-ahead 10.2.1 → 10.3.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 +26 -0
- package/dist/cjs/pm-plugins/commands/update-list-items.js +3 -1
- package/dist/cjs/pm-plugins/main.js +1 -0
- package/dist/cjs/pm-plugins/reducer.js +7 -1
- package/dist/cjs/typeAheadPlugin.js +3 -1
- package/dist/cjs/ui/ContentComponent.js +10 -7
- package/dist/cjs/ui/TypeAheadList.js +126 -52
- package/dist/cjs/ui/TypeAheadMenu.js +3 -0
- package/dist/cjs/ui/TypeAheadPopup.js +3 -0
- package/dist/cjs/ui/WrapperTypeAhead.js +3 -1
- package/dist/cjs/ui/hooks/build-sectioned-result.js +131 -0
- package/dist/cjs/ui/hooks/use-load-items.js +12 -4
- package/dist/es2019/pm-plugins/commands/update-list-items.js +3 -2
- package/dist/es2019/pm-plugins/main.js +1 -0
- package/dist/es2019/pm-plugins/reducer.js +6 -1
- package/dist/es2019/typeAheadPlugin.js +3 -1
- package/dist/es2019/ui/ContentComponent.js +10 -7
- package/dist/es2019/ui/TypeAheadList.js +85 -23
- package/dist/es2019/ui/TypeAheadMenu.js +2 -0
- package/dist/es2019/ui/TypeAheadPopup.js +2 -0
- package/dist/es2019/ui/WrapperTypeAhead.js +3 -1
- package/dist/es2019/ui/hooks/build-sectioned-result.js +83 -0
- package/dist/es2019/ui/hooks/use-load-items.js +13 -4
- package/dist/esm/pm-plugins/commands/update-list-items.js +3 -1
- package/dist/esm/pm-plugins/main.js +1 -0
- package/dist/esm/pm-plugins/reducer.js +7 -1
- package/dist/esm/typeAheadPlugin.js +3 -1
- package/dist/esm/ui/ContentComponent.js +10 -7
- package/dist/esm/ui/TypeAheadList.js +126 -52
- package/dist/esm/ui/TypeAheadMenu.js +3 -0
- package/dist/esm/ui/TypeAheadPopup.js +3 -0
- package/dist/esm/ui/WrapperTypeAhead.js +3 -1
- package/dist/esm/ui/hooks/build-sectioned-result.js +124 -0
- package/dist/esm/ui/hooks/use-load-items.js +12 -4
- package/dist/types/pm-plugins/commands/update-list-items.d.ts +2 -1
- package/dist/types/types/index.d.ts +8 -0
- package/dist/types/ui/TypeAheadList.d.ts +3 -1
- package/dist/types/ui/TypeAheadPopup.d.ts +3 -2
- package/dist/types/ui/hooks/build-sectioned-result.d.ts +11 -0
- package/dist/types/ui/hooks/use-load-items.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/commands/update-list-items.d.ts +2 -1
- package/dist/types-ts4.5/types/index.d.ts +8 -0
- package/dist/types-ts4.5/ui/TypeAheadList.d.ts +3 -1
- package/dist/types-ts4.5/ui/TypeAheadPopup.d.ts +3 -2
- package/dist/types-ts4.5/ui/hooks/build-sectioned-result.d.ts +11 -0
- package/dist/types-ts4.5/ui/hooks/use-load-items.d.ts +2 -1
- package/package.json +4 -4
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
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; } } }; }
|
|
3
|
+
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; } }
|
|
4
|
+
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; }
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
|
+
export var buildSectionedResult = function buildSectionedResult(_ref) {
|
|
7
|
+
var _triggerHandler$getSe;
|
|
8
|
+
var items = _ref.items,
|
|
9
|
+
triggerHandler = _ref.triggerHandler,
|
|
10
|
+
intl = _ref.intl;
|
|
11
|
+
if (!editorExperiment('platform_editor_agent_mentions', true) || !intl) {
|
|
12
|
+
return {
|
|
13
|
+
items: items,
|
|
14
|
+
sections: []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
var sectionDefinitions = (_triggerHandler$getSe = triggerHandler.getSections) === null || _triggerHandler$getSe === void 0 ? void 0 : _triggerHandler$getSe.call(triggerHandler, {
|
|
18
|
+
intl: intl
|
|
19
|
+
});
|
|
20
|
+
if (!sectionDefinitions || sectionDefinitions.length === 0) {
|
|
21
|
+
return {
|
|
22
|
+
items: items,
|
|
23
|
+
sections: []
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Track which item indexes have been claimed by a section, or excluded (matched a section but
|
|
28
|
+
// cut by that section's limit). Items excluded by limit should not appear anywhere in the output.
|
|
29
|
+
var assignedToSection = new Set();
|
|
30
|
+
var excludedByLimit = new Set();
|
|
31
|
+
var groupedBySection = new Map();
|
|
32
|
+
var _iterator = _createForOfIteratorHelper(sectionDefinitions),
|
|
33
|
+
_step;
|
|
34
|
+
try {
|
|
35
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
36
|
+
var section = _step.value;
|
|
37
|
+
var matchingIndexes = [];
|
|
38
|
+
for (var _i = 0; _i < items.length; _i++) {
|
|
39
|
+
if (assignedToSection.has(_i) || excludedByLimit.has(_i)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (section.filter(items[_i])) {
|
|
43
|
+
matchingIndexes.push(_i);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
var acceptedIndexes = section.limit !== undefined ? matchingIndexes.slice(0, section.limit) : matchingIndexes;
|
|
47
|
+
var rejectedByLimit = matchingIndexes.slice(acceptedIndexes.length);
|
|
48
|
+
var _iterator3 = _createForOfIteratorHelper(acceptedIndexes),
|
|
49
|
+
_step3;
|
|
50
|
+
try {
|
|
51
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
52
|
+
var _i2 = _step3.value;
|
|
53
|
+
assignedToSection.add(_i2);
|
|
54
|
+
}
|
|
55
|
+
} catch (err) {
|
|
56
|
+
_iterator3.e(err);
|
|
57
|
+
} finally {
|
|
58
|
+
_iterator3.f();
|
|
59
|
+
}
|
|
60
|
+
var _iterator4 = _createForOfIteratorHelper(rejectedByLimit),
|
|
61
|
+
_step4;
|
|
62
|
+
try {
|
|
63
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
64
|
+
var _i3 = _step4.value;
|
|
65
|
+
excludedByLimit.add(_i3);
|
|
66
|
+
}
|
|
67
|
+
} catch (err) {
|
|
68
|
+
_iterator4.e(err);
|
|
69
|
+
} finally {
|
|
70
|
+
_iterator4.f();
|
|
71
|
+
}
|
|
72
|
+
if (acceptedIndexes.length === 0) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
groupedBySection.set(section.id, {
|
|
76
|
+
indexes: acceptedIndexes,
|
|
77
|
+
section: section
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
} catch (err) {
|
|
81
|
+
_iterator.e(err);
|
|
82
|
+
} finally {
|
|
83
|
+
_iterator.f();
|
|
84
|
+
}
|
|
85
|
+
var flattenedItems = [];
|
|
86
|
+
var sections = [];
|
|
87
|
+
var _iterator2 = _createForOfIteratorHelper(sectionDefinitions),
|
|
88
|
+
_step2;
|
|
89
|
+
try {
|
|
90
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
91
|
+
var _section = _step2.value;
|
|
92
|
+
var grouped = groupedBySection.get(_section.id);
|
|
93
|
+
if (!grouped) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
var startIndex = flattenedItems.length;
|
|
97
|
+
flattenedItems.push.apply(flattenedItems, _toConsumableArray(grouped.indexes.map(function (i) {
|
|
98
|
+
return items[i];
|
|
99
|
+
})));
|
|
100
|
+
var endIndex = flattenedItems.length - 1;
|
|
101
|
+
sections.push({
|
|
102
|
+
endIndex: endIndex,
|
|
103
|
+
id: _section.id,
|
|
104
|
+
startIndex: startIndex,
|
|
105
|
+
title: _section.title
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Append items not claimed by any section and not excluded by a limit
|
|
110
|
+
} catch (err) {
|
|
111
|
+
_iterator2.e(err);
|
|
112
|
+
} finally {
|
|
113
|
+
_iterator2.f();
|
|
114
|
+
}
|
|
115
|
+
for (var i = 0; i < items.length; i++) {
|
|
116
|
+
if (!assignedToSection.has(i) && !excludedByLimit.has(i)) {
|
|
117
|
+
flattenedItems.push(items[i]);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
items: flattenedItems,
|
|
122
|
+
sections: sections
|
|
123
|
+
};
|
|
124
|
+
};
|
|
@@ -5,8 +5,9 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
5
5
|
import { clearListError } from '../../pm-plugins/commands/clear-list-error';
|
|
6
6
|
import { updateListError } from '../../pm-plugins/commands/update-list-error';
|
|
7
7
|
import { updateListItem } from '../../pm-plugins/commands/update-list-items';
|
|
8
|
+
import { buildSectionedResult } from './build-sectioned-result';
|
|
8
9
|
var EMPTY_LIST_ITEM = [];
|
|
9
|
-
export var useLoadItems = function useLoadItems(triggerHandler, editorView, query, showViewMore, api) {
|
|
10
|
+
export var useLoadItems = function useLoadItems(triggerHandler, editorView, query, showViewMore, api, intl) {
|
|
10
11
|
var _useState = useState(EMPTY_LIST_ITEM),
|
|
11
12
|
_useState2 = _slicedToArray(_useState, 2),
|
|
12
13
|
items = _useState2[0],
|
|
@@ -37,7 +38,14 @@ export var useLoadItems = function useLoadItems(triggerHandler, editorView, quer
|
|
|
37
38
|
var emptyItem = result.length === 0 && expValEquals('platform_editor_insert_menu_ai', 'isEnabled', true) ? (_triggerHandler$getEm = triggerHandler.getEmptyItem) === null || _triggerHandler$getEm === void 0 ? void 0 : _triggerHandler$getEm.call(triggerHandler, {
|
|
38
39
|
editorState: editorView.state
|
|
39
40
|
}) : undefined;
|
|
40
|
-
var
|
|
41
|
+
var rawList = result.length > 0 ? result : emptyItem ? [emptyItem] : EMPTY_LIST_ITEM;
|
|
42
|
+
var _buildSectionedResult = buildSectionedResult({
|
|
43
|
+
items: rawList,
|
|
44
|
+
triggerHandler: triggerHandler,
|
|
45
|
+
intl: intl !== null && intl !== void 0 ? intl : null
|
|
46
|
+
}),
|
|
47
|
+
list = _buildSectionedResult.items,
|
|
48
|
+
sections = _buildSectionedResult.sections;
|
|
41
49
|
if (componentIsMounted.current) {
|
|
42
50
|
setItems(list);
|
|
43
51
|
}
|
|
@@ -47,7 +55,7 @@ export var useLoadItems = function useLoadItems(triggerHandler, editorView, quer
|
|
|
47
55
|
title: 'View more'
|
|
48
56
|
};
|
|
49
57
|
queueMicrotask(function () {
|
|
50
|
-
updateListItem(showViewMore ? list.concat(viewMoreItem) : list)(view.state, view.dispatch);
|
|
58
|
+
updateListItem(showViewMore ? list.concat(viewMoreItem) : list, sections)(view.state, view.dispatch);
|
|
51
59
|
});
|
|
52
60
|
}).catch(function (e) {
|
|
53
61
|
if (editorExperiment('platform_editor_offline_editing_web', true)) {
|
|
@@ -65,7 +73,7 @@ export var useLoadItems = function useLoadItems(triggerHandler, editorView, quer
|
|
|
65
73
|
// ignore because EditorView is mutable but we don't want to
|
|
66
74
|
// call loadItems when it changes, only when the query changes
|
|
67
75
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
|
-
}, [triggerHandler, query]);
|
|
76
|
+
}, [triggerHandler, query, intl]);
|
|
69
77
|
useEffect(function () {
|
|
70
78
|
return function () {
|
|
71
79
|
componentIsMounted.current = false;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { Command, TypeAheadItem } from '@atlaskit/editor-common/types';
|
|
2
|
-
|
|
2
|
+
import type { TypeAheadResolvedSection } from '../../types';
|
|
3
|
+
export declare const updateListItem: (items: Array<TypeAheadItem>, sections?: Array<TypeAheadResolvedSection>) => Command;
|
|
@@ -35,11 +35,18 @@ export type TypeAheadPluginState = {
|
|
|
35
35
|
* If true, removes the trigger character from query when typeahead is closed
|
|
36
36
|
*/
|
|
37
37
|
removePrefixTriggerOnCancel?: boolean;
|
|
38
|
+
sections: Array<TypeAheadResolvedSection>;
|
|
38
39
|
selectedIndex: number;
|
|
39
40
|
stats: TypeAheadStatsSerializable | null;
|
|
40
41
|
triggerHandler?: TypeAheadHandler;
|
|
41
42
|
typeAheadHandlers: Array<TypeAheadHandler>;
|
|
42
43
|
};
|
|
44
|
+
export type TypeAheadResolvedSection = {
|
|
45
|
+
endIndex: number;
|
|
46
|
+
id: string;
|
|
47
|
+
startIndex: number;
|
|
48
|
+
title: string;
|
|
49
|
+
};
|
|
43
50
|
export type OnInsertSelectedItemProps = {
|
|
44
51
|
index: number;
|
|
45
52
|
mode: SelectItemMode;
|
|
@@ -88,6 +95,7 @@ export interface TypeAheadPluginSharedState {
|
|
|
88
95
|
isOpen: boolean;
|
|
89
96
|
items: Array<TypeAheadItem>;
|
|
90
97
|
query: string;
|
|
98
|
+
sections: Array<TypeAheadResolvedSection>;
|
|
91
99
|
selectedIndex: number;
|
|
92
100
|
triggerHandler?: TypeAheadHandler;
|
|
93
101
|
}
|
|
@@ -9,7 +9,7 @@ import type { ExtractInjectionAPI, TypeAheadItem } from '@atlaskit/editor-common
|
|
|
9
9
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import type { InputMethodType } from '../pm-plugins/analytics';
|
|
11
11
|
import type { TypeAheadPlugin } from '../typeAheadPluginType';
|
|
12
|
-
import type { TypeAheadHandler } from '../types';
|
|
12
|
+
import type { TypeAheadHandler, TypeAheadResolvedSection } from '../types';
|
|
13
13
|
export declare const TypeAheadList: React.FC<WithIntlProps<{
|
|
14
14
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
15
15
|
decorationElement: HTMLElement;
|
|
@@ -20,6 +20,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
|
|
|
20
20
|
moreElementsInQuickInsertViewEnabled?: boolean;
|
|
21
21
|
onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
|
|
22
22
|
onMoreOptionsClicked?: () => void;
|
|
23
|
+
sections?: Array<TypeAheadResolvedSection>;
|
|
23
24
|
selectedIndex: number;
|
|
24
25
|
showMoreOptionsButton?: boolean;
|
|
25
26
|
triggerHandler?: TypeAheadHandler;
|
|
@@ -34,6 +35,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
|
|
|
34
35
|
moreElementsInQuickInsertViewEnabled?: boolean;
|
|
35
36
|
onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
|
|
36
37
|
onMoreOptionsClicked?: () => void;
|
|
38
|
+
sections?: Array<TypeAheadResolvedSection>;
|
|
37
39
|
selectedIndex: number;
|
|
38
40
|
showMoreOptionsButton?: boolean;
|
|
39
41
|
triggerHandler?: TypeAheadHandler;
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
8
|
-
import type { ExtractInjectionAPI,
|
|
8
|
+
import type { ExtractInjectionAPI, TypeAheadItem, TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
9
9
|
import type { DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import { CloseSelectionOptions } from '../pm-plugins/constants';
|
|
11
11
|
import type { TypeAheadPlugin } from '../typeAheadPluginType';
|
|
12
|
-
import type { OnSelectItem, TypeAheadErrorInfo } from '../types';
|
|
12
|
+
import type { OnSelectItem, TypeAheadErrorInfo, TypeAheadResolvedSection } from '../types';
|
|
13
13
|
type TypeAheadPopupProps = {
|
|
14
14
|
anchorElement: HTMLElement;
|
|
15
15
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
@@ -24,6 +24,7 @@ type TypeAheadPopupProps = {
|
|
|
24
24
|
errorInfo: TypeAheadErrorInfo;
|
|
25
25
|
isEmptyQuery: boolean;
|
|
26
26
|
items: Array<TypeAheadItem>;
|
|
27
|
+
sections?: Array<TypeAheadResolvedSection>;
|
|
27
28
|
onItemInsert: (mode: SelectItemMode, index: number) => void;
|
|
28
29
|
popupsBoundariesElement?: HTMLElement;
|
|
29
30
|
popupsMountPoint?: HTMLElement;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl';
|
|
2
|
+
import type { TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { TypeAheadResolvedSection } from '../../types';
|
|
4
|
+
export declare const buildSectionedResult: ({ items, triggerHandler, intl, }: {
|
|
5
|
+
items: Array<TypeAheadItem>;
|
|
6
|
+
triggerHandler: TypeAheadHandler;
|
|
7
|
+
intl: IntlShape | null;
|
|
8
|
+
}) => {
|
|
9
|
+
items: Array<TypeAheadItem>;
|
|
10
|
+
sections: Array<TypeAheadResolvedSection>;
|
|
11
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl';
|
|
1
2
|
import type { ExtractInjectionAPI, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
4
|
import type { TypeAheadPlugin } from '../../typeAheadPluginType';
|
|
4
|
-
export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string, showViewMore?: boolean, api?: ExtractInjectionAPI<TypeAheadPlugin> | undefined) => Array<TypeAheadItem>;
|
|
5
|
+
export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string, showViewMore?: boolean, api?: ExtractInjectionAPI<TypeAheadPlugin> | undefined, intl?: IntlShape) => Array<TypeAheadItem>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { Command, TypeAheadItem } from '@atlaskit/editor-common/types';
|
|
2
|
-
|
|
2
|
+
import type { TypeAheadResolvedSection } from '../../types';
|
|
3
|
+
export declare const updateListItem: (items: Array<TypeAheadItem>, sections?: Array<TypeAheadResolvedSection>) => Command;
|
|
@@ -35,11 +35,18 @@ export type TypeAheadPluginState = {
|
|
|
35
35
|
* If true, removes the trigger character from query when typeahead is closed
|
|
36
36
|
*/
|
|
37
37
|
removePrefixTriggerOnCancel?: boolean;
|
|
38
|
+
sections: Array<TypeAheadResolvedSection>;
|
|
38
39
|
selectedIndex: number;
|
|
39
40
|
stats: TypeAheadStatsSerializable | null;
|
|
40
41
|
triggerHandler?: TypeAheadHandler;
|
|
41
42
|
typeAheadHandlers: Array<TypeAheadHandler>;
|
|
42
43
|
};
|
|
44
|
+
export type TypeAheadResolvedSection = {
|
|
45
|
+
endIndex: number;
|
|
46
|
+
id: string;
|
|
47
|
+
startIndex: number;
|
|
48
|
+
title: string;
|
|
49
|
+
};
|
|
43
50
|
export type OnInsertSelectedItemProps = {
|
|
44
51
|
index: number;
|
|
45
52
|
mode: SelectItemMode;
|
|
@@ -88,6 +95,7 @@ export interface TypeAheadPluginSharedState {
|
|
|
88
95
|
isOpen: boolean;
|
|
89
96
|
items: Array<TypeAheadItem>;
|
|
90
97
|
query: string;
|
|
98
|
+
sections: Array<TypeAheadResolvedSection>;
|
|
91
99
|
selectedIndex: number;
|
|
92
100
|
triggerHandler?: TypeAheadHandler;
|
|
93
101
|
}
|
|
@@ -9,7 +9,7 @@ import type { ExtractInjectionAPI, TypeAheadItem } from '@atlaskit/editor-common
|
|
|
9
9
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import type { InputMethodType } from '../pm-plugins/analytics';
|
|
11
11
|
import type { TypeAheadPlugin } from '../typeAheadPluginType';
|
|
12
|
-
import type { TypeAheadHandler } from '../types';
|
|
12
|
+
import type { TypeAheadHandler, TypeAheadResolvedSection } from '../types';
|
|
13
13
|
export declare const TypeAheadList: React.FC<WithIntlProps<{
|
|
14
14
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
15
15
|
decorationElement: HTMLElement;
|
|
@@ -20,6 +20,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
|
|
|
20
20
|
moreElementsInQuickInsertViewEnabled?: boolean;
|
|
21
21
|
onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
|
|
22
22
|
onMoreOptionsClicked?: () => void;
|
|
23
|
+
sections?: Array<TypeAheadResolvedSection>;
|
|
23
24
|
selectedIndex: number;
|
|
24
25
|
showMoreOptionsButton?: boolean;
|
|
25
26
|
triggerHandler?: TypeAheadHandler;
|
|
@@ -34,6 +35,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
|
|
|
34
35
|
moreElementsInQuickInsertViewEnabled?: boolean;
|
|
35
36
|
onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
|
|
36
37
|
onMoreOptionsClicked?: () => void;
|
|
38
|
+
sections?: Array<TypeAheadResolvedSection>;
|
|
37
39
|
selectedIndex: number;
|
|
38
40
|
showMoreOptionsButton?: boolean;
|
|
39
41
|
triggerHandler?: TypeAheadHandler;
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
8
|
-
import type { ExtractInjectionAPI,
|
|
8
|
+
import type { ExtractInjectionAPI, TypeAheadItem, TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
9
9
|
import type { DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import { CloseSelectionOptions } from '../pm-plugins/constants';
|
|
11
11
|
import type { TypeAheadPlugin } from '../typeAheadPluginType';
|
|
12
|
-
import type { OnSelectItem, TypeAheadErrorInfo } from '../types';
|
|
12
|
+
import type { OnSelectItem, TypeAheadErrorInfo, TypeAheadResolvedSection } from '../types';
|
|
13
13
|
type TypeAheadPopupProps = {
|
|
14
14
|
anchorElement: HTMLElement;
|
|
15
15
|
api: ExtractInjectionAPI<TypeAheadPlugin> | undefined;
|
|
@@ -24,6 +24,7 @@ type TypeAheadPopupProps = {
|
|
|
24
24
|
errorInfo: TypeAheadErrorInfo;
|
|
25
25
|
isEmptyQuery: boolean;
|
|
26
26
|
items: Array<TypeAheadItem>;
|
|
27
|
+
sections?: Array<TypeAheadResolvedSection>;
|
|
27
28
|
onItemInsert: (mode: SelectItemMode, index: number) => void;
|
|
28
29
|
popupsBoundariesElement?: HTMLElement;
|
|
29
30
|
popupsMountPoint?: HTMLElement;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl';
|
|
2
|
+
import type { TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { TypeAheadResolvedSection } from '../../types';
|
|
4
|
+
export declare const buildSectionedResult: ({ items, triggerHandler, intl, }: {
|
|
5
|
+
items: Array<TypeAheadItem>;
|
|
6
|
+
triggerHandler: TypeAheadHandler;
|
|
7
|
+
intl: IntlShape | null;
|
|
8
|
+
}) => {
|
|
9
|
+
items: Array<TypeAheadItem>;
|
|
10
|
+
sections: Array<TypeAheadResolvedSection>;
|
|
11
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl';
|
|
1
2
|
import type { ExtractInjectionAPI, TypeAheadHandler, TypeAheadItem } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
4
|
import type { TypeAheadPlugin } from '../../typeAheadPluginType';
|
|
4
|
-
export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string, showViewMore?: boolean, api?: ExtractInjectionAPI<TypeAheadPlugin> | undefined) => Array<TypeAheadItem>;
|
|
5
|
+
export declare const useLoadItems: (triggerHandler: TypeAheadHandler, editorView: EditorView, query: string, showViewMore?: boolean, api?: ExtractInjectionAPI<TypeAheadPlugin> | undefined, intl?: IntlShape) => Array<TypeAheadItem>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-type-ahead",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0",
|
|
4
4
|
"description": "Type-ahead plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"atlaskit:src": "src/index.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaskit/adf-schema": "^52.
|
|
32
|
+
"@atlaskit/adf-schema": "^52.15.0",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^10.1.0",
|
|
34
34
|
"@atlaskit/editor-plugin-connectivity": "^10.1.0",
|
|
35
35
|
"@atlaskit/editor-plugin-context-panel": "^12.1.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@atlaskit/primitives": "^19.0.0",
|
|
45
45
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
46
46
|
"@atlaskit/prosemirror-input-rules": "^3.7.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^84.3.0",
|
|
48
48
|
"@atlaskit/tokens": "^13.0.0",
|
|
49
49
|
"@atlaskit/visually-hidden": "^3.1.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"w3c-keyname": "^2.1.8"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@atlaskit/editor-common": "^114.
|
|
59
|
+
"@atlaskit/editor-common": "^114.50.0",
|
|
60
60
|
"react": "^18.2.0",
|
|
61
61
|
"react-dom": "^18.2.0",
|
|
62
62
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|