@atlaskit/editor-plugin-block-menu 5.2.11 → 5.2.13

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 (67) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/transform.js +2 -1
  3. package/dist/cjs/editor-commands/transform-node-utils/utils.js +1 -53
  4. package/dist/cjs/editor-commands/transformNode.js +4 -4
  5. package/dist/cjs/ui/block-menu-renderer/BlockMenuComponent.js +37 -0
  6. package/dist/cjs/ui/block-menu-renderer/BlockMenuComponents.js +29 -0
  7. package/dist/cjs/ui/block-menu-renderer/BlockMenuRenderer.js +33 -0
  8. package/dist/cjs/ui/block-menu-renderer/fallbacks.js +32 -0
  9. package/dist/cjs/ui/block-menu-renderer/types.js +5 -0
  10. package/dist/cjs/ui/block-menu-renderer/utils.js +127 -0
  11. package/dist/cjs/ui/block-menu.js +7 -20
  12. package/dist/cjs/ui/copy-link.js +7 -11
  13. package/dist/cjs/ui/hooks/useSuggestedItems.js +11 -4
  14. package/dist/cjs/ui/utils/copyLink.js +4 -4
  15. package/dist/cjs/ui/utils/suggested-items-rank.js +1 -1
  16. package/dist/es2019/editor-commands/transform-node-utils/transform.js +2 -1
  17. package/dist/es2019/editor-commands/transform-node-utils/utils.js +0 -54
  18. package/dist/es2019/editor-commands/transformNode.js +2 -2
  19. package/dist/es2019/ui/block-menu-renderer/BlockMenuComponent.js +31 -0
  20. package/dist/es2019/ui/block-menu-renderer/BlockMenuComponents.js +21 -0
  21. package/dist/es2019/ui/block-menu-renderer/BlockMenuRenderer.js +24 -0
  22. package/dist/es2019/ui/block-menu-renderer/fallbacks.js +21 -0
  23. package/dist/es2019/ui/block-menu-renderer/types.js +1 -0
  24. package/dist/es2019/ui/block-menu-renderer/utils.js +93 -0
  25. package/dist/es2019/ui/block-menu.js +6 -13
  26. package/dist/es2019/ui/copy-link.js +7 -11
  27. package/dist/es2019/ui/hooks/useSuggestedItems.js +10 -5
  28. package/dist/es2019/ui/utils/copyLink.js +3 -4
  29. package/dist/es2019/ui/utils/suggested-items-rank.js +0 -5
  30. package/dist/esm/editor-commands/transform-node-utils/transform.js +2 -1
  31. package/dist/esm/editor-commands/transform-node-utils/utils.js +0 -52
  32. package/dist/esm/editor-commands/transformNode.js +2 -2
  33. package/dist/esm/ui/block-menu-renderer/BlockMenuComponent.js +30 -0
  34. package/dist/esm/ui/block-menu-renderer/BlockMenuComponents.js +22 -0
  35. package/dist/esm/ui/block-menu-renderer/BlockMenuRenderer.js +25 -0
  36. package/dist/esm/ui/block-menu-renderer/fallbacks.js +25 -0
  37. package/dist/esm/ui/block-menu-renderer/types.js +1 -0
  38. package/dist/esm/ui/block-menu-renderer/utils.js +121 -0
  39. package/dist/esm/ui/block-menu.js +6 -19
  40. package/dist/esm/ui/copy-link.js +7 -11
  41. package/dist/esm/ui/hooks/useSuggestedItems.js +12 -5
  42. package/dist/esm/ui/utils/copyLink.js +4 -4
  43. package/dist/esm/ui/utils/suggested-items-rank.js +1 -1
  44. package/dist/types/blockMenuPluginType.d.ts +3 -2
  45. package/dist/types/editor-commands/transform-node-utils/utils.d.ts +1 -17
  46. package/dist/types/ui/block-menu-renderer/BlockMenuComponent.d.ts +11 -0
  47. package/dist/types/ui/block-menu-renderer/BlockMenuComponents.d.ts +12 -0
  48. package/dist/types/ui/block-menu-renderer/BlockMenuRenderer.d.ts +12 -0
  49. package/dist/types/ui/block-menu-renderer/fallbacks.d.ts +2 -0
  50. package/dist/types/ui/block-menu-renderer/types.d.ts +27 -0
  51. package/dist/types/ui/block-menu-renderer/utils.d.ts +37 -0
  52. package/dist/types/ui/utils/copyLink.d.ts +1 -3
  53. package/dist/types-ts4.5/blockMenuPluginType.d.ts +3 -2
  54. package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +1 -17
  55. package/dist/types-ts4.5/ui/block-menu-renderer/BlockMenuComponent.d.ts +11 -0
  56. package/dist/types-ts4.5/ui/block-menu-renderer/BlockMenuComponents.d.ts +12 -0
  57. package/dist/types-ts4.5/ui/block-menu-renderer/BlockMenuRenderer.d.ts +12 -0
  58. package/dist/types-ts4.5/ui/block-menu-renderer/fallbacks.d.ts +2 -0
  59. package/dist/types-ts4.5/ui/block-menu-renderer/types.d.ts +27 -0
  60. package/dist/types-ts4.5/ui/block-menu-renderer/utils.d.ts +37 -0
  61. package/dist/types-ts4.5/ui/utils/copyLink.d.ts +1 -3
  62. package/package.json +1 -1
  63. package/dist/cjs/ui/block-menu-renderer.js +0 -104
  64. package/dist/es2019/ui/block-menu-renderer.js +0 -83
  65. package/dist/esm/ui/block-menu-renderer.js +0 -95
  66. package/dist/types/ui/block-menu-renderer.d.ts +0 -18
  67. package/dist/types-ts4.5/ui/block-menu-renderer.d.ts +0 -18
