@atlaskit/editor-plugin-quick-insert 2.4.2 → 2.5.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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-quick-insert
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#150874](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/150874)
|
|
8
|
+
[`447821a1397a2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/447821a1397a2) -
|
|
9
|
+
Used plugin selector conditionally behind feature flag
|
|
10
|
+
|
|
3
11
|
## 2.4.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -9,6 +9,7 @@ exports.default = void 0;
|
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
12
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _commands = require("../../pm-plugins/commands");
|
|
14
15
|
var _ModalElementBrowser = _interopRequireDefault(require("./ModalElementBrowser"));
|
|
@@ -37,7 +38,7 @@ var Modal = function Modal(_ref) {
|
|
|
37
38
|
},
|
|
38
39
|
// See: https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/157796/overview?commentId=8559952
|
|
39
40
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
-
[getSuggestions, quickInsertState
|
|
41
|
+
[getSuggestions, quickInsertState.lazyDefaultItems, quickInsertState.providedItems, isOffline]);
|
|
41
42
|
var focusInEditor = (0, _react.useCallback)(function () {
|
|
42
43
|
if (!editorView.hasFocus()) {
|
|
43
44
|
editorView.focus();
|
|
@@ -78,26 +79,59 @@ var Modal = function Modal(_ref) {
|
|
|
78
79
|
getItems: getItems,
|
|
79
80
|
onInsertItem: onInsertItem,
|
|
80
81
|
helpUrl: helpUrl,
|
|
81
|
-
isOpen:
|
|
82
|
-
emptyStateHandler: quickInsertState
|
|
82
|
+
isOpen: quickInsertState.isElementBrowserModalOpen || false,
|
|
83
|
+
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
83
84
|
onClose: onClose,
|
|
84
85
|
onCloseComplete: onCloseComplete,
|
|
85
86
|
shouldReturnFocus: false
|
|
86
87
|
});
|
|
87
88
|
};
|
|
89
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
|
|
90
|
+
var lazyDefaultItems = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'quickInsert.lazyDefaultItems');
|
|
91
|
+
var providedItems = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'quickInsert.providedItems');
|
|
92
|
+
var isElementBrowserModalOpen = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'quickInsert.isElementBrowserModalOpen');
|
|
93
|
+
var emptyStateHandler = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'quickInsert.emptyStateHandler');
|
|
94
|
+
var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'connectivity.mode');
|
|
95
|
+
return {
|
|
96
|
+
mode: mode,
|
|
97
|
+
lazyDefaultItems: lazyDefaultItems,
|
|
98
|
+
providedItems: providedItems,
|
|
99
|
+
isElementBrowserModalOpen: isElementBrowserModalOpen,
|
|
100
|
+
emptyStateHandler: emptyStateHandler
|
|
101
|
+
};
|
|
102
|
+
}, function (api) {
|
|
103
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['quickInsert', 'connectivity']),
|
|
104
|
+
quickInsertState = _useSharedPluginState.quickInsertState,
|
|
105
|
+
connectivityState = _useSharedPluginState.connectivityState;
|
|
106
|
+
return {
|
|
107
|
+
lazyDefaultItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems,
|
|
108
|
+
providedItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems,
|
|
109
|
+
isElementBrowserModalOpen: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen,
|
|
110
|
+
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
111
|
+
mode: connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode
|
|
112
|
+
};
|
|
113
|
+
});
|
|
88
114
|
var _default = exports.default = function _default(_ref2) {
|
|
89
115
|
var _pluginInjectionAPI$q, _pluginInjectionAPI$q2;
|
|
90
116
|
var editorView = _ref2.editorView,
|
|
91
117
|
helpUrl = _ref2.helpUrl,
|
|
92
118
|
pluginInjectionAPI = _ref2.pluginInjectionAPI;
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
|
|
119
|
+
var _useSharedState = useSharedState(pluginInjectionAPI),
|
|
120
|
+
lazyDefaultItems = _useSharedState.lazyDefaultItems,
|
|
121
|
+
providedItems = _useSharedState.providedItems,
|
|
122
|
+
isElementBrowserModalOpen = _useSharedState.isElementBrowserModalOpen,
|
|
123
|
+
emptyStateHandler = _useSharedState.emptyStateHandler,
|
|
124
|
+
mode = _useSharedState.mode;
|
|
96
125
|
return /*#__PURE__*/_react.default.createElement(Modal, {
|
|
97
|
-
quickInsertState:
|
|
126
|
+
quickInsertState: {
|
|
127
|
+
lazyDefaultItems: lazyDefaultItems,
|
|
128
|
+
providedItems: providedItems,
|
|
129
|
+
isElementBrowserModalOpen: isElementBrowserModalOpen,
|
|
130
|
+
emptyStateHandler: emptyStateHandler
|
|
131
|
+
},
|
|
98
132
|
editorView: editorView,
|
|
99
133
|
helpUrl: helpUrl,
|
|
100
|
-
isOffline:
|
|
134
|
+
isOffline: mode === 'offline',
|
|
101
135
|
insertItem: 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.insertItem,
|
|
102
136
|
getSuggestions: pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$q2 = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q2 === void 0 || (_pluginInjectionAPI$q2 = _pluginInjectionAPI$q2.actions) === null || _pluginInjectionAPI$q2 === void 0 ? void 0 : _pluginInjectionAPI$q2.getSuggestions,
|
|
103
137
|
api: pluginInjectionAPI
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
3
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { closeElementBrowserModal } from '../../pm-plugins/commands';
|
|
5
6
|
import ModalElementBrowser from './ModalElementBrowser';
|
|
@@ -26,7 +27,7 @@ const Modal = ({
|
|
|
26
27
|
},
|
|
27
28
|
// See: https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/157796/overview?commentId=8559952
|
|
28
29
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
-
[getSuggestions, quickInsertState
|
|
30
|
+
[getSuggestions, quickInsertState.lazyDefaultItems, quickInsertState.providedItems, isOffline]);
|
|
30
31
|
const focusInEditor = useCallback(() => {
|
|
31
32
|
if (!editorView.hasFocus()) {
|
|
32
33
|
editorView.focus();
|
|
@@ -67,13 +68,39 @@ const Modal = ({
|
|
|
67
68
|
getItems: getItems,
|
|
68
69
|
onInsertItem: onInsertItem,
|
|
69
70
|
helpUrl: helpUrl,
|
|
70
|
-
isOpen:
|
|
71
|
-
emptyStateHandler: quickInsertState
|
|
71
|
+
isOpen: quickInsertState.isElementBrowserModalOpen || false,
|
|
72
|
+
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
72
73
|
onClose: onClose,
|
|
73
74
|
onCloseComplete: onCloseComplete,
|
|
74
75
|
shouldReturnFocus: false
|
|
75
76
|
});
|
|
76
77
|
};
|
|
78
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
79
|
+
const lazyDefaultItems = useSharedPluginStateSelector(api, 'quickInsert.lazyDefaultItems');
|
|
80
|
+
const providedItems = useSharedPluginStateSelector(api, 'quickInsert.providedItems');
|
|
81
|
+
const isElementBrowserModalOpen = useSharedPluginStateSelector(api, 'quickInsert.isElementBrowserModalOpen');
|
|
82
|
+
const emptyStateHandler = useSharedPluginStateSelector(api, 'quickInsert.emptyStateHandler');
|
|
83
|
+
const mode = useSharedPluginStateSelector(api, 'connectivity.mode');
|
|
84
|
+
return {
|
|
85
|
+
mode,
|
|
86
|
+
lazyDefaultItems,
|
|
87
|
+
providedItems,
|
|
88
|
+
isElementBrowserModalOpen,
|
|
89
|
+
emptyStateHandler
|
|
90
|
+
};
|
|
91
|
+
}, api => {
|
|
92
|
+
const {
|
|
93
|
+
quickInsertState,
|
|
94
|
+
connectivityState
|
|
95
|
+
} = useSharedPluginState(api, ['quickInsert', 'connectivity']);
|
|
96
|
+
return {
|
|
97
|
+
lazyDefaultItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems,
|
|
98
|
+
providedItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems,
|
|
99
|
+
isElementBrowserModalOpen: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen,
|
|
100
|
+
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
101
|
+
mode: connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode
|
|
102
|
+
};
|
|
103
|
+
});
|
|
77
104
|
export default (({
|
|
78
105
|
editorView,
|
|
79
106
|
helpUrl,
|
|
@@ -81,14 +108,22 @@ export default (({
|
|
|
81
108
|
}) => {
|
|
82
109
|
var _pluginInjectionAPI$q, _pluginInjectionAPI$q2, _pluginInjectionAPI$q3, _pluginInjectionAPI$q4;
|
|
83
110
|
const {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
111
|
+
lazyDefaultItems,
|
|
112
|
+
providedItems,
|
|
113
|
+
isElementBrowserModalOpen,
|
|
114
|
+
emptyStateHandler,
|
|
115
|
+
mode
|
|
116
|
+
} = useSharedState(pluginInjectionAPI);
|
|
87
117
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
88
|
-
quickInsertState:
|
|
118
|
+
quickInsertState: {
|
|
119
|
+
lazyDefaultItems,
|
|
120
|
+
providedItems,
|
|
121
|
+
isElementBrowserModalOpen,
|
|
122
|
+
emptyStateHandler
|
|
123
|
+
},
|
|
89
124
|
editorView: editorView,
|
|
90
125
|
helpUrl: helpUrl,
|
|
91
|
-
isOffline:
|
|
126
|
+
isOffline: mode === 'offline',
|
|
92
127
|
insertItem: 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.insertItem,
|
|
93
128
|
getSuggestions: pluginInjectionAPI === null || pluginInjectionAPI === void 0 ? void 0 : (_pluginInjectionAPI$q3 = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q3 === void 0 ? void 0 : (_pluginInjectionAPI$q4 = _pluginInjectionAPI$q3.actions) === null || _pluginInjectionAPI$q4 === void 0 ? void 0 : _pluginInjectionAPI$q4.getSuggestions,
|
|
94
129
|
api: pluginInjectionAPI
|
|
@@ -2,7 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
import React, { useCallback } from 'react';
|
|
5
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
6
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { closeElementBrowserModal } from '../../pm-plugins/commands';
|
|
8
9
|
import ModalElementBrowser from './ModalElementBrowser';
|
|
@@ -27,7 +28,7 @@ var Modal = function Modal(_ref) {
|
|
|
27
28
|
},
|
|
28
29
|
// See: https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/157796/overview?commentId=8559952
|
|
29
30
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
-
[getSuggestions, quickInsertState
|
|
31
|
+
[getSuggestions, quickInsertState.lazyDefaultItems, quickInsertState.providedItems, isOffline]);
|
|
31
32
|
var focusInEditor = useCallback(function () {
|
|
32
33
|
if (!editorView.hasFocus()) {
|
|
33
34
|
editorView.focus();
|
|
@@ -68,26 +69,59 @@ var Modal = function Modal(_ref) {
|
|
|
68
69
|
getItems: getItems,
|
|
69
70
|
onInsertItem: onInsertItem,
|
|
70
71
|
helpUrl: helpUrl,
|
|
71
|
-
isOpen:
|
|
72
|
-
emptyStateHandler: quickInsertState
|
|
72
|
+
isOpen: quickInsertState.isElementBrowserModalOpen || false,
|
|
73
|
+
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
73
74
|
onClose: onClose,
|
|
74
75
|
onCloseComplete: onCloseComplete,
|
|
75
76
|
shouldReturnFocus: false
|
|
76
77
|
});
|
|
77
78
|
};
|
|
79
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
|
|
80
|
+
var lazyDefaultItems = useSharedPluginStateSelector(api, 'quickInsert.lazyDefaultItems');
|
|
81
|
+
var providedItems = useSharedPluginStateSelector(api, 'quickInsert.providedItems');
|
|
82
|
+
var isElementBrowserModalOpen = useSharedPluginStateSelector(api, 'quickInsert.isElementBrowserModalOpen');
|
|
83
|
+
var emptyStateHandler = useSharedPluginStateSelector(api, 'quickInsert.emptyStateHandler');
|
|
84
|
+
var mode = useSharedPluginStateSelector(api, 'connectivity.mode');
|
|
85
|
+
return {
|
|
86
|
+
mode: mode,
|
|
87
|
+
lazyDefaultItems: lazyDefaultItems,
|
|
88
|
+
providedItems: providedItems,
|
|
89
|
+
isElementBrowserModalOpen: isElementBrowserModalOpen,
|
|
90
|
+
emptyStateHandler: emptyStateHandler
|
|
91
|
+
};
|
|
92
|
+
}, function (api) {
|
|
93
|
+
var _useSharedPluginState = useSharedPluginState(api, ['quickInsert', 'connectivity']),
|
|
94
|
+
quickInsertState = _useSharedPluginState.quickInsertState,
|
|
95
|
+
connectivityState = _useSharedPluginState.connectivityState;
|
|
96
|
+
return {
|
|
97
|
+
lazyDefaultItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems,
|
|
98
|
+
providedItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems,
|
|
99
|
+
isElementBrowserModalOpen: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen,
|
|
100
|
+
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
101
|
+
mode: connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode
|
|
102
|
+
};
|
|
103
|
+
});
|
|
78
104
|
export default (function (_ref2) {
|
|
79
105
|
var _pluginInjectionAPI$q, _pluginInjectionAPI$q2;
|
|
80
106
|
var editorView = _ref2.editorView,
|
|
81
107
|
helpUrl = _ref2.helpUrl,
|
|
82
108
|
pluginInjectionAPI = _ref2.pluginInjectionAPI;
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
109
|
+
var _useSharedState = useSharedState(pluginInjectionAPI),
|
|
110
|
+
lazyDefaultItems = _useSharedState.lazyDefaultItems,
|
|
111
|
+
providedItems = _useSharedState.providedItems,
|
|
112
|
+
isElementBrowserModalOpen = _useSharedState.isElementBrowserModalOpen,
|
|
113
|
+
emptyStateHandler = _useSharedState.emptyStateHandler,
|
|
114
|
+
mode = _useSharedState.mode;
|
|
86
115
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
87
|
-
quickInsertState:
|
|
116
|
+
quickInsertState: {
|
|
117
|
+
lazyDefaultItems: lazyDefaultItems,
|
|
118
|
+
providedItems: providedItems,
|
|
119
|
+
isElementBrowserModalOpen: isElementBrowserModalOpen,
|
|
120
|
+
emptyStateHandler: emptyStateHandler
|
|
121
|
+
},
|
|
88
122
|
editorView: editorView,
|
|
89
123
|
helpUrl: helpUrl,
|
|
90
|
-
isOffline:
|
|
124
|
+
isOffline: mode === 'offline',
|
|
91
125
|
insertItem: 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.insertItem,
|
|
92
126
|
getSuggestions: pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$q2 = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q2 === void 0 || (_pluginInjectionAPI$q2 = _pluginInjectionAPI$q2.actions) === null || _pluginInjectionAPI$q2 === void 0 ? void 0 : _pluginInjectionAPI$q2.getSuggestions,
|
|
93
127
|
api: pluginInjectionAPI
|