@capillarytech/creatives-library 0.0.4 → 0.0.6

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,10 +13,18 @@ class CardGrid extends React.Component { // eslint-disable-line react/prefer-sta
13
13
  super(props);
14
14
  this.handleOnItemHover = this.handleOnItemHover.bind(this);
15
15
  this.handleOnItemClick = this.handleOnItemClick.bind(this);
16
+ this.delayTimer = 0;
16
17
  }
17
18
 
18
19
  handleOnItemHover(state, id) {
19
- this.props.onHoverItem(state, id);
20
+ this.delay(() => {
21
+ this.props.onHoverItem(state, id);
22
+ }, 200);
23
+ }
24
+
25
+ delay(callback, ms) {
26
+ clearTimeout(this.delayTimer);
27
+ this.delayTimer = setTimeout(callback, ms);
20
28
  }
21
29
 
22
30
  handleOnItemClick(state, id) {
@@ -27,7 +35,7 @@ class CardGrid extends React.Component { // eslint-disable-line react/prefer-sta
27
35
  return (
28
36
  <div className={this.props.className}>
29
37
  <div style={{ marginBottom: '16px' }}>{this.props.filterContent}</div>
30
- {this.props.listItem && this.props.listItem.length > 0 && <div className={this.props.enablePagination ? 'pagination-container' : ''}>
38
+ <div className={this.props.enablePagination ? 'pagination-container' : ''}>
31
39
  <Row gutter={this.props.gutterSize}>
32
40
  { this.props.listItem ? this.props.listItem.map( (item) => (
33
41
  <Col style={{ width: `${100 / this.props.colNumber}%`, paddingBottom: '16px'}} key={item.id} span={parseInt(24 / this.props.colNumber, 10)}>
@@ -35,7 +43,7 @@ class CardGrid extends React.Component { // eslint-disable-line react/prefer-sta
35
43
  </Col>
36
44
  )) : ''}
37
45
  </Row>
38
- </div>}
46
+ </div>
39
47
  </div>
40
48
  );
41
49
  }
@@ -77,6 +77,7 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
77
77
  },
78
78
  content: "",
79
79
  editorInstance: undefined,
80
+ setInitData: false,
80
81
  };
81
82
 
82
83
  this.delayTimer = 0;
@@ -86,10 +87,16 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
86
87
 
87
88
  componentWillMount() {
88
89
  let content = '';
90
+ this.id = this.props.id;
89
91
  if (this.props.content !== '') {
90
92
  content = this.props.content;
93
+ content = content.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/\\&quot;/g, "\"");
91
94
  }
92
- this.setState({content});
95
+ this.setState({content}, () => {
96
+ if (this.editorInstance) {
97
+ this.editorInstance.setData(content);
98
+ }
99
+ });
93
100
  }
94
101
 
95
102
  //load ckeditor script as soon as component mounts if not already loaded
@@ -98,22 +105,12 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
98
105
  }
99
106
 
100
107
  componentWillReceiveProps(nextProps) {
108
+ this.id = this.props.id;
101
109
  if (this.editorInstance && this.editorInstance.status === "ready") {
110
+ // setTimeout(() => {
111
+ // this.editorInstance.name = this.id;
112
+ // }, 5000);
102
113
  console.log('nextProps CKEditor', nextProps, this.state.content, this.props.id);
103
- // if (!_.isEqual(nextProps.content, this.state.content)) {
104
- if (nextProps.content !== this.state.content) {
105
- let html = nextProps.content;
106
- if (html && html !== "") {
107
- console.log('html ckeditor', html);
108
- html = html.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/\\&quot;/g, "\"");
109
- }
110
- console.log("New content", nextProps.content, this.state.content, html);
111
- this.setState({content: html}, () => {
112
- this.editorInstance.setData(html);
113
- // this.editorInstance.insertHtml(html);
114
- // this.editorInstance.content = html;
115
- });
116
- }
117
114
  }
118
115
  }
119
116
 
@@ -135,7 +132,7 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
135
132
 
136
133
  let html = this.props.content;
137
134
  html = html.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"");
138
- console.log("ckeditor loading 1", this.node);
135
+ console.log("ckeditor loading 1", this.node, html);
139
136
  this.editorInstance = window.CKEDITOR.appendTo(
140
137
  this.node,
141
138
  this.state.config,
@@ -144,8 +141,9 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
144
141
  console.log('2');
145
142
 
146
143
  if (this.props.getEditorInstanse) {
147
- this.props.getEditorInstanse(this.editorInstance);
144
+ this.props.getEditorInstanse(this.editorInstance, this.props.id);
148
145
  }
146
+ //this.editorInstance.name = this.id;
149
147
 
150
148
  //Register listener for custom events if any
151
149
  this.editorInstance.on('change', this.handleContentChange);
@@ -160,6 +158,10 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
160
158
  }
161
159
 
162
160
  handleContentChange = (evt) => {
161
+ // this.setState({content: this.editorInstance.getData()}, () => {
162
+ // this.props.handleContentChange(evt);
163
+ // // evt.setData(this.editorInstance.getData());
164
+ // });
163
165
  this.delay(() => {
164
166
  this.setState({content: this.editorInstance.getData()}, () => {
165
167
  this.props.handleContentChange(evt);
@@ -168,6 +170,7 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
168
170
  };
169
171
 
170
172
  render() {
173
+ console.log('ckeditor loading render', this.props);
171
174
  return (
172
175
  <div id={this.props.id} style={{borderRight: "1px solid #000 !important"}}>
173
176
  <div className={this.props.activeClass} ref={(node) => (this.node = node)}/>
@@ -35,7 +35,6 @@ class CustomPopOver extends React.Component { // eslint-disable-line react/prefe
35
35
  }
36
36
 
37
37
  render() {
38
- console.log('Test Custom popover', this.props.popOverList.length, this.props.excludeList.length);
39
38
  return (
40
39
  <div>
41
40
  <CapPopover
@@ -43,6 +42,8 @@ class CustomPopOver extends React.Component { // eslint-disable-line react/prefe
43
42
  className={this.props.className}
44
43
  trigger={this.props.trigger}
45
44
  placement={this.props.placement}
45
+ visible={this.props.visible}
46
+ onVisibleChange={this.props.onVisibleChange}
46
47
  style={{height: '100%'}}
47
48
  content={
48
49
  this.renderPopoverContent()
@@ -71,6 +72,8 @@ CustomPopOver.propTypes = {
71
72
  excludeList: PropTypes.array,
72
73
  trigger: PropTypes.string,
73
74
  placement: PropTypes.string,
75
+ visible: PropTypes.bool,
76
+ onVisibleChange: PropTypes.func,
74
77
  handlePopOverClick: PropTypes.func,
75
78
  };
76
79
 
@@ -91,7 +91,7 @@ EmailPreview.propTypes = {
91
91
  content: PropTypes.oneOfType([
92
92
  PropTypes.object,
93
93
  PropTypes.string,
94
- ]).isRequired,
94
+ ]),
95
95
  show: PropTypes.bool,
96
96
  device: PropTypes.string,
97
97
  handleClose: PropTypes.func,