diff --git a/CHANGELOG.md b/CHANGELOG.md index f8b10be..18c1570 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ -## 1.4.2 +## 1.5.0 +- Add `onMessage` props on editor Callback outside postMessage internal type processing +- Added `_.sendEvent(type, data)` event callback to RN, using onMessage to receive callback + +## 1.4.0 #### Added - Add `pasteAsPlainText` props on editor - Add `removeFormat` props on editor diff --git a/README.md b/README.md index 961f392..ecccfa3 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,12 @@ The editor component. Simply place this component in your view hierarchy to rece * `onHeightChange` Callback after height change +* `onMessage` + Callback outside postMessage internal type processing + ``` + + ``` + * `useContainer` A boolean value that determines if a View container is wrapped around the WebView. The default value is true. If you are using your own View to wrap this library around, set this value to false. diff --git a/examples/src/example.js b/examples/src/example.js index 7d0819f..f09a712 100644 --- a/examples/src/example.js +++ b/examples/src/example.js @@ -5,6 +5,7 @@ */ import React from 'react'; import { + Alert, Appearance, Button, Keyboard, @@ -23,14 +24,14 @@ import {InsertLinkModal} from './insertLink'; import {EmojiView} from './emoji'; const initHTML = `
-
Rich Editor
+
Rich Editor
React Native And Flutter

- +



`; @@ -203,6 +204,19 @@ class Example extends React.Component { console.log('KeyDown:', data); }; + handleMessage = ({type, data}) => { + switch (type) { + case 'ImgClick': + Alert.alert('Click Image'); + break; + case 'TitleClick': + Alert.alert('Click Title'); + break; + default: + console.log('onMessage', type, data); + } + }; + render() { let that = this; const {contentStyle, theme, emojiVisible, disabled} = that.state; @@ -260,6 +274,7 @@ class Example extends React.Component { onPaste={that.handlePaste} onKeyUp={that.handleKeyUp} onKeyDown={that.handleKeyDown} + onMessage={that.handleMessage} pasteAsPlainText={true} /> diff --git a/src/RichEditor.js b/src/RichEditor.js index 80019be..d09c4c1 100755 --- a/src/RichEditor.js +++ b/src/RichEditor.js @@ -175,6 +175,9 @@ export default class RichTextEditor extends Component { case messages.OFFSET_HEIGHT: this.setWebHeight(data); break; + default: + this.props.onMessage && this.props.onMessage(message); + break; } } catch (e) { //alert('NON JSON MESSAGE'); diff --git a/src/editor.js b/src/editor.js index 23b6233..18b6cc3 100644 --- a/src/editor.js +++ b/src/editor.js @@ -40,7 +40,7 @@ function createHTML(options = {}) {