|
@@ -40,6 +40,7 @@ export default class RichTextEditor extends Component {
|
40
|
40
|
linkUrl: '',
|
41
|
41
|
keyboardHeight: 0
|
42
|
42
|
};
|
|
43
|
+ this._selectedTextChangeListeners = [];
|
43
|
44
|
}
|
44
|
45
|
|
45
|
46
|
componentWillMount() {
|
|
@@ -154,14 +155,20 @@ export default class RichTextEditor extends Component {
|
154
|
155
|
case messages.CONTENT_FOCUSED:
|
155
|
156
|
this.contentFocusHandler && this.contentFocusHandler();
|
156
|
157
|
break;
|
157
|
|
- case messages.SELECTION_CHANGE:
|
|
158
|
+ case messages.SELECTION_CHANGE: {
|
158
|
159
|
const items = message.data.items;
|
159
|
|
- this.state.listeners.map((listener) => listener(items));
|
160
|
|
- break
|
161
|
|
- case messages.CONTENT_CHANGE:
|
162
|
|
- const content = message.data.content;
|
163
|
|
- this.state.onChange.map((listener) => listener(content));
|
164
|
|
- break
|
|
160
|
+ this.state.listeners.map((listener) => {
|
|
161
|
+ listener(items);
|
|
162
|
+ });
|
|
163
|
+ break;
|
|
164
|
+ }
|
|
165
|
+ case messages.SELECTED_TEXT_CHANGED: {
|
|
166
|
+ const selectedText = message.data;
|
|
167
|
+ this._selectedTextChangeListeners.forEach((listener) => {
|
|
168
|
+ listener(selectedText);
|
|
169
|
+ });
|
|
170
|
+ break;
|
|
171
|
+ }
|
165
|
172
|
}
|
166
|
173
|
} catch(e) {
|
167
|
174
|
//alert('NON JSON MESSAGE');
|
|
@@ -559,6 +566,10 @@ export default class RichTextEditor extends Component {
|
559
|
566
|
this.contentFocusHandler = callbackHandler;
|
560
|
567
|
this._sendAction(actions.setContentFocusHandler);
|
561
|
568
|
}
|
|
569
|
+
|
|
570
|
+ addSelectedTextChangeListener(listener) {
|
|
571
|
+ this._selectedTextChangeListeners.push(listener);
|
|
572
|
+ }
|
562
|
573
|
}
|
563
|
574
|
|
564
|
575
|
const styles = StyleSheet.create({
|