@wordpress/block-editor
Version:
44 lines (42 loc) • 1.17 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = FormatEdit;
var _richText = require("@wordpress/rich-text");
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
function FormatEdit({
formatTypes,
onChange,
onFocus,
value,
forwardedRef
}) {
return formatTypes.map(settings => {
const {
name,
edit: Edit
} = settings;
if (!Edit) {
return null;
}
const activeFormat = (0, _richText.getActiveFormat)(value, name);
const isActive = activeFormat !== undefined;
const activeObject = (0, _richText.getActiveObject)(value);
const isObjectActive = activeObject !== undefined && activeObject.type === name;
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Edit, {
isActive: isActive,
activeAttributes: isActive ? activeFormat.attributes || {} : {},
isObjectActive: isObjectActive,
activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
value: value,
onChange: onChange,
onFocus: onFocus,
contentRef: forwardedRef
}, name);
});
}
//# sourceMappingURL=format-edit.js.map
;