@atlaskit/editor-common 134.20.1 → 135.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 (60) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/cjs/ai-messages/ai-suggestions.js +1 -1
  3. package/dist/cjs/credit-guard/CreditCheckedPopup.js +69 -15
  4. package/dist/cjs/element-browser/components/ElementBrowserLoader.js +25 -21
  5. package/dist/cjs/extensibility/ExtensionComponent.js +2 -1
  6. package/dist/cjs/extensions/extension-handlers.js +10 -44
  7. package/dist/cjs/monitoring/error.js +1 -1
  8. package/dist/cjs/numbered-headings/create-heading-numberer.js +37 -0
  9. package/dist/cjs/numbered-headings/index.js +5 -19
  10. package/dist/cjs/quick-insert/CompactQuickInsertMenuItem.js +16 -2
  11. package/dist/cjs/quick-insert/ElementBrowserQuickInsertMenuItem.js +15 -1
  12. package/dist/cjs/quick-insert/QuickInsertMenuItem.js +9 -0
  13. package/dist/cjs/quick-insert/quickInsertMenuItemUtils.js +6 -3
  14. package/dist/cjs/toolbar/EditorToolbarUIProvider.js +18 -0
  15. package/dist/cjs/ui/DropList/index.js +1 -1
  16. package/dist/cjs/ui/ErrorBoundary/index.js +6 -9
  17. package/dist/cjs/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +16 -3
  18. package/dist/es2019/ai-messages/ai-suggestions.js +1 -1
  19. package/dist/es2019/credit-guard/CreditCheckedPopup.js +66 -16
  20. package/dist/es2019/element-browser/components/ElementBrowserLoader.js +20 -14
  21. package/dist/es2019/extensibility/ExtensionComponent.js +2 -1
  22. package/dist/es2019/extensions/extension-handlers.js +6 -23
  23. package/dist/es2019/monitoring/error.js +1 -1
  24. package/dist/es2019/numbered-headings/create-heading-numberer.js +31 -0
  25. package/dist/es2019/numbered-headings/index.js +4 -19
  26. package/dist/es2019/quick-insert/CompactQuickInsertMenuItem.js +17 -3
  27. package/dist/es2019/quick-insert/ElementBrowserQuickInsertMenuItem.js +16 -2
  28. package/dist/es2019/quick-insert/QuickInsertMenuItem.js +9 -0
  29. package/dist/es2019/quick-insert/quickInsertMenuItemUtils.js +11 -6
  30. package/dist/es2019/toolbar/EditorToolbarUIProvider.js +16 -0
  31. package/dist/es2019/ui/DropList/index.js +1 -1
  32. package/dist/es2019/ui/ErrorBoundary/index.js +10 -7
  33. package/dist/es2019/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +16 -3
  34. package/dist/esm/ai-messages/ai-suggestions.js +1 -1
  35. package/dist/esm/credit-guard/CreditCheckedPopup.js +70 -16
  36. package/dist/esm/element-browser/components/ElementBrowserLoader.js +25 -19
  37. package/dist/esm/extensibility/ExtensionComponent.js +2 -1
  38. package/dist/esm/extensions/extension-handlers.js +8 -44
  39. package/dist/esm/monitoring/error.js +1 -1
  40. package/dist/esm/numbered-headings/create-heading-numberer.js +31 -0
  41. package/dist/esm/numbered-headings/index.js +5 -18
  42. package/dist/esm/quick-insert/CompactQuickInsertMenuItem.js +17 -3
  43. package/dist/esm/quick-insert/ElementBrowserQuickInsertMenuItem.js +16 -2
  44. package/dist/esm/quick-insert/QuickInsertMenuItem.js +9 -0
  45. package/dist/esm/quick-insert/quickInsertMenuItemUtils.js +6 -3
  46. package/dist/esm/toolbar/EditorToolbarUIProvider.js +18 -0
  47. package/dist/esm/ui/DropList/index.js +1 -1
  48. package/dist/esm/ui/ErrorBoundary/index.js +6 -9
  49. package/dist/esm/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +16 -3
  50. package/dist/types/analytics/types/events.d.ts +1 -1
  51. package/dist/types/extensions/extension-handlers.d.ts +2 -1
  52. package/dist/types/numbered-headings/create-heading-numberer.d.ts +14 -0
  53. package/dist/types/numbered-headings/index.d.ts +1 -4
  54. package/dist/types/quick-insert/CompactQuickInsertMenuItem.d.ts +1 -1
  55. package/dist/types/quick-insert/ElementBrowserQuickInsertMenuItem.d.ts +1 -1
  56. package/dist/types/quick-insert/QuickInsertMenuItem.d.ts +5 -1
  57. package/dist/types/quick-insert/quickInsertMenuItemUtils.d.ts +1 -1
  58. package/dist/types/ui/ErrorBoundary/index.d.ts +3 -6
  59. package/numbered-headings/create-heading-numberer/package.json +10 -0
  60. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  /* ElementBrowserQuickInsertMenuItem.tsx generated by @compiled/babel-plugin v3.0.4 */
