UNPKG

@atlaskit/editor-plugin-block-menu

Version:

BlockMenu plugin for @atlaskit/editor-core

25 lines 1.06 kB
import React, { useMemo } from 'react'; import { BlockMenuComponents } from './BlockMenuComponents'; import { BLOCK_MENU_FALLBACKS } from './fallbacks'; import { buildChildrenMap, getSortedTopLevelSections } from './utils'; /** * BlockMenuRenderer orchestrates the rendering of the entire block menu hierarchy */ export var BlockMenuRenderer = function BlockMenuRenderer(_ref) { var allRegisteredComponents = _ref.allRegisteredComponents, _ref$fallbacks = _ref.fallbacks, fallbacks = _ref$fallbacks === void 0 ? BLOCK_MENU_FALLBACKS : _ref$fallbacks; var _useMemo = useMemo(function () { return { childrenMap: buildChildrenMap(allRegisteredComponents), topLevelSections: getSortedTopLevelSections(allRegisteredComponents) }; }, [allRegisteredComponents]), childrenMap = _useMemo.childrenMap, topLevelSections = _useMemo.topLevelSections; return /*#__PURE__*/React.createElement(BlockMenuComponents, { registeredComponents: topLevelSections, childrenMap: childrenMap, fallbacks: fallbacks }); };