@@ -0,0 +1,121 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ /**
6
+ * Type guard to check if a component has a parent
7
+ *
8
+ * @param component The block menu component to check
9
+ * @returns True if the component has a parent, false otherwise
10
+ */
11
+ var hasParent = function hasParent(component) {
12
+ return 'parent' in component && !!component.parent;
13
+ };
14
+
15
+ /**
16
+ * Type guard to identify top-level sections (sections without a parent)
17
+ *
18
+ * @param component The block menu component to check
19
+ * @returns True if the component is a top-level section, false otherwise
20
+ */
21
+ var isTopLevelSection = function isTopLevelSection(component) {
22
+ return component.type === 'block-menu-section' && !hasParent(component);
23
+ };
24
+
25
+ /**
26
+ * Gets all top-level sections (those without a parent) sorted by rank
27
+ *
28
+ * @param components All registered block menu components
29
+ * @returns Sorted array of top-level sections
30
+ */
31
+ export var getSortedTopLevelSections = function getSortedTopLevelSections(components) {
32
+ return components.filter(isTopLevelSection).sort(function (a, b) {
33
+ return (a.rank || 0) - (b.rank || 0);
34
+ });
35
+ };
36
+
37
+ /**
38
+ * Generates a unique key from a key and type
39
+ * Used to lookup children in the childrenMap
40
+ *
41
+ * @param key The component's key
42
+ * @param type The component's type
43
+ * @returns A unique string key combining type and key
44
+ */
45
+ export var getChildrenMapKey = function getChildrenMapKey(key, type) {
46
+ return "".concat(type, ":").concat(key);
47
+ };
48
+
49
+ /**
50
+ * Builds a map of parent keys to their sorted children
51
+ * This enables efficient hierarchical rendering of the menu structure
52
+ *
53
+ * @param components All registered block menu components
54
+ * @returns Map where keys are parent identifiers and values are sorted child components
55
+ */
56
+ export var buildChildrenMap = function buildChildrenMap(components) {
57
+ var childrenMap = new Map();
58
+ var _iterator = _createForOfIteratorHelper(components),
59
+ _step;
60
+ try {
61
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
62
+ var component = _step.value;
63
+ // Only components with parents can be children
64
+ if ('parent' in component && !!component.parent) {
65
+ var childrenMapKey = getChildrenMapKey(component.parent.key, component.parent.type);
66
+ var existing = childrenMap.get(childrenMapKey) || [];
67
+ existing.push(component);
68
+ childrenMap.set(childrenMapKey, existing);
69
+ }
70
+ }
71
+
72
+ // Sort children by their rank within their parent
73
+ } catch (err) {
74
+ _iterator.e(err);
75
+ } finally {
76
+ _iterator.f();
77
+ }
78
+ var _iterator2 = _createForOfIteratorHelper(childrenMap.entries()),
79
+ _step2;
80
+ try {
81
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
82
+ var _step2$value = _slicedToArray(_step2.value, 2),
83
+ children = _step2$value[1];
84
+ children.sort(function (a, b) {
85
+ var rankA = hasParent(a) ? a.parent.rank || 0 : 0;
86
+ var rankB = hasParent(b) ? b.parent.rank || 0 : 0;
87
+ return rankA - rankB;
88
+ });
89
+ }
90
+ } catch (err) {
91
+ _iterator2.e(err);
92
+ } finally {
93
+ _iterator2.f();
94
+ }
95
+ return childrenMap;
96
+ };
97
+
98
+ /**
99
+ * Determines whether a component will render based on its type and children
100
+ *
101
+ * Rules:
102
+ * - An item will not render if has a component that returns null
103
+ * - A nested menu will render if it has at least one registered child component
104
+ * - A section will render if it has at least one registered child component that will render
105
+ *
106
+ * NOTE: This requires invoking each item's component function to check for null return
107
+ */
108
+ var _willComponentRender = function willComponentRender(registeredComponent, childrenMap) {
109
+ if (registeredComponent.type === 'block-menu-item') {
110
+ return registeredComponent.component ? registeredComponent.component() !== null : true;
111
+ }
112
+ var childrenMapKey = getChildrenMapKey(registeredComponent.key, registeredComponent.type);
113
+ var registeredComponents = childrenMap.get(childrenMapKey) || [];
114
+ if (registeredComponent.type === 'block-menu-nested') {
115
+ return registeredComponents.length > 0;
116
+ }
117
+ return registeredComponents.some(function (childComponent) {
118
+ return _willComponentRender(childComponent, childrenMap);
119
+ });
120
+ };
121
+ export { _willComponentRender as willComponentRender };
@@ -11,15 +11,15 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
11
11
  import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
