@atlaskit/editor-plugin-quick-insert 0.1.1 → 0.2.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 +17 -0
- package/README.md +1 -1
- package/dist/cjs/commands.js +4 -7
- package/dist/cjs/plugin-key.js +1 -2
- package/dist/cjs/plugin.js +31 -23
- package/dist/cjs/search.js +2 -3
- package/dist/cjs/ui/ModalElementBrowser/ModalElementBrowser.js +5 -5
- package/dist/cjs/ui/ModalElementBrowser/index.js +22 -7
- package/dist/cjs/ui/ModalElementBrowser/messages.js +2 -3
- package/dist/es2019/plugin.js +82 -71
- package/dist/es2019/ui/ModalElementBrowser/ModalElementBrowser.js +3 -1
- package/dist/es2019/ui/ModalElementBrowser/index.js +20 -4
- package/dist/esm/plugin.js +30 -21
- package/dist/esm/ui/ModalElementBrowser/ModalElementBrowser.js +3 -1
- package/dist/esm/ui/ModalElementBrowser/index.js +20 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugin.d.ts +7 -1
- package/dist/types/ui/ModalElementBrowser/ModalElementBrowser.d.ts +2 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/plugin.d.ts +9 -1
- package/dist/types-ts4.5/ui/ModalElementBrowser/ModalElementBrowser.d.ts +2 -0
- package/package.json +4 -3
- package/report.api.md +11 -1
- package/tmp/api-report-tmp.d.ts +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-quick-insert
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#41143](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41143) [`7d6dfe2befa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7d6dfe2befa) - [ED-20003] Replace TyepAhead API for Editor Plugin Injection API
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 0.1.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#39425](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39425) [`4c27d14af2e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4c27d14af2e) - [ED-19408] Fix issue where FocusTrap returnFocus was causing the cursor to end up at the beginning of the document when inserting elements using the element browser modal.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 0.1.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -27,4 +27,4 @@ Please see [Atlaskit - Editor plugin quick insert](https://atlaskit.atlassian.co
|
|
|
27
27
|
For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
|
|
28
28
|
## License
|
|
29
29
|
---
|
|
30
|
-
Please see [Atlassian Frontend - License](https://
|
|
30
|
+
Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
|
package/dist/cjs/commands.js
CHANGED
|
@@ -6,14 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.openElementBrowserModal = exports.insertItem = exports.closeElementBrowserModal = void 0;
|
|
7
7
|
var _insert = require("@atlaskit/editor-common/insert");
|
|
8
8
|
var _pluginKey = require("./plugin-key");
|
|
9
|
-
var openElementBrowserModal = function openElementBrowserModal(_ref) {
|
|
9
|
+
var openElementBrowserModal = exports.openElementBrowserModal = function openElementBrowserModal(_ref) {
|
|
10
10
|
var tr = _ref.tr;
|
|
11
11
|
return tr.setMeta(_pluginKey.pluginKey, {
|
|
12
12
|
isElementBrowserModalOpen: true
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
exports.
|
|
16
|
-
var closeElementBrowserModal = function closeElementBrowserModal() {
|
|
15
|
+
var closeElementBrowserModal = exports.closeElementBrowserModal = function closeElementBrowserModal() {
|
|
17
16
|
return function (state, dispatch) {
|
|
18
17
|
if (dispatch) {
|
|
19
18
|
dispatch(state.tr.setMeta(_pluginKey.pluginKey, {
|
|
@@ -25,8 +24,7 @@ var closeElementBrowserModal = function closeElementBrowserModal() {
|
|
|
25
24
|
};
|
|
26
25
|
|
|
27
26
|
// this method was adapted from the typeahead plugin so we respect the API for quick insert items
|
|
28
|
-
exports.
|
|
29
|
-
var insertItem = function insertItem(item) {
|
|
27
|
+
var insertItem = exports.insertItem = function insertItem(item) {
|
|
30
28
|
return function (state, dispatch) {
|
|
31
29
|
var insert = function insert(maybeNode) {
|
|
32
30
|
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -40,5 +38,4 @@ var insertItem = function insertItem(item) {
|
|
|
40
38
|
}
|
|
41
39
|
return true;
|
|
42
40
|
};
|
|
43
|
-
};
|
|
44
|
-
exports.insertItem = insertItem;
|
|
41
|
+
};
|
package/dist/cjs/plugin-key.js
CHANGED
|
@@ -5,5 +5,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.pluginKey = void 0;
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var pluginKey = new _state.PluginKey('quickInsertPluginKey');
|
|
9
|
-
exports.pluginKey = pluginKey;
|
|
8
|
+
var pluginKey = exports.pluginKey = new _state.PluginKey('quickInsertPluginKey');
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -18,41 +18,42 @@ var _search = require("./search");
|
|
|
18
18
|
var _ModalElementBrowser = _interopRequireDefault(require("./ui/ModalElementBrowser"));
|
|
19
19
|
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; }
|
|
20
20
|
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) { (0, _defineProperty2.default)(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; }
|
|
21
|
-
var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
21
|
+
var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
22
22
|
var options = _ref.config,
|
|
23
23
|
api = _ref.api;
|
|
24
|
+
var typeAhead = {
|
|
25
|
+
id: _typeAhead.TypeAheadAvailableNodes.QUICK_INSERT,
|
|
26
|
+
trigger: '/',
|
|
27
|
+
headless: options === null || options === void 0 ? void 0 : options.headless,
|
|
28
|
+
getItems: function getItems(_ref2) {
|
|
29
|
+
var query = _ref2.query,
|
|
30
|
+
editorState = _ref2.editorState;
|
|
31
|
+
var quickInsertState = _pluginKey.pluginKey.getState(editorState);
|
|
32
|
+
return Promise.resolve((0, _search.getQuickInsertSuggestions)({
|
|
33
|
+
query: query,
|
|
34
|
+
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
35
|
+
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
36
|
+
},
|
|
37
|
+
selectItem: function selectItem(state, item, insert) {
|
|
38
|
+
return item.action(insert, state);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
24
41
|
return {
|
|
25
42
|
name: 'quickInsert',
|
|
26
43
|
pmPlugins: function pmPlugins(defaultItems) {
|
|
27
44
|
return [{
|
|
28
45
|
name: 'quickInsert',
|
|
29
46
|
// It's important that this plugin is above TypeAheadPlugin
|
|
30
|
-
plugin: function plugin(
|
|
31
|
-
var providerFactory =
|
|
32
|
-
getIntl =
|
|
33
|
-
dispatch =
|
|
47
|
+
plugin: function plugin(_ref3) {
|
|
48
|
+
var providerFactory = _ref3.providerFactory,
|
|
49
|
+
getIntl = _ref3.getIntl,
|
|
50
|
+
dispatch = _ref3.dispatch;
|
|
34
51
|
return quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, options === null || options === void 0 ? void 0 : options.emptyStateHandler);
|
|
35
52
|
}
|
|
36
53
|
}];
|
|
37
54
|
},
|
|
38
55
|
pluginsOptions: {
|
|
39
|
-
typeAhead:
|
|
40
|
-
id: _typeAhead.TypeAheadAvailableNodes.QUICK_INSERT,
|
|
41
|
-
trigger: '/',
|
|
42
|
-
headless: options === null || options === void 0 ? void 0 : options.headless,
|
|
43
|
-
getItems: function getItems(_ref3) {
|
|
44
|
-
var query = _ref3.query,
|
|
45
|
-
editorState = _ref3.editorState;
|
|
46
|
-
var quickInsertState = _pluginKey.pluginKey.getState(editorState);
|
|
47
|
-
return Promise.resolve((0, _search.getQuickInsertSuggestions)({
|
|
48
|
-
query: query,
|
|
49
|
-
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
50
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
51
|
-
},
|
|
52
|
-
selectItem: function selectItem(state, item, insert) {
|
|
53
|
-
return item.action(insert, state);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
+
typeAhead: typeAhead
|
|
56
57
|
},
|
|
57
58
|
contentComponent: function contentComponent(_ref4) {
|
|
58
59
|
var editorView = _ref4.editorView;
|
|
@@ -74,6 +75,7 @@ var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
74
75
|
return null;
|
|
75
76
|
}
|
|
76
77
|
return {
|
|
78
|
+
typeAheadHandler: typeAhead,
|
|
77
79
|
lazyDefaultItems: quickInsertState.lazyDefaultItems,
|
|
78
80
|
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
79
81
|
providedItems: quickInsertState.providedItems,
|
|
@@ -82,6 +84,13 @@ var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
82
84
|
},
|
|
83
85
|
actions: {
|
|
84
86
|
insertItem: _commands.insertItem,
|
|
87
|
+
openTypeAhead: function openTypeAhead(inputMethod) {
|
|
88
|
+
var _api$typeAhead;
|
|
89
|
+
return Boolean(api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.open({
|
|
90
|
+
triggerHandler: typeAhead,
|
|
91
|
+
inputMethod: inputMethod
|
|
92
|
+
}));
|
|
93
|
+
},
|
|
85
94
|
getSuggestions: function getSuggestions(searchOptions) {
|
|
86
95
|
var _api$quickInsert$shar;
|
|
87
96
|
var _ref5 = (_api$quickInsert$shar = api === null || api === void 0 ? void 0 : api.quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {},
|
|
@@ -95,7 +104,6 @@ var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
95
104
|
}
|
|
96
105
|
};
|
|
97
106
|
};
|
|
98
|
-
exports.quickInsertPlugin = quickInsertPlugin;
|
|
99
107
|
var setProviderState = function setProviderState(providerState) {
|
|
100
108
|
return function (state, dispatch) {
|
|
101
109
|
if (dispatch) {
|
package/dist/cjs/search.js
CHANGED
|
@@ -8,7 +8,7 @@ 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
|
-
var getQuickInsertSuggestions = function getQuickInsertSuggestions(searchOptions) {
|
|
11
|
+
var getQuickInsertSuggestions = exports.getQuickInsertSuggestions = function getQuickInsertSuggestions(searchOptions) {
|
|
12
12
|
var lazyDefaultItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
13
13
|
return [];
|
|
14
14
|
};
|
|
@@ -29,5 +29,4 @@ var getQuickInsertSuggestions = function getQuickInsertSuggestions(searchOptions
|
|
|
29
29
|
return (0, _quickInsert.find)(query || '', category === 'all' || !category ? items : items.filter(function (item) {
|
|
30
30
|
return item.categories && item.categories.includes(category);
|
|
31
31
|
}));
|
|
32
|
-
};
|
|
33
|
-
exports.getQuickInsertSuggestions = getQuickInsertSuggestions;
|
|
32
|
+
};
|
|
@@ -23,8 +23,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
23
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
24
|
/** @jsx jsx */
|
|
25
25
|
|
|
26
|
-
var MODAL_WRAPPER_PADDING = 16;
|
|
27
|
-
exports.MODAL_WRAPPER_PADDING = MODAL_WRAPPER_PADDING;
|
|
26
|
+
var MODAL_WRAPPER_PADDING = exports.MODAL_WRAPPER_PADDING = 16;
|
|
28
27
|
var actionsStyles = (0, _react2.css)({
|
|
29
28
|
display: 'inline-flex',
|
|
30
29
|
margin: "0 ".concat("var(--ds-space-negative-050, -4px)")
|
|
@@ -105,9 +104,11 @@ var ModalElementBrowser = function ModalElementBrowser(props) {
|
|
|
105
104
|
stackIndex: 0,
|
|
106
105
|
key: "element-browser-modal",
|
|
107
106
|
onClose: props.onClose,
|
|
107
|
+
onCloseComplete: props.onCloseComplete,
|
|
108
108
|
height: "664px",
|
|
109
109
|
width: "x-large",
|
|
110
|
-
autoFocus: false
|
|
110
|
+
autoFocus: false,
|
|
111
|
+
shouldReturnFocus: props.shouldReturnFocus
|
|
111
112
|
// defaults to true and doesn't work along with stackIndex=1.
|
|
112
113
|
// packages/design-system/modal-dialog/src/components/Content.tsx Line 287
|
|
113
114
|
,
|
|
@@ -155,5 +156,4 @@ var HelpLink = function HelpLink(url, helpText) {
|
|
|
155
156
|
testId: "ModalElementBrowser__help-button"
|
|
156
157
|
}, helpText);
|
|
157
158
|
};
|
|
158
|
-
var _default = (0, _reactIntlNext.injectIntl)(ModalElementBrowser);
|
|
159
|
-
exports.default = _default;
|
|
159
|
+
var _default = exports.default = (0, _reactIntlNext.injectIntl)(ModalElementBrowser);
|
|
@@ -28,25 +28,41 @@ var Modal = function Modal(_ref) {
|
|
|
28
28
|
editorView.focus();
|
|
29
29
|
}
|
|
30
30
|
}, [editorView]);
|
|
31
|
+
|
|
32
|
+
// ED-19408 We not store the item ref in the state
|
|
33
|
+
// Instead of adding the item immediately on insert item
|
|
34
|
+
// We wait until modal close is complete, refocus the editor and then add the item
|
|
35
|
+
var insertableItem = _react.default.useRef(null);
|
|
31
36
|
var onInsertItem = (0, _react.useCallback)(function (item) {
|
|
32
37
|
(0, _commands.closeElementBrowserModal)()(editorView.state, editorView.dispatch);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, [editorView, focusInEditor]);
|
|
38
|
+
insertableItem.current = item;
|
|
39
|
+
}, [editorView]);
|
|
36
40
|
var onClose = (0, _react.useCallback)(function () {
|
|
37
41
|
(0, _commands.closeElementBrowserModal)()(editorView.state, editorView.dispatch);
|
|
38
42
|
focusInEditor();
|
|
39
43
|
}, [editorView, focusInEditor]);
|
|
44
|
+
var onCloseComplete = (0, _react.useCallback)(function () {
|
|
45
|
+
if (!insertableItem.current) {
|
|
46
|
+
focusInEditor();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
var item = insertableItem.current;
|
|
50
|
+
insertableItem.current = null;
|
|
51
|
+
focusInEditor();
|
|
52
|
+
(0, _commands.insertItem)(item)(editorView.state, editorView.dispatch);
|
|
53
|
+
}, [editorView, focusInEditor]);
|
|
40
54
|
return /*#__PURE__*/_react.default.createElement(_ModalElementBrowser.default, {
|
|
41
55
|
getItems: getItems,
|
|
42
56
|
onInsertItem: onInsertItem,
|
|
43
57
|
helpUrl: helpUrl,
|
|
44
58
|
isOpen: (quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen) || false,
|
|
45
59
|
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
46
|
-
onClose: onClose
|
|
60
|
+
onClose: onClose,
|
|
61
|
+
onCloseComplete: onCloseComplete,
|
|
62
|
+
shouldReturnFocus: false
|
|
47
63
|
});
|
|
48
64
|
};
|
|
49
|
-
var _default = function _default(_ref2) {
|
|
65
|
+
var _default = exports.default = function _default(_ref2) {
|
|
50
66
|
var editorView = _ref2.editorView,
|
|
51
67
|
helpUrl = _ref2.helpUrl,
|
|
52
68
|
pluginInjectionAPI = _ref2.pluginInjectionAPI;
|
|
@@ -57,5 +73,4 @@ var _default = function _default(_ref2) {
|
|
|
57
73
|
editorView: editorView,
|
|
58
74
|
helpUrl: helpUrl
|
|
59
75
|
});
|
|
60
|
-
};
|
|
61
|
-
exports.default = _default;
|
|
76
|
+
};
|
|
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.messages = void 0;
|
|
7
7
|
var _reactIntlNext = require("react-intl-next");
|
|
8
|
-
var messages = (0, _reactIntlNext.defineMessages)({
|
|
8
|
+
var messages = exports.messages = (0, _reactIntlNext.defineMessages)({
|
|
9
9
|
help: {
|
|
10
10
|
id: 'fabric.editor.elementBrowser.help',
|
|
11
11
|
defaultMessage: 'Help',
|
|
12
12
|
description: 'Element browser help button label'
|
|
13
13
|
}
|
|
14
|
-
});
|
|
15
|
-
exports.messages = messages;
|
|
14
|
+
});
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -9,81 +9,92 @@ import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
|
9
9
|
export const quickInsertPlugin = ({
|
|
10
10
|
config: options,
|
|
11
11
|
api
|
|
12
|
-
}) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}];
|
|
24
|
-
},
|
|
25
|
-
pluginsOptions: {
|
|
26
|
-
typeAhead: {
|
|
27
|
-
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
28
|
-
trigger: '/',
|
|
29
|
-
headless: options === null || options === void 0 ? void 0 : options.headless,
|
|
30
|
-
getItems({
|
|
12
|
+
}) => {
|
|
13
|
+
const typeAhead = {
|
|
14
|
+
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
15
|
+
trigger: '/',
|
|
16
|
+
headless: options === null || options === void 0 ? void 0 : options.headless,
|
|
17
|
+
getItems({
|
|
18
|
+
query,
|
|
19
|
+
editorState
|
|
20
|
+
}) {
|
|
21
|
+
const quickInsertState = pluginKey.getState(editorState);
|
|
22
|
+
return Promise.resolve(getQuickInsertSuggestions({
|
|
31
23
|
query,
|
|
32
|
-
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
38
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
39
|
-
},
|
|
40
|
-
selectItem: (state, item, insert) => {
|
|
41
|
-
return item.action(insert, state);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
contentComponent({
|
|
46
|
-
editorView
|
|
47
|
-
}) {
|
|
48
|
-
if (options !== null && options !== void 0 && options.enableElementBrowser) {
|
|
49
|
-
return /*#__PURE__*/React.createElement(ModalElementBrowser, {
|
|
50
|
-
editorView: editorView,
|
|
51
|
-
helpUrl: options === null || options === void 0 ? void 0 : options.elementBrowserHelpUrl,
|
|
52
|
-
pluginInjectionAPI: api
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
},
|
|
57
|
-
getSharedState(editorState) {
|
|
58
|
-
if (!editorState) {
|
|
59
|
-
return null;
|
|
24
|
+
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
25
|
+
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
26
|
+
},
|
|
27
|
+
selectItem: (state, item, insert) => {
|
|
28
|
+
return item.action(insert, state);
|
|
60
29
|
}
|
|
61
|
-
|
|
62
|
-
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
name: 'quickInsert',
|
|
33
|
+
pmPlugins(defaultItems) {
|
|
34
|
+
return [{
|
|
35
|
+
name: 'quickInsert',
|
|
36
|
+
// It's important that this plugin is above TypeAheadPlugin
|
|
37
|
+
plugin: ({
|
|
38
|
+
providerFactory,
|
|
39
|
+
getIntl,
|
|
40
|
+
dispatch
|
|
41
|
+
}) => quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, options === null || options === void 0 ? void 0 : options.emptyStateHandler)
|
|
42
|
+
}];
|
|
43
|
+
},
|
|
44
|
+
pluginsOptions: {
|
|
45
|
+
typeAhead
|
|
46
|
+
},
|
|
47
|
+
contentComponent({
|
|
48
|
+
editorView
|
|
49
|
+
}) {
|
|
50
|
+
if (options !== null && options !== void 0 && options.enableElementBrowser) {
|
|
51
|
+
return /*#__PURE__*/React.createElement(ModalElementBrowser, {
|
|
52
|
+
editorView: editorView,
|
|
53
|
+
helpUrl: options === null || options === void 0 ? void 0 : options.elementBrowserHelpUrl,
|
|
54
|
+
pluginInjectionAPI: api
|
|
55
|
+
});
|
|
56
|
+
}
|
|
63
57
|
return null;
|
|
58
|
+
},
|
|
59
|
+
getSharedState(editorState) {
|
|
60
|
+
if (!editorState) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const quickInsertState = pluginKey.getState(editorState);
|
|
64
|
+
if (!quickInsertState) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
typeAheadHandler: typeAhead,
|
|
69
|
+
lazyDefaultItems: quickInsertState.lazyDefaultItems,
|
|
70
|
+
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
71
|
+
providedItems: quickInsertState.providedItems,
|
|
72
|
+
isElementBrowserModalOpen: quickInsertState.isElementBrowserModalOpen
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
actions: {
|
|
76
|
+
insertItem,
|
|
77
|
+
openTypeAhead(inputMethod) {
|
|
78
|
+
var _api$typeAhead;
|
|
79
|
+
return Boolean(api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.open({
|
|
80
|
+
triggerHandler: typeAhead,
|
|
81
|
+
inputMethod
|
|
82
|
+
}));
|
|
83
|
+
},
|
|
84
|
+
getSuggestions: searchOptions => {
|
|
85
|
+
var _api$quickInsert$shar;
|
|
86
|
+
const {
|
|
87
|
+
lazyDefaultItems,
|
|
88
|
+
providedItems
|
|
89
|
+
} = (_api$quickInsert$shar = api === null || api === void 0 ? void 0 : api.quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {};
|
|
90
|
+
return getQuickInsertSuggestions(searchOptions, lazyDefaultItems, providedItems);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
commands: {
|
|
94
|
+
openElementBrowserModal
|
|
64
95
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
68
|
-
providedItems: quickInsertState.providedItems,
|
|
69
|
-
isElementBrowserModalOpen: quickInsertState.isElementBrowserModalOpen
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
actions: {
|
|
73
|
-
insertItem,
|
|
74
|
-
getSuggestions: searchOptions => {
|
|
75
|
-
var _api$quickInsert$shar;
|
|
76
|
-
const {
|
|
77
|
-
lazyDefaultItems,
|
|
78
|
-
providedItems
|
|
79
|
-
} = (_api$quickInsert$shar = api === null || api === void 0 ? void 0 : api.quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {};
|
|
80
|
-
return getQuickInsertSuggestions(searchOptions, lazyDefaultItems, providedItems);
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
commands: {
|
|
84
|
-
openElementBrowserModal
|
|
85
|
-
}
|
|
86
|
-
});
|
|
96
|
+
};
|
|
97
|
+
};
|
|
87
98
|
const setProviderState = providerState => (state, dispatch) => {
|
|
88
99
|
if (dispatch) {
|
|
89
100
|
dispatch(state.tr.setMeta(pluginKey, providerState));
|
|
@@ -85,9 +85,11 @@ const ModalElementBrowser = props => {
|
|
|
85
85
|
stackIndex: 0,
|
|
86
86
|
key: "element-browser-modal",
|
|
87
87
|
onClose: props.onClose,
|
|
88
|
+
onCloseComplete: props.onCloseComplete,
|
|
88
89
|
height: "664px",
|
|
89
90
|
width: "x-large",
|
|
90
|
-
autoFocus: false
|
|
91
|
+
autoFocus: false,
|
|
92
|
+
shouldReturnFocus: props.shouldReturnFocus
|
|
91
93
|
// defaults to true and doesn't work along with stackIndex=1.
|
|
92
94
|
// packages/design-system/modal-dialog/src/components/Content.tsx Line 287
|
|
93
95
|
,
|
|
@@ -17,22 +17,38 @@ const Modal = ({
|
|
|
17
17
|
editorView.focus();
|
|
18
18
|
}
|
|
19
19
|
}, [editorView]);
|
|
20
|
+
|
|
21
|
+
// ED-19408 We not store the item ref in the state
|
|
22
|
+
// Instead of adding the item immediately on insert item
|
|
23
|
+
// We wait until modal close is complete, refocus the editor and then add the item
|
|
24
|
+
const insertableItem = React.useRef(null);
|
|
20
25
|
const onInsertItem = useCallback(item => {
|
|
21
26
|
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}, [editorView, focusInEditor]);
|
|
27
|
+
insertableItem.current = item;
|
|
28
|
+
}, [editorView]);
|
|
25
29
|
const onClose = useCallback(() => {
|
|
26
30
|
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
27
31
|
focusInEditor();
|
|
28
32
|
}, [editorView, focusInEditor]);
|
|
33
|
+
const onCloseComplete = useCallback(() => {
|
|
34
|
+
if (!insertableItem.current) {
|
|
35
|
+
focusInEditor();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const item = insertableItem.current;
|
|
39
|
+
insertableItem.current = null;
|
|
40
|
+
focusInEditor();
|
|
41
|
+
insertItem(item)(editorView.state, editorView.dispatch);
|
|
42
|
+
}, [editorView, focusInEditor]);
|
|
29
43
|
return /*#__PURE__*/React.createElement(ModalElementBrowser, {
|
|
30
44
|
getItems: getItems,
|
|
31
45
|
onInsertItem: onInsertItem,
|
|
32
46
|
helpUrl: helpUrl,
|
|
33
47
|
isOpen: (quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen) || false,
|
|
34
48
|
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
35
|
-
onClose: onClose
|
|
49
|
+
onClose: onClose,
|
|
50
|
+
onCloseComplete: onCloseComplete,
|
|
51
|
+
shouldReturnFocus: false
|
|
36
52
|
});
|
|
37
53
|
};
|
|
38
54
|
export default (({
|
package/dist/esm/plugin.js
CHANGED
|
@@ -14,38 +14,39 @@ import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
|
14
14
|
export var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
15
15
|
var options = _ref.config,
|
|
16
16
|
api = _ref.api;
|
|
17
|
+
var typeAhead = {
|
|
18
|
+
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
19
|
+
trigger: '/',
|
|
20
|
+
headless: options === null || options === void 0 ? void 0 : options.headless,
|
|
21
|
+
getItems: function getItems(_ref2) {
|
|
22
|
+
var query = _ref2.query,
|
|
23
|
+
editorState = _ref2.editorState;
|
|
24
|
+
var quickInsertState = pluginKey.getState(editorState);
|
|
25
|
+
return Promise.resolve(getQuickInsertSuggestions({
|
|
26
|
+
query: query,
|
|
27
|
+
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
28
|
+
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
29
|
+
},
|
|
30
|
+
selectItem: function selectItem(state, item, insert) {
|
|
31
|
+
return item.action(insert, state);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
17
34
|
return {
|
|
18
35
|
name: 'quickInsert',
|
|
19
36
|
pmPlugins: function pmPlugins(defaultItems) {
|
|
20
37
|
return [{
|
|
21
38
|
name: 'quickInsert',
|
|
22
39
|
// It's important that this plugin is above TypeAheadPlugin
|
|
23
|
-
plugin: function plugin(
|
|
24
|
-
var providerFactory =
|
|
25
|
-
getIntl =
|
|
26
|
-
dispatch =
|
|
40
|
+
plugin: function plugin(_ref3) {
|
|
41
|
+
var providerFactory = _ref3.providerFactory,
|
|
42
|
+
getIntl = _ref3.getIntl,
|
|
43
|
+
dispatch = _ref3.dispatch;
|
|
27
44
|
return quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, options === null || options === void 0 ? void 0 : options.emptyStateHandler);
|
|
28
45
|
}
|
|
29
46
|
}];
|
|
30
47
|
},
|
|
31
48
|
pluginsOptions: {
|
|
32
|
-
typeAhead:
|
|
33
|
-
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
34
|
-
trigger: '/',
|
|
35
|
-
headless: options === null || options === void 0 ? void 0 : options.headless,
|
|
36
|
-
getItems: function getItems(_ref3) {
|
|
37
|
-
var query = _ref3.query,
|
|
38
|
-
editorState = _ref3.editorState;
|
|
39
|
-
var quickInsertState = pluginKey.getState(editorState);
|
|
40
|
-
return Promise.resolve(getQuickInsertSuggestions({
|
|
41
|
-
query: query,
|
|
42
|
-
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
43
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
44
|
-
},
|
|
45
|
-
selectItem: function selectItem(state, item, insert) {
|
|
46
|
-
return item.action(insert, state);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
+
typeAhead: typeAhead
|
|
49
50
|
},
|
|
50
51
|
contentComponent: function contentComponent(_ref4) {
|
|
51
52
|
var editorView = _ref4.editorView;
|
|
@@ -67,6 +68,7 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
67
68
|
return null;
|
|
68
69
|
}
|
|
69
70
|
return {
|
|
71
|
+
typeAheadHandler: typeAhead,
|
|
70
72
|
lazyDefaultItems: quickInsertState.lazyDefaultItems,
|
|
71
73
|
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
72
74
|
providedItems: quickInsertState.providedItems,
|
|
@@ -75,6 +77,13 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
75
77
|
},
|
|
76
78
|
actions: {
|
|
77
79
|
insertItem: insertItem,
|
|
80
|
+
openTypeAhead: function openTypeAhead(inputMethod) {
|
|
81
|
+
var _api$typeAhead;
|
|
82
|
+
return Boolean(api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.open({
|
|
83
|
+
triggerHandler: typeAhead,
|
|
84
|
+
inputMethod: inputMethod
|
|
85
|
+
}));
|
|
86
|
+
},
|
|
78
87
|
getSuggestions: function getSuggestions(searchOptions) {
|
|
79
88
|
var _api$quickInsert$shar;
|
|
80
89
|
var _ref5 = (_api$quickInsert$shar = api === null || api === void 0 ? void 0 : api.quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {},
|
|
@@ -93,9 +93,11 @@ var ModalElementBrowser = function ModalElementBrowser(props) {
|
|
|
93
93
|
stackIndex: 0,
|
|
94
94
|
key: "element-browser-modal",
|
|
95
95
|
onClose: props.onClose,
|
|
96
|
+
onCloseComplete: props.onCloseComplete,
|
|
96
97
|
height: "664px",
|
|
97
98
|
width: "x-large",
|
|
98
|
-
autoFocus: false
|
|
99
|
+
autoFocus: false,
|
|
100
|
+
shouldReturnFocus: props.shouldReturnFocus
|
|
99
101
|
// defaults to true and doesn't work along with stackIndex=1.
|
|
100
102
|
// packages/design-system/modal-dialog/src/components/Content.tsx Line 287
|
|
101
103
|
,
|
|
@@ -18,22 +18,38 @@ var Modal = function Modal(_ref) {
|
|
|
18
18
|
editorView.focus();
|
|
19
19
|
}
|
|
20
20
|
}, [editorView]);
|
|
21
|
+
|
|
22
|
+
// ED-19408 We not store the item ref in the state
|
|
23
|
+
// Instead of adding the item immediately on insert item
|
|
24
|
+
// We wait until modal close is complete, refocus the editor and then add the item
|
|
25
|
+
var insertableItem = React.useRef(null);
|
|
21
26
|
var onInsertItem = useCallback(function (item) {
|
|
22
27
|
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, [editorView, focusInEditor]);
|
|
28
|
+
insertableItem.current = item;
|
|
29
|
+
}, [editorView]);
|
|
26
30
|
var onClose = useCallback(function () {
|
|
27
31
|
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
28
32
|
focusInEditor();
|
|
29
33
|
}, [editorView, focusInEditor]);
|
|
34
|
+
var onCloseComplete = useCallback(function () {
|
|
35
|
+
if (!insertableItem.current) {
|
|
36
|
+
focusInEditor();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var item = insertableItem.current;
|
|
40
|
+
insertableItem.current = null;
|
|
41
|
+
focusInEditor();
|
|
42
|
+
insertItem(item)(editorView.state, editorView.dispatch);
|
|
43
|
+
}, [editorView, focusInEditor]);
|
|
30
44
|
return /*#__PURE__*/React.createElement(ModalElementBrowser, {
|
|
31
45
|
getItems: getItems,
|
|
32
46
|
onInsertItem: onInsertItem,
|
|
33
47
|
helpUrl: helpUrl,
|
|
34
48
|
isOpen: (quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen) || false,
|
|
35
49
|
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
36
|
-
onClose: onClose
|
|
50
|
+
onClose: onClose,
|
|
51
|
+
onCloseComplete: onCloseComplete,
|
|
52
|
+
shouldReturnFocus: false
|
|
37
53
|
});
|
|
38
54
|
};
|
|
39
55
|
export default (function (_ref2) {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { quickInsertPlugin } from './plugin';
|
|
2
|
-
export type { QuickInsertPlugin } from './plugin';
|
|
2
|
+
export type { QuickInsertPlugin, QuickInsertSharedState } from './plugin';
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
-
import type { Command, EditorCommand, NextEditorPlugin, QuickInsertPluginOptions, QuickInsertSearchOptions,
|
|
2
|
+
import type { Command, QuickInsertSharedState as CommonQuickInsertSharedState, EditorCommand, NextEditorPlugin, QuickInsertPluginOptions, QuickInsertSearchOptions, TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { TypeAheadInputMethod, TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
3
4
|
export type { QuickInsertPluginOptions };
|
|
5
|
+
export type QuickInsertSharedState = CommonQuickInsertSharedState & {
|
|
6
|
+
typeAheadHandler: TypeAheadHandler;
|
|
7
|
+
};
|
|
4
8
|
export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
|
|
5
9
|
pluginConfiguration: QuickInsertPluginOptions | undefined;
|
|
10
|
+
dependencies: [TypeAheadPlugin];
|
|
6
11
|
sharedState: QuickInsertSharedState | null;
|
|
7
12
|
actions: {
|
|
13
|
+
openTypeAhead: (inputMethod: TypeAheadInputMethod) => boolean;
|
|
8
14
|
insertItem: (item: QuickInsertItem) => Command;
|
|
9
15
|
getSuggestions: (searchOptions: QuickInsertSearchOptions) => QuickInsertItem[];
|
|
10
16
|
};
|
|
@@ -9,8 +9,10 @@ export interface Props {
|
|
|
9
9
|
onInsertItem: (item: QuickInsertItem) => void;
|
|
10
10
|
isOpen?: boolean;
|
|
11
11
|
onClose: () => void;
|
|
12
|
+
onCloseComplete: () => void;
|
|
12
13
|
helpUrl?: string | undefined;
|
|
13
14
|
emptyStateHandler?: EmptyStateHandler;
|
|
15
|
+
shouldReturnFocus?: boolean;
|
|
14
16
|
}
|
|
15
17
|
declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
16
18
|
WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { quickInsertPlugin } from './plugin';
|
|
2
|
-
export type { QuickInsertPlugin } from './plugin';
|
|
2
|
+
export type { QuickInsertPlugin, QuickInsertSharedState } from './plugin';
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
-
import type { Command, EditorCommand, NextEditorPlugin, QuickInsertPluginOptions, QuickInsertSearchOptions,
|
|
2
|
+
import type { Command, QuickInsertSharedState as CommonQuickInsertSharedState, EditorCommand, NextEditorPlugin, QuickInsertPluginOptions, QuickInsertSearchOptions, TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { TypeAheadInputMethod, TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
3
4
|
export type { QuickInsertPluginOptions };
|
|
5
|
+
export type QuickInsertSharedState = CommonQuickInsertSharedState & {
|
|
6
|
+
typeAheadHandler: TypeAheadHandler;
|
|
7
|
+
};
|
|
4
8
|
export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
|
|
5
9
|
pluginConfiguration: QuickInsertPluginOptions | undefined;
|
|
10
|
+
dependencies: [
|
|
11
|
+
TypeAheadPlugin
|
|
12
|
+
];
|
|
6
13
|
sharedState: QuickInsertSharedState | null;
|
|
7
14
|
actions: {
|
|
15
|
+
openTypeAhead: (inputMethod: TypeAheadInputMethod) => boolean;
|
|
8
16
|
insertItem: (item: QuickInsertItem) => Command;
|
|
9
17
|
getSuggestions: (searchOptions: QuickInsertSearchOptions) => QuickInsertItem[];
|
|
10
18
|
};
|
|
@@ -9,8 +9,10 @@ export interface Props {
|
|
|
9
9
|
onInsertItem: (item: QuickInsertItem) => void;
|
|
10
10
|
isOpen?: boolean;
|
|
11
11
|
onClose: () => void;
|
|
12
|
+
onCloseComplete: () => void;
|
|
12
13
|
helpUrl?: string | undefined;
|
|
13
14
|
emptyStateHandler?: EmptyStateHandler;
|
|
15
|
+
shouldReturnFocus?: boolean;
|
|
14
16
|
}
|
|
15
17
|
declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
16
18
|
WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-quick-insert",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Quick insert plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@atlaskit/button": "^16.10.0",
|
|
39
|
-
"@atlaskit/editor-common": "^76.
|
|
39
|
+
"@atlaskit/editor-common": "^76.6.0",
|
|
40
|
+
"@atlaskit/editor-plugin-type-ahead": "^0.5.0",
|
|
40
41
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
41
42
|
"@atlaskit/icon": "^21.12.0",
|
|
42
|
-
"@atlaskit/modal-dialog": "^12.
|
|
43
|
+
"@atlaskit/modal-dialog": "^12.8.0",
|
|
43
44
|
"@atlaskit/theme": "^12.6.0",
|
|
44
45
|
"@atlaskit/tokens": "^1.25.0",
|
|
45
46
|
"@babel/runtime": "^7.0.0",
|
package/report.api.md
CHANGED
|
@@ -21,15 +21,20 @@ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
|
21
21
|
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
22
22
|
import type { QuickInsertPluginOptions } from '@atlaskit/editor-common/types';
|
|
23
23
|
import type { QuickInsertSearchOptions } from '@atlaskit/editor-common/types';
|
|
24
|
-
import type { QuickInsertSharedState } from '@atlaskit/editor-common/types';
|
|
24
|
+
import type { QuickInsertSharedState as QuickInsertSharedState_2 } from '@atlaskit/editor-common/types';
|
|
25
|
+
import type { TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
26
|
+
import type { TypeAheadInputMethod } from '@atlaskit/editor-plugin-type-ahead';
|
|
27
|
+
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
25
28
|
|
|
26
29
|
// @public (undocumented)
|
|
27
30
|
export type QuickInsertPlugin = NextEditorPlugin<
|
|
28
31
|
'quickInsert',
|
|
29
32
|
{
|
|
30
33
|
pluginConfiguration: QuickInsertPluginOptions | undefined;
|
|
34
|
+
dependencies: [TypeAheadPlugin];
|
|
31
35
|
sharedState: QuickInsertSharedState | null;
|
|
32
36
|
actions: {
|
|
37
|
+
openTypeAhead: (inputMethod: TypeAheadInputMethod) => boolean;
|
|
33
38
|
insertItem: (item: QuickInsertItem) => Command;
|
|
34
39
|
getSuggestions: (
|
|
35
40
|
searchOptions: QuickInsertSearchOptions,
|
|
@@ -44,6 +49,11 @@ export type QuickInsertPlugin = NextEditorPlugin<
|
|
|
44
49
|
// @public (undocumented)
|
|
45
50
|
export const quickInsertPlugin: QuickInsertPlugin;
|
|
46
51
|
|
|
52
|
+
// @public (undocumented)
|
|
53
|
+
export type QuickInsertSharedState = QuickInsertSharedState_2 & {
|
|
54
|
+
typeAheadHandler: TypeAheadHandler;
|
|
55
|
+
};
|
|
56
|
+
|
|
47
57
|
// (No @packageDocumentation comment for this package)
|
|
48
58
|
```
|
|
49
59
|
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -10,13 +10,18 @@ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
|
10
10
|
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
11
11
|
import type { QuickInsertPluginOptions } from '@atlaskit/editor-common/types';
|
|
12
12
|
import type { QuickInsertSearchOptions } from '@atlaskit/editor-common/types';
|
|
13
|
-
import type { QuickInsertSharedState } from '@atlaskit/editor-common/types';
|
|
13
|
+
import type { QuickInsertSharedState as QuickInsertSharedState_2 } from '@atlaskit/editor-common/types';
|
|
14
|
+
import type { TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
15
|
+
import type { TypeAheadInputMethod } from '@atlaskit/editor-plugin-type-ahead';
|
|
16
|
+
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
14
17
|
|
|
15
18
|
// @public (undocumented)
|
|
16
19
|
export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
|
|
17
20
|
pluginConfiguration: QuickInsertPluginOptions | undefined;
|
|
21
|
+
dependencies: [TypeAheadPlugin];
|
|
18
22
|
sharedState: QuickInsertSharedState | null;
|
|
19
23
|
actions: {
|
|
24
|
+
openTypeAhead: (inputMethod: TypeAheadInputMethod) => boolean;
|
|
20
25
|
insertItem: (item: QuickInsertItem) => Command;
|
|
21
26
|
getSuggestions: (searchOptions: QuickInsertSearchOptions) => QuickInsertItem[];
|
|
22
27
|
};
|
|
@@ -28,6 +33,11 @@ export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
|
|
|
28
33
|
// @public (undocumented)
|
|
29
34
|
export const quickInsertPlugin: QuickInsertPlugin;
|
|
30
35
|
|
|
36
|
+
// @public (undocumented)
|
|
37
|
+
export type QuickInsertSharedState = QuickInsertSharedState_2 & {
|
|
38
|
+
typeAheadHandler: TypeAheadHandler;
|
|
39
|
+
};
|
|
40
|
+
|
|
31
41
|
// (No @packageDocumentation comment for this package)
|
|
32
42
|
|
|
33
43
|
```
|