UNPKG

@wordpress/editor

Version:
49 lines (48 loc) 1.31 kB
// packages/editor/src/components/collab-sidebar/rich-text-control/format-edit.tsx import { getActiveFormat, getActiveObject } from "@wordpress/rich-text"; import { jsx } from "react/jsx-runtime"; import { createElement } from "react"; var EMPTY_CONTEXT = {}; function Edit({ onChange, onFocus, value, forwardedRef, settings, isVisible }) { const { name, edit: EditFunction } = settings; if (!EditFunction) { return null; } const activeFormat = getActiveFormat(value, name); const isActive = activeFormat !== void 0; const activeObject = getActiveObject(value); const isObjectActive = activeObject !== void 0 && activeObject.type === name; return /* @__PURE__ */ jsx( EditFunction, { isActive, isVisible, activeAttributes: isActive ? activeFormat.attributes || {} : {}, isObjectActive, activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {}, value, onChange, onFocus, contentRef: forwardedRef, context: EMPTY_CONTEXT }, name ); } function FormatEdit({ formatTypes, ...props }) { return formatTypes.map((settings) => /* @__PURE__ */ createElement(Edit, { settings, ...props, key: settings.name })); } export { FormatEdit as default }; //# sourceMappingURL=format-edit.mjs.map