@atlaskit/editor-common 128.4.0 → 129.1.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 (57) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/cjs/clipboard/index.js +41 -21
  3. package/dist/cjs/extensibility/extensionNodeView.js +17 -2
  4. package/dist/cjs/extensibility/preserveRemixNodeView.js +150 -0
  5. package/dist/cjs/extensions/native-embed-maui-extension-key.js +8 -0
  6. package/dist/cjs/messages/insert-block.js +0 -5
  7. package/dist/cjs/monitoring/error.js +1 -1
  8. package/dist/cjs/quick-insert/get-matching-quick-insert-components.js +38 -9
  9. package/dist/cjs/quick-insert/getQuickInsertMenuRows.js +12 -0
  10. package/dist/cjs/quick-insert/registered-menu-model.js +7 -0
  11. package/dist/cjs/quick-insert/snippetMenuRank.js +35 -0
  12. package/dist/cjs/quick-insert/utils.js +9 -14
  13. package/dist/cjs/type-ahead/messages.js +0 -10
  14. package/dist/cjs/ui/DropList/index.js +1 -1
  15. package/dist/es2019/clipboard/index.js +18 -6
  16. package/dist/es2019/extensibility/extensionNodeView.js +15 -2
  17. package/dist/es2019/extensibility/preserveRemixNodeView.js +132 -0
  18. package/dist/es2019/extensions/native-embed-maui-extension-key.js +2 -0
  19. package/dist/es2019/messages/insert-block.js +0 -5
  20. package/dist/es2019/monitoring/error.js +1 -1
  21. package/dist/es2019/quick-insert/get-matching-quick-insert-components.js +23 -3
  22. package/dist/es2019/quick-insert/getQuickInsertMenuRows.js +4 -0
  23. package/dist/es2019/quick-insert/registered-menu-model.js +1 -0
  24. package/dist/es2019/quick-insert/snippetMenuRank.js +30 -0
  25. package/dist/es2019/quick-insert/utils.js +7 -12
  26. package/dist/es2019/type-ahead/messages.js +0 -10
  27. package/dist/es2019/ui/DropList/index.js +1 -1
  28. package/dist/esm/clipboard/index.js +40 -20
  29. package/dist/esm/extensibility/extensionNodeView.js +17 -2
  30. package/dist/esm/extensibility/preserveRemixNodeView.js +145 -0
  31. package/dist/esm/extensions/native-embed-maui-extension-key.js +2 -0
  32. package/dist/esm/messages/insert-block.js +0 -5
  33. package/dist/esm/monitoring/error.js +1 -1
  34. package/dist/esm/quick-insert/get-matching-quick-insert-components.js +37 -9
  35. package/dist/esm/quick-insert/getQuickInsertMenuRows.js +5 -0
  36. package/dist/esm/quick-insert/registered-menu-model.js +1 -0
  37. package/dist/esm/quick-insert/snippetMenuRank.js +29 -0
  38. package/dist/esm/quick-insert/utils.js +9 -14
  39. package/dist/esm/type-ahead/messages.js +0 -10
  40. package/dist/esm/ui/DropList/index.js +1 -1
  41. package/dist/types/extensibility/preserveRemixNodeView.d.ts +33 -0
  42. package/dist/types/extensions/native-embed-maui-extension-key.d.ts +1 -0
  43. package/dist/types/messages/insert-block.d.ts +0 -5
  44. package/dist/types/quick-insert/build-quick-insert-menu-model.d.ts +1 -0
  45. package/dist/types/quick-insert/getQuickInsertMenuRows.d.ts +3 -0
  46. package/dist/types/quick-insert/registered-menu-model.d.ts +1 -0
  47. package/dist/types/quick-insert/snippetMenuRank.d.ts +16 -0
  48. package/dist/types/type-ahead/messages.d.ts +0 -10
  49. package/dist/types/types/type-ahead.d.ts +0 -7
  50. package/extensibility/preserve-remix-node-view/package.json +10 -0
  51. package/extensions/native-embed-maui-extension-key/package.json +10 -0
  52. package/package.json +4 -4
  53. package/quick-insert/snippet-menu-rank/package.json +10 -0
  54. package/dist/cjs/quick-insert/boost-native-results-above-skills.js +0 -61
  55. package/dist/es2019/quick-insert/boost-native-results-above-skills.js +0 -49
  56. package/dist/esm/quick-insert/boost-native-results-above-skills.js +0 -54
  57. package/dist/types/quick-insert/boost-native-results-above-skills.d.ts +0 -21
