@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
@@ -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 = "129.0.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -37,8 +37,15 @@ export const copyToClipboard = async textToCopy => {
37
37
  }
38
38
  };
39
39
 
40
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
41
- export const copyHTMLToClipboard = async (elementToCopy, plainTextToCopy) => {
40
+ // EDF-2436: the copy helpers below are called fire-and-forget from click handlers, so a
41
+ // late rejection (eg. the polyfill's DOM fallback running after the document is gone)
42
+ // becomes an unhandled rejection and takes down the whole process. Attaching a no-op
43
+ // handler marks it handled; callers that await still receive the error.
44
+ const markRejectionHandled = promise => {
45
+ promise.catch(() => {});
46
+ return promise;
47
+ };
48
+ const writeHTMLToClipboard = async (elementToCopy, plainTextToCopy) => {
42
49
  if (isClipboardApiSupported() && typeof ClipboardItem !== 'undefined') {
43
50
  try {
44
51
  const data = new ClipboardItem({
@@ -57,7 +64,8 @@ export const copyHTMLToClipboard = async (elementToCopy, plainTextToCopy) => {
57
64
  try {
58
65
  // ED-17083 extension copy seems have issue with ClipboardItem API
59
66
  // Hence of use of this polyfill
60
- copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy);
67
+ // Awaited so the polyfill's async failures land in the catch below.
68
+ await copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy);
61
69
  } catch (error) {
62
70
  // eslint-disable-next-line no-console
63
71
  console.log(error);
@@ -65,10 +73,9 @@ export const copyHTMLToClipboard = async (elementToCopy, plainTextToCopy) => {
65
73
  }
66
74
  };
67
75
 
68
- // At the time of development, Firefox doesn't support ClipboardItem API
69
- // Hence of use of this polyfill
70
76
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
71
- export const copyHTMLToClipboardPolyfill = async (elementToCopy, plainTextToCopy) => {
77
+ export const copyHTMLToClipboard = (elementToCopy, plainTextToCopy) => markRejectionHandled(writeHTMLToClipboard(elementToCopy, plainTextToCopy));
78
+ const writeHTMLToClipboardPolyfill = async (elementToCopy, plainTextToCopy) => {
72
79
  const dt = new clipboard.ClipboardItem({
73
80
  'text/html': new Blob([elementToCopy.innerHTML], {
74
81
  type: 'text/html'
@@ -80,6 +87,11 @@ export const copyHTMLToClipboardPolyfill = async (elementToCopy, plainTextToCopy
80
87
  await clipboard.write([dt]);
81
88
  };
82
89
 
90
+ // At the time of development, Firefox doesn't support ClipboardItem API
91
+ // Hence of use of this polyfill
92
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
93
+ export const copyHTMLToClipboardPolyfill = (elementToCopy, plainTextToCopy) => markRejectionHandled(writeHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy));
94
+
83
95
  // Safari can revoke transient user activation before asynchronous clipboard writes complete.
84
96
  // Keep this helper synchronous so callers can invoke it directly from a click handler.
85
97
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
@@ -7,6 +7,7 @@ import ReactNodeView from '../react-node-view';
7
7
  import { Extension } from './Extension';
8
8
  import { ExtensionNodeWrapper } from './ExtensionNodeWrapper';
9
9
  import { isNativeEmbedExtension } from './nativeEmbedExtension';
10
+ import { preserveRemixNodeView } from './preserveRemixNodeView';
10
11
  /**
11
12
  * Allowlists of extension keys + layout
12
13
  * Currently, only toc with default layout allows to skip React render.
@@ -334,7 +335,7 @@ function ExtensionNodeRender({
334
335
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
335
336
  export default function ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionLoadingHandlers, extensionNodeViewOptions, pluginInjectionApi, macroInteractionDesignFeatureFlags, showLivePagesBodiedMacrosRendererView, showUpdatedLivePages1PBodiedExtensionUI, rendererExtensionHandlers, intl) {
336
337
  return (node, view, getPos) => {
337
- return new ExtensionNode(node, view, getPos, portalProviderAPI, eventDispatcher, {
338
+ const renderProps = {
338
339
  providerFactory,
339
340
  extensionHandlers,
340
341
  extensionLoadingHandlers,
@@ -345,6 +346,18 @@ export default function ExtensionNodeView(portalProviderAPI, eventDispatcher, pr
345
346
  showUpdatedLivePages1PBodiedExtensionUI,
346
347
  rendererExtensionHandlers,
347
348
  intl
348
- }).init();
349
+ };
350
+ const createExtensionNode = currentNode => new ExtensionNode(currentNode, view, getPos, portalProviderAPI, eventDispatcher, renderProps);
351
+ if (!isSSR() && fg('cc_maui_annotations_on_extensions')) {
352
+ return preserveRemixNodeView({
353
+ node,
354
+ view,
355
+ getPos,
356
+ renderProps,
357
+ rendererKind: ExtensionNode,
358
+ createExtensionNode
359
+ });
360
+ }
361
+ return createExtensionNode(node).init();
349
362
  };
350
363
  }
@@ -0,0 +1,132 @@
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
+ const editors = new WeakMap();
6
+ /** Only block Remix embeds with a stable identity can participate in the handoff. */
7
+ const isRemixNodeForPreservation = node => node.type.name === 'extension' && node.attrs.extensionKey === NATIVE_EMBED_MAUI_EXTENSION_KEY && typeof node.attrs.localId === 'string' && node.attrs.localId.length > 0;
8
+ const sameChart = (left, right) => left.mark(left.marks.filter(mark => mark.type.name !== 'annotation')).eq(right.mark(right.marks.filter(mark => mark.type.name !== 'annotation')));
9
+
10
+ /**
11
+ * A disposable ProseMirror slot around a retained React portal. destroy() parks the
12
+ * portal before ProseMirror disconnects its mark wrapper. After reconciliation, the
13
+ * replacement claims the parked portal without taking one from a still-live node.
14
+ */
15
+ export function preserveRemixNodeView({
16
+ node,
17
+ view,
18
+ getPos,
19
+ renderProps,
20
+ rendererKind,
21
+ createExtensionNode
22
+ }) {
23
+ if (!isRemixNodeForPreservation(node)) {
24
+ return createExtensionNode(node).init();
25
+ }
26
+ const ownerDocument = view.dom.ownerDocument;
27
+ const slot = ownerDocument.createElement('div');
28
+ if (!view.dom.isConnected || typeof getPos !== 'function' || typeof slot.moveBefore !== 'function') {
29
+ return createExtensionNode(node).init();
30
+ }
31
+ const owner = {
32
+ getPos,
33
+ destroyed: false
34
+ };
35
+ let entries = editors.get(view);
36
+ if (!entries) {
37
+ entries = new Set();
38
+ editors.set(view, entries);
39
+ }
40
+ const registry = entries;
41
+ let entry;
42
+ let latestNode = node;
43
+ let latestDecorations = [];
44
+ let latestInnerDecorations;
45
+
46
+ // Construction can precede the old slot's destroy(). Defer portal adoption until
47
+ // both hooks have run; no rendering opportunity occurs between these microtasks.
48
+ queueMicrotask(() => {
49
+ if (owner.destroyed || view.isDestroyed || !slot.isConnected) {
50
+ return;
51
+ }
52
+ entry = Array.from(registry).find(existing => existing.owner.destroyed && existing.rendererKind === rendererKind && sameChart(existing.inner.node, latestNode));
53
+ if (entry) {
54
+ var _slot$moveBefore, _entry$parking;
55
+ entry.owner = owner;
56
+ entry.inner.reactComponentProps = renderProps;
57
+ (_slot$moveBefore = slot.moveBefore) === null || _slot$moveBefore === void 0 ? void 0 : _slot$moveBefore.call(slot, entry.inner.dom, null);
58
+ (_entry$parking = entry.parking) === null || _entry$parking === void 0 ? void 0 : _entry$parking.remove();
59
+ entry.parking = undefined;
60
+ if (!entry.inner.update(latestNode, latestDecorations, latestInnerDecorations)) {
61
+ // A matching chart is normally accepted, but honour the NodeView contract
62
+ // if a renderer rejects it. Remove the old portal before creating a replacement.
63
+ registry.delete(entry);
64
+ const dom = entry.inner.dom;
65
+ entry.inner.destroy();
66
+ dom.remove();
67
+ entry = undefined;
68
+ }
69
+ }
70
+ if (!entry) {
71
+ // Construct only after the old slot has had a chance to park its portal.
72
+ const inner = createExtensionNode(latestNode);
73
+ const retained = {
74
+ inner,
75
+ owner,
76
+ rendererKind
77
+ };
78
+ entry = retained;
79
+ inner.getPos = () => retained.owner.destroyed ? undefined : retained.owner.getPos();
80
+ inner.init();
81
+ slot.appendChild(inner.dom);
82
+ registry.add(retained);
83
+ }
84
+ });
85
+ return {
86
+ dom: slot,
87
+ // The retained extension is an atom: ProseMirror must not manage the portal's children.
88
+ update(next, decorations, innerDecorations) {
89
+ if (next.type !== node.type || next.attrs.localId !== node.attrs.localId || next.attrs.extensionKey !== node.attrs.extensionKey) {
90
+ return false;
91
+ }
92
+ latestNode = next;
93
+ latestDecorations = decorations;
94
+ latestInnerDecorations = innerDecorations;
95
+ return entry ? entry.inner.update(next, decorations, innerDecorations) : true;
96
+ },
97
+ stopEvent: event => {
98
+ var _entry$inner$stopEven, _entry;
99
+ 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;
100
+ },
101
+ ignoreMutation: mutation => {
102
+ var _entry$inner$ignoreMu, _entry2;
103
+ 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';
104
+ },
105
+ destroy() {
106
+ owner.destroyed = true;
107
+ if (!entry) {
108
+ return;
109
+ }
110
+ const retained = entry;
111
+ if (retained.inner.dom.isConnected) {
112
+ var _parking$moveBefore;
113
+ const parking = ownerDocument.createElement('div');
114
+ // Transient, outside the editable document and inaccessible while awaiting handoff.
115
+ parking.hidden = true;
116
+ ownerDocument.body.appendChild(parking);
117
+ (_parking$moveBefore = parking.moveBefore) === null || _parking$moveBefore === void 0 ? void 0 : _parking$moveBefore.call(parking, retained.inner.dom, null);
118
+ retained.parking = parking;
119
+ }
120
+ // Give constructors queued after destroy() a chance to claim the portal first.
121
+ queueMicrotask(() => queueMicrotask(() => {
122
+ if (retained.owner === owner && registry.delete(retained)) {
123
+ var _retained$parking;
124
+ const dom = retained.inner.dom;
125
+ retained.inner.destroy();
126
+ dom.remove();
127
+ (_retained$parking = retained.parking) === null || _retained$parking === void 0 ? void 0 : _retained$parking.remove();
128
+ }
129
+ }));
130
+ }
131
+ };
132
+ }
@@ -0,0 +1,2 @@
1
+ import { NATIVE_EMBED_EXTENSION_KEY } from './manifest-helpers';
2
+ export const NATIVE_EMBED_MAUI_EXTENSION_KEY = `${NATIVE_EMBED_EXTENSION_KEY}:maui`;
@@ -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 = "129.0.0";
17
17
  const sanitiseSentryEvents = (data, _hint) => {
18
18
  // Remove URL as it has UGC
19
19
  // Ignored via go/ees007
@@ -2,11 +2,25 @@ import { getComponentIdentity, resolveSurface, willComponentRender } from '@atla
2
2
  import { isMenuFooterSectionKey } from '../type-ahead/isMenuFooterSectionKey';
3
3
  import { isSectionOverflowItemKey } from '../type-ahead/isSectionOverflowItemKey';
4
4
  import { ASK_ROVO_MENU_ITEM } from './keys';
5
+ const SEARCH_TOP_MATCH_LIMIT = 5;
5
6
  const getRank = (component, parentKey) => {
6
7
  var _component$parents$fi, _component$parents, _component$parents$fi2;
7
8
  return (_component$parents$fi = (_component$parents = component.parents) === null || _component$parents === void 0 ? void 0 : (_component$parents$fi2 = _component$parents.find(parent => parent.key === parentKey)) === null || _component$parents$fi2 === void 0 ? void 0 : _component$parents$fi2.rank) !== null && _component$parents$fi !== void 0 ? _component$parents$fi : Number.MAX_SAFE_INTEGER;
8
9
  };
9
- const compareMatchedItems = (a, b) => a.sectionRank - b.sectionRank || a.score - b.score || a.itemRank - b.itemRank || a.identity.localeCompare(b.identity);
10
+ const compareMatchedItems = (a, b) => a.sectionRank - b.sectionRank || a.score - b.score || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
11
+ const compareSearchResults = (a, b) => a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
12
+ const getSearchResults = matches => {
13
+ const topMatches = Array.from(matches).sort(compareSearchResults).slice(0, SEARCH_TOP_MATCH_LIMIT);
14
+ const topMatchIdentities = new Set(topMatches.map(({
15
+ identity
16
+ }) => identity));
17
+ const tailMatches = matches.filter(({
18
+ identity
19
+ }) => !topMatchIdentities.has(identity));
20
+ return [...topMatches, ...tailMatches].map(({
21
+ item
22
+ }) => item);
23
+ };
10
24
 
11
25
  /**
12
26
  * Resolves registered menu items for a non-empty query. This intentionally has
@@ -33,12 +47,13 @@ export const getMatchingQuickInsertComponents = ({
33
47
  };
34
48
  }
35
49
  const matches = new Map();
50
+ const sourceIndexByComponent = new Map(components.map((component, index) => [component, index]));
36
51
  for (const section of topLevelChildren) {
37
52
  if (section.type !== 'menu-section' || isMenuFooterSectionKey(section.key) || !willComponentRender(section, childrenMap, surfaceContext)) {
38
53
  continue;
39
54
  }
40
55
  for (const item of (_childrenMap$get = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []) {
41
- var _childrenMap$get, _item$match, _match$score;
56
+ var _childrenMap$get, _item$match, _match$score, _sourceIndexByCompone;
42
57
  if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap, surfaceContext)) {
43
58
  continue;
44
59
  }
@@ -54,6 +69,7 @@ export const getMatchingQuickInsertComponents = ({
54
69
  item,
55
70
  itemRank: getRank(item, section.key),
56
71
  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)),
72
+ sourceIndex: (_sourceIndexByCompone = sourceIndexByComponent.get(item)) !== null && _sourceIndexByCompone !== void 0 ? _sourceIndexByCompone : Number.MAX_SAFE_INTEGER,
57
73
  section,
58
74
  sectionRank: getRank(section, root.key)
59
75
  };
@@ -63,8 +79,10 @@ export const getMatchingQuickInsertComponents = ({
63
79
  }
64
80
  }
65
81
  }
82
+ const uniqueMatches = Array.from(matches.values()).sort(compareMatchedItems);
83
+ const searchResults = query !== '' ? getSearchResults(uniqueMatches) : undefined;
66
84
  const sectionsByKey = new Map();
67
- for (const match of Array.from(matches.values()).sort(compareMatchedItems)) {
85
+ for (const match of uniqueMatches) {
68
86
  const existing = sectionsByKey.get(match.section.key);
69
87
  if (existing) {
70
88
  existing.push(match.item);
@@ -77,6 +95,7 @@ export const getMatchingQuickInsertComponents = ({
77
95
  return {
78
96
  footer: undefined,
79
97
  root,
98
+ searchResults,
80
99
  sections
81
100
  };
82
101
  }
@@ -91,6 +110,7 @@ export const getMatchingQuickInsertComponents = ({
91
110
  fallbackItems,
92
111
  footer,
93
112
  root,
113
+ searchResults,
94
114
  sections
95
115
  };
96
116
  };
@@ -0,0 +1,4 @@
1
+ export const getQuickInsertMenuRows = model => {
2
+ var _model$searchResults, _model$fallbackItems;
3
+ return [...((_model$searchResults = model.searchResults) !== null && _model$searchResults !== void 0 ? _model$searchResults : model.sections.flat()), ...((_model$fallbackItems = model.fallbackItems) !== null && _model$fallbackItems !== void 0 ? _model$fallbackItems : [])];
4
+ };
@@ -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,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 = "129.0.0";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -83,10 +83,17 @@ export var copyToClipboard = /*#__PURE__*/function () {
83
83
  };
84
84
  }();
85
85
 
86
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
87
- export var copyHTMLToClipboard = /*#__PURE__*/function () {
86
+ // EDF-2436: the copy helpers below are called fire-and-forget from click handlers, so a
87
+ // late rejection (eg. the polyfill's DOM fallback running after the document is gone)
88
+ // becomes an unhandled rejection and takes down the whole process. Attaching a no-op
89
+ // handler marks it handled; callers that await still receive the error.
90
+ var markRejectionHandled = function markRejectionHandled(promise) {
91
+ promise.catch(function () {});
92
+ return promise;
93
+ };
94
+ var writeHTMLToClipboard = /*#__PURE__*/function () {
88
95
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(elementToCopy, plainTextToCopy) {
89
- var data, _t3;
96
+ var data, _t3, _t4;
90
97
  return _regeneratorRuntime.wrap(function (_context2) {
91
98
  while (1) switch (_context2.prev = _context2.next) {
92
99
  case 0:
@@ -113,34 +120,40 @@ export var copyHTMLToClipboard = /*#__PURE__*/function () {
113
120
  _t3 = _context2["catch"](1);
114
121
  throw new Error('Clipboard api is not supported');
115
122
  case 4:
116
- _context2.next = 6;
123
+ _context2.next = 9;
117
124
  break;
118
125
  case 5:
119
- if (!!document && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object') {
120
- try {
121
- // ED-17083 extension copy seems have issue with ClipboardItem API
122
- // Hence of use of this polyfill
123
- copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy);
124
- } catch (error) {
125
- // eslint-disable-next-line no-console
126
- console.log(error);
127
- }
126
+ if (!(!!document && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object')) {
127
+ _context2.next = 9;
128
+ break;
128
129
  }
129
- case 6:
130
+ _context2.prev = 6;
131
+ _context2.next = 7;
132
+ return copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy);
133
+ case 7:
134
+ _context2.next = 9;
135
+ break;
136
+ case 8:
137
+ _context2.prev = 8;
138
+ _t4 = _context2["catch"](6);
139
+ // eslint-disable-next-line no-console
140
+ console.log(_t4);
141
+ case 9:
130
142
  case "end":
131
143
  return _context2.stop();
132
144
  }
133
- }, _callee2, null, [[1, 3]]);
145
+ }, _callee2, null, [[1, 3], [6, 8]]);
134
146
  }));
135
- return function copyHTMLToClipboard(_x2, _x3) {
147
+ return function writeHTMLToClipboard(_x2, _x3) {
136
148
  return _ref2.apply(this, arguments);
137
149
  };
138
150
  }();
139
151
 
140
- // At the time of development, Firefox doesn't support ClipboardItem API
141
- // Hence of use of this polyfill
142
152
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
143
- export var copyHTMLToClipboardPolyfill = /*#__PURE__*/function () {
153
+ export var copyHTMLToClipboard = function copyHTMLToClipboard(elementToCopy, plainTextToCopy) {
154
+ return markRejectionHandled(writeHTMLToClipboard(elementToCopy, plainTextToCopy));
155
+ };
156
+ var writeHTMLToClipboardPolyfill = /*#__PURE__*/function () {
144
157
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(elementToCopy, plainTextToCopy) {
145
158
  var dt;
146
159
  return _regeneratorRuntime.wrap(function (_context3) {
@@ -162,11 +175,18 @@ export var copyHTMLToClipboardPolyfill = /*#__PURE__*/function () {
162
175
  }
163
176
  }, _callee3);
164
177
  }));
165
- return function copyHTMLToClipboardPolyfill(_x4, _x5) {
178
+ return function writeHTMLToClipboardPolyfill(_x4, _x5) {
166
179
  return _ref3.apply(this, arguments);
167
180
  };
168
181
  }();
169
182
 
183
+ // At the time of development, Firefox doesn't support ClipboardItem API
184
+ // Hence of use of this polyfill
185
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
186
+ export var copyHTMLToClipboardPolyfill = function copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy) {
187
+ return markRejectionHandled(writeHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy));
188
+ };
189
+
170
190
  // Safari can revoke transient user activation before asynchronous clipboard writes complete.
171
191
  // Keep this helper synchronous so callers can invoke it directly from a click handler.
172
192
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
@@ -17,6 +17,7 @@ import ReactNodeView from '../react-node-view';
17
17
  import { Extension } from './Extension';
18
18
  import { ExtensionNodeWrapper } from './ExtensionNodeWrapper';
19
19
  import { isNativeEmbedExtension } from './nativeEmbedExtension';
20
+ import { preserveRemixNodeView } from './preserveRemixNodeView';
20
21
  /**
21
22
  * Allowlists of extension keys + layout
22
23
  * Currently, only toc with default layout allows to skip React render.
@@ -378,7 +379,7 @@ function ExtensionNodeRender(_ref2) {
378
379
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
379
380
  export default function ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionLoadingHandlers, extensionNodeViewOptions, pluginInjectionApi, macroInteractionDesignFeatureFlags, showLivePagesBodiedMacrosRendererView, showUpdatedLivePages1PBodiedExtensionUI, rendererExtensionHandlers, intl) {
380
381
  return function (node, view, getPos) {
381
- return new ExtensionNode(node, view, getPos, portalProviderAPI, eventDispatcher, {
382
+ var renderProps = {
382
383
  providerFactory: providerFactory,
383
384
  extensionHandlers: extensionHandlers,
384
385
  extensionLoadingHandlers: extensionLoadingHandlers,
@@ -389,6 +390,20 @@ export default function ExtensionNodeView(portalProviderAPI, eventDispatcher, pr
389
390
  showUpdatedLivePages1PBodiedExtensionUI: showUpdatedLivePages1PBodiedExtensionUI,
390
391
  rendererExtensionHandlers: rendererExtensionHandlers,
391
392
  intl: intl
392
- }).init();
393
+ };
394
+ var createExtensionNode = function createExtensionNode(currentNode) {
395
+ return new ExtensionNode(currentNode, view, getPos, portalProviderAPI, eventDispatcher, renderProps);
396
+ };
397
+ if (!isSSR() && fg('cc_maui_annotations_on_extensions')) {
398
+ return preserveRemixNodeView({
399
+ node: node,
400
+ view: view,
401
+ getPos: getPos,
402
+ renderProps: renderProps,
403
+ rendererKind: ExtensionNode,
404
+ createExtensionNode: createExtensionNode
405
+ });
406
+ }
407
+ return createExtensionNode(node).init();
393
408
  };
394
409
  }