@atlaskit/editor-plugin-quick-insert 30.0.0 → 30.0.2
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 +18 -0
- package/dist/cjs/ui/RegistryElementBrowser/model.js +17 -3
- package/dist/cjs/ui/registered-menu/get-quick-insert-menu-model.js +32 -15
- package/dist/es2019/ui/RegistryElementBrowser/model.js +15 -3
- package/dist/es2019/ui/registered-menu/get-quick-insert-menu-model.js +17 -3
- package/dist/esm/ui/RegistryElementBrowser/model.js +17 -3
- package/dist/esm/ui/registered-menu/get-quick-insert-menu-model.js +32 -15
- package/package.json +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-quick-insert
|
|
2
2
|
|
|
3
|
+
## 30.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 30.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`f2e219b3ca00d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2e219b3ca00d) -
|
|
14
|
+
Rank slash command search results with matcher priority groups while retaining the current
|
|
15
|
+
ordering for items without a group. Recommended results for audited search terms, including Jira,
|
|
16
|
+
receive fixed scores in group 0 under platform_editor_slash_command. The Element Browser applies
|
|
17
|
+
the same priority groups to its search results. Menu item matchers now require the item's key in
|
|
18
|
+
their context; callers must pass the registration key.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 30.0.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -127,17 +127,31 @@ var getRegistryElementBrowserItems = exports.getRegistryElementBrowserItems = fu
|
|
|
127
127
|
if (!normalizedQuery) {
|
|
128
128
|
return itemsWithDescriptions;
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
var matches = itemsWithDescriptions.flatMap(function (item) {
|
|
131
131
|
var _item$registration$ma, _item$registration;
|
|
132
132
|
var result = (_item$registration$ma = (_item$registration = item.registration).match) === null || _item$registration$ma === void 0 ? void 0 : _item$registration$ma.call(_item$registration, {
|
|
133
133
|
formatMessage: formatMessage,
|
|
134
|
+
itemKey: item.registration.key,
|
|
134
135
|
query: normalizedQuery
|
|
135
136
|
});
|
|
136
137
|
return result ? [_objectSpread(_objectSpread({}, item), {}, {
|
|
138
|
+
priorityGroup: result.priorityGroup !== undefined && Number.isFinite(result.priorityGroup) ? result.priorityGroup : undefined,
|
|
137
139
|
score: Math.min(1, Math.max(0, result.score))
|
|
138
140
|
})] : [];
|
|
139
|
-
})
|
|
141
|
+
});
|
|
142
|
+
var prioritized = matches.filter(function (_ref4) {
|
|
143
|
+
var priorityGroup = _ref4.priorityGroup;
|
|
144
|
+
return priorityGroup !== undefined;
|
|
145
|
+
});
|
|
146
|
+
var unprioritized = matches.filter(function (_ref5) {
|
|
147
|
+
var priorityGroup = _ref5.priorityGroup;
|
|
148
|
+
return priorityGroup === undefined;
|
|
149
|
+
});
|
|
150
|
+
return [].concat((0, _toConsumableArray2.default)(prioritized.sort(function (left, right) {
|
|
151
|
+
var _right$priorityGroup, _left$priorityGroup;
|
|
152
|
+
return ((_right$priorityGroup = right.priorityGroup) !== null && _right$priorityGroup !== void 0 ? _right$priorityGroup : 0) - ((_left$priorityGroup = left.priorityGroup) !== null && _left$priorityGroup !== void 0 ? _left$priorityGroup : 0) || left.score - right.score || compareRanks(left.ranks, right.ranks) || left.registration.key.localeCompare(right.registration.key);
|
|
153
|
+
})), (0, _toConsumableArray2.default)(unprioritized.sort(function (left, right) {
|
|
140
154
|
var _left$ranks$, _right$ranks$;
|
|
141
155
|
return ((_left$ranks$ = left.ranks[0]) !== null && _left$ranks$ !== void 0 ? _left$ranks$ : 0) - ((_right$ranks$ = right.ranks[0]) !== null && _right$ranks$ !== void 0 ? _right$ranks$ : 0) || left.score - right.score || compareRanks(left.ranks, right.ranks) || left.registration.key.localeCompare(right.registration.key);
|
|
142
|
-
});
|
|
156
|
+
})));
|
|
143
157
|
};
|
|
@@ -41,6 +41,10 @@ var compareMatchedItems = function compareMatchedItems(a, b) {
|
|
|
41
41
|
var compareSearchResults = function compareSearchResults(a, b) {
|
|
42
42
|
return a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
|
|
43
43
|
};
|
|
44
|
+
var comparePrioritizedSearchResults = function comparePrioritizedSearchResults(a, b) {
|
|
45
|
+
var _b$priorityGroup, _a$priorityGroup;
|
|
46
|
+
return ((_b$priorityGroup = b.priorityGroup) !== null && _b$priorityGroup !== void 0 ? _b$priorityGroup : 0) - ((_a$priorityGroup = a.priorityGroup) !== null && _a$priorityGroup !== void 0 ? _a$priorityGroup : 0) || compareSearchResults(a, b);
|
|
47
|
+
};
|
|
44
48
|
var getSearchResults = function getSearchResults(matches) {
|
|
45
49
|
var topMatches = Array.from(matches).sort(compareSearchResults).slice(0, SEARCH_TOP_MATCH_LIMIT);
|
|
46
50
|
var topMatchIdentities = new Set(topMatches.map(function (_ref) {
|
|
@@ -129,6 +133,7 @@ var buildSearchSections = function buildSearchSections(_ref5) {
|
|
|
129
133
|
}
|
|
130
134
|
var match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
|
|
131
135
|
formatMessage: formatMessage,
|
|
136
|
+
itemKey: item.key,
|
|
132
137
|
query: query
|
|
133
138
|
});
|
|
134
139
|
if (item.match && match === null) {
|
|
@@ -138,6 +143,7 @@ var buildSearchSections = function buildSearchSections(_ref5) {
|
|
|
138
143
|
identity: "".concat(item.type, ":").concat(item.key),
|
|
139
144
|
item: item,
|
|
140
145
|
itemRank: getParentRank(item, section.key),
|
|
146
|
+
priorityGroup: (match === null || match === void 0 ? void 0 : match.priorityGroup) !== undefined && Number.isFinite(match.priorityGroup) ? match.priorityGroup : undefined,
|
|
141
147
|
score: Math.min(1, Math.max(0, (_match$score = match === null || match === void 0 ? void 0 : match.score) !== null && _match$score !== void 0 ? _match$score : 0)),
|
|
142
148
|
sourceIndex: (_sourceIndexByCompone = sourceIndexByComponent.get(item)) !== null && _sourceIndexByCompone !== void 0 ? _sourceIndexByCompone : Number.MAX_SAFE_INTEGER,
|
|
143
149
|
sectionRank: getParentRank(section, root.key)
|
|
@@ -159,11 +165,22 @@ var buildSearchSections = function buildSearchSections(_ref5) {
|
|
|
159
165
|
_iterator2.f();
|
|
160
166
|
}
|
|
161
167
|
var uniqueMatches = Array.from(matches.values()).sort(compareMatchedItems);
|
|
162
|
-
var
|
|
163
|
-
|
|
168
|
+
var prioritizedMatches = uniqueMatches.filter(function (_ref6) {
|
|
169
|
+
var priorityGroup = _ref6.priorityGroup;
|
|
170
|
+
return priorityGroup !== undefined;
|
|
171
|
+
});
|
|
172
|
+
var unprioritizedMatches = uniqueMatches.filter(function (_ref7) {
|
|
173
|
+
var priorityGroup = _ref7.priorityGroup;
|
|
174
|
+
return priorityGroup === undefined;
|
|
175
|
+
});
|
|
176
|
+
var orderedSearchResults = [].concat((0, _toConsumableArray2.default)(prioritizedMatches.sort(comparePrioritizedSearchResults).map(function (_ref8) {
|
|
177
|
+
var item = _ref8.item;
|
|
178
|
+
return item;
|
|
179
|
+
})), (0, _toConsumableArray2.default)(getSearchResults(unprioritizedMatches)));
|
|
180
|
+
if (orderedSearchResults.length > 0) {
|
|
164
181
|
return {
|
|
165
182
|
fallbackItems: [],
|
|
166
|
-
sections: [[SEARCH_RESULTS_HEADING].concat((0, _toConsumableArray2.default)(
|
|
183
|
+
sections: [[SEARCH_RESULTS_HEADING].concat((0, _toConsumableArray2.default)(orderedSearchResults))]
|
|
167
184
|
};
|
|
168
185
|
}
|
|
169
186
|
var fallbackItem = contentSections.flatMap(function (section) {
|
|
@@ -182,14 +199,14 @@ var buildSearchSections = function buildSearchSections(_ref5) {
|
|
|
182
199
|
* Builds the registered quick-insert menu model. An empty query browses every
|
|
183
200
|
* category; a non-empty query returns ranked matches. The footer is shared by both.
|
|
184
201
|
*/
|
|
185
|
-
var getQuickInsertMenuModel = exports.getQuickInsertMenuModel = function getQuickInsertMenuModel(
|
|
186
|
-
var components =
|
|
187
|
-
formatMessage =
|
|
188
|
-
getItemRank =
|
|
189
|
-
query =
|
|
190
|
-
rootComponent =
|
|
191
|
-
selectCategoryItems =
|
|
192
|
-
surfaceContext =
|
|
202
|
+
var getQuickInsertMenuModel = exports.getQuickInsertMenuModel = function getQuickInsertMenuModel(_ref9) {
|
|
203
|
+
var components = _ref9.components,
|
|
204
|
+
formatMessage = _ref9.formatMessage,
|
|
205
|
+
getItemRank = _ref9.getItemRank,
|
|
206
|
+
query = _ref9.query,
|
|
207
|
+
rootComponent = _ref9.rootComponent,
|
|
208
|
+
selectCategoryItems = _ref9.selectCategoryItems,
|
|
209
|
+
surfaceContext = _ref9.surfaceContext;
|
|
193
210
|
var rankedComponents = (0, _itemRank.applyRegisteredItemRanks)(components, getItemRank);
|
|
194
211
|
var _resolveSurface = (0, _surfaceRenderer.resolveSurface)(rankedComponents, rootComponent),
|
|
195
212
|
childrenMap = _resolveSurface.childrenMap,
|
|
@@ -207,12 +224,12 @@ var getQuickInsertMenuModel = exports.getQuickInsertMenuModel = function getQuic
|
|
|
207
224
|
var renderedSections = topLevelChildren.filter(function (section) {
|
|
208
225
|
return section.type === 'menu-section' && (0, _surfaceRenderer.willComponentRender)(section, childrenMap, surfaceContext);
|
|
209
226
|
});
|
|
210
|
-
var footerSection = renderedSections.find(function (
|
|
211
|
-
var key =
|
|
227
|
+
var footerSection = renderedSections.find(function (_ref0) {
|
|
228
|
+
var key = _ref0.key;
|
|
212
229
|
return (0, _typeAheadIsMenuFooterSectionKey.isMenuFooterSectionKey)(key);
|
|
213
230
|
});
|
|
214
|
-
var contentSections = renderedSections.filter(function (
|
|
215
|
-
var key =
|
|
231
|
+
var contentSections = renderedSections.filter(function (_ref1) {
|
|
232
|
+
var key = _ref1.key;
|
|
216
233
|
return !(0, _typeAheadIsMenuFooterSectionKey.isMenuFooterSectionKey)(key);
|
|
217
234
|
});
|
|
218
235
|
var content = query === '' ? buildBrowseSections({
|
|
@@ -96,18 +96,30 @@ export const getRegistryElementBrowserItems = ({
|
|
|
96
96
|
if (!normalizedQuery) {
|
|
97
97
|
return itemsWithDescriptions;
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
const matches = itemsWithDescriptions.flatMap(item => {
|
|
100
100
|
var _item$registration$ma, _item$registration;
|
|
101
101
|
const result = (_item$registration$ma = (_item$registration = item.registration).match) === null || _item$registration$ma === void 0 ? void 0 : _item$registration$ma.call(_item$registration, {
|
|
102
102
|
formatMessage,
|
|
103
|
+
itemKey: item.registration.key,
|
|
103
104
|
query: normalizedQuery
|
|
104
105
|
});
|
|
105
106
|
return result ? [{
|
|
106
107
|
...item,
|
|
108
|
+
priorityGroup: result.priorityGroup !== undefined && Number.isFinite(result.priorityGroup) ? result.priorityGroup : undefined,
|
|
107
109
|
score: Math.min(1, Math.max(0, result.score))
|
|
108
110
|
}] : [];
|
|
109
|
-
})
|
|
111
|
+
});
|
|
112
|
+
const prioritized = matches.filter(({
|
|
113
|
+
priorityGroup
|
|
114
|
+
}) => priorityGroup !== undefined);
|
|
115
|
+
const unprioritized = matches.filter(({
|
|
116
|
+
priorityGroup
|
|
117
|
+
}) => priorityGroup === undefined);
|
|
118
|
+
return [...prioritized.sort((left, right) => {
|
|
119
|
+
var _right$priorityGroup, _left$priorityGroup;
|
|
120
|
+
return ((_right$priorityGroup = right.priorityGroup) !== null && _right$priorityGroup !== void 0 ? _right$priorityGroup : 0) - ((_left$priorityGroup = left.priorityGroup) !== null && _left$priorityGroup !== void 0 ? _left$priorityGroup : 0) || left.score - right.score || compareRanks(left.ranks, right.ranks) || left.registration.key.localeCompare(right.registration.key);
|
|
121
|
+
}), ...unprioritized.sort((left, right) => {
|
|
110
122
|
var _left$ranks$, _right$ranks$;
|
|
111
123
|
return ((_left$ranks$ = left.ranks[0]) !== null && _left$ranks$ !== void 0 ? _left$ranks$ : 0) - ((_right$ranks$ = right.ranks[0]) !== null && _right$ranks$ !== void 0 ? _right$ranks$ : 0) || left.score - right.score || compareRanks(left.ranks, right.ranks) || left.registration.key.localeCompare(right.registration.key);
|
|
112
|
-
});
|
|
124
|
+
})];
|
|
113
125
|
};
|
|
@@ -21,6 +21,10 @@ const getParentRank = (component, parentKey) => {
|
|
|
21
21
|
};
|
|
22
22
|
const compareMatchedItems = (a, b) => a.sectionRank - b.sectionRank || a.score - b.score || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
|
|
23
23
|
const compareSearchResults = (a, b) => a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
|
|
24
|
+
const comparePrioritizedSearchResults = (a, b) => {
|
|
25
|
+
var _b$priorityGroup, _a$priorityGroup;
|
|
26
|
+
return ((_b$priorityGroup = b.priorityGroup) !== null && _b$priorityGroup !== void 0 ? _b$priorityGroup : 0) - ((_a$priorityGroup = a.priorityGroup) !== null && _a$priorityGroup !== void 0 ? _a$priorityGroup : 0) || compareSearchResults(a, b);
|
|
27
|
+
};
|
|
24
28
|
const getSearchResults = matches => {
|
|
25
29
|
const topMatches = Array.from(matches).sort(compareSearchResults).slice(0, SEARCH_TOP_MATCH_LIMIT);
|
|
26
30
|
const topMatchIdentities = new Set(topMatches.map(({
|
|
@@ -83,6 +87,7 @@ const buildSearchSections = ({
|
|
|
83
87
|
}
|
|
84
88
|
const match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
|
|
85
89
|
formatMessage,
|
|
90
|
+
itemKey: item.key,
|
|
86
91
|
query
|
|
87
92
|
});
|
|
88
93
|
if (item.match && match === null) {
|
|
@@ -92,6 +97,7 @@ const buildSearchSections = ({
|
|
|
92
97
|
identity: `${item.type}:${item.key}`,
|
|
93
98
|
item,
|
|
94
99
|
itemRank: getParentRank(item, section.key),
|
|
100
|
+
priorityGroup: (match === null || match === void 0 ? void 0 : match.priorityGroup) !== undefined && Number.isFinite(match.priorityGroup) ? match.priorityGroup : undefined,
|
|
95
101
|
score: Math.min(1, Math.max(0, (_match$score = match === null || match === void 0 ? void 0 : match.score) !== null && _match$score !== void 0 ? _match$score : 0)),
|
|
96
102
|
sourceIndex: (_sourceIndexByCompone = sourceIndexByComponent.get(item)) !== null && _sourceIndexByCompone !== void 0 ? _sourceIndexByCompone : Number.MAX_SAFE_INTEGER,
|
|
97
103
|
sectionRank: getParentRank(section, root.key)
|
|
@@ -103,11 +109,19 @@ const buildSearchSections = ({
|
|
|
103
109
|
}
|
|
104
110
|
}
|
|
105
111
|
const uniqueMatches = Array.from(matches.values()).sort(compareMatchedItems);
|
|
106
|
-
const
|
|
107
|
-
|
|
112
|
+
const prioritizedMatches = uniqueMatches.filter(({
|
|
113
|
+
priorityGroup
|
|
114
|
+
}) => priorityGroup !== undefined);
|
|
115
|
+
const unprioritizedMatches = uniqueMatches.filter(({
|
|
116
|
+
priorityGroup
|
|
117
|
+
}) => priorityGroup === undefined);
|
|
118
|
+
const orderedSearchResults = [...prioritizedMatches.sort(comparePrioritizedSearchResults).map(({
|
|
119
|
+
item
|
|
120
|
+
}) => item), ...getSearchResults(unprioritizedMatches)];
|
|
121
|
+
if (orderedSearchResults.length > 0) {
|
|
108
122
|
return {
|
|
109
123
|
fallbackItems: [],
|
|
110
|
-
sections: [[SEARCH_RESULTS_HEADING, ...
|
|
124
|
+
sections: [[SEARCH_RESULTS_HEADING, ...orderedSearchResults]]
|
|
111
125
|
};
|
|
112
126
|
}
|
|
113
127
|
const fallbackItem = contentSections.flatMap(section => {
|
|
@@ -120,17 +120,31 @@ export var getRegistryElementBrowserItems = function getRegistryElementBrowserIt
|
|
|
120
120
|
if (!normalizedQuery) {
|
|
121
121
|
return itemsWithDescriptions;
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
var matches = itemsWithDescriptions.flatMap(function (item) {
|
|
124
124
|
var _item$registration$ma, _item$registration;
|
|
125
125
|
var result = (_item$registration$ma = (_item$registration = item.registration).match) === null || _item$registration$ma === void 0 ? void 0 : _item$registration$ma.call(_item$registration, {
|
|
126
126
|
formatMessage: formatMessage,
|
|
127
|
+
itemKey: item.registration.key,
|
|
127
128
|
query: normalizedQuery
|
|
128
129
|
});
|
|
129
130
|
return result ? [_objectSpread(_objectSpread({}, item), {}, {
|
|
131
|
+
priorityGroup: result.priorityGroup !== undefined && Number.isFinite(result.priorityGroup) ? result.priorityGroup : undefined,
|
|
130
132
|
score: Math.min(1, Math.max(0, result.score))
|
|
131
133
|
})] : [];
|
|
132
|
-
})
|
|
134
|
+
});
|
|
135
|
+
var prioritized = matches.filter(function (_ref4) {
|
|
136
|
+
var priorityGroup = _ref4.priorityGroup;
|
|
137
|
+
return priorityGroup !== undefined;
|
|
138
|
+
});
|
|
139
|
+
var unprioritized = matches.filter(function (_ref5) {
|
|
140
|
+
var priorityGroup = _ref5.priorityGroup;
|
|
141
|
+
return priorityGroup === undefined;
|
|
142
|
+
});
|
|
143
|
+
return [].concat(_toConsumableArray(prioritized.sort(function (left, right) {
|
|
144
|
+
var _right$priorityGroup, _left$priorityGroup;
|
|
145
|
+
return ((_right$priorityGroup = right.priorityGroup) !== null && _right$priorityGroup !== void 0 ? _right$priorityGroup : 0) - ((_left$priorityGroup = left.priorityGroup) !== null && _left$priorityGroup !== void 0 ? _left$priorityGroup : 0) || left.score - right.score || compareRanks(left.ranks, right.ranks) || left.registration.key.localeCompare(right.registration.key);
|
|
146
|
+
})), _toConsumableArray(unprioritized.sort(function (left, right) {
|
|
133
147
|
var _left$ranks$, _right$ranks$;
|
|
134
148
|
return ((_left$ranks$ = left.ranks[0]) !== null && _left$ranks$ !== void 0 ? _left$ranks$ : 0) - ((_right$ranks$ = right.ranks[0]) !== null && _right$ranks$ !== void 0 ? _right$ranks$ : 0) || left.score - right.score || compareRanks(left.ranks, right.ranks) || left.registration.key.localeCompare(right.registration.key);
|
|
135
|
-
});
|
|
149
|
+
})));
|
|
136
150
|
};
|
|
@@ -34,6 +34,10 @@ var compareMatchedItems = function compareMatchedItems(a, b) {
|
|
|
34
34
|
var compareSearchResults = function compareSearchResults(a, b) {
|
|
35
35
|
return a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
|
|
36
36
|
};
|
|
37
|
+
var comparePrioritizedSearchResults = function comparePrioritizedSearchResults(a, b) {
|
|
38
|
+
var _b$priorityGroup, _a$priorityGroup;
|
|
39
|
+
return ((_b$priorityGroup = b.priorityGroup) !== null && _b$priorityGroup !== void 0 ? _b$priorityGroup : 0) - ((_a$priorityGroup = a.priorityGroup) !== null && _a$priorityGroup !== void 0 ? _a$priorityGroup : 0) || compareSearchResults(a, b);
|
|
40
|
+
};
|
|
37
41
|
var getSearchResults = function getSearchResults(matches) {
|
|
38
42
|
var topMatches = Array.from(matches).sort(compareSearchResults).slice(0, SEARCH_TOP_MATCH_LIMIT);
|
|
39
43
|
var topMatchIdentities = new Set(topMatches.map(function (_ref) {
|
|
@@ -122,6 +126,7 @@ var buildSearchSections = function buildSearchSections(_ref5) {
|
|
|
122
126
|
}
|
|
123
127
|
var match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
|
|
124
128
|
formatMessage: formatMessage,
|
|
129
|
+
itemKey: item.key,
|
|
125
130
|
query: query
|
|
126
131
|
});
|
|
127
132
|
if (item.match && match === null) {
|
|
@@ -131,6 +136,7 @@ var buildSearchSections = function buildSearchSections(_ref5) {
|
|
|
131
136
|
identity: "".concat(item.type, ":").concat(item.key),
|
|
132
137
|
item: item,
|
|
133
138
|
itemRank: getParentRank(item, section.key),
|
|
139
|
+
priorityGroup: (match === null || match === void 0 ? void 0 : match.priorityGroup) !== undefined && Number.isFinite(match.priorityGroup) ? match.priorityGroup : undefined,
|
|
134
140
|
score: Math.min(1, Math.max(0, (_match$score = match === null || match === void 0 ? void 0 : match.score) !== null && _match$score !== void 0 ? _match$score : 0)),
|
|
135
141
|
sourceIndex: (_sourceIndexByCompone = sourceIndexByComponent.get(item)) !== null && _sourceIndexByCompone !== void 0 ? _sourceIndexByCompone : Number.MAX_SAFE_INTEGER,
|
|
136
142
|
sectionRank: getParentRank(section, root.key)
|
|
@@ -152,11 +158,22 @@ var buildSearchSections = function buildSearchSections(_ref5) {
|
|
|
152
158
|
_iterator2.f();
|
|
153
159
|
}
|
|
154
160
|
var uniqueMatches = Array.from(matches.values()).sort(compareMatchedItems);
|
|
155
|
-
var
|
|
156
|
-
|
|
161
|
+
var prioritizedMatches = uniqueMatches.filter(function (_ref6) {
|
|
162
|
+
var priorityGroup = _ref6.priorityGroup;
|
|
163
|
+
return priorityGroup !== undefined;
|
|
164
|
+
});
|
|
165
|
+
var unprioritizedMatches = uniqueMatches.filter(function (_ref7) {
|
|
166
|
+
var priorityGroup = _ref7.priorityGroup;
|
|
167
|
+
return priorityGroup === undefined;
|
|
168
|
+
});
|
|
169
|
+
var orderedSearchResults = [].concat(_toConsumableArray(prioritizedMatches.sort(comparePrioritizedSearchResults).map(function (_ref8) {
|
|
170
|
+
var item = _ref8.item;
|
|
171
|
+
return item;
|
|
172
|
+
})), _toConsumableArray(getSearchResults(unprioritizedMatches)));
|
|
173
|
+
if (orderedSearchResults.length > 0) {
|
|
157
174
|
return {
|
|
158
175
|
fallbackItems: [],
|
|
159
|
-
sections: [[SEARCH_RESULTS_HEADING].concat(_toConsumableArray(
|
|
176
|
+
sections: [[SEARCH_RESULTS_HEADING].concat(_toConsumableArray(orderedSearchResults))]
|
|
160
177
|
};
|
|
161
178
|
}
|
|
162
179
|
var fallbackItem = contentSections.flatMap(function (section) {
|
|
@@ -175,14 +192,14 @@ var buildSearchSections = function buildSearchSections(_ref5) {
|
|
|
175
192
|
* Builds the registered quick-insert menu model. An empty query browses every
|
|
176
193
|
* category; a non-empty query returns ranked matches. The footer is shared by both.
|
|
177
194
|
*/
|
|
178
|
-
export var getQuickInsertMenuModel = function getQuickInsertMenuModel(
|
|
179
|
-
var components =
|
|
180
|
-
formatMessage =
|
|
181
|
-
getItemRank =
|
|
182
|
-
query =
|
|
183
|
-
rootComponent =
|
|
184
|
-
selectCategoryItems =
|
|
185
|
-
surfaceContext =
|
|
195
|
+
export var getQuickInsertMenuModel = function getQuickInsertMenuModel(_ref9) {
|
|
196
|
+
var components = _ref9.components,
|
|
197
|
+
formatMessage = _ref9.formatMessage,
|
|
198
|
+
getItemRank = _ref9.getItemRank,
|
|
199
|
+
query = _ref9.query,
|
|
200
|
+
rootComponent = _ref9.rootComponent,
|
|
201
|
+
selectCategoryItems = _ref9.selectCategoryItems,
|
|
202
|
+
surfaceContext = _ref9.surfaceContext;
|
|
186
203
|
var rankedComponents = applyRegisteredItemRanks(components, getItemRank);
|
|
187
204
|
var _resolveSurface = resolveSurface(rankedComponents, rootComponent),
|
|
188
205
|
childrenMap = _resolveSurface.childrenMap,
|
|
@@ -200,12 +217,12 @@ export var getQuickInsertMenuModel = function getQuickInsertMenuModel(_ref6) {
|
|
|
200
217
|
var renderedSections = topLevelChildren.filter(function (section) {
|
|
201
218
|
return section.type === 'menu-section' && willComponentRender(section, childrenMap, surfaceContext);
|
|
202
219
|
});
|
|
203
|
-
var footerSection = renderedSections.find(function (
|
|
204
|
-
var key =
|
|
220
|
+
var footerSection = renderedSections.find(function (_ref0) {
|
|
221
|
+
var key = _ref0.key;
|
|
205
222
|
return isMenuFooterSectionKey(key);
|
|
206
223
|
});
|
|
207
|
-
var contentSections = renderedSections.filter(function (
|
|
208
|
-
var key =
|
|
224
|
+
var contentSections = renderedSections.filter(function (_ref1) {
|
|
225
|
+
var key = _ref1.key;
|
|
209
226
|
return !isMenuFooterSectionKey(key);
|
|
210
227
|
});
|
|
211
228
|
var content = query === '' ? buildBrowseSections({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-quick-insert",
|
|
3
|
-
"version": "30.0.
|
|
3
|
+
"version": "30.0.2",
|
|
4
4
|
"description": "Quick insert plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
39
39
|
"@atlaskit/editor-shared-styles": "^4.6.0",
|
|
40
40
|
"@atlaskit/editor-tables": "^3.2.0",
|
|
41
|
-
"@atlaskit/editor-ui-control-model": "^
|
|
41
|
+
"@atlaskit/editor-ui-control-model": "^3.0.0",
|
|
42
42
|
"@atlaskit/heading": "^8.0.0",
|
|
43
43
|
"@atlaskit/icon": "^38.0.0",
|
|
44
44
|
"@atlaskit/menu": "^11.0.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
48
48
|
"@atlaskit/primitives": "^22.6.0",
|
|
49
49
|
"@atlaskit/textfield": "^10.2.0",
|
|
50
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
50
|
+
"@atlaskit/tmp-editor-statsig": "^248.0.0",
|
|
51
51
|
"@atlaskit/tokens": "^20.8.0",
|
|
52
52
|
"@atlaskit/tooltip": "^24.4.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-loosely-lazy": "^1.0.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@atlaskit/editor-common": "^134.
|
|
59
|
+
"@atlaskit/editor-common": "^134.1.0",
|
|
60
60
|
"react": "^18.2.0 || ^19.2.0",
|
|
61
61
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
62
62
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -66,8 +66,7 @@
|
|
|
66
66
|
"@testing-library/react": "^16.3.0",
|
|
67
67
|
"react": "^19.2.0",
|
|
68
68
|
"react-dom": "^19.2.0",
|
|
69
|
-
"react-intl": "^7.0.0"
|
|
70
|
-
"wait-for-expect": "^1.2.0"
|
|
69
|
+
"react-intl": "^7.0.0"
|
|
71
70
|
},
|
|
72
71
|
"platform-feature-flags": {
|
|
73
72
|
"platform_editor_ease_of_use_metrics": {
|