2
2
  import "./ElementBrowserQuickInsertMenuItem.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
- import React, { useId, useMemo } from 'react';
4
+ import React, { useCallback, useId, useMemo } from 'react';
5
5
  /* eslint-disable @atlaskit/design-system/no-emotion-primitives -- Compiled primitives do not provide Pressable. */
6
6
  import { Box } from '@atlaskit/primitives/box';
7
7
  import { Pressable } from '@atlaskit/primitives/pressable';
@@ -103,10 +103,13 @@ var pinnedIconColorResetStyles = null;
103
103
  */
104
104
  export var ElementBrowserQuickInsertMenuItem = function ElementBrowserQuickInsertMenuItem(_ref) {
105
105
  var ariaLabel = _ref.ariaLabel,
106
+ ariaControls = _ref['aria-controls'],
107
+ itemRef = _ref.itemRef,
106
108
  description = _ref.description,
107
109
  iconBefore = _ref.iconBefore,
108
110
  _ref$isDisabled = _ref.isDisabled,
109
111
  isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
112
+ onBeforeSelect = _ref.onBeforeSelect,
110
113
  lozenge = _ref.lozenge,
111
114
  onSelect = _ref.onSelect,
112
115
  preview = _ref.preview,
@@ -123,7 +126,16 @@ export var ElementBrowserQuickInsertMenuItem = function ElementBrowserQuickInser
123
126
  id = _ref2.id,
124
127
  isSelected = _ref2.isSelected;
125
128
  var itemDescription = description !== null && description !== void 0 ? description : item === null || item === void 0 ? void 0 : item.description;
126
- var handleClick = useQuickInsertMenuItemSelection(onSelect);
129
+ var handleClick = useQuickInsertMenuItemSelection(onSelect, onBeforeSelect);
130
+ var setItemElement = useCallback(function (element) {
131
+ if (typeof itemRef === 'function') {
132
+ itemRef(element);
133
+ } else if (itemRef) {
134
+ Object.assign(itemRef, {
135
+ current: element
136
+ });
137
+ }
138
+ }, [itemRef]);
127
139
  var descriptionId = useId();
128
140
  var resolvedPreview = useMemo(function () {
129
141
  return preview !== null && preview !== void 0 ? preview : previewImageUrls ? {
@@ -135,6 +147,8 @@ export var ElementBrowserQuickInsertMenuItem = function ElementBrowserQuickInser
135
147
  className: ax(["_rpzpjdj5 _1pgcjdj5", !isDisabled && "_syaz1q3r"])
136
148
  }, iconBefore) : undefined;
137
149
  return /*#__PURE__*/React.createElement(Pressable, {
150
+ ref: setItemElement,
151
+ "aria-controls": ariaControls,
138
152
  "aria-describedby": hasDescription ? descriptionId : undefined,
139
153
  "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : title,
140
154
  "aria-selected": isSelected,
@@ -6,9 +6,12 @@ import { useQuickInsertContext } from './useQuickInsertContext';
6
6
  export var QuickInsertMenuItem = function QuickInsertMenuItem(_ref) {
7
7
  var _surfaceContext$get;
8
8
  var ariaLabel = _ref.ariaLabel,
9
+ ariaControls = _ref['aria-controls'],
10
+ itemRef = _ref.itemRef,
9
11
  description = _ref.description,
10
12
  iconBefore = _ref.iconBefore,
11
13
  isDisabled = _ref.isDisabled,
14
+ onBeforeSelect = _ref.onBeforeSelect,
12
15
  lozenge = _ref.lozenge,
13
16
  onSelect = _ref.onSelect,
14
17
  preview = _ref.preview,
@@ -25,9 +28,12 @@ export var QuickInsertMenuItem = function QuickInsertMenuItem(_ref) {
25
28
  var surface = surfaceContext === null || surfaceContext === void 0 || (_surfaceContext$get = surfaceContext.get(REGISTERED_MENU_SURFACE_CONTEXT)) === null || _surfaceContext$get === void 0 ? void 0 : _surfaceContext$get.surface;
26
29
  return surface === 'element-browser' ? /*#__PURE__*/React.createElement(ElementBrowserQuickInsertMenuItem, {
27
30
  ariaLabel: ariaLabel,
31
+ "aria-controls": ariaControls,
32
+ itemRef: itemRef,
28
33
  description: description,
29
34
  iconBefore: iconBefore,
30
35
  isDisabled: isDisabled,
36
+ onBeforeSelect: onBeforeSelect,
31
37
  lozenge: lozenge,
32
38
  onSelect: onSelect,
33
39
  preview: preview,
@@ -37,9 +43,12 @@ export var QuickInsertMenuItem = function QuickInsertMenuItem(_ref) {
37
43
  title: title
38
44
  }) : /*#__PURE__*/React.createElement(CompactQuickInsertMenuItem, {
39
45
  ariaLabel: ariaLabel,
46
+ "aria-controls": ariaControls,
47
+ itemRef: itemRef,
40
48
  description: description,
41
49
  iconBefore: iconBefore,
42
50
  isDisabled: isDisabled,
51
+ onBeforeSelect: onBeforeSelect,
43
52
  lozenge: lozenge,
44
53
  onSelect: onSelect,
45
54
  preview: preview,
@@ -1,16 +1,19 @@
1
1
  import { useCallback } from 'react';
2
2
  import { useQuickInsertContext } from './useQuickInsertContext';
3
- export var useQuickInsertMenuItemSelection = function useQuickInsertMenuItemSelection(onSelect) {
3
+ export var useQuickInsertMenuItemSelection = function useQuickInsertMenuItemSelection(onSelect, onBeforeSelect) {
4
4
  var _useQuickInsertContex = useQuickInsertContext(),
5
5
  editorView = _useQuickInsertContex.editorView,
6
6
  select = _useQuickInsertContex.select;
7
7
  return useCallback(function () {
8
- return select(function (selectionContext) {
8
+ if ((onBeforeSelect === null || onBeforeSelect === void 0 ? void 0 : onBeforeSelect()) === false) {
9
+ return;
10
+ }
11
+ select(function (selectionContext) {
9
12
  return onSelect({
10
13
  editorView: editorView,
11
14
  insert: selectionContext.insert,
12
15
  source: selectionContext.source
13
16
  });
14
17
  });
15
- }, [editorView, onSelect, select]);
18
+ }, [editorView, onBeforeSelect, onSelect, select]);
16
19
  };
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { ToolbarUIProvider } from '@atlaskit/editor-toolbar/ui-context';
3
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
3
4
  export var EditorToolbarUIProvider = function EditorToolbarUIProvider(_ref) {
4
5
  var children = _ref.children,
5
6
  api = _ref.api,
@@ -13,6 +14,23 @@ export var EditorToolbarUIProvider = function EditorToolbarUIProvider(_ref) {
13
14
  var onDropdownOpenChanged = useCallback(function (_ref2) {
14
15
  var isOpen = _ref2.isOpen,
15
16
  event = _ref2.event;
17
+ if (!isOpen && fg('platform-dst-top-layer')) {
18
+ // Escape, Tab and an outside press have no target, and the editor does not take focus.
19
+ // The browser moves focus on Escape and Tab. On an outside press, focus goes where the
20
+ // user pressed, for example the editor. After a toolbar action (an item pick, a trigger
21
+ // click, a close from code), the editor takes focus back.
22
+ if (event === null || event.target instanceof Element) {
23
+ // After the design system's focus return as the menu hides.
24
+ setTimeout(function () {
25
+ return requestAnimationFrame(function () {
26
+ api === null || api === void 0 || api.core.actions.focus({
27
+ scrollIntoView: false
28
+ });
29
+ });
30
+ }, 1);
31
+ }
32
+ return;
33
+ }
16
34
  if (!isOpen) {
17
35
  // Only refocus the editor when the dropdown closes via mouse or programmatic close.
18
36
  // When closed via keyboard Escape, keep focus on the trigger for better keyboard UX.
@@ -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.20.0";
23
+ var packageVersion = "135.0.0";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005
@@ -20,7 +20,7 @@ export var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
20
20
  }
21
21
  _this = _callSuper(this, ErrorBoundary, [].concat(args));
22
22
  _defineProperty(_this, "state", {
23
- errorCaptured: false
23
+ error: null
24
24
  });
25
25
  return _this;
26
26
  }
@@ -30,11 +30,6 @@ export var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
30
30
  value: function hasFallback() {
31
31
  return typeof this.props.fallbackComponent !== 'undefined';
32
32
  }
33
- }, {
34
- key: "shouldRecover",
35
- value: function shouldRecover() {
36
- return this.hasFallback() && this.state.errorCaptured;
37
- }
38
33
  }, {
39
34
  key: "componentDidCatch",
40
35
  value: function componentDidCatch(error, errorInfo) {
@@ -56,15 +51,17 @@ export var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
56
51
  });
57
52
  if (this.hasFallback()) {
58
53
  this.setState({
59
- errorCaptured: true
54
+ error: error
60
55
  });
61
56
  }
62
57
  }
63
58
  }, {
64
59
  key: "render",
65
60
  value: function render() {
66
- if (this.shouldRecover()) {
67
- return this.props.fallbackComponent;
61
+ var error = this.state.error;
62
+ if (error) {
63
+ var fallbackComponent = this.props.fallbackComponent;
64
+ return typeof fallbackComponent === 'function' ? fallbackComponent(error) : fallbackComponent !== null && fallbackComponent !== void 0 ? fallbackComponent : null;
68
65
  }
69
66
  return this.props.children;
70
67
  }
@@ -7,6 +7,7 @@ import React, { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
7
7
 
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
9
9
  import { css, jsx } from '@emotion/react';
10
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
10
11
  import { ELEMENT_BROWSER_ID } from '../../element-browser';
11
12
  import { fullPageMessages } from '../../messages';
12
13
  import { mediaInsertMessages } from '../../messages/media-insert';
@@ -122,12 +123,24 @@ export var ToolbarArrowKeyNavigationProvider = function ToolbarArrowKeyNavigatio
122
123
  * @param event
123
124
  */
124
125
  var handleKeyDown = function handleKeyDown(event) {
125
- var _document$querySelect, _document$querySelect2, _wrapperRef$current, _wrapperRef$current2;
126
+ var _document$querySelect, _document$querySelect2, _wrapperRef$current2, _wrapperRef$current3;
126
127
  // To trap the focus inside the horizontal toolbar for left and right arrow keys
127
128
  var targetElement = event.target;
128
129
  if (targetElement instanceof HTMLElement && !targetElement.closest("".concat(childComponentSelector))) {
129
130
  return;
130
131
  }
132
+
133
+ // On the top layer, a menu or popup opened from the toolbar renders inside the toolbar, and
134
+ // it owns its keys: the arrow keys, Tab, and Escape (which closes it and returns focus to its
135
+ // opener). So the toolbar ignores keys from a layer inside it. A layer around the toolbar
136
+ // (for example a floating toolbar's popup) does not count.
137
+ if (fg('platform-dst-top-layer') && targetElement instanceof Element) {
138
+ var _wrapperRef$current;
139
+ var layer = targetElement.closest('[popover], dialog');
140
+ if (layer && (_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(layer)) {
141
+ return;
142
+ }
143
+ }
131
144
  if (targetElement instanceof HTMLElement && (_document$querySelect = document.querySelector('[data-role="droplistContent"], [data-test-id="color-picker-menu"], [data-emoji-picker-container="true"]')) !== null && _document$querySelect !== void 0 && _document$querySelect.contains(targetElement) || targetElement instanceof HTMLElement && (_document$querySelect2 = document.querySelector('[data-test-id="color-picker-menu"]')) !== null && _document$querySelect2 !== void 0 && _document$querySelect2.contains(targetElement) || targetElement instanceof HTMLElement && targetElement.closest('[data-keyboard-navigation-independent]') || event.key === 'ArrowUp' || event.key === 'ArrowDown' || disableArrowKeyNavigation) {
132
145
  return;
133
146
  }
@@ -136,7 +149,7 @@ export var ToolbarArrowKeyNavigationProvider = function ToolbarArrowKeyNavigatio
136
149
  // if menu wrapper exists, then a menu is open and arrow keys will be handled by MenuArrowKeyNavigationProvider
137
150
  return;
138
151
  }
139
- var elementBrowser = wrapperRef === null || wrapperRef === void 0 || (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.querySelector("#".concat(ELEMENT_BROWSER_ID));
152
+ var elementBrowser = wrapperRef === null || wrapperRef === void 0 || (_wrapperRef$current2 = wrapperRef.current) === null || _wrapperRef$current2 === void 0 ? void 0 : _wrapperRef$current2.querySelector("#".concat(ELEMENT_BROWSER_ID));
140
153
  if (elementBrowser) {
141
154
  // if element browser is open, then arrow keys will be handled by MenuArrowKeyNavigationProvider
142
155
  return;
@@ -150,7 +163,7 @@ export var ToolbarArrowKeyNavigationProvider = function ToolbarArrowKeyNavigatio
150
163
  if (targetElement instanceof HTMLElement && targetElement.closest("[aria-label=\"".concat(intl.formatMessage(mediaInsertMessages.mediaPickerPopupAriaLabel), "\"]"))) {
151
164
  return;
152
165
  }
153
- if (targetElement instanceof HTMLElement && !((_wrapperRef$current2 = wrapperRef.current) !== null && _wrapperRef$current2 !== void 0 && _wrapperRef$current2.contains(targetElement))) {
166
+ if (targetElement instanceof HTMLElement && !((_wrapperRef$current3 = wrapperRef.current) !== null && _wrapperRef$current3 !== void 0 && _wrapperRef$current3.contains(targetElement))) {
154
167
  selectedItemIndex.current = -1;
155
168
  } else {
156
169
  selectedItemIndex.current = targetElement instanceof HTMLElement && filteredFocusableElements.indexOf(targetElement) > -1 ? filteredFocusableElements.indexOf(targetElement) : selectedItemIndex.current;
@@ -167,7 +167,7 @@ export type ErrorEventAttributes = {
167
167
  outdatedBrowser?: boolean;
168
168
  product?: string;
169
169
  };
170
- type ComponentCrashErrorAEP = OperationalAEP<ACTION.EDITOR_CRASHED, ACTION_SUBJECT.FLOATING_CONTEXTUAL_BUTTON | ACTION_SUBJECT.PLUGIN_SLOT | ACTION_SUBJECT.REACT_NODE_VIEW | ACTION_SUBJECT.TABLES_PLUGIN | ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN | ACTION_SUBJECT.EDITOR | ACTION_SUBJECT.BLOCK_MENU | ACTION_SUBJECT.SYNCED_BLOCK | ACTION_SUBJECT.TOOLBAR, ACTION_SUBJECT_ID | FLOATING_CONTROLS_TITLE, ErrorEventAttributes>;
170
+ type ComponentCrashErrorAEP = OperationalAEP<ACTION.EDITOR_CRASHED, ACTION_SUBJECT.FLOATING_CONTEXTUAL_BUTTON | ACTION_SUBJECT.PLUGIN_SLOT | ACTION_SUBJECT.REACT_NODE_VIEW | ACTION_SUBJECT.TABLES_PLUGIN | ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN | ACTION_SUBJECT.EDITOR | ACTION_SUBJECT.RENDERER | ACTION_SUBJECT.BLOCK_MENU | ACTION_SUBJECT.SYNCED_BLOCK | ACTION_SUBJECT.TOOLBAR, ACTION_SUBJECT_ID | FLOATING_CONTROLS_TITLE, ErrorEventAttributes>;
171
171
  type ComponentCrashAdditionalInfoErrorAEP = OperationalAEP<ACTION.EDITOR_CRASHED_ADDITIONAL_INFORMATION, ACTION_SUBJECT.EDITOR, undefined, {
172
172
  errorId: string;
173
173
  }>;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import Loadable from 'react-loadable';
3
+ import type { ACTION_SUBJECT } from '../analytics/types/enums';
3
4
  import type { ExtensionParams, MultiBodiedExtensionActions, ReferenceEntity } from './types/extension-handler';
4
5
  import type { ExtensionKey, ExtensionModuleNode, ExtensionType } from './types/extension-manifest';
5
6
  import type { Parameters } from './types/extension-parameters';
@@ -12,7 +13,7 @@ export declare function getExtensionModuleNodeMaybePreloaded(extensionProvider:
12
13
  export declare function getExtensionModuleNodePrivateProps(extensionProvider: ExtensionProvider, extensionType: ExtensionType, extensionKey: ExtensionKey): Promise<{
13
14
  [prop: string]: any;
14
15
  }>;
15
- export declare function getNodeRenderer<T extends Parameters>(extensionProvider: ExtensionProvider, extensionType: ExtensionType, extensionKey: ExtensionKey): React.ComponentType<{
16
+ export declare function getNodeRenderer<T extends Parameters>(extensionProvider: ExtensionProvider, extensionType: ExtensionType, extensionKey: ExtensionKey, errorActionSubject: ACTION_SUBJECT.EDITOR | ACTION_SUBJECT.RENDERER): React.ComponentType<{
16
17
  actions?: MultiBodiedExtensionActions;
17
18
  isSelected?: boolean;
18
19
  node: ExtensionParams<T>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Creates a function that returns the decimal outline number (`1`, `1.1`, `1.1.1`) of each heading,
3
+ * called once per heading in document order. Use it when headings are visited one at a time.
4
+ *
5
+ * Each number has exactly `level` segments. Skipped levels are backfilled with `1` and count as
6
+ * real siblings, and a higher-level heading resets all deeper counters.
7
+ *
8
+ * @example
9
+ * const getNextHeadingNumber = createHeadingNumberer();
10
+ * getNextHeadingNumber(1); // '1'
11
+ * getNextHeadingNumber(3); // '1.1.1'
12
+ * getNextHeadingNumber(2); // '1.2'
13
+ */
14
+ export declare const createHeadingNumberer: () => ((level: number) => string);
@@ -4,10 +4,7 @@
4
4
  */
5
5
  export declare const HEADING_NUMBER_ATTRIBUTE = "data-heading-number";
6
6
  /**
7
- * Computes decimal outline numbers (`1`, `1.1`, `1.1.1`) for headings in document order.
8
- *
9
- * Each number has exactly `level` segments. Skipped levels are backfilled with `1` and count as
10
- * real siblings, and a higher-level heading resets all deeper counters.
7
+ * Computes decimal outline numbers for headings in document order. See `createHeadingNumberer`.
11
8
  *
12
9
  * @example getHeadingNumbers([1, 3, 2]) // ['1', '1.1.1', '1.2']
13
10
  */
@@ -4,4 +4,4 @@
4
4
  */
5
5
  import React from 'react';
6
6
  import type { QuickInsertMenuItemProps } from './QuickInsertMenuItem';
7
- export declare const CompactQuickInsertMenuItem: ({ ariaLabel, description, iconBefore, isDisabled, lozenge, onSelect, preview, previewIcon, previewImageUrls, shortcut, titleContent, shouldShowPreview, shouldClampPreview, shouldWrapIcon, title, }: QuickInsertMenuItemProps) => React.JSX.Element;
7
+ export declare const CompactQuickInsertMenuItem: ({ ariaLabel, 'aria-controls': ariaControls, description, iconBefore, itemRef, isDisabled, lozenge, onSelect, onBeforeSelect, preview, previewIcon, previewImageUrls, shortcut, titleContent, shouldShowPreview, shouldClampPreview, shouldWrapIcon, title, }: QuickInsertMenuItemProps) => React.JSX.Element;
@@ -10,4 +10,4 @@ import type { QuickInsertMenuItemProps } from './QuickInsertMenuItem';
10
10
  * always in a bordered box, above the title instead. The hover card's small title icon
11
11
  * (`previewIcon`) is not shown, so a tile never repeats its icon.
12
12
  */
13
- export declare const ElementBrowserQuickInsertMenuItem: ({ ariaLabel, description, iconBefore, isDisabled, lozenge, onSelect, preview, previewImageUrls, shortcut, titleContent, title, }: QuickInsertMenuItemProps) => React.JSX.Element;
13
+ export declare const ElementBrowserQuickInsertMenuItem: ({ ariaLabel, 'aria-controls': ariaControls, itemRef, description, iconBefore, isDisabled, onBeforeSelect, lozenge, onSelect, preview, previewImageUrls, shortcut, titleContent, title, }: QuickInsertMenuItemProps) => React.JSX.Element;
@@ -10,12 +10,16 @@ export type OnSelectContext = {
10
10
  source: INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
11
11
  };
12
12
  export type QuickInsertMenuItemProps = {
13
+ 'aria-controls'?: string;
13
14
  ariaLabel?: string;
14
15
  description?: string;
15
16
  iconBefore?: React.ReactNode;
16
17
  isDisabled?: boolean;
18
+ itemRef?: React.Ref<HTMLElement>;
17
19
  /** Shown after the title in the menu row only, not in the preview. */
18
20
  lozenge?: React.ReactNode;
21
+ /** Return false to keep the registered menu open without selecting this item. */
22
+ onBeforeSelect?: () => boolean;
19
23
  onSelect: (context: OnSelectContext) => Transaction | false | void;
20
24
  /** Structured preview content for the selected item. */
21
25
  preview?: QuickInsertPreview;
@@ -36,4 +40,4 @@ export type QuickInsertMenuItemProps = {
36
40
  /** Rich content rendered in place of the title in the menu row and preview. `title` is still used for accessibility. */
37
41
  titleContent?: React.ReactNode;
38
42
  };
39
- export declare const QuickInsertMenuItem: ({ ariaLabel, description, iconBefore, isDisabled, lozenge, onSelect, preview, previewIcon, previewImageUrls, shortcut, titleContent, shouldShowPreview, shouldClampPreview, shouldWrapIcon, title, }: QuickInsertMenuItemProps) => React.JSX.Element;
43
+ export declare const QuickInsertMenuItem: ({ ariaLabel, 'aria-controls': ariaControls, itemRef, description, iconBefore, isDisabled, onBeforeSelect, lozenge, onSelect, preview, previewIcon, previewImageUrls, shortcut, titleContent, shouldShowPreview, shouldClampPreview, shouldWrapIcon, title, }: QuickInsertMenuItemProps) => React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import type { QuickInsertMenuItemProps } from './QuickInsertMenuItem';
2
- export declare const useQuickInsertMenuItemSelection: (onSelect: QuickInsertMenuItemProps['onSelect']) => (() => void);
2
+ export declare const useQuickInsertMenuItemSelection: (onSelect: QuickInsertMenuItemProps['onSelect'], onBeforeSelect?: QuickInsertMenuItemProps['onBeforeSelect']) => (() => void);
@@ -9,17 +9,14 @@ interface ErrorBoundaryProps {
9
9
  component: ErrorCrashPayload['actionSubject'];
10
10
  componentId?: ErrorCrashPayload['actionSubjectId'];
11
11
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
12
- fallbackComponent?: React.ReactNode;
12
+ fallbackComponent?: React.ReactNode | ((error: Error) => React.ReactNode);
13
13
  }
14
14
  interface ErrorBoundaryState {
15
- errorCaptured: boolean;
15
+ error: Error | null;
16
16
  }
17
17
  export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
18
- state: {
19
- errorCaptured: boolean;
20
- };
18
+ state: ErrorBoundaryState;
21
19
  hasFallback(): boolean;
22
- shouldRecover(): boolean;
23
20
  componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
24
21
  render(): React.ReactNode;
25
22
  }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/numbered-headings/create-heading-numberer",
3
+ "main": "../../dist/cjs/numbered-headings/create-heading-numberer.js",
4
+ "module": "../../dist/esm/numbered-headings/create-heading-numberer.js",
5
+ "module:es2019": "../../dist/es2019/numbered-headings/create-heading-numberer.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../../dist/types/numbered-headings/create-heading-numberer.d.ts"
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "134.20.1",
3
+ "version": "135.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/"
@@ -80,7 +80,7 @@
80
80
  "@atlaskit/react-compiler-gating": "^0.2.0",
81
81
  "@atlaskit/react-ufo": "^8.5.0",
82
82
  "@atlaskit/section-message": "^10.3.0",
83
- "@atlaskit/smart-card": "^46.14.0",
83
+ "@atlaskit/smart-card": "^46.15.0",
84
84
  "@atlaskit/smart-user-picker": "^12.12.0",
85
85
  "@atlaskit/spinner": "^20.4.0",
86
86
  "@atlaskit/task-decision": "^21.16.0",