@atlaskit/editor-plugin-quick-insert 16.2.2 → 16.2.4

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,20 @@
1
1
  # @atlaskit/editor-plugin-quick-insert
2
2
 
3
+ ## 16.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`25ed290dcc443`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/25ed290dcc443) -
8
+ Add Quick Insert category selection support for slash commands behind the
9
+ platform_editor_slash_command feature flag.
10
+ - Updated dependencies
11
+
12
+ ## 16.2.3
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 16.2.2
4
19
 
5
20
  ### Patch Changes
@@ -118,9 +118,9 @@ var calculateQuickInsertItemsAttributes = exports.calculateQuickInsertItemsAttri
118
118
  }
119
119
  };
120
120
  var countItem = function countItem(item) {
121
- var _categories$map$filte;
121
+ var _item$categories, _categories$map$filte;
122
122
  countCategoryItem(attributes.allCategories, item);
123
- var categories = item.categories;
123
+ var categories = (_item$categories = item.categories) !== null && _item$categories !== void 0 ? _item$categories : [];
124
124
  var normalizedCategories = new Set((_categories$map$filte = categories === null || categories === void 0 ? void 0 : categories.map(function (category) {
125
125
  return category.trim().toLowerCase();
126
126
  }).filter(Boolean)) !== null && _categories$map$filte !== void 0 ? _categories$map$filte : []);
@@ -145,7 +145,8 @@ var calculateQuickInsertItemsAttributes = exports.calculateQuickInsertItemsAttri
145
145
  countCategoryItem(attributes.legacyCategory.uncategorized, item);
146
146
  }
147
147
  var _iterator2 = _createForOfIteratorHelper((0, _getMenuItemParents.getQuickInsertMenuItemParents)({
148
- categories: categories,
148
+ category: item.category,
149
+ legacyCategories: item.categories,
149
150
  rank: 0
150
151
  })),
151
152
  _step2;
@@ -14,6 +14,7 @@ var _reactIntl = require("react-intl");
14
14
  var _coreUtils = require("@atlaskit/editor-common/core-utils");
15
15
  var _messages = require("@atlaskit/editor-common/messages");
16
16
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
17
+ var _getActiveQuickInsertCategories = require("@atlaskit/editor-common/quick-insert/get-active-quick-insert-categories");
17
18
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
18
19
  var _typeAhead = require("@atlaskit/editor-common/type-ahead");
19
20
  var _showMoreHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/show-more-horizontal"));
@@ -71,8 +72,7 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
71
72
  disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
72
73
  prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn,
73
74
  itemFilter: function itemFilter(item) {
74
- var _item$categories$incl, _item$categories;
75
- return (_item$categories$incl = (_item$categories = item.categories) === null || _item$categories === void 0 ? void 0 : _item$categories.includes('AI')) !== null && _item$categories$incl !== void 0 ? _item$categories$incl : false;
75
+ return (0, _getActiveQuickInsertCategories.getActiveQuickInsertCategories)(item.category, item.categories).includes('AI');
76
76
  }
77
77
  }, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems);
78
78
  return matches[0];
@@ -55,7 +55,8 @@ var getComponentsFromLegacyItems = function getComponentsFromLegacyItems(items,
55
55
  type: 'menu-item',
56
56
  key: (0, _getProviderMenuItemKey.getQuickInsertProviderMenuItemKey)(identity),
57
57
  parents: (0, _getMenuItemParents.getQuickInsertMenuItemParents)({
58
- categories: item.categories,
58
+ category: item.category,
59
+ legacyCategories: item.categories,
59
60
  rank: (_item$priority = item.priority) !== null && _item$priority !== void 0 ? _item$priority : index
60
61
  }),
61
62
  component: function component() {
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.withLayoutQuickInsertPrioritySorting = exports.getQuickInsertSuggestions = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
10
+ var _getActiveQuickInsertCategories = require("@atlaskit/editor-common/quick-insert/get-active-quick-insert-categories");
10
11
  var _utils = require("@atlaskit/editor-common/utils");
11
12
  var _fg = require("@atlaskit/platform-feature-flags/fg");
12
13
  var isRegisteredLayoutQuickInsertItem = function isRegisteredLayoutQuickInsertItem(item) {
@@ -70,6 +71,6 @@ var getQuickInsertSuggestions = exports.getQuickInsertSuggestions = function get
70
71
  });
71
72
  }