@@ -0,0 +1,145 @@
1
+ import { NATIVE_EMBED_MAUI_EXTENSION_KEY } from '../extensions/native-embed-maui-extension-key';
2
+
3
+ // Do not polyfill with insertBefore: it disconnects an iframe and resets its browsing context.
4
+
5
+ var editors = new WeakMap();
6
+ /** Only block Remix embeds with a stable identity can participate in the handoff. */
7
+ var isRemixNodeForPreservation = function isRemixNodeForPreservation(node) {
8
+ return node.type.name === 'extension' && node.attrs.extensionKey === NATIVE_EMBED_MAUI_EXTENSION_KEY && typeof node.attrs.localId === 'string' && node.attrs.localId.length > 0;
9
+ };
10
+ var sameChart = function sameChart(left, right) {
11
+ return left.mark(left.marks.filter(function (mark) {
12
+ return mark.type.name !== 'annotation';
13
+ })).eq(right.mark(right.marks.filter(function (mark) {
14
+ return mark.type.name !== 'annotation';
15
+ })));
16
+ };
17
+
18
+ /**
19
+ * A disposable ProseMirror slot around a retained React portal. destroy() parks the
20
+ * portal before ProseMirror disconnects its mark wrapper. After reconciliation, the
21
+ * replacement claims the parked portal without taking one from a still-live node.
22
+ */
23
+ export function preserveRemixNodeView(_ref) {
24
+ var node = _ref.node,
25
+ view = _ref.view,
26
+ getPos = _ref.getPos,
27
+ renderProps = _ref.renderProps,
28
+ rendererKind = _ref.rendererKind,
29
+ createExtensionNode = _ref.createExtensionNode;
30
+ if (!isRemixNodeForPreservation(node)) {
31
+ return createExtensionNode(node).init();
32
+ }
33
+ var ownerDocument = view.dom.ownerDocument;
34
+ var slot = ownerDocument.createElement('div');
35
+ if (!view.dom.isConnected || typeof getPos !== 'function' || typeof slot.moveBefore !== 'function') {
36
+ return createExtensionNode(node).init();
37
+ }
38
+ var owner = {
39
+ getPos: getPos,
40
+ destroyed: false
41
+ };
42
+ var entries = editors.get(view);
43
+ if (!entries) {
44
+ entries = new Set();
45
+ editors.set(view, entries);
46
+ }
47
+ var registry = entries;
48
+ var entry;
49
+ var latestNode = node;
50
+ var latestDecorations = [];
51
+ var latestInnerDecorations;
52
+
53
+ // Construction can precede the old slot's destroy(). Defer portal adoption until
54
+ // both hooks have run; no rendering opportunity occurs between these microtasks.
55
+ queueMicrotask(function () {
56
+ if (owner.destroyed || view.isDestroyed || !slot.isConnected) {
57
+ return;
58
+ }
59
+ entry = Array.from(registry).find(function (existing) {
60
+ return existing.owner.destroyed && existing.rendererKind === rendererKind && sameChart(existing.inner.node, latestNode);
61
+ });
62
+ if (entry) {
63
+ var _slot$moveBefore, _entry$parking;
64
+ entry.owner = owner;
65
+ entry.inner.reactComponentProps = renderProps;
66
+ (_slot$moveBefore = slot.moveBefore) === null || _slot$moveBefore === void 0 || _slot$moveBefore.call(slot, entry.inner.dom, null);
67
+ (_entry$parking = entry.parking) === null || _entry$parking === void 0 || _entry$parking.remove();
68
+ entry.parking = undefined;
69
+ if (!entry.inner.update(latestNode, latestDecorations, latestInnerDecorations)) {
70
+ // A matching chart is normally accepted, but honour the NodeView contract
71
+ // if a renderer rejects it. Remove the old portal before creating a replacement.
72
+ registry.delete(entry);
73
+ var dom = entry.inner.dom;
74
+ entry.inner.destroy();
75
+ dom.remove();
76
+ entry = undefined;
77
+ }
78
+ }
79
+ if (!entry) {
80
+ // Construct only after the old slot has had a chance to park its portal.
81
+ var inner = createExtensionNode(latestNode);
82
+ var retained = {
83
+ inner: inner,
84
+ owner: owner,
85
+ rendererKind: rendererKind
86
+ };
87
+ entry = retained;
88
+ inner.getPos = function () {
89
+ return retained.owner.destroyed ? undefined : retained.owner.getPos();
90
+ };
91
+ inner.init();
92
+ slot.appendChild(inner.dom);
93
+ registry.add(retained);
94
+ }
95
+ });
96
+ return {
97
+ dom: slot,
98
+ // The retained extension is an atom: ProseMirror must not manage the portal's children.
99
+ update: function update(next, decorations, innerDecorations) {
100
+ if (next.type !== node.type || next.attrs.localId !== node.attrs.localId || next.attrs.extensionKey !== node.attrs.extensionKey) {
101
+ return false;
102
+ }
103
+ latestNode = next;
104
+ latestDecorations = decorations;
105
+ latestInnerDecorations = innerDecorations;
106
+ return entry ? entry.inner.update(next, decorations, innerDecorations) : true;
107
+ },
108
+ stopEvent: function stopEvent(event) {
109
+ var _entry$inner$stopEven, _entry;
110
+ return (_entry$inner$stopEven = (_entry = entry) === null || _entry === void 0 ? void 0 : _entry.inner.stopEvent(event)) !== null && _entry$inner$stopEven !== void 0 ? _entry$inner$stopEven : false;
111
+ },
112
+ ignoreMutation: function ignoreMutation(mutation) {
113
+ var _entry$inner$ignoreMu, _entry2;
114
+ return (_entry$inner$ignoreMu = (_entry2 = entry) === null || _entry2 === void 0 ? void 0 : _entry2.inner.ignoreMutation(mutation)) !== null && _entry$inner$ignoreMu !== void 0 ? _entry$inner$ignoreMu : mutation.type !== 'selection';
115
+ },
116
+ destroy: function destroy() {
117
+ owner.destroyed = true;
118
+ if (!entry) {
119
+ return;
120
+ }
121
+ var retained = entry;
122
+ if (retained.inner.dom.isConnected) {
123
+ var _parking$moveBefore;
124
+ var parking = ownerDocument.createElement('div');
125
+ // Transient, outside the editable document and inaccessible while awaiting handoff.
126
+ parking.hidden = true;
127
+ ownerDocument.body.appendChild(parking);
128
+ (_parking$moveBefore = parking.moveBefore) === null || _parking$moveBefore === void 0 || _parking$moveBefore.call(parking, retained.inner.dom, null);
129
+ retained.parking = parking;
130
+ }
131
+ // Give constructors queued after destroy() a chance to claim the portal first.
132
+ queueMicrotask(function () {
133
+ return queueMicrotask(function () {
134
+ if (retained.owner === owner && registry.delete(retained)) {
135
+ var _retained$parking;
136
+ var dom = retained.inner.dom;
137
+ retained.inner.destroy();
138
+ dom.remove();
139
+ (_retained$parking = retained.parking) === null || _retained$parking === void 0 || _retained$parking.remove();
140
+ }
141
+ });
142
+ });
143
+ }
144
+ };
145
+ }
@@ -0,0 +1,2 @@
1
+ import { NATIVE_EMBED_EXTENSION_KEY } from './manifest-helpers';
2
+ export var NATIVE_EMBED_MAUI_EXTENSION_KEY = "".concat(NATIVE_EMBED_EXTENSION_KEY, ":maui");
@@ -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 = "129.0.0";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -1,3 +1,4 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
3
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
4
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
@@ -5,6 +6,7 @@ import { getComponentIdentity, resolveSurface, willComponentRender } from '@atla
5
6
  import { isMenuFooterSectionKey } from '../type-ahead/isMenuFooterSectionKey';
