diff --git a/client/src/templates/helpers.js b/client/src/templates/helpers.js index 1b2e335d..de53ed33 100644 --- a/client/src/templates/helpers.js +++ b/client/src/templates/helpers.js @@ -700,7 +700,7 @@ export function getEditForm(owner, typeKey, prefix = '') { height="400px" mode="text" label={t('templateContentPlainText')} - help={To extract the text from HTML click here. Please note that your existing plaintext in the field above will be overwritten. This feature uses the Premailer API, a third party service. Their Terms of Service and Privacy Policy apply.} + help={To extract the text from HTML click here. Please note that your existing plaintext in the field above will be overwritten.} /> ); diff --git a/locales/de-DE/common.json b/locales/de-DE/common.json index 53d7aac5..0802c0da 100644 --- a/locales/de-DE/common.json +++ b/locales/de-DE/common.json @@ -955,7 +955,7 @@ "contentOfAnRssEntry": "Inhalt eines RSS Eintrag", "rssEntrySummary": "RSS Eintrag Zusammenfassung", "rssEntryImageUrl": "RSS Eintrag Bild URL", - "toExtractTheTextFromHtmlClickHerePlease": "<1>Hier klicken den Text aus dem HTML zu extrahieren. Hinweis: der bestehende Klartext wird überschrieben. Dieses Feature nutzt die <3>Premailer API. Es gelten die Datenschutzbestimmungen des Anbieters.", + "toExtractTheTextFromHtmlClickHerePlease": "<1>Hier klicken den Text aus dem HTML zu extrahieren. Hinweis: der bestehende Klartext wird überschrieben.", "mosaicoTemplateUpdated": "Mosaico Vorlage aktualisiert", "mosaicoTemplateCreated": "Mosaico Vorlage erstellt", "deletingMosaicoTemplate": "Mosaico Vorlage wird gelöscht ...", diff --git a/locales/en-US/common.json b/locales/en-US/common.json index eb9915ee..215b703a 100644 --- a/locales/en-US/common.json +++ b/locales/en-US/common.json @@ -961,7 +961,7 @@ "contentOfAnRssEntry": "Content of an RSS entry", "rssEntrySummary": "RSS entry summary", "rssEntryImageUrl": "RSS entry image URL", - "toExtractTheTextFromHtmlClickHerePlease": "To extract the text from HTML click <1>here. Please note that your existing plaintext in the field above will be overwritten. This feature uses the <3>Premailer API, a third party service. Their Terms of Service and Privacy Policy apply.", + "toExtractTheTextFromHtmlClickHerePlease": "To extract the text from HTML click <1>here. Please note that your existing plaintext in the field above will be overwritten.", "mosaicoTemplateUpdated": "Mosaico template updated", "mosaicoTemplateCreated": "Mosaico template created", "deletingMosaicoTemplate": "Deleting Mosaico template ...", diff --git a/locales/es-ES/common.json b/locales/es-ES/common.json index a0c072af..a7fe842d 100644 --- a/locales/es-ES/common.json +++ b/locales/es-ES/common.json @@ -985,7 +985,7 @@ "contentOfAnRssEntry": "Contenido de la entrada RSS", "rssEntrySummary": "Resumen de la entrada RSS", "rssEntryImageUrl": "Enlace a la imágen RSS", - "toExtractTheTextFromHtmlClickHerePlease": "To extract the text from HTML click <1>here. Please note that your existing plaintext in the field above will be overwritten. This feature uses the <3>Premailer API, a third party service. Their Terms of Service and Privacy Policy apply.", + "toExtractTheTextFromHtmlClickHerePlease": "To extract the text from HTML click <1>here. Please note that your existing plaintext in the field above will be overwritten.", "mosaicoTemplateUpdated": "Plantilla Mosaico actualizada", "mosaicoTemplateCreated": "Plantilla Mosaico creada", "deletingMosaicoTemplate": "Borrando plantilla Mosaico ...", diff --git a/locales/fr-FR/common.json b/locales/fr-FR/common.json index 8c7bff85..a7dbe39f 100644 --- a/locales/fr-FR/common.json +++ b/locales/fr-FR/common.json @@ -956,7 +956,7 @@ "contentOfAnRssEntry": "Contenu d'une entrée RSS", "rssEntrySummary": "Résumé de l'entrée RSS", "rssEntryImageUrl": "URL de l'image d'entrée RSS", - "toExtractTheTextFromHtmlClickHerePlease": "Pour extraire le texte de HTML, cliquez <1> ici . Veuillez noter que votre texte en clair existant dans le champ ci-dessus sera écrasé. Cette fonctionnalité utilise l '<3> API Premailer , un service tiers. Leurs conditions d'utilisation et leur politique de confidentialité s'appliquent. ", + "toExtractTheTextFromHtmlClickHerePlease": "Pour extraire le texte de HTML, cliquez <1> ici . Veuillez noter que votre texte en clair existant dans le champ ci-dessus sera écrasé.", "mosaicoTemplateUpdated": "Modèle Mosaico mis à jour", "mosaicoTemplateCreated": "Modèle Mosaico créé", "deletingMosaicoTemplate": "Suppression du modèle Mosaico ...", diff --git a/locales/pt-BR/common.json b/locales/pt-BR/common.json index 19254c1d..17d2d124 100644 --- a/locales/pt-BR/common.json +++ b/locales/pt-BR/common.json @@ -1028,7 +1028,7 @@ "contentOfAnRssEntry": "Conteúdo de uma entrada RSS", "rssEntrySummary": "Resumo da entrada do RSS", "rssEntryImageUrl": "URL da imagem de entrada RSS", - "toExtractTheTextFromHtmlClickHerePlease": "Para extrair o texto do HTML, clique <1> aqui . Observe que o texto original existente no campo acima será sobrescrito. Esse recurso usa a <3> Premailer API , uma serviço de terceiros. Os seus Termos de Serviço e Política de Privacidade são aplicáveis. ", + "toExtractTheTextFromHtmlClickHerePlease": "Para extrair o texto do HTML, clique <1> aqui . Observe que o texto original existente no campo acima será sobrescrito.", "mosaicoTemplateUpdated": "Mosaico template updated", "mosaicoTemplateUpdated - TODO: update line above and then delete this line to mark that the translation has been fixed": "Mosaico template updated", "mosaicoTemplateCreated": "Mosaico template created", diff --git a/server/package-lock.json b/server/package-lock.json index de12ae85..c233bb46 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -12162,15 +12162,6 @@ "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" }, - "premailer-api": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/premailer-api/-/premailer-api-1.0.4.tgz", - "integrity": "sha1-hz9A/DiN3IgG81uY3NKymTeKh08=", - "requires": { - "request": "^2.72.0", - "underscore": "^1.8.3" - } - }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", @@ -13432,11 +13423,6 @@ "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=" }, - "underscore": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", - "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" - }, "underscore.string": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.5.tgz", diff --git a/server/package.json b/server/package.json index 3a028206..749dd8eb 100644 --- a/server/package.json +++ b/server/package.json @@ -102,7 +102,6 @@ "openpgp": "^4.7.2", "passport": "^0.4.1", "passport-local": "^1.0.0", - "premailer-api": "^1.0.4", "request": "^2.88.0", "request-promise": "^4.2.5", "serve-favicon": "^2.5.0", diff --git a/server/routes/rest/editors.js b/server/routes/rest/editors.js index 0fc5bdb3..fbdef77b 100644 --- a/server/routes/rest/editors.js +++ b/server/routes/rest/editors.js @@ -3,23 +3,14 @@ const passport = require('../../lib/passport'); const bluebird = require('bluebird'); -const premailerApi = require('premailer-api'); -const premailerPrepareAsync = bluebird.promisify(premailerApi.prepare.bind(premailerApi)); +const htmlToText = require('html-to-text'); const router = require('../../lib/router-async').create(); router.postAsync('/html-to-text', passport.loggedIn, passport.csrfProtection, async (req, res) => { - if (!req.body.html) { - return res.json({text: ''}); // Premailer crashes very hard when html is empty - } - - const email = await premailerPrepareAsync({ - html: req.body.html, - fetchHTML: false - }); - - res.json({text: email.text.replace(/%5B/g, '[').replace(/%5D/g, ']')}); + const email = htmlToText.fromString(req.body.html, {wordwrap: 130}); + res.json({text: email}); }); module.exports = router;