@atlaskit/editor-plugin-quick-insert 19.0.1 → 19.0.3

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/quickInsertPlugin.js +6 -13
  3. package/dist/cjs/ui/ModalElementBrowser/ModalElementBrowser.js +2 -2
  4. package/dist/cjs/ui/RegistryElementBrowser/RegistryElementBrowser.js +2 -2
  5. package/dist/cjs/ui/RegistryElementBrowser/index.js +1 -1
  6. package/dist/cjs/ui/getLegacyCompatibleComponents.js +7 -0
  7. package/dist/cjs/ui/getQuickInsertComponents.js +1 -1
  8. package/dist/cjs/ui/getRecommendedComponents.js +2 -2
  9. package/dist/es2019/entry-points/quick-insert-plugin.js +1 -0
  10. package/dist/es2019/entry-points/registry-element-browser.js +1 -0
  11. package/dist/es2019/quickInsertPlugin.js +7 -15
  12. package/dist/es2019/ui/ModalElementBrowser/ModalElementBrowser.js +2 -2
  13. package/dist/es2019/ui/RegistryElementBrowser/RegistryElementBrowser.js +2 -2
  14. package/dist/es2019/ui/RegistryElementBrowser/index.js +1 -1
  15. package/dist/es2019/ui/getLegacyCompatibleComponents.js +7 -0
  16. package/dist/es2019/ui/getQuickInsertComponents.js +1 -1
  17. package/dist/es2019/ui/getRecommendedComponents.js +2 -2
  18. package/dist/esm/entry-points/quick-insert-plugin.js +1 -0
  19. package/dist/esm/entry-points/registry-element-browser.js +1 -0
  20. package/dist/esm/quickInsertPlugin.js +6 -13
  21. package/dist/esm/ui/ModalElementBrowser/ModalElementBrowser.js +2 -2
  22. package/dist/esm/ui/RegistryElementBrowser/RegistryElementBrowser.js +2 -2
  23. package/dist/esm/ui/RegistryElementBrowser/index.js +1 -1
  24. package/dist/esm/ui/getLegacyCompatibleComponents.js +7 -0
  25. package/dist/esm/ui/getQuickInsertComponents.js +1 -1
  26. package/dist/esm/ui/getRecommendedComponents.js +2 -2
  27. package/dist/types/ui/getQuickInsertComponents.d.ts +1 -1
  28. package/dist/types/ui/getRecommendedComponents.d.ts +1 -1
  29. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/editor-plugin-quick-insert
2
2
 
3
+ ## 19.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`64a76a7487e96`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/64a76a7487e96) -
8
+ Add block template hover previews keyed by stable snippet IDs behind
9
+ platform_editor_slash_command, including the legacy Confluence provider path and the direct
10
+ extension renderer used by the slash menu. Unknown snippet IDs remain without a preview. Use the
11
+ supplied highest-quality light and dark preview assets for all 21 supported block templates.
12
+ - Updated dependencies
13
+
14
+ ## 19.0.2
15
+
16
+ ### Patch Changes
17
+
18
+ - [`1e8d2aad8e882`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1e8d2aad8e882) -
19
+ Remove the permanent `platform_editor_layout_typeahead_reorder` experiment and its temporary
20
+ Editor Statsig registration.
21
+ - Updated dependencies
22
+
3
23
  ## 19.0.1
4
24
 
5
25
  ### Patch Changes
@@ -25,8 +25,8 @@ var _appCategoryAnalytics = require("./app-category-analytics");
25
25
  var _commands = require("./pm-plugins/commands");
26
26
  var _quickInsertOpenExperience = require("./pm-plugins/experiences/quick-insert-open-experience");
27
27
  var _pluginKey = require("./pm-plugins/plugin-key");
28
- var _getLegacyCompatibleComponents = require("./ui/getLegacyCompatibleComponents");
29
28
  var _blockControlQuickInsert = require("./ui/block-control-quick-insert");
29
+ var _getLegacyCompatibleComponents = require("./ui/getLegacyCompatibleComponents");
30
30
  var _getQuickInsertComponents = require("./ui/getQuickInsertComponents");
31
31
  var _ModalElementBrowser = _interopRequireDefault(require("./ui/ModalElementBrowser"));
32
32
  var _RegistryElementBrowser = require("./ui/RegistryElementBrowser");
@@ -41,7 +41,7 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
41
41
  var _options$onInsert;
42
42
  options === null || options === void 0 || (_options$onInsert = options.onInsert) === null || _options$onInsert === void 0 || _options$onInsert.call(options, item);
43
43
  };
