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 | ## New Beta Version With Full Offline Support Now Available
|
19 | 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.
|
20 | install it by using:
|
21 | ~~~
|
22 | npm install --save react-native-webview-quilljs@beta
|
23 | ~~~
|
24 | or
|
25 | ~~~
|
26 | yarn add react-native-webview-quilljs@beta
|
27 | ~~~
|
28 |
|
29 | The code for the beta is in the inline-javascript-3 branch.
|
30 | NOTE: Barring any unforeseen circumstances, I will be merging the beta and publishing it by 7 April, 2018.
|
31 |
|
32 | ## Installation
|
33 | ~~~
|
34 | npm install --save react-native-webview-quilljs
|
35 | ~~~
|
36 | or
|
37 | ~~~
|
38 | yarn add react-native-webview-quilljs
|
39 | ~~~
|
40 |
|
41 | and then
|
42 | ~~~
|
43 | import {WebViewQuillEditor, WebViewQuillViewer} from 'react-native-webview-quilljs'
|
44 | ~~~
|
45 |
|
46 | ## Usage
|
47 | This package can be used to create both an editor and a viewer
|
48 |
|
49 | Creating a Quill.js editor with the standard toolbar:
|
50 | ~~~~
|
51 | <WebViewQuillEditor
|
52 | ref={component => (this.webViewQuillEditor = component)}
|
53 | getDeltaCallback={this.getDeltaCallback}
|
54 | contentToDisplay={contentToDisplay}
|
55 | onLoad={this.onLoadCallback}
|
56 | />
|
57 | ~~~~
|
58 |
|
59 | This component accepts the following props:
|
60 |
|
61 |
|
62 | | Name | Required | Description |
|
63 | | ---------------------- | ------------- | ----------- |
|
64 | | ref | yes | A reference to the editor componment to be used to retrieve its contents using this.webViewQuillEditor.getDelta();
|
65 | | getDeltaCallback | no | Function called in response to a call to this.webViewQuillEditor.getDelta(). It will receive a Delta object containing the contents of editor |
|
66 | | 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/)|
|
67 | | onLoad | no| A function called when the Editor finishes loading |
|
68 | | 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](https://quilljs.com/docs/api/events.html) |
|
69 | | backgroundColor| no | String that equates to a valid CSS color value that the background of the editor will be set to|
|
70 | |getEditorCallback| no | A function that will receive the Quill.js editor as an arguement |
|
71 |
|
72 |
|
73 | Creating a Delta viewer that can display content created with Quill.js:
|
74 | ~~~
|
75 | <WebViewQuillViewer
|
76 | ref={component => (this.webViewQuillViewer = component)}
|
77 | contentToDisplay={this.state.messageDelta}
|
78 | onLoad={this.onLoadCallback}
|
79 | />
|
80 | ~~~
|
81 |
|
82 | This component accepts the following props:
|
83 |
|
84 | | Name | Required | Description |
|
85 | | ---------------------- | ------------- | ----------- |
|
86 | | ref | yes | A reference to the editor componment to be used to update its contents using this.webViewQuillViewer.sendContentToViewer(delta);
|
87 | | 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/)|
|
88 | |onLoad | no| A function called when the Editor finishes loading |
|
89 | | backgroundColor| no | String that equates to a valid CSS color value that the background of the viewer will be set to|
|
90 | |getViewerCallback| no | A function that will receive the Quill.js viewer as an arguement |
|
91 |
|
92 | ## Changelog
|
93 | ### 0.8.0
|
94 | * Removes the propType specification for contentToDisplay to address issue #19
|
95 | ### 0.6.5
|
96 | * Added initial testing framework
|
97 | ### 0.6.0
|
98 | * 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.
|
99 | * Added getViewerCallback and getEditorCallback
|
100 | ### 0.4.4
|
101 | * Changed HTTP path for files to be downloaded in preparation for potential inline JS bundling or Expo Packager bundling of files.
|
102 | ### 0.4.0
|
103 | * Added "backgroundColor" props for both the WebViewQuillViewer and WebViewQuillEditor
|
104 | ### 0.3.20
|
105 | * Added copy and paste of HTML
|
106 | ### 0.3.10
|
107 | * Revert file access features from 0.3.0.
|
108 | ### 0.3.0
|
109 | * 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.
|
110 | * Fonts display correctly on iOS devices
|
111 | ### 0.2.5
|
112 | * Added onDeltaChangeCallback property to Editor
|
113 |
|
114 | ## LICENSE
|
115 |
|
116 | MIT
|