@atlaskit/editor-plugin-quick-insert 13.0.1 → 13.1.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 +17 -0
- package/dist/cjs/pm-plugins/commands/index.js +35 -3
- package/dist/cjs/quickInsertPlugin.js +56 -33
- package/dist/cjs/ui/ModalElementBrowser/ModalElementBrowser.js +2 -1
- package/dist/cjs/ui/ModalElementBrowser/index.js +24 -15
- package/dist/cjs/ui/QuickInsertMenuFooterItem.js +37 -0
- package/dist/cjs/ui/QuickInsertSectionOverflowMenuItem.js +38 -0
- package/dist/cjs/ui/getQuickInsertComponents.js +103 -11
- package/dist/es2019/pm-plugins/commands/index.js +27 -0
- package/dist/es2019/quickInsertPlugin.js +27 -5
- package/dist/es2019/ui/ModalElementBrowser/ModalElementBrowser.js +2 -1
- package/dist/es2019/ui/ModalElementBrowser/index.js +25 -16
- package/dist/es2019/ui/QuickInsertMenuFooterItem.js +31 -0
- package/dist/es2019/ui/QuickInsertSectionOverflowMenuItem.js +32 -0
- package/dist/es2019/ui/getQuickInsertComponents.js +100 -7
- package/dist/esm/pm-plugins/commands/index.js +34 -2
- package/dist/esm/quickInsertPlugin.js +57 -34
- package/dist/esm/ui/ModalElementBrowser/ModalElementBrowser.js +2 -1
- package/dist/esm/ui/ModalElementBrowser/index.js +25 -16
- package/dist/esm/ui/QuickInsertMenuFooterItem.js +28 -0
- package/dist/esm/ui/QuickInsertSectionOverflowMenuItem.js +29 -0
- package/dist/esm/ui/getQuickInsertComponents.js +105 -13
- package/dist/types/pm-plugins/commands/index.d.ts +11 -0
- package/dist/types/pm-plugins/plugin-key.d.ts +5 -1
- package/dist/types/quickInsertPluginType.d.ts +5 -0
- package/dist/types/ui/ModalElementBrowser/ModalElementBrowser.d.ts +1 -0
- package/dist/types/ui/QuickInsertMenuFooterItem.d.ts +8 -0
- package/dist/types/ui/QuickInsertSectionOverflowMenuItem.d.ts +9 -0
- package/dist/types/ui/getQuickInsertComponents.d.ts +8 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-quick-insert
|
|
2
2
|
|
|
3
|
+
## 13.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 13.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`7087f393ec725`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7087f393ec725) -
|
|
14
|
+
Add the categorized registered Quick Insert browse experience with representative native elements
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 13.0.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -3,15 +3,47 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.openElementBrowserModal = exports.createInsertItem = exports.closeElementBrowserModal = void 0;
|
|
6
|
+
exports.openElementBrowserModal = exports.openElementBrowser = exports.createInsertItem = exports.closeElementBrowserModal = exports.closeElementBrowser = void 0;
|
|
7
7
|
var _insert = require("@atlaskit/editor-common/insert");
|
|
8
8
|
var _pluginKey = require("../plugin-key");
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var openElementBrowser = exports.openElementBrowser = function openElementBrowser() {
|
|
10
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
11
|
+
category = _ref.category;
|
|
12
|
+
return function (_ref2) {
|
|
13
|
+
var tr = _ref2.tr;
|
|
14
|
+
return tr.setMeta(_pluginKey.pluginKey, {
|
|
15
|
+
elementBrowserInitialCategory: category,
|
|
16
|
+
isElementBrowserOpen: true
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
var closeElementBrowser = exports.closeElementBrowser = function closeElementBrowser() {
|
|
21
|
+
return function (state, dispatch) {
|
|
22
|
+
if (dispatch) {
|
|
23
|
+
dispatch(state.tr.setMeta(_pluginKey.pluginKey, {
|
|
24
|
+
elementBrowserInitialCategory: undefined,
|
|
25
|
+
isElementBrowserOpen: false
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @private
|
|
34
|
+
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-62138 Internal documentation for deprecation (no external access)} Tracked by EDITOR-8422. Use `openElementBrowser` instead.
|
|
35
|
+
*/
|
|
36
|
+
var openElementBrowserModal = exports.openElementBrowserModal = function openElementBrowserModal(_ref3) {
|
|
37
|
+
var tr = _ref3.tr;
|
|
11
38
|
return tr.setMeta(_pluginKey.pluginKey, {
|
|
12
39
|
isElementBrowserModalOpen: true
|
|
13
40
|
});
|
|
14
41
|
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @private
|
|
45
|
+
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-62138 Internal documentation for deprecation (no external access)} Tracked by EDITOR-8422. Use `closeElementBrowser` instead.
|
|
46
|
+
*/
|
|
15
47
|
var closeElementBrowserModal = exports.closeElementBrowserModal = function closeElementBrowserModal() {
|
|
16
48
|
return function (state, dispatch) {
|
|
17
49
|
if (dispatch) {
|
|
@@ -95,8 +95,28 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
95
95
|
};
|
|
96
96
|
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command')) {
|
|
97
97
|
var _api$uiControlRegistr;
|
|
98
|
-
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _getQuickInsertComponents.getQuickInsertComponents)(
|
|
98
|
+
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _getQuickInsertComponents.getQuickInsertComponents)({
|
|
99
|
+
api: api,
|
|
100
|
+
includeElementBrowserItems: (options === null || options === void 0 ? void 0 : options.enableElementBrowser) === true
|
|
101
|
+
}));
|
|
99
102
|
}
|
|
103
|
+
var openElementBrowser = function openElementBrowser(options) {
|
|
104
|
+
return function (_ref5) {
|
|
105
|
+
var tr = _ref5.tr;
|
|
106
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
|
|
107
|
+
var _api$metrics;
|
|
108
|
+
api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.handleIntentToStartEdit({
|
|
109
|
+
shouldStartTimer: false,
|
|
110
|
+
shouldPersistActiveSession: true
|
|
111
|
+
})({
|
|
112
|
+
tr: tr
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return (0, _commands.openElementBrowser)(options)({
|
|
116
|
+
tr: tr
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
};
|
|
100
120
|
var intl;
|
|
101
121
|
return {
|
|
102
122
|
name: 'quickInsert',
|
|
@@ -104,10 +124,10 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
104
124
|
return [{
|
|
105
125
|
name: 'quickInsert',
|
|
106
126
|
// It's important that this plugin is above TypeAheadPlugin
|
|
107
|
-
plugin: function plugin(
|
|
108
|
-
var providerFactory =
|
|
109
|
-
getIntl =
|
|
110
|
-
dispatch =
|
|
127
|
+
plugin: function plugin(_ref6) {
|
|
128
|
+
var providerFactory = _ref6.providerFactory,
|
|
129
|
+
getIntl = _ref6.getIntl,
|
|
130
|
+
dispatch = _ref6.dispatch;
|
|
111
131
|
return quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, options === null || options === void 0 ? void 0 : options.emptyStateHandler);
|
|
112
132
|
}
|
|
113
133
|
}, {
|
|
@@ -126,10 +146,10 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
126
146
|
pluginsOptions: {
|
|
127
147
|
typeAhead: typeAhead
|
|
128
148
|
},
|
|
129
|
-
contentComponent: function contentComponent(
|
|
130
|
-
var editorView =
|
|
131
|
-
popupsMountPoint =
|
|
132
|
-
wrapperElement =
|
|
149
|
+
contentComponent: function contentComponent(_ref7) {
|
|
150
|
+
var editorView = _ref7.editorView,
|
|
151
|
+
popupsMountPoint = _ref7.popupsMountPoint,
|
|
152
|
+
wrapperElement = _ref7.wrapperElement;
|
|
133
153
|
refs.popupsMountPoint = popupsMountPoint || undefined;
|
|
134
154
|
refs.wrapperElement = wrapperElement || undefined;
|
|
135
155
|
if (!editorView || (0, _coreUtils.isSSR)()) {
|
|
@@ -157,7 +177,8 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
157
177
|
lazyDefaultItems: quickInsertState.lazyDefaultItems,
|
|
158
178
|
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
159
179
|
providedItems: quickInsertState.providedItems,
|
|
160
|
-
isElementBrowserModalOpen: quickInsertState.isElementBrowserModalOpen
|
|
180
|
+
isElementBrowserModalOpen: quickInsertState.isElementBrowserModalOpen,
|
|
181
|
+
isElementBrowserOpen: quickInsertState.isElementBrowserOpen
|
|
161
182
|
};
|
|
162
183
|
},
|
|
163
184
|
actions: {
|
|
@@ -172,9 +193,9 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
172
193
|
},
|
|
173
194
|
getSuggestions: function getSuggestions(searchOptions) {
|
|
174
195
|
var _api$quickInsert$shar, _api$quickInsert;
|
|
175
|
-
var
|
|
176
|
-
lazyDefaultItems =
|
|
177
|
-
providedItems =
|
|
196
|
+
var _ref8 = (_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 : {},
|
|
197
|
+
lazyDefaultItems = _ref8.lazyDefaultItems,
|
|
198
|
+
providedItems = _ref8.providedItems;
|
|
178
199
|
if ((0, _expValEquals.expValEquals)('platform_editor_layout_typeahead_reorder', 'isEnabled', true)) {
|
|
179
200
|
var _options$prioritySort;
|
|
180
201
|
searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
|
|
@@ -201,11 +222,12 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
201
222
|
}
|
|
202
223
|
},
|
|
203
224
|
commands: {
|
|
204
|
-
|
|
205
|
-
|
|
225
|
+
openElementBrowser: openElementBrowser,
|
|
226
|
+
openElementBrowserModal: function openElementBrowserModal(_ref9) {
|
|
227
|
+
var tr = _ref9.tr;
|
|
206
228
|
if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
|
|
207
|
-
var _api$
|
|
208
|
-
api === null || api === void 0 || (_api$
|
|
229
|
+
var _api$metrics2;
|
|
230
|
+
api === null || api === void 0 || (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 || _api$metrics2.commands.handleIntentToStartEdit({
|
|
209
231
|
shouldStartTimer: false,
|
|
210
232
|
shouldPersistActiveSession: true
|
|
211
233
|
})({
|
|
@@ -217,11 +239,11 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
217
239
|
});
|
|
218
240
|
},
|
|
219
241
|
addQuickInsertItem: function addQuickInsertItem(item) {
|
|
220
|
-
return function (
|
|
242
|
+
return function (_ref0) {
|
|
221
243
|
var _api$quickInsert$shar2, _api$quickInsert2;
|
|
222
|
-
var tr =
|
|
223
|
-
var
|
|
224
|
-
lazyDefaultItems =
|
|
244
|
+
var tr = _ref0.tr;
|
|
245
|
+
var _ref1 = (_api$quickInsert$shar2 = api === null || api === void 0 || (_api$quickInsert2 = api.quickInsert) === null || _api$quickInsert2 === void 0 ? void 0 : _api$quickInsert2.sharedState.currentState()) !== null && _api$quickInsert$shar2 !== void 0 ? _api$quickInsert$shar2 : {},
|
|
246
|
+
lazyDefaultItems = _ref1.lazyDefaultItems;
|
|
225
247
|
var defaultItems = lazyDefaultItems ? lazyDefaultItems() : [];
|
|
226
248
|
var memoisedNewItems = (0, _quickInsert.memoProcessQuickInsertItems)([item], intl);
|
|
227
249
|
return tr.setMeta(_pluginKey.pluginKey, {
|
|
@@ -232,12 +254,12 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
232
254
|
};
|
|
233
255
|
},
|
|
234
256
|
updateQuickInsertItem: function updateQuickInsertItem(key, item) {
|
|
235
|
-
return function (
|
|
257
|
+
return function (_ref10) {
|
|
236
258
|
var _api$quickInsert$shar3, _api$quickInsert3;
|
|
237
|
-
var tr =
|
|
238
|
-
var
|
|
239
|
-
providedItems =
|
|
240
|
-
lazyDefaultItems =
|
|
259
|
+
var tr = _ref10.tr;
|
|
260
|
+
var _ref11 = (_api$quickInsert$shar3 = api === null || api === void 0 || (_api$quickInsert3 = api.quickInsert) === null || _api$quickInsert3 === void 0 ? void 0 : _api$quickInsert3.sharedState.currentState()) !== null && _api$quickInsert$shar3 !== void 0 ? _api$quickInsert$shar3 : {},
|
|
261
|
+
providedItems = _ref11.providedItems,
|
|
262
|
+
lazyDefaultItems = _ref11.lazyDefaultItems;
|
|
241
263
|
var defaultItems = lazyDefaultItems ? lazyDefaultItems() : [];
|
|
242
264
|
var newItem = (0, _quickInsert.memoProcessQuickInsertItems)([item], intl);
|
|
243
265
|
var replaceByKey = function replaceByKey(items) {
|
|
@@ -262,12 +284,12 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
|
|
|
262
284
|
};
|
|
263
285
|
},
|
|
264
286
|
removeQuickInsertItem: function removeQuickInsertItem(key) {
|
|
265
|
-
return function (
|
|
287
|
+
return function (_ref12) {
|
|
266
288
|
var _api$quickInsert$shar4, _api$quickInsert4, _providedItems$filter;
|
|
267
|
-
var tr =
|
|
268
|
-
var
|
|
269
|
-
providedItems =
|
|
270
|
-
lazyDefaultItems =
|
|
289
|
+
var tr = _ref12.tr;
|
|
290
|
+
var _ref13 = (_api$quickInsert$shar4 = api === null || api === void 0 || (_api$quickInsert4 = api.quickInsert) === null || _api$quickInsert4 === void 0 ? void 0 : _api$quickInsert4.sharedState.currentState()) !== null && _api$quickInsert$shar4 !== void 0 ? _api$quickInsert$shar4 : {},
|
|
291
|
+
providedItems = _ref13.providedItems,
|
|
292
|
+
lazyDefaultItems = _ref13.lazyDefaultItems;
|
|
271
293
|
var defaultItems = lazyDefaultItems ? lazyDefaultItems() : [];
|
|
272
294
|
return tr.setMeta(_pluginKey.pluginKey, {
|
|
273
295
|
providedItems: (_providedItems$filter = providedItems === null || providedItems === void 0 ? void 0 : providedItems.filter(function (item) {
|
|
@@ -302,6 +324,7 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
|
|
|
302
324
|
init: function init() {
|
|
303
325
|
return {
|
|
304
326
|
isElementBrowserModalOpen: false,
|
|
327
|
+
isElementBrowserOpen: false,
|
|
305
328
|
emptyStateHandler: emptyStateHandler,
|
|
306
329
|
// lazy so it doesn't run on editor initialization
|
|
307
330
|
// memo here to avoid using a singleton cache, avoids editor
|
|
@@ -329,7 +352,7 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
|
|
|
329
352
|
},
|
|
330
353
|
view: function view(editorView) {
|
|
331
354
|
var providerHandler = /*#__PURE__*/function () {
|
|
332
|
-
var
|
|
355
|
+
var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_name, providerPromise) {
|
|
333
356
|
var provider, providedItems, _t;
|
|
334
357
|
return _regenerator.default.wrap(function (_context) {
|
|
335
358
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -365,7 +388,7 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
|
|
|
365
388
|
}, _callee, null, [[1, 4]]);
|
|
366
389
|
}));
|
|
367
390
|
return function providerHandler(_x, _x2) {
|
|
368
|
-
return
|
|
391
|
+
return _ref14.apply(this, arguments);
|
|
369
392
|
};
|
|
370
393
|
}();
|
|
371
394
|
providerFactory.subscribe('quickInsertProvider', providerHandler);
|
|
@@ -85,6 +85,7 @@ var ModalElementBrowser = function ModalElementBrowser(props) {
|
|
|
85
85
|
css: wrapperStyles
|
|
86
86
|
}, (0, _react2.jsx)(_elementBrowser.ElementBrowser, {
|
|
87
87
|
categories: (0, _categories.getCategories)(props.intl),
|
|
88
|
+
defaultCategory: props.defaultCategory,
|
|
88
89
|
getItems: props.getItems,
|
|
89
90
|
showSearch: true,
|
|
90
91
|
showCategories: true,
|
|
@@ -94,7 +95,7 @@ var ModalElementBrowser = function ModalElementBrowser(props) {
|
|
|
94
95
|
emptyStateHandler: props.emptyStateHandler,
|
|
95
96
|
autoFocusSearch: false
|
|
96
97
|
}));
|
|
97
|
-
}, [props.intl, props.getItems, onSelectItem, onInsertItem, props.emptyStateHandler]);
|
|
98
|
+
}, [props.intl, props.defaultCategory, props.getItems, onSelectItem, onInsertItem, props.emptyStateHandler]);
|
|
98
99
|
var label = intl.formatMessage(_quickInsert.messages.browse);
|
|
99
100
|
return (0, _react2.jsx)("div", {
|
|
100
101
|
"data-editor-popup": true
|
|
@@ -11,8 +11,10 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
13
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
14
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
14
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _commands = require("../../pm-plugins/commands");
|
|
17
|
+
var _pluginKey = require("../../pm-plugins/plugin-key");
|
|
16
18
|
var _ModalElementBrowser = _interopRequireDefault(require("./ModalElementBrowser"));
|
|
17
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
18
20
|
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; }
|
|
@@ -24,7 +26,8 @@ var Modal = function Modal(_ref) {
|
|
|
24
26
|
helpUrl = _ref.helpUrl,
|
|
25
27
|
insertItem = _ref.insertItem,
|
|
26
28
|
getSuggestions = _ref.getSuggestions,
|
|
27
|
-
api = _ref.api
|
|
29
|
+
api = _ref.api,
|
|
30
|
+
defaultCategory = _ref.defaultCategory;
|
|
28
31
|
var getItems = (0, _react.useCallback)(function (query, category) {
|
|
29
32
|
var _getSuggestions$map, _getSuggestions;
|
|
30
33
|
return (_getSuggestions$map = getSuggestions === null || getSuggestions === void 0 || (_getSuggestions = getSuggestions({
|
|
@@ -49,22 +52,26 @@ var Modal = function Modal(_ref) {
|
|
|
49
52
|
// Instead of adding the item immediately on insert item
|
|
50
53
|
// We wait until modal close is complete, refocus the editor and then add the item
|
|
51
54
|
var insertableItem = _react.default.useRef(null);
|
|
55
|
+
var closeBrowser = (0, _react.useCallback)(function () {
|
|
56
|
+
var closeCommand = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command') ? _commands.closeElementBrowser : _commands.closeElementBrowserModal;
|
|
57
|
+
closeCommand()(editorView.state, editorView.dispatch);
|
|
58
|
+
}, [editorView]);
|
|
52
59
|
var onInsertItem = (0, _react.useCallback)(function (item) {
|
|
53
|
-
(
|
|
60
|
+
closeBrowser();
|
|
54
61
|
if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
|
|
55
62
|
var _api$metrics;
|
|
56
63
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.startActiveSessionTimer());
|
|
57
64
|
}
|
|
58
65
|
insertableItem.current = item;
|
|
59
|
-
}, [
|
|
66
|
+
}, [closeBrowser, api]);
|
|
60
67
|
var onClose = (0, _react.useCallback)(function () {
|
|
61
|
-
(
|
|
68
|
+
closeBrowser();
|
|
62
69
|
if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
|
|
63
70
|
var _api$metrics2;
|
|
64
71
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 ? void 0 : _api$metrics2.commands.startActiveSessionTimer());
|
|
65
72
|
}
|
|
66
73
|
focusInEditor();
|
|
67
|
-
}, [
|
|
74
|
+
}, [closeBrowser, focusInEditor, api]);
|
|
68
75
|
var onCloseComplete = (0, _react.useCallback)(function () {
|
|
69
76
|
if (!insertableItem.current) {
|
|
70
77
|
focusInEditor();
|
|
@@ -76,10 +83,11 @@ var Modal = function Modal(_ref) {
|
|
|
76
83
|
insertItem === null || insertItem === void 0 || insertItem(item, _analytics.INPUT_METHOD.ELEMENT_BROWSER)(editorView.state, editorView.dispatch);
|
|
77
84
|
}, [editorView, focusInEditor, insertItem]);
|
|
78
85
|
return /*#__PURE__*/_react.default.createElement(_ModalElementBrowser.default, {
|
|
86
|
+
defaultCategory: defaultCategory,
|
|
79
87
|
getItems: getItems,
|
|
80
88
|
onInsertItem: onInsertItem,
|
|
81
89
|
helpUrl: helpUrl,
|
|
82
|
-
isOpen: quickInsertState.
|
|
90
|
+
isOpen: quickInsertState.isElementBrowserOpen || false,
|
|
83
91
|
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
84
92
|
onClose: onClose,
|
|
85
93
|
onCloseComplete: onCloseComplete,
|
|
@@ -87,32 +95,33 @@ var Modal = function Modal(_ref) {
|
|
|
87
95
|
});
|
|
88
96
|
};
|
|
89
97
|
var _default = exports.default = function _default(_ref2) {
|
|
90
|
-
var _pluginInjectionAPI$q, _pluginInjectionAPI$q2;
|
|
98
|
+
var _pluginKey$getState, _pluginInjectionAPI$q, _pluginInjectionAPI$q2;
|
|
91
99
|
var editorView = _ref2.editorView,
|
|
92
100
|
helpUrl = _ref2.helpUrl,
|
|
93
101
|
pluginInjectionAPI = _ref2.pluginInjectionAPI;
|
|
94
102
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(pluginInjectionAPI, ['quickInsert', 'connectivity'], function (state) {
|
|
95
|
-
var _state$quickInsertSta, _state$quickInsertSta2, _state$quickInsertSta3, _state$quickInsertSta4, _state$connectivitySt;
|
|
103
|
+
var _state$quickInsertSta, _state$quickInsertSta2, _state$quickInsertSta3, _state$quickInsertSta4, _state$quickInsertSta5, _state$connectivitySt;
|
|
96
104
|
return {
|
|
97
105
|
lazyDefaultItems: (_state$quickInsertSta = state.quickInsertState) === null || _state$quickInsertSta === void 0 ? void 0 : _state$quickInsertSta.lazyDefaultItems,
|
|
98
106
|
providedItems: (_state$quickInsertSta2 = state.quickInsertState) === null || _state$quickInsertSta2 === void 0 ? void 0 : _state$quickInsertSta2.providedItems,
|
|
99
|
-
|
|
100
|
-
emptyStateHandler: (_state$
|
|
107
|
+
isElementBrowserOpen: (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command') ? (_state$quickInsertSta3 = state.quickInsertState) === null || _state$quickInsertSta3 === void 0 ? void 0 : _state$quickInsertSta3.isElementBrowserOpen : (_state$quickInsertSta4 = state.quickInsertState) === null || _state$quickInsertSta4 === void 0 ? void 0 : _state$quickInsertSta4.isElementBrowserModalOpen,
|
|
108
|
+
emptyStateHandler: (_state$quickInsertSta5 = state.quickInsertState) === null || _state$quickInsertSta5 === void 0 ? void 0 : _state$quickInsertSta5.emptyStateHandler,
|
|
101
109
|
mode: (_state$connectivitySt = state.connectivityState) === null || _state$connectivitySt === void 0 ? void 0 : _state$connectivitySt.mode
|
|
102
110
|
};
|
|
103
111
|
}),
|
|
104
112
|
lazyDefaultItems = _useSharedPluginState.lazyDefaultItems,
|
|
105
113
|
providedItems = _useSharedPluginState.providedItems,
|
|
106
|
-
|
|
114
|
+
isElementBrowserOpen = _useSharedPluginState.isElementBrowserOpen,
|
|
107
115
|
emptyStateHandler = _useSharedPluginState.emptyStateHandler,
|
|
108
116
|
mode = _useSharedPluginState.mode;
|
|
109
|
-
return /*#__PURE__*/_react.default.createElement(Modal
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
return /*#__PURE__*/_react.default.createElement(Modal, {
|
|
118
|
+
defaultCategory: (_pluginKey$getState = _pluginKey.pluginKey.getState(editorView.state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.elementBrowserInitialCategory
|
|
119
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
120
|
+
,
|
|
112
121
|
quickInsertState: {
|
|
113
122
|
lazyDefaultItems: lazyDefaultItems,
|
|
114
123
|
providedItems: providedItems,
|
|
115
|
-
|
|
124
|
+
isElementBrowserOpen: isElementBrowserOpen,
|
|
116
125
|
emptyStateHandler: emptyStateHandler
|
|
117
126
|
},
|
|
118
127
|
editorView: editorView,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.QuickInsertMenuFooterItem = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactIntl = require("react-intl");
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
|
+
var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
|
|
13
|
+
var _showMoreHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/show-more-horizontal"));
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
15
|
+
var QuickInsertMenuFooterItem = exports.QuickInsertMenuFooterItem = function QuickInsertMenuFooterItem(_ref) {
|
|
16
|
+
var api = _ref.api;
|
|
17
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
18
|
+
formatMessage = _useIntl.formatMessage;
|
|
19
|
+
var onSelect = (0, _react.useCallback)(function (_ref2) {
|
|
20
|
+
var _api$quickInsert$comm, _api$quickInsert;
|
|
21
|
+
var insert = _ref2.insert;
|
|
22
|
+
var tr = insert(undefined);
|
|
23
|
+
return (_api$quickInsert$comm = api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.commands.openElementBrowser()({
|
|
24
|
+
tr: tr
|
|
25
|
+
})) !== null && _api$quickInsert$comm !== void 0 ? _api$quickInsert$comm : tr;
|
|
26
|
+
}, [api]);
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
|
|
28
|
+
ariaLabel: formatMessage(_messages.toolbarInsertBlockMessages.viewMoreAriaLabel),
|
|
29
|
+
iconBefore: /*#__PURE__*/_react.default.createElement(_showMoreHorizontal.default, {
|
|
30
|
+
label: ""
|
|
31
|
+
}),
|
|
32
|
+
isDisabled: !(api !== null && api !== void 0 && api.quickInsert),
|
|
33
|
+
onSelect: onSelect,
|
|
34
|
+
shouldWrapIcon: false,
|
|
35
|
+
title: formatMessage(_messages.toolbarInsertBlockMessages.viewMore)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.QuickInsertSectionOverflowMenuItem = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactIntl = require("react-intl");
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
|
+
var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
|
|
13
|
+
var _add = _interopRequireDefault(require("@atlaskit/icon/core/add"));
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
15
|
+
var QuickInsertSectionOverflowMenuItem = exports.QuickInsertSectionOverflowMenuItem = function QuickInsertSectionOverflowMenuItem(_ref) {
|
|
16
|
+
var api = _ref.api,
|
|
17
|
+
category = _ref.category;
|
|
18
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
19
|
+
formatMessage = _useIntl.formatMessage;
|
|
20
|
+
var onSelect = (0, _react.useCallback)(function (_ref2) {
|
|
21
|
+
var _api$quickInsert$comm, _api$quickInsert;
|
|
22
|
+
var insert = _ref2.insert;
|
|
23
|
+
var tr = insert(undefined);
|
|
24
|
+
return (_api$quickInsert$comm = api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.commands.openElementBrowser({
|
|
25
|
+
category: category
|
|
26
|
+
})({
|
|
27
|
+
tr: tr
|
|
28
|
+
})) !== null && _api$quickInsert$comm !== void 0 ? _api$quickInsert$comm : tr;
|
|
29
|
+
}, [api, category]);
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
|
|
31
|
+
iconBefore: /*#__PURE__*/_react.default.createElement(_add.default, {
|
|
32
|
+
label: ""
|
|
33
|
+
}),
|
|
34
|
+
isDisabled: !(api !== null && api !== void 0 && api.quickInsert),
|
|
35
|
+
onSelect: onSelect,
|
|
36
|
+
title: formatMessage(_messages.toolbarInsertBlockMessages.viewMore)
|
|
37
|
+
});
|
|
38
|
+
};
|
|
@@ -5,19 +5,111 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getQuickInsertComponents = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _reactIntl = require("react-intl");
|
|
10
11
|
var _keys = require("@atlaskit/editor-common/quick-insert/keys");
|
|
12
|
+
var _menuRoot = require("@atlaskit/editor-common/quick-insert/menu-root");
|
|
13
|
+
var _menuSection = require("@atlaskit/editor-common/quick-insert/menu-section");
|
|
14
|
+
var _messages = require("@atlaskit/editor-common/quick-insert/messages");
|
|
11
15
|
var _rank = require("@atlaskit/editor-common/quick-insert/rank");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
var _typeAheadGetMenuFooterSectionKey = require("@atlaskit/editor-common/type-ahead-get-menu-footer-section-key");
|
|
17
|
+
var _typeAheadGetSectionOverflowItemKey = require("@atlaskit/editor-common/type-ahead-get-section-overflow-item-key");
|
|
18
|
+
var _QuickInsertMenuFooterItem = require("./QuickInsertMenuFooterItem");
|
|
19
|
+
var _QuickInsertSectionOverflowMenuItem = require("./QuickInsertSectionOverflowMenuItem");
|
|
20
|
+
var categories = [{
|
|
21
|
+
message: _messages.messages.categoryRecommended,
|
|
22
|
+
section: _keys.RECOMMENDED_SECTION
|
|
23
|
+
}, {
|
|
24
|
+
message: _messages.messages.categoryStructure,
|
|
25
|
+
section: _keys.STRUCTURE_SECTION
|
|
26
|
+
}, {
|
|
27
|
+
message: _messages.messages.categoryMedia,
|
|
28
|
+
section: _keys.MEDIA_SECTION
|
|
29
|
+
}, {
|
|
30
|
+
message: _messages.messages.categoryEmbed,
|
|
31
|
+
section: _keys.EMBED_SECTION
|
|
32
|
+
}, {
|
|
33
|
+
message: _messages.messages.categoryTextFormatting,
|
|
34
|
+
section: _keys.TEXT_FORMATTING_SECTION
|
|
35
|
+
}, {
|
|
36
|
+
message: _messages.messages.categoryRovo,
|
|
37
|
+
section: _keys.ROVO_SECTION
|
|
38
|
+
}, {
|
|
39
|
+
message: _messages.messages.categoryDataAndCharts,
|
|
40
|
+
section: _keys.DATA_AND_CHARTS_SECTION
|
|
41
|
+
}, {
|
|
42
|
+
message: _messages.messages.categoryBlockTemplates,
|
|
43
|
+
section: _keys.BLOCK_TEMPLATES_SECTION
|
|
44
|
+
}, {
|
|
45
|
+
message: _messages.messages.categoryOther,
|
|
46
|
+
section: _keys.OTHER_SECTION
|
|
47
|
+
}];
|
|
48
|
+
var createSectionComponent = function createSectionComponent(message) {
|
|
49
|
+
var SectionComponent = function SectionComponent(_ref) {
|
|
50
|
+
var children = _ref.children;
|
|
51
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
52
|
+
formatMessage = _useIntl.formatMessage;
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(_menuSection.QuickInsertMenuSection, {
|
|
54
|
+
title: formatMessage(message)
|
|
55
|
+
}, children);
|
|
56
|
+
};
|
|
57
|
+
return SectionComponent;
|
|
58
|
+
};
|
|
59
|
+
var getQuickInsertComponents = exports.getQuickInsertComponents = function getQuickInsertComponents(_ref2) {
|
|
60
|
+
var api = _ref2.api,
|
|
61
|
+
includeElementBrowserItems = _ref2.includeElementBrowserItems;
|
|
62
|
+
return [{
|
|
63
|
+
key: _keys.MENU.key,
|
|
64
|
+
type: _keys.MENU.type,
|
|
65
|
+
component: _menuRoot.QuickInsertMenuRoot
|
|
66
|
+
}].concat((0, _toConsumableArray2.default)(categories.flatMap(function (_ref3) {
|
|
67
|
+
var message = _ref3.message,
|
|
68
|
+
section = _ref3.section;
|
|
69
|
+
return [{
|
|
70
|
+
key: section.key,
|
|
71
|
+
type: section.type,
|
|
72
|
+
parents: [{
|
|
73
|
+
key: _keys.MENU.key,
|
|
74
|
+
type: _keys.MENU.type,
|
|
19
75
|
rank: _rank.QUICK_INSERT_MENU_RANK[section.key]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
76
|
+
}],
|
|
77
|
+
component: createSectionComponent(message)
|
|
78
|
+
}].concat((0, _toConsumableArray2.default)(includeElementBrowserItems ? [{
|
|
79
|
+
key: (0, _typeAheadGetSectionOverflowItemKey.getSectionOverflowItemKey)(section.key),
|
|
80
|
+
type: 'menu-item',
|
|
81
|
+
parents: [{
|
|
82
|
+
key: section.key,
|
|
83
|
+
type: section.type,
|
|
84
|
+
rank: _rank.CATEGORY_VIEW_MORE_RANK
|
|
85
|
+
}],
|
|
86
|
+
component: function component() {
|
|
87
|
+
return /*#__PURE__*/_react.default.createElement(_QuickInsertSectionOverflowMenuItem.QuickInsertSectionOverflowMenuItem, {
|
|
88
|
+
api: api,
|
|
89
|
+
category: section.key
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}] : []));
|
|
93
|
+
})), (0, _toConsumableArray2.default)(includeElementBrowserItems ? [{
|
|
94
|
+
key: (0, _typeAheadGetMenuFooterSectionKey.getMenuFooterSectionKey)(_keys.MENU.key),
|
|
95
|
+
type: 'menu-section',
|
|
96
|
+
parents: [{
|
|
97
|
+
key: _keys.MENU.key,
|
|
98
|
+
type: _keys.MENU.type,
|
|
99
|
+
rank: Number.MAX_SAFE_INTEGER
|
|
100
|
+
}]
|
|
101
|
+
}, {
|
|
102
|
+
key: _keys.VIEW_ALL_ELEMENTS_MENU_ITEM.key,
|
|
103
|
+
type: _keys.VIEW_ALL_ELEMENTS_MENU_ITEM.type,
|
|
104
|
+
parents: [{
|
|
105
|
+
key: (0, _typeAheadGetMenuFooterSectionKey.getMenuFooterSectionKey)(_keys.MENU.key),
|
|
106
|
+
type: 'menu-section',
|
|
107
|
+
rank: 100
|
|
108
|
+
}],
|
|
109
|
+
component: function component() {
|
|
110
|
+
return /*#__PURE__*/_react.default.createElement(_QuickInsertMenuFooterItem.QuickInsertMenuFooterItem, {
|
|
111
|
+
api: api
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}] : []));
|
|
23
115
|
};
|
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
2
2
|
import { pluginKey } from '../plugin-key';
|
|
3
|
+
export const openElementBrowser = ({
|
|
4
|
+
category
|
|
5
|
+
} = {}) => ({
|
|
6
|
+
tr
|
|
7
|
+
}) => tr.setMeta(pluginKey, {
|
|
8
|
+
elementBrowserInitialCategory: category,
|
|
9
|
+
isElementBrowserOpen: true
|
|
10
|
+
});
|
|
11
|
+
export const closeElementBrowser = () => (state, dispatch) => {
|
|
12
|
+
if (dispatch) {
|
|
13
|
+
dispatch(state.tr.setMeta(pluginKey, {
|
|
14
|
+
elementBrowserInitialCategory: undefined,
|
|
15
|
+
isElementBrowserOpen: false
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @private
|
|
23
|
+
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-62138 Internal documentation for deprecation (no external access)} Tracked by EDITOR-8422. Use `openElementBrowser` instead.
|
|
24
|
+
*/
|
|
3
25
|
export const openElementBrowserModal = ({
|
|
4
26
|
tr
|
|
5
27
|
}) => tr.setMeta(pluginKey, {
|
|
6
28
|
isElementBrowserModalOpen: true
|
|
7
29
|
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-62138 Internal documentation for deprecation (no external access)} Tracked by EDITOR-8422. Use `closeElementBrowser` instead.
|
|
34
|
+
*/
|
|
8
35
|
export const closeElementBrowserModal = () => (state, dispatch) => {
|
|
9
36
|
if (dispatch) {
|
|
10
37
|
dispatch(state.tr.setMeta(pluginKey, {
|