@atlaskit/editor-common 134.10.1 → 134.11.1

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 (46) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/afm-products/tsconfig.json +3 -0
  3. package/credit-guard/package.json +10 -0
  4. package/dist/cjs/credit-guard/CreditCheckedPopup.compiled.css +7 -0
  5. package/dist/cjs/credit-guard/CreditCheckedPopup.js +195 -0
  6. package/dist/cjs/credit-guard/checkAICreditStatus.js +25 -0
  7. package/dist/cjs/credit-guard/index.js +26 -0
  8. package/dist/cjs/credit-guard/types.js +5 -0
  9. package/dist/cjs/credit-guard/useAICreditGuard.js +51 -0
  10. package/dist/cjs/element-browser/components/ElementList/ElementList.js +67 -14
  11. package/dist/cjs/element-browser/components/StatelessElementBrowser.js +19 -5
  12. package/dist/cjs/monitoring/error.js +1 -1
  13. package/dist/cjs/quick-insert/insert-menu-check.js +15 -0
  14. package/dist/cjs/ui/DropList/index.js +1 -1
  15. package/dist/es2019/credit-guard/CreditCheckedPopup.compiled.css +7 -0
  16. package/dist/es2019/credit-guard/CreditCheckedPopup.js +174 -0
  17. package/dist/es2019/credit-guard/checkAICreditStatus.js +19 -0
  18. package/dist/es2019/credit-guard/index.js +5 -0
  19. package/dist/es2019/credit-guard/types.js +1 -0
  20. package/dist/es2019/credit-guard/useAICreditGuard.js +33 -0
  21. package/dist/es2019/element-browser/components/ElementList/ElementList.js +58 -6
  22. package/dist/es2019/element-browser/components/StatelessElementBrowser.js +19 -5
  23. package/dist/es2019/monitoring/error.js +1 -1
  24. package/dist/es2019/quick-insert/insert-menu-check.js +9 -0
  25. package/dist/es2019/ui/DropList/index.js +1 -1
  26. package/dist/esm/credit-guard/CreditCheckedPopup.compiled.css +7 -0
  27. package/dist/esm/credit-guard/CreditCheckedPopup.js +186 -0
  28. package/dist/esm/credit-guard/checkAICreditStatus.js +19 -0
  29. package/dist/esm/credit-guard/index.js +5 -0
  30. package/dist/esm/credit-guard/types.js +1 -0
  31. package/dist/esm/credit-guard/useAICreditGuard.js +44 -0
  32. package/dist/esm/element-browser/components/ElementList/ElementList.js +67 -14
  33. package/dist/esm/element-browser/components/StatelessElementBrowser.js +19 -5
  34. package/dist/esm/monitoring/error.js +1 -1
  35. package/dist/esm/quick-insert/insert-menu-check.js +9 -0
  36. package/dist/esm/ui/DropList/index.js +1 -1
  37. package/dist/types/credit-guard/CreditCheckedPopup.d.ts +34 -0
  38. package/dist/types/credit-guard/checkAICreditStatus.d.ts +3 -0
  39. package/dist/types/credit-guard/index.d.ts +6 -0
  40. package/dist/types/credit-guard/types.d.ts +13 -0
  41. package/dist/types/credit-guard/useAICreditGuard.d.ts +16 -0
  42. package/dist/types/element-browser/components/ElementList/ElementList.d.ts +1 -0
  43. package/dist/types/provider-factory/quick-insert-provider.d.ts +26 -0
  44. package/dist/types/quick-insert/insert-menu-check.d.ts +5 -0
  45. package/package.json +3 -2
  46. package/quick-insert/insert-menu-check/package.json +10 -0
