@capillarytech/creatives-library 2.0.66 → 2.0.69
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.
- package/components/Ckeditor/index.js +30 -3
- package/components/FormBuilder/index.js +50 -27
- package/components/FormBuilder/test +1845 -0
- package/components/Header/index.js +7 -4
- package/components/Header/messages.js +12 -0
- package/components/Sidebar/index.js +0 -27
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +42 -0
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +104 -0
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +21 -0
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/tests/index.test.js +10 -0
- package/containers/Cap/actions.js +6 -0
- package/containers/Cap/constants.js +2 -0
- package/containers/Cap/index.js +1 -22
- package/containers/Cap/reducer.js +4 -2
- package/containers/Cap/selectors.js +13 -0
- package/containers/CreativesContainer/SlideBoxContent.js +2 -1
- package/containers/Ebill/index.js +4 -21
- package/containers/Email/index.js +9 -24
- package/containers/Line/Create/index.js +5 -17
- package/containers/Line/Edit/index.js +5 -25
- package/containers/MobilePush/Create/index.js +5 -22
- package/containers/MobilePush/Create/selectors.js +1 -1
- package/containers/MobilePush/Edit/index.js +9 -30
- package/containers/MobilePush/Edit/selectors.js +2 -2
- package/containers/MobilePush/initialSchema.js +0 -12
- package/containers/MobilepushWrapper/index.js +3 -2
- package/containers/Sms/Create/index.js +17 -31
- package/containers/Sms/Edit/index.js +6 -20
- package/containers/Templates/index.js +60 -67
- package/containers/Templates/reducer.js +3 -3
- package/containers/WeChat/MapTemplates/index.js +6 -22
- package/containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +46 -2
- package/containers/WeChat/RichmediaTemplates/Create/actions.js +4 -3
- package/containers/WeChat/RichmediaTemplates/Create/constants.js +1 -0
- package/containers/WeChat/RichmediaTemplates/Create/index.js +525 -165
- package/containers/WeChat/RichmediaTemplates/Create/messages.js +125 -1
- package/containers/WeChat/RichmediaTemplates/Create/reducer.js +15 -4
- package/containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
- package/containers/WeChat/RichmediaTemplates/Create/sagas.js +7 -3
- package/containers/WeChat/RichmediaTemplates/Create/selectors.js +5 -0
- package/containers/WeChat/RichmediaTemplates/Edit/index.js +24 -8
- package/containers/WeChat/RichmediaTemplates/Edit/selectors.js +6 -1
- package/initialState.js +1 -0
- package/package.json +2 -2
- package/routes.js +22 -4
|
@@ -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://
|
|
16
|
+
const defaultScriptUrl = "https://ckeditor.com/assets/libs/ckeditor4/4.11.4/ckeditor.js";
|
|
17
17
|
const user = localStorage.getItem('user');
|
|
18
18
|
let locale = 'en';
|
|
19
19
|
if (user && JSON.parse(user).lang) {
|
|
@@ -70,10 +70,16 @@ const CKEditorConfig = {
|
|
|
70
70
|
class Ckeditor extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
71
71
|
constructor(props) {
|
|
72
72
|
super(props);
|
|
73
|
-
|
|
73
|
+
const config = CKEditorConfig;
|
|
74
|
+
if (this.props.channel && this.props.channel.toLowerCase() === 'wechat') {
|
|
75
|
+
config.startupFocus = false;
|
|
76
|
+
config.toolbar[6].items = ['Table', 'HorizontalRule', 'Smiley'];
|
|
77
|
+
config.width = 'calc(100% - 70px)';
|
|
78
|
+
config.height = 'calc(100vh - 450px)';
|
|
79
|
+
}
|
|
74
80
|
//State initialization
|
|
75
81
|
this.state = {
|
|
76
|
-
config
|
|
82
|
+
config,
|
|
77
83
|
events: {
|
|
78
84
|
blur: this.onBlur,
|
|
79
85
|
afterPaste: this.afterPaste,
|
|
@@ -157,6 +163,24 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
|
|
|
157
163
|
_.forEach(this.props.events, (event, index) => {
|
|
158
164
|
this.editorInstance.on(index, event);
|
|
159
165
|
});
|
|
166
|
+
if (this.props.channel.toLowerCase() === 'wechat') {
|
|
167
|
+
this.editorInstance.on('blur', this.onFocusOut);
|
|
168
|
+
_.forEach(this.props.events, (event, index) => {
|
|
169
|
+
this.editorInstance.on(index, event);
|
|
170
|
+
});
|
|
171
|
+
this.editorInstance.on('focus', this.onFocusIn);
|
|
172
|
+
_.forEach(this.props.events, (event, index) => {
|
|
173
|
+
this.editorInstance.on(index, event);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
onFocusOut = () => {
|
|
179
|
+
this.props.onFocusOut();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
onFocusIn = () => {
|
|
183
|
+
this.props.onFocusIn();
|
|
160
184
|
}
|
|
161
185
|
|
|
162
186
|
delay(callback, ms) {
|
|
@@ -201,6 +225,9 @@ Ckeditor.propTypes = {
|
|
|
201
225
|
events: PropTypes.object,
|
|
202
226
|
getEditorInstanse: PropTypes.func,
|
|
203
227
|
handleContentChange: PropTypes.func,
|
|
228
|
+
channel: PropTypes.string,
|
|
229
|
+
onFocusOut: PropTypes.func,
|
|
230
|
+
onFocusIn: PropTypes.func,
|
|
204
231
|
};
|
|
205
232
|
|
|
206
233
|
export default Ckeditor;
|
|
@@ -1967,10 +1967,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1967
1967
|
// }
|
|
1968
1968
|
return;
|
|
1969
1969
|
}
|
|
1970
|
-
|
|
1970
|
+
console.log('Call Event ', event, data, this.props.parent);
|
|
1971
|
+
// val.injectedEvents[event].call(this.props.parent, data);
|
|
1972
|
+
val.injectedEvents[event].call(this.props.parent, data, val.id);
|
|
1971
1973
|
}
|
|
1972
|
-
openFileDialog = () => {
|
|
1973
|
-
|
|
1974
|
+
openFileDialog = (e, parentID) => {
|
|
1975
|
+
console.log("filedialog: ");
|
|
1976
|
+
document.querySelector(`#${parentID} #fileName`).click();
|
|
1974
1977
|
};
|
|
1975
1978
|
handleOk = (ev) => {
|
|
1976
1979
|
const id = ev.target.id;
|
|
@@ -2036,6 +2039,12 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2036
2039
|
e.preventDefault();
|
|
2037
2040
|
const _URL = window.URL || window.webkitURL;
|
|
2038
2041
|
const file = files[0];
|
|
2042
|
+
if (val.supportedExtensions) {
|
|
2043
|
+
const allowedExtensions = /(\.bmp|\.jpeg|\.png|\.gif|\.jpg)$/i;
|
|
2044
|
+
if (!allowedExtensions.exec(file.name)) {
|
|
2045
|
+
this.callChildEvent({file, type: 'wrong file'}, val, val.submitAction);
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2039
2048
|
const img = new Image();
|
|
2040
2049
|
img.src = _URL.createObjectURL(file);
|
|
2041
2050
|
img.onload = () => {
|
|
@@ -2689,8 +2698,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2689
2698
|
<CapColumn span={val.width} offset={val.offset} style={val.style}>
|
|
2690
2699
|
{val.showPreview && <WithLabel key={`${val.id}-with-label`} {...rest} errorMessage={ifError && errorMessage}/>}
|
|
2691
2700
|
<form encType="multipart/form-data" id={val.id}>
|
|
2692
|
-
<input key={val.id} style={{ display: 'none'}} id="fileName" type="file" onChange={(e) => this.uploadImages(e, {files: e.target.files}, val)} accept="image/*" />
|
|
2693
|
-
<CapButton disabled={val.disabled ? val.disabled : false} type="secondary" onClick={(e) => this.openFileDialog(e)} style={{float: 'right'
|
|
2701
|
+
<input key={val.id} style={{ display: 'none'}} id="fileName" type="file" onChange={(e) => this.uploadImages(e, {files: e.target.files}, val)} accept={val.supportedExtensions ? val.supportedExtensions : "image/*"} />
|
|
2702
|
+
<CapButton disabled={val.disabled ? val.disabled : false} type="secondary" onClick={(e) => this.openFileDialog(e, val.id)} style={{float: 'right'}}>
|
|
2694
2703
|
{val.label}
|
|
2695
2704
|
</CapButton>
|
|
2696
2705
|
</form>
|
|
@@ -2891,31 +2900,46 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2891
2900
|
}
|
|
2892
2901
|
break;
|
|
2893
2902
|
case "ckeditor": {
|
|
2894
|
-
if (
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
let langIndex = 0;
|
|
2898
|
-
if (val.id.indexOf('template-content') > -1 && val.id !== 'template-content') {
|
|
2899
|
-
langIndex = parseInt(val.id.replace('template-content', ''), 10) - 1;
|
|
2900
|
-
}
|
|
2901
|
-
|
|
2902
|
-
const currentLang = (!_.isEmpty(this.state.formData) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`]) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages) && this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex]) ? this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex] : this.props.baseLanguage;
|
|
2903
|
-
const content = (!_.isEmpty(this.state.formData) && this.state.formData[`${this.state.currentTab - 1}`][currentLang]['template-content'] ? this.state.formData[`${this.state.currentTab - 1}`][currentLang]['template-content'] : '');
|
|
2904
|
-
|
|
2905
|
-
if (this.state.formData[`${this.state.currentTab - 1}`][currentLang].is_drag_drop) {
|
|
2906
|
-
// content = "";
|
|
2907
|
-
}
|
|
2908
|
-
columns.push(
|
|
2909
|
-
<CapColumn style={val.colStyle ? val.colStyle : {}} span={val.width}>
|
|
2903
|
+
if (this.props.schema && this.props.schema.channel && this.props.schema.channel.toLowerCase() === 'wechat' ) {
|
|
2904
|
+
const content = !_.isEmpty(this.state.formData) && this.state.formData['content-value'] ? this.state.formData['content-value'] : '';
|
|
2905
|
+
columns.push(
|
|
2910
2906
|
<CKEditor
|
|
2911
2907
|
id={val.id}
|
|
2912
2908
|
content={content}
|
|
2913
2909
|
events={val.events}
|
|
2914
2910
|
getEditorInstanse={(evt, id) => val.injectedEvents.getEditorInstanse.call(this, evt, id)}
|
|
2915
2911
|
handleContentChange={(event) => this.callChildEvent(event, val, 'onContentChange')}
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2912
|
+
channel="wechat"
|
|
2913
|
+
onFocusOut={(event) => this.callChildEvent(event, val, 'onFocusOut')}
|
|
2914
|
+
onFocusIn={(event) => this.callChildEvent(event, val, 'onFocusIn')}
|
|
2915
|
+
/> );
|
|
2916
|
+
} else {
|
|
2917
|
+
if (_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`])) {
|
|
2918
|
+
return true;
|
|
2919
|
+
}
|
|
2920
|
+
let langIndex = 0;
|
|
2921
|
+
if (val.id.indexOf('template-content') > -1 && val.id !== 'template-content') {
|
|
2922
|
+
langIndex = parseInt(val.id.replace('template-content', ''), 10) - 1;
|
|
2923
|
+
}
|
|
2924
|
+
console.log('CKEditor Data 2', this.state.formData, this.state.formData[`${this.state.currentTab - 1}`], val, this.state.currentTab, this.state.currentLangTab, langIndex);
|
|
2925
|
+
const currentLang = (!_.isEmpty(this.state.formData) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`]) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages) && this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex]) ? this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex] : this.props.baseLanguage;
|
|
2926
|
+
const content = (!_.isEmpty(this.state.formData) && this.state.formData[`${this.state.currentTab - 1}`][currentLang]['template-content'] ? this.state.formData[`${this.state.currentTab - 1}`][currentLang]['template-content'] : '');
|
|
2927
|
+
console.log('ckeditor current lang', currentLang, content);
|
|
2928
|
+
if (this.state.formData[`${this.state.currentTab - 1}`][currentLang].is_drag_drop) {
|
|
2929
|
+
// content = "";
|
|
2930
|
+
}
|
|
2931
|
+
columns.push(
|
|
2932
|
+
<CapColumn style={val.colStyle ? val.colStyle : {}} span={val.width}>
|
|
2933
|
+
<CKEditor
|
|
2934
|
+
id={val.id}
|
|
2935
|
+
content={content}
|
|
2936
|
+
events={val.events}
|
|
2937
|
+
getEditorInstanse={(evt, id) => val.injectedEvents.getEditorInstanse.call(this, evt, id)}
|
|
2938
|
+
handleContentChange={(event) => this.callChildEvent(event, val, 'onContentChange')}
|
|
2939
|
+
/>
|
|
2940
|
+
</CapColumn>
|
|
2941
|
+
);
|
|
2942
|
+
}
|
|
2919
2943
|
}
|
|
2920
2944
|
break;
|
|
2921
2945
|
case "edmeditor": {
|
|
@@ -3167,10 +3191,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3167
3191
|
});
|
|
3168
3192
|
|
|
3169
3193
|
allElements.push(renderedContainers);
|
|
3170
|
-
|
|
3171
|
-
const modal = this.getModal();
|
|
3172
|
-
allElements.push(modal);
|
|
3173
3194
|
}
|
|
3195
|
+
const modal = this.getModal();
|
|
3196
|
+
allElements.push(modal);
|
|
3174
3197
|
return allElements;
|
|
3175
3198
|
}
|
|
3176
3199
|
|