@atlaskit/editor-common 134.10.1 → 134.11.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.
- package/CHANGELOG.md +25 -0
- package/credit-guard/package.json +10 -0
- package/dist/cjs/credit-guard/CreditCheckedPopup.compiled.css +3 -0
- package/dist/cjs/credit-guard/CreditCheckedPopup.js +182 -0
- package/dist/cjs/credit-guard/checkAICreditStatus.js +25 -0
- package/dist/cjs/credit-guard/index.js +26 -0
- package/dist/cjs/credit-guard/types.js +5 -0
- package/dist/cjs/credit-guard/useAICreditGuard.js +45 -0
- package/dist/cjs/element-browser/components/ElementList/ElementList.js +80 -28
- package/dist/cjs/element-browser/components/StatelessElementBrowser.js +17 -5
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/quick-insert/insert-menu-check.js +11 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/credit-guard/CreditCheckedPopup.compiled.css +3 -0
- package/dist/es2019/credit-guard/CreditCheckedPopup.js +161 -0
- package/dist/es2019/credit-guard/checkAICreditStatus.js +19 -0
- package/dist/es2019/credit-guard/index.js +5 -0
- package/dist/es2019/credit-guard/types.js +1 -0
- package/dist/es2019/credit-guard/useAICreditGuard.js +27 -0
- package/dist/es2019/element-browser/components/ElementList/ElementList.js +71 -20
- package/dist/es2019/element-browser/components/StatelessElementBrowser.js +13 -5
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/quick-insert/insert-menu-check.js +5 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/credit-guard/CreditCheckedPopup.compiled.css +3 -0
- package/dist/esm/credit-guard/CreditCheckedPopup.js +173 -0
- package/dist/esm/credit-guard/checkAICreditStatus.js +19 -0
- package/dist/esm/credit-guard/index.js +5 -0
- package/dist/esm/credit-guard/types.js +1 -0
- package/dist/esm/credit-guard/useAICreditGuard.js +38 -0
- package/dist/esm/element-browser/components/ElementList/ElementList.js +80 -28
- package/dist/esm/element-browser/components/StatelessElementBrowser.js +17 -5
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/quick-insert/insert-menu-check.js +5 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/credit-guard/CreditCheckedPopup.d.ts +34 -0
- package/dist/types/credit-guard/checkAICreditStatus.d.ts +3 -0
- package/dist/types/credit-guard/index.d.ts +6 -0
- package/dist/types/credit-guard/types.d.ts +13 -0
- package/dist/types/credit-guard/useAICreditGuard.d.ts +16 -0
- package/dist/types/element-browser/components/ElementList/ElementList.d.ts +1 -0
- package/dist/types/provider-factory/quick-insert-provider.d.ts +26 -0
- package/dist/types/quick-insert/insert-menu-check.d.ts +3 -0
- package/package.json +2 -1
- package/quick-insert/insert-menu-check/package.json +10 -0
|
@@ -24,6 +24,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
24
24
|
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
25
25
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '../../../analytics';
|
|
26
26
|
import { IconFallback } from '../../../quick-insert';
|
|
27
|
+
import { runInsertMenuItemCheck } from '../../../quick-insert/insert-menu-check';
|
|
27
28
|
import { ELEMENT_ITEM_HEIGHT, ELEMENT_ITEM_PADDING, ELEMENT_LIST_PADDING, SCROLLBAR_WIDTH } from '../../constants';
|
|
28
29
|
import useContainerWidth from '../../hooks/use-container-width';
|
|
29
30
|
import useFocus from '../../hooks/use-focus';
|
|
@@ -364,6 +365,7 @@ var ElementListMultipleColumns = function ElementListMultipleColumns(props) {
|
|
|
364
365
|
var MemoizedElementItem = /*#__PURE__*/memo(ElementItem);
|
|
365
366
|
MemoizedElementItem.displayName = 'MemoizedElementItem';
|
|
366
367
|
|
|
368
|
+
/** Render an insert item, optionally wrapped by its interaction policy. */
|
|
367
369
|
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
368
370
|
export function ElementItem(_ref6) {
|
|
369
371
|
var inlineMode = _ref6.inlineMode,
|
|
@@ -375,6 +377,7 @@ export function ElementItem(_ref6) {
|
|
|
375
377
|
setFocusedItemIndex = _ref6.setFocusedItemIndex,
|
|
376
378
|
role = _ref6.role;
|
|
377
379
|
var ref = useFocus(focus);
|
|
380
|
+
var surface = inlineMode ? 'toolbar' : 'element-browser';
|
|
378
381
|
|
|
379
382
|
/**
|
|
380
383
|
* Note: props.onSelectItem(item) is not called here as the StatelessElementBrowser's
|
|
@@ -385,24 +388,70 @@ export function ElementItem(_ref6) {
|
|
|
385
388
|
e.preventDefault();
|
|
386
389
|
e.stopPropagation();
|
|
387
390
|
setFocusedItemIndex(index);
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
391
|
+
var detail = e.nativeEvent.detail;
|
|
392
|
+
runInsertMenuItemCheck(item, {
|
|
393
|
+
surface: surface
|
|
394
|
+
}, function () {
|
|
395
|
+
switch (detail) {
|
|
396
|
+
case 0:
|
|
394
397
|
onInsertItem(item);
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
398
|
+
break;
|
|
399
|
+
case 1:
|
|
400
|
+
if (inlineMode) {
|
|
401
|
+
onInsertItem(item);
|
|
402
|
+
}
|
|
403
|
+
break;
|
|
404
|
+
case 2:
|
|
405
|
+
if (!inlineMode) {
|
|
406
|
+
onInsertItem(item);
|
|
407
|
+
}
|
|
408
|
+
break;
|
|
409
|
+
default:
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
}, [index, inlineMode, item, onInsertItem, setFocusedItemIndex, surface]);
|
|
414
|
+
var renderItem = useCallback(function (triggerProps) {
|
|
415
|
+
return jsx(ElementItemButton, {
|
|
416
|
+
item: item,
|
|
417
|
+
index: index,
|
|
418
|
+
inlineMode: inlineMode,
|
|
419
|
+
selected: selected,
|
|
420
|
+
role: role,
|
|
421
|
+
onClick: onClick,
|
|
422
|
+
focusRef: ref,
|
|
423
|
+
triggerProps: triggerProps
|
|
424
|
+
});
|
|
425
|
+
}, [item, index, inlineMode, selected, role, onClick, ref]);
|
|
426
|
+
return item.renderMenuItemWrapper ? item.renderMenuItemWrapper({
|
|
427
|
+
isActive: focus || selected,
|
|
428
|
+
surface: surface,
|
|
429
|
+
renderItem: renderItem
|
|
430
|
+
}) : renderItem();
|
|
431
|
+
}
|
|
432
|
+
var ElementItemButton = function ElementItemButton(_ref7) {
|
|
433
|
+
var _triggerProps$isSelec;
|
|
434
|
+
var item = _ref7.item,
|
|
435
|
+
index = _ref7.index,
|
|
436
|
+
inlineMode = _ref7.inlineMode,
|
|
437
|
+
selected = _ref7.selected,
|
|
438
|
+
role = _ref7.role,
|
|
439
|
+
onClick = _ref7.onClick,
|
|
440
|
+
focusRef = _ref7.focusRef,
|
|
441
|
+
triggerProps = _ref7.triggerProps;
|
|
442
|
+
var popupRef = triggerProps === null || triggerProps === void 0 ? void 0 : triggerProps.ref;
|
|
443
|
+
var setTriggerRef = useCallback(function (element) {
|
|
444
|
+
Object.assign(focusRef, {
|
|
445
|
+
current: element
|
|
446
|
+
});
|
|
447
|
+
if (typeof popupRef === 'function') {
|
|
448
|
+
popupRef(element);
|
|
449
|
+
} else if (popupRef) {
|
|
450
|
+
Object.assign(popupRef, {
|
|
451
|
+
current: element
|
|
452
|
+
});
|
|
404
453
|
}
|
|
405
|
-
}, [
|
|
454
|
+
}, [focusRef, popupRef]);
|
|
406
455
|
var icon = item.icon,
|
|
407
456
|
title = item.title,
|
|
408
457
|
description = item.description,
|
|
@@ -418,10 +467,13 @@ export function ElementItem(_ref6) {
|
|
|
418
467
|
icon: icon,
|
|
419
468
|
title: title
|
|
420
469
|
}),
|
|
421
|
-
isSelected: selected,
|
|
470
|
+
isSelected: (_triggerProps$isSelec = triggerProps === null || triggerProps === void 0 ? void 0 : triggerProps.isSelected) !== null && _triggerProps$isSelec !== void 0 ? _triggerProps$isSelec : selected,
|
|
471
|
+
"aria-controls": triggerProps === null || triggerProps === void 0 ? void 0 : triggerProps['aria-controls'],
|
|
422
472
|
"aria-label": title,
|
|
423
|
-
ref:
|
|
424
|
-
testId: "element-item-".concat(index)
|
|
473
|
+
ref: setTriggerRef,
|
|
474
|
+
testId: "element-item-".concat(index)
|
|
475
|
+
// Keep the search combobox's aria-activedescendant target stable.
|
|
476
|
+
,
|
|
425
477
|
id: "searched-item-".concat(index),
|
|
426
478
|
isDisabled: isDisabled,
|
|
427
479
|
role: role
|
|
@@ -438,7 +490,7 @@ export function ElementItem(_ref6) {
|
|
|
438
490
|
isDisabled: isDisabled,
|
|
439
491
|
lozenge: lozenge
|
|
440
492
|
})));
|
|
441
|
-
}
|
|
493
|
+
};
|
|
442
494
|
|
|
443
495
|
/**
|
|
444
496
|
* Inline mode should use the existing Align-items:center value.
|
|
@@ -446,18 +498,18 @@ export function ElementItem(_ref6) {
|
|
|
446
498
|
var itemStyleOverrides = {
|
|
447
499
|
alignItems: 'flex-start'
|
|
448
500
|
};
|
|
449
|
-
var ElementBefore = /*#__PURE__*/memo(function (
|
|
450
|
-
var icon =
|
|
501
|
+
var ElementBefore = /*#__PURE__*/memo(function (_ref8) {
|
|
502
|
+
var icon = _ref8.icon;
|
|
451
503
|
return jsx("div", {
|
|
452
504
|
css: [itemIcon, itemIconStyle]
|
|
453
505
|
}, icon ? icon() : jsx(IconFallback, null));
|
|
454
506
|
});
|
|
455
|
-
var ItemContent = /*#__PURE__*/memo(function (
|
|
456
|
-
var title =
|
|
457
|
-
description =
|
|
458
|
-
keyshortcut =
|
|
459
|
-
lozenge =
|
|
460
|
-
isDisabled =
|
|
507
|
+
var ItemContent = /*#__PURE__*/memo(function (_ref9) {
|
|
508
|
+
var title = _ref9.title,
|
|
509
|
+
description = _ref9.description,
|
|
510
|
+
keyshortcut = _ref9.keyshortcut,
|
|
511
|
+
lozenge = _ref9.lozenge,
|
|
512
|
+
isDisabled = _ref9.isDisabled;
|
|
461
513
|
return (
|
|
462
514
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
463
515
|
jsx("div", {
|
|
@@ -13,6 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
13
13
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
14
14
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
15
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '../../analytics';
|
|
16
|
+
import { runInsertMenuItemCheck } from '../../quick-insert/insert-menu-check';
|
|
16
17
|
import editorUGCToken from '../../ugc-tokens/get-editor-ugc-token';
|
|
17
18
|
import { ViewMore } from '../components/ViewMore';
|
|
18
19
|
import { DEVICE_BREAKPOINT_NUMBERS, ELEMENT_BROWSER_ID, ELEMENT_BROWSER_LIST_ID, GRID_SIZE, INLINE_SIDEBAR_HEIGHT, SIDEBAR_HEADING_WRAPPER_HEIGHT, SIDEBAR_WIDTH } from '../constants';
|
|
@@ -196,6 +197,7 @@ function StatelessElementBrowser(props) {
|
|
|
196
197
|
/* Only for hitting enter to select item when focused on search bar,
|
|
197
198
|
* The actual enter key press is handled on individual items level.
|
|
198
199
|
*/
|
|
200
|
+
var surface = props.mode === 'inline' ? 'toolbar' : 'element-browser';
|
|
199
201
|
var selectedItem = selectedItemIndex !== undefined ? items[selectedItemIndex] : null;
|
|
200
202
|
var onItemsEnterTabKeyPress = useCallback(function (e) {
|
|
201
203
|
var _selectedItem$isDisab;
|
|
@@ -208,11 +210,15 @@ function StatelessElementBrowser(props) {
|
|
|
208
210
|
e.preventDefault();
|
|
209
211
|
return;
|
|
210
212
|
}
|
|
213
|
+
e.preventDefault();
|
|
211
214
|
if (onInsertItem && selectedItem != null && !((_selectedItem$isDisab = selectedItem.isDisabled) !== null && _selectedItem$isDisab !== void 0 ? _selectedItem$isDisab : false)) {
|
|
212
|
-
|
|
215
|
+
runInsertMenuItemCheck(selectedItem, {
|
|
216
|
+
surface: surface
|
|
217
|
+
}, function () {
|
|
218
|
+
return onInsertItem(selectedItem);
|
|
219
|
+
});
|
|
213
220
|
}
|
|
214
|
-
|
|
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,15 @@ function StatelessElementBrowser(props) {
|
|
|
220
226
|
*/
|
|
221
227
|
useEffect(function () {
|
|
222
228
|
if (onSelectItem && selectedItem != null) {
|
|
223
|
-
|
|
229
|
+
// Highlighting is eligibility-only: arrows must never open a popup or take focus.
|
|
230
|
+
runInsertMenuItemCheck(selectedItem, {
|
|
231
|
+
surface: surface,
|
|
232
|
+
showFeedback: false
|
|
233
|
+
}, function () {
|
|
234
|
+
return onSelectItem(selectedItem);
|
|
235
|
+
});
|
|
224
236
|
}
|
|
225
|
-
}, [onSelectItem, selectedItem]);
|
|
237
|
+
}, [onSelectItem, selectedItem, surface, focusedItemIndex, selectedItemIndex]);
|
|
226
238
|
var onSelectCategoryCB = useCallback(function (category) {
|
|
227
239
|
onSelectCategory(category);
|
|
228
240
|
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.
|
|
22
|
+
var packageVersion = "134.10.1";
|
|
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,5 @@
|
|
|
1
|
+
/** Check eligibility before selecting or inserting in the original event handler. */
|
|
2
|
+
export var runInsertMenuItemCheck = function runInsertMenuItemCheck(item, options, onAllowed) {
|
|
3
|
+
var _item$onBeforeSelect;
|
|
4
|
+
if (((_item$onBeforeSelect = item.onBeforeSelect) === null || _item$onBeforeSelect === void 0 ? void 0 : _item$onBeforeSelect.call(item, options)) !== false) onAllowed();
|
|
5
|
+
};
|
|
@@ -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.
|
|
23
|
+
var packageVersion = "134.10.1";
|
|
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,3 @@
|
|
|
1
|
+
import type { QuickInsertItem } from '../provider-factory/quick-insert-provider';
|
|
2
|
+
/** Check eligibility before selecting or inserting in the original event handler. */
|
|
3
|
+
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.
|
|
3
|
+
"version": "134.11.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/"
|
|
@@ -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",
|
|
@@ -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
|
+
}
|