email-builder-online 2.0.0 → 2.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/README.md +71 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# email-builder-online
|
|
2
2
|
|
|
3
|
-
Powerful, modern email builder with drag-and-drop blocks, live preview, and HTML
|
|
3
|
+
Powerful, modern email builder with drag-and-drop blocks, live preview, and HTML export. Built with React and Material UI, distributed as a React component and as a Web Component so it can be embedded in other frameworks (Nuxt 3, Next.js, SvelteKit, etc.). Compatible with React 18 and 19.
|
|
4
4
|
|
|
5
5
|
- Drag-and-drop blocks (Text, Image, Button, Columns, etc.)
|
|
6
6
|
- Editor and Preview tabs with responsive screen sizes
|
|
7
7
|
- Undo/Redo and keyboard shortcuts
|
|
8
|
-
- HTML
|
|
8
|
+
- HTML outputs and copy-to-clipboard helpers
|
|
9
9
|
- CSS size guard for email client compatibility
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
@@ -61,7 +61,7 @@ import { registerEmailBuilder } from 'email-builder-online';
|
|
|
61
61
|
import 'email-builder-online/style.css';
|
|
62
62
|
|
|
63
63
|
export default defineNuxtPlugin(() => {
|
|
64
|
-
|
|
64
|
+
registerEmailBuilder('email-builder'); // optional tag name (default: 'email-builder')
|
|
65
65
|
});
|
|
66
66
|
```
|
|
67
67
|
|
|
@@ -107,6 +107,74 @@ Notes on SSR and dependencies
|
|
|
107
107
|
- The Web Component wrapper is registered only on the client. Use a client-only plugin in SSR frameworks.
|
|
108
108
|
- React and ReactDOM are peer dependencies even for the Web Component. Install them in your app or use a bundler that provides them. React 18 and 19 are supported.
|
|
109
109
|
|
|
110
|
+
## Custom Editor Standalone
|
|
111
|
+
|
|
112
|
+
The package also ships the `CustomEditorInputStandalone` component (referred to in the UI as **CustomEditorStandalone**) so the rich text block can be embedded outside of the full builder experience.
|
|
113
|
+
|
|
114
|
+
### React
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { useState } from 'react';
|
|
118
|
+
import { CustomEditorInputStandalone } from 'email-builder-online';
|
|
119
|
+
import 'email-builder-online/style.css';
|
|
120
|
+
|
|
121
|
+
export default function CustomEditorExample() {
|
|
122
|
+
const [value, setValue] = useState('<p>Write your custom content here…</p>');
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<CustomEditorInputStandalone
|
|
126
|
+
initialData={value}
|
|
127
|
+
onChange={setValue}
|
|
128
|
+
editorBackgroundColor="#ffffff"
|
|
129
|
+
editorColorDefault="#1f2937"
|
|
130
|
+
fontFamily="MODERN_SANS"
|
|
131
|
+
lineHeight={1.6}
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Key props you may want to control:
|
|
138
|
+
- `initialData`: starting HTML value of the editor.
|
|
139
|
+
- `onChange`: receives the latest HTML string every time the content changes.
|
|
140
|
+
- `editorBackgroundColor`, `editorColorDefault`, `fontFamily`, `fontSize`, `lineHeight`: styling helpers for the standalone instance.
|
|
141
|
+
- `linkColor`, `underlineLinks`, `rootFontFamily`, `rootTextColor`, `rootCanvasColor`: override the root node defaults when you need consistent rendering outside the builder.
|
|
142
|
+
|
|
143
|
+
### Web Component
|
|
144
|
+
|
|
145
|
+
Register the element on the client and optionally pick a custom tag name:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import { registerCustomEditorInput } from 'email-builder-online';
|
|
149
|
+
import 'email-builder-online/style.css';
|
|
150
|
+
|
|
151
|
+
if (typeof window !== 'undefined') {
|
|
152
|
+
registerCustomEditorInput('custom-editor'); // default is "custom-editor-input"
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Usage example in plain HTML (Nuxt/Vue/Svelte users should wrap with their client-only utilities):
|
|
157
|
+
|
|
158
|
+
```html
|
|
159
|
+
<custom-editor
|
|
160
|
+
editor-background-color="#ffffff"
|
|
161
|
+
editor-color-default="#1f2937"
|
|
162
|
+
font-family="MODERN_SANS"
|
|
163
|
+
initial-data="<p>Write your custom content here…</p>"
|
|
164
|
+
></custom-editor>
|
|
165
|
+
|
|
166
|
+
<script type="module">
|
|
167
|
+
const editor = document.querySelector('custom-editor');
|
|
168
|
+
editor?.addEventListener('onChange', (event) => {
|
|
169
|
+
const value = event.detail; // latest HTML string
|
|
170
|
+
console.log('Editor value:', value);
|
|
171
|
+
});
|
|
172
|
+
editor.initialData = '<p>Programmatically update the content.</p>';
|
|
173
|
+
</script>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Boolean and numeric attributes on the custom element map to their camelCase React counterparts (`dark-mode` → `darkMode`, `font-size` → `fontSize`, etc.). When working in frameworks, prefer binding them as element properties to avoid string coercion.
|
|
177
|
+
|
|
110
178
|
## Props / Attributes
|
|
111
179
|
|
|
112
180
|
React Props (camelCase) and Web Component attributes (dash-case) map 1:1:
|
|
@@ -136,4 +204,3 @@ MIT Ac Laravel42
|
|
|
136
204
|
## Changelog
|
|
137
205
|
|
|
138
206
|
See Git history for details. Please open issues or PRs for bugs and improvements.
|
|
139
|
-
|