hivewrite-sdk 1.1.4 → 1.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 +38 -5
- package/bundle.min.js +1 -1
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ npm install hivewrite-sdk
|
|
|
28
28
|
|
|
29
29
|
### Via CDN (Plain HTML/JS)
|
|
30
30
|
```html
|
|
31
|
-
<script src="https://cdn.jsdelivr.net/npm/hivewrite-sdk/bundle.min.js"></script>
|
|
31
|
+
<script src="https://cdn.jsdelivr.net/npm/hivewrite-sdk@latest/bundle.min.js"></script>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
---
|
|
@@ -70,7 +70,7 @@ const MyEditor = () => {
|
|
|
70
70
|
```html
|
|
71
71
|
<div id="editor-container" style="height: 100vh;"></div>
|
|
72
72
|
|
|
73
|
-
<script src="https://cdn.jsdelivr.net/npm/hivewrite-sdk/bundle.min.js"></script>
|
|
73
|
+
<script src="https://cdn.jsdelivr.net/npm/hivewrite-sdk@latest/bundle.min.js"></script>
|
|
74
74
|
<script>
|
|
75
75
|
hivewrite.init({
|
|
76
76
|
apiKey: 'your-api-key',
|
|
@@ -101,6 +101,7 @@ Initializes and mounts the editor.
|
|
|
101
101
|
| :--- | :--- | :--- | :--- |
|
|
102
102
|
| `apiKey` | `string` | Yes | Your HiveWrite API Key |
|
|
103
103
|
| `container` | `string \| HTMLElement` | Yes | CSS selector or DOM element to mount the editor |
|
|
104
|
+
| `userId` | `string` | No | Unique identifier for the current user |
|
|
104
105
|
| `mode` | `string` | Yes | `'FULL_EDITOR'`, `'DESIGN_ONLY'`, `'READ_ONLY'` |
|
|
105
106
|
| `theme` | `string` | No | `'light'` (default) or `'dark'` |
|
|
106
107
|
| `locale` | `string` | No | `'en'` (default), `'es'`, or `'fr'` |
|
|
@@ -218,9 +219,10 @@ mergeTags: [
|
|
|
218
219
|
| Callback | Arguments | Description |
|
|
219
220
|
| :--- | :--- | :--- |
|
|
220
221
|
| `onLoad` | `()` | Editor fully initialized |
|
|
221
|
-
| `onSave` | `(json: any)` | User saves or `saveDesign` called |
|
|
222
|
-
| `onExport` | `(html: string)` | User exports or `exportHtml` called |
|
|
223
|
-
| `onError` | `(err: any)` | Initialization or processing error |
|
|
222
|
+
| `onSave` | `(json: any, userId?: string)` | User saves or `saveDesign` called |
|
|
223
|
+
| `onExport` | `(html: string, userId?: string)` | User exports or `exportHtml` called |
|
|
224
|
+
| `onError` | `(err: any, userId?: string)` | Initialization or processing error |
|
|
225
|
+
| `onTemplateChange` | `(templateId: string, userId?: string)` | Template selection changed |
|
|
224
226
|
| `onImageUpload` | `(file: File)` | **Async**. Handle image uploads, return URL |
|
|
225
227
|
|
|
226
228
|
### Image Upload Example
|
|
@@ -233,6 +235,32 @@ callbacks: {
|
|
|
233
235
|
const data = await res.json();
|
|
234
236
|
return data.url; // Return the uploaded image URL
|
|
235
237
|
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Response Examples
|
|
243
|
+
|
|
244
|
+
#### `onSave(design, userId)`
|
|
245
|
+
The `design` object contains the full state of the editor.
|
|
246
|
+
|
|
247
|
+
```json
|
|
248
|
+
{
|
|
249
|
+
"blocks": [ ... ], // Array of block objects
|
|
250
|
+
"canvasSettings": { ... }, // Canvas styles (width, background, etc)
|
|
251
|
+
"templateName": "My Email Template",
|
|
252
|
+
"userId": "user_12345" // The current user ID, If present
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### `onExport(html, userId)`
|
|
257
|
+
The `html` argument is a string containing the final generated HTML.
|
|
258
|
+
|
|
259
|
+
```javascript
|
|
260
|
+
// Example usage
|
|
261
|
+
onExport: (html, userId) => {
|
|
262
|
+
console.log(`Exported for user ${userId}`);
|
|
263
|
+
saveToDatabase(html);
|
|
236
264
|
}
|
|
237
265
|
```
|
|
238
266
|
|
|
@@ -272,6 +300,7 @@ Exported HTML is fully compatible with:
|
|
|
272
300
|
| `saveTemplate({ name })` | Save as reusable template |
|
|
273
301
|
| `importHTML({ html })` | Import HTML into editor (experimental) |
|
|
274
302
|
| `setTheme(theme)` | Switch theme at runtime |
|
|
303
|
+
| `setUserId(userId)` | Update user ID at runtime |
|
|
275
304
|
| `destroy()` | Unmount and cleanup |
|
|
276
305
|
|
|
277
306
|
---
|
|
@@ -279,3 +308,7 @@ Exported HTML is fully compatible with:
|
|
|
279
308
|
## 📄 License
|
|
280
309
|
|
|
281
310
|
MIT © [Babber Maven](https://github.com/babbermaven)
|
|
311
|
+
|
|
312
|
+
<br/>
|
|
313
|
+
|
|
314
|
+
Created & Maintained by [Shahzad Siddique](https://github.com/code-with-shahzad)
|