44
- var typeAheadPrioritySortingFn = (0, _expValEquals.expValEquals)('platform_editor_layout_typeahead_reorder', 'isEnabled', true) ? (0, _search.withLayoutQuickInsertPrioritySorting)(options === null || options === void 0 ? void 0 : options.prioritySortingFn) : options === null || options === void 0 ? void 0 : options.prioritySortingFn;
44
+ var typeAheadPrioritySortingFn = (0, _search.withLayoutQuickInsertPrioritySorting)(options === null || options === void 0 ? void 0 : options.prioritySortingFn);
45
45
  var typeAhead = {
46
46
  id: _typeAhead.TypeAheadAvailableNodes.QUICK_INSERT,
47
47
  trigger: '/',
@@ -224,20 +224,13 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
224
224
  }));
225
225
  },
226
226
  getSuggestions: function getSuggestions(searchOptions) {
227
- var _api$quickInsert$shar, _api$quickInsert;
227
+ var _api$quickInsert$shar, _api$quickInsert, _options$prioritySort;
228
228
  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 : {},
229
229
  lazyDefaultItems = _ref8.lazyDefaultItems,
230
230
  providedItems = _ref8.providedItems;
231
- if ((0, _expValEquals.expValEquals)('platform_editor_layout_typeahead_reorder', 'isEnabled', true)) {
232
- var _options$prioritySort;
233
- searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
234
- prioritySortingFn: (0, _search.withLayoutQuickInsertPrioritySorting)((_options$prioritySort = options === null || options === void 0 ? void 0 : options.prioritySortingFn) !== null && _options$prioritySort !== void 0 ? _options$prioritySort : searchOptions.prioritySortingFn)
235
- });
236
- } else if (options !== null && options !== void 0 && options.prioritySortingFn) {
237
- searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
238
- prioritySortingFn: options.prioritySortingFn
239
- });
240
- }
231
+ searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
232
+ prioritySortingFn: (0, _search.withLayoutQuickInsertPrioritySorting)((_options$prioritySort = options === null || options === void 0 ? void 0 : options.prioritySortingFn) !== null && _options$prioritySort !== void 0 ? _options$prioritySort : searchOptions.prioritySortingFn)
233
+ });
241
234
 
242
235
  // EDITOR-6558: layer the consumer-supplied filter (e.g. Markdown Mode allowlist)
243
236
  // over any caller-supplied filter so both apply.
@@ -13,10 +13,10 @@ var _button = _interopRequireDefault(require("@atlaskit/button/button"));
13
13
  var _elementBrowser = require("@atlaskit/editor-common/element-browser");
14
14
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
15
15
  var _questionCircle = _interopRequireDefault(require("@atlaskit/icon/core/question-circle"));
16
- var _modalDialog = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-dialog"));
17
16
  var _closeButton = require("@atlaskit/modal-dialog/close-button");
18
- var _modalTransition = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-transition"));
19
17
  var _hooks = require("@atlaskit/modal-dialog/hooks");
18
+ var _modalDialog = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-dialog"));
19
+ var _modalTransition = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-transition"));
20
20
  var _categories = require("./categories");
21
21
  /**
22
22
  * @jsxRuntime classic
@@ -13,13 +13,13 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
13
13
  var _react = _interopRequireWildcard(require("react"));
14
14
  var _reactIntl = require("react-intl");
15
15
  var _button = _interopRequireDefault(require("@atlaskit/button/icon/button"));
16
- var _heading = _interopRequireDefault(require("@atlaskit/heading/heading"));
17
16
  var _keys = require("@atlaskit/editor-common/quick-insert/keys");
18
17
  var _typeAheadGetMenuFooterSectionKey = require("@atlaskit/editor-common/type-ahead-get-menu-footer-section-key");
19
18
  var _typeAheadGetSectionOverflowItemKey = require("@atlaskit/editor-common/type-ahead-get-section-overflow-item-key");
19
+ var _heading = _interopRequireDefault(require("@atlaskit/heading/heading"));
20
20
  var _cross = _interopRequireDefault(require("@atlaskit/icon/core/cross"));
21
- var _modalDialog = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-dialog"));
22
21
  var _modalBody = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-body"));
22
+ var _modalDialog = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-dialog"));
23
23
  var _modalFooter = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-footer"));
24
24
  var _modalHeader = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-header"));
25
25
  var _modalTitle = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-title"));
@@ -10,8 +10,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
12
  var _isOfflineMode = require("@atlaskit/editor-common/connectivity/isOfflineMode");
13
- var _insert = require("@atlaskit/editor-common/insert");
14
13
  var _hooks = require("@atlaskit/editor-common/hooks");
14
+ var _insert = require("@atlaskit/editor-common/insert");
15
15
  var _keys = require("@atlaskit/editor-common/quick-insert/keys");
16
16
  var _commands = require("../../pm-plugins/commands");
17
17
  var _pluginKey = require("../../pm-plugins/plugin-key");
@@ -12,8 +12,10 @@ var _createQuickInsertMatcher = require("@atlaskit/editor-common/quick-insert/cr
12
12
  var _getMenuItemParents = require("@atlaskit/editor-common/quick-insert/get-menu-item-parents");
13
13
  var _getProviderMenuItemKey = require("@atlaskit/editor-common/quick-insert/get-provider-menu-item-key");
14
14
  var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
15
+ var _snippetPreviewImageUrls = require("@atlaskit/editor-common/quick-insert/snippet-preview-image-urls");
15
16
  var _useQuickInsertContext = require("@atlaskit/editor-common/quick-insert/use-quick-insert-context");
16
17
  var _apps = _interopRequireDefault(require("@atlaskit/icon/core/apps"));
18
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
17
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; }
18
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; }
19
21
  var LegacyQuickInsertProviderMenuItem = function LegacyQuickInsertProviderMenuItem(_ref) {
@@ -33,12 +35,17 @@ var LegacyQuickInsertProviderMenuItem = function LegacyQuickInsertProviderMenuIt
33
35
  return result;
34
36
  };
35
37
  var Icon = item.icon;
38
+ var itemKey = item.key === undefined ? undefined : String(item.key);
39
+ var snippetKeyPrefix = 'snippet-extension:snippet-';
40
+ var previewKey = itemKey !== null && itemKey !== void 0 && itemKey.startsWith(snippetKeyPrefix) ? itemKey.slice(snippetKeyPrefix.length) : undefined;
41
+ var previewImageUrls = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command') && previewKey ? (0, _snippetPreviewImageUrls.getSnippetPreviewImageUrls)(previewKey) : undefined;
36
42
  return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
37
43
  iconBefore: Icon ? /*#__PURE__*/_react.default.createElement(Icon, null) : /*#__PURE__*/_react.default.createElement(_apps.default, {
38
44
  label: ""
39
45
  }),
