// import { useState, useEffect } from '@wordpress/element'; // import { Button } from '@wordpress/components'; // import './editor.scss'; // const Advertisement = ( { attributes, setAttributes } ) => { // const [ adContents, setAdContents ] = useState( // attributes.adContents || [ '' ] // ); // const [ expandedAds, setExpandedAds ] = useState( [ 0 ] ); // useEffect( () => { // setAdContents( attributes.adContents || [ '' ] ); // }, [ attributes.adContents ] ); // const handleAddAdContent = () => { // const newAdContents = [ ...adContents, '' ]; // setAdContents( newAdContents ); // setAttributes( { adContents: newAdContents } ); // setExpandedAds( [ newAdContents.length - 1 ] ); // Automatically expand the newly added ad // }; // const handleAdContentChange = ( value, index ) => { // const newAdContents = [ ...adContents ]; // newAdContents[ index ] = value; // setAdContents( newAdContents ); // setAttributes( { adContents: newAdContents } ); // }; // const handleRemoveAdContent = ( index ) => { // const newAdContents = adContents.filter( ( _, i ) => i !== index ); // setAdContents( newAdContents ); // setAttributes( { adContents: newAdContents } ); // setExpandedAds( [] ); // Collapse all ads if one is removed // }; // const toggleExpandAd = ( index ) => { // if ( expandedAds.includes( index ) ) { // setExpandedAds( [] ); // } else { // setExpandedAds( [ index ] ); // } // }; // const onDragEnd = ( result ) => { // const { source, destination } = result; // if ( ! destination ) { // return; // } // const reorderedItems = Array.from( adContents ); // const [ sourceItem ] = reorderedItems.splice( source.index, 1 ); // reorderedItems.splice( destination.index, 0, sourceItem ); // setAttributes( { adContents: reorderedItems } ); // setAdContents( reorderedItems ); // }; // return ( // // // { ( provided ) => ( //
// { adContents.map( ( content, index ) => ( // // { ( provided ) => ( //
//
//
{ `${ // index + 1 // }. Ads` }
//
// // toggleExpandAd( index ) // } // > // { expandedAds.includes( // index // ) ? ( // // ) : ( // // ) } // // //
//
// { expandedAds.includes( index ) && ( //
//
//
// { // handleAdContentChange( // value, // index // ); // } } // className="sp-smart-post-ad-textarea" // /> //
//
// ) } //
// ) } //
// ) ) } // { provided.placeholder } // //
// ) } //
//
// ); // }; // export default Advertisement;