Apply nl2br attribute within rendered custom html

[MAILPOET-2462]
This commit is contained in:
Rostislav Wolny
2019-12-11 14:44:54 +01:00
committed by Pavel Dohnal
parent ece2b2ab55
commit e49d456e77

View File

@@ -4,7 +4,7 @@ import {
PanelBody,
TextareaControl,
ToggleControl,
SandBox
SandBox,
} from '@wordpress/components';
import { InspectorControls } from '@wordpress/block-editor';
import PropTypes from 'prop-types';
@@ -32,11 +32,13 @@ const CustomHtmlEdit = ({ attributes, setAttributes }) => {
</InspectorControls>
);
const styles = attributes.nl2br ? ['body { white-space: pre-line; }'] : [];
const key = `${attributes.content}_${styles}`;
return (
<>
{inspectorControls}
<div>
<SandBox html={attributes.content} key={attributes.content} />
<SandBox html={attributes.content} styles={styles} key={key} />
</div>
</>
);