@capillarytech/creatives-library 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -765,7 +765,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
765
765
|
const newSchema = this.injectEvents(nextProps.metaEntities.layouts[0].definition);
|
|
766
766
|
console.log('Schema test 1 ', newSchema);
|
|
767
767
|
this.setState({schema: newSchema});
|
|
768
|
-
if (this.props.location.query.module !== 'library') {
|
|
768
|
+
if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
|
|
769
769
|
const query = {
|
|
770
770
|
layout: 'EMAIL',
|
|
771
771
|
type: 'TAG',
|
|
@@ -147,7 +147,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
147
147
|
if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
|
|
148
148
|
console.log('final schema is**', nextProps.metaEntities.layouts[0].definition);
|
|
149
149
|
this.injectEvents(nextProps.metaEntities.layouts[0].definition);
|
|
150
|
-
if (this.props.location.query.module !== 'library') {
|
|
150
|
+
if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
|
|
151
151
|
const query = {
|
|
152
152
|
layout: 'SMS',
|
|
153
153
|
type: 'TAG',
|
|
@@ -1459,6 +1459,7 @@ Create.propTypes = {
|
|
|
1459
1459
|
metaEntities: PropTypes.object,
|
|
1460
1460
|
intl: intlShape.isRequired,
|
|
1461
1461
|
supportedTags: PropTypes.array,
|
|
1462
|
+
getDefaultTags: PropTypes.bool,
|
|
1462
1463
|
};
|
|
1463
1464
|
|
|
1464
1465
|
const mapStateToProps = createStructuredSelector({
|
|
@@ -123,7 +123,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
123
123
|
this.setState({schema: nextProps.metaEntities.layouts[0].definition}, () => {
|
|
124
124
|
this.injectEvents(nextProps.metaEntities.layouts[0].definition);
|
|
125
125
|
});
|
|
126
|
-
if (this.props.location.query.module !== 'library') {
|
|
126
|
+
if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
|
|
127
127
|
const query = {
|
|
128
128
|
layout: 'SMS',
|
|
129
129
|
type: 'TAG',
|
|
@@ -1438,6 +1438,7 @@ Edit.propTypes = {
|
|
|
1438
1438
|
intl: intlShape.isRequired,
|
|
1439
1439
|
templateData: PropTypes.object,
|
|
1440
1440
|
supportedTags: PropTypes.array,
|
|
1441
|
+
getDefaultTags: PropTypes.bool,
|
|
1441
1442
|
// route: PropTypes.object,
|
|
1442
1443
|
};
|
|
1443
1444
|
|
package/package.json
CHANGED
package/utils/smsCharCount.js
DELETED
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import Jed from './jed';
|
|
3
|
-
|
|
4
|
-
const l10n = {};
|
|
5
|
-
const i18n = new Jed(l10n);
|
|
6
|
-
let settings;
|
|
7
|
-
|
|
8
|
-
function smsCounter(options, chars) {
|
|
9
|
-
settings = Object.assign({
|
|
10
|
-
smsCount: 160,
|
|
11
|
-
}, options);
|
|
12
|
-
return updateSmsData(chars); //this.each(function() {
|
|
13
|
-
// if (!skipObj) {
|
|
14
|
-
// this.keyup(updateSmsData);
|
|
15
|
-
// } else {
|
|
16
|
-
// updateSmsData();
|
|
17
|
-
// }
|
|
18
|
-
// });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let updateSmsData = (chars) => {
|
|
22
|
-
let skipObj = false;
|
|
23
|
-
let msgContent;
|
|
24
|
-
if (chars !== undefined && chars !== "" && chars !== false && chars !== true) {
|
|
25
|
-
skipObj = true;
|
|
26
|
-
}
|
|
27
|
-
if (skipObj) {
|
|
28
|
-
msgContent = chars;
|
|
29
|
-
} else {
|
|
30
|
-
// msgContent = $(this).val();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const charset7bit = {
|
|
34
|
-
'@': 1,
|
|
35
|
-
'$': 1,
|
|
36
|
-
"\n": 1,
|
|
37
|
-
"\r": 1,
|
|
38
|
-
'_': 1,
|
|
39
|
-
' ': 1,
|
|
40
|
-
'!': 1,
|
|
41
|
-
'"': 1,
|
|
42
|
-
'#': 1,
|
|
43
|
-
'%': 1,
|
|
44
|
-
'&': 1,
|
|
45
|
-
"'": 1,
|
|
46
|
-
'(': 1,
|
|
47
|
-
')': 1,
|
|
48
|
-
'*': 1,
|
|
49
|
-
'+': 1,
|
|
50
|
-
',': 1,
|
|
51
|
-
'-': 1,
|
|
52
|
-
'.': 1,
|
|
53
|
-
'/': 1,
|
|
54
|
-
'0': 1,
|
|
55
|
-
'1': 1,
|
|
56
|
-
'2': 1,
|
|
57
|
-
'3': 1,
|
|
58
|
-
'4': 1,
|
|
59
|
-
'5': 1,
|
|
60
|
-
'6': 1,
|
|
61
|
-
'7': 1,
|
|
62
|
-
'8': 1,
|
|
63
|
-
'9': 1,
|
|
64
|
-
':': 1,
|
|
65
|
-
';': 1,
|
|
66
|
-
'<': 1,
|
|
67
|
-
'=': 1,
|
|
68
|
-
'>': 1,
|
|
69
|
-
'?': 1,
|
|
70
|
-
'¡': 1,
|
|
71
|
-
'A': 1,
|
|
72
|
-
'B': 1,
|
|
73
|
-
'C': 1,
|
|
74
|
-
'D': 1,
|
|
75
|
-
'E': 1,
|
|
76
|
-
'F': 1,
|
|
77
|
-
'G': 1,
|
|
78
|
-
'H': 1,
|
|
79
|
-
'I': 1,
|
|
80
|
-
'J': 1,
|
|
81
|
-
'K': 1,
|
|
82
|
-
'L': 1,
|
|
83
|
-
'M': 1,
|
|
84
|
-
'N': 1,
|
|
85
|
-
'O': 1,
|
|
86
|
-
'P': 1,
|
|
87
|
-
'Q': 1,
|
|
88
|
-
'R': 1,
|
|
89
|
-
'S': 1,
|
|
90
|
-
'T': 1,
|
|
91
|
-
'U': 1,
|
|
92
|
-
'V': 1,
|
|
93
|
-
'W': 1,
|
|
94
|
-
'X': 1,
|
|
95
|
-
'Y': 1,
|
|
96
|
-
'Z': 1,
|
|
97
|
-
'a': 1,
|
|
98
|
-
'b': 1,
|
|
99
|
-
'c': 1,
|
|
100
|
-
'd': 1,
|
|
101
|
-
'e': 1,
|
|
102
|
-
'f': 1,
|
|
103
|
-
'g': 1,
|
|
104
|
-
'h': 1,
|
|
105
|
-
'i': 1,
|
|
106
|
-
'j': 1,
|
|
107
|
-
'k': 1,
|
|
108
|
-
'l': 1,
|
|
109
|
-
'm': 1,
|
|
110
|
-
'n': 1,
|
|
111
|
-
'o': 1,
|
|
112
|
-
'p': 1,
|
|
113
|
-
'q': 1,
|
|
114
|
-
'r': 1,
|
|
115
|
-
's': 1,
|
|
116
|
-
't': 1,
|
|
117
|
-
'u': 1,
|
|
118
|
-
'v': 1,
|
|
119
|
-
'w': 1,
|
|
120
|
-
'x': 1,
|
|
121
|
-
'y': 1,
|
|
122
|
-
'z': 1,
|
|
123
|
-
"\f": 2,
|
|
124
|
-
'^': 2,
|
|
125
|
-
'{': 2,
|
|
126
|
-
'}': 2,
|
|
127
|
-
'\\': 2,
|
|
128
|
-
'[': 2,
|
|
129
|
-
'~': 2,
|
|
130
|
-
']': 2,
|
|
131
|
-
'|': 2,
|
|
132
|
-
'è': 1,
|
|
133
|
-
'é': 1,
|
|
134
|
-
'ù': 1,
|
|
135
|
-
'ì': 1,
|
|
136
|
-
'ò': 1,
|
|
137
|
-
'Ç': 1,
|
|
138
|
-
'Ø': 1,
|
|
139
|
-
'ø': 1,
|
|
140
|
-
'Å': 1,
|
|
141
|
-
'å': 1,
|
|
142
|
-
'Δ': 1,
|
|
143
|
-
'Φ': 1,
|
|
144
|
-
'Γ': 1,
|
|
145
|
-
'Λ': 1,
|
|
146
|
-
'Ω': 1,
|
|
147
|
-
'Π': 1,
|
|
148
|
-
'Ψ': 1,
|
|
149
|
-
'Σ': 1,
|
|
150
|
-
'Θ': 1,
|
|
151
|
-
'Ξ': 1,
|
|
152
|
-
'Æ': 1,
|
|
153
|
-
'æ': 1,
|
|
154
|
-
'ß': 1,
|
|
155
|
-
'É': 1,
|
|
156
|
-
'Ä': 1,
|
|
157
|
-
'Ö': 1,
|
|
158
|
-
'Ñ': 1,
|
|
159
|
-
'Ü': 1,
|
|
160
|
-
'ä': 1,
|
|
161
|
-
'ö': 1,
|
|
162
|
-
'ñ': 1,
|
|
163
|
-
'ü': 1,
|
|
164
|
-
'à': 1,
|
|
165
|
-
'£': 1,
|
|
166
|
-
'¥': 1,
|
|
167
|
-
'¤': 1,
|
|
168
|
-
'§': 1,
|
|
169
|
-
'¿': 1,
|
|
170
|
-
'€': 2,
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
msgContent = msgContent.replace(/\u00a0/g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\\n\\n/g, "\\n").replace(/\\n/g, " ");
|
|
174
|
-
msgContent = msgContent.replace(/\r/g, " ").replace(/\f/g, " ");
|
|
175
|
-
|
|
176
|
-
const matches = msgContent.split("");
|
|
177
|
-
console.log('Test 1', msgContent, matches);
|
|
178
|
-
let use7bit = true;
|
|
179
|
-
let length7bit = 0;
|
|
180
|
-
let length16bit = 0;
|
|
181
|
-
let parts = {
|
|
182
|
-
sms_count: 1,
|
|
183
|
-
chars_left: 160,
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
matches.forEach( (char) => {
|
|
187
|
-
if (use7bit && charset7bit[char] === undefined) {
|
|
188
|
-
use7bit = false;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (use7bit) {
|
|
192
|
-
length7bit += charset7bit[char];
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
length16bit += 1;
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
if (use7bit) {
|
|
199
|
-
parts = smsCount(length7bit, false);
|
|
200
|
-
} else {
|
|
201
|
-
parts = smsCount(length16bit, true);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (typeof settings.getCount === 'function') {
|
|
205
|
-
settings.getCount.call(this, parts);
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
let smsCount = (chars, enc16) => {
|
|
210
|
-
let charactersLeft = 0;
|
|
211
|
-
let smsCharCounter = 0;
|
|
212
|
-
|
|
213
|
-
if (enc16 === false && chars <= 160) {
|
|
214
|
-
charactersLeft = 160 - chars;
|
|
215
|
-
return {
|
|
216
|
-
sms_count: 1,
|
|
217
|
-
chars_left: charactersLeft,
|
|
218
|
-
chars,
|
|
219
|
-
charset: false,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (enc16 === true && chars <= 70) {
|
|
224
|
-
charactersLeft = 70 - chars;
|
|
225
|
-
return {
|
|
226
|
-
sms_count: 1,
|
|
227
|
-
chars_left: charactersLeft,
|
|
228
|
-
chars,
|
|
229
|
-
charset: "Unicode charset",
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (enc16 === false) {
|
|
234
|
-
smsCharCounter = Math.ceil(chars / 153);
|
|
235
|
-
charactersLeft = (smsCount * 153) - chars;
|
|
236
|
-
return {
|
|
237
|
-
sms_count: smsCharCounter,
|
|
238
|
-
chars_left: charactersLeft,
|
|
239
|
-
chars,
|
|
240
|
-
charset: false,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
smsCharCounter = Math.ceil(chars / 67);
|
|
245
|
-
charactersLeft = (smsCharCounter * 67) - chars;
|
|
246
|
-
return {
|
|
247
|
-
sms_count: smsCharCounter,
|
|
248
|
-
chars_left: charactersLeft,
|
|
249
|
-
chars,
|
|
250
|
-
charset: "Unicode charset",
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
function _camp1(s) {
|
|
255
|
-
try {
|
|
256
|
-
return i18n.dgettext("camp1", s) !== '' ? this.i18n.dgettext("camp1", s) : s;
|
|
257
|
-
} catch (err) {
|
|
258
|
-
console.log('i18n Error', err.message);
|
|
259
|
-
return s;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* returns no of char an SMS contains in
|
|
265
|
-
* messaging of campaign based on ascii and
|
|
266
|
-
* non-ascii characters.
|
|
267
|
-
* @param message
|
|
268
|
-
* @returns
|
|
269
|
-
*/
|
|
270
|
-
function smsCharCount(message) {
|
|
271
|
-
// const that = this;
|
|
272
|
-
let msgcount = 1;
|
|
273
|
-
let countLbl = 0;
|
|
274
|
-
const props = {
|
|
275
|
-
chars_left: 160,
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
smsCounter({
|
|
279
|
-
getCount: (parts) => {
|
|
280
|
-
props.chars_left = parts.chars_left;
|
|
281
|
-
props.total_chars = parts.chars;
|
|
282
|
-
props.charset = parts.charset;
|
|
283
|
-
msgcount = parts.sms_count;
|
|
284
|
-
countLbl = parts.chars;
|
|
285
|
-
if (parts.charset !== false) {
|
|
286
|
-
countLbl = `${parts.chars} ${_camp1("Unicode")}`;
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
}, message);
|
|
290
|
-
return [countLbl, msgcount, props];
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// function escapeRegex(text) {
|
|
294
|
-
// return text.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&").replace(/\s/g, "\\s+").replace(/'|"/g, "(?:'|\")");
|
|
295
|
-
// }
|
|
296
|
-
|
|
297
|
-
export function checkUnicode(str, msg) {
|
|
298
|
-
const non_unicode = {'@': 1, '$': 1, "\n":1, "\r":1, '_': 1, ' ': 1, '!': 1, '"': 1, '#': 1, '%': 1, '&': 1, "'":1, '(': 1, ')': 1, '*': 1, '+': 1, ',': 1, '-': 1, '.': 1, '/': 1, '0': 1, '1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '6': 1, '7': 1, '8': 1, '9': 1, ':': 1, ';': 1, '<': 1, '=': 1, '>': 1, '?': 1, '¡': 1, 'A': 1, 'B': 1, 'C': 1, 'D': 1, 'E': 1, 'F': 1, 'G': 1, 'H': 1, 'I': 1, 'J': 1, 'K': 1, 'L': 1, 'M': 1, 'N': 1, 'O': 1, 'P': 1, 'Q': 1, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 1, 'W': 1, 'X': 1, 'Y': 1, 'Z': 1, 'a': 1, 'b': 1, 'c': 1, 'd': 1, 'e': 1, 'f': 1, 'g': 1, 'h': 1, 'i': 1, 'j': 1, 'k': 1, 'l': 1, 'm': 1, 'n': 1, 'o': 1, 'p': 1, 'q': 1, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 1, 'w': 1, 'x': 1, 'y': 1, 'z': 1, "\f": 2, '^': 2, '{': 2, '}': 2, '\\': 2, '[': 2, '~': 2,']':2,'|':2,'è':1,'é':1,'ù':1,'ì':1,'ò':1,'Ç':1,'Ø':1,'ø':1,'Å':1,'å':1,'Δ':1,'Φ':1,'Γ':1,'Λ':1,'Ω':1,'Π':1,'Ψ':1,'Σ':1,'Θ':1,'Ξ':1,'Æ':1,'æ':1,'ß':1,'É':1,'Ä':1,'Ö':1,'Ñ':1,'Ü':1,'¿':1,'ä':1,'ö':1,'ñ':1,'ü':1,'à':1,'£': 1,'¥': 1,'¤': 1,'§': 1,'¿': 1,'€':2};
|
|
299
|
-
var isUnicode=0;
|
|
300
|
-
msg = typeof msg !== 'undefined' ? msg : "This message contains Unicode Characters. Do you want to proceed?";
|
|
301
|
-
|
|
302
|
-
str = str.replace(/\u00a0/g, " ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\\n\\n/g, "\\n").replace(/\\n/g, " ");
|
|
303
|
-
str = str.replace(/\r/g," ").replace(/\f/g," ");
|
|
304
|
-
var matches = str.split("");
|
|
305
|
-
for (var i in matches) {
|
|
306
|
-
const char = matches[i];
|
|
307
|
-
if (!non_unicode[char]) {
|
|
308
|
-
isUnicode = 1;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
// if (isUnicode === 1) {
|
|
312
|
-
// const r = confirm(msg);
|
|
313
|
-
// if (r === true) {
|
|
314
|
-
// return true;
|
|
315
|
-
// }
|
|
316
|
-
// return false;
|
|
317
|
-
// }
|
|
318
|
-
//
|
|
319
|
-
return isUnicode === 1;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export function updateCharCount(boxVal) {
|
|
323
|
-
// let tagHtml = "<span class='editor_tag' title='%desc%' contenteditable='false'>%name%</span>";
|
|
324
|
-
// let tagText = "{{%name%}}";
|
|
325
|
-
|
|
326
|
-
// let boxVal = html.replace(new RegExp(escapeRegex(tagHtml).replace("%name%", "(.*?)").replace(/%.*?%/g, "(?:.*?)"), "g"), tagText.replace(/%name%/g, "$1")).replace(/\<(p|div|br).*?\>/g, "\\n").replace(/\<.*?\>/g, "");
|
|
327
|
-
// boxVal = "" + boxVal;
|
|
328
|
-
|
|
329
|
-
// let unicodeFlag = 0;
|
|
330
|
-
// let extraChars = 0;
|
|
331
|
-
console.log('Box val', boxVal);
|
|
332
|
-
let msgCount = 0;
|
|
333
|
-
const lenCount = smsCharCount(boxVal);
|
|
334
|
-
const len = lenCount[0];
|
|
335
|
-
msgCount = lenCount[1];
|
|
336
|
-
const charLeft = lenCount[2].chars_left;
|
|
337
|
-
const totalChars = lenCount[2].total_chars;
|
|
338
|
-
const charset = lenCount[2].charset;
|
|
339
|
-
if (!charset && totalChars > 1000) {
|
|
340
|
-
console.log("only 1000 character allowed in normal sms remaining character will be discarded");
|
|
341
|
-
} else if (charset && totalChars > 500) {
|
|
342
|
-
console.log("only 500 character allowed in unicode sms remaining character will be discarded");
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// return `${len} characters = ${msgCount} Messages*, Characters left: ${charLeft}`;
|
|
346
|
-
return {
|
|
347
|
-
totalLength: len,
|
|
348
|
-
msgCount,
|
|
349
|
-
charLeft,
|
|
350
|
-
};
|
|
351
|
-
}
|