Add automatic nl2br switch to custom html settings
[MAILPOET-2462]
This commit is contained in:
committed by
Pavel Dohnal
parent
a577680122
commit
906307a2c7
@@ -14,6 +14,10 @@ export const settings = {
|
||||
type: 'string',
|
||||
default: MailPoet.I18n.t('blockCustomHtmlDefault'),
|
||||
},
|
||||
nl2br: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
supports: {
|
||||
html: false,
|
||||
|
@@ -3,6 +3,7 @@ import {
|
||||
Panel,
|
||||
PanelBody,
|
||||
TextareaControl,
|
||||
ToggleControl,
|
||||
} from '@wordpress/components';
|
||||
import { InspectorControls } from '@wordpress/block-editor';
|
||||
import PropTypes from 'prop-types';
|
||||
@@ -20,6 +21,11 @@ const CustomHtmlEdit = ({ attributes, setAttributes }) => {
|
||||
rows={4}
|
||||
onChange={(content) => setAttributes({ content })}
|
||||
/>
|
||||
<ToggleControl
|
||||
label={MailPoet.I18n.t('blockCustomHtmlNl2br')}
|
||||
checked={attributes.nl2br}
|
||||
onChange={(nl2br) => (setAttributes({ nl2br }))}
|
||||
/>
|
||||
</PanelBody>
|
||||
</Panel>
|
||||
|
||||
|
@@ -92,6 +92,7 @@ export default (blocks) => {
|
||||
static: '0',
|
||||
params: {
|
||||
text: block.attributes && block.attributes.content ? block.attributes.content : '',
|
||||
nl2br: block.attributes && block.attributes.nl2br ? '1' : '0',
|
||||
},
|
||||
};
|
||||
default:
|
||||
|
@@ -75,6 +75,7 @@ export default (data) => {
|
||||
name: 'mailpoet-form/custom-html',
|
||||
attributes: {
|
||||
content: item.params && item.params.text ? item.params.text : '',
|
||||
nl2br: item.params && item.params.nl2br ? !!item.params.nl2br : false,
|
||||
},
|
||||
};
|
||||
default:
|
||||
|
Reference in New Issue
Block a user