@atlaskit/editor-common 128.4.0 → 129.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/messages/insert-block.js +0 -5
  3. package/dist/cjs/monitoring/error.js +1 -1
  4. package/dist/cjs/quick-insert/snippetMenuRank.js +35 -0
  5. package/dist/cjs/quick-insert/utils.js +9 -14
  6. package/dist/cjs/type-ahead/messages.js +0 -10
  7. package/dist/cjs/ui/DropList/index.js +1 -1
  8. package/dist/es2019/messages/insert-block.js +0 -5
  9. package/dist/es2019/monitoring/error.js +1 -1
  10. package/dist/es2019/quick-insert/snippetMenuRank.js +30 -0
  11. package/dist/es2019/quick-insert/utils.js +7 -12
  12. package/dist/es2019/type-ahead/messages.js +0 -10
  13. package/dist/es2019/ui/DropList/index.js +1 -1
  14. package/dist/esm/messages/insert-block.js +0 -5
  15. package/dist/esm/monitoring/error.js +1 -1
  16. package/dist/esm/quick-insert/snippetMenuRank.js +29 -0
  17. package/dist/esm/quick-insert/utils.js +9 -14
  18. package/dist/esm/type-ahead/messages.js +0 -10
  19. package/dist/esm/ui/DropList/index.js +1 -1
  20. package/dist/types/messages/insert-block.d.ts +0 -5
  21. package/dist/types/quick-insert/snippetMenuRank.d.ts +16 -0
  22. package/dist/types/type-ahead/messages.d.ts +0 -10
  23. package/dist/types/types/type-ahead.d.ts +0 -7
  24. package/package.json +3 -3
  25. package/quick-insert/snippet-menu-rank/package.json +10 -0
  26. package/dist/cjs/quick-insert/boost-native-results-above-skills.js +0 -61
  27. package/dist/es2019/quick-insert/boost-native-results-above-skills.js +0 -49
  28. package/dist/esm/quick-insert/boost-native-results-above-skills.js +0 -54
  29. package/dist/types/quick-insert/boost-native-results-above-skills.d.ts +0 -21
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 129.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`1cb97ba88fb58`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1cb97ba88fb58) -
8
+ Clean up experiment `platform_editor_insert_menu_ai` (keep control).
9
+
10
+ Breaking changes (`@atlaskit/editor-common`): removed `getEmptyItem` from `TypeAheadHandler`, and
11
+ removed the unused messages `typeAheadListMessages.emptySearchResultsSuggestionNew`,
12
+ `typeAheadListMessages.emptySearchResultsSuggestionAskRovoOnly` and
13
+ `toolbarInsertBlockMessages.askRovo`.
14
+
15
+ ### Minor Changes
16
+
17
+ - [`7609e9d6f1431`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7609e9d6f1431) -
18
+ Add the quick-insert/snippet-menu-rank entry point with getSnippetMenuRank and
19
+ TEMPLATE_GALLERY_MENU_RANK for ordering Block templates in the Insert menu
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+
3
25
  ## 128.4.0
4
26
 
5
27
  ### Minor Changes
@@ -211,11 +211,6 @@ var toolbarInsertBlockMessages = exports.toolbarInsertBlockMessages = (0, _react
211
211
  defaultMessage: 'Add a custom status label',
212
212
  description: 'Menu description shown in the quick insert menu. Explains that users can add custom status labels.'
213
213
  },
214
- askRovo: {
215
- id: 'fabric.editor.askRovo',
216
- defaultMessage: 'Ask Rovo',
217
- description: 'Button label shown in the quick insert empty results state. Allows users to ask Rovo AI for help.'
218
- },
219
214
  viewMore: {
220
215
  id: 'fabric.editor.viewMore',
221
216
  defaultMessage: 'View more',
@@ -27,7 +27,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
27
27
  var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
28
28
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
29
29
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
30
- var packageVersion = "128.3.2";
30
+ var packageVersion = "128.4.0";
31
31
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
32
32
  // Remove URL as it has UGC
33
33
  // Ignored via go/ees007
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSnippetMenuRank = exports.TEMPLATE_GALLERY_MENU_RANK = void 0;
7
+ var MAX_DATE_MS = 8.64e15; // largest valid Date value
8
+ var FAVORITE_TIER = -2;
9
+ var CURATED_TIER = 1;
10
+ var TEMPLATE_GALLERY_MENU_RANK = exports.TEMPLATE_GALLERY_MENU_RANK = 0;
11
+
12
+ /**
13
+ * Menu rank for a Block template within the Block templates section. Lower ranks appear first.
14
+ * Each rank is its tier plus a fraction in [0, 1), so tiers never overlap.
15
+ *
16
+ * Negative ranks are intentional and valid. This is a `parents[].rank` sort key, not a Fuse score:
17
+ * the registry menu compares ranks by subtraction, and Fuse's 0–1 `score` is a separate value that
18
+ * is compared first when searching, so rank only orders templates with equal scores.
19
+ */
20
+ var getSnippetMenuRank = exports.getSnippetMenuRank = function getSnippetMenuRank(_ref) {
21
+ var insertCount = _ref.insertCount,
22
+ isFavorite = _ref.isFavorite,
23
+ scope = _ref.scope,
24
+ updatedAt = _ref.updatedAt;
25
+ if (isFavorite) {
26
+ // Stays in (-2, -1.5]; more inserts rank first.
27
+ return FAVORITE_TIER + 1 / ((insertCount !== null && insertCount !== void 0 ? insertCount : 0) + 2);
28
+ }
29
+ if (scope !== 'GLOBAL') {
30
+ var time = Number.isFinite(updatedAt) ? Math.max(updatedAt, 1) : 1;
31
+ // USER and SITE templates stay in [-1, 0); newer updates rank first.
32
+ return -time / MAX_DATE_MS;
33
+ }
34
+ return CURATED_TIER;
35
+ };
@@ -10,8 +10,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _fuse = _interopRequireDefault(require("fuse.js"));
12
12
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
13
- var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
14
- var _boostNativeResultsAboveSkills = require("./boost-native-results-above-skills");
15
13
  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; }