12
12
  import { DRAG_HANDLE_SELECTOR, DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles';
13
13
  import { Popup } from '@atlaskit/editor-common/ui';
14
+ import { ArrowKeyNavigationProvider, ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu';
14
15
  import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
15
16
  import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
16
- import { ToolbarDropdownItem, ToolbarDropdownItemSection, ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
17
17
  import { fg } from '@atlaskit/platform-feature-flags';
18
18
  import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
19
19
  import { Box } from '@atlaskit/primitives/compiled';
20
20
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
21
21
  import { useBlockMenu } from './block-menu-provider';
22
- import { BlockMenuRenderer } from './block-menu-renderer';
22
+ import { BlockMenuRenderer } from './block-menu-renderer/BlockMenuRenderer';
23
23
  var styles = {
24
24
  base: "_2rko12b0 _bfhk1bhr _16qs130s",
25
25
  emptyMenuSectionStyles: "_1cc0glyw _1k2yglyw"
@@ -111,24 +111,11 @@ var BlockMenuContent = function BlockMenuContent(_ref3) {
111
111
  testId: "editor-block-menu",
112
112
  ref: ref,
113
113
  xcss: cx(styles.base, editorExperiment('platform_synced_block', true) && styles.emptyMenuSectionStyles)
114
+ }, /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
115
+ type: ArrowKeyNavigationType.MENU
114
116
  }, /*#__PURE__*/React.createElement(BlockMenuRenderer, {
115
- components: blockMenuComponents || [],
116
- fallbacks: {
117
- nestedMenu: function nestedMenu() {
118
- return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
119
- elemBefore: undefined,
120
- elemAfter: undefined
121
- }, /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, /*#__PURE__*/React.createElement(ToolbarDropdownItem, null, "Block Menu Item")));
122
- },
123
- section: function section() {
124
- return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, /*#__PURE__*/React.createElement(ToolbarDropdownItem, null, "Block Menu Item"));
125
- },
126
- // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-jsx
127
- item: function item() {
128
- return /*#__PURE__*/React.createElement(ToolbarDropdownItem, null, "Block Menu Item");
129
- }
130
- }
131
- }));
117
+ allRegisteredComponents: blockMenuComponents || []
118
+ })));
132
119
  };
133
120
  var BlockMenu = function BlockMenu(_ref4) {
134
121
  var _editorView$dom, _ref5;
@@ -22,24 +22,21 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
22
22
  var _ref2 = config || {},
23
23
  getLinkPath = _ref2.getLinkPath,
24
24
  blockLinkHashPrefix = _ref2.blockLinkHashPrefix;
25
- var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls', 'selection', 'core'], function (_ref3) {
25
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls', 'selection'], function (_ref3) {
26
26
  var blockControlsState = _ref3.blockControlsState,
27
- selectionState = _ref3.selectionState,
28
- coreState = _ref3.coreState;
27
+ selectionState = _ref3.selectionState;
29
28
  return {
30
29
  menuTriggerBy: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.menuTriggerBy,
31
30
  preservedSelection: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.preservedSelection,
32
- defaultSelection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection,
33
- schema: coreState === null || coreState === void 0 ? void 0 : coreState.schema
31
+ defaultSelection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
34
32
  };
35
33
  }),