6
7
  import { isSectionOverflowItemKey } from '../type-ahead/isSectionOverflowItemKey';
7
8
  import { ASK_ROVO_MENU_ITEM } from './keys';
9
+ var SEARCH_TOP_MATCH_LIMIT = 5;
8
10
  var getRank = function getRank(component, parentKey) {
9
11
  var _component$parents$fi, _component$parents;
10
12
  return (_component$parents$fi = (_component$parents = component.parents) === null || _component$parents === void 0 || (_component$parents = _component$parents.find(function (parent) {
@@ -12,20 +14,38 @@ var getRank = function getRank(component, parentKey) {
12
14
  })) === null || _component$parents === void 0 ? void 0 : _component$parents.rank) !== null && _component$parents$fi !== void 0 ? _component$parents$fi : Number.MAX_SAFE_INTEGER;
13
15
  };
14
16
  var compareMatchedItems = function compareMatchedItems(a, b) {
15
- return a.sectionRank - b.sectionRank || a.score - b.score || a.itemRank - b.itemRank || a.identity.localeCompare(b.identity);
17
+ return a.sectionRank - b.sectionRank || a.score - b.score || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
18
+ };
19
+ var compareSearchResults = function compareSearchResults(a, b) {
20
+ return a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
21
+ };
22
+ var getSearchResults = function getSearchResults(matches) {
23
+ var topMatches = Array.from(matches).sort(compareSearchResults).slice(0, SEARCH_TOP_MATCH_LIMIT);
24
+ var topMatchIdentities = new Set(topMatches.map(function (_ref) {
25
+ var identity = _ref.identity;
26
+ return identity;
27
+ }));
28
+ var tailMatches = matches.filter(function (_ref2) {
29
+ var identity = _ref2.identity;
30
+ return !topMatchIdentities.has(identity);
31
+ });
32
+ return [].concat(_toConsumableArray(topMatches), _toConsumableArray(tailMatches)).map(function (_ref3) {
33
+ var item = _ref3.item;
34
+ return item;
35
+ });
16
36
  };
17
37
 
18
38
  /**
19
39
  * Resolves registered menu items for a non-empty query. This intentionally has
20
40
  * no empty-query path so browse behavior remains owned by buildQuickInsertMenuModel.
21
41
  */
22
- export var getMatchingQuickInsertComponents = function getMatchingQuickInsertComponents(_ref) {
42
+ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertComponents(_ref4) {
23
43
  var _childrenMap$get2;
24
- var components = _ref.components,
25
- rootComponent = _ref.rootComponent,
26
- query = _ref.query,
27
- formatMessage = _ref.formatMessage,
28
- surfaceContext = _ref.surfaceContext;
44
+ var components = _ref4.components,
45
+ rootComponent = _ref4.rootComponent,
46
+ query = _ref4.query,
47
+ formatMessage = _ref4.formatMessage,
48
+ surfaceContext = _ref4.surfaceContext;
29
49
  var _resolveSurface = resolveSurface(components, rootComponent),
30
50
  childrenMap = _resolveSurface.childrenMap,
31
51
  root = _resolveSurface.root,
@@ -38,6 +58,9 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
38
58
  };
39
59
  }
40
60
  var matches = new Map();
61
+ var sourceIndexByComponent = new Map(components.map(function (component, index) {
62
+ return [component, index];
63
+ }));
41
64
  var _iterator = _createForOfIteratorHelper(topLevelChildren),
42
65
  _step;
43
66
  try {
@@ -51,7 +74,7 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
51
74
  _step3;
52
75
  try {
53
76
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
54
- var _item$match, _match$score;
77
+ var _item$match, _match$score, _sourceIndexByCompone;
55
78
  var item = _step3.value;
56
79
  if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap, surfaceContext)) {
57
80
  continue;
@@ -68,6 +91,7 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
68
91
  item: item,
69
92
  itemRank: getRank(item, section.key),
70
93
  score: Math.min(1, Math.max(0, (_match$score = match === null || match === void 0 ? void 0 : match.score) !== null && _match$score !== void 0 ? _match$score : 0)),
94
+ sourceIndex: (_sourceIndexByCompone = sourceIndexByComponent.get(item)) !== null && _sourceIndexByCompone !== void 0 ? _sourceIndexByCompone : Number.MAX_SAFE_INTEGER,
71
95
  section: section,
72
96
  sectionRank: getRank(section, root.key)
73
97
  };
@@ -87,8 +111,10 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
87
111
  } finally {
88
112
  _iterator.f();
89
113
  }
