| 1 |
import classnames from 'classnames/dedupe'; |
| 2 |
|
| 3 |
import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; |
| 4 |
import { PanelBody, TextControl } from '@wordpress/components'; |
| 5 |
import { applyFilters } from '@wordpress/hooks'; |
| 6 |
import { __ } from '@wordpress/i18n'; |
| 7 |
|
| 8 |
import { getFieldAttributes } from '../../field-attributes'; |
| 9 |
import FieldLabel from '../../field-label'; |
| 10 |
|
| 11 |
/** |
| 12 |
* Block Edit Class. |
| 13 |
* |
| 14 |
* @param props |
| 15 |
*/ |
| 16 |
export default function BlockEdit(props) { |
| 17 |
const { attributes, setAttributes } = props; |
| 18 |
|
| 19 |
const { default: defaultVal } = props; |
| 20 |
|
| 21 |
let { className = '' } = props; |
| 22 |
|
| 23 |
className = classnames( |
| 24 |
'ghostkit-form-field ghostkit-form-field-hidden', |
| 25 |
className |
| 26 |
); |
| 27 |
className = applyFilters('ghostkit.editor.className', className, props); |
| 28 |
|
| 29 |
const blockProps = useBlockProps({ className }); |
| 30 |
|
| 31 |
return ( |
| 32 |
<> |
| 33 |
<InspectorControls> |
| 34 |
<PanelBody> |
| 35 |
<TextControl |
| 36 |
label={__('Value', 'ghostkit')} |
| 37 |
value={defaultVal} |
| 38 |
onChange={(val) => setAttributes({ default: val })} |
| 39 |
/> |
| 40 |
</PanelBody> |
| 41 |
</InspectorControls> |
| 42 |
<div {...blockProps}> |
| 43 |
<FieldLabel {...props} /> |
| 44 |
<TextControl type="text" {...getFieldAttributes(attributes)} /> |
| 45 |
</div> |
| 46 |
</> |
| 47 |
); |
| 48 |
} |
| 49 |
|