hivewrite-sdk 1.0.3 → 1.0.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 +193 -53
- package/bundle.min.js +1 -1
- package/index.d.ts +28 -13
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
# HiveWrite Email Editor SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A powerful, flexible, and easy-to-integrate drag-and-drop email builder for React or JavaScript applications. Create beautiful, responsive emails with a modern WYSIWYG editor.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/hivewrite-sdk)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## ✨ Features
|
|
9
|
+
|
|
10
|
+
- 📧 **Drag & Drop Editor** - Intuitive block-based email building
|
|
11
|
+
- 🎨 **Rich Block Types** - Text, images, buttons, videos, countdown timers, social icons, and more
|
|
12
|
+
- 📱 **Mobile Preview** - Real-time mobile (320px) and desktop preview modes
|
|
13
|
+
- 🌙 **Dark/Light Theme** - Built-in theme support
|
|
14
|
+
- 📤 **HTML/MJML Export** - Export responsive HTML emails compatible with all email clients
|
|
15
|
+
- 🎯 **Merge Tags** - Dynamic content placeholders for personalization
|
|
16
|
+
- 🖼️ **Stock Images** - Built-in Unsplash integration for stock photos
|
|
17
|
+
- 🏗️ **Pre-built Templates** - E-commerce, marketing, and transactional email templates
|
|
18
|
+
- 🔧 **Fully Customizable** - White-labeling, permissions, and branding options
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 📦 Installation
|
|
9
23
|
|
|
10
24
|
### Via NPM
|
|
11
25
|
```bash
|
|
@@ -19,23 +33,25 @@ npm install hivewrite-sdk
|
|
|
19
33
|
|
|
20
34
|
---
|
|
21
35
|
|
|
22
|
-
## Quick Start
|
|
36
|
+
## 🚀 Quick Start
|
|
23
37
|
|
|
24
38
|
### React Integration
|
|
25
39
|
|
|
26
40
|
```tsx
|
|
27
41
|
import React, { useEffect, useRef } from 'react';
|
|
28
|
-
import {
|
|
42
|
+
import { hivewrite } from 'hivewrite-sdk';
|
|
29
43
|
|
|
30
44
|
const MyEditor = () => {
|
|
31
45
|
const containerRef = useRef(null);
|
|
32
46
|
|
|
33
47
|
useEffect(() => {
|
|
34
48
|
if (containerRef.current) {
|
|
35
|
-
|
|
49
|
+
hivewrite.init({
|
|
36
50
|
apiKey: 'your-api-key',
|
|
37
51
|
container: containerRef.current,
|
|
38
52
|
mode: 'FULL_EDITOR',
|
|
53
|
+
theme: 'dark',
|
|
54
|
+
locale: 'en',
|
|
39
55
|
callbacks: {
|
|
40
56
|
onLoad: () => console.log('Editor ready'),
|
|
41
57
|
onSave: (design) => console.log('Saved:', design),
|
|
@@ -56,86 +72,210 @@ const MyEditor = () => {
|
|
|
56
72
|
|
|
57
73
|
<script src="https://cdn.jsdelivr.net/npm/hivewrite-sdk/bundle.min.js"></script>
|
|
58
74
|
<script>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
hivewrite.init({
|
|
76
|
+
apiKey: 'your-api-key',
|
|
77
|
+
container: '#editor-container',
|
|
78
|
+
mode: 'FULL_EDITOR',
|
|
79
|
+
theme: 'dark',
|
|
80
|
+
locale: 'en',
|
|
81
|
+
callbacks: {
|
|
82
|
+
onLoad: () => console.log('Editor ready'),
|
|
83
|
+
onSave: (design) => console.log('Saved:', design),
|
|
84
|
+
onExport: (html) => console.log('HTML:', html)
|
|
85
|
+
}
|
|
86
|
+
});
|
|
67
87
|
</script>
|
|
68
88
|
```
|
|
69
89
|
|
|
70
90
|
---
|
|
71
91
|
|
|
72
|
-
## API Reference
|
|
92
|
+
## 📖 API Reference
|
|
93
|
+
|
|
94
|
+
### `hivewrite.init(config: SDKConfig)`
|
|
73
95
|
|
|
74
|
-
### `EmailEditor.init(config: SDKConfig)`
|
|
75
96
|
Initializes and mounts the editor.
|
|
76
97
|
|
|
77
|
-
####
|
|
98
|
+
#### SDKConfig Parameters
|
|
78
99
|
|
|
79
100
|
| Parameter | Type | Required | Description |
|
|
80
101
|
| :--- | :--- | :--- | :--- |
|
|
81
|
-
| `apiKey` | `string` | Yes | Your HiveWrite API Key
|
|
82
|
-
| `container` | `string \| HTMLElement` | Yes | CSS selector or DOM element to mount the editor
|
|
83
|
-
| `mode` | `string` | Yes | `'FULL_EDITOR'`, `'DESIGN_ONLY'`, `'READ_ONLY'
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
102
|
+
| `apiKey` | `string` | Yes | Your HiveWrite API Key |
|
|
103
|
+
| `container` | `string \| HTMLElement` | Yes | CSS selector or DOM element to mount the editor |
|
|
104
|
+
| `mode` | `string` | Yes | `'FULL_EDITOR'`, `'DESIGN_ONLY'`, `'READ_ONLY'` |
|
|
105
|
+
| `theme` | `string` | No | `'light'` (default) or `'dark'` |
|
|
106
|
+
| `locale` | `string` | No | `'en'` (default), `'es'`, or `'fr'` |
|
|
107
|
+
| `branding` | `object` | No | Custom white-labeling options |
|
|
108
|
+
| `permissions` | `object` | No | Toggle features: `exportHTML`, `aiMagic`, `uploadImages` |
|
|
109
|
+
| `mergeTags` | `array` | No | Array of `{ name, value, category }` for dynamic content |
|
|
110
|
+
| `callbacks` | `object` | No | Event hooks for SDK actions |
|
|
88
111
|
|
|
89
112
|
---
|
|
90
113
|
|
|
91
|
-
|
|
114
|
+
## 🧱 Available Block Types
|
|
115
|
+
|
|
116
|
+
| Block | Description |
|
|
117
|
+
| :--- | :--- |
|
|
118
|
+
| `text` | Rich text paragraph |
|
|
119
|
+
| `heading1`, `heading2`, `heading3` | Heading elements |
|
|
120
|
+
| `image` | Image with alt text, link, and styling |
|
|
121
|
+
| `button` | CTA button with customizable colors and links |
|
|
122
|
+
| `divider` | Horizontal line separator |
|
|
123
|
+
| `video` | Video embed with poster image and play button |
|
|
124
|
+
| `timer` | Countdown timer (static snapshot in email export) |
|
|
125
|
+
| `icon` | Social/brand icons with shape options (circle, square, none) |
|
|
126
|
+
| `tiktok` | TikTok video embed card |
|
|
127
|
+
| `twitter` | X/Twitter post embed card |
|
|
128
|
+
| `bulletList`, `numberedList` | List elements |
|
|
129
|
+
| `blockquote` | Quote block |
|
|
130
|
+
| `columns2`, `columns3` | Multi-column layouts |
|
|
131
|
+
| `section` | Single column container |
|
|
132
|
+
| `html` | Custom HTML code block |
|
|
92
133
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 📤 Export Options
|
|
137
|
+
|
|
138
|
+
### Export to HTML
|
|
139
|
+
```javascript
|
|
140
|
+
const result = await hivewrite.export({
|
|
141
|
+
format: 'html',
|
|
142
|
+
minify: true,
|
|
143
|
+
inlineCSS: true
|
|
144
|
+
});
|
|
145
|
+
console.log(result.html);
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Export to JSON (Design)
|
|
149
|
+
```javascript
|
|
150
|
+
const result = await hivewrite.export({ format: 'json' });
|
|
151
|
+
console.log(result.design);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Export Features
|
|
155
|
+
- **Responsive HTML** - MJML-based output compatible with all email clients
|
|
156
|
+
- **Inline CSS** - Optional CSS inlining for maximum compatibility
|
|
157
|
+
- **Minification** - Reduce file size for production
|
|
158
|
+
- **Static Snapshots** - Countdown timers, videos, and embeds render as email-safe static content
|
|
101
159
|
|
|
102
160
|
---
|
|
103
161
|
|
|
104
|
-
|
|
162
|
+
## 🎨 Theming & Branding
|
|
105
163
|
|
|
106
|
-
|
|
107
|
-
|
|
164
|
+
### Theme Modes
|
|
165
|
+
```javascript
|
|
166
|
+
hivewrite.init({
|
|
167
|
+
theme: 'dark', // or 'light'
|
|
168
|
+
// ...
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Switch theme at runtime
|
|
172
|
+
hivewrite.setTheme('light');
|
|
173
|
+
```
|
|
108
174
|
|
|
109
|
-
|
|
110
|
-
|
|
175
|
+
### White Labeling
|
|
176
|
+
```javascript
|
|
177
|
+
branding: {
|
|
178
|
+
primaryColor: '#6366f1', // Main accent color
|
|
179
|
+
secondaryColor: '#8b5cf6', // Secondary elements
|
|
180
|
+
accentColor: '#ec4899', // Highlights and focus
|
|
181
|
+
logoUrl: 'https://yoursite.com/logo.png',
|
|
182
|
+
customCSS: '.my-class { color: red; }'
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
111
187
|
|
|
112
|
-
|
|
113
|
-
Compiles the current design into MJML-based responsive HTML.
|
|
188
|
+
## 🔐 Permissions
|
|
114
189
|
|
|
115
|
-
|
|
116
|
-
|
|
190
|
+
Control what features are available:
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
permissions: {
|
|
194
|
+
exportHTML: true, // Allow HTML export
|
|
195
|
+
aiMagic: true, // Enable AI features
|
|
196
|
+
uploadImages: false // Disable uploads (stock images only)
|
|
197
|
+
}
|
|
198
|
+
```
|
|
117
199
|
|
|
118
200
|
---
|
|
119
201
|
|
|
120
|
-
##
|
|
202
|
+
## 🏷️ Merge Tags
|
|
121
203
|
|
|
122
|
-
|
|
123
|
-
Customize the editor appearance to match your brand:
|
|
124
|
-
- `primaryColor`: Accent color for buttons and highlights.
|
|
125
|
-
- `logoUrl`: Custom logo in the editor sidebar/loading screen.
|
|
126
|
-
- `hidePoweredBy`: Remove HiveWrite branding.
|
|
127
|
-
- `customCSS`: Inject global CSS for deep styling overrides.
|
|
204
|
+
Add dynamic content placeholders:
|
|
128
205
|
|
|
129
|
-
### Merge Tags
|
|
130
|
-
Provide dynamic tags for personalization:
|
|
131
206
|
```javascript
|
|
132
207
|
mergeTags: [
|
|
133
|
-
{
|
|
134
|
-
{
|
|
208
|
+
{ name: 'First Name', value: '{{first_name}}', category: 'User' },
|
|
209
|
+
{ name: 'Company', value: '{{company}}', category: 'User' },
|
|
210
|
+
{ name: 'Unsubscribe Link', value: '{{unsubscribe_url}}', category: 'Links' }
|
|
135
211
|
]
|
|
136
212
|
```
|
|
137
213
|
|
|
138
214
|
---
|
|
139
215
|
|
|
140
|
-
##
|
|
216
|
+
## 📞 Callbacks
|
|
217
|
+
|
|
218
|
+
| Callback | Arguments | Description |
|
|
219
|
+
| :--- | :--- | :--- |
|
|
220
|
+
| `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 |
|
|
224
|
+
| `onImageUpload` | `(file: File)` | **Async**. Handle image uploads, return URL |
|
|
225
|
+
|
|
226
|
+
### Image Upload Example
|
|
227
|
+
```javascript
|
|
228
|
+
callbacks: {
|
|
229
|
+
onImageUpload: async (file) => {
|
|
230
|
+
const formData = new FormData();
|
|
231
|
+
formData.append('image', file);
|
|
232
|
+
const res = await fetch('/api/upload', { method: 'POST', body: formData });
|
|
233
|
+
const data = await res.json();
|
|
234
|
+
return data.url; // Return the uploaded image URL
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## 📱 Mobile Preview
|
|
242
|
+
|
|
243
|
+
The editor includes a mobile preview mode (320px width) with automatic scaling:
|
|
244
|
+
- Font sizes scale proportionally
|
|
245
|
+
- Images adapt to container width
|
|
246
|
+
- Spacing adjusts for mobile screens
|
|
247
|
+
|
|
248
|
+
Toggle between desktop and mobile using the view mode controls in the toolbar.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## 📧 Email Client Compatibility
|
|
253
|
+
|
|
254
|
+
Exported HTML is fully compatible with:
|
|
255
|
+
- Gmail (Web, iOS, Android)
|
|
256
|
+
- Apple Mail
|
|
257
|
+
- Outlook (Desktop, Web, Mobile)
|
|
258
|
+
- Yahoo Mail
|
|
259
|
+
- Samsung Mail
|
|
260
|
+
- And many more...
|
|
261
|
+
|
|
262
|
+
> **Note**: Some features like videos and iframes are rendered as static fallbacks since email clients don't support embedded media.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## 🛠️ Methods
|
|
267
|
+
|
|
268
|
+
| Method | Description |
|
|
269
|
+
| :--- | :--- |
|
|
270
|
+
| `init(config)` | Initialize the editor |
|
|
271
|
+
| `export({ format, minify?, inlineCSS? })` | Export design to HTML or JSON |
|
|
272
|
+
| `saveTemplate({ name })` | Save as reusable template |
|
|
273
|
+
| `importHTML({ html })` | Import HTML into editor (experimental) |
|
|
274
|
+
| `setTheme(theme)` | Switch theme at runtime |
|
|
275
|
+
| `destroy()` | Unmount and cleanup |
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## 📄 License
|
|
280
|
+
|
|
141
281
|
MIT © [Babber Maven](https://github.com/babbermaven)
|