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 | ~~~
|
21 | npm install --save react-native-webview-quilljs
|
22 | ~~~
|
23 | or
|
24 | ~~~
|
25 | yarn add react-native-webview-quilljs
|
26 | ~~~
|
27 |
|
28 | and then
|
29 | ~~~
|
30 | import {WebViewQuillEditor, WebViewQuillViewer} from 'react-native-webview-quilljs'
|
31 | ~~~
|
32 |
|
33 | ## Usage
|
34 | This package can be used to create both an editor and a viewer
|
35 |
|
36 | Creating 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 |
|
46 | This 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 | ~~~
|
57 | deltaChange // changes to the delta
|
58 | delta // delta contents as received by getContents() mothod
|
59 | deltaOld // the previous contents of the editor
|
60 | changeSource // source of change (user, api, etc.)
|
61 | ~~~
|
62 | Further 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 |
|
67 | Creating 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 |
|
76 | This 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 | ### 0.8.3
|
88 | * Updated onChangeCallback to receive the changes, contents, and previous contents of the delta
|
89 | ### 0.8.0
|
90 | * Removes the propType specification for contentToDisplay to address issue #19
|
91 | ### 0.6.5
|
92 | * Added initial testing framework
|
93 | ### 0.6.0
|
94 | * 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.
|
95 | * Added getViewerCallback and getEditorCallback
|
96 | ### 0.4.4
|
97 | * Changed HTTP path for files to be downloaded in preparation for potential inline JS bundling or Expo Packager bundling of files.
|
98 | ### 0.4.0
|
99 | * Added "backgroundColor" props for both the WebViewQuillViewer and WebViewQuillEditor
|
100 | ### 0.3.20
|
101 | * Added copy and paste of HTML
|
102 | ### 0.3.10
|
103 | * Revert file access features from 0.3.0.
|
104 | ### 0.3.0
|
105 | * 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.
|
106 | * Fonts display correctly on iOS devices
|
107 | ### 0.2.5
|
108 | * Added onDeltaChangeCallback property to Editor
|
109 |
|
110 | ## LICENSE
|
111 |
|
112 | MIT
|