diff --git a/assets/js/src/form_editor/blocks/custom_textarea/custom_field_settings.jsx b/assets/js/src/form_editor/blocks/custom_textarea/custom_field_settings.jsx deleted file mode 100644 index bd1c262eda..0000000000 --- a/assets/js/src/form_editor/blocks/custom_textarea/custom_field_settings.jsx +++ /dev/null @@ -1,78 +0,0 @@ -import React, { useState } from 'react'; -import { - SelectControl, -} from '@wordpress/components'; -import PropTypes from 'prop-types'; -import MailPoet from 'mailpoet'; - -import CustomTextSettings from '../custom_text/custom_field_settings.jsx'; - -const CustomFieldSettings = ({ - mandatory, - validate, - lines, - isSaving, - onSave, -}) => { - const [localLines, setLocalLines] = useState(lines); - - return ( - <> - { - onSave({ - ...customTextParams, - lines: localLines, - }); - }} - /> - - - ); -}; - -CustomFieldSettings.propTypes = { - mandatory: PropTypes.bool, - validate: PropTypes.string, - lines: PropTypes.string, - onSave: PropTypes.func.isRequired, - isSaving: PropTypes.bool, -}; - -CustomFieldSettings.defaultProps = { - mandatory: false, - validate: '', - lines: '1', - isSaving: false, -}; - -export default CustomFieldSettings; diff --git a/assets/js/src/form_editor/blocks/custom_textarea/edit.jsx b/assets/js/src/form_editor/blocks/custom_textarea/edit.jsx index 332b33c841..a711c2abb0 100644 --- a/assets/js/src/form_editor/blocks/custom_textarea/edit.jsx +++ b/assets/js/src/form_editor/blocks/custom_textarea/edit.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { Panel, - PanelBody, + PanelBody, SelectControl, TextControl, ToggleControl, } from '@wordpress/components'; @@ -10,7 +10,7 @@ import PropTypes from 'prop-types'; import MailPoet from 'mailpoet'; import { useDispatch, useSelect } from '@wordpress/data'; -import CustomFieldSettings from './custom_field_settings.jsx'; +import CustomFieldSettings from '../custom_text/custom_field_settings.jsx'; import formatLabel from '../label_formatter.jsx'; const CustomTextAreaEdit = ({ attributes, setAttributes }) => { @@ -58,6 +58,33 @@ const CustomTextAreaEdit = ({ attributes, setAttributes }) => { checked={attributes.labelWithinInput} onChange={(labelWithinInput) => (setAttributes({ labelWithinInput }))} /> + (setAttributes({ lines }))} + /> diff --git a/assets/js/src/form_editor/store/blocks_to_form_body.jsx b/assets/js/src/form_editor/store/blocks_to_form_body.jsx index a5eda78302..2d1b713571 100644 --- a/assets/js/src/form_editor/store/blocks_to_form_body.jsx +++ b/assets/js/src/form_editor/store/blocks_to_form_body.jsx @@ -38,6 +38,9 @@ const mapCustomField = (block, customFields, mappedCommonProperties) => { if (has(block.attributes, 'dateType')) { mapped.params.date_type = block.attributes.dateType; } + if (has(block.attributes, 'lines')) { + mapped.params.lines = block.attributes.lines; + } if (has(block.attributes, 'dateFormat')) { mapped.params.date_format = block.attributes.dateFormat; } diff --git a/assets/js/src/form_editor/store/form_body_to_blocks.jsx b/assets/js/src/form_editor/store/form_body_to_blocks.jsx index 9a0802c3f8..ad43e4e825 100644 --- a/assets/js/src/form_editor/store/form_body_to_blocks.jsx +++ b/assets/js/src/form_editor/store/form_body_to_blocks.jsx @@ -25,6 +25,9 @@ const mapCustomField = (item, customFields, mappedCommonProperties) => { if (has(item.params, 'hide_label')) { mapped.attributes.hideLabel = !!item.params.hide_label; } + if (has(item.params, 'lines')) { + mapped.attributes.lines = item.params.lines; + } if (has(item.params, 'date_type')) { mapped.attributes.dateType = item.params.date_type; }