__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ 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 { useEffect, useRef, memo } from "@wordpress/element";
import {
InnerBlocks,
BlockControls,
AlignmentToolbar,
} from "@wordpress/block-editor";
import { select } from "@wordpress/data";
/*
* Internal Dependencies
*/
import Style from "./style";
import Inspector from "./inspector";
import { SHAPE_DIVIDER_TOP, SHAPE_DIVIDER_BOTTOM } from "./constants";
import {
BlockProps, ShapeDividerContent, withBlockContext
} from "@essential-blocks/controls";
import defaultAttributes from './attributes';
function Edit(props) {
const {
isSelected,
attributes,
setAttributes,
className,
clientId,
} = props;
const {
blockId,
wrapperAlign,
isWrapperWidth,
classHook,
wrpShapeTopInvert,
wrpShapeBottomInvert,
} = attributes;
// you must declare this variable
const enhancedProps = {
...props,
blockPrefix: 'eb-wrapper',
style: <Style {...props} />
};
const isMount = useRef(null);
useEffect(() => {
// set isMount value
isMount.current = true;
return () => {
isMount.current = false;
};
}, []);
useEffect(() => {
if (!isMount.current) {
setAttributes({ wrpShapeTopInvert: false });
setAttributes({ wrpShapeTopInvert: false });
}
isMount.current = false;
}, [
attributes[`${SHAPE_DIVIDER_TOP}Type`],
attributes[`${SHAPE_DIVIDER_BOTTOM}Type`],
]);
const alignmentClass =
wrapperAlign === "center"
? "eb-wrapper-align-center"
: wrapperAlign === "right"
? "eb-wrapper-align-right"
: "";
return (
<>
{isSelected && <Inspector {...props} />}
<BlockControls>
<AlignmentToolbar
value={wrapperAlign}
onChange={(wrapperAlign) => setAttributes({ wrapperAlign })}
/>
</BlockControls>
<BlockProps.Edit {...enhancedProps}>
<div
className={`eb-parent-wrapper eb-parent-${blockId} ${classHook}`}
>
<div
className={`eb-wrapper-outer ${blockId}${isWrapperWidth ? ` ${alignmentClass}` : ""
}`}
>
{attributes[`${SHAPE_DIVIDER_TOP}Type`] != "" && (
<ShapeDividerContent
position="top"
style={attributes[`${SHAPE_DIVIDER_TOP}Type`]}
negative={wrpShapeTopInvert}
/>
)}
{attributes[`${SHAPE_DIVIDER_BOTTOM}Type`] != "" && (
<ShapeDividerContent
position="bottom"
style={
attributes[`${SHAPE_DIVIDER_BOTTOM}Type`]
}
negative={wrpShapeBottomInvert}
/>
)}
<div className="eb-wrapper-inner">
<div
className={`eb-wrapper-inner-blocks${!isWrapperWidth ? ` ${alignmentClass}` : ""
}`}
>
<InnerBlocks
templateLock={false}
renderAppender={
select(
"core/block-editor"
).getBlockOrder(clientId).length > 0
? undefined
: InnerBlocks.ButtonBlockAppender
}
/>
</div>
</div>
</div>
</div>
</BlockProps.Edit>
</>
);
}
export default memo(withBlockContext(defaultAttributes)(Edit))
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| constants | Folder | 0750 |
|
|
| attributes.js | File | 2.27 KB | 0640 |
|
| deprecated.js | File | 3.85 KB | 0640 |
|
| edit.js | File | 4.26 KB | 0640 |
|
| icon.svg | File | 1.38 KB | 0640 |
|
| index.js | File | 658 B | 0640 |
|
| inspector.js | File | 8.44 KB | 0640 |
|
| save.js | File | 2.16 KB | 0640 |
|
| style.js | File | 7.62 KB | 0640 |
|
| style.scss | File | 132 B | 0640 |
|