@capillarytech/creatives-library 8.0.136-alpha.4 → 8.0.136-beta.3
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/BreadCrumbs/index.js +65 -0
- package/components/BreadCrumbs/messages.js +13 -0
- package/components/CapTagList/index.js +235 -0
- package/components/CapTagList/messages.js +45 -0
- package/components/Card/_customCard.scss +40 -0
- package/components/Card/index.js +78 -0
- package/components/Card/tests/__snapshots__/index.test.js.snap +22 -0
- package/components/Card/tests/index.test.js +20 -0
- package/components/CardGrid/index.js +71 -0
- package/components/Ckeditor/index.js +238 -0
- package/components/Ckeditor/messages.js +13 -0
- package/components/Ckeditor/style.scss +3 -0
- package/components/Component/index.js +29 -0
- package/components/CustomPopOver/index.js +81 -0
- package/components/CustomPopOver/messages.js +17 -0
- package/components/DateFilter/index.js +349 -0
- package/components/DateFilter/messages.js +57 -0
- package/components/DateRange/index.js +114 -0
- package/components/DateRange/messages.js +25 -0
- package/components/Edmeditor/index.js +65 -0
- package/components/Edmeditor/messages.js +13 -0
- package/components/EmailPreview/_emailPreview.scss +119 -0
- package/components/EmailPreview/assets/images/iPad.svg +10 -0
- package/components/EmailPreview/assets/images/mobile.png +0 -0
- package/components/EmailPreview/index.js +107 -0
- package/components/EmailPreview/messages.js +33 -0
- package/components/Footer/index.js +27 -0
- package/components/Footer/messages.js +13 -0
- package/components/FormBuilder/_formBuilder.scss +83 -0
- package/components/FormBuilder/index.js +3279 -0
- package/components/FormBuilder/messages.js +61 -0
- package/components/Header/index.js +44 -0
- package/components/Header/messages.js +29 -0
- package/components/ImagePreview/_imagePreview.scss +63 -0
- package/components/ImagePreview/index.js +52 -0
- package/components/ImagePreview/messages.js +17 -0
- package/components/PageHeader/_pageHeader.scss +22 -0
- package/components/PageHeader/index.js +37 -0
- package/components/PageHeader/messages.js +13 -0
- package/components/Pagination/_pagination.scss +5 -0
- package/components/Pagination/index.js +49 -0
- package/components/PreviewSideBar/_previewsidebar.scss +28 -0
- package/components/PreviewSideBar/index.js +152 -0
- package/components/PreviewSideBar/messages.js +41 -0
- package/components/Sidebar/_sidebar.scss +115 -0
- package/components/Sidebar/index.js +214 -0
- package/components/Sidebar/messages.js +21 -0
- package/components/SlideBox/_slideBox.scss +63 -0
- package/components/SlideBox/index.js +47 -0
- package/components/SlideBox/tests/index.test.js +103 -0
- package/components/SmsEditor/index.js +55 -0
- package/components/SmsTest/index.js +117 -0
- package/components/SmsTest/messages.js +21 -0
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +42 -0
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +141 -0
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +21 -0
- package/components/TemplatePreview/_templatePreview.scss +642 -0
- package/components/TemplatePreview/assets/images/WECHAT_5x.png +0 -0
- package/components/TemplatePreview/assets/images/androidPushMessage.svg +45 -0
- package/components/TemplatePreview/assets/images/home-screen-android.svg +21 -0
- package/components/TemplatePreview/assets/images/home-screen-ios.svg +16 -0
- package/components/TemplatePreview/assets/images/iPhonePushMessage.svg +135 -0
- package/components/TemplatePreview/assets/images/mobile.svg +24 -0
- package/components/TemplatePreview/assets/images/sms-body.png +0 -0
- package/components/TemplatePreview/assets/images/sms-icon.png +0 -0
- package/components/TemplatePreview/assets/images/sms_mobile.png +0 -0
- package/components/TemplatePreview/assets/images/sms_mobile_android.svg +22 -0
- package/components/TemplatePreview/assets/images/sms_mobile_ios.svg +16 -0
- package/components/TemplatePreview/assets/images/user-icon.svg +19 -0
- package/components/TemplatePreview/assets/images/wechat-mobile.svg +78 -0
- package/components/TemplatePreview/assets/images/wechat_mobile_android.svg +20 -0
- package/components/TemplatePreview/index.js +617 -0
- package/components/TemplatePreview/messages.js +78 -0
- package/components/Toastr/index.js +60 -0
- package/components/Toastr/messages.js +13 -0
- package/components/ToastrMessage/index.js +113 -0
- package/components/ToastrMessage/messages.js +17 -0
- package/components/TopBar/_topbar.scss +46 -0
- package/components/TopBar/assets/images/capillary_logo.png +0 -0
- package/components/TopBar/assets/images/old_capillary_logo.png +0 -0
- package/components/TopBar/index.js +113 -0
- package/components/TopBar/messages.js +29 -0
- package/containers/App/actions.js +7 -0
- package/containers/App/constants.js +114 -0
- package/containers/App/index.js +52 -0
- package/containers/App/reducer.js +19 -0
- package/containers/App/sagas.js +31 -0
- package/containers/App/selectors.js +25 -0
- package/containers/App/test/saga.test.js +11 -0
- package/containers/Assets/Gallery/_gallery.scss +126 -0
- package/containers/Assets/Gallery/actions.js +37 -0
- package/containers/Assets/Gallery/constants.js +23 -0
- package/containers/Assets/Gallery/index.js +473 -0
- package/containers/Assets/Gallery/messages.js +93 -0
- package/containers/Assets/Gallery/reducer.js +81 -0
- package/containers/Assets/Gallery/sagas.js +80 -0
- package/containers/Assets/Gallery/selectors.js +25 -0
- package/containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +9 -0
- package/containers/Assets/Gallery/tests/actions.test.js +25 -0
- package/containers/Assets/Gallery/tests/reducer.test.js +96 -0
- package/containers/Assets/Gallery/tests/saga.test.js +157 -0
- package/containers/Cap/actions.js +66 -0
- package/containers/Cap/constants.js +25 -0
- package/containers/Cap/index.js +402 -0
- package/containers/Cap/messages.js +75 -0
- package/containers/Cap/reducer.js +113 -0
- package/containers/Cap/sagas.js +159 -0
- package/containers/Cap/selectors.js +75 -0
- package/containers/Cap/tests/__snapshots__/index.test.js.snap +2269 -0
- package/containers/Cap/tests/index.test.js +22 -0
- package/containers/Cap/tests/saga.test.js +284 -0
- package/containers/Dashboard/actions.js +15 -0
- package/containers/Dashboard/constants.js +7 -0
- package/containers/Dashboard/index.js +76 -0
- package/containers/Dashboard/messages.js +13 -0
- package/containers/Dashboard/reducer.js +21 -0
- package/containers/Dashboard/sagas.js +17 -0
- package/containers/Dashboard/selectors.js +25 -0
- package/containers/Dashboard/test/saga.test.js +9 -0
- package/containers/Ebill/_ebill.scss +5 -0
- package/containers/Ebill/actions.js +43 -0
- package/containers/Ebill/constants.js +20 -0
- package/containers/Ebill/index.js +1278 -0
- package/containers/Ebill/messages.js +77 -0
- package/containers/Ebill/reducer.js +72 -0
- package/containers/Ebill/sagas.js +74 -0
- package/containers/Ebill/selectors.js +25 -0
- package/containers/Ebill/test/saga.test.js +11 -0
- package/containers/Email/_email.scss +141 -0
- package/containers/Email/actions.js +81 -0
- package/containers/Email/constants.js +36 -0
- package/containers/Email/index.js +3325 -0
- package/containers/Email/messages.js +289 -0
- package/containers/Email/reducer.js +142 -0
- package/containers/Email/sagas.js +135 -0
- package/containers/Email/selectors.js +31 -0
- package/containers/Email/test/saga.test.js +671 -0
- package/containers/LanguageProvider/actions.js +17 -0
- package/containers/LanguageProvider/constants.js +8 -0
- package/containers/LanguageProvider/index.js +80 -0
- package/containers/LanguageProvider/reducer.js +30 -0
- package/containers/LanguageProvider/selectors.js +20 -0
- package/containers/LanguageProvider/tests/actions.test.js +19 -0
- package/containers/LanguageProvider/tests/index.test.js +78 -0
- package/containers/LanguageProvider/tests/reducer.test.js +20 -0
- package/containers/LanguageProvider/tests/selectors.test.js +15 -0
- package/containers/Line/Create/_lineCreate.scss +54 -0
- package/containers/Line/Create/actions.js +90 -0
- package/containers/Line/Create/constants.js +39 -0
- package/containers/Line/Create/index.js +836 -0
- package/containers/Line/Create/messages.js +189 -0
- package/containers/Line/Create/reducer.js +99 -0
- package/containers/Line/Create/sagas.js +121 -0
- package/containers/Line/Create/selectors.js +36 -0
- package/containers/Line/Create/tests/saga.test.js +202 -0
- package/containers/Line/Edit/_lineEdit.scss +35 -0
- package/containers/Line/Edit/actions.js +79 -0
- package/containers/Line/Edit/constants.js +27 -0
- package/containers/Line/Edit/index.js +1050 -0
- package/containers/Line/Edit/messages.js +177 -0
- package/containers/Line/Edit/reducer.js +83 -0
- package/containers/Line/Edit/sagas.js +80 -0
- package/containers/Line/Edit/selectors.js +29 -0
- package/containers/Line/Edit/test/saga.test.js +160 -0
- package/containers/Login/assets/images/capillary_logo.png +0 -0
- package/containers/Login/components/LoginForm/index.js +62 -0
- package/containers/Login/components/LoginForm/messages.js +33 -0
- package/containers/Login/index.js +130 -0
- package/containers/Login/messages.js +25 -0
- package/containers/Login/selectors.js +25 -0
- package/containers/MobilePush/Create/_mobilePushCreate.scss +39 -0
- package/containers/MobilePush/Create/actions.js +46 -0
- package/containers/MobilePush/Create/constants.js +23 -0
- package/containers/MobilePush/Create/index.js +2303 -0
- package/containers/MobilePush/Create/messages.js +269 -0
- package/containers/MobilePush/Create/reducer.js +70 -0
- package/containers/MobilePush/Create/sagas.js +74 -0
- package/containers/MobilePush/Create/selectors.js +28 -0
- package/containers/MobilePush/Create/test/saga.test.js +19 -0
- package/containers/MobilePush/Edit/_mobilePushCreate.scss +39 -0
- package/containers/MobilePush/Edit/actions.js +91 -0
- package/containers/MobilePush/Edit/constants.js +35 -0
- package/containers/MobilePush/Edit/index.js +2601 -0
- package/containers/MobilePush/Edit/messages.js +266 -0
- package/containers/MobilePush/Edit/reducer.js +112 -0
- package/containers/MobilePush/Edit/sagas.js +126 -0
- package/containers/MobilePush/Edit/selectors.js +29 -0
- package/containers/MobilePush/Edit/tests/saga.test.js +255 -0
- package/containers/NotFoundPage/index.js +25 -0
- package/containers/NotFoundPage/messages.js +13 -0
- package/containers/NotFoundPage/tests/index.test.js +17 -0
- package/containers/Sms/Create/_smsCreate.scss +42 -0
- package/containers/Sms/Create/actions.js +27 -0
- package/containers/Sms/Create/constants.js +16 -0
- package/containers/Sms/Create/index.js +1488 -0
- package/containers/Sms/Create/messages.js +109 -0
- package/containers/Sms/Create/reducer.js +41 -0
- package/containers/Sms/Create/sagas.js +40 -0
- package/containers/Sms/Create/selectors.js +28 -0
- package/containers/Sms/Create/test/saga.test.js +11 -0
- package/containers/Sms/Edit/actions.js +40 -0
- package/containers/Sms/Edit/constants.js +17 -0
- package/containers/Sms/Edit/index.js +1472 -0
- package/containers/Sms/Edit/messages.js +105 -0
- package/containers/Sms/Edit/reducer.js +50 -0
- package/containers/Sms/Edit/sagas.js +60 -0
- package/containers/Sms/Edit/selectors.js +32 -0
- package/containers/Sms/Edit/test/saga.test.js +13 -0
- package/containers/TagList/_tagList.scss +8 -0
- package/containers/TagList/actions.js +15 -0
- package/containers/TagList/constants.js +32 -0
- package/containers/TagList/index.js +236 -0
- package/containers/TagList/messages.js +13 -0
- package/containers/TagList/reducer.js +23 -0
- package/containers/TagList/sagas.js +11 -0
- package/containers/TagList/selectors.js +25 -0
- package/containers/Templates/_templates.scss +333 -0
- package/containers/Templates/actions.js +103 -0
- package/containers/Templates/constants.js +60 -0
- package/containers/Templates/index.js +1756 -0
- package/containers/Templates/messages.js +337 -0
- package/containers/Templates/reducer.js +142 -0
- package/containers/Templates/sagas.js +163 -0
- package/containers/Templates/selectors.js +28 -0
- package/containers/Templates/test/saga.test.js +241 -0
- package/containers/WeChat/MapTemplates/_mapTemplates.scss +8 -0
- package/containers/WeChat/MapTemplates/actions.js +52 -0
- package/containers/WeChat/MapTemplates/constants.js +28 -0
- package/containers/WeChat/MapTemplates/index.js +1610 -0
- package/containers/WeChat/MapTemplates/messages.js +157 -0
- package/containers/WeChat/MapTemplates/reducer.js +74 -0
- package/containers/WeChat/MapTemplates/sagas.js +84 -0
- package/containers/WeChat/MapTemplates/selectors.js +25 -0
- package/containers/WeChat/MapTemplates/test/saga.test.js +155 -0
- package/containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +57 -0
- package/containers/WeChat/RichmediaTemplates/Create/actions.js +36 -0
- package/containers/WeChat/RichmediaTemplates/Create/constants.js +15 -0
- package/containers/WeChat/RichmediaTemplates/Create/index.js +1071 -0
- package/containers/WeChat/RichmediaTemplates/Create/messages.js +165 -0
- package/containers/WeChat/RichmediaTemplates/Create/reducer.js +60 -0
- package/containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
- package/containers/WeChat/RichmediaTemplates/Create/sagas.js +51 -0
- package/containers/WeChat/RichmediaTemplates/Create/selectors.js +37 -0
- package/containers/WeChat/RichmediaTemplates/Create/test/saga.test.js +13 -0
- package/containers/WeChat/RichmediaTemplates/Edit/actions.js +20 -0
- package/containers/WeChat/RichmediaTemplates/Edit/constants.js +10 -0
- package/containers/WeChat/RichmediaTemplates/Edit/index.js +136 -0
- package/containers/WeChat/RichmediaTemplates/Edit/messages.js +13 -0
- package/containers/WeChat/RichmediaTemplates/Edit/reducer.js +28 -0
- package/containers/WeChat/RichmediaTemplates/Edit/sagas.js +36 -0
- package/containers/WeChat/RichmediaTemplates/Edit/selectors.js +30 -0
- package/containers/WeChat/RichmediaTemplates/Edit/test/saga.test.js +12 -0
- package/containers/WeChat/RichmediaTemplates/View/actions.js +15 -0
- package/containers/WeChat/RichmediaTemplates/View/constants.js +7 -0
- package/containers/WeChat/RichmediaTemplates/View/index.js +47 -0
- package/containers/WeChat/RichmediaTemplates/View/messages.js +21 -0
- package/containers/WeChat/RichmediaTemplates/View/reducer.js +23 -0
- package/containers/WeChat/RichmediaTemplates/View/sagas.js +11 -0
- package/containers/WeChat/RichmediaTemplates/View/selectors.js +25 -0
- package/index.js +2 -4
- package/package.json +1 -1
- package/routes.js +202 -136
- package/services/getSchema.js +1 -1
- package/services/localStorageApi.js +0 -1
- package/tests/i18n.test.js +1 -1
- package/utils/asyncInjectors.js +78 -0
- package/utils/authWrapper.js +1 -1
- package/utils/callNativeEvent.js +16 -0
- package/utils/checkStore.js +21 -0
- package/utils/common.js +2 -2
- package/utils/customAuthWrapper.js +62 -0
- package/utils/customConnectedAuthWrapper.js +26 -0
- package/utils/tagValidations.js +1 -1
- package/utils/tests/checkStore.test.js +1 -1
- package/utils/tests/customAuth.test.js +1 -1
- package/utils/transformerUtils.js +195 -1
- package/v2Components/CapTagList/index.js +14 -9
- package/v2Components/Carousel/style.scss +1 -1
- package/v2Components/EmailMobilePreview/index.js +2 -2
- package/v2Components/FormBuilder/index.js +2 -2
- package/v2Components/TemplatePreview/index.js +1 -2
- package/v2Containers/Cap/tests/saga.test.js +1 -1
- package/v2Containers/Email/index.js +1 -1
- package/v2Containers/FTP/index.js +1 -1
- package/v2Containers/Line/Container/Text/index.js +6 -6
- package/v2Containers/Sms/Create/index.js +2 -2
- package/v2Containers/Sms/Edit/index.js +1 -1
- package/v2Containers/TagList/index.js +1 -1
- package/v2Containers/TagList/utils.js +1 -1
- package/v2Containers/Templates/index.js +1 -1
- package/v2Containers/Templates/sagas.js +1 -1
- package/constants/unified.js +0 -189
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Ckeditor
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
// import styled from 'styled-components';
|
|
11
|
+
|
|
12
|
+
// import { FormattedMessage } from 'react-intl';
|
|
13
|
+
import _ from 'lodash';
|
|
14
|
+
// import messages from './messages';
|
|
15
|
+
import './style.scss';
|
|
16
|
+
const loadScript = require('load-script');
|
|
17
|
+
// fetching ckeditor from s3 by rerouting through arya whitelisted services
|
|
18
|
+
const defaultScriptUrl = `${window.location.origin}/arya/ui/library/ckeditor/ckeditor.js`;
|
|
19
|
+
//Uncomment the above line to use CKEDITOR in local
|
|
20
|
+
// const defaultScriptUrl = 'https://crm-nightly-new.cc.capillarytech.com/arya/ui/library/ckeditor/ckeditor.js';
|
|
21
|
+
const user = localStorage.getItem('user');
|
|
22
|
+
let locale = 'en';
|
|
23
|
+
if (user && JSON.parse(user).lang) {
|
|
24
|
+
locale = JSON.parse(user).lang;
|
|
25
|
+
}
|
|
26
|
+
const CKEditorConfig = {
|
|
27
|
+
skin: 'moono-lisa',
|
|
28
|
+
toolbar: [
|
|
29
|
+
{ name: 'document', items: ['Source', '-'] },
|
|
30
|
+
{ name: 'clipboard', items: ['Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
|
|
31
|
+
{ name: 'editing', items: ['Find', 'Replace', '-', 'SelectAll', '-'] },
|
|
32
|
+
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'CopyFormatting', 'RemoveFormat'] },
|
|
33
|
+
{ name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language'] },
|
|
34
|
+
{ name: 'links', items: ['Link', 'Unlink', 'Anchor'] },
|
|
35
|
+
{ name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'Smiley'] },
|
|
36
|
+
// '/',
|
|
37
|
+
{ name: 'styles', items: ['Format', 'Font', 'FontSize'] },
|
|
38
|
+
{ name: 'colors', items: ['TextColor', 'BGColor'] },
|
|
39
|
+
{ name: 'tools', items: ['Maximize', 'ShowBlocks'] },
|
|
40
|
+
],
|
|
41
|
+
format_tags: 'p;h1;h2;h3;pre',
|
|
42
|
+
toolbarCanCollapse: true,
|
|
43
|
+
toolbarStartupExpanded: true,
|
|
44
|
+
uiColor: '#e3e3e3',
|
|
45
|
+
width: 'calc(100% - 2px)',
|
|
46
|
+
height: 'calc(100vh - 290px)',
|
|
47
|
+
fullPage: true,
|
|
48
|
+
htmlEncodeOutput: true,
|
|
49
|
+
startupFocus: true,
|
|
50
|
+
allowedContent: {
|
|
51
|
+
// Allow all content.
|
|
52
|
+
$1: {
|
|
53
|
+
// elements: this.editorInstance.dtd,
|
|
54
|
+
//elements: window.CKEDITOR.dtd,
|
|
55
|
+
attributes: true,
|
|
56
|
+
styles: true,
|
|
57
|
+
classes: true,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
disallowedContent: 'script; *[on*]',
|
|
61
|
+
language: locale,
|
|
62
|
+
toolbar_Basic:
|
|
63
|
+
[
|
|
64
|
+
['SwitchBar', '-', 'Source', '-', 'Bold', 'Italic', 'Underline'],
|
|
65
|
+
['NumberedList', 'BulletedList'],
|
|
66
|
+
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
|
|
67
|
+
['Link', 'Unlink', 'Anchor'],
|
|
68
|
+
['Image', 'Table'],
|
|
69
|
+
['Font', 'FontSize'],
|
|
70
|
+
['TextColor', 'BGColor'],
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
class Ckeditor extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
75
|
+
constructor(props) {
|
|
76
|
+
super(props);
|
|
77
|
+
const config = CKEditorConfig;
|
|
78
|
+
if (this.props.channel && this.props.channel.toLowerCase() === 'wechat') {
|
|
79
|
+
config.startupFocus = false;
|
|
80
|
+
config.toolbar[6].items = ['Table', 'HorizontalRule', 'Smiley'];
|
|
81
|
+
config.width = 'calc(100% - 70px)';
|
|
82
|
+
config.height = 'calc(100vh - 450px)';
|
|
83
|
+
}
|
|
84
|
+
//State initialization
|
|
85
|
+
this.state = {
|
|
86
|
+
config,
|
|
87
|
+
events: {
|
|
88
|
+
blur: this.onBlur,
|
|
89
|
+
afterPaste: this.afterPaste,
|
|
90
|
+
change: this.onChange,
|
|
91
|
+
},
|
|
92
|
+
content: "",
|
|
93
|
+
editorInstance: undefined,
|
|
94
|
+
setInitData: false,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
this.delayTimer = 0;
|
|
98
|
+
//Bindings
|
|
99
|
+
this.onLoad = this.onLoad.bind(this);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
componentWillMount() {
|
|
103
|
+
let content = '';
|
|
104
|
+
this.id = this.props.id;
|
|
105
|
+
if (this.props.content !== '') {
|
|
106
|
+
content = this.props.content;
|
|
107
|
+
content = content.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\\"/g, "\"");
|
|
108
|
+
}
|
|
109
|
+
this.setState({content}, () => {
|
|
110
|
+
if (this.editorInstance) {
|
|
111
|
+
this.editorInstance.setData(content);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//load ckeditor script as soon as component mounts if not already loaded
|
|
117
|
+
componentDidMount() {
|
|
118
|
+
loadScript(defaultScriptUrl, this.onLoad);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
componentWillReceiveProps(nextProps) {
|
|
122
|
+
this.id = this.props.id;
|
|
123
|
+
if (this.editorInstance && this.editorInstance.status === "ready") {
|
|
124
|
+
// setTimeout(() => {
|
|
125
|
+
// this.editorInstance.name = this.id;
|
|
126
|
+
// }, 5000);
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
componentWillUnmount() {
|
|
132
|
+
this.unmounting = true;
|
|
133
|
+
if (this.editorInstance) {
|
|
134
|
+
this.editorInstance.destroy();
|
|
135
|
+
if (window.CKEDITOR && !_.isEmpty(window.CKEDITOR.instances)) {
|
|
136
|
+
window.CKEDITOR.instances = {};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
onLoad() {
|
|
142
|
+
if (this.unmounting) return;
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if (!window.CKEDITOR) {
|
|
146
|
+
console.error("CKEditor not found");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
let html = this.props.content;
|
|
151
|
+
html = html.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"");
|
|
152
|
+
|
|
153
|
+
this.editorInstance = window.CKEDITOR.appendTo(
|
|
154
|
+
this.node,
|
|
155
|
+
this.state.config,
|
|
156
|
+
html
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
if (this.props.getEditorInstanse) {
|
|
161
|
+
this.props.getEditorInstanse(this.editorInstance, this.props.id);
|
|
162
|
+
}
|
|
163
|
+
//this.editorInstance.name = this.id;
|
|
164
|
+
|
|
165
|
+
//Register listener for custom events if any
|
|
166
|
+
this.editorInstance.on('change', this.handleContentChange);
|
|
167
|
+
_.forEach(this.props.events, (event, index) => {
|
|
168
|
+
this.editorInstance.on(index, event);
|
|
169
|
+
});
|
|
170
|
+
const channel = _.get(this.props, 'channel', '');
|
|
171
|
+
if (channel === 'wechat') {
|
|
172
|
+
this.editorInstance.on('blur', this.onFocusOut);
|
|
173
|
+
_.forEach(this.props.events, (event, index) => {
|
|
174
|
+
this.editorInstance.on(index, event);
|
|
175
|
+
});
|
|
176
|
+
this.editorInstance.on('focus', this.onFocusIn);
|
|
177
|
+
_.forEach(this.props.events, (event, index) => {
|
|
178
|
+
this.editorInstance.on(index, event);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
onFocusOut = () => {
|
|
184
|
+
this.props.onFocusOut();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
onFocusIn = () => {
|
|
188
|
+
this.props.onFocusIn();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
delay(callback, ms) {
|
|
192
|
+
clearTimeout(this.delayTimer);
|
|
193
|
+
this.delayTimer = setTimeout(callback, ms);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
handleContentChange = (evt) => {
|
|
197
|
+
// this.setState({content: this.editorInstance.getData()}, () => {
|
|
198
|
+
// this.props.handleContentChange(evt);
|
|
199
|
+
// // evt.setData(this.editorInstance.getData());
|
|
200
|
+
// });
|
|
201
|
+
this.delay(() => {
|
|
202
|
+
this.setState({content: this.editorInstance.getData()}, () => {
|
|
203
|
+
this.props.handleContentChange(evt);
|
|
204
|
+
});
|
|
205
|
+
}, 1000);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
render() {
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<div id={this.props.id} style={{borderRight: "1px solid #000 !important"}}>
|
|
212
|
+
<div className={this.props.activeClass} ref={(node) => (this.node = node)}/>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
Ckeditor.defaultProps = {
|
|
219
|
+
id: 'ckeditor',
|
|
220
|
+
content: "<html><body></body></html>",
|
|
221
|
+
config: {},
|
|
222
|
+
activeClass: "",
|
|
223
|
+
events: {},
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
Ckeditor.propTypes = {
|
|
227
|
+
id: PropTypes.string,
|
|
228
|
+
content: PropTypes.any,
|
|
229
|
+
activeClass: PropTypes.string,
|
|
230
|
+
events: PropTypes.object,
|
|
231
|
+
getEditorInstanse: PropTypes.func,
|
|
232
|
+
handleContentChange: PropTypes.func,
|
|
233
|
+
channel: PropTypes.string,
|
|
234
|
+
onFocusOut: PropTypes.func,
|
|
235
|
+
onFocusIn: PropTypes.func,
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export default Ckeditor;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ckeditor Messages
|
|
3
|
+
*
|
|
4
|
+
* This contains all the text for the Ckeditor component.
|
|
5
|
+
*/
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
|
|
8
|
+
export default defineMessages({
|
|
9
|
+
header: {
|
|
10
|
+
id: 'creatives.components.Ckeditor.header',
|
|
11
|
+
defaultMessage: 'This is the Ckeditor component !',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Component
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
import React from "react";
|
|
10
|
+
// import styled from 'styled-components';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Component extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
14
|
+
render() {
|
|
15
|
+
const className = this.props.name;
|
|
16
|
+
return (
|
|
17
|
+
<div className={className}>
|
|
18
|
+
{this.props.children}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Component.propTypes = {
|
|
25
|
+
name: PropTypes.string.isRequired,
|
|
26
|
+
children: PropTypes.array,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default Component;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* CustomPopOver
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import {CapPopover} from '@capillarytech/cap-react-ui-library';
|
|
11
|
+
import _ from "lodash";
|
|
12
|
+
import { FormattedMessage } from 'react-intl';
|
|
13
|
+
import messages from './messages';
|
|
14
|
+
|
|
15
|
+
class CustomPopOver extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
16
|
+
componentWillMount() {
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
componentWillReceiveProps(nextProps) {
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
renderPopoverContent() {
|
|
25
|
+
const elem = [];
|
|
26
|
+
_.forEach(this.props.popOverList, (content, index) => {
|
|
27
|
+
|
|
28
|
+
if (this.props.excludeList.indexOf(content.iso_code) === -1) {
|
|
29
|
+
elem.push(
|
|
30
|
+
<p style={{ cursor: "pointer"}} key={index} onClick={() => this.props.handlePopOverClick(content)}>{content.language}</p>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return elem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
render() {
|
|
39
|
+
return (
|
|
40
|
+
<div>
|
|
41
|
+
<CapPopover
|
|
42
|
+
id={this.props.id}
|
|
43
|
+
className={this.props.className}
|
|
44
|
+
trigger={this.props.trigger}
|
|
45
|
+
placement={this.props.placement}
|
|
46
|
+
visible={this.props.visible}
|
|
47
|
+
onVisibleChange={this.props.onVisibleChange}
|
|
48
|
+
style={{height: '100%'}}
|
|
49
|
+
content={
|
|
50
|
+
this.renderPopoverContent()
|
|
51
|
+
}
|
|
52
|
+
>
|
|
53
|
+
<p style={{fontFamily: "open-sans", fontWeight: '600', display: `${this.props.popOverList.length === this.props.excludeList.length ? 'none' : ''}`}}><FormattedMessage {...messages.languages} /></p>
|
|
54
|
+
</CapPopover>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
CustomPopOver.defaultProps = {
|
|
61
|
+
id: 'popover',
|
|
62
|
+
className: '',
|
|
63
|
+
trigger: "click",
|
|
64
|
+
placement: "bottomLeft",
|
|
65
|
+
popOverList: [],
|
|
66
|
+
excludeList: [],
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
CustomPopOver.propTypes = {
|
|
70
|
+
id: PropTypes.string,
|
|
71
|
+
className: PropTypes.string,
|
|
72
|
+
popOverList: PropTypes.array,
|
|
73
|
+
excludeList: PropTypes.array,
|
|
74
|
+
trigger: PropTypes.string,
|
|
75
|
+
placement: PropTypes.string,
|
|
76
|
+
visible: PropTypes.bool,
|
|
77
|
+
onVisibleChange: PropTypes.func,
|
|
78
|
+
handlePopOverClick: PropTypes.func,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default CustomPopOver;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* CustomPopOver Messages
|
|
3
|
+
*
|
|
4
|
+
* This contains all the text for the CustomPopOver component.
|
|
5
|
+
*/
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
|
|
8
|
+
export default defineMessages({
|
|
9
|
+
header: {
|
|
10
|
+
id: 'creatives.components.CustomPopOver.header',
|
|
11
|
+
defaultMessage: 'This is the CustomPopOver component !',
|
|
12
|
+
},
|
|
13
|
+
languages: {
|
|
14
|
+
id: 'creatives.components.CustomPopOver.languages',
|
|
15
|
+
defaultMessage: '+ Languages',
|
|
16
|
+
},
|
|
17
|
+
});
|