| 1 |
import classnames from 'classnames/dedupe'; |
| 2 |
|
| 3 |
import { |
| 4 |
InnerBlocks, |
| 5 |
useBlockProps, |
| 6 |
useInnerBlocksProps, |
| 7 |
} from '@wordpress/block-editor'; |
| 8 |
import { useSelect } from '@wordpress/data'; |
| 9 |
import { applyFilters } from '@wordpress/hooks'; |
| 10 |
|
| 11 |
/** |
| 12 |
* Block Edit Class. |
| 13 |
* |
| 14 |
* @param props |
| 15 |
*/ |
| 16 |
export default function BlockEdit(props) { |
| 17 |
const { attributes, clientId } = props; |
| 18 |
let { className } = attributes; |
| 19 |
|
| 20 |
const hasChildBlocks = useSelect( |
| 21 |
(select) => { |
| 22 |
const blockEditor = select('core/block-editor'); |
| 23 |
|
| 24 |
return blockEditor |
| 25 |
? blockEditor.getBlockOrder(clientId).length > 0 |
| 26 |
: false; |
| 27 |
}, |
| 28 |
[clientId] |
| 29 |
); |
| 30 |
|
| 31 |
className = classnames(className, 'ghostkit-carousel-slide'); |
| 32 |
|
| 33 |
className = applyFilters('ghostkit.editor.className', className, props); |
| 34 |
|
| 35 |
const blockProps = useBlockProps({ className }); |
| 36 |
const innerBlockProps = useInnerBlocksProps(blockProps, { |
| 37 |
renderAppender: hasChildBlocks |
| 38 |
? undefined |
| 39 |
: InnerBlocks.ButtonBlockAppender, |
| 40 |
templateLock: false, |
| 41 |
}); |
| 42 |
|
| 43 |
return <div {...innerBlockProps} />; |
| 44 |
} |
| 45 |
|