UNPKG

@lobehub/editor

Version:

A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.

27 lines 1.03 kB
import { computePosition, flip, offset, shift } from '@floating-ui/dom'; export var updatePosition = function updatePosition(_ref) { var floating = _ref.floating, _ref$placement = _ref.placement, placement = _ref$placement === void 0 ? 'bottom-start' : _ref$placement, reference = _ref.reference, _ref$offset = _ref.offset, offsetNumber = _ref$offset === void 0 ? 8 : _ref$offset, callback = _ref.callback; if (!reference || !floating) return; return computePosition(reference, floating, { middleware: [offset(offsetNumber), flip(), shift()], placement: placement }).then(function (props) { if (!floating) return false; var x = props.x, y = props.y; floating.style.left = "".concat(x, "px"); floating.style.top = "".concat(y, "px"); callback === null || callback === void 0 || callback(props); }); }; export var cleanPosition = function cleanPosition(floating) { if (!floating) return false; floating.style.left = '-9999px'; floating.style.top = '-9999px'; };