36
34
  preservedSelection = _useSharedPluginState.preservedSelection,
37
35
  defaultSelection = _useSharedPluginState.defaultSelection,
38
- menuTriggerBy = _useSharedPluginState.menuTriggerBy,
39
- schema = _useSharedPluginState.schema;
36
+ menuTriggerBy = _useSharedPluginState.menuTriggerBy;
40
37
  var selection = preservedSelection || defaultSelection;
41
38
  var handleClick = useCallback(function () {
42
- if (!selection || !schema) {
39
+ if (!selection) {
43
40
  return;
44
41
  }
45
42
  api === null || api === void 0 || api.core.actions.execute(function (_ref4) {
@@ -65,8 +62,7 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
65
62
  copyLink({
66
63
  getLinkPath: getLinkPath,
67
64
  blockLinkHashPrefix: blockLinkHashPrefix,
68
- selection: selection,
69
- schema: schema
65
+ selection: selection
70
66
  }).then(function (success) {
71
67
  if (success) {
72
68
  api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
@@ -78,7 +74,7 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
78
74
  });
79
75
  }
80
76
  });
81
- }, [api, blockLinkHashPrefix, getLinkPath, onDropdownOpenChanged, schema, selection]);
77
+ }, [api, blockLinkHashPrefix, getLinkPath, onDropdownOpenChanged, selection]);
82
78
 
83
79
  // Hide copy link when `platform_editor_adf_with_localid` feature flag is off or when the node is nested or on empty line
