@atlaskit/editor-plugin-quick-insert 1.4.7 → 1.5.1
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 +22 -0
- package/dist/cjs/plugin.js +20 -4
- package/dist/cjs/search.js +3 -2
- package/dist/cjs/ui/ModalElementBrowser/index.js +7 -3
- package/dist/es2019/plugin.js +20 -3
- package/dist/es2019/search.js +3 -2
- package/dist/es2019/ui/ModalElementBrowser/index.js +7 -3
- package/dist/esm/plugin.js +20 -4
- package/dist/esm/search.js +3 -2
- package/dist/esm/ui/ModalElementBrowser/index.js +7 -3
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +1 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-quick-insert
|
|
2
2
|
|
|
3
|
+
## 1.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#155735](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/155735)
|
|
8
|
+
[`1beeeda29023a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1beeeda29023a) -
|
|
9
|
+
Upgrades editor packages to react 18
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 1.5.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#154398](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/154398)
|
|
17
|
+
[`ca1591355d790`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ca1591355d790) -
|
|
18
|
+
[ux] Allows for passing functions to the quickInsert plugin that allow for capturing element
|
|
19
|
+
insertion metrics and then using that data to change the element sort order
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 1.4.7
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.quickInsertPlugin = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
var _reactIntlNext = require("react-intl-next");
|
|
14
14
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
@@ -23,6 +23,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
23
23
|
var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
24
24
|
var options = _ref.config,
|
|
25
25
|
api = _ref.api;
|
|
26
|
+
var onInsert = function onInsert(item) {
|
|
27
|
+
var _options$onInsert;
|
|
28
|
+
options === null || options === void 0 || (_options$onInsert = options.onInsert) === null || _options$onInsert === void 0 || _options$onInsert.call(options, item);
|
|
29
|
+
};
|
|
26
30
|
var typeAhead = {
|
|
27
31
|
id: _typeAhead.TypeAheadAvailableNodes.QUICK_INSERT,
|
|
28
32
|
trigger: '/',
|
|
@@ -33,11 +37,17 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
33
37
|
var quickInsertState = _pluginKey.pluginKey.getState(editorState);
|
|
34
38
|
return Promise.resolve((0, _search.getQuickInsertSuggestions)({
|
|
35
39
|
query: query,
|
|
36
|
-
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
40
|
+
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
|
|
41
|
+
prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn
|
|
37
42
|
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
38
43
|
},
|
|
39
44
|
selectItem: function selectItem(state, item, insert) {
|
|
40
|
-
|
|
45
|
+
var quickInsertItem = item;
|
|
46
|
+
var result = quickInsertItem.action(insert, state);
|
|
47
|
+
if (result) {
|
|
48
|
+
onInsert(quickInsertItem);
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
41
51
|
}
|
|
42
52
|
};
|
|
43
53
|
var intl;
|
|
@@ -99,8 +109,14 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
99
109
|
var _ref5 = (_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 : {},
|
|
100
110
|
lazyDefaultItems = _ref5.lazyDefaultItems,
|
|
101
111
|
providedItems = _ref5.providedItems;
|
|
112
|
+
if (options !== null && options !== void 0 && options.prioritySortingFn) {
|
|
113
|
+
searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
|
|
114
|
+
prioritySortingFn: options.prioritySortingFn
|
|
115
|
+
});
|
|
116
|
+
}
|
|
102
117
|
return (0, _search.getQuickInsertSuggestions)(searchOptions, lazyDefaultItems, providedItems);
|
|
103
|
-
}
|
|
118
|
+
},
|
|
119
|
+
onInsert: onInsert
|
|
104
120
|
},
|
|
105
121
|
commands: {
|
|
106
122
|
openElementBrowserModal: _commands.openElementBrowserModal,
|
package/dist/cjs/search.js
CHANGED
|
@@ -18,7 +18,8 @@ var getQuickInsertSuggestions = exports.getQuickInsertSuggestions = function get
|
|
|
18
18
|
category = searchOptions.category,
|
|
19
19
|
disableDefaultItems = searchOptions.disableDefaultItems,
|
|
20
20
|
featuredItems = searchOptions.featuredItems,
|
|
21
|
-
templateItems = searchOptions.templateItems
|
|
21
|
+
templateItems = searchOptions.templateItems,
|
|
22
|
+
prioritySortingFn = searchOptions.prioritySortingFn;
|
|
22
23
|
var defaultItems = disableDefaultItems ? [] : lazyDefaultItems();
|
|
23
24
|
var items = providedItems ? (0, _utils.dedupe)([].concat((0, _toConsumableArray2.default)(defaultItems), (0, _toConsumableArray2.default)(providedItems)), function (item) {
|
|
24
25
|
return item.title;
|
|
@@ -39,5 +40,5 @@ var getQuickInsertSuggestions = exports.getQuickInsertSuggestions = function get
|
|
|
39
40
|
}
|
|
40
41
|
return (0, _quickInsert.find)(query || '', category === 'all' || !category ? items : items.filter(function (item) {
|
|
41
42
|
return item.categories && item.categories.includes(category);
|
|
42
|
-
}));
|
|
43
|
+
}), prioritySortingFn);
|
|
43
44
|
};
|
|
@@ -16,7 +16,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
16
16
|
var Modal = function Modal(_ref) {
|
|
17
17
|
var quickInsertState = _ref.quickInsertState,
|
|
18
18
|
editorView = _ref.editorView,
|
|
19
|
-
helpUrl = _ref.helpUrl
|
|
19
|
+
helpUrl = _ref.helpUrl,
|
|
20
|
+
onInsert = _ref.onInsert;
|
|
20
21
|
var getItems = (0, _react.useCallback)(function (query, category) {
|
|
21
22
|
return (0, _search.getQuickInsertSuggestions)({
|
|
22
23
|
query: query,
|
|
@@ -34,9 +35,10 @@ var Modal = function Modal(_ref) {
|
|
|
34
35
|
// We wait until modal close is complete, refocus the editor and then add the item
|
|
35
36
|
var insertableItem = _react.default.useRef(null);
|
|
36
37
|
var onInsertItem = (0, _react.useCallback)(function (item) {
|
|
38
|
+
onInsert === null || onInsert === void 0 || onInsert(item);
|
|
37
39
|
(0, _commands.closeElementBrowserModal)()(editorView.state, editorView.dispatch);
|
|
38
40
|
insertableItem.current = item;
|
|
39
|
-
}, [editorView]);
|
|
41
|
+
}, [editorView, onInsert]);
|
|
40
42
|
var onClose = (0, _react.useCallback)(function () {
|
|
41
43
|
(0, _commands.closeElementBrowserModal)()(editorView.state, editorView.dispatch);
|
|
42
44
|
focusInEditor();
|
|
@@ -63,6 +65,7 @@ var Modal = function Modal(_ref) {
|
|
|
63
65
|
});
|
|
64
66
|
};
|
|
65
67
|
var _default = exports.default = function _default(_ref2) {
|
|
68
|
+
var _pluginInjectionAPI$q;
|
|
66
69
|
var editorView = _ref2.editorView,
|
|
67
70
|
helpUrl = _ref2.helpUrl,
|
|
68
71
|
pluginInjectionAPI = _ref2.pluginInjectionAPI;
|
|
@@ -71,6 +74,7 @@ var _default = exports.default = function _default(_ref2) {
|
|
|
71
74
|
return /*#__PURE__*/_react.default.createElement(Modal, {
|
|
72
75
|
quickInsertState: quickInsertState !== null && quickInsertState !== void 0 ? quickInsertState : undefined,
|
|
73
76
|
editorView: editorView,
|
|
74
|
-
helpUrl: helpUrl
|
|
77
|
+
helpUrl: helpUrl,
|
|
78
|
+
onInsert: pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$q = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q === void 0 || (_pluginInjectionAPI$q = _pluginInjectionAPI$q.actions) === null || _pluginInjectionAPI$q === void 0 ? void 0 : _pluginInjectionAPI$q.onInsert
|
|
75
79
|
});
|
|
76
80
|
};
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -11,6 +11,10 @@ export const quickInsertPlugin = ({
|
|
|
11
11
|
config: options,
|
|
12
12
|
api
|
|
13
13
|
}) => {
|
|
14
|
+
const onInsert = item => {
|
|
15
|
+
var _options$onInsert;
|
|
16
|
+
options === null || options === void 0 ? void 0 : (_options$onInsert = options.onInsert) === null || _options$onInsert === void 0 ? void 0 : _options$onInsert.call(options, item);
|
|
17
|
+
};
|
|
14
18
|
const typeAhead = {
|
|
15
19
|
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
16
20
|
trigger: '/',
|
|
@@ -22,11 +26,17 @@ export const quickInsertPlugin = ({
|
|
|
22
26
|
const quickInsertState = pluginKey.getState(editorState);
|
|
23
27
|
return Promise.resolve(getQuickInsertSuggestions({
|
|
24
28
|
query,
|
|
25
|
-
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
29
|
+
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
|
|
30
|
+
prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn
|
|
26
31
|
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
27
32
|
},
|
|
28
33
|
selectItem: (state, item, insert) => {
|
|
29
|
-
|
|
34
|
+
const quickInsertItem = item;
|
|
35
|
+
const result = quickInsertItem.action(insert, state);
|
|
36
|
+
if (result) {
|
|
37
|
+
onInsert(quickInsertItem);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
30
40
|
}
|
|
31
41
|
};
|
|
32
42
|
let intl;
|
|
@@ -89,8 +99,15 @@ export const quickInsertPlugin = ({
|
|
|
89
99
|
lazyDefaultItems,
|
|
90
100
|
providedItems
|
|
91
101
|
} = (_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 : {};
|
|
102
|
+
if (options !== null && options !== void 0 && options.prioritySortingFn) {
|
|
103
|
+
searchOptions = {
|
|
104
|
+
...searchOptions,
|
|
105
|
+
prioritySortingFn: options.prioritySortingFn
|
|
106
|
+
};
|
|
107
|
+
}
|
|
92
108
|
return getQuickInsertSuggestions(searchOptions, lazyDefaultItems, providedItems);
|
|
93
|
-
}
|
|
109
|
+
},
|
|
110
|
+
onInsert
|
|
94
111
|
},
|
|
95
112
|
commands: {
|
|
96
113
|
openElementBrowserModal,
|
package/dist/es2019/search.js
CHANGED
|
@@ -7,7 +7,8 @@ export const getQuickInsertSuggestions = (searchOptions, lazyDefaultItems = () =
|
|
|
7
7
|
category,
|
|
8
8
|
disableDefaultItems,
|
|
9
9
|
featuredItems,
|
|
10
|
-
templateItems
|
|
10
|
+
templateItems,
|
|
11
|
+
prioritySortingFn
|
|
11
12
|
} = searchOptions;
|
|
12
13
|
const defaultItems = disableDefaultItems ? [] : lazyDefaultItems();
|
|
13
14
|
const items = providedItems ? dedupe([...defaultItems, ...providedItems], item => item.title) : defaultItems;
|
|
@@ -23,5 +24,5 @@ export const getQuickInsertSuggestions = (searchOptions, lazyDefaultItems = () =
|
|
|
23
24
|
if (featuredItems) {
|
|
24
25
|
return items.filter(item => item.featured);
|
|
25
26
|
}
|
|
26
|
-
return find(query || '', category === 'all' || !category ? items : items.filter(item => item.categories && item.categories.includes(category)));
|
|
27
|
+
return find(query || '', category === 'all' || !category ? items : items.filter(item => item.categories && item.categories.includes(category)), prioritySortingFn);
|
|
27
28
|
};
|
|
@@ -6,7 +6,8 @@ import ModalElementBrowser from './ModalElementBrowser';
|
|
|
6
6
|
const Modal = ({
|
|
7
7
|
quickInsertState,
|
|
8
8
|
editorView,
|
|
9
|
-
helpUrl
|
|
9
|
+
helpUrl,
|
|
10
|
+
onInsert
|
|
10
11
|
}) => {
|
|
11
12
|
const getItems = useCallback((query, category) => getQuickInsertSuggestions({
|
|
12
13
|
query,
|
|
@@ -23,9 +24,10 @@ const Modal = ({
|
|
|
23
24
|
// We wait until modal close is complete, refocus the editor and then add the item
|
|
24
25
|
const insertableItem = React.useRef(null);
|
|
25
26
|
const onInsertItem = useCallback(item => {
|
|
27
|
+
onInsert === null || onInsert === void 0 ? void 0 : onInsert(item);
|
|
26
28
|
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
27
29
|
insertableItem.current = item;
|
|
28
|
-
}, [editorView]);
|
|
30
|
+
}, [editorView, onInsert]);
|
|
29
31
|
const onClose = useCallback(() => {
|
|
30
32
|
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
31
33
|
focusInEditor();
|
|
@@ -56,12 +58,14 @@ export default (({
|
|
|
56
58
|
helpUrl,
|
|
57
59
|
pluginInjectionAPI
|
|
58
60
|
}) => {
|
|
61
|
+
var _pluginInjectionAPI$q, _pluginInjectionAPI$q2;
|
|
59
62
|
const {
|
|
60
63
|
quickInsertState
|
|
61
64
|
} = useSharedPluginState(pluginInjectionAPI, ['quickInsert']);
|
|
62
65
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
63
66
|
quickInsertState: quickInsertState !== null && quickInsertState !== void 0 ? quickInsertState : undefined,
|
|
64
67
|
editorView: editorView,
|
|
65
|
-
helpUrl: helpUrl
|
|
68
|
+
helpUrl: helpUrl,
|
|
69
|
+
onInsert: pluginInjectionAPI === null || pluginInjectionAPI === void 0 ? void 0 : (_pluginInjectionAPI$q = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q === void 0 ? void 0 : (_pluginInjectionAPI$q2 = _pluginInjectionAPI$q.actions) === null || _pluginInjectionAPI$q2 === void 0 ? void 0 : _pluginInjectionAPI$q2.onInsert
|
|
66
70
|
});
|
|
67
71
|
});
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -16,6 +16,10 @@ import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
|
16
16
|
export var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
17
17
|
var options = _ref.config,
|
|
18
18
|
api = _ref.api;
|
|
19
|
+
var onInsert = function onInsert(item) {
|
|
20
|
+
var _options$onInsert;
|
|
21
|
+
options === null || options === void 0 || (_options$onInsert = options.onInsert) === null || _options$onInsert === void 0 || _options$onInsert.call(options, item);
|
|
22
|
+
};
|
|
19
23
|
var typeAhead = {
|
|
20
24
|
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
21
25
|
trigger: '/',
|
|
@@ -26,11 +30,17 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
26
30
|
var quickInsertState = pluginKey.getState(editorState);
|
|
27
31
|
return Promise.resolve(getQuickInsertSuggestions({
|
|
28
32
|
query: query,
|
|
29
|
-
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
33
|
+
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
|
|
34
|
+
prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn
|
|
30
35
|
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
31
36
|
},
|
|
32
37
|
selectItem: function selectItem(state, item, insert) {
|
|
33
|
-
|
|
38
|
+
var quickInsertItem = item;
|
|
39
|
+
var result = quickInsertItem.action(insert, state);
|
|
40
|
+
if (result) {
|
|
41
|
+
onInsert(quickInsertItem);
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
34
44
|
}
|
|
35
45
|
};
|
|
36
46
|
var intl;
|
|
@@ -92,8 +102,14 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
92
102
|
var _ref5 = (_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 : {},
|
|
93
103
|
lazyDefaultItems = _ref5.lazyDefaultItems,
|
|
94
104
|
providedItems = _ref5.providedItems;
|
|
105
|
+
if (options !== null && options !== void 0 && options.prioritySortingFn) {
|
|
106
|
+
searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
|
|
107
|
+
prioritySortingFn: options.prioritySortingFn
|
|
108
|
+
});
|
|
109
|
+
}
|
|
95
110
|
return getQuickInsertSuggestions(searchOptions, lazyDefaultItems, providedItems);
|
|
96
|
-
}
|
|
111
|
+
},
|
|
112
|
+
onInsert: onInsert
|
|
97
113
|
},
|
|
98
114
|
commands: {
|
|
99
115
|
openElementBrowserModal: openElementBrowserModal,
|
package/dist/esm/search.js
CHANGED
|
@@ -11,7 +11,8 @@ export var getQuickInsertSuggestions = function getQuickInsertSuggestions(search
|
|
|
11
11
|
category = searchOptions.category,
|
|
12
12
|
disableDefaultItems = searchOptions.disableDefaultItems,
|
|
13
13
|
featuredItems = searchOptions.featuredItems,
|
|
14
|
-
templateItems = searchOptions.templateItems
|
|
14
|
+
templateItems = searchOptions.templateItems,
|
|
15
|
+
prioritySortingFn = searchOptions.prioritySortingFn;
|
|
15
16
|
var defaultItems = disableDefaultItems ? [] : lazyDefaultItems();
|
|
16
17
|
var items = providedItems ? dedupe([].concat(_toConsumableArray(defaultItems), _toConsumableArray(providedItems)), function (item) {
|
|
17
18
|
return item.title;
|
|
@@ -32,5 +33,5 @@ export var getQuickInsertSuggestions = function getQuickInsertSuggestions(search
|
|
|
32
33
|
}
|
|
33
34
|
return find(query || '', category === 'all' || !category ? items : items.filter(function (item) {
|
|
34
35
|
return item.categories && item.categories.includes(category);
|
|
35
|
-
}));
|
|
36
|
+
}), prioritySortingFn);
|
|
36
37
|
};
|
|
@@ -6,7 +6,8 @@ import ModalElementBrowser from './ModalElementBrowser';
|
|
|
6
6
|
var Modal = function Modal(_ref) {
|
|
7
7
|
var quickInsertState = _ref.quickInsertState,
|
|
8
8
|
editorView = _ref.editorView,
|
|
9
|
-
helpUrl = _ref.helpUrl
|
|
9
|
+
helpUrl = _ref.helpUrl,
|
|
10
|
+
onInsert = _ref.onInsert;
|
|
10
11
|
var getItems = useCallback(function (query, category) {
|
|
11
12
|
return getQuickInsertSuggestions({
|
|
12
13
|
query: query,
|
|
@@ -24,9 +25,10 @@ var Modal = function Modal(_ref) {
|
|
|
24
25
|
// We wait until modal close is complete, refocus the editor and then add the item
|
|
25
26
|
var insertableItem = React.useRef(null);
|
|
26
27
|
var onInsertItem = useCallback(function (item) {
|
|
28
|
+
onInsert === null || onInsert === void 0 || onInsert(item);
|
|
27
29
|
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
28
30
|
insertableItem.current = item;
|
|
29
|
-
}, [editorView]);
|
|
31
|
+
}, [editorView, onInsert]);
|
|
30
32
|
var onClose = useCallback(function () {
|
|
31
33
|
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
32
34
|
focusInEditor();
|
|
@@ -53,6 +55,7 @@ var Modal = function Modal(_ref) {
|
|
|
53
55
|
});
|
|
54
56
|
};
|
|
55
57
|
export default (function (_ref2) {
|
|
58
|
+
var _pluginInjectionAPI$q;
|
|
56
59
|
var editorView = _ref2.editorView,
|
|
57
60
|
helpUrl = _ref2.helpUrl,
|
|
58
61
|
pluginInjectionAPI = _ref2.pluginInjectionAPI;
|
|
@@ -61,6 +64,7 @@ export default (function (_ref2) {
|
|
|
61
64
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
62
65
|
quickInsertState: quickInsertState !== null && quickInsertState !== void 0 ? quickInsertState : undefined,
|
|
63
66
|
editorView: editorView,
|
|
64
|
-
helpUrl: helpUrl
|
|
67
|
+
helpUrl: helpUrl,
|
|
68
|
+
onInsert: pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$q = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q === void 0 || (_pluginInjectionAPI$q = _pluginInjectionAPI$q.actions) === null || _pluginInjectionAPI$q === void 0 ? void 0 : _pluginInjectionAPI$q.onInsert
|
|
65
69
|
});
|
|
66
70
|
});
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
|
|
|
14
14
|
openTypeAhead: (inputMethod: TypeAheadInputMethod) => boolean;
|
|
15
15
|
insertItem: (item: QuickInsertItem, source?: INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR) => Command;
|
|
16
16
|
getSuggestions: (searchOptions: QuickInsertSearchOptions) => QuickInsertItem[];
|
|
17
|
+
onInsert: (item: QuickInsertItem) => void;
|
|
17
18
|
};
|
|
18
19
|
commands: {
|
|
19
20
|
openElementBrowserModal: EditorCommand;
|
|
@@ -16,6 +16,7 @@ export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
|
|
|
16
16
|
openTypeAhead: (inputMethod: TypeAheadInputMethod) => boolean;
|
|
17
17
|
insertItem: (item: QuickInsertItem, source?: INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR) => Command;
|
|
18
18
|
getSuggestions: (searchOptions: QuickInsertSearchOptions) => QuickInsertItem[];
|
|
19
|
+
onInsert: (item: QuickInsertItem) => void;
|
|
19
20
|
};
|
|
20
21
|
commands: {
|
|
21
22
|
openElementBrowserModal: EditorCommand;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-quick-insert",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Quick insert plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"atlassian": {
|
|
11
11
|
"team": "Editor: Lego",
|
|
12
12
|
"singleton": true,
|
|
13
|
-
"runReact18":
|
|
13
|
+
"runReact18": true
|
|
14
14
|
},
|
|
15
15
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
16
16
|
"main": "dist/cjs/index.js",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/button": "^20.
|
|
35
|
-
"@atlaskit/editor-common": "^94.
|
|
34
|
+
"@atlaskit/button": "^20.3.0",
|
|
35
|
+
"@atlaskit/editor-common": "^94.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-type-ahead": "^1.10.0",
|
|
37
37
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
38
|
-
"@atlaskit/icon": "^22.
|
|
38
|
+
"@atlaskit/icon": "^22.24.0",
|
|
39
39
|
"@atlaskit/modal-dialog": "^12.17.0",
|
|
40
40
|
"@atlaskit/theme": "^14.0.0",
|
|
41
41
|
"@atlaskit/tokens": "^2.0.0",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": "^16.8.0 || ^17.0.0 || ~18.2.0",
|
|
47
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.2.0",
|
|
47
48
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
@@ -51,7 +52,6 @@
|
|
|
51
52
|
"@atlaskit/ssr": "*",
|
|
52
53
|
"@atlaskit/visual-regression": "*",
|
|
53
54
|
"@testing-library/react": "^12.1.5",
|
|
54
|
-
"react-dom": "^16.8.0",
|
|
55
55
|
"typescript": "~5.4.2",
|
|
56
56
|
"wait-for-expect": "^1.2.0"
|
|
57
57
|
},
|