Basic support for Mosaico-based email templates.
This commit is contained in:
parent
b5cdf57f72
commit
7b5642e911
38 changed files with 1271 additions and 751 deletions
|
@ -39,7 +39,8 @@ export default class CUD extends Component {
|
|||
this.templateTypes = getTemplateTypes(props.t);
|
||||
|
||||
this.state = {
|
||||
showMergeTagReference: false
|
||||
showMergeTagReference: false,
|
||||
elementInFullscreen: false
|
||||
};
|
||||
|
||||
this.initForm();
|
||||
|
@ -66,7 +67,8 @@ export default class CUD extends Component {
|
|||
namespace: mailtrainConfig.user.namespace,
|
||||
type: mailtrainConfig.editors[0],
|
||||
text: '',
|
||||
html: ''
|
||||
html: '',
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +94,11 @@ export default class CUD extends Component {
|
|||
async submitHandler() {
|
||||
const t = this.props.t;
|
||||
|
||||
if (this.props.entity) {
|
||||
const typeKey = this.getFormValue('type');
|
||||
await this.templateTypes[typeKey].htmlEditorBeforeSave(this);
|
||||
}
|
||||
|
||||
let sendMethod, url;
|
||||
if (this.props.entity) {
|
||||
sendMethod = FormSendMethod.PUT;
|
||||
|
@ -120,6 +127,9 @@ export default class CUD extends Component {
|
|||
}
|
||||
|
||||
async extractPlainText() {
|
||||
const typeKey = this.getFormValue('type');
|
||||
await this.templateTypes[typeKey].htmlEditorBeforeSave(this);
|
||||
|
||||
const html = this.getFormValue('html');
|
||||
if (!html) {
|
||||
alert('Missing HTML content');
|
||||
|
@ -145,6 +155,12 @@ export default class CUD extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
async setElementInFullscreen(elementInFullscreen) {
|
||||
this.setState({
|
||||
elementInFullscreen
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const t = this.props.t;
|
||||
const isEdit = !!this.props.entity;
|
||||
|
@ -241,7 +257,7 @@ export default class CUD extends Component {
|
|||
</div>}
|
||||
</AlignedRow>
|
||||
|
||||
{this.templateTypes[typeKey].form}
|
||||
{this.templateTypes[typeKey].getHTMLEditor(this)}
|
||||
|
||||
<ACEEditor id="text" height="400px" mode="text" label={t('Template content (plain text)')} help={<Trans>To extract the text from HTML click <ActionLink onClickAsync={::this.extractPlainText}>here</ActionLink>. Please note that your existing plaintext in the field above will be overwritten. This feature uses the <a href="http://premailer.dialect.ca/api">Premailer API</a>, a third party service. Their Terms of Service and Privacy Policy apply.</Trans>}/>
|
||||
</div>
|
||||
|
@ -249,7 +265,7 @@ export default class CUD extends Component {
|
|||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={this.state.elementInFullscreen ? styles.withElementInFullscreen : ''}>
|
||||
{canDelete &&
|
||||
<DeleteModalDialog
|
||||
stateOwner={this}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue