/** * Retrieves the translation of text. * * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-i18n/ */ import { __ } from '@wordpress/i18n'; /** * React hook that is used to mark the block wrapper element. * It provides all the necessary props like the class name. * * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops */ import { useBlockProps, InnerBlocks, InspectorControls } from '@wordpress/block-editor'; import { SelectControl, BaseControl, ToggleControl,__experimentalUnitControl as UnitControl } from '@wordpress/components'; import { useState, useEffect } from 'react'; /** * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files. * Those files can contain any CSS code that gets applied to the editor. * * @see https://www.npmjs.com/package/@wordpress/scripts#using-css */ import './editor.scss'; /** * The edit function describes the structure of your block in the context of the * editor. This represents what the editor will render when the block is used. * * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit * * @return {Element} Element to render. */ export default function Edit({ attributes, setAttributes }) { const [isIndependentLarge, setIsIndependentLarge] = useState(false); const [paddingTop, setPaddingTop] = useState('10px'); const [paddingRight, setPaddingRight] = useState('10px'); const [paddingBottom, setPaddingBottom] = useState('10px'); const [paddingLeft, setPaddingLeft] = useState('10px'); const { sticky } = attributes; // Block props for the outer block const blockProps = useBlockProps(); // Handle the change of the sticky attribute const handleStickyChange = (value) => { setAttributes({ sticky: value }); }; const handleToggleChange = () => { setIsIndependentLarge(!isIndependentLarge); }; const updatePaddingForAllSizes = (newValue) => { const newPadding = { extraLarge: { top: newValue, right: newValue, bottom: newValue, left: newValue }, large: { top: newValue, right: newValue, bottom: newValue, left: newValue }, medium: { top: newValue, right: newValue, bottom: newValue, left: newValue }, small: { top: newValue, right: newValue, bottom: newValue, left: newValue } }; // Update the padding attribute with the new padding object setAttributes({ padding: newPadding }); }; return (