@lobehub/editor
Version:
A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.
56 lines (55 loc) • 1.79 kB
JavaScript
'use client';
var _templateObject;
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
import { Dropdown } from '@lobehub/ui';
import { createStaticStyles } from 'antd-style';
import { useCallback } from 'react';
import { jsx as _jsx } from "react/jsx-runtime";
var styles = createStaticStyles(function (_ref) {
var css = _ref.css;
return {
menu: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: fixed;\n z-index: 9999;\n "])))
};
});
var DefaultSlashMenu = function DefaultSlashMenu(_ref2) {
var activeKey = _ref2.activeKey,
anchorClassName = _ref2.anchorClassName,
loading = _ref2.loading,
onSelect = _ref2.onSelect,
open = _ref2.open,
options = _ref2.options,
position = _ref2.position,
_onClose = _ref2.onClose;
var handleMenuClick = useCallback(function (_ref3) {
var key = _ref3.key;
var option = options.find(function (item) {
return 'key' in item && item.key === key;
});
if (option) onSelect(option);
}, [options, onSelect]);
return /*#__PURE__*/_jsx("div", {
className: styles.menu,
style: {
left: position.x,
top: position.y
},
children: /*#__PURE__*/_jsx(Dropdown, {
menu: {
// @ts-ignore
activeKey: activeKey,
items: loading ? [{
disabled: true,
key: 'loading',
label: 'Loading...'
}] : options,
onClick: handleMenuClick
},
open: open,
children: /*#__PURE__*/_jsx("span", {
className: anchorClassName
})
})
});
};
DefaultSlashMenu.displayName = 'DefaultSlashMenu';
export default DefaultSlashMenu;