@ninesstudios/whiteboard 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/whiteboard.es.js +2588 -2565
- package/dist/whiteboard.es.js.map +1 -1
- package/dist/whiteboard.umd.js +23 -23
- package/dist/whiteboard.umd.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -140,6 +140,33 @@ function App() {
|
|
|
140
140
|
| `isLocked` | `boolean` | `false` | When `true`, disables all editing tools and shows a lock indicator. |
|
|
141
141
|
| `lockText` | `string` | `undefined` | Custom text to display on the lock indicator when `isLocked` is true. |
|
|
142
142
|
| `onLockChange` | `(isLocked: boolean) => void` | `undefined` | Callback fired when the lock state changes. |
|
|
143
|
+
| `onImageUpload` | `(file: File) => Promise<string>` | `undefined` | Async callback to handle image uploads. Must return a Promise that resolves to the image URL. |
|
|
144
|
+
|
|
145
|
+
### Handling Image Uploads
|
|
146
|
+
|
|
147
|
+
By default, the whiteboard creates temporary Blob URLs for uploaded images. This works great for local sessions but won't work for real-time collaboration because Blob URLs are local to the browser tab.
|
|
148
|
+
|
|
149
|
+
To support multiplayer image sharing, you must provide the `onImageUpload` prop. This function should upload the file to your server (e.g., S3, Cloudinary) and return the public URL.
|
|
150
|
+
|
|
151
|
+
```jsx
|
|
152
|
+
const handleImageUpload = async (file) => {
|
|
153
|
+
// 1. Upload file to your server
|
|
154
|
+
const formData = new FormData();
|
|
155
|
+
formData.append('file', file);
|
|
156
|
+
|
|
157
|
+
const response = await fetch('https://your-api.com/upload', {
|
|
158
|
+
method: 'POST',
|
|
159
|
+
body: formData
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const data = await response.json();
|
|
163
|
+
|
|
164
|
+
// 2. Return the public URL
|
|
165
|
+
return data.url;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
<Whiteboard onImageUpload={handleImageUpload} />
|
|
169
|
+
```
|
|
143
170
|
|
|
144
171
|
### Ref Methods
|
|
145
172
|
|