@@ -0,0 +1,44 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { useCallback, useLayoutEffect, useState } from 'react';
3
+ import { checkAICreditStatus } from './checkAICreditStatus';
4
+ /** Shares advisory checks and feedback state without owning action execution or selection. */
5
+ export var useAICreditGuard = function useAICreditGuard(getAICreditStatus) {
6
+ var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
7
+ var _useState = useState(null),
8
+ _useState2 = _slicedToArray(_useState, 2),
9
+ feedback = _useState2[0],
10
+ setFeedback = _useState2[1];
11
+ var _useState3 = useState(false),
12
+ _useState4 = _slicedToArray(_useState3, 2),
13
+ isBlocked = _useState4[0],
14
+ setIsBlocked = _useState4[1];
15
+ var close = useCallback(function () {
16
+ return setFeedback(null);
17
+ }, []);
18
+ useLayoutEffect(function () {
19
+ if (!isActive) {
20
+ close();
21
+ setIsBlocked(false);
22
+ }
23
+ }, [isActive, close]);
24
+ var check = useCallback(function (creditCheck) {
25
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
26
+ _ref$showFeedback = _ref.showFeedback,
27
+ showFeedback = _ref$showFeedback === void 0 ? true : _ref$showFeedback;
28
+ if (!isActive) {
29
+ return false;
30
+ }
31
+ var result = checkAICreditStatus(getAICreditStatus, creditCheck);
32
+ setIsBlocked(result.isBlocked);
33
+ if (showFeedback) {
34
+ setFeedback(result.isBlocked ? result : null);
35
+ }
36
+ return !result.isBlocked;
37
+ }, [getAICreditStatus, isActive]);
38
+ return {
39
+ check: check,
40
+ close: close,
41
+ feedback: feedback,
42
+ isBlocked: isBlocked
43
+ };
44
+ };
@@ -364,6 +364,7 @@ var ElementListMultipleColumns = function ElementListMultipleColumns(props) {
364
364
  var MemoizedElementItem = /*#__PURE__*/memo(ElementItem);
365
365
  MemoizedElementItem.displayName = 'MemoizedElementItem';
366
366
 
367
+ /** Render an insert item, optionally wrapped by its interaction policy. */
367
368
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
368
369
  export function ElementItem(_ref6) {
369
370
  var inlineMode = _ref6.inlineMode,
@@ -375,6 +376,7 @@ export function ElementItem(_ref6) {
375
376
  setFocusedItemIndex = _ref6.setFocusedItemIndex,
376
377
  role = _ref6.role;
377
378
  var ref = useFocus(focus);
379
+ var surface = inlineMode ? 'toolbar' : 'element-browser';
378
380
 
379
381
  /**
380
382
  * Note: props.onSelectItem(item) is not called here as the StatelessElementBrowser's
@@ -382,10 +384,17 @@ export function ElementItem(_ref6) {
382
384
  * This implementation was changed for keyboard/click selection to work with `onInsertItem`.
383
385
  */
384
386
  var onClick = useCallback(function (e) {
387
+ var _item$onBeforeSelect;
385
388
  e.preventDefault();
386
389
  e.stopPropagation();
387
390
  setFocusedItemIndex(index);
388
- switch (e.nativeEvent.detail) {
391
+ var detail = e.nativeEvent.detail;
392
+ if (((_item$onBeforeSelect = item.onBeforeSelect) === null || _item$onBeforeSelect === void 0 ? void 0 : _item$onBeforeSelect.call(item, {
393
+ surface: surface
394
+ })) === false) {
395
+ return;
396
+ }
397
+ switch (detail) {
389
398
  case 0:
390
399
  onInsertItem(item);
391
400
  break;
@@ -402,7 +411,48 @@ export function ElementItem(_ref6) {
402
411
  default:
403
412
  return;
404
413
  }
405
- }, [index, inlineMode, item, onInsertItem, setFocusedItemIndex]);
414
+ }, [index, inlineMode, item, onInsertItem, setFocusedItemIndex, surface]);
415
+ var renderItem = useCallback(function (triggerProps) {
416
+ return jsx(ElementItemButton, {
417
+ item: item,
418
+ index: index,
419
+ inlineMode: inlineMode,
420
+ selected: selected,
421
+ role: role,
422
+ onClick: onClick,
423
+ focusRef: ref,
424
+ triggerProps: triggerProps
425
+ });
426
+ }, [item, index, inlineMode, selected, role, onClick, ref]);
427
+ return item.renderMenuItemWrapper ? item.renderMenuItemWrapper({
428
+ isActive: focus || selected,
429
+ surface: surface,
430
+ renderItem: renderItem
431
+ }) : renderItem();
432
+ }
433
+ var ElementItemButton = function ElementItemButton(_ref7) {
434
+ var _triggerProps$isSelec;
435
+ var item = _ref7.item,
436
+ index = _ref7.index,
437
+ inlineMode = _ref7.inlineMode,
438
+ selected = _ref7.selected,
439
+ role = _ref7.role,
440
+ onClick = _ref7.onClick,
441
+ focusRef = _ref7.focusRef,
442
+ triggerProps = _ref7.triggerProps;
443
+ var popupRef = triggerProps === null || triggerProps === void 0 ? void 0 : triggerProps.ref;
444
+ var setTriggerRef = useCallback(function (element) {
445
+ Object.assign(focusRef, {
446
+ current: element
447
+ });
448
+ if (typeof popupRef === 'function') {
449
+ popupRef(element);
450
+ } else if (popupRef) {
451
+ Object.assign(popupRef, {
452
+ current: element
453
+ });
454
+ }
455
+ }, [focusRef, popupRef]);
406
456
  var icon = item.icon,
407
457
  title = item.title,
408
458
  description = item.description,
@@ -418,10 +468,13 @@ export function ElementItem(_ref6) {
418
468
  icon: icon,
419
469
  title: title
420
470
  }),
421
- isSelected: selected,
471
+ isSelected: (_triggerProps$isSelec = triggerProps === null || triggerProps === void 0 ? void 0 : triggerProps.isSelected) !== null && _triggerProps$isSelec !== void 0 ? _triggerProps$isSelec : selected,
472
+ "aria-controls": triggerProps === null || triggerProps === void 0 ? void 0 : triggerProps['aria-controls'],
422
473
  "aria-label": title,
423
- ref: ref,
424
- testId: "element-item-".concat(index),
474
+ ref: setTriggerRef,
475
+ testId: "element-item-".concat(index)
476
+ // Keep the search combobox's aria-activedescendant target stable.
477
+ ,
425
478
  id: "searched-item-".concat(index),
426
479
  isDisabled: isDisabled,
427
480
  role: role
@@ -438,7 +491,7 @@ export function ElementItem(_ref6) {
438
491
  isDisabled: isDisabled,
439
492
  lozenge: lozenge
440
493
  })));
