hivewrite-sdk 1.0.5 → 1.0.7
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 +184 -53
- package/assets/hivewrite-icon.png +0 -0
- package/bundle.min.js +1 -1
- package/index.d.ts +3 -3
- package/index.js +1 -1
- package/package.json +3 -2
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,25 +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',
|
|
39
|
-
theme: 'dark',
|
|
40
|
-
locale: 'en',
|
|
53
|
+
theme: 'dark',
|
|
54
|
+
locale: 'en',
|
|
41
55
|
callbacks: {
|
|
42
56
|
onLoad: () => console.log('Editor ready'),
|
|
43
57
|
onSave: (design) => console.log('Saved:', design),
|
|
@@ -58,12 +72,12 @@ const MyEditor = () => {
|
|
|
58
72
|
|
|
59
73
|
<script src="https://cdn.jsdelivr.net/npm/hivewrite-sdk/bundle.min.js"></script>
|
|
60
74
|
<script>
|
|
61
|
-
|
|
75
|
+
hivewrite.init({
|
|
62
76
|
apiKey: 'your-api-key',
|
|
63
77
|
container: '#editor-container',
|
|
64
78
|
mode: 'FULL_EDITOR',
|
|
65
|
-
theme: 'dark',
|
|
66
|
-
locale: 'en',
|
|
79
|
+
theme: 'dark',
|
|
80
|
+
locale: 'en',
|
|
67
81
|
callbacks: {
|
|
68
82
|
onLoad: () => console.log('Editor ready'),
|
|
69
83
|
onSave: (design) => console.log('Saved:', design),
|
|
@@ -75,76 +89,193 @@ const MyEditor = () => {
|
|
|
75
89
|
|
|
76
90
|
---
|
|
77
91
|
|
|
78
|
-
## API Reference
|
|
92
|
+
## 📖 API Reference
|
|
93
|
+
|
|
94
|
+
### `hivewrite.init(config: SDKConfig)`
|
|
79
95
|
|
|
80
|
-
### `EmailEditor.init(config: SDKConfig)`
|
|
81
96
|
Initializes and mounts the editor.
|
|
82
97
|
|
|
83
|
-
####
|
|
98
|
+
#### SDKConfig Parameters
|
|
84
99
|
|
|
85
100
|
| Parameter | Type | Required | Description |
|
|
86
101
|
| :--- | :--- | :--- | :--- |
|
|
87
|
-
| `apiKey` | `string` | Yes | Your HiveWrite API Key
|
|
88
|
-
| `container` | `string \| HTMLElement` | Yes | CSS selector or DOM element to mount the editor
|
|
102
|
+
| `apiKey` | `string` | Yes | Your HiveWrite API Key |
|
|
103
|
+
| `container` | `string \| HTMLElement` | Yes | CSS selector or DOM element to mount the editor |
|
|
89
104
|
| `mode` | `string` | Yes | `'FULL_EDITOR'`, `'DESIGN_ONLY'`, `'READ_ONLY'` |
|
|
90
|
-
| `theme` | `string` | No | `'light'` (default) or `'dark'
|
|
91
|
-
| `locale` | `string` | No | `'en'` (default), `'es'`, or `'fr'
|
|
92
|
-
| `branding` | `object` | No | Custom white-labeling options
|
|
93
|
-
| `permissions
|
|
94
|
-
| `mergeTags` | `array` | No | Array of `{ name, value, category }` for dynamic content
|
|
95
|
-
| `callbacks` | `object` | No | Event hooks for SDK actions
|
|
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 |
|
|
96
111
|
|
|
97
112
|
---
|
|
98
113
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
|
102
|
-
| :--- | :--- |
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
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 |
|
|
108
133
|
|
|
109
134
|
---
|
|
110
135
|
|
|
111
|
-
|
|
136
|
+
## 📤 Export Options
|
|
112
137
|
|
|
113
|
-
|
|
114
|
-
|
|
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
|
+
```
|
|
115
147
|
|
|
116
|
-
|
|
117
|
-
|
|
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
|
|
118
159
|
|
|
119
|
-
|
|
120
|
-
Experimental: Attempts to parse HTML into editor blocks.
|
|
160
|
+
---
|
|
121
161
|
|
|
122
|
-
|
|
123
|
-
|
|
162
|
+
## 🎨 Theming & Branding
|
|
163
|
+
|
|
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
|
+
```
|
|
174
|
+
|
|
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
|
+
```
|
|
124
185
|
|
|
125
186
|
---
|
|
126
187
|
|
|
127
|
-
##
|
|
188
|
+
## 🔐 Permissions
|
|
128
189
|
|
|
129
|
-
|
|
130
|
-
Customize the editor appearance:
|
|
131
|
-
- `primaryColor`: Main button and active state color.
|
|
132
|
-
- `secondaryColor`: Secondary button and sidebar accents.
|
|
133
|
-
- `accentColor`: Highlight colors for focus states.
|
|
134
|
-
- `logoUrl`: Link to your company logo.
|
|
135
|
-
- `customCSS`: Inject global CSS overrides.
|
|
190
|
+
Control what features are available:
|
|
136
191
|
|
|
137
|
-
### Permissions
|
|
138
|
-
Control what your users can do:
|
|
139
192
|
```javascript
|
|
140
193
|
permissions: {
|
|
141
|
-
exportHTML: true,
|
|
142
|
-
aiMagic: true,
|
|
143
|
-
uploadImages: false
|
|
194
|
+
exportHTML: true, // Allow HTML export
|
|
195
|
+
aiMagic: true, // Enable AI features
|
|
196
|
+
uploadImages: false // Disable uploads (stock images only)
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 🏷️ Merge Tags
|
|
203
|
+
|
|
204
|
+
Add dynamic content placeholders:
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
mergeTags: [
|
|
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' }
|
|
211
|
+
]
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
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
|
+
}
|
|
144
236
|
}
|
|
145
237
|
```
|
|
146
238
|
|
|
147
239
|
---
|
|
148
240
|
|
|
149
|
-
##
|
|
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
|
+
|
|
150
281
|
MIT © [Babber Maven](https://github.com/babbermaven)
|
|
Binary file
|