diff --git a/config/default.toml b/config/default.toml index 63b08a91..bea73175 100644 --- a/config/default.toml +++ b/config/default.toml @@ -135,8 +135,8 @@ processes=1 [mosaico] # Installed templates templates=[["versafix-1", "Versafix One"]] -# Inject custom scripts from public/mosaico/custom/ -# customscripts=["some-lib.js", "my-mosaico-plugin.js"] +# Inject custom scripts +# customscripts=["/mosaico/custom/my-mosaico-plugin.js"] [grapejs] # Installed templates diff --git a/routes/editorapi.js b/routes/editorapi.js index f6b4d560..fd85bc73 100644 --- a/routes/editorapi.js +++ b/routes/editorapi.js @@ -417,37 +417,32 @@ let parseGrapejsMultipartTestForm = (req, res, next) => { }; router.post('/test', parseGrapejsMultipartTestForm, passport.csrfProtection, (req, res) => { + let sendError = err => { + if (req.query.editor === 'grapejs') { + res.status(500).json({ + errors: err.message || err + }); + } else { + res.status(500).send(err.message || err); + } + }; + prepareHtml({ editorName: req.query.editor, html: req.body.html }, (err, html) => { if (err) { - req.query.editor === 'grapejs' ? - res.status(500).json({ - errors: err.message || err - }) : - res.status(500).send(err.message || err); - return; + return sendError(err); } settings.list(['defaultAddress', 'defaultFrom'], (err, configItems) => { if (err) { - req.query.editor === 'grapejs' ? - res.status(500).json({ - errors: err.message || err - }) : - res.status(500).send(err.message || err); - return; + return sendError(err); } mailer.getMailer((err, transport) => { if (err) { - req.query.editor === 'grapejs' ? - res.status(500).json({ - errors: err.message || err - }) : - res.status(500).send(err.message || err); - return; + return sendError(err); } let opts = { @@ -465,12 +460,7 @@ router.post('/test', parseGrapejsMultipartTestForm, passport.csrfProtection, (re transport.sendMail(opts, (err, info) => { if (err) { - req.query.editor === 'grapejs' ? - res.status(500).json({ - errors: err.message || err - }) : - res.status(500).send(err.message || err); - return; + return sendError(err); } req.query.editor === 'grapejs' ? diff --git a/views/grapejs/editor.hbs b/views/grapejs/editor.hbs index d9595ad8..f6203b1a 100644 --- a/views/grapejs/editor.hbs +++ b/views/grapejs/editor.hbs @@ -19,6 +19,9 @@ } #toast-container { + top: auto !important; + bottom: 5px; + right: 325px; font-size: 13px; font-weight: lighter; } @@ -177,7 +180,7 @@ var encodedSrc = (s && s[1]) || encodeURIComponent(src); var dynamicSrc = '/editorapi/img?src=' + encodedSrc + '&method=resize¶ms=' + $(this).width() + '%2C' + $(this).height(); imgs.push({ - cls: $(this).attr('class'), + cls: $(this).attr('class').split(' ')[0], dynamicSrc: dynamicSrc, src: src, }); @@ -245,10 +248,12 @@ statusFormElC.style.opacity = '0'; statusFormEl.removeAttribute('data-tooltip'); md.close(); + toastr.success('Testmail sent'); } else if (res.errors) { statusFormEl.className = 'fa fa-exclamation-circle'; statusFormEl.setAttribute('data-tooltip', res.errors); statusFormElC.className = 'form-status text-danger'; + toastr.error(res.errors); } }); @@ -357,9 +362,10 @@ }, null, 'html') .success(function() { window.bridge.lastSavedHtml = html; + toastr.success('Sucessfully saved'); }) .fail(function(data) { - alert(data.responseText || 'An error occured while saving the document'); + toastr.error(data.responseText || 'An error occured while saving the document'); }) .always(function() { setTimeout(function() { diff --git a/views/mosaico/layout-editor.hbs b/views/mosaico/layout-editor.hbs index 4787f670..175be4cf 100644 --- a/views/mosaico/layout-editor.hbs +++ b/views/mosaico/layout-editor.hbs @@ -25,7 +25,7 @@ {{#if editorConfig.customscripts}} {{#each editorConfig.customscripts}} - + {{/each}} {{/if}}