72
73
  return (0, _quickInsert.find)(((0, _fg.fg)('platform_editor_fix_space_triggering_ai') ? query === null || query === void 0 ? void 0 : query.trimEnd() : query) || '', category === 'all' || !category ? items : items.filter(function (item) {
73
- return item.categories && item.categories.includes(category);
74
+ return (0, _getActiveQuickInsertCategories.getActiveQuickInsertCategories)(item.category, item.categories).includes(category);
74
75
  }), prioritySortingFn);
75
76
  };
@@ -111,9 +111,9 @@ export const calculateQuickInsertItemsAttributes = ({
111
111
  }
112
112
  };
113
113
  const countItem = item => {
114
- var _categories$map$filte;
114
+ var _item$categories, _categories$map$filte;
115
115
  countCategoryItem(attributes.allCategories, item);
116
- const categories = item.categories;
116
+ const categories = (_item$categories = item.categories) !== null && _item$categories !== void 0 ? _item$categories : [];
117
117
  const normalizedCategories = new Set((_categories$map$filte = categories === null || categories === void 0 ? void 0 : categories.map(category => category.trim().toLowerCase()).filter(Boolean)) !== null && _categories$map$filte !== void 0 ? _categories$map$filte : []);
118
118
  let hasUnknownCategory = normalizedCategories.size === 0;
119
119
  for (const category of normalizedCategories) {
@@ -129,7 +129,8 @@ export const calculateQuickInsertItemsAttributes = ({
129
129
  for (const {
130
130
  key
131
131
  } of getQuickInsertMenuItemParents({
132
- categories,
132
+ category: item.category,
133
+ legacyCategories: item.categories,
133
134
  rank: 0
134
135
  })) {
135
136
  const categoryKey = sectionCategoryKeys[key];
@@ -3,6 +3,7 @@ import { useIntl } from 'react-intl';
3
3
  import { isSSR } from '@atlaskit/editor-common/core-utils';
4
4
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
5
  import { memoProcessQuickInsertItems } from '@atlaskit/editor-common/quick-insert';
6
+ import { getActiveQuickInsertCategories } from '@atlaskit/editor-common/quick-insert/get-active-quick-insert-categories';
6
7
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
8
  import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
8
9
  import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
@@ -60,10 +61,7 @@ export const quickInsertPlugin = ({
60
61
  query: '',
61
62
  disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
62
63
  prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn,
63
- itemFilter: item => {
64
- var _item$categories$incl, _item$categories;
65
- return (_item$categories$incl = (_item$categories = item.categories) === null || _item$categories === void 0 ? void 0 : _item$categories.includes('AI')) !== null && _item$categories$incl !== void 0 ? _item$categories$incl : false;
66
- }
64
+ itemFilter: item => getActiveQuickInsertCategories(item.category, item.categories).includes('AI')
67
65
  }, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems);
68
66
  return matches[0];
69
67
  },
@@ -46,7 +46,8 @@ const getComponentsFromLegacyItems = (items, onInsert) => items.map((item, index
46
46
  type: 'menu-item',
47
47
  key: getQuickInsertProviderMenuItemKey(identity),
48
48
  parents: getQuickInsertMenuItemParents({
49
- categories: item.categories,
49
+ category: item.category,
50
+ legacyCategories: item.categories,
50
51
  rank: (_item$priority = item.priority) !== null && _item$priority !== void 0 ? _item$priority : index
51
52
  }),
52
53
  component: () => /*#__PURE__*/React.createElement(LegacyQuickInsertProviderMenuItem, {
@@ -1,4 +1,5 @@
1
1
  import { find } from '@atlaskit/editor-common/quick-insert';
2
+ import { getActiveQuickInsertCategories } from '@atlaskit/editor-common/quick-insert/get-active-quick-insert-categories';
2
3
  import { dedupe } from '@atlaskit/editor-common/utils';
3
4
  import { fg } from '@atlaskit/platform-feature-flags/fg';
4
5
  const isRegisteredLayoutQuickInsertItem = item => {
@@ -51,5 +52,5 @@ export const getQuickInsertSuggestions = (searchOptions, lazyDefaultItems = () =
51
52
  if (featuredItems) {
52
53
  return items.filter(item => item.featured);
53
54
  }
54
- return find((fg('platform_editor_fix_space_triggering_ai') ? query === null || query === void 0 ? void 0 : query.trimEnd() : query) || '', category === 'all' || !category ? items : items.filter(item => item.categories && item.categories.includes(category)), prioritySortingFn);
55
+ return find((fg('platform_editor_fix_space_triggering_ai') ? query === null || query === void 0 ? void 0 : query.trimEnd() : query) || '', category === 'all' || !category ? items : items.filter(item => getActiveQuickInsertCategories(item.category, item.categories).includes(category)), prioritySortingFn);
55
56
  };
@@ -111,9 +111,9 @@ export var calculateQuickInsertItemsAttributes = function calculateQuickInsertIt
111
111
  }
112
112
  };
113
113
  var countItem = function countItem(item) {
114
- var _categories$map$filte;
114
+ var _item$categories, _categories$map$filte;
115
115
  countCategoryItem(attributes.allCategories, item);
116
- var categories = item.categories;
116
+ var categories = (_item$categories = item.categories) !== null && _item$categories !== void 0 ? _item$categories : [];
117
117
  var normalizedCategories = new Set((_categories$map$filte = categories === null || categories === void 0 ? void 0 : categories.map(function (category) {
118
118
  return category.trim().toLowerCase();
119
119
  }).filter(Boolean)) !== null && _categories$map$filte !== void 0 ? _categories$map$filte : []);
@@ -138,7 +138,8 @@ export var calculateQuickInsertItemsAttributes = function calculateQuickInsertIt
138
138
  countCategoryItem(attributes.legacyCategory.uncategorized, item);
139
139
  }
140
140
  var _iterator2 = _createForOfIteratorHelper(getQuickInsertMenuItemParents({
141
- categories: categories,
141
+ category: item.category,
142
+ legacyCategories: item.categories,
142
143
  rank: 0
143
144
  })),
144
145
  _step2;
@@ -9,6 +9,7 @@ import { useIntl } from 'react-intl';
9
9
  import { isSSR } from '@atlaskit/editor-common/core-utils';
10
10
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
11
11
  import { memoProcessQuickInsertItems } from '@atlaskit/editor-common/quick-insert';
12
+ import { getActiveQuickInsertCategories } from '@atlaskit/editor-common/quick-insert/get-active-quick-insert-categories';
12
13
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
13
14
  import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
14
15
  import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
@@ -64,8 +65,7 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
64
65
  disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
65
66
  prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn,
66
67
  itemFilter: function itemFilter(item) {
67
- var _item$categories$incl, _item$categories;
68
- return (_item$categories$incl = (_item$categories = item.categories) === null || _item$categories === void 0 ? void 0 : _item$categories.includes('AI')) !== null && _item$categories$incl !== void 0 ? _item$categories$incl : false;
68
+ return getActiveQuickInsertCategories(item.category, item.categories).includes('AI');
69
69
  }
70
70
  }, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems);
71
71
  return matches[0];
@@ -48,7 +48,8 @@ var getComponentsFromLegacyItems = function getComponentsFromLegacyItems(items,
48
48
  type: 'menu-item',
49
49
  key: getQuickInsertProviderMenuItemKey(identity),
50
50
  parents: getQuickInsertMenuItemParents({
51
- categories: item.categories,
51
+ category: item.category,
52
+ legacyCategories: item.categories,
52
53
  rank: (_item$priority = item.priority) !== null && _item$priority !== void 0 ? _item$priority : index
53
54
  }),
54
55
  component: function component() {
@@ -1,5 +1,6 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { find } from '@atlaskit/editor-common/quick-insert';
3
+ import { getActiveQuickInsertCategories } from '@atlaskit/editor-common/quick-insert/get-active-quick-insert-categories';
3
4
  import { dedupe } from '@atlaskit/editor-common/utils';
4
5
  import { fg } from '@atlaskit/platform-feature-flags/fg';
5
6
  var isRegisteredLayoutQuickInsertItem = function isRegisteredLayoutQuickInsertItem(item) {
@@ -63,6 +64,6 @@ export var getQuickInsertSuggestions = function getQuickInsertSuggestions(search
63
64
  });
64
65
  }
65
66
  return find((fg('platform_editor_fix_space_triggering_ai') ? query === null || query === void 0 ? void 0 : query.trimEnd() : query) || '', category === 'all' || !category ? items : items.filter(function (item) {
66
- return item.categories && item.categories.includes(category);
67
+ return getActiveQuickInsertCategories(item.category, item.categories).includes(category);
67
68
  }), prioritySortingFn);
68
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-quick-insert",
3
- "version": "16.2.2",
3
+ "version": "16.2.4",
4
4
  "description": "Quick insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,7 +38,7 @@
38
38
  "@atlaskit/platform-feature-flags": "^2.2.0",
39
39
  "@atlaskit/primitives": "^22.5.0",
40
40
  "@atlaskit/textfield": "^10.2.0",
41
- "@atlaskit/tmp-editor-statsig": "^170.0.0",
41
+ "@atlaskit/tmp-editor-statsig": "^172.0.0",
42
42
  "@atlaskit/tokens": "^16.11.0",
43
43
  "@atlaskit/tooltip": "^24.3.0",
44
44
  "@babel/runtime": "^7.0.0",
@@ -46,7 +46,7 @@
46
46
  "@emotion/react": "^11.7.1"
47
47
  },
48
48
  "peerDependencies": {
49
- "@atlaskit/editor-common": "^120.10.0",
49
+ "@atlaskit/editor-common": "^120.11.0",
50
50
  "react": "^18.2.0 || ^19.2.0",
51
51
  "react-dom": "^18.2.0 || ^19.2.0",
52
52
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -59,42 +59,6 @@
59
59
  "react-intl": "^7.0.0",
60
60
  "wait-for-expect": "^1.2.0"
61
61
  },
62
- "techstack": {
63
- "@atlassian/frontend": {
64
- "code-structure": [
65
- "editor-plugin"
66
- ],
67
- "import-structure": [
68
- "atlassian-conventions"
69
- ],
70
- "circular-dependencies": [
71
- "file-and-folder-level"
72
- ]
73
- },
74
- "@repo/internal": {
75
- "dom-events": "use-bind-event-listener",
76
- "analytics": [
77
- "analytics-next"
78
- ],
79
- "design-tokens": [
80
- "color"
81
- ],
82
- "theming": [
83
- "react-context"
84
- ],
85
- "ui-components": [
86
- "lite-mode"
87
- ],
88
- "deprecation": "no-deprecated-imports",
89
- "styling": [
90
- "emotion",
91
- "emotion"
92
- ],
93
- "imports": [
94
- "import-no-extraneous-disable-for-examples-and-docs"
95
- ]
96
- }
97
- },
98
62
  "platform-feature-flags": {
99
63
  "platform_editor_ease_of_use_metrics": {
100
64
  "type": "boolean"