Skip to content

Commit b25eebe

Browse files
author
Erika Perugachi
authored
Merge pull request #458 from erikaperugachi/composer
Composer
2 parents fcf74fb + 70ece96 commit b25eebe

33 files changed

+418
-642
lines changed

electron_app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "criptext",
3-
"version": "0.12.0",
3+
"version": "0.12.1",
44
"author": {
55
"name": "Criptext Inc.",
66
"email": "[email protected]",
@@ -17,7 +17,7 @@
1717
},
1818
"scripts": {
1919
"electron": "electron .",
20-
"set-env": "NODE_ENV=development CSC_LINK=build/Certificates.p12 CSC_KEY_PASSWORD=xxxxxxxx CSC_IDENTITY_AUTO_DISCOVERY=true MAILBOX_URL=http://localhost:3000 DIALOG_URL=http://localhost:3006 LOGIN_URL=http://localhost:3005 LOADING_URL=http://localhost:3003 COMPOSER_URL=http://localhost:3004 REACT_APP_KEYSERVER_URL=http://localhost:8000 REACT_APP_SOCKETSERVER_URL=ws://localhost:3001",
20+
"set-env": "NODE_ENV=development CSC_LINK=build/Certificates.p12 CSC_KEY_PASSWORD=xxxxxxxx CSC_IDENTITY_AUTO_DISCOVERY=true MAILBOX_URL=http://localhost:3000 DIALOG_URL=http://localhost:3006 LOGIN_URL=http://localhost:3005 LOADING_URL=http://localhost:3003 COMPOSER_URL=http://localhost:3004",
2121
"start": "npm run set-env electron .",
2222
"postinstall": "install-app-deps",
2323
"test": "criptext-js-tools test",

email_composer/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@
77
"base64-js": "^1.3.0",
88
"criptext-files-sdk": "^0.6.2",
99
"crypto-js": "^3.1.9-1",
10-
"draft-js": "^0.10.5",
1110
"draftjs-to-html": "^0.8.2",
12-
"html-to-draftjs": "^1.3.1",
1311
"immutable": "^3.8.2",
12+
"jquery": "^3.3.1",
1413
"node-sass-chokidar": "^0.0.3",
1514
"npm-run-all": "^4.1.2",
1615
"randomcolor": "^0.5.3",
1716
"react": "^16.2.0",
1817
"react-autosuggest": "^9.3.4",
1918
"react-dom": "^16.2.0",
20-
"react-draft-wysiwyg": "^1.12.7",
2119
"react-scripts": "1.1.0",
2220
"react-switch": "^3.0.4",
23-
"react-tagsinput": "^3.19.0"
21+
"react-tagsinput": "^3.19.0",
22+
"react-trumbowyg": "^1.1.0"
2423
},
2524
"scripts": {
2625
"build-css": "node-sass-chokidar src -o src",

email_composer/src/app.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,15 @@ TABLE OF CONTENTS
391391
.icon-text-edit:before {
392392
content: "\e93b";
393393
}
394+
.icon-font-size:before {
395+
content: "\e935";
396+
}
394397
.icon-clock:before {
395398
content: "\e93e";
396399
}
400+
.icon-add-friend:before {
401+
content: "\e934";
402+
}
397403

398404
/* 2.- CONTENT
399405
----------------------------- */

email_composer/src/components/Body.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import './body.css';
77
const Body = props => (
88
<div className="body-container">
99
<DropfileField
10-
blockRenderMap={props.blockRenderMap}
1110
files={props.files}
1211
getHtmlBody={props.getHtmlBody}
1312
htmlBody={props.htmlBody}
@@ -34,12 +33,11 @@ const Body = props => (
3433

3534
Body.propTypes = {
3635
addFiletoken: PropTypes.func,
37-
blockRenderMap: PropTypes.object,
3836
files: PropTypes.array,
3937
getHtmlBody: PropTypes.func,
4038
handleDragLeave: PropTypes.func,
4139
handleDragOver: PropTypes.func,
42-
htmlBody: PropTypes.object,
40+
htmlBody: PropTypes.string,
4341
isDragActive: PropTypes.bool,
4442
isFocusEditorInput: PropTypes.bool,
4543
isToolbarHidden: PropTypes.bool,

email_composer/src/components/BodyWrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class BodyWrapper extends Component {
3232

3333
BodyWrapper.propTypes = {
3434
getHtmlBody: PropTypes.func,
35-
htmlBody: PropTypes.object,
35+
htmlBody: PropTypes.string,
3636
isFocusEditorInput: PropTypes.bool,
3737
onDrop: PropTypes.func,
3838
onFocusTextEditor: PropTypes.func

email_composer/src/components/Composer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const Composer = props => (
2727
text={props.textSubject}
2828
/>
2929
<BodyWrapper
30-
blockRenderMap={props.blockRenderMap}
3130
files={props.files}
3231
getHtmlBody={props.getHtmlBody}
3332
handleDragLeave={props.handleDragLeave}
@@ -62,7 +61,6 @@ const Composer = props => (
6261
Composer.propTypes = {
6362
addFiletoken: PropTypes.func,
6463
bccEmails: PropTypes.array,
65-
blockRenderMap: PropTypes.object,
6664
ccEmails: PropTypes.array,
6765
disableSendButtonOnInvalidEmail: PropTypes.func,
6866
displayNonCriptextPopup: PropTypes.bool,
@@ -76,7 +74,7 @@ Composer.propTypes = {
7674
handleDragOver: PropTypes.func,
7775
handlePauseUploadFile: PropTypes.func,
7876
handleResumeUploadFile: PropTypes.func,
79-
htmlBody: PropTypes.object,
77+
htmlBody: PropTypes.string,
8078
isCollapsedMoreRecipient: PropTypes.bool,
8179
isDragActive: PropTypes.bool,
8280
isFocusEditorInput: PropTypes.bool,

email_composer/src/components/DropfileField.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import './dropfilefield.css';
77
const DropfileField = props => (
88
<div
99
className={
10-
'dropfilefiled-container ' + (props.isDragActive ? 'dragActive' : '')
10+
'dropfilefiled-container' +
11+
(props.isDragActive ? ' dragActive' : '') +
12+
(props.isToolbarHidden ? ' toolbarHidden' : '')
1113
}
1214
onDragLeave={props.onDragLeave}
1315
onDragOver={props.onDragOver}
@@ -18,7 +20,6 @@ const DropfileField = props => (
1820
isFocusEditorInput={props.isFocusEditorInput}
1921
toolbarHidden={props.isToolbarHidden}
2022
getHtmlBody={props.getHtmlBody}
21-
blockRenderMap={props.blockRenderMap}
2223
onFocusTextEditor={props.onFocusTextEditor}
2324
/>
2425
<div className="files-container">
@@ -70,10 +71,9 @@ DropfileField.defaultProps = {
7071
DropfileField.propTypes = {
7172
accept: PropTypes.string,
7273
addFiletoken: PropTypes.func,
73-
blockRenderMap: PropTypes.object,
7474
files: PropTypes.array,
7575
getHtmlBody: PropTypes.func,
76-
htmlBody: PropTypes.object,
76+
htmlBody: PropTypes.string,
7777
isDragActive: PropTypes.bool,
7878
isFocusEditorInput: PropTypes.bool,
7979
isToolbarHidden: PropTypes.bool,

email_composer/src/components/EditorWrapper.js

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,51 @@
1+
import './global';
12
import React, { Component } from 'react';
23
import PropTypes from 'prop-types';
3-
import { Editor } from 'react-draft-wysiwyg';
4+
import Trumbowyg from 'react-trumbowyg';
5+
import '../../node_modules/trumbowyg/dist/plugins/colors/trumbowyg.colors.min.js';
6+
import '../../node_modules/trumbowyg/dist/plugins/colors/ui/trumbowyg.colors.css';
7+
import '../../node_modules/trumbowyg/dist/plugins/fontfamily/trumbowyg.fontfamily.js';
8+
import '../../node_modules/trumbowyg/dist/plugins/fontsize/trumbowyg.fontsize.js';
9+
import 'react-trumbowyg/dist/trumbowyg.css';
410
import './editor.css';
511

612
class EditorWrapper extends Component {
713
render() {
814
return (
9-
<Editor
10-
{...this.props}
11-
ref={editor => {
12-
this.editor = editor;
13-
}}
14-
toolbar={{
15-
options: [
16-
'inline',
17-
'fontSize',
18-
'fontFamily',
19-
'list',
20-
'textAlign',
21-
'colorPicker',
22-
'link',
23-
'emoji'
24-
],
25-
inline: {
26-
options: ['bold', 'italic', 'underline']
27-
},
28-
textAlign: { inDropdown: true },
29-
link: {
30-
inDropdown: false,
31-
defaultTargetOption: '_blank'
32-
},
33-
history: { inDropdown: true }
34-
}}
35-
editorState={this.props.htmlBody}
36-
onEditorStateChange={this.onChangeHtmlBody}
37-
placeholder={'Message'}
38-
blockRenderMap={this.props.blockRenderMap}
39-
onFocus={() => this.handleFocus()}
15+
<Trumbowyg
16+
id="react-trumbowyg"
17+
buttons={[
18+
['fontfamily'],
19+
['fontsize'],
20+
['bold', 'italic', 'underline'],
21+
['link'],
22+
['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
23+
['unorderedList', 'orderedList'],
24+
['foreColor', 'backColor'],
25+
['removeformat']
26+
]}
27+
data={this.props.htmlBody}
28+
onChange={this.onChangeHtmlBody}
29+
placeholder="Message"
4030
/>
4131
);
4232
}
4333

44-
componentDidMount() {
45-
if (this.props.isFocusEditorInput) {
46-
this.editor.focusEditor();
34+
componentDidUpdate(prevProps) {
35+
if (prevProps.htmlBody !== this.props.htmlBody) {
36+
this.props.getHtmlBody(this.props.htmlBody);
4737
}
4838
}
4939

50-
onChangeHtmlBody = html => {
40+
onChangeHtmlBody = e => {
41+
const html = e.target.innerHTML;
5142
this.props.getHtmlBody(html);
5243
};
53-
54-
handleFocus = () => {
55-
this.props.onFocusTextEditor(true);
56-
};
5744
}
5845

5946
EditorWrapper.propTypes = {
60-
blockRenderMap: PropTypes.object,
6147
getHtmlBody: PropTypes.func,
62-
htmlBody: PropTypes.object,
48+
htmlBody: PropTypes.string,
6349
isFocusEditorInput: PropTypes.bool,
6450
onFocusTextEditor: PropTypes.func
6551
};

email_composer/src/components/Recipient.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const renderRecipientTo = props => (
3636
<div className="recipient-content">
3737
<span className="recipient-input-label">To:</span>
3838
<TagsInput
39-
addKeys={[9, 13, 32, 186, 188]}
39+
addKeys={[9, 13, 32, 188]}
4040
addOnBlur={true}
4141
addOnPaste={true}
4242
className="recipient-tags"
@@ -47,8 +47,10 @@ const renderRecipientTo = props => (
4747
placeholder: '',
4848
name: 'To'
4949
}}
50+
inputValue={props.inputToValue}
5051
onlyUnique={true}
5152
onChange={props.onChangeToTag}
53+
onChangeInput={props.onChangeToInput}
5254
onValidationReject={props.handleOnValidationRejectToTag}
5355
pasteSplit={pasteSplit}
5456
renderInput={AutocompleteWrapper}
@@ -66,7 +68,7 @@ const renderRecipientCc = props => (
6668
<div className="recipient-content">
6769
<span className="recipient-input-label">Cc:</span>
6870
<TagsInput
69-
addKeys={[9, 13, 32, 186, 188]}
71+
addKeys={[9, 13, 32, 188]}
7072
addOnBlur={true}
7173
addOnPaste={true}
7274
className="recipient-tags"
@@ -76,7 +78,9 @@ const renderRecipientCc = props => (
7678
placeholder: '',
7779
name: 'Cc'
7880
}}
81+
inputValue={props.inputCcValue}
7982
onChange={props.onChangeCcTag}
83+
onChangeInput={props.onChangeCcInput}
8084
onlyUnique={true}
8185
onValidationReject={props.handleOnValidationRejectCcTag}
8286
pasteSplit={pasteSplit}
@@ -95,7 +99,7 @@ const renderRecipientBcc = props => (
9599
<div className="recipient-content">
96100
<span className="recipient-input-label">Bcc:</span>
97101
<TagsInput
98-
addKeys={[9, 13, 32, 186, 188]}
102+
addKeys={[9, 13, 32, 188]}
99103
addOnBlur={true}
100104
addOnPaste={true}
101105
className="recipient-tags"
@@ -105,7 +109,9 @@ const renderRecipientBcc = props => (
105109
placeholder: '',
106110
name: 'Bcc'
107111
}}
112+
inputValue={props.inputBccValue}
108113
onChange={props.onChangeBccTag}
114+
onChangeInput={props.onChangeBccInput}
109115
onlyUnique={true}
110116
onValidationReject={props.handleOnValidationRejectBccTag}
111117
pasteSplit={pasteSplit}
@@ -129,7 +135,9 @@ Recipient.propTypes = {
129135
renderRecipientTo.propTypes = {
130136
checkDisableSendButton: PropTypes.func,
131137
handleOnValidationRejectToTag: PropTypes.func,
138+
inputToValue: PropTypes.string,
132139
isFocusEditorInput: PropTypes.bool,
140+
onChangeToInput: PropTypes.func,
133141
onChangeToTag: PropTypes.func,
134142
toTags: PropTypes.string
135143
};
@@ -138,13 +146,17 @@ renderRecipientCc.propTypes = {
138146
ccTags: PropTypes.string,
139147
checkDisableSendButton: PropTypes.func,
140148
handleOnValidationRejectCcTag: PropTypes.func,
149+
inputCcValue: PropTypes.string,
150+
onChangeCcInput: PropTypes.func,
141151
onChangeCcTag: PropTypes.func
142152
};
143153

144154
renderRecipientBcc.propTypes = {
145155
bccTags: PropTypes.string,
146156
checkDisableSendButton: PropTypes.func,
147157
handleOnValidationRejectBccTag: PropTypes.func,
158+
inputBccValue: PropTypes.string,
159+
onChangeBccInput: PropTypes.func,
148160
onChangeBccTag: PropTypes.func
149161
};
150162

email_composer/src/components/RecipientWrapper.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,33 @@ import Recipient from './Recipient';
44
import { RegexUtils } from './../utils/electronUtilsInterface';
55

66
class RecipientWrapper extends Component {
7+
constructor(props) {
8+
super(props);
9+
this.state = {
10+
inputBccValue: '',
11+
inputCcValue: '',
12+
inputToValue: ''
13+
};
14+
}
15+
716
render() {
817
return (
918
<Recipient
1019
{...this.props}
1120
bccTags={this.props.bccEmails}
1221
ccTags={this.props.ccEmails}
1322
emailRegex={RegexUtils.emailRegex}
23+
inputBccValue={this.state.inputBccValue}
24+
inputCcValue={this.state.inputCcValue}
25+
inputToValue={this.state.inputToValue}
1426
isCollapsedMoreRecipient={this.props.isCollapsedMoreRecipient}
1527
onToggleRecipient={this.props.onToggleRecipient}
16-
onChangeBccTag={this.handleOnChangeBccTag}
17-
onChangeCcTag={this.handleOnChangeCcTag}
18-
onChangeToTag={this.handleOnChangeToTag}
28+
onChangeBccTag={this.handleChangeBccTag}
29+
onChangeCcTag={this.handleChangeCcTag}
30+
onChangeToTag={this.handleChangeToTag}
31+
onChangeBccInput={this.handleChangeBccInput}
32+
onChangeCcInput={this.handleChangeCcInput}
33+
onChangeToInput={this.handleChangeToInput}
1934
onValidationRejectBccTag={this.handleOnValidationRejectBccTag}
2035
onValidationRejectCcTag={this.handleOnValidationRejectCcTag}
2136
onValidationRejectToTag={this.handleOnValidationRejectToTag}
@@ -31,15 +46,27 @@ class RecipientWrapper extends Component {
3146
}
3247
};
3348

34-
handleOnChangeBccTag = tags => {
49+
handleChangeBccInput = text => {
50+
this.setState({ inputBccValue: text ? text.replace(';', '') : text });
51+
};
52+
53+
handleChangeCcInput = text => {
54+
this.setState({ inputCcValue: text ? text.replace(';', '') : text });
55+
};
56+
57+
handleChangeToInput = text => {
58+
this.setState({ inputToValue: text ? text.replace(';', '') : text });
59+
};
60+
61+
handleChangeBccTag = tags => {
3562
this.props.getBccEmails(tags);
3663
};
3764

38-
handleOnChangeCcTag = tags => {
65+
handleChangeCcTag = tags => {
3966
this.props.getCcEmails(tags);
4067
};
4168

42-
handleOnChangeToTag = tags => {
69+
handleChangeToTag = tags => {
4370
this.props.getToEmails(tags);
4471
};
4572

0 commit comments

Comments
 (0)