__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
/**
* WordPress dependencies
*/
import { __ } from "@wordpress/i18n";
import { memo } from "@wordpress/element";
/**
* Internal dependencies
*/
import {
BlockProps,
withBlockContext
} from "@essential-blocks/controls";
import InfoboxContainer from "./components/infobox-edit";
import Inspector from "./inspector";
import Style from "./style";
import defaultAttributes from './attributes';
import { useEffect } from "react";
function Edit(props) {
const {
attributes,
setAttributes,
isSelected,
} = props;
const {
enableTitle,
showMedia,
iconView,
iconShape,
layoutPreset,
flexDirection,
contentAlignment,
mediaAlignSelf,
contentsAlignment,
mediaAlignment,
btnAlign,
version,
imageUrl,
imageUrlOld,
imageAlt,
imageAltOld
} = attributes;
// Handle imageUrlOld fallback logic
const finalImageUrl = imageUrlOld || imageUrl;
const finalImageAlt = imageAltOld || imageAlt;
// Create updated attributes object with fallback values
const updatedAttributes = {
...attributes,
imageUrl: finalImageUrl,
imageAlt: finalImageAlt,
};
// you must declare this variable
const enhancedProps = {
...props,
blockPrefix: 'eb-infobox',
style: <Style {...props} />
};
useEffect(() => {
if (enableTitle === undefined) {
setAttributes({ enableTitle: true });
}
if (showMedia === undefined) {
setAttributes({ showMedia: true });
}
if (iconView === undefined) {
setAttributes({ iconView: 'default' });
}
if (iconShape === undefined) {
setAttributes({ iconShape: 'circle' });
}
if (flexDirection === undefined) {
setAttributes({ flexDirection: 'column' });
}
if (contentAlignment === undefined) {
setAttributes({ contentAlignment: 'center' });
}
if (mediaAlignSelf === undefined) {
setAttributes({ mediaAlignSelf: 'center' });
}
if (contentsAlignment === undefined) {
setAttributes({ contentsAlignment: 'center' });
}
if (mediaAlignment === undefined) {
setAttributes({ mediaAlignment: 'center' });
}
if (btnAlign === undefined) {
setAttributes({ btnAlign: 'center' });
}
if (!version || version == "1") {
setAttributes({ version: "2" });
}
// Handle imageUrlOld migration
if (imageUrlOld && (!imageUrl || imageUrl === '')) {
setAttributes({ imageUrl: imageUrlOld });
}
}, [])
return (
<>
{isSelected && (
<Inspector
attributes={updatedAttributes}
setAttributes={setAttributes}
/>
)}
<BlockProps.Edit {...enhancedProps}>
<InfoboxContainer
setAttributes={setAttributes}
attributes={updatedAttributes}
/>
</BlockProps.Edit>
</>
);
}
export default memo(withBlockContext(defaultAttributes)(Edit))
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| components | Folder | 0750 |
|
|
| constants | Folder | 0750 |
|
|
| attributes.js | File | 10.87 KB | 0640 |
|
| deprecated.js | File | 25.82 KB | 0640 |
|
| edit.js | File | 3.23 KB | 0640 |
|
| example.js | File | 149 B | 0640 |
|
| frontend.js | File | 3.13 KB | 0640 |
|
| icon.svg | File | 1.13 KB | 0640 |
|
| index.js | File | 734 B | 0640 |
|
| inspector.js | File | 57.79 KB | 0640 |
|
| save.js | File | 1.42 KB | 0640 |
|
| style.css | File | 1.2 KB | 0640 |
|
| style.js | File | 20.26 KB | 0640 |
|
| style.scss | File | 1.43 KB | 0640 |
|