@wordpress/block-editor
Version:
40 lines (39 loc) • 1.08 kB
JavaScript
// packages/block-editor/src/components/rich-text/native/format-edit.js
import { getActiveFormat, getActiveObject } from "@wordpress/rich-text";
import { jsx } from "react/jsx-runtime";
function FormatEdit({
formatTypes,
onChange,
onFocus,
value,
forwardedRef
}) {
return formatTypes.map((settings) => {
const { name, edit: Edit } = settings;
if (!Edit) {
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(
Edit,
{
isActive,
activeAttributes: isActive ? activeFormat.attributes || {} : {},
isObjectActive,
activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
value,
onChange,
onFocus,
contentRef: forwardedRef
},
name
);
});
}
export {
FormatEdit as default
};
//# sourceMappingURL=format-edit.js.map