114
+ var uniqueMatches = Array.from(matches.values()).sort(compareMatchedItems);
115
+ var searchResults = query !== '' ? getSearchResults(uniqueMatches) : undefined;
90
116
  var sectionsByKey = new Map();
91
- var _iterator2 = _createForOfIteratorHelper(Array.from(matches.values()).sort(compareMatchedItems)),
117
+ var _iterator2 = _createForOfIteratorHelper(uniqueMatches),
92
118
  _step2;
93
119
  try {
94
120
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
@@ -110,6 +136,7 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
110
136
  return {
111
137
  footer: undefined,
112
138
  root: root,
139
+ searchResults: searchResults,
113
140
  sections: sections
114
141
  };
115
142
  }
@@ -132,6 +159,7 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
132
159
  fallbackItems: fallbackItems,
133
160
  footer: footer,
134
161
  root: root,
162
+ searchResults: searchResults,
135
163
  sections: sections
136
164
  };
137
165
  };
@@ -0,0 +1,5 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ export var getQuickInsertMenuRows = function getQuickInsertMenuRows(model) {
3
+ var _model$searchResults, _model$fallbackItems;
4
+ return [].concat(_toConsumableArray((_model$searchResults = model.searchResults) !== null && _model$searchResults !== void 0 ? _model$searchResults : model.sections.flat()), _toConsumableArray((_model$fallbackItems = model.fallbackItems) !== null && _model$fallbackItems !== void 0 ? _model$fallbackItems : []));
5
+ };
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
2
 