16
14
  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; }
17
15
  var processQuickInsertItems = function processQuickInsertItems(items, intl) {
@@ -67,7 +65,7 @@ var options = {
67
65
  */
68
66
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
69
67
  function find(query, items, prioritySortingFn) {
70
- var _rerankedResults$data, _rerankedResults$lega;
68
+ var _results$datasourceIn, _results$legacyIndex$;
71
69
  if (query === '') {
72
70
  // Copy and sort list by priority
73
71
  return items.slice(0).sort(function (a, b) {
@@ -86,28 +84,25 @@ function find(query, items, prioritySortingFn) {
86
84
  var fuse = new _fuse.default(items, fuseOptions);
87
85
  var results = fuse.search(query);
88
86
 
89
- // platform_editor_insert_menu_ai: boost native editor elements above skills
90
- var rerankedResults = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_insert_menu_ai') ? (0, _boostNativeResultsAboveSkills.boostNativeResultsAboveSkills)(results) : results;
91
-
92
87
  // searching for jira work items macro first
93
- var datasourceIndex = rerankedResults.findIndex(function (r) {
88
+ var datasourceIndex = results.findIndex(function (r) {
94
89
  var _r$item$keywords;
95
90
  return r.item.id === 'datasource' && ((_r$item$keywords = r.item.keywords) === null || _r$item$keywords === void 0 ? void 0 : _r$item$keywords.includes('jira'));
96
91
  });
97
92
 
98
93
  // then searching for the legacy jira macro
99
- var legacyIndex = rerankedResults.findIndex(function (r) {
94
+ var legacyIndex = results.findIndex(function (r) {
100
95
  return typeof r.item.key === 'string' && r.item.key.endsWith(':jira');
101
96
  });
102
97
 
103
98
  // the jira legcy macro is found before the jira work items macro then swap the two
104
- if (datasourceIndex > 0 && legacyIndex >= 0 && legacyIndex < datasourceIndex && Math.abs(((_rerankedResults$data = rerankedResults[datasourceIndex].score) !== null && _rerankedResults$data !== void 0 ? _rerankedResults$data : 0) - ((_rerankedResults$lega = rerankedResults[legacyIndex].score) !== null && _rerankedResults$lega !== void 0 ? _rerankedResults$lega : 0)) < 0.2) {
105
- var _rerankedResults$spli = rerankedResults.splice(datasourceIndex, 1),
106
- _rerankedResults$spli2 = (0, _slicedToArray2.default)(_rerankedResults$spli, 1),
107
- datasource = _rerankedResults$spli2[0];
108
- rerankedResults.splice(legacyIndex, 0, datasource);
99
+ if (datasourceIndex > 0 && legacyIndex >= 0 && legacyIndex < datasourceIndex && Math.abs(((_results$datasourceIn = results[datasourceIndex].score) !== null && _results$datasourceIn !== void 0 ? _results$datasourceIn : 0) - ((_results$legacyIndex$ = results[legacyIndex].score) !== null && _results$legacyIndex$ !== void 0 ? _results$legacyIndex$ : 0)) < 0.2) {
100
+ var _results$splice = results.splice(datasourceIndex, 1),
101
+ _results$splice2 = (0, _slicedToArray2.default)(_results$splice, 1),
102
+ datasource = _results$splice2[0];
103
+ results.splice(legacyIndex, 0, datasource);
109
104
  }
110
- return rerankedResults.map(function (result) {
105
+ return results.map(function (result) {
111
106
  return result.item;
112
107
  });
113
108
  }
@@ -110,15 +110,5 @@ var typeAheadListMessages = exports.typeAheadListMessages = (0, _reactIntl.defin
110
110
  id: 'fabric.editor.emptySearchResultsSuggestion',
111
111
  defaultMessage: 'Select {buttonName} to browse inserts.',
112
112
  description: 'a prompt to suggest user to click a button to browse inserts when there are no search results'
113
- },
114
- emptySearchResultsSuggestionNew: {
115
- id: 'fabric.editor.emptySearchResultsSuggestionNew',
116
- defaultMessage: 'Select {askRovoName} for help, or {buttonName} to browse inserts.',
117
- description: 'a prompt to suggest user to click a button to browse inserts or ask Rovo for help when there are no search results'
118
- },
119
- emptySearchResultsSuggestionAskRovoOnly: {
120
- id: 'fabric.editor.emptySearchResultsSuggestionAskRovoOnly',
121
- defaultMessage: 'Select {askRovoName} for help.',
122
- description: 'a prompt to suggest user to ask Rovo for help when there are no search results and no browse inserts button is available'
123
113
  }
124
114
  });
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
24
24
  * @jsx jsx
25
25
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "128.3.2";
27
+ var packageVersion = "128.4.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -205,11 +205,6 @@ export const toolbarInsertBlockMessages = defineMessages({
205
205
  defaultMessage: 'Add a custom status label',
206
206
  description: 'Menu description shown in the quick insert menu. Explains that users can add custom status labels.'
207
207
  },
208
- askRovo: {
209
- id: 'fabric.editor.askRovo',
210
- defaultMessage: 'Ask Rovo',
211
- description: 'Button label shown in the quick insert empty results state. Allows users to ask Rovo AI for help.'
212
- },
213
208
  viewMore: {
214
209
  id: 'fabric.editor.viewMore',
215
210
  defaultMessage: 'View more',
@@ -13,7 +13,7 @@ const NETWORK_FAILURE_REGEX = /^network failure/i;
13
13
  const RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
14
14
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
15
15
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
16
- const packageVersion = "128.3.2";
16
+ const packageVersion = "128.4.0";
17
17
  const sanitiseSentryEvents = (data, _hint) => {
18
18
  // Remove URL as it has UGC
19
19
  // Ignored via go/ees007
@@ -0,0 +1,30 @@
1
+ const MAX_DATE_MS = 8.64e15; // largest valid Date value
2
+ const FAVORITE_TIER = -2;
3
+ const CURATED_TIER = 1;
4
+ export const TEMPLATE_GALLERY_MENU_RANK = 0;
5
+
6
+ /**
7
+ * Menu rank for a Block template within the Block templates section. Lower ranks appear first.
8
+ * Each rank is its tier plus a fraction in [0, 1), so tiers never overlap.
9
+ *
10
+ * Negative ranks are intentional and valid. This is a `parents[].rank` sort key, not a Fuse score:
11
+ * the registry menu compares ranks by subtraction, and Fuse's 0–1 `score` is a separate value that
12
+ * is compared first when searching, so rank only orders templates with equal scores.
13
+ */
14
+ export const getSnippetMenuRank = ({
15
+ insertCount,
16
+ isFavorite,
17
+ scope,
18
+ updatedAt
19
+ }) => {
20
+ if (isFavorite) {
21
+ // Stays in (-2, -1.5]; more inserts rank first.
22
+ return FAVORITE_TIER + 1 / ((insertCount !== null && insertCount !== void 0 ? insertCount : 0) + 2);
23
+ }
24
+ if (scope !== 'GLOBAL') {
25
+ const time = Number.isFinite(updatedAt) ? Math.max(updatedAt, 1) : 1;
26
+ // USER and SITE templates stay in [-1, 0); newer updates rank first.
27
+ return -time / MAX_DATE_MS;
28
+ }
29
+ return CURATED_TIER;
30
+ };
@@ -1,7 +1,5 @@
1
1
  import Fuse from 'fuse.js';
2
2
  import memoizeOne from 'memoize-one';
3
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
- import { boostNativeResultsAboveSkills } from './boost-native-results-above-skills';
5
3
  const processQuickInsertItems = (items, intl) => {
6
4
  return items.reduce((acc, item) => {
7
5
  if (typeof item === 'function' &&
@@ -51,7 +49,7 @@ const options = {
51
49
  */
52
50
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
53
51
  export function find(query, items, prioritySortingFn) {
54
- var _rerankedResults$data, _rerankedResults$lega;
52
+ var _results$datasourceIn, _results$legacyIndex$;
55
53
  if (query === '') {
56
54
  // Copy and sort list by priority
57
55
  return items.slice(0).sort((a, b) => (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY));
@@ -70,22 +68,19 @@ export function find(query, items, prioritySortingFn) {
70
68
  const fuse = new Fuse(items, fuseOptions);
71
69
  const results = fuse.search(query);
72
70
 
73
- // platform_editor_insert_menu_ai: boost native editor elements above skills
74
- const rerankedResults = isExperimentEnabled('platform_editor_insert_menu_ai') ? boostNativeResultsAboveSkills(results) : results;
75
-
76
71
  // searching for jira work items macro first
77
- const datasourceIndex = rerankedResults.findIndex(r => {
72
+ const datasourceIndex = results.findIndex(r => {
78
73
  var _r$item$keywords;
79
74
  return r.item.id === 'datasource' && ((_r$item$keywords = r.item.keywords) === null || _r$item$keywords === void 0 ? void 0 : _r$item$keywords.includes('jira'));
80
75
  });
81
76
 
82
77
  // then searching for the legacy jira macro
83
- const legacyIndex = rerankedResults.findIndex(r => typeof r.item.key === 'string' && r.item.key.endsWith(':jira'));
78
+ const legacyIndex = results.findIndex(r => typeof r.item.key === 'string' && r.item.key.endsWith(':jira'));
84
79
 
85
80
  // the jira legcy macro is found before the jira work items macro then swap the two
86
- if (datasourceIndex > 0 && legacyIndex >= 0 && legacyIndex < datasourceIndex && Math.abs(((_rerankedResults$data = rerankedResults[datasourceIndex].score) !== null && _rerankedResults$data !== void 0 ? _rerankedResults$data : 0) - ((_rerankedResults$lega = rerankedResults[legacyIndex].score) !== null && _rerankedResults$lega !== void 0 ? _rerankedResults$lega : 0)) < 0.2) {
87
- const [datasource] = rerankedResults.splice(datasourceIndex, 1);
88
- rerankedResults.splice(legacyIndex, 0, datasource);
81
+ if (datasourceIndex > 0 && legacyIndex >= 0 && legacyIndex < datasourceIndex && Math.abs(((_results$datasourceIn = results[datasourceIndex].score) !== null && _results$datasourceIn !== void 0 ? _results$datasourceIn : 0) - ((_results$legacyIndex$ = results[legacyIndex].score) !== null && _results$legacyIndex$ !== void 0 ? _results$legacyIndex$ : 0)) < 0.2) {
82
+ const [datasource] = results.splice(datasourceIndex, 1);
83
+ results.splice(legacyIndex, 0, datasource);
89
84
  }
90
- return rerankedResults.map(result => result.item);
85
+ return results.map(result => result.item);
91
86
  }
@@ -104,15 +104,5 @@ export const typeAheadListMessages = defineMessages({
104
104
  id: 'fabric.editor.emptySearchResultsSuggestion',
105
105
  defaultMessage: 'Select {buttonName} to browse inserts.',
106
106
  description: 'a prompt to suggest user to click a button to browse inserts when there are no search results'
107
- },
108
- emptySearchResultsSuggestionNew: {
109
- id: 'fabric.editor.emptySearchResultsSuggestionNew',
110
- defaultMessage: 'Select {askRovoName} for help, or {buttonName} to browse inserts.',
111
- description: 'a prompt to suggest user to click a button to browse inserts or ask Rovo for help when there are no search results'
112
- },
113
- emptySearchResultsSuggestionAskRovoOnly: {
114
- id: 'fabric.editor.emptySearchResultsSuggestionAskRovoOnly',
115
- defaultMessage: 'Select {askRovoName} for help.',
116
- description: 'a prompt to suggest user to ask Rovo for help when there are no search results and no browse inserts button is available'
117
107
  }
118
108
  });
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags/fg';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "128.3.2";
17
+ const packageVersion = "128.4.0";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -205,11 +205,6 @@ export var toolbarInsertBlockMessages = defineMessages({
205
205
  defaultMessage: 'Add a custom status label',
206
206
  description: 'Menu description shown in the quick insert menu. Explains that users can add custom status labels.'
207
207
  },
208
- askRovo: {
209
- id: 'fabric.editor.askRovo',
210
- defaultMessage: 'Ask Rovo',
211
- description: 'Button label shown in the quick insert empty results state. Allows users to ask Rovo AI for help.'
212
- },
213
208
  viewMore: {
214
209
  id: 'fabric.editor.viewMore',
215
210
  defaultMessage: 'View more',
@@ -19,7 +19,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
19
19
  var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
20
20
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
21
21
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
22
- var packageVersion = "128.3.2";
22
+ var packageVersion = "128.4.0";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -0,0 +1,29 @@
1
+ var MAX_DATE_MS = 8.64e15; // largest valid Date value
2
+ var FAVORITE_TIER = -2;
3
+ var CURATED_TIER = 1;
4
+ export var TEMPLATE_GALLERY_MENU_RANK = 0;
5
+
6
+ /**
7
+ * Menu rank for a Block template within the Block templates section. Lower ranks appear first.
8
+ * Each rank is its tier plus a fraction in [0, 1), so tiers never overlap.
9
+ *
10
+ * Negative ranks are intentional and valid. This is a `parents[].rank` sort key, not a Fuse score:
11
+ * the registry menu compares ranks by subtraction, and Fuse's 0–1 `score` is a separate value that
12
+ * is compared first when searching, so rank only orders templates with equal scores.
13
+ */
14
+ export var getSnippetMenuRank = function getSnippetMenuRank(_ref) {
15
+ var insertCount = _ref.insertCount,
16
+ isFavorite = _ref.isFavorite,
17
+ scope = _ref.scope,
18
+ updatedAt = _ref.updatedAt;
19
+ if (isFavorite) {
20
+ // Stays in (-2, -1.5]; more inserts rank first.
21
+ return FAVORITE_TIER + 1 / ((insertCount !== null && insertCount !== void 0 ? insertCount : 0) + 2);
22
+ }
23
+ if (scope !== 'GLOBAL') {
24
+ var time = Number.isFinite(updatedAt) ? Math.max(updatedAt, 1) : 1;
25
+ // USER and SITE templates stay in [-1, 0); newer updates rank first.
26
+ return -time / MAX_DATE_MS;
27
+ }
28
+ return CURATED_TIER;
29
+ };
@@ -4,8 +4,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  import Fuse from 'fuse.js';
6
6
  import memoizeOne from 'memoize-one';
7
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
8
- import { boostNativeResultsAboveSkills } from './boost-native-results-above-skills';
9
7
  var processQuickInsertItems = function processQuickInsertItems(items, intl) {
10
8
  return items.reduce(function (acc, item) {
11
9
  if (typeof item === 'function' &&
@@ -59,7 +57,7 @@ var options = {
59
57
  */
60
58
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
61
59
  export function find(query, items, prioritySortingFn) {
62
- var _rerankedResults$data, _rerankedResults$lega;
60
+ var _results$datasourceIn, _results$legacyIndex$;
63
61
  if (query === '') {
64
62
  // Copy and sort list by priority
65
63
  return items.slice(0).sort(function (a, b) {
@@ -78,28 +76,25 @@ export function find(query, items, prioritySortingFn) {
78
76
  var fuse = new Fuse(items, fuseOptions);
79
77
  var results = fuse.search(query);
80
78
 
81
- // platform_editor_insert_menu_ai: boost native editor elements above skills
82
- var rerankedResults = isExperimentEnabled('platform_editor_insert_menu_ai') ? boostNativeResultsAboveSkills(results) : results;
83
-
84
79
  // searching for jira work items macro first
85
- var datasourceIndex = rerankedResults.findIndex(function (r) {
80
+ var datasourceIndex = results.findIndex(function (r) {
86
81
  var _r$item$keywords;
87
82
  return r.item.id === 'datasource' && ((_r$item$keywords = r.item.keywords) === null || _r$item$keywords === void 0 ? void 0 : _r$item$keywords.includes('jira'));
88
83
  });
89
84
 
90
85
  // then searching for the legacy jira macro
91
- var legacyIndex = rerankedResults.findIndex(function (r) {
86
+ var legacyIndex = results.findIndex(function (r) {
92
87
  return typeof r.item.key === 'string' && r.item.key.endsWith(':jira');
93
88
  });
94
89
 
95
90
  // the jira legcy macro is found before the jira work items macro then swap the two
96
- if (datasourceIndex > 0 && legacyIndex >= 0 && legacyIndex < datasourceIndex && Math.abs(((_rerankedResults$data = rerankedResults[datasourceIndex].score) !== null && _rerankedResults$data !== void 0 ? _rerankedResults$data : 0) - ((_rerankedResults$lega = rerankedResults[legacyIndex].score) !== null && _rerankedResults$lega !== void 0 ? _rerankedResults$lega : 0)) < 0.2) {
97
- var _rerankedResults$spli = rerankedResults.splice(datasourceIndex, 1),
98
- _rerankedResults$spli2 = _slicedToArray(_rerankedResults$spli, 1),
99
- datasource = _rerankedResults$spli2[0];
100
- rerankedResults.splice(legacyIndex, 0, datasource);
91
+ if (datasourceIndex > 0 && legacyIndex >= 0 && legacyIndex < datasourceIndex && Math.abs(((_results$datasourceIn = results[datasourceIndex].score) !== null && _results$datasourceIn !== void 0 ? _results$datasourceIn : 0) - ((_results$legacyIndex$ = results[legacyIndex].score) !== null && _results$legacyIndex$ !== void 0 ? _results$legacyIndex$ : 0)) < 0.2) {
92
+ var _results$splice = results.splice(datasourceIndex, 1),
93
+ _results$splice2 = _slicedToArray(_results$splice, 1),
94
+ datasource = _results$splice2[0];
95
+ results.splice(legacyIndex, 0, datasource);
101
96
  }
102
- return rerankedResults.map(function (result) {
97
+ return results.map(function (result) {
103
98
  return result.item;
104
99
  });
105
100
  }
@@ -104,15 +104,5 @@ export var typeAheadListMessages = defineMessages({
104
104
  id: 'fabric.editor.emptySearchResultsSuggestion',
105
105
  defaultMessage: 'Select {buttonName} to browse inserts.',
106
106
  description: 'a prompt to suggest user to click a button to browse inserts when there are no search results'
107
- },
108
- emptySearchResultsSuggestionNew: {
109
- id: 'fabric.editor.emptySearchResultsSuggestionNew',
110
- defaultMessage: 'Select {askRovoName} for help, or {buttonName} to browse inserts.',
111
- description: 'a prompt to suggest user to click a button to browse inserts or ask Rovo for help when there are no search results'
112
- },
113
- emptySearchResultsSuggestionAskRovoOnly: {
114
- id: 'fabric.editor.emptySearchResultsSuggestionAskRovoOnly',
115
- defaultMessage: 'Select {askRovoName} for help.',
116
- description: 'a prompt to suggest user to ask Rovo for help when there are no search results and no browse inserts button is available'
117
107
  }
118
108
  });
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags/fg';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "128.3.2";
24
+ var packageVersion = "128.4.0";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -39,11 +39,6 @@ export declare const toolbarInsertBlockMessages: {
39
39
  description: string;
40
40
  id: string;
41
41
  };
42
- askRovo: {
43
- defaultMessage: string;
44
- description: string;
45
- id: string;
46
- };
47
42
  closeInsertRightRail: {
48
43
  defaultMessage: string;
49
44
  description: string;
@@ -0,0 +1,16 @@
1
+ export type SnippetMenuRankInput = {
2
+ insertCount?: number;
3
+ isFavorite: boolean;
4
+ scope: 'GLOBAL' | 'SITE' | 'USER';
5
+ updatedAt: number;
6
+ };
7
+ export declare const TEMPLATE_GALLERY_MENU_RANK = 0;
8
+ /**
9
+ * Menu rank for a Block template within the Block templates section. Lower ranks appear first.
10
+ * Each rank is its tier plus a fraction in [0, 1), so tiers never overlap.
11
+ *
12
+ * Negative ranks are intentional and valid. This is a `parents[].rank` sort key, not a Fuse score:
13
+ * the registry menu compares ranks by subtraction, and Fuse's 0–1 `score` is a separate value that
14
+ * is compared first when searching, so rank only orders templates with equal scores.
15
+ */
16
+ export declare const getSnippetMenuRank: ({ insertCount, isFavorite, scope, updatedAt, }: SnippetMenuRankInput) => number;
@@ -29,16 +29,6 @@ export declare const typeAheadListMessages: {
29
29
  description: string;
30
30
  id: string;
31
31
  };
32
- emptySearchResultsSuggestionAskRovoOnly: {
33
- defaultMessage: string;
34
- description: string;
35
- id: string;
36
- };
37
- emptySearchResultsSuggestionNew: {
38
- defaultMessage: string;
39
- description: string;
40
- id: string;
41
- };
42
32
  inputQueryAssistiveLabel: {
43
33
  defaultMessage: string;
44
34
  description: string;
@@ -126,13 +126,6 @@ export type TypeAheadHandler = {
126
126
  }) => void;
127
127
  /** Handler returns typeahead item based on query. Used to find which item to insert. */
128
128
  forceSelect?: TypeAheadForceSelect;
129
- /**
130
- * Optional handler that returns an item (Ask Rovo) to display in the typeahead's
131
- * empty-results state.
132
- */
133
- getEmptyItem?: (props: {
134
- editorState: EditorState;
135
- }) => TypeAheadItem | undefined;
136
129
  getHighlight?: (state: EditorState) => JSX.Element | null;
137
130
  /** Handler returns an array of TypeAheadItem based on query to be displayed in the TypeAhead */
138
131
  getItems: (props: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "128.4.0",
3
+ "version": "129.0.0",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@atlaskit/activity-provider": "^3.1.0",
32
- "@atlaskit/adf-schema": "^57.6.0",
32
+ "@atlaskit/adf-schema": "^57.7.0",
33
33
  "@atlaskit/adf-utils": "^20.9.0",
34
34
  "@atlaskit/afm-i18n-platform-editor-editor-common": "2.270.0",
35
35
  "@atlaskit/analytics-listeners": "^11.4.0",
@@ -77,7 +77,7 @@
77
77
  "@atlaskit/profilecard": "^27.1.0",
78
78
  "@atlaskit/prosemirror-history": "^1.3.0",
79
79
  "@atlaskit/react-compiler-gating": "^0.2.0",
80
- "@atlaskit/react-ufo": "^8.0.0",
80
+ "@atlaskit/react-ufo": "^8.1.0",
81
81
  "@atlaskit/section-message": "^10.2.0",
82
82
  "@atlaskit/smart-card": "^46.5.0",
83
83
  "@atlaskit/smart-user-picker": "^12.3.0",
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/quick-insert/snippet-menu-rank",
3
+ "main": "../../dist/cjs/quick-insert/snippetMenuRank.js",
4
+ "module": "../../dist/esm/quick-insert/snippetMenuRank.js",
5
+ "module:es2019": "../../dist/es2019/quick-insert/snippetMenuRank.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../../dist/types/quick-insert/snippetMenuRank.d.ts"
10
+ }
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.boostNativeResultsAboveSkills = boostNativeResultsAboveSkills;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var SCORE_PROXIMITY_THRESHOLD = 0.2;
10
-
11
- /**
12
- * The extension type for Rovo skills, used to identify skill items in the
13
- * quick insert menu. Matches the value defined in
14
- * @atlassian/conversation-assistant-content-transformer/utils/skills.
15
- *
16
- * Intentionally duplicated here to avoid adding a runtime dependency from
17
- * editor-common to the conversation-assistant packages.
18
- */
19
- var ROVO_SKILL_EXTENSION_TYPE = 'com.atlassian.rovo.skill';
20
-
21
- /**
22
- * Promotes native editor elements above Rovo skill items in search results
23
- * when their Fuse scores are close.
24
- *
25
- * An item is classified as a Rovo skill when its `extensionType` property
26
- * (set by `buildMenuItem` for all extension manifest items) matches the
27
- * Rovo skill extension type. Native editor items (Link, Code snippet, Table,
28
- * etc.) and other non-Rovo extensions are unaffected, regardless of their
29
- * priority value.
30
- *
31
- * When a skill and a native item have similar scores (within the proximity
32
- * threshold), the native item is promoted above the skill. But when a skill
33
- * is a significantly better match (e.g. searching "research" and the skill is
34
- * "Research Insights" while the native item is "Live search"), the skill keeps
35
- * its higher rank.
36
- */
37
- function boostNativeResultsAboveSkills(results) {
38
- var isSkill = function isSkill(r) {
39
- return r.item.extensionType === ROVO_SKILL_EXTENSION_TYPE;
40
- };
41
- var reordered = results.slice(0);
42
- for (var i = 1; i < reordered.length; i++) {
43
- if (isSkill(reordered[i])) {
44
- continue;
45
- }
46
- // reordered[i] is a native item — check if there are skills
47
- // ranked above it that have a similar score.
48
- var insertAt = i;
49
- while (insertAt > 0 && isSkill(reordered[insertAt - 1]) && Math.abs(((_reordered$score = reordered[insertAt - 1].score) !== null && _reordered$score !== void 0 ? _reordered$score : 0) - ((_reordered$i$score = reordered[i].score) !== null && _reordered$i$score !== void 0 ? _reordered$i$score : 0)) < SCORE_PROXIMITY_THRESHOLD) {
50
- var _reordered$score, _reordered$i$score;
51
- insertAt--;
52
- }
53
- if (insertAt < i) {
54
- var _reordered$splice = reordered.splice(i, 1),
55
- _reordered$splice2 = (0, _slicedToArray2.default)(_reordered$splice, 1),
56
- native = _reordered$splice2[0];
57
- reordered.splice(insertAt, 0, native);
58
- }
59
- }
60
- return reordered;
61
- }
@@ -1,49 +0,0 @@
1
- const SCORE_PROXIMITY_THRESHOLD = 0.2;
2
-
3
- /**
4
- * The extension type for Rovo skills, used to identify skill items in the
5
- * quick insert menu. Matches the value defined in
6
- * @atlassian/conversation-assistant-content-transformer/utils/skills.
7
- *
8
- * Intentionally duplicated here to avoid adding a runtime dependency from
9
- * editor-common to the conversation-assistant packages.
10
- */
11
- const ROVO_SKILL_EXTENSION_TYPE = 'com.atlassian.rovo.skill';
12
-
13
- /**
14
- * Promotes native editor elements above Rovo skill items in search results
15
- * when their Fuse scores are close.
16
- *
17
- * An item is classified as a Rovo skill when its `extensionType` property
18
- * (set by `buildMenuItem` for all extension manifest items) matches the
19
- * Rovo skill extension type. Native editor items (Link, Code snippet, Table,
20
- * etc.) and other non-Rovo extensions are unaffected, regardless of their
21
- * priority value.
22
- *
23
- * When a skill and a native item have similar scores (within the proximity
24
- * threshold), the native item is promoted above the skill. But when a skill
25
- * is a significantly better match (e.g. searching "research" and the skill is
26
- * "Research Insights" while the native item is "Live search"), the skill keeps
27
- * its higher rank.
28
- */
29
- export function boostNativeResultsAboveSkills(results) {
30
- const isSkill = r => r.item.extensionType === ROVO_SKILL_EXTENSION_TYPE;
31
- const reordered = results.slice(0);
32
- for (let i = 1; i < reordered.length; i++) {
33
- if (isSkill(reordered[i])) {
34
- continue;
35
- }
36
- // reordered[i] is a native item — check if there are skills
37
- // ranked above it that have a similar score.
38
- let insertAt = i;
39
- while (insertAt > 0 && isSkill(reordered[insertAt - 1]) && Math.abs(((_reordered$score = reordered[insertAt - 1].score) !== null && _reordered$score !== void 0 ? _reordered$score : 0) - ((_reordered$i$score = reordered[i].score) !== null && _reordered$i$score !== void 0 ? _reordered$i$score : 0)) < SCORE_PROXIMITY_THRESHOLD) {
40
- var _reordered$score, _reordered$i$score;
41
- insertAt--;
42
- }
43
- if (insertAt < i) {
44
- const [native] = reordered.splice(i, 1);
45
- reordered.splice(insertAt, 0, native);
46
- }
47
- }
48
- return reordered;
49
- }
@@ -1,54 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- var SCORE_PROXIMITY_THRESHOLD = 0.2;
3
-
4
- /**
5
- * The extension type for Rovo skills, used to identify skill items in the
6
- * quick insert menu. Matches the value defined in
7
- * @atlassian/conversation-assistant-content-transformer/utils/skills.
8
- *
9
- * Intentionally duplicated here to avoid adding a runtime dependency from
10
- * editor-common to the conversation-assistant packages.
11
- */
12
- var ROVO_SKILL_EXTENSION_TYPE = 'com.atlassian.rovo.skill';
13
-
14
- /**
15
- * Promotes native editor elements above Rovo skill items in search results
16
- * when their Fuse scores are close.
17
- *
18
- * An item is classified as a Rovo skill when its `extensionType` property
19
- * (set by `buildMenuItem` for all extension manifest items) matches the
20
- * Rovo skill extension type. Native editor items (Link, Code snippet, Table,
21
- * etc.) and other non-Rovo extensions are unaffected, regardless of their
22
- * priority value.
23
- *
24
- * When a skill and a native item have similar scores (within the proximity
25
- * threshold), the native item is promoted above the skill. But when a skill
26
- * is a significantly better match (e.g. searching "research" and the skill is
27
- * "Research Insights" while the native item is "Live search"), the skill keeps
28
- * its higher rank.
29
- */
30
- export function boostNativeResultsAboveSkills(results) {
31
- var isSkill = function isSkill(r) {
32
- return r.item.extensionType === ROVO_SKILL_EXTENSION_TYPE;
33
- };
34
- var reordered = results.slice(0);
35
- for (var i = 1; i < reordered.length; i++) {
36
- if (isSkill(reordered[i])) {
37
- continue;
38
- }
39
- // reordered[i] is a native item — check if there are skills
40
- // ranked above it that have a similar score.
41
- var insertAt = i;
42
- while (insertAt > 0 && isSkill(reordered[insertAt - 1]) && Math.abs(((_reordered$score = reordered[insertAt - 1].score) !== null && _reordered$score !== void 0 ? _reordered$score : 0) - ((_reordered$i$score = reordered[i].score) !== null && _reordered$i$score !== void 0 ? _reordered$i$score : 0)) < SCORE_PROXIMITY_THRESHOLD) {
43
- var _reordered$score, _reordered$i$score;
44
- insertAt--;
45
- }
46
- if (insertAt < i) {
47
- var _reordered$splice = reordered.splice(i, 1),
48
- _reordered$splice2 = _slicedToArray(_reordered$splice, 1),
49
- native = _reordered$splice2[0];
50
- reordered.splice(insertAt, 0, native);
51
- }
52
- }
53
- return reordered;
54
- }
@@ -1,21 +0,0 @@
1
- import type { QuickInsertItem } from '../provider-factory';
2
- /**
3
- * Promotes native editor elements above Rovo skill items in search results
4
- * when their Fuse scores are close.
5
- *
6
- * An item is classified as a Rovo skill when its `extensionType` property
7
- * (set by `buildMenuItem` for all extension manifest items) matches the
8
- * Rovo skill extension type. Native editor items (Link, Code snippet, Table,
9
- * etc.) and other non-Rovo extensions are unaffected, regardless of their
10
- * priority value.
11
- *
12
- * When a skill and a native item have similar scores (within the proximity
13
- * threshold), the native item is promoted above the skill. But when a skill
14
- * is a significantly better match (e.g. searching "research" and the skill is
15
- * "Research Insights" while the native item is "Live search"), the skill keeps
16
- * its higher rank.
17
- */
18
- export declare function boostNativeResultsAboveSkills<T extends {
19
- item: QuickInsertItem;
20
- score?: number;
21
- }>(results: T[]): T[];