|
@@ -19,7 +19,9 @@ export default class RichTextEditor extends Component {
|
19
|
19
|
titlePlaceholder: PropTypes.string,
|
20
|
20
|
contentPlaceholder: PropTypes.string,
|
21
|
21
|
editorInitializedCallback: PropTypes.func,
|
22
|
|
- customCSS: PropTypes.string
|
|
22
|
+ customCSS: PropTypes.string,
|
|
23
|
+ hiddenTitle: PropTypes.bool,
|
|
24
|
+ enableOnChange: PropTypes.bool
|
23
|
25
|
};
|
24
|
26
|
|
25
|
27
|
constructor(props) {
|
|
@@ -31,6 +33,7 @@ export default class RichTextEditor extends Component {
|
31
|
33
|
this._onKeyboardWillHide = this._onKeyboardWillHide.bind(this);
|
32
|
34
|
this.state = {
|
33
|
35
|
listeners: [],
|
|
36
|
+ onChange: [],
|
34
|
37
|
showLinkDialog: false,
|
35
|
38
|
linkInitialUrl: '',
|
36
|
39
|
linkTitle: '',
|
|
@@ -127,6 +130,10 @@ export default class RichTextEditor extends Component {
|
127
|
130
|
this.setContentPlaceholder(this.props.contentPlaceholder);
|
128
|
131
|
this.setTitleHTML(this.props.initialTitleHTML);
|
129
|
132
|
this.setContentHTML(this.props.initialContentHTML);
|
|
133
|
+
|
|
134
|
+ this.props.hiddenTitle && this.hideTitle();
|
|
135
|
+ this.props.enableOnChange && this.enableOnChange();
|
|
136
|
+
|
130
|
137
|
this.props.editorInitializedCallback && this.props.editorInitializedCallback();
|
131
|
138
|
|
132
|
139
|
break;
|
|
@@ -151,6 +158,10 @@ export default class RichTextEditor extends Component {
|
151
|
158
|
const items = message.data.items;
|
152
|
159
|
this.state.listeners.map((listener) => listener(items));
|
153
|
160
|
break
|
|
161
|
+ case messages.CONTENT_CHANGE:
|
|
162
|
+ const content = message.data.content;
|
|
163
|
+ this.state.onChange.map((listener) => listener(content));
|
|
164
|
+ break
|
154
|
165
|
}
|
155
|
166
|
} catch(e) {
|
156
|
167
|
//alert('NON JSON MESSAGE');
|
|
@@ -311,11 +322,29 @@ export default class RichTextEditor extends Component {
|
311
|
322
|
listeners: [...this.state.listeners, listener]
|
312
|
323
|
});
|
313
|
324
|
}
|
|
325
|
+
|
|
326
|
+ enableOnChange() {
|
|
327
|
+ this._sendAction(actions.enableOnChange);
|
|
328
|
+ }
|
|
329
|
+
|
|
330
|
+ registerContentChangeListener(listener) {
|
|
331
|
+ this.setState({
|
|
332
|
+ onChange: [...this.state.onChange, listener]
|
|
333
|
+ });
|
|
334
|
+ }
|
314
|
335
|
|
315
|
336
|
setTitleHTML(html) {
|
316
|
337
|
this._sendAction(actions.setTitleHtml, html);
|
317
|
338
|
}
|
318
|
|
-
|
|
339
|
+ hideTitle() {
|
|
340
|
+ this._sendAction(actions.hideTitle);
|
|
341
|
+ }
|
|
342
|
+ showTitle() {
|
|
343
|
+ this._sendAction(actions.showTitle);
|
|
344
|
+ }
|
|
345
|
+ toggleTitle() {
|
|
346
|
+ this._sendAction(actions.toggleTitle);
|
|
347
|
+ }
|
319
|
348
|
setContentHTML(html) {
|
320
|
349
|
this._sendAction(actions.setContentHtml, html);
|
321
|
350
|
}
|