3
3
  export { buildQuickInsertMenuModel } from './build-quick-insert-menu-model';
4
+ export { getQuickInsertMenuRows } from './getQuickInsertMenuRows';
4
5
  export { quickInsertProviderMenuItemKey } from './getQuickInsertProviderMenuItemKey';
5
6
  export { selectQuickInsertCategoryItems } from './selectQuickInsertCategoryItems';
6
7
  export { getMatchingQuickInsertComponents } from './get-matching-quick-insert-components';
@@ -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 = "129.0.0";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -0,0 +1,33 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Decoration, DecorationSource, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { getPosHandler } from '../react-node-view';
4
+ type ExtensionView = {
5
+ destroy: () => void;
6
+ dom: HTMLElement;
7
+ getPos: getPosHandler;
8
+ ignoreMutation: (mutation: MutationRecord | {
9
+ target: Node;
10
+ type: 'selection';
11
+ }) => boolean;
12
+ init: () => NodeView;
13
+ node: PMNode;
14
+ reactComponentProps: unknown;
15
+ stopEvent: (event: Event) => boolean;
16
+ update: (node: PMNode, decorations: readonly Decoration[], innerDecorations?: DecorationSource) => boolean;
17
+ view: EditorView;
18
+ };
19
+ type PreservationOptions = {
20
+ createExtensionNode: (node: PMNode) => ExtensionView;
21
+ getPos: getPosHandler;
22
+ node: PMNode;
23
+ rendererKind: object;
24
+ renderProps: unknown;
25
+ view: EditorView;
26
+ };
27
+ /**
28
+ * A disposable ProseMirror slot around a retained React portal. destroy() parks the
29
+ * portal before ProseMirror disconnects its mark wrapper. After reconciliation, the
30
+ * replacement claims the parked portal without taking one from a still-live node.
31
+ */
32
+ export declare function preserveRemixNodeView({ node, view, getPos, renderProps, rendererKind, createExtensionNode, }: PreservationOptions): NodeView;
33
+ export {};
@@ -0,0 +1 @@
1
+ export declare const NATIVE_EMBED_MAUI_EXTENSION_KEY: string;
@@ -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;
@@ -6,6 +6,7 @@ export type QuickInsertMenuModel = {
6
6
  fallbackItems?: RegisterMenuItem[];
7
7
  footer: RegisterMenuItem | undefined;
8
8
  root: RegisterComponent | undefined;
9
+ searchResults?: RegisterMenuItem[];
9
10
  sections: QuickInsertMenuSection[];
10
11
  };
