UNPKG

5.61 kBMarkdownView Raw
1# React Native Webview Quilljs
2## Quill.js editor and viewer components with no native code for React Native apps built using [Expo](https://expo.io/).
3
4[![npm](https://img.shields.io/npm/v/react-native-webview-quilljs.svg)](https://www.npmjs.com/package/react-native-webview-quilljs)
5[![npm](https://img.shields.io/npm/dm/react-native-webview-quilljs.svg)](https://www.npmjs.com/package/react-native-webview-quilljs)
6[![npm](https://img.shields.io/npm/dt/react-native-webview-quilljs.svg)](https://www.npmjs.com/package/react-native-webview-quilljs)
7[![npm](https://img.shields.io/npm/l/react-native-webview-quilljs.svg)](https://github.com/react-native-component/react-native-webview-quilljs/blob/master/LICENSE)
8
9
10![Image](https://thumbs.gfycat.com/CelebratedSilentDromedary-size_restricted.gif)
11
12## Try it in Expo
13![QR Code](https://github.com/reggie3/react-native-webview-quilljs/blob/master/expo-qr-code.png)
14
15
16[Link to Expo Project Page](https://expo.io/@reggie3/react-native-webview-quilljs)
17
18
19## Installation
20~~~
21npm install --save react-native-webview-quilljs
22~~~
23or
24~~~
25yarn add react-native-webview-quilljs
26~~~
27
28and then
29~~~
30import {WebViewQuillEditor, WebViewQuillViewer} from 'react-native-webview-quilljs'
31~~~
32
33## Usage
34This package can be used to create both an editor and a viewer
35
36Creating a Quill.js editor with the standard toolbar:
37~~~~
38 <WebViewQuillEditor
39 ref={component => (this.webViewQuillEditor = component)}
40 getDeltaCallback={this.getDeltaCallback}
41 contentToDisplay={contentToDisplay}
42 onLoad={this.onLoadCallback}
43 />
44~~~~
45
46This component accepts the following props:
47
48
49| Name | Required | Description |
50| ---------------------- | ------------- | ----------- |
51| ref | yes | A reference to the editor component to be used to retrieve its contents using this.webViewQuillEditor.getDelta();
52| getDeltaCallback | no | Function called in response to a call to this.webViewQuillEditor.getDelta(). It will receive a Delta object containing the contents of editor |
53| 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](https://quilljs.com/guides/designing-the-delta-format/)|
54| onLoad | no| A function called when the Editor finishes loading |
55| onDeltaChangeCallback | no | Function called when the contents of Quill editor have changed. The function receives a delta containing the following arguments:
56~~~
57deltaChange // changes to the delta
58delta // delta contents as received by getContents() mothod
59deltaOld // the previous contents of the editor
60changeSource // source of change (user, api, etc.)
61 ~~~
62Further information on what is returned is described in the Quill.js API [documentation](https://quilljs.com/docs/api/events.html) |
63| backgroundColor| no | String that equates to a valid CSS color value that the background of the editor will be set to|
64|getEditorCallback| no | A function that will receive the Quill.js editor as an arguement |
65
66
67Creating a Delta viewer that can display content created with Quill.js:
68~~~
69<WebViewQuillViewer
70 ref={component => (this.webViewQuillViewer = component)}
71 contentToDisplay={this.state.messageDelta}
72 onLoad={this.onLoadCallback}
73 />
74~~~
75
76This component accepts the following props:
77
78| Name | Required | Description |
79| ---------------------- | ------------- | ----------- |
80| ref | yes | A reference to the editor component to be used to update its contents using this.webViewQuillViewer.sendContentToViewer(delta);
81| 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](https://quilljs.com/guides/designing-the-delta-format/)|
82|onLoad | no| A function called when the Editor finishes loading |
83| backgroundColor| no | String that equates to a valid CSS color value that the background of the viewer will be set to|
84|getViewerCallback| no | A function that will receive the Quill.js viewer as an argument |
85
86## Changelog
87
88### 0.9.0
89
90* Replace Expo dependency with expo-asset-utils
91
92### 0.8.3
93
94* Updated onChangeCallback to receive the changes, contents, and previous contents of the delta
95
96### 0.8.0
97
98* Removes the propType specification for contentToDisplay to address issue #19
99
100### 0.6.5
101
102* Added initial testing framework
103
104### 0.6.0
105
106* 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.
107
108* Added getViewerCallback and getEditorCallback
109
110### 0.4.4
111
112* Changed HTTP path for files to be downloaded in preparation for potential inline JS bundling or Expo Packager bundling of files.
113
114### 0.4.0
115
116* Added "backgroundColor" props for both the WebViewQuillViewer and WebViewQuillEditor
117
118### 0.3.20
119
120* Added copy and paste of HTML
121
122### 0.3.10
123
124* Revert file access features from 0.3.0.
125
126### 0.3.0
127
128* 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.
129* Fonts display correctly on iOS devices
130
131### 0.2.5
132
133* Added onDeltaChangeCallback property to Editor
134
135## LICENSE
136
137MIT