import { useEffect, useMemo } from "@wordpress/element"; import { RichText, useBlockProps } from "@wordpress/block-editor"; import InspectorControl from "../../components/inspectorControls/inspectorControls"; import { panelBodyRightIcon, panelBodyTitleIcon, SectionNineteenImage } from "../../icons/icons"; import { jsonStringify } from "../shared/helpFn"; import dynamicCssFn from "./dynamicCss"; import Inspector from "./inspector"; import HeadingWrapper from "./headingWrapper"; import { googleFonts, useDeviceType } from "../../controls/controls"; import classNames from "classnames"; import addInitialAttr from "../shared/addInitialAttr"; import { compose } from "@wordpress/compose"; const SectionHeadingEdit = ({ attributes, setAttributes }) => { const { uniqueId, showSectionHeading, fontListsEditPage, sectionHeadingLabel, sectionHeadingLinkUrl, sectionHeadingStyle, sectionHeadingStyleBackgroundColor, sectionHeadingHTMLTag: HeadingTag, showSubHeading, sectionSubHeadingAliment, subHeadingLabel, additionalCssClass, customCss, sectionHeadingTypography, sectionSubHeadingTypography, sectionHeadingGlobalTypo, sectionSubHeadingGlobalTypography, } = attributes; const googleFontLists = [sectionHeadingTypography, sectionSubHeadingTypography]; useEffect(() => { setAttributes({ fontLists: jsonStringify(googleFonts(googleFontLists, "frontend")), fontListsEditPage: googleFonts(googleFontLists), }); }, googleFontLists); const deviceType = useDeviceType(); const blockStyling = useMemo(() => dynamicCssFn(attributes, deviceType), [attributes, deviceType]); const blockProps = useBlockProps(); const className = classNames("sp-section-heading-container", sectionHeadingStyle); const renderSectionNineteenImage = sectionHeadingStyle === "section-heading-nineteen" && ( ); return (
{showSectionHeading && (
setAttributes({ sectionHeadingLabel: newValue, }) } contentEditable={true} /> {renderSectionNineteenImage}
{showSubHeading && (
setAttributes({ subHeadingLabel: newValue, }) } />
)}
)}
); }; export default compose(addInitialAttr)(SectionHeadingEdit);