441
- }
494
+ };
442
495
 
443
496
  /**
444
497
  * Inline mode should use the existing Align-items:center value.
@@ -446,18 +499,18 @@ export function ElementItem(_ref6) {
446
499
  var itemStyleOverrides = {
447
500
  alignItems: 'flex-start'
448
501
  };
449
- var ElementBefore = /*#__PURE__*/memo(function (_ref7) {
450
- var icon = _ref7.icon;
502
+ var ElementBefore = /*#__PURE__*/memo(function (_ref8) {
503
+ var icon = _ref8.icon;
451
504
  return jsx("div", {
452
505
  css: [itemIcon, itemIconStyle]
453
506
  }, icon ? icon() : jsx(IconFallback, null));
454
507
  });
455
- var ItemContent = /*#__PURE__*/memo(function (_ref8) {
456
- var title = _ref8.title,
457
- description = _ref8.description,
458
- keyshortcut = _ref8.keyshortcut,
459
- lozenge = _ref8.lozenge,
460
- isDisabled = _ref8.isDisabled;
508
+ var ItemContent = /*#__PURE__*/memo(function (_ref9) {
509
+ var title = _ref9.title,
510
+ description = _ref9.description,
511
+ keyshortcut = _ref9.keyshortcut,
512
+ lozenge = _ref9.lozenge,
513
+ isDisabled = _ref9.isDisabled;
461
514
  return (
462
515
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
463
516
  jsx("div", {
@@ -196,6 +196,7 @@ function StatelessElementBrowser(props) {
196
196
  /* Only for hitting enter to select item when focused on search bar,
197
197
  * The actual enter key press is handled on individual items level.
198
198
  */
199
+ var surface = props.mode === 'inline' ? 'toolbar' : 'element-browser';
199
200
  var selectedItem = selectedItemIndex !== undefined ? items[selectedItemIndex] : null;
200
201
  var onItemsEnterTabKeyPress = useCallback(function (e) {
201
202
  var _selectedItem$isDisab;
@@ -208,11 +209,16 @@ function StatelessElementBrowser(props) {
208
209
  e.preventDefault();
209
210
  return;
210
211
  }
212
+ e.preventDefault();
211
213
  if (onInsertItem && selectedItem != null && !((_selectedItem$isDisab = selectedItem.isDisabled) !== null && _selectedItem$isDisab !== void 0 ? _selectedItem$isDisab : false)) {
212
- onInsertItem(selectedItem);
214
+ var _selectedItem$onBefor;
215
+ if (((_selectedItem$onBefor = selectedItem.onBeforeSelect) === null || _selectedItem$onBefor === void 0 ? void 0 : _selectedItem$onBefor.call(selectedItem, {
216
+ surface: surface
217
+ })) !== false) {
218
+ onInsertItem(selectedItem);
219
+ }
213
220
  }
214
- e.preventDefault();
215
- }, [onInsertItem, selectedItem, setFocusedCategoryIndex, showCategories, selectedCategoryIndex]);
221
+ }, [onInsertItem, selectedItem, setFocusedCategoryIndex, showCategories, selectedCategoryIndex, surface]);
216
222
 
217
223
  /**
218
224
  * On arrow key selection and clicks the selectedItemIndex will change.
@@ -220,9 +226,17 @@ function StatelessElementBrowser(props) {
220
226
  */
221
227
  useEffect(function () {
222
228
  if (onSelectItem && selectedItem != null) {
223
- onSelectItem(selectedItem);
229
+ var _selectedItem$onBefor2;
230
+ // Highlighting is eligibility-only: arrows must never open a popup or take focus.
231
+ // eslint-disable-next-line @atlassian/perf-linting/no-chain-state-updates -- Synchronize silent eligibility with the product-supplied guard before notifying the parent selection.
232
+ if (((_selectedItem$onBefor2 = selectedItem.onBeforeSelect) === null || _selectedItem$onBefor2 === void 0 ? void 0 : _selectedItem$onBefor2.call(selectedItem, {
233
+ surface: surface,
234
+ showFeedback: false
235
+ })) !== false) {
236
+ onSelectItem(selectedItem);
237
+ }
224
238
  }
225
- }, [onSelectItem, selectedItem]);
239
+ }, [onSelectItem, selectedItem, surface, focusedItemIndex, selectedItemIndex]);
226
240
  var onSelectCategoryCB = useCallback(function (category) {
227
241
  onSelectCategory(category);
228
242
  categoryBeenChosen.current = true;
@@ -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 = "134.10.0";
22
+ var packageVersion = "134.11.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,9 @@
1
+ /**
2
+ * Compatibility helper for existing package consumers; Editor callers check item.onBeforeSelect directly.
3
+ */
4
+ export var runInsertMenuItemCheck = function runInsertMenuItemCheck(item, options, onAllowed) {
5
+ var _item$onBeforeSelect;
6
+ if (((_item$onBeforeSelect = item.onBeforeSelect) === null || _item$onBeforeSelect === void 0 ? void 0 : _item$onBeforeSelect.call(item, options)) !== false) {
7
+ onAllowed();
8
+ }
9
+ };
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
20
20
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import Layer from '../Layer';
22
22
  var packageName = "@atlaskit/editor-common";
23
- var packageVersion = "134.10.0";
23
+ var packageVersion = "134.11.0";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005
@@ -0,0 +1,34 @@
1
+ import React, { type ComponentProps } from 'react';
2
+ import { Popup } from '@atlaskit/popup/popup';
3
+ import type { AICreditCheck, GetAICreditStatus } from './types';
4
+ import { type AICreditGuard } from './useAICreditGuard';
5
+ type PopupProps = ComponentProps<typeof Popup>;
6
+ export type CreditPopupTriggerProps = Parameters<PopupProps['trigger']>[0] & {
7
+ id: string;
8
+ };
9
+ type ControlledCreditPopupProps = {
10
+ guard: Pick<AICreditGuard, 'feedback' | 'close'>;
11
+ /** Restore nested insert-menu search focus on Escape and use the Editor dialog layer. */
12
+ isNestedMenu?: boolean;
13
+ placement?: PopupProps['placement'];
14
+ renderTrigger: (props: CreditPopupTriggerProps) => React.ReactNode;
15
+ shouldRenderToParent?: boolean;
16
+ };
17
+ type TriggerEvent = React.MouseEvent | React.KeyboardEvent;
18
+ /** Props the trigger applies to anchor the popup and guard its native action. */
19
+ export type CreditCheckedTriggerProps = CreditPopupTriggerProps & {
20
+ 'aria-haspopup': 'dialog';
21
+ isSelected: boolean;
22
+ onClick: (event?: TriggerEvent) => void;
23
+ };
24
+ type CreditCheckedActionPopupProps = {
25
+ creditCheck: AICreditCheck;
26
+ getAICreditStatus: GetAICreditStatus;
27
+ onAllowed: (event?: TriggerEvent) => void;
28
+ placement: PopupProps['placement'];
29
+ renderTrigger: (props: CreditCheckedTriggerProps) => React.ReactNode;
30
+ };
31
+ export type CreditCheckedPopupProps = CreditCheckedActionPopupProps | ControlledCreditPopupProps;
32
+ /** Reuses the toolbar action contract; insert-menu adapters can supply an externally triggered guard. */
33
+ export declare const CreditCheckedPopup: (props: CreditCheckedPopupProps) => React.JSX.Element;
34
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { AICreditCheck, AICreditStatus, GetAICreditStatus } from './types';
2
+ /** Editor consumes cached decisions synchronously; legacy async providers fail open. */
3
+ export declare const checkAICreditStatus: (getAICreditStatus: GetAICreditStatus, creditCheck: AICreditCheck) => AICreditStatus;
@@ -0,0 +1,6 @@
1
+ export { CreditCheckedPopup } from './CreditCheckedPopup';
2
+ export type { CreditCheckedPopupProps, CreditCheckedTriggerProps, CreditPopupTriggerProps, } from './CreditCheckedPopup';
3
+ export { useAICreditGuard } from './useAICreditGuard';
4
+ export { checkAICreditStatus } from './checkAICreditStatus';
5
+ export type { AICreditGuard } from './useAICreditGuard';
6
+ export type { AICreditCheck, AICreditStatus, GetAICreditStatus } from './types';
@@ -0,0 +1,13 @@
1
+ import type { ReactNode } from 'react';
2
+ export type EditorAICreditFeatureName = 'blockMenu-askRovo' | 'selectionToolbar-askRovo' | 'selectionToolbar-remix' | 'commentEditor-askRovo' | 'quickInsert-askRovo' | 'elementBrowser-askRovo' | 'panelFloatingToolbar-remix' | 'primaryToolbar-write' | 'mediaFloatingToolbar-editImage' | 'tableFloatingToolbar-remix' | 'smartLinkFloatingToolbar-askRovo' | 'codeBlockFloatingToolbar-remix' | 'imageGenerationMediaInsert';
3
+ export type AICreditCheck = {
4
+ featureName: EditorAICreditFeatureName;
5
+ };
6
+ export type AICreditStatus = {
7
+ isBlocked: false;
8
+ } | {
9
+ isBlocked: true;
10
+ renderCustomContent: () => ReactNode;
11
+ };
12
+ /** Supply a synchronous cached decision. Promise typing remains temporarily for legacy consumers. */
13
+ export type GetAICreditStatus = (context: AICreditCheck) => AICreditStatus | Promise<AICreditStatus>;
@@ -0,0 +1,16 @@
1
+ import type { AICreditCheck, AICreditStatus, GetAICreditStatus } from './types';
2
+ type CreditStatus = AICreditStatus;
3
+ export type BlockedCreditStatus = Extract<CreditStatus, {
4
+ isBlocked: true;
5
+ }>;
6
+ export type AICreditGuard = {
7
+ check: (creditCheck: AICreditCheck, options?: {
8
+ showFeedback?: boolean;
9
+ }) => boolean;
10
+ close: () => void;
11
+ feedback: BlockedCreditStatus | null;
12
+ isBlocked: boolean;
13
+ };
14
+ /** Shares advisory checks and feedback state without owning action execution or selection. */
15
+ export declare const useAICreditGuard: (getAICreditStatus: GetAICreditStatus, isActive?: boolean) => AICreditGuard;
16
+ export {};
@@ -41,6 +41,7 @@ type ElementItemType = {
41
41
  selected: boolean;
42
42
  setFocusedItemIndex: (index: number) => void;
43
43
  };
44
+ /** Render an insert item, optionally wrapped by its interaction policy. */
44
45
  export declare function ElementItem({ inlineMode, selected, item, index, onInsertItem, focus, setFocusedItemIndex, role, }: ElementItemType): jsx.JSX.Element;
45
46
  declare const MemoizedElementListWithAnalytics: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<Props & SelectedItemProps & WithAnalyticsEventsProps & WithContextProps, 'ref'> & React.RefAttributes<unknown>>>;
46
47
  export default MemoizedElementListWithAnalytics;
@@ -1,3 +1,4 @@
1
+ import type { ReactElement, Ref } from 'react';
1
2
  import type { Node } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
4
  import type { RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
@@ -9,6 +10,20 @@ export type QuickInsertActionInsert = (node?: Node | Record<string, any> | strin
9
10
  selectInlineNode?: boolean;
10
11
  }) => Transaction;
11
12
  export type QuickInsertItemId = 'hyperlink' | 'table' | 'helpdialog' | 'date' | 'media' | 'media-insert' | 'blockquote' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'codeblock' | 'unorderedList' | 'feedbackdialog' | 'orderedList' | 'rule' | 'status' | 'mention' | 'emoji' | 'action' | 'decision' | 'infopanel' | 'notepanel' | 'successpanel' | 'warningpanel' | 'errorpanel' | 'custompanel' | 'layout' | 'expand' | 'placeholderText' | 'datasource' | 'loom' | 'onecolumnlayout' | 'twocolumnslayout' | 'threecolumnslayout' | 'fourcolumnslayout' | 'fivecolumnslayout' | 'syncBlock' | 'aiSpeechToText' | 'aiImageGeneration';
13
+ /** Insert-menu hosts keep interaction policy outside of the shared Editor packages. */
14
+ export type InsertMenuSurface = 'toolbar' | 'element-browser';
15
+ export type InsertMenuItemTriggerProps = {
16
+ 'aria-controls'?: string;
17
+ id?: string;
18
+ /** Override insertion-selection appearance without changing keyboard focus. */
19
+ isSelected?: boolean;
20
+ ref?: Ref<HTMLElement>;
21
+ };
22
+ export type InsertMenuItemWrapperProps = {
23
+ isActive: boolean;
24
+ renderItem: (triggerProps?: InsertMenuItemTriggerProps) => ReactElement;
25
+ surface: InsertMenuSurface;
26
+ };
12
27
  export type QuickInsertItem = TypeAheadItem & {
13
28
  /**
14
29
  * What to do on insert
@@ -35,8 +50,19 @@ export type QuickInsertItem = TypeAheadItem & {
35
50
  isHidden?: () => boolean;
36
51
  /** other names used to find the item */
37
52
  keywords?: Array<string>;
53
+ /**
54
+ * Return false to retain the menu without selecting/inserting this item.
55
+ * With showFeedback=false this must not open feedback or move focus.
56
+ * Decisions must be synchronous so actions run in their original event handler.
57
+ */
58
+ onBeforeSelect?: (options: {
59
+ showFeedback?: boolean;
60
+ surface: InsertMenuSurface;
61
+ }) => boolean;
38
62
  /** Optional visual and attribution content shown while this item is selected. */
39
63
  preview?: QuickInsertPreview;
64
+ /** Optional wrapper; trigger bindings must be forwarded to the actual menu control. */
65
+ renderMenuItemWrapper?: (props: InsertMenuItemWrapperProps) => ReactElement;
40
66
  };
41
67
  export type QuickInsertProvider = {
42
68
  /** Registered leaf items for the Quick Insert browse menu. */
@@ -0,0 +1,5 @@
1
+ import type { QuickInsertItem } from '../provider-factory/quick-insert-provider';
2
+ /**
3
+ * Compatibility helper for existing package consumers; Editor callers check item.onBeforeSelect directly.
4
+ */
5
+ export declare const runInsertMenuItemCheck: (item: QuickInsertItem, options: Parameters<NonNullable<QuickInsertItem['onBeforeSelect']>>[0], onAllowed: () => void) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "134.10.1",
3
+ "version": "134.11.1",
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/"
@@ -73,6 +73,7 @@
73
73
  "@atlaskit/platform-feature-flags": "^2.2.0",
74
74
  "@atlaskit/platform-feature-flags-react": "^1.2.0",
75
75
  "@atlaskit/popper": "^9.4.0",
76
+ "@atlaskit/popup": "^10.2.0",
76
77
  "@atlaskit/primitives": "^22.7.0",
77
78
  "@atlaskit/profilecard": "^27.6.0",
78
79
  "@atlaskit/prosemirror-history": "^1.3.0",
@@ -86,7 +87,7 @@
86
87
  "@atlaskit/teams-app-config": "^3.1.0",
87
88
  "@atlaskit/textfield": "^10.3.0",
88
89
  "@atlaskit/tmp-editor-statsig": "^260.0.0",
89
- "@atlaskit/tokens": "^20.10.0",
90
+ "@atlaskit/tokens": "^20.11.0",
90
91
  "@atlaskit/tooltip": "^24.4.0",
91
92
  "@atlaskit/width-detector": "^7.2.0",
92
93
  "@babel/runtime": "^7.0.0",
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/quick-insert/insert-menu-check",
3
+ "main": "../../dist/cjs/quick-insert/insert-menu-check.js",
4
+ "module": "../../dist/esm/quick-insert/insert-menu-check.js",
5
+ "module:es2019": "../../dist/es2019/quick-insert/insert-menu-check.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../../dist/types/quick-insert/insert-menu-check.d.ts"
10
+ }