@capillarytech/creatives-library 7.12.84 → 7.12.85
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.
|
@@ -13,7 +13,7 @@ import React from 'react';
|
|
|
13
13
|
import _ from 'lodash';
|
|
14
14
|
// import messages from './messages';
|
|
15
15
|
const loadScript = require('load-script');
|
|
16
|
-
const defaultScriptUrl = "https://ckeditor.com/assets/libs/ckeditor4/4.
|
|
16
|
+
const defaultScriptUrl = "https://ckeditor.com/assets/libs/ckeditor4/4.19.0/ckeditor.js";
|
|
17
17
|
const user = localStorage.getItem('user');
|
|
18
18
|
let locale = 'en';
|
|
19
19
|
if (user && JSON.parse(user).lang) {
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ import React from 'react';
|
|
|
13
13
|
import _ from 'lodash';
|
|
14
14
|
// import messages from './messages';
|
|
15
15
|
const loadScript = require('load-script');
|
|
16
|
-
const defaultScriptUrl = "https://ckeditor.com/assets/libs/ckeditor4/4.
|
|
16
|
+
const defaultScriptUrl = "https://ckeditor.com/assets/libs/ckeditor4/4.19.0/ckeditor.js";
|
|
17
17
|
const user = localStorage.getItem('user');
|
|
18
18
|
let locale = 'en';
|
|
19
19
|
if (user && JSON.parse(user).lang) {
|
|
@@ -322,7 +322,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
322
322
|
if (this.state.isEdit && nextProps.location.query.module === "library" && !_.isEmpty(nextProps.templateData) && !this.props.params.id && !nextProps.isGetFormData && _.isEmpty(_.get(this, `state.formData['template-subject']`))) {
|
|
323
323
|
this.startTemplateCreation(nextProps.templateData);
|
|
324
324
|
}
|
|
325
|
-
if (nextProps.location.query.module === 'library' && nextProps.isGetFormData && (this.props.isGetFormData
|
|
325
|
+
if (nextProps.location.query.module === 'library' && nextProps.isGetFormData && (this.props.isGetFormData!==nextProps.isGetFormData)) {
|
|
326
326
|
const formData = this.state.formData;
|
|
327
327
|
let isBeeEditor = false;
|
|
328
328
|
const isBEEEnable = this.checkBeeEditorAllowedForLibrary();
|
|
@@ -679,9 +679,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
679
679
|
channel: EMAIL,
|
|
680
680
|
timeTaken,
|
|
681
681
|
content: base?.[activeTab]?.['template-content'],
|
|
682
|
-
mode: isEdit ? EDIT : CREATE
|
|
682
|
+
mode: isEdit ? EDIT : CREATE
|
|
683
683
|
});
|
|
684
|
-
|
|
684
|
+
|
|
685
685
|
// this.resetSchema();
|
|
686
686
|
let message;
|
|
687
687
|
if (isEdit) {
|
|
@@ -870,6 +870,46 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
870
870
|
} else {
|
|
871
871
|
schema.containers[index].isActive = false;
|
|
872
872
|
}
|
|
873
|
+
// const isLanguageSupport = this.props.location.query.isLanguageSupport;
|
|
874
|
+
|
|
875
|
+
_.forEach(data.selectedLanguages, (lang, langIndex) => {
|
|
876
|
+
if ((type !== 'embedded' || (type === 'embedded' && isLanguageSupport === 'true')) && lang !== this.props.currentOrgDetails.basic_details.base_language) {
|
|
877
|
+
const tabContent = _.cloneDeep(containers[0].tabContent.sections[0]);
|
|
878
|
+
const tabContentSection = tabContent.inputFields[0].cols[0];
|
|
879
|
+
const panes = containers[0].panes.slice();
|
|
880
|
+
const firstPane = _.cloneDeep(panes[0]);
|
|
881
|
+
const sections = [];
|
|
882
|
+
_.forEach(firstPane.sections, (section) => {
|
|
883
|
+
let sect = _.cloneDeep(section);
|
|
884
|
+
|
|
885
|
+
if (sect.type === 'col-label') {
|
|
886
|
+
sect = this.cloneColLabel(sect, (langIndex + 1));
|
|
887
|
+
} else if (sect.type === 'multicols') {
|
|
888
|
+
sect = this.cloneMultiCol(sect, (langIndex + 1));
|
|
889
|
+
} else if (sect.type === 'parent') {
|
|
890
|
+
sect = this.cloneParent(sect, (langIndex + 1));
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
sections.push(sect);
|
|
894
|
+
return true;
|
|
895
|
+
});
|
|
896
|
+
//
|
|
897
|
+
|
|
898
|
+
this.map[`template-content${data.selectedLanguages.indexOf(lang) + 1}`] = this.map['template-content'];
|
|
899
|
+
tabContentSection.id = `${tabContentSection.id}${index + 1}`;
|
|
900
|
+
tabContentSection.value = `${data[lang].language}`;
|
|
901
|
+
|
|
902
|
+
firstPane.sections = sections;
|
|
903
|
+
firstPane.sectionsHeaders = [tabContent];
|
|
904
|
+
|
|
905
|
+
// panes.push(firstPane);
|
|
906
|
+
|
|
907
|
+
schema.containers[index].panes.push(firstPane);
|
|
908
|
+
} else if (lang !== this.props.currentOrgDetails.basic_details.base_language) {
|
|
909
|
+
delete data[lang];
|
|
910
|
+
data.selectedLanguages.splice(langIndex, 1);
|
|
911
|
+
}
|
|
912
|
+
});
|
|
873
913
|
}
|
|
874
914
|
if (data.base) {
|
|
875
915
|
formData.base = data;
|
|
@@ -2331,7 +2371,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2331
2371
|
const response = {
|
|
2332
2372
|
action: "getFormData",
|
|
2333
2373
|
postAction: this.state.getFormDataValue || 'next',
|
|
2334
|
-
id: _.get(this.props, 'Email.templateDetails._id', ''),
|
|
2374
|
+
id : _.get(this.props, 'Email.templateDetails._id', ''),
|
|
2335
2375
|
value: this.transformFormData(passedData),
|
|
2336
2376
|
validity: this.state.isFormValid,
|
|
2337
2377
|
type: 'EMAIL',
|
|
@@ -2365,8 +2405,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2365
2405
|
const newdata = data;
|
|
2366
2406
|
|
|
2367
2407
|
if (!isNaN(index) && newdata) {
|
|
2368
|
-
const baseLangTabKey = newdata[baseLanguage]
|
|
2408
|
+
const baseLangTabKey = newdata[baseLanguage].tabKey;
|
|
2369
2409
|
newdata.tabKey = baseLangTabKey;
|
|
2410
|
+
newdata.activeTab = baseLanguage;
|
|
2370
2411
|
if (newdata.base) {
|
|
2371
2412
|
baseKey = baseLangTabKey;
|
|
2372
2413
|
}
|
|
@@ -2388,7 +2429,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2388
2429
|
obj.versions.base = formData.base;
|
|
2389
2430
|
obj.versions.base.tabKey = baseKey;
|
|
2390
2431
|
obj.versions.base.subject = formData['template-subject'];
|
|
2391
|
-
obj.versions.base.activeTab =
|
|
2432
|
+
obj.versions.base.activeTab = baseLanguage;
|
|
2392
2433
|
_.forEach(obj.versions.base.selectedLanguages, (language) => {
|
|
2393
2434
|
if (obj.versions.base[language].is_drag_drop) {
|
|
2394
2435
|
delete obj.versions.base[language].edmeditorsrc;
|
|
@@ -2686,7 +2727,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2686
2727
|
isEdit={this.state.isEdit}
|
|
2687
2728
|
iframeParent={parent}
|
|
2688
2729
|
router={this.props.router}
|
|
2689
|
-
baseLanguage={this.
|
|
2730
|
+
baseLanguage={this.props.currentOrgDetails.basic_details.base_language}
|
|
2690
2731
|
supportedLanguages={this.getSupportedLanguages(this.props)}
|
|
2691
2732
|
isSchemaChanged={this.state.isSchemaChanged}
|
|
2692
2733
|
cmsTemplates={this.props.Templates.cmsTemplates}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
2
|
-
/* eslint-disable no-unused-expressions */
|
|
3
|
-
import { parse } from 'node-html-parser';
|
|
4
|
-
|
|
5
|
-
// https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=100,height=100,quality=75,fit=cover,g=top,format=auto/intouch_creative_assets/005710a7-6412-44fe-a19f-e72456b1.jpg
|
|
6
|
-
|
|
7
|
-
const CDN_BASE_URL = `https://storage.crm.n.content-cdn.io`;
|
|
8
|
-
const CDN_TRANSFORMATION_URL_SUFFIX = `/cdn-cgi/image/`;
|
|
9
|
-
const QUALITY = 75;
|
|
10
|
-
// const regex = /https:\/\/.*intouch_creative_assets.*(?:jpg|png|jpeg|gif)$/;
|
|
11
|
-
const regex = /https:\/\/.*intouch_creative_assets.*$/;
|
|
12
|
-
const INTOUCH_CREATIVE_ASSETS = 'intouch_creative_assets';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* getCdnUrl : utility function to replace and return s3/cdn url with cdn url.
|
|
16
|
-
*/
|
|
17
|
-
export const getCdnUrl = ({url, height, width, transformationEnabled = false, reduceQuality = true}) => {
|
|
18
|
-
if (!url.includes(INTOUCH_CREATIVE_ASSETS)) return url;
|
|
19
|
-
|
|
20
|
-
const [, assetKey] = url.split(INTOUCH_CREATIVE_ASSETS);
|
|
21
|
-
let newUrl = `${CDN_BASE_URL}`;
|
|
22
|
-
if (transformationEnabled || reduceQuality) {
|
|
23
|
-
newUrl += CDN_TRANSFORMATION_URL_SUFFIX;
|
|
24
|
-
if (height) {
|
|
25
|
-
newUrl += `height=${height},`;
|
|
26
|
-
}
|
|
27
|
-
if (width) {
|
|
28
|
-
newUrl += `width=${width},`;
|
|
29
|
-
}
|
|
30
|
-
newUrl += `quality=${QUALITY}`;
|
|
31
|
-
}
|
|
32
|
-
newUrl += `/intouch_creative_assets${assetKey}`;
|
|
33
|
-
return newUrl;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @param {*} htmlContents
|
|
39
|
-
* @returns htmlContents with updated urls in image tag
|
|
40
|
-
*/
|
|
41
|
-
export const updateImagesInHtml = (htmlContents) => {
|
|
42
|
-
const copiedHtmlContents = htmlContents;
|
|
43
|
-
try {
|
|
44
|
-
const root = parse(htmlContents);
|
|
45
|
-
root.querySelectorAll('img').forEach((element) => {
|
|
46
|
-
const imageSrc = element.getAttribute('src');
|
|
47
|
-
const isAsset = regex.test(imageSrc);
|
|
48
|
-
if (isAsset) {
|
|
49
|
-
const height = element.getAttribute('height');
|
|
50
|
-
const width = element.getAttribute('width');
|
|
51
|
-
const newUrl = getCdnUrl({url: imageSrc, height, width, transformationEnabled: true, reduceQuality: true});
|
|
52
|
-
element.setAttribute('src', newUrl);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return root.toString();
|
|
56
|
-
} catch (e) {
|
|
57
|
-
console.log('An error occured while updating images in html', e);
|
|
58
|
-
return copiedHtmlContents; //return received input directly in case an exception is thrown
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
* @param {*} contents
|
|
65
|
-
* @returns
|
|
66
|
-
*/
|
|
67
|
-
export const transformEmailTemplates = (contents) => {
|
|
68
|
-
const contentsCopy = cloneDeep(contents);
|
|
69
|
-
try {
|
|
70
|
-
const base = contentsCopy?.versions?.base;
|
|
71
|
-
const languages = base?.selectedLanguages;
|
|
72
|
-
languages?.forEach((lang) => {
|
|
73
|
-
const htmlContents = base?.[lang]?.['template-content'];
|
|
74
|
-
const newHtmlContents = updateImagesInHtml(htmlContents);
|
|
75
|
-
base[lang]['template-content'] = newHtmlContents;
|
|
76
|
-
});
|
|
77
|
-
return contentsCopy;
|
|
78
|
-
} catch (e) {
|
|
79
|
-
console.log('Some error has occured while transforming email templates', e);
|
|
80
|
-
return contents; //return received input directly in case an exception is thrown
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// export const transformRcsTemplates = (contents) => {
|
|
85
|
-
// const contentsCopy = cloneDeep(contents);
|
|
86
|
-
// }
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// {
|
|
90
|
-
// "name": "test 1",
|
|
91
|
-
// "versions": {
|
|
92
|
-
// "base": {
|
|
93
|
-
// "content": {
|
|
94
|
-
// "RCS": {
|
|
95
|
-
// "cardContent": [
|
|
96
|
-
// {
|
|
97
|
-
// "title": "asdf",
|
|
98
|
-
// "description": "asdf",
|
|
99
|
-
// "mediaType": "NONE"
|
|
100
|
-
// }
|
|
101
|
-
// ],
|
|
102
|
-
// "cardSettings": {
|
|
103
|
-
// "cardOrientation": "VERTICAL"
|
|
104
|
-
// },
|
|
105
|
-
// "cardType": "STANDALONE",
|
|
106
|
-
// "contentType": "RICHCARD",
|
|
107
|
-
// "smsFallBackContent": {
|
|
108
|
-
// "message": ""
|
|
109
|
-
// }
|
|
110
|
-
// }
|
|
111
|
-
// }
|
|
112
|
-
// }
|
|
113
|
-
// },
|
|
114
|
-
// "type": "RCS"
|
|
115
|
-
// }
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// {
|
|
119
|
-
// "name": "test 2",
|
|
120
|
-
// "versions": {
|
|
121
|
-
// "base": {
|
|
122
|
-
// "content": {
|
|
123
|
-
// "RCS": {
|
|
124
|
-
// "cardContent": [
|
|
125
|
-
// {
|
|
126
|
-
// "title": "asdfasdf",
|
|
127
|
-
// "description": "asdfadsf",
|
|
128
|
-
// "mediaType": "IMAGE",
|
|
129
|
-
// "suggestions": [
|
|
130
|
-
// {
|
|
131
|
-
// "type": "CTA",
|
|
132
|
-
// "text": "fasdf",
|
|
133
|
-
// "url": "https://www.google.com"
|
|
134
|
-
// }
|
|
135
|
-
// ],
|
|
136
|
-
// "media": {
|
|
137
|
-
// "mediaUrl": "https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/820a9ff9-ad5b-410e-b471-75c2e1a9.jpg",
|
|
138
|
-
// "height": "MEDIUM"
|
|
139
|
-
// }
|
|
140
|
-
// }
|
|
141
|
-
// ],
|
|
142
|
-
// "cardSettings": {
|
|
143
|
-
// "cardOrientation": "VERTICAL"
|
|
144
|
-
// },
|
|
145
|
-
// "cardType": "STANDALONE",
|
|
146
|
-
// "contentType": "RICHCARD",
|
|
147
|
-
// "smsFallBackContent": {
|
|
148
|
-
// "message": "asdf"
|
|
149
|
-
// }
|
|
150
|
-
// }
|
|
151
|
-
// }
|
|
152
|
-
// }
|
|
153
|
-
// },
|
|
154
|
-
// "type": "RCS"
|
|
155
|
-
// }
|