hivewrite-sdk 1.1.16 → 1.1.17
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 +88 -21
- package/bundle.min.js +1 -1
- package/index.d.ts +31 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,11 +101,11 @@ Initializes and mounts the editor.
|
|
|
101
101
|
| `apiKey` | `string` | Yes | Your HiveWrite API Key |
|
|
102
102
|
| `container` | `string \| HTMLElement` | Yes | CSS selector or DOM element to mount the editor |
|
|
103
103
|
| `userId` | `string` | No | Unique identifier for the current user |
|
|
104
|
-
| `mode` | `string` | Yes | `'FULL_EDITOR'`, `'DESIGN_ONLY'`, `'READ_ONLY'` |
|
|
104
|
+
| `mode` | `string` | Yes | `'FULL_EDITOR'`, `'DESIGN_ONLY'`, `'READ_ONLY'`, `'HTML_IMPORT'` |
|
|
105
105
|
| `theme` | `string` | No | `'light'` (default) or `'dark'` |
|
|
106
106
|
| `locale` | `string` | No | `'en'` (default), `'es'`, or `'fr'` |
|
|
107
|
-
| `branding` | `object` | No | Custom white-labeling options |
|
|
108
|
-
| `permissions` | `object` | No | Toggle features: `export`, `aiMagic`, `uploadImages` |
|
|
107
|
+
| `branding` | `object` | No | Custom white-labeling options (`primaryColor`, `secondaryColor`, `accentColor`, `logoUrl`, `customCSS`) |
|
|
108
|
+
| `permissions` | `object` | No | Toggle features: `export`, `aiMagic`, `uploadImages`, `hideSaveButton` |
|
|
109
109
|
| `mergeTags` | `array` | No | Array of `{ label, value }` for dynamic content |
|
|
110
110
|
| `portalTarget` | `string` | No | `'window'` (default) or `'container'`. Controls where dialogs render. |
|
|
111
111
|
| `callbacks` | `object` | No | Event hooks for SDK actions |
|
|
@@ -140,10 +140,10 @@ Initializes and mounts the editor.
|
|
|
140
140
|
```javascript
|
|
141
141
|
const result = await hivewrite.export({
|
|
142
142
|
format: 'html',
|
|
143
|
-
minify: true
|
|
144
|
-
inlineCSS: true
|
|
143
|
+
minify: true
|
|
145
144
|
});
|
|
146
|
-
|
|
145
|
+
// Or use the shorthand
|
|
146
|
+
hivewrite.exportHtml((html) => console.log(html));
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
### Export to JSON (Design)
|
|
@@ -192,9 +192,10 @@ Control what features are available:
|
|
|
192
192
|
|
|
193
193
|
```javascript
|
|
194
194
|
permissions: {
|
|
195
|
-
export: true,
|
|
195
|
+
export: true, // Allow HTML export
|
|
196
196
|
aiMagic: true, // Enable AI features
|
|
197
|
-
uploadImages: false
|
|
197
|
+
uploadImages: false, // Disable uploads (stock images only)
|
|
198
|
+
hideSaveButton: true // Hide the built-in save button
|
|
198
199
|
}
|
|
199
200
|
```
|
|
200
201
|
|
|
@@ -210,7 +211,6 @@ mergeTags: [
|
|
|
210
211
|
{ label: 'Company', value: '{{company}}' },
|
|
211
212
|
{ label: 'Unsubscribe Link', value: '{{unsubscribe_url}}' }
|
|
212
213
|
]
|
|
213
|
-
```
|
|
214
214
|
|
|
215
215
|
---
|
|
216
216
|
|
|
@@ -219,7 +219,8 @@ mergeTags: [
|
|
|
219
219
|
| Callback | Arguments | Description |
|
|
220
220
|
| :--- | :--- | :--- |
|
|
221
221
|
| `onLoad` | `()` | Editor fully initialized |
|
|
222
|
-
| `onExport` | `(html: string, userId?: string)` |
|
|
222
|
+
| `onExport` | `(html: string, userId?: string)` | Triggered on HTML export |
|
|
223
|
+
| `onSave` | `(json: {blocks: any[], canvasSettings: CanvasSettings, name: string, description: string, category: string}, userId?: string)` | Triggered on design save |
|
|
223
224
|
| `onError` | `(err: any, userId?: string)` | Initialization or processing error |
|
|
224
225
|
| `onTemplateChange` | `(templateId: string, userId?: string)` | Template selection changed |
|
|
225
226
|
| `onImageUpload` | `(file: File, userId?: string)` | **Async**. Handle image uploads, return URL |
|
|
@@ -241,18 +242,20 @@ callbacks: {
|
|
|
241
242
|
### Response Examples
|
|
242
243
|
|
|
243
244
|
#### `hivewrite.save()`
|
|
244
|
-
|
|
245
|
+
Triggers the `onSave` callback with the current design state.
|
|
245
246
|
|
|
246
247
|
```javascript
|
|
247
|
-
|
|
248
|
-
console.log(design);
|
|
248
|
+
hivewrite.save();
|
|
249
249
|
|
|
250
|
-
//
|
|
250
|
+
// Result sent to onSave(json, userId):
|
|
251
251
|
{
|
|
252
|
-
"
|
|
252
|
+
"body": {
|
|
253
|
+
"blocks": [ ... ] // Array of block objects
|
|
254
|
+
},
|
|
253
255
|
"canvasSettings": { ... }, // Canvas styles (width, background, etc)
|
|
254
|
-
"
|
|
255
|
-
"
|
|
256
|
+
"name": "My Email Template",
|
|
257
|
+
"description": "Here will be the description",
|
|
258
|
+
"category": "marketing"
|
|
256
259
|
}
|
|
257
260
|
```
|
|
258
261
|
|
|
@@ -269,6 +272,67 @@ onExport: (html, userId) => {
|
|
|
269
272
|
|
|
270
273
|
---
|
|
271
274
|
|
|
275
|
+
## 🏗️ Design JSON Format
|
|
276
|
+
|
|
277
|
+
The `loadDesign(data)` method and `onSave` callback use a specific JSON structure.
|
|
278
|
+
|
|
279
|
+
### `data` Object
|
|
280
|
+
|
|
281
|
+
| Property | Type | Description |
|
|
282
|
+
| :--- | :--- | :--- |
|
|
283
|
+
| `blocks` | `EditorBlock[]` | Array of content blocks |
|
|
284
|
+
| `canvasSettings` | `CanvasSettings` | Global editor styles and branding |
|
|
285
|
+
|
|
286
|
+
### JSON Example
|
|
287
|
+
|
|
288
|
+
```json
|
|
289
|
+
{
|
|
290
|
+
"blocks": [
|
|
291
|
+
{
|
|
292
|
+
"id": "os-UuWl9Cx32T7OYMdmRO",
|
|
293
|
+
"type": "text",
|
|
294
|
+
"content": {
|
|
295
|
+
"text": "<a href=\"#\" style=\"color:#666;text-decoration:none;\">View in browser</a>"
|
|
296
|
+
},
|
|
297
|
+
"styles": {
|
|
298
|
+
"textAlign": "center",
|
|
299
|
+
"fontSize": "12px",
|
|
300
|
+
"color": "#666",
|
|
301
|
+
"padding": "10px",
|
|
302
|
+
"backgroundColor": "#FFFFFF"
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"id": "II1rUSyoqXnn9qTqQp54h",
|
|
307
|
+
"type": "image",
|
|
308
|
+
"content": {
|
|
309
|
+
"src": "https://images.unsplash.com/photo-1504674900247-0877df9cc836?q=80&w=800&auto=format&fit=crop"
|
|
310
|
+
},
|
|
311
|
+
"styles": {
|
|
312
|
+
"width": "100%",
|
|
313
|
+
"height": "300px",
|
|
314
|
+
"objectFit": "cover"
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
],
|
|
318
|
+
"canvasSettings": {
|
|
319
|
+
"backgroundColor": "#ffffff",
|
|
320
|
+
"outerBackgroundColor": "#ffffff",
|
|
321
|
+
"width": "100%",
|
|
322
|
+
"maxWidth": "600px",
|
|
323
|
+
"fontFamily": "Inter, sans-serif",
|
|
324
|
+
"padding": "32px",
|
|
325
|
+
"branding": {
|
|
326
|
+
"primary": "#000000",
|
|
327
|
+
"secondary": "#4b5563",
|
|
328
|
+
"accent": "#2563eb"
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
272
336
|
## 📱 Mobile Preview
|
|
273
337
|
|
|
274
338
|
The editor includes a mobile preview mode (350px width) with automatic scaling:
|
|
@@ -299,11 +363,14 @@ Exported HTML is fully compatible with:
|
|
|
299
363
|
| Method | Description |
|
|
300
364
|
| :--- | :--- |
|
|
301
365
|
| `init(config)` | Initialize the editor |
|
|
302
|
-
| `
|
|
303
|
-
| `
|
|
304
|
-
| `
|
|
366
|
+
| `loadDesign(data)` | Load a previously saved JSON design |
|
|
367
|
+
| `export({ format, minify? })` | Export design to HTML, JSON, or MJML |
|
|
368
|
+
| `exportHtml(callback)` | Shorthand for HTML export |
|
|
369
|
+
| `exportJson(callback)` | Shorthand for JSON export |
|
|
370
|
+
| `exportMjml(callback)` | Shorthand for MJML export |
|
|
371
|
+
| `save()` | Triggers `onSave` callback with current JSON |
|
|
305
372
|
| `setTheme(theme)` | Switch theme at runtime |
|
|
306
|
-
| `
|
|
373
|
+
| `setLocale(locale)` | Switch locale at runtime |
|
|
307
374
|
| `destroy()` | Unmount and cleanup |
|
|
308
375
|
|
|
309
376
|
---
|