Quill.js editor and viewer components with no native code for React Native apps built using Expo.
The new beta does not require downloading any files during program launch to make it work. All Editor and Viewer JavaScript files are bundled with the package.
install it by using:
npm install --save react-native-webview-quilljs@beta
or
yarn add react-native-webview-quilljs@beta
The code for the beta is in the inline-javascript-3 branch. NOTE: Barring any unforeseen circumstances, I will be merging the beta and publishing it by 7 April, 2018.
npm install --save react-native-webview-quilljs
or
yarn add react-native-webview-quilljs
and then
import {WebViewQuillEditor, WebViewQuillViewer} from 'react-native-webview-quilljs'
This package can be used to create both an editor and a viewer
Creating a Quill.js editor with the standard toolbar:
<WebViewQuillEditor
ref={component => (this.webViewQuillEditor = component)}
getDeltaCallback={this.getDeltaCallback}
contentToDisplay={contentToDisplay}
onLoad={this.onLoadCallback}
/>
This component accepts the following props:
Name | Required | Description |
---|---|---|
ref | yes | A reference to the editor componment to be used to retrieve its contents using this.webViewQuillEditor.getDelta(); |
getDeltaCallback | no | Function called in response to a call to this.webViewQuillEditor.getDelta(). It will receive a Delta object containing the contents of editor |
contentToDisplay | no | A Quill delta that will be displayed by the editor when it loads. A deltas is an array describing the content and formatting of the message. See delta details here |
onLoad | no | A function called when the Editor finishes loading |
onDeltaChangeCallback | no | Function called when the contents of Quill editor have changed. The function receives a delta containing the new contents, the old contents, and source as described in the Quill.js API documentation |
backgroundColor | no | String that equates to a valid CSS color value that the background of the editor will be set to |
getEditorCallback | no | A function that will receive the Quill.js editor as an arguement |
Creating a Delta viewer that can display content created with Quill.js:
<WebViewQuillViewer
ref={component => (this.webViewQuillViewer = component)}
contentToDisplay={this.state.messageDelta}
onLoad={this.onLoadCallback}
/>
This component accepts the following props:
Name | Required | Description |
---|---|---|
ref | yes | A reference to the editor componment to be used to update its contents using this.webViewQuillViewer.sendContentToViewer(delta); |
contentToDisplay | no | A Quill delta that will be displayed by the viewer when it loads. A deltas is an array describing the content and formatting of the message. See delta details here |
onLoad | no | A function called when the Editor finishes loading |
backgroundColor | no | String that equates to a valid CSS color value that the background of the viewer will be set to |
getViewerCallback | no | A function that will receive the Quill.js viewer as an arguement |
- Removes the propType specification for contentToDisplay to address issue #19
- Added initial testing framework
- Removed requirement to download JavaScript files from GitHub in order for the package to work. JavaScript files are now inline with the HTML which enables the package to work without an Internet connection.
- Added getViewerCallback and getEditorCallback
- Changed HTTP path for files to be downloaded in preparation for potential inline JS bundling or Expo Packager bundling of files.
- Added "backgroundColor" props for both the WebViewQuillViewer and WebViewQuillEditor
- Added copy and paste of HTML
- Revert file access features from 0.3.0.
- Library no longer relies on accessing WebView files from the Internet. All files needed by both the Editor and Viewer are included with the packages.
- Fonts display correctly on iOS devices
- Added onDeltaChangeCallback property to Editor
MIT