@atlaskit/editor-plugin-quick-insert 10.4.3 → 10.4.5
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 +14 -0
- package/dist/cjs/quickInsertPlugin.js +11 -4
- package/dist/cjs/ui/search.js +34 -1
- package/dist/es2019/quickInsertPlugin.js +13 -5
- package/dist/es2019/ui/search.js +27 -0
- package/dist/esm/quickInsertPlugin.js +12 -5
- package/dist/esm/ui/search.js +33 -0
- package/dist/types/ui/search.d.ts +1 -0
- package/dist/types-ts4.5/ui/search.d.ts +1 -0
- package/editor-plugin-quick-insert.docs.tsx +22 -20
- package/package.json +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-quick-insert
|
|
2
2
|
|
|
3
|
+
## 10.4.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 10.4.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`bc59bccc2fc5c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bc59bccc2fc5c) -
|
|
14
|
+
Reorder advanced layout quick insert suggestions
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 10.4.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -34,6 +34,7 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
34
34
|
var _options$onInsert;
|
|
35
35
|
options === null || options === void 0 || (_options$onInsert = options.onInsert) === null || _options$onInsert === void 0 || _options$onInsert.call(options, item);
|
|
36
36
|
};
|
|
37
|
+
var typeAheadPrioritySortingFn = (0, _expValEquals.expValEquals)('platform_editor_layout_typeahead_reorder', 'isEnabled', true) ? (0, _search.withLayoutQuickInsertPrioritySorting)(options === null || options === void 0 ? void 0 : options.prioritySortingFn) : options === null || options === void 0 ? void 0 : options.prioritySortingFn;
|
|
37
38
|
var typeAhead = {
|
|
38
39
|
id: _typeAhead.TypeAheadAvailableNodes.QUICK_INSERT,
|
|
39
40
|
trigger: '/',
|
|
@@ -42,13 +43,14 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
42
43
|
var query = _ref2.query,
|
|
43
44
|
editorState = _ref2.editorState;
|
|
44
45
|
var quickInsertState = _pluginKey.pluginKey.getState(editorState);
|
|
45
|
-
|
|
46
|
+
var items = (0, _search.getQuickInsertSuggestions)({
|
|
46
47
|
query: query,
|
|
47
48
|
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
|
|
48
|
-
prioritySortingFn:
|
|
49
|
+
prioritySortingFn: typeAheadPrioritySortingFn,
|
|
49
50
|
// EDITOR-6558: pass through consumer-supplied filter (e.g. Markdown Mode allowlist)
|
|
50
51
|
itemFilter: options === null || options === void 0 ? void 0 : options.itemFilter
|
|
51
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems)
|
|
52
|
+
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems);
|
|
53
|
+
return Promise.resolve(items);
|
|
52
54
|
},
|
|
53
55
|
getEmptyItem: function getEmptyItem(_ref3) {
|
|
54
56
|
var editorState = _ref3.editorState;
|
|
@@ -165,7 +167,12 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
165
167
|
var _ref7 = (_api$quickInsert$shar = api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {},
|
|
166
168
|
lazyDefaultItems = _ref7.lazyDefaultItems,
|
|
167
169
|
providedItems = _ref7.providedItems;
|
|
168
|
-
if (
|
|
170
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_layout_typeahead_reorder', 'isEnabled', true)) {
|
|
171
|
+
var _options$prioritySort;
|
|
172
|
+
searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
|
|
173
|
+
prioritySortingFn: (0, _search.withLayoutQuickInsertPrioritySorting)((_options$prioritySort = options === null || options === void 0 ? void 0 : options.prioritySortingFn) !== null && _options$prioritySort !== void 0 ? _options$prioritySort : searchOptions.prioritySortingFn)
|
|
174
|
+
});
|
|
175
|
+
} else if (options !== null && options !== void 0 && options.prioritySortingFn) {
|
|
169
176
|
searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
|
|
170
177
|
prioritySortingFn: options.prioritySortingFn
|
|
171
178
|
});
|
package/dist/cjs/ui/search.js
CHANGED
|
@@ -4,11 +4,44 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getQuickInsertSuggestions = void 0;
|
|
7
|
+
exports.withLayoutQuickInsertPrioritySorting = exports.getQuickInsertSuggestions = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var isRegisteredLayoutQuickInsertItem = function isRegisteredLayoutQuickInsertItem(item) {
|
|
13
|
+
var _item$keywords, _item$keywords2;
|
|
14
|
+
return Boolean(item.id && item.id !== 'layout' && ((_item$keywords = item.keywords) === null || _item$keywords === void 0 ? void 0 : _item$keywords.includes('layout')) && ((_item$keywords2 = item.keywords) === null || _item$keywords2 === void 0 ? void 0 : _item$keywords2.includes('column')));
|
|
15
|
+
};
|
|
16
|
+
var getLayoutQuickInsertItemIdRank = function getLayoutQuickInsertItemIdRank(items) {
|
|
17
|
+
return new Map(items.filter(isRegisteredLayoutQuickInsertItem).map(function (item, index) {
|
|
18
|
+
return [item.id, index];
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
var getQuickInsertItemId = function getQuickInsertItemId(items, result) {
|
|
22
|
+
var _items$result$idx;
|
|
23
|
+
return (_items$result$idx = items[result.idx]) === null || _items$result$idx === void 0 ? void 0 : _items$result$idx.id;
|
|
24
|
+
};
|
|
25
|
+
var withLayoutQuickInsertPrioritySorting = exports.withLayoutQuickInsertPrioritySorting = function withLayoutQuickInsertPrioritySorting(prioritySortingFn) {
|
|
26
|
+
return function (items) {
|
|
27
|
+
var consumerSortFn = prioritySortingFn === null || prioritySortingFn === void 0 ? void 0 : prioritySortingFn(items);
|
|
28
|
+
var layoutItemIdRank = getLayoutQuickInsertItemIdRank(items);
|
|
29
|
+
if (layoutItemIdRank.size < 2) {
|
|
30
|
+
return consumerSortFn;
|
|
31
|
+
}
|
|
32
|
+
return function (firstItem, secondItem) {
|
|
33
|
+
var firstLayoutItemRank = layoutItemIdRank.get(getQuickInsertItemId(items, firstItem));
|
|
34
|
+
var secondLayoutItemRank = layoutItemIdRank.get(getQuickInsertItemId(items, secondItem));
|
|
35
|
+
if (firstLayoutItemRank !== undefined && secondLayoutItemRank !== undefined) {
|
|
36
|
+
return firstLayoutItemRank - secondLayoutItemRank;
|
|
37
|
+
}
|
|
38
|
+
if (consumerSortFn) {
|
|
39
|
+
return consumerSortFn(firstItem, secondItem);
|
|
40
|
+
}
|
|
41
|
+
return firstItem.score === secondItem.score ? firstItem.idx < secondItem.idx ? -1 : 1 : firstItem.score < secondItem.score ? -1 : 1;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
12
45
|
var getQuickInsertSuggestions = exports.getQuickInsertSuggestions = function getQuickInsertSuggestions(searchOptions) {
|
|
13
46
|
var lazyDefaultItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
14
47
|
return [];
|
|
@@ -12,7 +12,7 @@ import { createInsertItem, openElementBrowserModal } from './pm-plugins/commands
|
|
|
12
12
|
import { getQuickInsertOpenExperiencePlugin } from './pm-plugins/experiences/quick-insert-open-experience';
|
|
13
13
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
14
14
|
import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
15
|
-
import { getQuickInsertSuggestions } from './ui/search';
|
|
15
|
+
import { getQuickInsertSuggestions, withLayoutQuickInsertPrioritySorting } from './ui/search';
|
|
16
16
|
export const quickInsertPlugin = ({
|
|
17
17
|
config: options,
|
|
18
18
|
api
|
|
@@ -22,6 +22,7 @@ export const quickInsertPlugin = ({
|
|
|
22
22
|
var _options$onInsert;
|
|
23
23
|
options === null || options === void 0 ? void 0 : (_options$onInsert = options.onInsert) === null || _options$onInsert === void 0 ? void 0 : _options$onInsert.call(options, item);
|
|
24
24
|
};
|
|
25
|
+
const typeAheadPrioritySortingFn = expValEquals('platform_editor_layout_typeahead_reorder', 'isEnabled', true) ? withLayoutQuickInsertPrioritySorting(options === null || options === void 0 ? void 0 : options.prioritySortingFn) : options === null || options === void 0 ? void 0 : options.prioritySortingFn;
|
|
25
26
|
const typeAhead = {
|
|
26
27
|
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
27
28
|
trigger: '/',
|
|
@@ -31,13 +32,14 @@ export const quickInsertPlugin = ({
|
|
|
31
32
|
editorState
|
|
32
33
|
}) {
|
|
33
34
|
const quickInsertState = pluginKey.getState(editorState);
|
|
34
|
-
|
|
35
|
+
const items = getQuickInsertSuggestions({
|
|
35
36
|
query: query,
|
|
36
37
|
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
|
|
37
|
-
prioritySortingFn:
|
|
38
|
+
prioritySortingFn: typeAheadPrioritySortingFn,
|
|
38
39
|
// EDITOR-6558: pass through consumer-supplied filter (e.g. Markdown Mode allowlist)
|
|
39
40
|
itemFilter: options === null || options === void 0 ? void 0 : options.itemFilter
|
|
40
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems)
|
|
41
|
+
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems);
|
|
42
|
+
return Promise.resolve(items);
|
|
41
43
|
},
|
|
42
44
|
getEmptyItem({
|
|
43
45
|
editorState
|
|
@@ -155,7 +157,13 @@ export const quickInsertPlugin = ({
|
|
|
155
157
|
lazyDefaultItems,
|
|
156
158
|
providedItems
|
|
157
159
|
} = (_api$quickInsert$shar = api === null || api === void 0 ? void 0 : (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {};
|
|
158
|
-
if (
|
|
160
|
+
if (expValEquals('platform_editor_layout_typeahead_reorder', 'isEnabled', true)) {
|
|
161
|
+
var _options$prioritySort;
|
|
162
|
+
searchOptions = {
|
|
163
|
+
...searchOptions,
|
|
164
|
+
prioritySortingFn: withLayoutQuickInsertPrioritySorting((_options$prioritySort = options === null || options === void 0 ? void 0 : options.prioritySortingFn) !== null && _options$prioritySort !== void 0 ? _options$prioritySort : searchOptions.prioritySortingFn)
|
|
165
|
+
};
|
|
166
|
+
} else if (options !== null && options !== void 0 && options.prioritySortingFn) {
|
|
159
167
|
searchOptions = {
|
|
160
168
|
...searchOptions,
|
|
161
169
|
prioritySortingFn: options.prioritySortingFn
|
package/dist/es2019/ui/search.js
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { find } from '@atlaskit/editor-common/quick-insert';
|
|
2
2
|
import { dedupe } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
const isRegisteredLayoutQuickInsertItem = item => {
|
|
5
|
+
var _item$keywords, _item$keywords2;
|
|
6
|
+
return Boolean(item.id && item.id !== 'layout' && ((_item$keywords = item.keywords) === null || _item$keywords === void 0 ? void 0 : _item$keywords.includes('layout')) && ((_item$keywords2 = item.keywords) === null || _item$keywords2 === void 0 ? void 0 : _item$keywords2.includes('column')));
|
|
7
|
+
};
|
|
8
|
+
const getLayoutQuickInsertItemIdRank = items => new Map(items.filter(isRegisteredLayoutQuickInsertItem).map((item, index) => [item.id, index]));
|
|
9
|
+
const getQuickInsertItemId = (items, result) => {
|
|
10
|
+
var _items$result$idx;
|
|
11
|
+
return (_items$result$idx = items[result.idx]) === null || _items$result$idx === void 0 ? void 0 : _items$result$idx.id;
|
|
12
|
+
};
|
|
13
|
+
export const withLayoutQuickInsertPrioritySorting = prioritySortingFn => items => {
|
|
14
|
+
const consumerSortFn = prioritySortingFn === null || prioritySortingFn === void 0 ? void 0 : prioritySortingFn(items);
|
|
15
|
+
const layoutItemIdRank = getLayoutQuickInsertItemIdRank(items);
|
|
16
|
+
if (layoutItemIdRank.size < 2) {
|
|
17
|
+
return consumerSortFn;
|
|
18
|
+
}
|
|
19
|
+
return (firstItem, secondItem) => {
|
|
20
|
+
const firstLayoutItemRank = layoutItemIdRank.get(getQuickInsertItemId(items, firstItem));
|
|
21
|
+
const secondLayoutItemRank = layoutItemIdRank.get(getQuickInsertItemId(items, secondItem));
|
|
22
|
+
if (firstLayoutItemRank !== undefined && secondLayoutItemRank !== undefined) {
|
|
23
|
+
return firstLayoutItemRank - secondLayoutItemRank;
|
|
24
|
+
}
|
|
25
|
+
if (consumerSortFn) {
|
|
26
|
+
return consumerSortFn(firstItem, secondItem);
|
|
27
|
+
}
|
|
28
|
+
return firstItem.score === secondItem.score ? firstItem.idx < secondItem.idx ? -1 : 1 : firstItem.score < secondItem.score ? -1 : 1;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
4
31
|
export const getQuickInsertSuggestions = (searchOptions, lazyDefaultItems = () => [], providedItems) => {
|
|
5
32
|
// @ts-ignore
|
|
6
33
|
const {
|
|
@@ -18,7 +18,7 @@ import { createInsertItem, openElementBrowserModal as _openElementBrowserModal }
|
|
|
18
18
|
import { getQuickInsertOpenExperiencePlugin } from './pm-plugins/experiences/quick-insert-open-experience';
|
|
19
19
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
20
20
|
import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
21
|
-
import { getQuickInsertSuggestions } from './ui/search';
|
|
21
|
+
import { getQuickInsertSuggestions, withLayoutQuickInsertPrioritySorting } from './ui/search';
|
|
22
22
|
export var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
23
23
|
var options = _ref.config,
|
|
24
24
|
api = _ref.api;
|
|
@@ -27,6 +27,7 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
27
27
|
var _options$onInsert;
|
|
28
28
|
options === null || options === void 0 || (_options$onInsert = options.onInsert) === null || _options$onInsert === void 0 || _options$onInsert.call(options, item);
|
|
29
29
|
};
|
|
30
|
+
var typeAheadPrioritySortingFn = expValEquals('platform_editor_layout_typeahead_reorder', 'isEnabled', true) ? withLayoutQuickInsertPrioritySorting(options === null || options === void 0 ? void 0 : options.prioritySortingFn) : options === null || options === void 0 ? void 0 : options.prioritySortingFn;
|
|
30
31
|
var typeAhead = {
|
|
31
32
|
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
32
33
|
trigger: '/',
|
|
@@ -35,13 +36,14 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
35
36
|
var query = _ref2.query,
|
|
36
37
|
editorState = _ref2.editorState;
|
|
37
38
|
var quickInsertState = pluginKey.getState(editorState);
|
|
38
|
-
|
|
39
|
+
var items = getQuickInsertSuggestions({
|
|
39
40
|
query: query,
|
|
40
41
|
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
|
|
41
|
-
prioritySortingFn:
|
|
42
|
+
prioritySortingFn: typeAheadPrioritySortingFn,
|
|
42
43
|
// EDITOR-6558: pass through consumer-supplied filter (e.g. Markdown Mode allowlist)
|
|
43
44
|
itemFilter: options === null || options === void 0 ? void 0 : options.itemFilter
|
|
44
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems)
|
|
45
|
+
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems);
|
|
46
|
+
return Promise.resolve(items);
|
|
45
47
|
},
|
|
46
48
|
getEmptyItem: function getEmptyItem(_ref3) {
|
|
47
49
|
var editorState = _ref3.editorState;
|
|
@@ -158,7 +160,12 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
158
160
|
var _ref7 = (_api$quickInsert$shar = api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {},
|
|
159
161
|
lazyDefaultItems = _ref7.lazyDefaultItems,
|
|
160
162
|
providedItems = _ref7.providedItems;
|
|
161
|
-
if (
|
|
163
|
+
if (expValEquals('platform_editor_layout_typeahead_reorder', 'isEnabled', true)) {
|
|
164
|
+
var _options$prioritySort;
|
|
165
|
+
searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
|
|
166
|
+
prioritySortingFn: withLayoutQuickInsertPrioritySorting((_options$prioritySort = options === null || options === void 0 ? void 0 : options.prioritySortingFn) !== null && _options$prioritySort !== void 0 ? _options$prioritySort : searchOptions.prioritySortingFn)
|
|
167
|
+
});
|
|
168
|
+
} else if (options !== null && options !== void 0 && options.prioritySortingFn) {
|
|
162
169
|
searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
|
|
163
170
|
prioritySortingFn: options.prioritySortingFn
|
|
164
171
|
});
|
package/dist/esm/ui/search.js
CHANGED
|
@@ -2,6 +2,39 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import { find } from '@atlaskit/editor-common/quick-insert';
|
|
3
3
|
import { dedupe } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
var isRegisteredLayoutQuickInsertItem = function isRegisteredLayoutQuickInsertItem(item) {
|
|
6
|
+
var _item$keywords, _item$keywords2;
|
|
7
|
+
return Boolean(item.id && item.id !== 'layout' && ((_item$keywords = item.keywords) === null || _item$keywords === void 0 ? void 0 : _item$keywords.includes('layout')) && ((_item$keywords2 = item.keywords) === null || _item$keywords2 === void 0 ? void 0 : _item$keywords2.includes('column')));
|
|
8
|
+
};
|
|
9
|
+
var getLayoutQuickInsertItemIdRank = function getLayoutQuickInsertItemIdRank(items) {
|
|
10
|
+
return new Map(items.filter(isRegisteredLayoutQuickInsertItem).map(function (item, index) {
|
|
11
|
+
return [item.id, index];
|
|
12
|
+
}));
|
|
13
|
+
};
|
|
14
|
+
var getQuickInsertItemId = function getQuickInsertItemId(items, result) {
|
|
15
|
+
var _items$result$idx;
|
|
16
|
+
return (_items$result$idx = items[result.idx]) === null || _items$result$idx === void 0 ? void 0 : _items$result$idx.id;
|
|
17
|
+
};
|
|
18
|
+
export var withLayoutQuickInsertPrioritySorting = function withLayoutQuickInsertPrioritySorting(prioritySortingFn) {
|
|
19
|
+
return function (items) {
|
|
20
|
+
var consumerSortFn = prioritySortingFn === null || prioritySortingFn === void 0 ? void 0 : prioritySortingFn(items);
|
|
21
|
+
var layoutItemIdRank = getLayoutQuickInsertItemIdRank(items);
|
|
22
|
+
if (layoutItemIdRank.size < 2) {
|
|
23
|
+
return consumerSortFn;
|
|
24
|
+
}
|
|
25
|
+
return function (firstItem, secondItem) {
|
|
26
|
+
var firstLayoutItemRank = layoutItemIdRank.get(getQuickInsertItemId(items, firstItem));
|
|
27
|
+
var secondLayoutItemRank = layoutItemIdRank.get(getQuickInsertItemId(items, secondItem));
|
|
28
|
+
if (firstLayoutItemRank !== undefined && secondLayoutItemRank !== undefined) {
|
|
29
|
+
return firstLayoutItemRank - secondLayoutItemRank;
|
|
30
|
+
}
|
|
31
|
+
if (consumerSortFn) {
|
|
32
|
+
return consumerSortFn(firstItem, secondItem);
|
|
33
|
+
}
|
|
34
|
+
return firstItem.score === secondItem.score ? firstItem.idx < secondItem.idx ? -1 : 1 : firstItem.score < secondItem.score ? -1 : 1;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
5
38
|
export var getQuickInsertSuggestions = function getQuickInsertSuggestions(searchOptions) {
|
|
6
39
|
var lazyDefaultItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
7
40
|
return [];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
2
|
import type { QuickInsertSearchOptions } from '@atlaskit/editor-common/types';
|
|
3
3
|
type GetQuickInsertSuggestions = (searchOptions: QuickInsertSearchOptions, lazyDefaultItems?: () => QuickInsertItem[], providedItems?: QuickInsertItem[]) => QuickInsertItem[];
|
|
4
|
+
export declare const withLayoutQuickInsertPrioritySorting: (prioritySortingFn?: QuickInsertSearchOptions["prioritySortingFn"]) => QuickInsertSearchOptions["prioritySortingFn"];
|
|
4
5
|
export declare const getQuickInsertSuggestions: GetQuickInsertSuggestions;
|
|
5
6
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
2
|
import type { QuickInsertSearchOptions } from '@atlaskit/editor-common/types';
|
|
3
3
|
type GetQuickInsertSuggestions = (searchOptions: QuickInsertSearchOptions, lazyDefaultItems?: () => QuickInsertItem[], providedItems?: QuickInsertItem[]) => QuickInsertItem[];
|
|
4
|
+
export declare const withLayoutQuickInsertPrioritySorting: (prioritySortingFn?: QuickInsertSearchOptions["prioritySortingFn"]) => QuickInsertSearchOptions["prioritySortingFn"];
|
|
4
5
|
export declare const getQuickInsertSuggestions: GetQuickInsertSuggestions;
|
|
5
6
|
export {};
|
|
@@ -5,31 +5,33 @@
|
|
|
5
5
|
|
|
6
6
|
import path from 'path';
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type { StructuredContentSource } from '@atlassian/structured-docs-types/types';
|
|
9
9
|
|
|
10
10
|
import packageJson from './package.json';
|
|
11
11
|
|
|
12
12
|
const packagePath = path.resolve(__dirname);
|
|
13
13
|
|
|
14
|
-
const documentation:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
const documentation: StructuredContentSource = {
|
|
15
|
+
components: [
|
|
16
|
+
{
|
|
17
|
+
name: 'Editor Plugin Quick Insert',
|
|
18
|
+
description: 'Quick insert plugin for @atlaskit/editor-core',
|
|
19
|
+
status: 'general-availability',
|
|
20
|
+
import: {
|
|
21
|
+
name: 'quickInsertPlugin',
|
|
22
|
+
package: '@atlaskit/editor-plugin-quick-insert',
|
|
23
|
+
type: 'named',
|
|
24
|
+
packagePath,
|
|
25
|
+
packageJson,
|
|
26
|
+
},
|
|
27
|
+
usageGuidelines: [],
|
|
28
|
+
contentGuidelines: [],
|
|
29
|
+
accessibilityGuidelines: [],
|
|
30
|
+
keywords: ['editor', 'editor-plugin-quick-insert', 'atlaskit'],
|
|
31
|
+
categories: ['editor'],
|
|
32
|
+
examples: [],
|
|
25
33
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
accessibilityGuidelines: [],
|
|
29
|
-
keywords: ['editor', 'editor-plugin-quick-insert', 'atlaskit'],
|
|
30
|
-
categories: ['editor'],
|
|
31
|
-
examples: [],
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
+
],
|
|
35
|
+
};
|
|
34
36
|
|
|
35
37
|
export default documentation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-quick-insert",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.5",
|
|
4
4
|
"description": "Quick insert plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^10.1.0",
|
|
34
34
|
"@atlaskit/editor-plugin-connectivity": "^10.1.0",
|
|
35
35
|
"@atlaskit/editor-plugin-metrics": "^11.1.0",
|
|
36
|
-
"@atlaskit/editor-plugin-type-ahead": "^10.
|
|
36
|
+
"@atlaskit/editor-plugin-type-ahead": "^10.2.0",
|
|
37
37
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
38
|
-
"@atlaskit/icon": "^35.
|
|
39
|
-
"@atlaskit/modal-dialog": "^15.
|
|
38
|
+
"@atlaskit/icon": "^35.1.0",
|
|
39
|
+
"@atlaskit/modal-dialog": "^15.2.0",
|
|
40
40
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
41
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
41
|
+
"@atlaskit/tmp-editor-statsig": "^83.0.0",
|
|
42
42
|
"@atlaskit/tokens": "^13.0.0",
|
|
43
43
|
"@babel/runtime": "^7.0.0",
|
|
44
44
|
"@emotion/react": "^11.7.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@atlaskit/editor-common": "^114.
|
|
47
|
+
"@atlaskit/editor-common": "^114.46.0",
|
|
48
48
|
"react": "^18.2.0",
|
|
49
49
|
"react-dom": "^18.2.0",
|
|
50
50
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -52,6 +52,8 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@atlassian/structured-docs-types": "workspace:^",
|
|
54
54
|
"@testing-library/react": "^16.3.0",
|
|
55
|
+
"react": "^18.2.0",
|
|
56
|
+
"react-dom": "^18.2.0",
|
|
55
57
|
"react-intl": "^6.6.2",
|
|
56
58
|
"wait-for-expect": "^1.2.0"
|
|
57
59
|
},
|