Skip to content

Commit 78d2948

Browse files
authored
Merge pull request #1517 from Hirobreak/remove-style
Email Detail Style Wrap
2 parents b403414 + d9d670e commit 78d2948

File tree

24 files changed

+130
-28
lines changed

24 files changed

+130
-28
lines changed

electron_app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "criptext",
3-
"version": "0.30.2",
3+
"version": "0.30.3",
44
"author": {
55
"name": "Criptext Inc",
66
"email": "[email protected]",

electron_app/src/utils/const.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const LINK_DEVICES_FILE_VERSION = '6';
1111
const PROD_SOCKET_URL = 'wss://socket.criptext.com';
1212
const PROD_SERVER_URL = 'https://api.criptext.com';
1313
const PROD_DATA_TRANSFER_URL = 'https://transfer.criptext.com';
14+
const PROD_ACCOUNT_URL = 'https://account.criptext.com';
1415
const FILE_SERVER_APP_ID = 'qynhtyzjrshazxqarkpy';
1516
const FILE_SERVER_KEY = 'lofjksedbxuucdjjpnby';
1617
const PROD_APP_DOMAIN = 'criptext.com';
@@ -45,5 +46,6 @@ module.exports = {
4546
? process.env.DEV_NUCLEUS_ID
4647
: process.env.PROD_NUCLEUS_ID || nucleusId,
4748
INSTALLER_TYPE: criptextInstallerType,
48-
DEFAULT_PIN
49+
DEFAULT_PIN,
50+
ACCOUNT_URL: isDevelopment ? process.env.DEV_ACCOUNT_URL : PROD_ACCOUNT_URL
4951
};

electron_app/src/windows/mailbox.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const globalManager = require('./../globalManager');
99
const { EVENTS, callEvent } = require('./events');
1010
const { mailtoProtocolRegex } = require('./../utils/RegexUtils');
1111
const { removeProtocolFromUrl } = require('./../utils/stringUtils');
12-
const { API_TRACKING_EVENT } = require('./../utils/const');
12+
const { API_TRACKING_EVENT, ACCOUNT_URL } = require('./../utils/const');
1313
const { isFromStore, isDev } = require('./windowUtils');
1414
const {
1515
updateUserData,
@@ -26,7 +26,8 @@ const mailboxSize = {
2626
height: 800
2727
};
2828

29-
const adminUrl = 'https://admin.criptext.com/?#/account/billing';
29+
const oldAdminUrl = 'https://admin.criptext.com/?#/account/billing';
30+
const adminUrl = `${ACCOUNT_URL}/?#/billing`;
3031

3132
const iconPath = path.join(
3233
__dirname,
@@ -188,7 +189,7 @@ const openLinkInDefaultBrowser = (ev, url) => {
188189
emailAddress
189190
});
190191
return;
191-
} else if (url === adminUrl) {
192+
} else if (url === adminUrl || url === oldAdminUrl) {
192193
mailboxWindow.webContents.send('open-plus');
193194
return;
194195
}

electron_app/src/windows/upgradePlus.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { BrowserWindow } = require('electron');
22
const language = require('../lang/index');
3+
const { ACCOUNT_URL } = require('../utils/const');
34

45
const openUpgradeToPlusWindow = token => {
56
try {
@@ -15,9 +16,7 @@ const openUpgradeToPlusWindow = token => {
1516
}
1617
});
1718
workerWin.loadURL(
18-
`https://admin.criptext.com/?#/account/billing?lang=${
19-
language.currentLanguage
20-
}&token=${token}`
19+
`${ACCOUNT_URL}?#/billing?lang=${language.currentLanguage}&token=${token}`
2120
);
2221
workerWin.webContents.closeDevTools();
2322
return workerWin;

email_composer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "email_composer",
3-
"version": "0.30.2",
3+
"version": "0.30.3",
44
"private": true,
55
"dependencies": {
66
"@criptext/electron-better-ipc": "^0.7.0-rc1-0.2",

email_loading/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "email_loading",
3-
"version": "0.30.2",
3+
"version": "0.30.3",
44
"private": true,
55
"dependencies": {
66
"@criptext/electron-better-ipc": "^0.7.0-rc1-0.2",

email_login/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "email_login",
3-
"version": "0.30.2",
3+
"version": "0.30.3",
44
"private": true,
55
"dependencies": {
66
"@criptext/electron-better-ipc": "^0.7.0-rc1-0.2",

email_mailbox/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "email_mailbox",
3-
"version": "0.30.2",
3+
"version": "0.30.3",
44
"private": true,
55
"dependencies": {
66
"@criptext/electron-better-ipc": "^0.7.0-rc1-0.2",
77
"animejs": "^2.2.0",
88
"base64-js": "^1.3.0",
99
"criptext-files-sdk": "^0.8.0",
1010
"crypto-js": "^3.1.9-1",
11+
"css": "^3.0.0",
1112
"draft-js": "^0.10.5",
1213
"draftjs-to-html": "^0.8.4",
1314
"html-to-draftjs": "^1.4.0",

email_mailbox/src/components/Email.js

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import ButtonUnsend from './ButtonUnsendWrapper';
1212
import AvatarImage from './AvatarImage';
1313
import ButtonIcon from './ButtonIcon';
1414
import { EmailStatus } from './../utils/const';
15+
import css from 'css';
1516
import string from '../lang';
1617
import './email.scss';
18+
import { logError } from '../utils/ipc';
1719

1820
const DeletePermanenltyPopup = PopupHOC(DialogPopup);
1921
const BlockRemotePopup = PopupHOC(BlockRemoteContentPopup);
@@ -105,7 +107,10 @@ const Email = props => (
105107
</div>
106108
<hr />
107109
<div className="email-body">
108-
<div disabled={props.hideView || props.isUnsend} className="email-text">
110+
<div
111+
disabled={props.hideView || props.isUnsend}
112+
className={`email-text cptx-email-display-${props.email.key}`}
113+
>
109114
<div dangerouslySetInnerHTML={{ __html: theMail(props) }} />
110115
</div>
111116
{!!props.files.length &&
@@ -331,10 +336,33 @@ const renderIconSecure = (onMouseEnterTooltip, onMouseLeaveTooltip, id) => {
331336
};
332337

333338
const theMail = props => {
334-
const { content, blockImagesInline } = props;
339+
const { content, blockImagesInline, email } = props;
340+
341+
let newContent = content;
342+
try {
343+
const wrapper = document.createElement('div');
344+
wrapper.innerHTML = content;
345+
const styles = wrapper.getElementsByTagName('style');
346+
for (const style of styles) {
347+
const parsedCss = css.parse(style.innerText);
348+
const sheet = parsedCss.stylesheet;
349+
for (const rule in sheet.rules) {
350+
const myRule = sheet.rules[rule];
351+
for (const s in myRule.selectors) {
352+
myRule.selectors[s] =
353+
`.cptx-email-display-${email.key} ` + myRule.selectors[s];
354+
}
355+
}
356+
style.innerHTML = css.stringify(parsedCss);
357+
}
358+
newContent = wrapper.innerHTML;
359+
} catch (ex) {
360+
logError(ex);
361+
}
362+
335363
if (!blockImagesInline)
336-
return `<div class="email-container">${content}</div>`;
337-
return getDOM(content);
364+
return `<div class="email-container">${newContent}</div>`;
365+
return getDOM(newContent);
338366
};
339367

340368
const getDOM = html => {

email_mailbox/src/components/SettingUpgradePlusWrapper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Component } from 'react';
22
import { myAccount, mySettings } from '../utils/electronInterface';
33
import './settingupgradepluss.scss';
4+
import { accountUrl } from '../utils/const';
45

56
const Loading = () => (
67
<div className="loading-ring">
@@ -30,7 +31,7 @@ class SettingUpgradePlusWrapper extends Component {
3031
<iframe
3132
id="cptx-upgrade-to-plus-iframe"
3233
title="cptx-upgrade-to-plus-iframe"
33-
src={`https://admin.criptext.com/?#/account/billing?lang=${mySettings.language ||
34+
src={`${accountUrl}/?#/billing?lang=${mySettings.language ||
3435
'en'}&token=${myAccount.jwt}`}
3536
onLoad={this.handleLoad}
3637
className={

0 commit comments

Comments
 (0)