Apply nl2br attribute within rendered custom html
[MAILPOET-2462]
This commit is contained in:
committed by
Pavel Dohnal
parent
ece2b2ab55
commit
e49d456e77
@@ -4,7 +4,7 @@ import {
|
|||||||
PanelBody,
|
PanelBody,
|
||||||
TextareaControl,
|
TextareaControl,
|
||||||
ToggleControl,
|
ToggleControl,
|
||||||
SandBox
|
SandBox,
|
||||||
} from '@wordpress/components';
|
} from '@wordpress/components';
|
||||||
import { InspectorControls } from '@wordpress/block-editor';
|
import { InspectorControls } from '@wordpress/block-editor';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
@@ -32,11 +32,13 @@ const CustomHtmlEdit = ({ attributes, setAttributes }) => {
|
|||||||
|
|
||||||
</InspectorControls>
|
</InspectorControls>
|
||||||
);
|
);
|
||||||
|
const styles = attributes.nl2br ? ['body { white-space: pre-line; }'] : [];
|
||||||
|
const key = `${attributes.content}_${styles}`;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{inspectorControls}
|
{inspectorControls}
|
||||||
<div>
|
<div>
|
||||||
<SandBox html={attributes.content} key={attributes.content} />
|
<SandBox html={attributes.content} styles={styles} key={key} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user