@devhiteshk/email-template-editor 1.0.0
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/LICENSE +21 -0
- package/README.md +163 -0
- package/dist/email-template-editor.js +114148 -0
- package/dist/email-template-editor.umd.cjs +539 -0
- package/package.json +91 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Waypoint (Metaccountant, Inc.)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Email Template Editor
|
|
2
|
+
|
|
3
|
+
A complete React email template editor with Material-UI theming, drag-and-drop functionality, and real-time preview.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎨 **Complete Material-UI Integration** - Purple-themed design system
|
|
8
|
+
- 📧 **Email Template Building** - Drag-and-drop email components
|
|
9
|
+
- 🔧 **Editable Template Names** - Inline editing with auto-save
|
|
10
|
+
- 🎯 **Variable Management** - Dynamic content with variable extraction
|
|
11
|
+
- 📱 **Responsive Design** - Works on desktop and mobile
|
|
12
|
+
- 🌐 **SSR Compatible** - Works with Next.js and other SSR frameworks
|
|
13
|
+
- ⚡ **Built with Vite** - Fast development and optimized builds
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @your-username/email-template-editor
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Peer Dependencies
|
|
22
|
+
|
|
23
|
+
Make sure you have these peer dependencies installed:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/icons-material
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Basic Usage
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import React from 'react';
|
|
35
|
+
import { EmailTemplateEditor } from '@your-username/email-template-editor';
|
|
36
|
+
|
|
37
|
+
function App() {
|
|
38
|
+
const handleSave = (blockTemplate, htmlTemplate, variables, templateName) => {
|
|
39
|
+
console.log('Template saved:', {
|
|
40
|
+
blockTemplate,
|
|
41
|
+
htmlTemplate,
|
|
42
|
+
variables,
|
|
43
|
+
templateName
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<EmailTemplateEditor
|
|
49
|
+
templateName="My Newsletter"
|
|
50
|
+
onSave={handleSave}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### SSR Usage (Next.js)
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import React from 'react';
|
|
60
|
+
import { ClientOnlyEmailTemplateEditor } from '@your-username/email-template-editor';
|
|
61
|
+
|
|
62
|
+
export default function EmailBuilderPage() {
|
|
63
|
+
const handleSave = (blockTemplate, htmlTemplate, variables, templateName) => {
|
|
64
|
+
// Save to your backend
|
|
65
|
+
fetch('/api/templates', {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
headers: { 'Content-Type': 'application/json' },
|
|
68
|
+
body: JSON.stringify({ blockTemplate, htmlTemplate, variables, templateName })
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<ClientOnlyEmailTemplateEditor
|
|
74
|
+
templateName="Newsletter Template"
|
|
75
|
+
onSave={handleSave}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### With Initial Template
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import React from 'react';
|
|
85
|
+
import { EmailTemplateEditor } from '@your-username/email-template-editor';
|
|
86
|
+
|
|
87
|
+
const initialTemplate = {
|
|
88
|
+
// Your template configuration
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
function App() {
|
|
92
|
+
return (
|
|
93
|
+
<EmailTemplateEditor
|
|
94
|
+
template={initialTemplate}
|
|
95
|
+
templateName="Welcome Email"
|
|
96
|
+
onSave={(blockTemplate, htmlTemplate, variables, templateName) => {
|
|
97
|
+
// Handle save
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## API Reference
|
|
105
|
+
|
|
106
|
+
### EmailTemplateEditor Props
|
|
107
|
+
|
|
108
|
+
| Prop | Type | Default | Description |
|
|
109
|
+
|------|------|---------|-------------|
|
|
110
|
+
| `template` | `TEditorConfiguration` | `undefined` | Initial template configuration |
|
|
111
|
+
| `templateName` | `string` | `"Untitled Template"` | Initial template name |
|
|
112
|
+
| `onSave` | `function` | `undefined` | Callback when template is saved |
|
|
113
|
+
|
|
114
|
+
### onSave Callback
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
onSave?: (
|
|
118
|
+
blockTemplate: TEditorConfiguration,
|
|
119
|
+
htmlTemplate: string,
|
|
120
|
+
variables: Record<string, string>,
|
|
121
|
+
templateName: string
|
|
122
|
+
) => void
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
- `blockTemplate`: The block-based template configuration
|
|
126
|
+
- `htmlTemplate`: Generated HTML string
|
|
127
|
+
- `variables`: Extracted variables from the template
|
|
128
|
+
- `templateName`: Current template name
|
|
129
|
+
|
|
130
|
+
## Components
|
|
131
|
+
|
|
132
|
+
### EmailTemplateEditor
|
|
133
|
+
Main component for client-side applications.
|
|
134
|
+
|
|
135
|
+
### ClientOnlyEmailTemplateEditor
|
|
136
|
+
SSR-safe wrapper that only renders on the client side. Use this for Next.js and other SSR frameworks.
|
|
137
|
+
|
|
138
|
+
## Styling
|
|
139
|
+
|
|
140
|
+
The editor comes with a complete purple-themed Material-UI design system. All components are styled consistently and follow Material Design principles.
|
|
141
|
+
|
|
142
|
+
## Browser Support
|
|
143
|
+
|
|
144
|
+
- Chrome (latest)
|
|
145
|
+
- Firefox (latest)
|
|
146
|
+
- Safari (latest)
|
|
147
|
+
- Edge (latest)
|
|
148
|
+
|
|
149
|
+
## Contributing
|
|
150
|
+
|
|
151
|
+
1. Fork the repository
|
|
152
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
153
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
154
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
155
|
+
5. Open a Pull Request
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT © [Your Name]
|
|
160
|
+
|
|
161
|
+
## Support
|
|
162
|
+
|
|
163
|
+
If you encounter any issues, please file them on the [GitHub issues page](https://github.com/your-username/email-template-editor/issues).
|