84
80
  if (!fg('platform_editor_adf_with_localid') || !!menuTriggerBy && isNestedNode(selection, menuTriggerBy) || selection !== null && selection !== void 0 && selection.empty) {
@@ -1,6 +1,7 @@
1
1
  import { useMemo } from 'react';
2
2
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
- import { getBlockNodesInRange, expandSelectionToBlockRange } from '../../editor-commands/transform-node-utils/utils';
3
+ import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
4
+ import { getBlockNodesInRange } from '../../editor-commands/transform-node-utils/utils';
4
5
  import { getSortedSuggestedItems } from '../utils/suggested-items-rank';
5
6
  export var useSuggestedItems = function useSuggestedItems(api) {
6
7
  var _api$blockMenu;
@@ -29,17 +30,23 @@ export var useSuggestedItems = function useSuggestedItems(api) {
29
30
  if (menuItemsMap.size === 0 || !currentSelection) {
30
31
  return [];
31
32
  }
32
- var _expandSelectionToBlo = expandSelectionToBlockRange(currentSelection, currentSelection.$from.doc.type.schema),
33
+ var _expandSelectionToBlo = expandSelectionToBlockRange(currentSelection),
33
34
  range = _expandSelectionToBlo.range;
34
35
  if (!range) {
35
36
  return [];
36
37
  }
37
38
  var blockNodes = getBlockNodesInRange(range);
38
- var singleNode = blockNodes.length === 1 ? blockNodes[0] : undefined;
39
- if (!singleNode) {
39
+ if (blockNodes.length === 0) {
40
40
  return [];
41
41
  }
42
- var nodeTypeName = singleNode.type.name;
42
+ var firstNodeType = blockNodes[0].type.name;
43
+ var allSameType = blockNodes.every(function (node) {
44
+ return node.type.name === firstNodeType;
45
+ });
46
+ if (!allSameType) {
47
+ return [];
48
+ }
49
+ var nodeTypeName = firstNodeType;
43
50
  var sortedKeys = getSortedSuggestedItems(nodeTypeName);
44
51
  return sortedKeys.map(function (key) {
45
52
  return menuItemsMap.get(key);
@@ -3,15 +3,15 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { createBlockLinkHashValue, DEFAULT_BLOCK_LINK_HASH_PREFIX } from '@atlaskit/editor-common/block-menu';
4
4
  import { copyToClipboard } from '@atlaskit/editor-common/clipboard';
5
5
  import { logException } from '@atlaskit/editor-common/monitoring';
6
- import { expandSelectionToBlockRange } from '../../editor-commands/transform-node-utils/utils';
6
+ import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
7
7
  export var copyLink = /*#__PURE__*/function () {
8
8
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
9
- var getLinkPath, _ref$blockLinkHashPre, blockLinkHashPrefix, selection, schema, blockRange, node, path, url, href;
9
+ var getLinkPath, _ref$blockLinkHashPre, blockLinkHashPrefix, selection, blockRange, node, path, url, href;
10
10
  return _regeneratorRuntime.wrap(function _callee$(_context) {
11
11
  while (1) switch (_context.prev = _context.next) {
12
12
  case 0:
13
- getLinkPath = _ref.getLinkPath, _ref$blockLinkHashPre = _ref.blockLinkHashPrefix, blockLinkHashPrefix = _ref$blockLinkHashPre === void 0 ? DEFAULT_BLOCK_LINK_HASH_PREFIX : _ref$blockLinkHashPre, selection = _ref.selection, schema = _ref.schema;
14
- blockRange = expandSelectionToBlockRange(selection, schema);
13
+ getLinkPath = _ref.getLinkPath, _ref$blockLinkHashPre = _ref.blockLinkHashPrefix, blockLinkHashPrefix = _ref$blockLinkHashPre === void 0 ? DEFAULT_BLOCK_LINK_HASH_PREFIX : _ref$blockLinkHashPre, selection = _ref.selection;
14
+ blockRange = expandSelectionToBlockRange(selection);
15
15
  if (blockRange) {
16
16
  _context.next = 4;
17
17
  break;
@@ -37,7 +37,7 @@ export var BLOCK_MENU_NODE_TYPES = {
37
37
  EMBED_CARD: 'embedCard',
38
38
  TABLE: 'table'
39
39
  };
40
- export var TRANSFORM_SUGGESTED_ITEMS_RANK = (_TRANSFORM_SUGGESTED_ = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.PARAGRAPH, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_HEADINGS_H1_MENU_ITEM.key, 200), TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXPAND, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCKQUOTE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.LAYOUT_SECTION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.PANEL, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.CODE_BLOCK, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.DECISION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BULLET_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.ORDERED_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.HEADING, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.TASK_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.MEDIA_SINGLE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXTENSION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BODIED_EXTENSION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)));
40
+ export var TRANSFORM_SUGGESTED_ITEMS_RANK = (_TRANSFORM_SUGGESTED_ = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.PARAGRAPH, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_HEADINGS_H1_MENU_ITEM.key, 200), TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXPAND, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCKQUOTE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.LAYOUT_SECTION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.PANEL, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.CODE_BLOCK, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.DECISION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BULLET_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.ORDERED_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.HEADING, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), _defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.TASK_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.MEDIA_SINGLE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXTENSION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)));
41
41
  export var getSuggestedItemsForNodeType = function getSuggestedItemsForNodeType(nodeType) {
42
42
  return TRANSFORM_SUGGESTED_ITEMS_RANK[nodeType];
43
43
  };
@@ -1,4 +1,4 @@
1
- import type { NextEditorPlugin, OptionalPlugin, EditorCommand } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
4
4
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
@@ -84,7 +84,7 @@ type BlockMenuNested = {
84
84
  key: string;
85
85
  type: 'block-menu-nested';
86
86
  };
87
- export type BlockMenuNestedComponent = (props?: {
87
+ export type BlockMenuNestedComponent = (props: {
88
88
  children: React.ReactNode;
89
89
  }) => React.ReactNode;
90
90
  export type BlockMenuSectionComponent = (props: {
@@ -108,4 +108,5 @@ export type RegisterBlockMenuItem = BlockMenuItem & {
108
108
  parent: Parent<BlockMenuSection>;
109
109
  };
110
110
  export type RegisterBlockMenuComponent = RegisterBlockMenuNested | RegisterBlockMenuSection | RegisterBlockMenuItem;
111
+ export type RegisterBlockMenuComponentType = RegisterBlockMenuComponent['type'];
111
112
  export {};
@@ -1,25 +1,9 @@
1
- import type { Schema, Node as PMNode, NodeRange } from '@atlaskit/editor-prosemirror/model';
1
+ import type { NodeRange, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
4
  import type { NodeTypeName } from './types';
5
5
  export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
6
6
  export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean) => NodeTypeName | null;
7
- /**
8
- * Use common expandToBlockRange function to get the correct range for the selection
9
- * For example, if selection starts in a listItem, go find the bullet list or ordered list, their $from
10
- * @param selection
11
- * @param schema
12
- * @returns
13
- */
14
- export declare const expandSelectionToBlockRange: (selection: Selection, schema: Schema) => {
15
- $from: import("prosemirror-model").ResolvedPos;
16
- $to: import("prosemirror-model").ResolvedPos;
17
- range: NodeRange | null;
18
- } | {
19
- $from: import("prosemirror-model").ResolvedPos;
20
- $to: import("prosemirror-model").ResolvedPos;
21
- range?: undefined;
22
- };
23
7
  export declare const isListType: (node: PMNode, schema: Schema) => boolean;
24
8
  /**
25
9
  * Converts a nestedExpand to a regular expand node.
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { RegisterBlockMenuComponent } from '../../blockMenuPluginType';
3
+ import type { BlockMenuRenderingContext } from './types';
4
+ type BlockMenuComponentProps = BlockMenuRenderingContext & {
5
+ registeredComponent: RegisterBlockMenuComponent;
6
+ };
7
+ /**
8
+ * Renders the given registered component based on its type
9
+ */
10
+ export declare const BlockMenuComponent: ({ registeredComponent, childrenMap, fallbacks, }: BlockMenuComponentProps) => React.JSX.Element | null;
11
+ export {};
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { RegisterBlockMenuComponent } from '../../blockMenuPluginType';
3
+ import type { BlockMenuRenderingContext } from './types';
4
+ type BlockMenuComponentsProps = BlockMenuRenderingContext & {
5
+ registeredComponents?: RegisterBlockMenuComponent[];
6
+ };
7
+ /**
8
+ * Renders the given registered components
9
+ * Returns null if no components are rendered
10
+ */
11
+ export declare const BlockMenuComponents: ({ registeredComponents, childrenMap, fallbacks, }: BlockMenuComponentsProps) => React.JSX.Element | null;
12
+ export {};
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { RegisterBlockMenuComponent } from '../../blockMenuPluginType';
3
+ import type { BlockMenuFallbacks } from './types';
4
+ type BlockMenuProps = {
5
+ allRegisteredComponents: RegisterBlockMenuComponent[];
6
+ fallbacks?: BlockMenuFallbacks;
7
+ };
8
+ /**
9
+ * BlockMenuRenderer orchestrates the rendering of the entire block menu hierarchy
10
+ */
11
+ export declare const BlockMenuRenderer: ({ allRegisteredComponents, fallbacks, }: BlockMenuProps) => React.JSX.Element;
12
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { BlockMenuFallbacks } from './types';
2
+ export declare const BLOCK_MENU_FALLBACKS: BlockMenuFallbacks;
@@ -0,0 +1,27 @@
1
+ import type { BlockMenuItemComponent, BlockMenuNestedComponent, BlockMenuSectionComponent, RegisterBlockMenuComponent } from '../../blockMenuPluginType';
2
+ /**
3
+ * Fallback components used as defaults when specific components aren't provided
4
+ */
5
+ export type BlockMenuFallbacks = {
6
+ 'block-menu-item': BlockMenuItemComponent;
7
+ 'block-menu-nested': BlockMenuNestedComponent;
8
+ 'block-menu-section': BlockMenuSectionComponent;
9
+ };
10
+ /**
11
+ * Map of parent keys to their sorted children components
12
+ * Used to efficiently organize and render hierarchical menu structures
13
+ */
14
+ export type ChildrenMap = Map<string, RegisterBlockMenuComponent[]>;
15
+ /**
16
+ * Props shared across multiple block menu rendering components
17
+ */
18
+ export type BlockMenuRenderingContext = {
19
+ /**
20
+ * Lookup map for child components organized by parent key
21
+ */
22
+ childrenMap: ChildrenMap;
23
+ /**
24
+ * Fallback components when specific components aren't registered
25
+ */
26
+ fallbacks: BlockMenuFallbacks;
27
+ };
@@ -0,0 +1,37 @@
1
+ import type { RegisterBlockMenuComponent, RegisterBlockMenuComponentType, RegisterBlockMenuSection } from '../../blockMenuPluginType';
2
+ import type { ChildrenMap } from './types';
3
+ /**
4
+ * Gets all top-level sections (those without a parent) sorted by rank
5
+ *
6
+ * @param components All registered block menu components
7
+ * @returns Sorted array of top-level sections
8
+ */
9
+ export declare const getSortedTopLevelSections: (components: RegisterBlockMenuComponent[]) => RegisterBlockMenuSection[];
10
+ /**
11
+ * Generates a unique key from a key and type
12
+ * Used to lookup children in the childrenMap
13
+ *
14
+ * @param key The component's key
15
+ * @param type The component's type
16
+ * @returns A unique string key combining type and key
17
+ */
18
+ export declare const getChildrenMapKey: (key: string, type: Omit<RegisterBlockMenuComponentType, "block-menu-item">) => string;
19
+ /**
20
+ * Builds a map of parent keys to their sorted children
21
+ * This enables efficient hierarchical rendering of the menu structure
22
+ *
23
+ * @param components All registered block menu components
24
+ * @returns Map where keys are parent identifiers and values are sorted child components
25
+ */
26
+ export declare const buildChildrenMap: (components: RegisterBlockMenuComponent[]) => ChildrenMap;
27
+ /**
28
+ * Determines whether a component will render based on its type and children
29
+ *
30
+ * Rules:
31
+ * - An item will not render if has a component that returns null
32
+ * - A nested menu will render if it has at least one registered child component
33
+ * - A section will render if it has at least one registered child component that will render
34
+ *
35
+ * NOTE: This requires invoking each item's component function to check for null return
36
+ */
37
+ export declare const willComponentRender: (registeredComponent: RegisterBlockMenuComponent, childrenMap: ChildrenMap) => boolean;
@@ -1,10 +1,8 @@
1
- import type { Schema } from '@atlaskit/editor-prosemirror/model';
2
1
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
3
2
  type CopyLinkOptions = {
4
3
  blockLinkHashPrefix?: string;
5
4
  getLinkPath?: () => string | null;
6
- schema: Schema;
7
5
  selection: Selection;
8
6
  };
9
- export declare const copyLink: ({ getLinkPath, blockLinkHashPrefix, selection, schema, }: CopyLinkOptions) => Promise<boolean>;
7
+ export declare const copyLink: ({ getLinkPath, blockLinkHashPrefix, selection, }: CopyLinkOptions) => Promise<boolean>;
10
8
  export {};
@@ -1,4 +1,4 @@
1
- import type { NextEditorPlugin, OptionalPlugin, EditorCommand } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
4
4
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
@@ -84,7 +84,7 @@ type BlockMenuNested = {
84
84
  key: string;
85
85
  type: 'block-menu-nested';
86
86
  };
87
- export type BlockMenuNestedComponent = (props?: {
87
+ export type BlockMenuNestedComponent = (props: {
88
88
  children: React.ReactNode;
89
89
  }) => React.ReactNode;
90
90
  export type BlockMenuSectionComponent = (props: {
@@ -108,4 +108,5 @@ export type RegisterBlockMenuItem = BlockMenuItem & {
108
108
  parent: Parent<BlockMenuSection>;
109
109
  };
110
110
  export type RegisterBlockMenuComponent = RegisterBlockMenuNested | RegisterBlockMenuSection | RegisterBlockMenuItem;
111
+ export type RegisterBlockMenuComponentType = RegisterBlockMenuComponent['type'];
111
112
  export {};
@@ -1,25 +1,9 @@
1
- import type { Schema, Node as PMNode, NodeRange } from '@atlaskit/editor-prosemirror/model';
1
+ import type { NodeRange, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
4
  import type { NodeTypeName } from './types';
5
5
  export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
6
6
  export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean) => NodeTypeName | null;
7
- /**
8
- * Use common expandToBlockRange function to get the correct range for the selection
9
- * For example, if selection starts in a listItem, go find the bullet list or ordered list, their $from
10
- * @param selection
11
- * @param schema
12
- * @returns
13
- */
14
- export declare const expandSelectionToBlockRange: (selection: Selection, schema: Schema) => {
15
- $from: import("prosemirror-model").ResolvedPos;
16
- $to: import("prosemirror-model").ResolvedPos;
17
- range: NodeRange | null;
18
- } | {
19
- $from: import("prosemirror-model").ResolvedPos;
20
- $to: import("prosemirror-model").ResolvedPos;
21
- range?: undefined;
22
- };
23
7
  export declare const isListType: (node: PMNode, schema: Schema) => boolean;
24
8
  /**
25
9
  * Converts a nestedExpand to a regular expand node.
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { RegisterBlockMenuComponent } from '../../blockMenuPluginType';
3
+ import type { BlockMenuRenderingContext } from './types';
4
+ type BlockMenuComponentProps = BlockMenuRenderingContext & {
5
+ registeredComponent: RegisterBlockMenuComponent;
6
+ };
7
+ /**
8
+ * Renders the given registered component based on its type
9
+ */
10
+ export declare const BlockMenuComponent: ({ registeredComponent, childrenMap, fallbacks, }: BlockMenuComponentProps) => React.JSX.Element | null;
11
+ export {};
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { RegisterBlockMenuComponent } from '../../blockMenuPluginType';
3
+ import type { BlockMenuRenderingContext } from './types';
4
+ type BlockMenuComponentsProps = BlockMenuRenderingContext & {
5
+ registeredComponents?: RegisterBlockMenuComponent[];
6
+ };
7
+ /**
8
+ * Renders the given registered components
9
+ * Returns null if no components are rendered
10
+ */
11
+ export declare const BlockMenuComponents: ({ registeredComponents, childrenMap, fallbacks, }: BlockMenuComponentsProps) => React.JSX.Element | null;
12
+ export {};
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { RegisterBlockMenuComponent } from '../../blockMenuPluginType';
3
+ import type { BlockMenuFallbacks } from './types';
4
+ type BlockMenuProps = {
5
+ allRegisteredComponents: RegisterBlockMenuComponent[];
6
+ fallbacks?: BlockMenuFallbacks;
7
+ };
8
+ /**
9
+ * BlockMenuRenderer orchestrates the rendering of the entire block menu hierarchy
10
+ */
11
+ export declare const BlockMenuRenderer: ({ allRegisteredComponents, fallbacks, }: BlockMenuProps) => React.JSX.Element;
12
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { BlockMenuFallbacks } from './types';
2
+ export declare const BLOCK_MENU_FALLBACKS: BlockMenuFallbacks;
@@ -0,0 +1,27 @@
1
+ import type { BlockMenuItemComponent, BlockMenuNestedComponent, BlockMenuSectionComponent, RegisterBlockMenuComponent } from '../../blockMenuPluginType';
2
+ /**
3
+ * Fallback components used as defaults when specific components aren't provided
4
+ */
5
+ export type BlockMenuFallbacks = {
6
+ 'block-menu-item': BlockMenuItemComponent;
7
+ 'block-menu-nested': BlockMenuNestedComponent;
8
+ 'block-menu-section': BlockMenuSectionComponent;
9
+ };
10
+ /**
11
+ * Map of parent keys to their sorted children components
12
+ * Used to efficiently organize and render hierarchical menu structures
13
+ */
14
+ export type ChildrenMap = Map<string, RegisterBlockMenuComponent[]>;
15
+ /**
16
+ * Props shared across multiple block menu rendering components
17
+ */
18
+ export type BlockMenuRenderingContext = {
19
+ /**
20
+ * Lookup map for child components organized by parent key
21
+ */
22
+ childrenMap: ChildrenMap;
23
+ /**
24
+ * Fallback components when specific components aren't registered
25
+ */
26
+ fallbacks: BlockMenuFallbacks;
27
+ };
@@ -0,0 +1,37 @@
1
+ import type { RegisterBlockMenuComponent, RegisterBlockMenuComponentType, RegisterBlockMenuSection } from '../../blockMenuPluginType';
2
+ import type { ChildrenMap } from './types';
3
+ /**
4
+ * Gets all top-level sections (those without a parent) sorted by rank
5
+ *
6
+ * @param components All registered block menu components
7
+ * @returns Sorted array of top-level sections
8
+ */
9
+ export declare const getSortedTopLevelSections: (components: RegisterBlockMenuComponent[]) => RegisterBlockMenuSection[];
10
+ /**
11
+ * Generates a unique key from a key and type
12
+ * Used to lookup children in the childrenMap
13
+ *
14
+ * @param key The component's key
15
+ * @param type The component's type
16
+ * @returns A unique string key combining type and key
17
+ */
18
+ export declare const getChildrenMapKey: (key: string, type: Omit<RegisterBlockMenuComponentType, "block-menu-item">) => string;
19
+ /**
20
+ * Builds a map of parent keys to their sorted children
21
+ * This enables efficient hierarchical rendering of the menu structure
22
+ *
23
+ * @param components All registered block menu components
24
+ * @returns Map where keys are parent identifiers and values are sorted child components
25
+ */
26
+ export declare const buildChildrenMap: (components: RegisterBlockMenuComponent[]) => ChildrenMap;
27
+ /**
28
+ * Determines whether a component will render based on its type and children
29
+ *
30
+ * Rules:
31
+ * - An item will not render if has a component that returns null
32
+ * - A nested menu will render if it has at least one registered child component
33
+ * - A section will render if it has at least one registered child component that will render
34
+ *
35
+ * NOTE: This requires invoking each item's component function to check for null return
36
+ */
37
+ export declare const willComponentRender: (registeredComponent: RegisterBlockMenuComponent, childrenMap: ChildrenMap) => boolean;