import { BaseControl, CheckboxControl, TextControl, PanelBody, } from '@wordpress/components'; import { useEffect, useRef, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { AttributesPropsAndSetter } from '../../types'; import { SeeMoreSelect } from './SeeMoreSelect'; export const HeightPanel = ({ attributes, setAttributes, }: AttributesPropsAndSetter) => { const [editorHeight, setEditorHeight] = useState( attributes?.editorHeight ?? false, ); const [enableMaxHeight, setEnableMaxHeight] = useState( attributes?.enableMaxHeight ?? false, ); const [seeMoreString, setSeeMoreString] = useState( attributes?.seeMoreString ?? '', ); const [seeMoreAfterLine, setSeeMoreAfterLine] = useState( attributes?.seeMoreAfterLine ?? '', ); const [seeMoreTransition, setSeeMoreTransition] = useState( attributes?.seeMoreTransition ?? false, ); const open = useRef(Number(attributes?.editorHeight) > 0); useEffect(() => { setAttributes({ editorHeight, seeMoreString, seeMoreAfterLine, seeMoreTransition, enableMaxHeight, }); }, [ editorHeight, seeMoreString, seeMoreAfterLine, seeMoreTransition, setAttributes, enableMaxHeight, ]); return ( {enableMaxHeight && ( <> { setAttributes({ seeMoreType }); }} /> )} ); };