@bolttech/template-editor 0.0.1
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 +321 -0
- package/dist/DataSourceModal-CW1ZoE0O.js +433 -0
- package/dist/index-CmbewOaI.js +26017 -0
- package/dist/template-editor.d.ts +32 -0
- package/dist/template-editor.es.js +4 -0
- package/dist/template-editor.umd.js +272 -0
- package/package.json +103 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 BoltTech
|
|
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,321 @@
|
|
|
1
|
+
# @bolttech/template-editor
|
|
2
|
+
|
|
3
|
+
A powerful, drag-and-drop visual template editor built with React, TypeScript, and Craft.js. Create dynamic templates with variables, rich content, and professional layouts - perfect for email templates, landing pages, and dynamic content generation.
|
|
4
|
+
|
|
5
|
+
## โจ Features
|
|
6
|
+
|
|
7
|
+
- **๐จ Visual Drag & Drop Editor**: Intuitive interface for building templates without code
|
|
8
|
+
- **๐ฑ Responsive Design**: Built-in responsive controls and preview modes
|
|
9
|
+
- **๐ง Variable System**: Dynamic content with Handlebars-style variables (`{{variable}}`)
|
|
10
|
+
- **๐งฑ Rich Component Library**: Text, images, buttons, containers, and dividers
|
|
11
|
+
- **โก Real-time Editing**: See changes instantly as you build
|
|
12
|
+
- **๐ค HTML Export**: Generate clean, production-ready HTML
|
|
13
|
+
- **๐ฏ TypeScript Support**: Full type safety and excellent developer experience
|
|
14
|
+
- **๐ Shadow DOM Isolation**: Styles and components are fully encapsulated
|
|
15
|
+
|
|
16
|
+
## ๐ฆ Installation
|
|
17
|
+
|
|
18
|
+
### NPM
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @bolttech/template-editor
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Yarn
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
yarn add @bolttech/template-editor
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Peer Dependencies
|
|
31
|
+
|
|
32
|
+
The library requires these peer dependencies to be installed in your project:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# For React 16.8+, 17, 18 or 19
|
|
36
|
+
npm install react react-dom
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> **Note**: All other dependencies (monaco-editor, handlebars, react-icons, htmlparser2, sanitize-html) are now included automatically with the library installation.
|
|
40
|
+
|
|
41
|
+
## ๐ Quick Start
|
|
42
|
+
|
|
43
|
+
### Basic Usage
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import React from 'react';
|
|
47
|
+
|
|
48
|
+
import { TemplateEditor } from '@bolttech/template-editor';
|
|
49
|
+
import '@bolttech/template-editor/style.css';
|
|
50
|
+
|
|
51
|
+
function App() {
|
|
52
|
+
return (
|
|
53
|
+
<div style={{ height: '100vh' }}>
|
|
54
|
+
<TemplateEditor />
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default App;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### With Variables and Schema
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import React from 'react';
|
|
66
|
+
|
|
67
|
+
import {
|
|
68
|
+
PlaceholderData,
|
|
69
|
+
PlaceholderSchema,
|
|
70
|
+
TemplateEditor,
|
|
71
|
+
} from '@bolttech/template-editor';
|
|
72
|
+
import '@bolttech/template-editor/style.css';
|
|
73
|
+
|
|
74
|
+
const placeholderData: PlaceholderData = {
|
|
75
|
+
user: {
|
|
76
|
+
name: 'John Doe',
|
|
77
|
+
email: 'john@example.com',
|
|
78
|
+
profile: {
|
|
79
|
+
age: 28,
|
|
80
|
+
verified: true,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
company: {
|
|
84
|
+
name: 'BoltTech',
|
|
85
|
+
address: {
|
|
86
|
+
city: 'Sรฃo Paulo',
|
|
87
|
+
country: 'Brazil',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
product: {
|
|
91
|
+
name: 'Template Editor',
|
|
92
|
+
price: 99.99,
|
|
93
|
+
},
|
|
94
|
+
campaign: {
|
|
95
|
+
active: true,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const placeholderSchema: PlaceholderSchema[] = [
|
|
100
|
+
{
|
|
101
|
+
key: 'user.name',
|
|
102
|
+
label: 'User Name',
|
|
103
|
+
value: 'John Doe',
|
|
104
|
+
type: 'text',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
key: 'user.email',
|
|
108
|
+
label: 'User Email',
|
|
109
|
+
value: 'user@example.com',
|
|
110
|
+
type: 'text',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: 'product.price',
|
|
114
|
+
label: 'Product Price',
|
|
115
|
+
value: 0,
|
|
116
|
+
type: 'number',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
key: 'campaign.type',
|
|
120
|
+
label: 'Campaign Type',
|
|
121
|
+
value: 'email',
|
|
122
|
+
type: 'enum',
|
|
123
|
+
options: [
|
|
124
|
+
{ label: 'Email Campaign', value: 'email' },
|
|
125
|
+
{ label: 'SMS Campaign', value: 'sms' },
|
|
126
|
+
{ label: 'Push Notification', value: 'push' },
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
function App() {
|
|
132
|
+
return (
|
|
133
|
+
<div style={{ height: '100vh' }}>
|
|
134
|
+
<TemplateEditor
|
|
135
|
+
placeholders={placeholderData}
|
|
136
|
+
placeholderSchema={placeholderSchema}
|
|
137
|
+
/>
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## ๐ API Reference
|
|
144
|
+
|
|
145
|
+
### Props
|
|
146
|
+
|
|
147
|
+
The `TemplateEditor` component accepts two optional props:
|
|
148
|
+
|
|
149
|
+
| Prop | Type | Description |
|
|
150
|
+
| ------------------- | --------------------- | ----------------------------------------------------- |
|
|
151
|
+
| `placeholders` | `PlaceholderData` | Data for template variables (supports nested objects) |
|
|
152
|
+
| `placeholderSchema` | `PlaceholderSchema[]` | Schema definitions for variable types and options |
|
|
153
|
+
|
|
154
|
+
### Basic Example
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
const placeholders = {
|
|
158
|
+
user: { name: 'John Doe', email: 'john@example.com' },
|
|
159
|
+
company: { name: 'ACME Corp' },
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const schema = [
|
|
163
|
+
{ key: 'user.name', label: 'User Name', value: 'Default', type: 'text' },
|
|
164
|
+
{
|
|
165
|
+
key: 'user.role',
|
|
166
|
+
label: 'Role',
|
|
167
|
+
value: 'user',
|
|
168
|
+
type: 'enum',
|
|
169
|
+
options: ['admin', 'user'],
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
<TemplateEditor placeholders={placeholders} placeholderSchema={schema} />;
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
๐ **Need more details?** See [complete API reference](docs/api/types.md) for full TypeScript definitions.
|
|
177
|
+
|
|
178
|
+
## ๐งฑ Built-in Blocks
|
|
179
|
+
|
|
180
|
+
The editor includes drag & drop components:
|
|
181
|
+
|
|
182
|
+
- **๐ Text** - Rich text with formatting and variables
|
|
183
|
+
- **๐ Button** - Interactive buttons with styling
|
|
184
|
+
- **๐ผ๏ธ Image** - Responsive images with alt text
|
|
185
|
+
- **๐ฆ Box** - Layout containers with spacing controls
|
|
186
|
+
- **ใฐ๏ธ Divider** - Visual separators
|
|
187
|
+
- **๐ Variable** - Dynamic content with Handlebars syntax (`{{variable.name}}`)
|
|
188
|
+
|
|
189
|
+
## ๐ฏ Use Cases
|
|
190
|
+
|
|
191
|
+
Perfect for creating:
|
|
192
|
+
|
|
193
|
+
- **๐ง Email templates** - Marketing emails, newsletters, notifications
|
|
194
|
+
- **๐ Landing pages** - Product launches, campaigns, lead generation
|
|
195
|
+
- **๐ Documents** - Reports, invoices, certificates
|
|
196
|
+
- **๐จ Dynamic content** - Personalized content with variables
|
|
197
|
+
|
|
198
|
+
๐ก **Want examples?** Check [docs/](docs/) for sample implementations.
|
|
199
|
+
|
|
200
|
+
## ๐จ Styling
|
|
201
|
+
|
|
202
|
+
The editor uses **Shadow DOM** for complete style isolation - no CSS conflicts with your app!
|
|
203
|
+
|
|
204
|
+
## ๐ง TypeScript Support
|
|
205
|
+
|
|
206
|
+
Full TypeScript support included:
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
import type {
|
|
210
|
+
PlaceholderData,
|
|
211
|
+
PlaceholderSchema,
|
|
212
|
+
TemplateEditorProps,
|
|
213
|
+
} from '@bolttech/template-editor';
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## ๐ Troubleshooting
|
|
217
|
+
|
|
218
|
+
**Styles not loading?**
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
import '@bolttech/template-editor/style.css';
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Peer dependency warnings?**
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
npm install react react-dom
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## ๐ Requirements
|
|
231
|
+
|
|
232
|
+
- **Node.js**: โฅ16.0
|
|
233
|
+
- **React**: โฅ16.8.0 (supports React 16.8, 17, 18, 19)
|
|
234
|
+
- **TypeScript**: โฅ4.0 (recommended)
|
|
235
|
+
|
|
236
|
+
## ๐ License
|
|
237
|
+
|
|
238
|
+
MIT License - see the [LICENSE](LICENSE) file for details.
|
|
239
|
+
|
|
240
|
+
## ๐งช Testing
|
|
241
|
+
|
|
242
|
+
The library includes comprehensive tests to ensure reliability:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Run tests once
|
|
246
|
+
npm run test:run
|
|
247
|
+
|
|
248
|
+
# Run tests in watch mode
|
|
249
|
+
npm run test:watch
|
|
250
|
+
|
|
251
|
+
# Run tests with coverage
|
|
252
|
+
npm run test:coverage
|
|
253
|
+
|
|
254
|
+
# Run full CI pipeline (lint + test + build)
|
|
255
|
+
npm run ci
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## ๐ง Development & Deployment
|
|
259
|
+
|
|
260
|
+
### Pre-commit and Pre-push Hooks
|
|
261
|
+
|
|
262
|
+
This project uses Husky to ensure code quality:
|
|
263
|
+
|
|
264
|
+
**Pre-commit hooks:**
|
|
265
|
+
|
|
266
|
+
- โ
Code formatting and linting (via lint-staged)
|
|
267
|
+
- โ
Test execution
|
|
268
|
+
|
|
269
|
+
**Pre-push hooks:**
|
|
270
|
+
|
|
271
|
+
- โ
Test execution with coverage
|
|
272
|
+
- โ
Build verification
|
|
273
|
+
|
|
274
|
+
### Available Scripts
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Development
|
|
278
|
+
npm run dev # Start development server
|
|
279
|
+
npm run preview # Preview production build
|
|
280
|
+
|
|
281
|
+
# Code Quality
|
|
282
|
+
npm run lint # Run ESLint
|
|
283
|
+
npm run format # Fix formatting and linting
|
|
284
|
+
npm run format:check # Check formatting only
|
|
285
|
+
|
|
286
|
+
# Testing
|
|
287
|
+
npm run test # Run tests in watch mode
|
|
288
|
+
npm run test:run # Run tests once
|
|
289
|
+
npm run test:coverage # Run tests with coverage report
|
|
290
|
+
npm run test:watch # Run tests in watch mode
|
|
291
|
+
|
|
292
|
+
# Building
|
|
293
|
+
npm run build # Build for production
|
|
294
|
+
npm run build:lib # Build library only
|
|
295
|
+
|
|
296
|
+
# CI/CD
|
|
297
|
+
npm run ci # Run complete CI pipeline
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Docker Support
|
|
301
|
+
|
|
302
|
+
Build and test in Docker:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
# Build with tests included
|
|
306
|
+
docker build -f Dockerfile.jenkins -t template-editor .
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## ๐ค Contributing
|
|
310
|
+
|
|
311
|
+
We welcome contributions! Please see our [development guide](docs/DEVELOPMENT.md) for details.
|
|
312
|
+
|
|
313
|
+
## ๐ Support
|
|
314
|
+
|
|
315
|
+
For support, questions, or assistance with the Template Editor, please contact our Shared Services team:
|
|
316
|
+
|
|
317
|
+
๐ง **Email**: shared-services@bolttech.io
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
Built with โค๏ธ by BoltTech for creating beautiful, dynamic templates with ease.
|