40
46
  isDisabled: isDisabled,
41
47
  onSelect: onSelect,
48
+ previewImageUrls: previewImageUrls,
42
49
  shortcut: item.keyshortcut,
43
50
  title: item.title
44
51
  });
@@ -16,10 +16,10 @@ var _messages = require("@atlaskit/editor-common/quick-insert/messages");
16
16
  var _rank = require("@atlaskit/editor-common/quick-insert/rank");
17
17
  var _typeAheadGetMenuFooterSectionKey = require("@atlaskit/editor-common/type-ahead-get-menu-footer-section-key");
18
18
  var _typeAheadGetSectionOverflowItemKey = require("@atlaskit/editor-common/type-ahead-get-section-overflow-item-key");
19
+ var _getRecommendedComponents = require("./getRecommendedComponents");
19
20
  var _QuickInsertMenuFooterItem = require("./QuickInsertMenuFooterItem");
20
21
  var _QuickInsertRecommendedSlot = require("./QuickInsertRecommendedSlot");
21
22
  var _QuickInsertSectionOverflowMenuItem = require("./QuickInsertSectionOverflowMenuItem");
22
- var _getRecommendedComponents = require("./getRecommendedComponents");
23
23
  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
24
  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; }
25
25
  var categories = [{
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isRecommendedSlotKey = exports.getRecommendedComponents = exports.createRecommendedSnapshotCache = exports.RECOMMENDED_SLOT_KEY_PREFIX = exports.MAX_RECOMMENDED_ITEMS = void 0;
7
+ var _monitoring = require("@atlaskit/editor-common/monitoring");
8
+ var _isRecommendedItem = require("@atlaskit/editor-common/quick-insert/is-recommended-item");
7
9
  var _keys = require("@atlaskit/editor-common/quick-insert/keys");
8
10
  var _typeAheadIsMenuFooterSectionKey = require("@atlaskit/editor-common/type-ahead-is-menu-footer-section-key");
9
11
  var _typeAheadIsSectionOverflowItemKey = require("@atlaskit/editor-common/type-ahead-is-section-overflow-item-key");
10
- var _isRecommendedItem = require("@atlaskit/editor-common/quick-insert/is-recommended-item");
11
- var _monitoring = require("@atlaskit/editor-common/monitoring");
12
12
  var _typeAheadSurfaceContext = require("@atlaskit/editor-common/type-ahead-surface-context");
13
13
  var MAX_RECOMMENDED_ITEMS = exports.MAX_RECOMMENDED_ITEMS = 5;
14
14
  var RECOMMENDED_SLOT_KEY_PREFIX = exports.RECOMMENDED_SLOT_KEY_PREFIX = 'quick-insert-recommended-slot-';
@@ -1,2 +1,3 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
+
2
3
  export { quickInsertPlugin } from '../quickInsertPlugin';
@@ -1,2 +1,3 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
+
2
3
  export { RegistryElementBrowser } from '../ui/RegistryElementBrowser/RegistryElementBrowser';
@@ -14,8 +14,8 @@ import { createQuickInsertItemsAnalyticsScheduler } from './app-category-analyti
14
14
  import { createInsertItem, openElementBrowser as openElementBrowserCommand, openElementBrowserModal } from './pm-plugins/commands';
15
15
  import { getQuickInsertOpenExperiencePlugin } from './pm-plugins/experiences/quick-insert-open-experience';
16
16
  import { pluginKey } from './pm-plugins/plugin-key';
17
- import { getLegacyCompatibleComponents } from './ui/getLegacyCompatibleComponents';
18
17
  import { getBlockControlQuickInsertComponents } from './ui/block-control-quick-insert';
18
+ import { getLegacyCompatibleComponents } from './ui/getLegacyCompatibleComponents';
19
19
  import { getQuickInsertComponents } from './ui/getQuickInsertComponents';
20
20
  import ModalElementBrowser from './ui/ModalElementBrowser';
21
21
  import { RegistryElementBrowserContainer } from './ui/RegistryElementBrowser';
@@ -29,7 +29,7 @@ export const quickInsertPlugin = ({
29
29
  var _options$onInsert;
30
30
  options === null || options === void 0 ? void 0 : (_options$onInsert = options.onInsert) === null || _options$onInsert === void 0 ? void 0 : _options$onInsert.call(options, item);
31
31
  };
32
- const typeAheadPrioritySortingFn = expValEquals('platform_editor_layout_typeahead_reorder', 'isEnabled', true) ? withLayoutQuickInsertPrioritySorting(options === null || options === void 0 ? void 0 : options.prioritySortingFn) : options === null || options === void 0 ? void 0 : options.prioritySortingFn;
32
+ const typeAheadPrioritySortingFn = withLayoutQuickInsertPrioritySorting(options === null || options === void 0 ? void 0 : options.prioritySortingFn);
33
33
  const typeAhead = {
34
34
  id: TypeAheadAvailableNodes.QUICK_INSERT,
35
35
  trigger: '/',
@@ -204,23 +204,15 @@ export const quickInsertPlugin = ({
204
204
  }));
205
205
  },
206
206
  getSuggestions: searchOptions => {
207
- var _api$quickInsert$shar, _api$quickInsert;
207
+ var _api$quickInsert$shar, _api$quickInsert, _options$prioritySort;
208
208
  const {
209
209
  lazyDefaultItems,
210
210
  providedItems
211
211
  } = (_api$quickInsert$shar = api === null || api === void 0 ? void 0 : (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {};
212
- if (expValEquals('platform_editor_layout_typeahead_reorder', 'isEnabled', true)) {
213
- var _options$prioritySort;
214
- searchOptions = {
215
- ...searchOptions,
216
- prioritySortingFn: withLayoutQuickInsertPrioritySorting((_options$prioritySort = options === null || options === void 0 ? void 0 : options.prioritySortingFn) !== null && _options$prioritySort !== void 0 ? _options$prioritySort : searchOptions.prioritySortingFn)
217
- };
218
- } else if (options !== null && options !== void 0 && options.prioritySortingFn) {
219
- searchOptions = {
220
- ...searchOptions,
221
- prioritySortingFn: options.prioritySortingFn
222
- };
223
- }
212
+ searchOptions = {
213
+ ...searchOptions,
214
+ prioritySortingFn: withLayoutQuickInsertPrioritySorting((_options$prioritySort = options === null || options === void 0 ? void 0 : options.prioritySortingFn) !== null && _options$prioritySort !== void 0 ? _options$prioritySort : searchOptions.prioritySortingFn)
215
+ };
224
216
 
225
217
  // EDITOR-6558: layer the consumer-supplied filter (e.g. Markdown Mode allowlist)
226
218
  // over any caller-supplied filter so both apply.
@@ -11,10 +11,10 @@ import Button from '@atlaskit/button/button';
11
11
  import { ElementBrowser } from '@atlaskit/editor-common/element-browser';
12
12
  import { messages } from '@atlaskit/editor-common/quick-insert';
13
13
  import QuestionCircleIcon from '@atlaskit/icon/core/question-circle';
14
- import Modal from '@atlaskit/modal-dialog/modal-dialog';
15
14
  import { CloseButton } from '@atlaskit/modal-dialog/close-button';
16
- import ModalTransition from '@atlaskit/modal-dialog/modal-transition';
17
15
  import { useModal } from '@atlaskit/modal-dialog/hooks';
16
+ import Modal from '@atlaskit/modal-dialog/modal-dialog';
17
+ import ModalTransition from '@atlaskit/modal-dialog/modal-transition';
18
18
  import { getCategories } from './categories';
19
19
  export const MODAL_WRAPPER_PADDING = 16;
20
20
  const actionsStyles = css({
@@ -4,13 +4,13 @@ import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import { useIntl } from 'react-intl';
6
6
  import IconButton from '@atlaskit/button/icon/button';
7
- import Heading from '@atlaskit/heading/heading';
8
7
  import { MENU, RECOMMENDED_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
9
8
  import { getMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-get-menu-footer-section-key';
10
9
  import { getSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-get-section-overflow-item-key';
10
+ import Heading from '@atlaskit/heading/heading';
11
11
  import CrossIcon from '@atlaskit/icon/core/cross';
12
- import Modal from '@atlaskit/modal-dialog/modal-dialog';
13
12
  import ModalBody from '@atlaskit/modal-dialog/modal-body';
13
+ import Modal from '@atlaskit/modal-dialog/modal-dialog';
14
14
  import ModalFooter from '@atlaskit/modal-dialog/modal-footer';
15
15
  import ModalHeader from '@atlaskit/modal-dialog/modal-header';
16
16
  import ModalTitle from '@atlaskit/modal-dialog/modal-title';
@@ -1,8 +1,8 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { isOfflineMode } from '@atlaskit/editor-common/connectivity/isOfflineMode';
4
- import { insertSelectedItem } from '@atlaskit/editor-common/insert';
5
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
+ import { insertSelectedItem } from '@atlaskit/editor-common/insert';
6
6
  import { MENU } from '@atlaskit/editor-common/quick-insert/keys';
7
7
  import { closeElementBrowser } from '../../pm-plugins/commands';
8
8
  import { pluginKey } from '../../pm-plugins/plugin-key';
@@ -3,8 +3,10 @@ import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/c
3
3
  import { getQuickInsertMenuItemParents } from '@atlaskit/editor-common/quick-insert/get-menu-item-parents';
4
4
  import { getQuickInsertProviderMenuItemKey } from '@atlaskit/editor-common/quick-insert/get-provider-menu-item-key';
5
5
  import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
6
+ import { getSnippetPreviewImageUrls } from '@atlaskit/editor-common/quick-insert/snippet-preview-image-urls';
6
7
  import { useQuickInsertContext } from '@atlaskit/editor-common/quick-insert/use-quick-insert-context';
7
8
  import AppsIcon from '@atlaskit/icon/core/apps';
9
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
8
10
  const LegacyQuickInsertProviderMenuItem = ({
9
11
  item,
10
12
  onInsert
@@ -25,12 +27,17 @@ const LegacyQuickInsertProviderMenuItem = ({
25
27
  return result;
26
28
  };
27
29
  const Icon = item.icon;
30
+ const itemKey = item.key === undefined ? undefined : String(item.key);
31
+ const snippetKeyPrefix = 'snippet-extension:snippet-';
32
+ const previewKey = itemKey !== null && itemKey !== void 0 && itemKey.startsWith(snippetKeyPrefix) ? itemKey.slice(snippetKeyPrefix.length) : undefined;
33
+ const previewImageUrls = isExperimentEnabled('platform_editor_slash_command') && previewKey ? getSnippetPreviewImageUrls(previewKey) : undefined;
28
34
  return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
29
35
  iconBefore: Icon ? /*#__PURE__*/React.createElement(Icon, null) : /*#__PURE__*/React.createElement(AppsIcon, {
30
36
  label: ""
31
37
  }),
32
38
  isDisabled: isDisabled,
33
39
  onSelect: onSelect,
40
+ previewImageUrls: previewImageUrls,
34
41
  shortcut: item.keyshortcut,
35
42
  title: item.title
36
43
  });
@@ -7,10 +7,10 @@ import { messages } from '@atlaskit/editor-common/quick-insert/messages';
7
7
  import { CATEGORY_VIEW_MORE_RANK, QUICK_INSERT_MENU_RANK } from '@atlaskit/editor-common/quick-insert/rank';
8
8
  import { getMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-get-menu-footer-section-key';
9
9
  import { getSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-get-section-overflow-item-key';
10
+ import { createRecommendedSnapshotCache, MAX_RECOMMENDED_ITEMS, RECOMMENDED_SLOT_KEY_PREFIX } from './getRecommendedComponents';
10
11
  import { QuickInsertMenuFooterItem } from './QuickInsertMenuFooterItem';
11
12
  import { QuickInsertRecommendedSlot } from './QuickInsertRecommendedSlot';
12
13
  import { QuickInsertSectionOverflowMenuItem } from './QuickInsertSectionOverflowMenuItem';
13
- import { createRecommendedSnapshotCache, MAX_RECOMMENDED_ITEMS, RECOMMENDED_SLOT_KEY_PREFIX } from './getRecommendedComponents';
14
14
  const categories = [{
15
15
  message: messages.categoryRecommended,
16
16
  section: RECOMMENDED_SECTION
@@ -1,8 +1,8 @@
1
+ import { logException } from '@atlaskit/editor-common/monitoring';
2
+ import { defaultIsRecommendedItem } from '@atlaskit/editor-common/quick-insert/is-recommended-item';
1
3
  import { MENU } from '@atlaskit/editor-common/quick-insert/keys';
2
4
  import { isMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-is-menu-footer-section-key';
3
5
  import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
4
- import { defaultIsRecommendedItem } from '@atlaskit/editor-common/quick-insert/is-recommended-item';
5
- import { logException } from '@atlaskit/editor-common/monitoring';
6
6
  import { TYPE_AHEAD_SURFACE_CONTEXT } from '@atlaskit/editor-common/type-ahead-surface-context';
7
7
  export const MAX_RECOMMENDED_ITEMS = 5;
8
8
  export const RECOMMENDED_SLOT_KEY_PREFIX = 'quick-insert-recommended-slot-';
@@ -1,2 +1,3 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
+
2
3
  export { quickInsertPlugin } from '../quickInsertPlugin';
@@ -1,2 +1,3 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
+
2
3
  export { RegistryElementBrowser } from '../ui/RegistryElementBrowser/RegistryElementBrowser';
@@ -20,8 +20,8 @@ import { createQuickInsertItemsAnalyticsScheduler } from './app-category-analyti
20
20
  import { createInsertItem, openElementBrowser as openElementBrowserCommand, openElementBrowserModal as _openElementBrowserModal } from './pm-plugins/commands';
21
21
  import { getQuickInsertOpenExperiencePlugin } from './pm-plugins/experiences/quick-insert-open-experience';
22
22
  import { pluginKey } from './pm-plugins/plugin-key';
23
- import { getLegacyCompatibleComponents } from './ui/getLegacyCompatibleComponents';
24
23
  import { getBlockControlQuickInsertComponents } from './ui/block-control-quick-insert';
24
+ import { getLegacyCompatibleComponents } from './ui/getLegacyCompatibleComponents';
25
25
  import { getQuickInsertComponents } from './ui/getQuickInsertComponents';
26
26
  import ModalElementBrowser from './ui/ModalElementBrowser';
27
27
  import { RegistryElementBrowserContainer } from './ui/RegistryElementBrowser';
@@ -34,7 +34,7 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
34
34
  var _options$onInsert;
35
35
  options === null || options === void 0 || (_options$onInsert = options.onInsert) === null || _options$onInsert === void 0 || _options$onInsert.call(options, item);
36
36
  };
37
- var typeAheadPrioritySortingFn = expValEquals('platform_editor_layout_typeahead_reorder', 'isEnabled', true) ? withLayoutQuickInsertPrioritySorting(options === null || options === void 0 ? void 0 : options.prioritySortingFn) : options === null || options === void 0 ? void 0 : options.prioritySortingFn;
37
+ var typeAheadPrioritySortingFn = withLayoutQuickInsertPrioritySorting(options === null || options === void 0 ? void 0 : options.prioritySortingFn);
38
38
  var typeAhead = {
39
39
  id: TypeAheadAvailableNodes.QUICK_INSERT,
40
40
  trigger: '/',
@@ -217,20 +217,13 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
217
217
  }));
218
218
  },
219
219
  getSuggestions: function getSuggestions(searchOptions) {
220
- var _api$quickInsert$shar, _api$quickInsert;
220
+ var _api$quickInsert$shar, _api$quickInsert, _options$prioritySort;
221
221
  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 : {},
222
222
  lazyDefaultItems = _ref8.lazyDefaultItems,
223
223
  providedItems = _ref8.providedItems;
224
- if (expValEquals('platform_editor_layout_typeahead_reorder', 'isEnabled', true)) {
225
- var _options$prioritySort;
226
- searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
227
- prioritySortingFn: withLayoutQuickInsertPrioritySorting((_options$prioritySort = options === null || options === void 0 ? void 0 : options.prioritySortingFn) !== null && _options$prioritySort !== void 0 ? _options$prioritySort : searchOptions.prioritySortingFn)
228
- });
229
- } else if (options !== null && options !== void 0 && options.prioritySortingFn) {
230
- searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
231
- prioritySortingFn: options.prioritySortingFn
232
- });
233
- }
224
+ searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
225
+ prioritySortingFn: withLayoutQuickInsertPrioritySorting((_options$prioritySort = options === null || options === void 0 ? void 0 : options.prioritySortingFn) !== null && _options$prioritySort !== void 0 ? _options$prioritySort : searchOptions.prioritySortingFn)
226
+ });
234
227
 
235
228
  // EDITOR-6558: layer the consumer-supplied filter (e.g. Markdown Mode allowlist)
236
229
  // over any caller-supplied filter so both apply.
@@ -12,10 +12,10 @@ import Button from '@atlaskit/button/button';
12
12
  import { ElementBrowser } from '@atlaskit/editor-common/element-browser';
13
13
  import { messages } from '@atlaskit/editor-common/quick-insert';
14
14
  import QuestionCircleIcon from '@atlaskit/icon/core/question-circle';
15
- import Modal from '@atlaskit/modal-dialog/modal-dialog';
16
15
  import { CloseButton } from '@atlaskit/modal-dialog/close-button';
17
- import ModalTransition from '@atlaskit/modal-dialog/modal-transition';
18
16
  import { useModal } from '@atlaskit/modal-dialog/hooks';
17
+ import Modal from '@atlaskit/modal-dialog/modal-dialog';
18
+ import ModalTransition from '@atlaskit/modal-dialog/modal-transition';
19
19
  import { getCategories } from './categories';
20
20
  export var MODAL_WRAPPER_PADDING = 16;
21
21
  var actionsStyles = css({
@@ -5,13 +5,13 @@ import { ax, ix } from "@compiled/react/runtime";
5
5
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
6
6
  import { useIntl } from 'react-intl';
7
7
  import IconButton from '@atlaskit/button/icon/button';
8
- import Heading from '@atlaskit/heading/heading';
9
8
  import { MENU, RECOMMENDED_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
10
9
  import { getMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-get-menu-footer-section-key';
11
10
  import { getSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-get-section-overflow-item-key';
11
+ import Heading from '@atlaskit/heading/heading';
12
12
  import CrossIcon from '@atlaskit/icon/core/cross';
13
- import Modal from '@atlaskit/modal-dialog/modal-dialog';
14
13
  import ModalBody from '@atlaskit/modal-dialog/modal-body';
14
+ import Modal from '@atlaskit/modal-dialog/modal-dialog';
15
15
  import ModalFooter from '@atlaskit/modal-dialog/modal-footer';
16
16
  import ModalHeader from '@atlaskit/modal-dialog/modal-header';
17
17
  import ModalTitle from '@atlaskit/modal-dialog/modal-title';
@@ -2,8 +2,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { useCallback, useEffect, useRef, useState } from 'react';
3
3
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { isOfflineMode } from '@atlaskit/editor-common/connectivity/isOfflineMode';
5
- import { insertSelectedItem } from '@atlaskit/editor-common/insert';
6
5
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
+ import { insertSelectedItem } from '@atlaskit/editor-common/insert';
7
7
  import { MENU } from '@atlaskit/editor-common/quick-insert/keys';
8
8
  import { closeElementBrowser } from '../../pm-plugins/commands';
9
9
  import { pluginKey } from '../../pm-plugins/plugin-key';
@@ -7,8 +7,10 @@ import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/c
7
7
  import { getQuickInsertMenuItemParents } from '@atlaskit/editor-common/quick-insert/get-menu-item-parents';
8
8
  import { getQuickInsertProviderMenuItemKey } from '@atlaskit/editor-common/quick-insert/get-provider-menu-item-key';
9
9
  import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
10
+ import { getSnippetPreviewImageUrls } from '@atlaskit/editor-common/quick-insert/snippet-preview-image-urls';
10
11
  import { useQuickInsertContext } from '@atlaskit/editor-common/quick-insert/use-quick-insert-context';
11
12
  import AppsIcon from '@atlaskit/icon/core/apps';
13
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
12
14
  var LegacyQuickInsertProviderMenuItem = function LegacyQuickInsertProviderMenuItem(_ref) {
13
15
  var item = _ref.item,
14
16
  onInsert = _ref.onInsert;
@@ -26,12 +28,17 @@ var LegacyQuickInsertProviderMenuItem = function LegacyQuickInsertProviderMenuIt
26
28
  return result;
27
29
  };
28
30
  var Icon = item.icon;
31
+ var itemKey = item.key === undefined ? undefined : String(item.key);
32
+ var snippetKeyPrefix = 'snippet-extension:snippet-';
33
+ var previewKey = itemKey !== null && itemKey !== void 0 && itemKey.startsWith(snippetKeyPrefix) ? itemKey.slice(snippetKeyPrefix.length) : undefined;
34
+ var previewImageUrls = isExperimentEnabled('platform_editor_slash_command') && previewKey ? getSnippetPreviewImageUrls(previewKey) : undefined;
29
35
  return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
30
36
  iconBefore: Icon ? /*#__PURE__*/React.createElement(Icon, null) : /*#__PURE__*/React.createElement(AppsIcon, {
31
37
  label: ""
32
38
  }),
33
39
  isDisabled: isDisabled,
34
40
  onSelect: onSelect,
41
+ previewImageUrls: previewImageUrls,
35
42
  shortcut: item.keyshortcut,
36
43
  title: item.title
37
44
  });
@@ -11,10 +11,10 @@ import { messages } from '@atlaskit/editor-common/quick-insert/messages';
11
11
  import { CATEGORY_VIEW_MORE_RANK, QUICK_INSERT_MENU_RANK } from '@atlaskit/editor-common/quick-insert/rank';
12
12
  import { getMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-get-menu-footer-section-key';
13
13
  import { getSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-get-section-overflow-item-key';
14
+ import { createRecommendedSnapshotCache, MAX_RECOMMENDED_ITEMS, RECOMMENDED_SLOT_KEY_PREFIX } from './getRecommendedComponents';
14
15
  import { QuickInsertMenuFooterItem } from './QuickInsertMenuFooterItem';
15
16
  import { QuickInsertRecommendedSlot } from './QuickInsertRecommendedSlot';
16
17
  import { QuickInsertSectionOverflowMenuItem } from './QuickInsertSectionOverflowMenuItem';
17
- import { createRecommendedSnapshotCache, MAX_RECOMMENDED_ITEMS, RECOMMENDED_SLOT_KEY_PREFIX } from './getRecommendedComponents';
18
18
  var categories = [{
19
19
  message: messages.categoryRecommended,
20
20
  section: RECOMMENDED_SECTION
@@ -1,8 +1,8 @@
1
+ import { logException } from '@atlaskit/editor-common/monitoring';
2
+ import { defaultIsRecommendedItem } from '@atlaskit/editor-common/quick-insert/is-recommended-item';
1
3
  import { MENU } from '@atlaskit/editor-common/quick-insert/keys';
2
4
  import { isMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-is-menu-footer-section-key';
3
5
  import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
4
- import { defaultIsRecommendedItem } from '@atlaskit/editor-common/quick-insert/is-recommended-item';
5
- import { logException } from '@atlaskit/editor-common/monitoring';
6
6
  import { TYPE_AHEAD_SURFACE_CONTEXT } from '@atlaskit/editor-common/type-ahead-surface-context';
7
7
  export var MAX_RECOMMENDED_ITEMS = 5;
8
8
  export var RECOMMENDED_SLOT_KEY_PREFIX = 'quick-insert-recommended-slot-';
@@ -1,6 +1,6 @@
1
+ import type { IsRecommendedItem } from '@atlaskit/editor-common/quick-insert/is-recommended-item';
1
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
3
  import type { CommonComponentProps, RegisterComponent } from '@atlaskit/editor-ui-control-model/types';
3
- import type { IsRecommendedItem } from '@atlaskit/editor-common/quick-insert/is-recommended-item';
4
4
  import type { QuickInsertPlugin } from '../quickInsertPluginType';
5
5
  type Params = {
6
6
  api: ExtractInjectionAPI<QuickInsertPlugin> | undefined;
@@ -1,5 +1,5 @@
1
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
1
  import { type IsRecommendedItem } from '@atlaskit/editor-common/quick-insert/is-recommended-item';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { RegisterComponent, RegisterMenuItem, SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
4
4
  import type { QuickInsertPlugin } from '../quickInsertPluginType';
5
5
  export declare const MAX_RECOMMENDED_ITEMS = 5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-quick-insert",
3
- "version": "19.0.1",
3
+ "version": "19.0.3",
4
4
  "description": "Quick insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -26,16 +26,16 @@
26
26
  ],
27
27
  "atlaskit:src": "src/index.ts",
28
28
  "dependencies": {
29
- "@atlaskit/button": "^25.3.0",
29
+ "@atlaskit/button": "^25.4.0",
30
30
  "@atlaskit/css": "^1.1.0",
31
31
  "@atlaskit/editor-plugin-analytics": "^19.0.0",
32
32
  "@atlaskit/editor-plugin-connectivity": "^19.0.0",
33
33
  "@atlaskit/editor-plugin-metrics": "^20.0.0",
34
34
  "@atlaskit/editor-plugin-type-ahead": "^20.0.0",
35
- "@atlaskit/editor-plugin-ui-control-registry": "^13.0.0",
35
+ "@atlaskit/editor-plugin-ui-control-registry": "^13.1.0",
36
36
  "@atlaskit/editor-prosemirror": "^9.0.0",
37
37
  "@atlaskit/editor-tables": "^3.2.0",
38
- "@atlaskit/editor-ui-control-model": "^2.9.0",
38
+ "@atlaskit/editor-ui-control-model": "^2.10.0",
39
39
  "@atlaskit/heading": "^7.2.0",
40
40
  "@atlaskit/icon": "^37.7.0",
41
41
  "@atlaskit/modal-dialog": "^16.6.0",
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/platform-feature-flags": "^2.2.0",
44
44
  "@atlaskit/primitives": "^22.5.0",
45
45
  "@atlaskit/textfield": "^10.2.0",
46
- "@atlaskit/tmp-editor-statsig": "^200.0.0",
46
+ "@atlaskit/tmp-editor-statsig": "^201.0.0",
47
47
  "@atlaskit/tokens": "^18.2.0",
48
48
  "@atlaskit/tooltip": "^24.3.0",
49
49
  "@babel/runtime": "^7.0.0",
@@ -51,7 +51,7 @@
51
51
  "@emotion/react": "^11.7.1"
52
52
  },
53
53
  "peerDependencies": {
54
- "@atlaskit/editor-common": "^123.0.0",
54
+ "@atlaskit/editor-common": "^123.3.0",
55
55
  "react": "^18.2.0 || ^19.2.0",
56
56
  "react-dom": "^18.2.0 || ^19.2.0",
57
57
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"