deprecated
2 months ago
block.json
1 month ago
edit.js
2 months ago
icon.svg
2 months ago
index.js
2 months ago
index.php
2 months ago
save.js
2 months ago
style.scss
3 days ago
transforms.js
2 months ago
edit.js
53 lines
| 1 | import { PanelBody, PanelRow } from '@wordpress/components'; |
| 2 | import { |
| 3 | RichText, |
| 4 | InnerBlocks, |
| 5 | InspectorControls, |
| 6 | useBlockProps, |
| 7 | } from '@wordpress/block-editor'; |
| 8 | import { __ } from '@wordpress/i18n'; |
| 9 | |
| 10 | export default function FAQEdit({ attributes, setAttributes }) { |
| 11 | let massage; |
| 12 | // eslint-disable-next-line no-undef |
| 13 | if (vk_blocks_check.is_pro) { |
| 14 | massage = __( |
| 15 | 'If you want to be collapsing this block, you can set it at Setting > VK Blocks', |
| 16 | 'vk-blocks' |
| 17 | ); |
| 18 | } else { |
| 19 | massage = __( |
| 20 | 'You can be collapsing this block at VK Blocks Pro', |
| 21 | 'vk-blocks' |
| 22 | ); |
| 23 | } |
| 24 | const { heading, content } = attributes; |
| 25 | const TEMPLATE = [['core/paragraph', { content }]]; |
| 26 | |
| 27 | const blockProps = useBlockProps({ |
| 28 | className: `vk_faq [accordion_trigger_switch]`, |
| 29 | }); |
| 30 | |
| 31 | return ( |
| 32 | <> |
| 33 | <InspectorControls> |
| 34 | <PanelBody title={__('Accordion Setting', 'vk-blocks')}> |
| 35 | <PanelRow>{massage}</PanelRow> |
| 36 | </PanelBody> |
| 37 | </InspectorControls> |
| 38 | <dl {...blockProps}> |
| 39 | <RichText |
| 40 | tagName="dt" |
| 41 | className={'vk_faq_title'} |
| 42 | onChange={(value) => setAttributes({ heading: value })} |
| 43 | value={heading} |
| 44 | placeholder={__('Please enter a question.', 'vk-blocks')} |
| 45 | /> |
| 46 | <dd className={`vk_faq_content`}> |
| 47 | <InnerBlocks template={TEMPLATE} /> |
| 48 | </dd> |
| 49 | </dl> |
| 50 | </> |
| 51 | ); |
| 52 | } |
| 53 |