Quill.js editor and viewer components with no native code for React Native apps. This is a purely JavaScript component based on @zenomaro's react-quill project (https://github.com/zenoamaro/react-quill/)
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
// A Quill.js editor with the standard toolbar
<WebViewQuillJS
defaultContent={this.state.defaultContent}
backgroundColor={"#FAEBD7"}
onMessageReceived={this.onMessageReceived}
/>
// A Quill.js viewer with no toolbar
<WebViewQuillJS
backgroundColor={"#fffbef"}
content={this.state.content}
isReadOnly
/>
This component accepts the following props:
property | required | type | purpose |
---|---|---|---|
backgroundColor | optional | string | The background color of the Quill Component |
content | optional | HTML, a Quill Delta, or a plain object representing a Delta | Content of a controlled viewer component |
defaultContent | optional | HTML, a Quill Delta, or a plain object representing a Delta | Inital value of an uncontrolled editor component |
doShowDebugMessages | optional | boolean | Show debug messages from the Webview Component |
doShowQuillComponentDebugMessages | optional | boolean | Show debug messages from the contents of the Webview component |
isReadOnly | optional | boolean | Editor or viewer component (false or true) |
onError | optional | function | Function called if the Webview component experiences an Error |
onLoadEnd | optional | function | Function called when the Webview has finished loading |
onLoadStart | optional | function | Function called if the Webview begins loading |
onMessageReceived | optional | function | Function called when the WebViewQuillJS component receives a message from the editor |
A WebviewQuillJSMessage object is passed to the onMessageReceived function:
export type WebviewQuillJSMessage = {
event?: WebviewQuillJSEvents,
msg?: string,
error?: string,
payload?: any
};
WebviewQuillJSEvents consists of the following enumerated values:
export enum WebviewQuillJSEvents {
QUILLJS_COMPONENT_MOUNTED = "QUILLJS_COMPONENT_MOUNTED",
DOCUMENT_EVENT_LISTENER_ADDED = "DOCUMENT_EVENT_LISTENER_ADDED",
WINDOW_EVENT_LISTENER_ADDED = "WINDOW_EVENT_LISTENER_ADDED",
UNABLE_TO_ADD_EVENT_LISTENER = "UNABLE_TO_ADD_EVENT_LISTENER",
DOCUMENT_EVENT_LISTENER_REMOVED = "DOCUMENT_EVENT_LISTENER_REMOVED",
WINDOW_EVENT_LISTENER_REMOVED = "WINDOW_EVENT_LISTENER_REMOVED",
// The following events correlate to the similarly named react-quill props
// https://github.com/zenoamaro/react-quill/#props
ON_CHANGE = "ON_CHANGE",
ON_CHANGE_SELECTION = "ON_CHANGE_SELECTION",
ON_FOCUS = "ON_FOCUS",
ON_BLUR = "ON_BLUR",
ON_KEY_PRESS = "ON_KEY_PRESS",
ON_KEY_DOWN = "ON_KEY_DOWN",
ON_KEY_UP = "ON_KEY_UP"
}
The payload
object contains the values passed to by the corresponding react-quilljs prop functions here: https://github.com/zenoamaro/react-quill/#props
- Replace Expo dependency with expo-asset-utils
- Updated onChangeCallback to receive the changes, contents, and previous contents of the delta
- 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 onContentChange property to Editor
- Add TypeScript support
- Switch to react-native-community/react-native-webview implementation
- Simplify event communication
MIT