11
12
  export declare const buildQuickInsertMenuModel: (components: RegisterComponent[], rootComponent: SurfaceIdentifier, selectCategoryItems?: QuickInsertCategoryItemSelectionPolicy, surfaceContext?: SurfaceContext) => QuickInsertMenuModel;
@@ -0,0 +1,3 @@
1
+ import type { RegisterMenuItem, RegisterMenuSection } from '@atlaskit/editor-ui-control-model/types';
2
+ import type { QuickInsertMenuModel } from './build-quick-insert-menu-model';
3
+ export declare const getQuickInsertMenuRows: (model: QuickInsertMenuModel) => Array<RegisterMenuItem | RegisterMenuSection>;
@@ -1,4 +1,5 @@
1
1
  export { buildQuickInsertMenuModel } from './build-quick-insert-menu-model';
2
+ export { getQuickInsertMenuRows } from './getQuickInsertMenuRows';
2
3
  export { quickInsertProviderMenuItemKey } from './getQuickInsertProviderMenuItemKey';
3
4
  export { selectQuickInsertCategoryItems } from './selectQuickInsertCategoryItems';
4
5
  export { getMatchingQuickInsertComponents } from './get-matching-quick-insert-components';
@@ -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: {
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/extensibility/preserve-remix-node-view",
3
+ "main": "../../dist/cjs/extensibility/preserveRemixNodeView.js",
4
+ "module": "../../dist/esm/extensibility/preserveRemixNodeView.js",
5
+ "module:es2019": "../../dist/es2019/extensibility/preserveRemixNodeView.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../../dist/types/extensibility/preserveRemixNodeView.d.ts"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/extensions/native-embed-maui-extension-key",
3
+ "main": "../../dist/cjs/extensions/native-embed-maui-extension-key.js",
4
+ "module": "../../dist/esm/extensions/native-embed-maui-extension-key.js",
5
+ "module:es2019": "../../dist/es2019/extensions/native-embed-maui-extension-key.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../../dist/types/extensions/native-embed-maui-extension-key.d.ts"
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "128.4.0",
3
+ "version": "129.1.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",
@@ -85,7 +85,7 @@
85
85
  "@atlaskit/task-decision": "^21.12.0",
86
86
  "@atlaskit/teams-app-config": "^3.1.0",
87
87
  "@atlaskit/textfield": "^10.2.0",
88
- "@atlaskit/tmp-editor-statsig": "^224.0.0",
88
+ "@atlaskit/tmp-editor-statsig": "^225.0.0",
89
89
  "@atlaskit/tokens": "^20.3.0",
90
90
  "@atlaskit/tooltip": "^24.4.0",
91
91
  "@atlaskit/width-detector": "^7.2.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
+ }