Skip to content

Commit 7ba9194

Browse files
committed
feat(theming): theming was improved
1 parent e9b1289 commit 7ba9194

File tree

7 files changed

+94
-122
lines changed

7 files changed

+94
-122
lines changed

README.md

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,18 @@
22

33
A React-based email template editor component that allows users to create and customize email templates through a visual interface. This component can be embedded in any React application.
44

5-
## Overview
6-
7-
React Email Editor is a comprehensive solution for creating email templates with a drag-and-drop interface. It's built as a reusable React component that can be easily integrated into your applications.
8-
95
## Features
106

117
- Visual email template builder
128
- Rich set of components (text, buttons, images, dividers, containers, columns, etc.)
139
- Markdown support for text editing
1410
- Responsive email templates
15-
- Customizable themes
16-
- Export to HTML
11+
- Embeddable into React applications
1712

1813
## Installation
1914

2015
```bash
21-
npm install kontakto-email-editor
16+
npm install @kontakto/email-template-editor
2217
```
2318

2419
## Usage
@@ -28,7 +23,7 @@ npm install kontakto-email-editor
2823
You can easily embed the EmailEditor into any React application:
2924

3025
```jsx
31-
import { EmailEditor } from 'kontakto-email-editor';
26+
import { EmailEditor } from '@kontakto/email-template-editor';
3227

3328
function MyApp() {
3429
return (
@@ -62,6 +57,7 @@ function MyApp() {
6257
| `deleteTemplate` | function | - | Deletes a template: `(id) => void` |
6358
| `copyTemplate` | function | - | Copies a template: `(name, content) => void` |
6459
| `saveAs` | function | - | Saves template with new name: `(name, content) => Promise<{id, name}>` |
60+
| `theme` | object | theme.ts | Custom theme for the EmailEditor, must be a Material UI theme object |
6561

6662
#### Imperative API
6763

@@ -114,30 +110,8 @@ This will start a development server with the EmailEditor running as a standalon
114110

115111
## Theming
116112

117-
The EmailEditor component does not include its own ThemeProvider, allowing you to integrate it with your application's theme. To apply a theme to the EmailEditor, wrap it with MUI's ThemeProvider:
118-
119-
```jsx
120-
import React from 'react';
121-
import { ThemeProvider, CssBaseline } from '@mui/material';
122-
import { EmailEditor } from 'kontakto-email-editor';
123-
import { createTheme } from '@mui/material/styles';
124-
125-
// Create your custom theme or import it
126-
const theme = createTheme({
127-
// Your theme options
128-
});
113+
The EmailEditor component has the CssBaseline and ThemeProvider components from Material UI applied by default. However, if you need to supply a custom theme, you can do so by passing a custom theme to the EmailEditor component. The theme should be a Material UI theme object.
129114

130-
const MyApp = () => {
131-
return (
132-
<ThemeProvider theme={theme}>
133-
<CssBaseline />
134-
<EmailEditor />
135-
</ThemeProvider>
136-
);
137-
};
138-
```
139-
140-
For reference, you can copy the default theme implementation from the `src/theme.ts` file in the package and customize it according to your application's design system.
141115

142116
## Development
143117

@@ -161,7 +135,6 @@ To run this locally:
161135
- `src/app/` - Main application components
162136
- `src/email-builder/` - Email template rendering
163137
- `src/core/` - Core utilities and types
164-
- `src/configuration/` - Configuration options
165138

166139
## Technologies
167140

@@ -172,31 +145,25 @@ To run this locally:
172145
- Vite as the build tool
173146
- Marked and Highlight.js for markdown and code highlighting
174147

175-
# Kontakto-Email-Editor
148+
# Email-Template-Editor
176149

177150
Licensed under the MIT License. See `LICENSE` for details.
178151

179-
This project, Kontakto-Email-Editor, is a substantial derivative work based on an original MIT-licensed project, `email-builder-js` by Waypoint (Metaccountant, Inc.). `email-builder-js` is a free and open-source block-based email template builder designed for developers to create emails with JSON or HTML output. While the original code was created by Waypoint, this project has been significantly refactored with:
152+
This project, Email-Template-Editor, is a substantial derivative work based on an original MIT-licensed project, `email-builder-js` by Waypoint (Metaccountant, Inc.). `email-builder-js` is a free and open-source block-based email template builder designed for developers to create emails with JSON or HTML output. While the original code was created by Waypoint, this project has been significantly refactored with:
180153

181-
1. Complete restructuring of the project files and directories.
154+
1. Restructuring of the project files and directories.
182155
2. Implementation of how external context is handled.
183-
3. Changes to the core purpose - from a standalone email builder to an embeddable email editor component for React projects.
156+
3. Changes to the purpose of the project to be integrated and embedded into other React based projects.
184157

185158
## Original Code from Waypoint (Metaccountant, Inc.)
186159

187-
The following parts of this project are derived from the original MIT-licensed project `email-builder-js` by Waypoint:
188-
189-
* The core parsing logic is based on Waypoint's original block-based parsing approach
190-
* The initial concepts for the block structure of the email content
191-
192-
## New Code and Modifications by Kontakto Oy
193-
194-
The following parts of this project are entirely new or represent significant modifications by Kontakto Oy:
160+
The following parts (not limited to) of this project are derived from the original MIT-licensed project `email-builder-js` by Waypoint:
195161

196-
* Kontakto significantly restructured the project, so it is now embeddable email editor component as a single NPM package, rather than a set of multiple NPM packages.
197-
* External context handling mechanism has been implemented.
198-
* The core purpose of the project has been changed from a standalone email builder to an embeddable email editor component for React projects.
162+
* The parsing logic is based on Waypoint's original block-based parsing approach
163+
* The concepts for the blocks
164+
* The concepts for the editor
165+
* The concepts of the builder
199166

200167
## Acknowledgements
201168

202-
This project gratefully acknowledges the original work by Waypoint (Metaccountant, Inc.) on `email-builder-js` as the foundation upon which this enhanced and refactored version was built. Without their initial effort in creating `email-builder-js`, this project would not have been possible.
169+
This project gratefully acknowledges the original work by Waypoint (Metaccountant, Inc.) on `email-builder-js` as the foundation upon which this version was built.

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link rel="icon" type="image/png" sizes="16x16" href="/src/favicon/favicon-16x16.png" />
88
<meta name="viewport" content="width=900" />
99
<meta name="description" content="EmailBuilder.js interactive playground. Brought to you by Waypoint." />
10-
<title>EmailBuilder.js &mdash; Free and Open Source Template Builder</title>
10+
<title>Email Template Editor</title>
1111
<style>
1212
html {
1313
margin: 0px;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@kontakto/react-email-editor",
2+
"name": "@kontakto/email-template-editor",
33
"version": "1.1.1",
44
"type": "module",
55
"main": "dist/index.js",

src/app/email-canvas/import-json/import-json-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function ImportJsonDialog({ onClose }: ImportJsonDialogProps) {
5252
>
5353
<DialogContent>
5454
<Typography color="text.secondary" paragraph>
55-
Copy and paste an EmailBuilder.js JSON (
55+
Copy and paste an JSON (
5656
<Link
5757
href="https://gist.githubusercontent.com/jordanisip/efb61f56ba71bd36d3a9440122cb7f50/raw/30ea74a6ac7e52ebdc309bce07b71a9286ce2526/emailBuilderTemplate.json"
5858
target="_blank"

src/app/index.tsx

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React, { forwardRef, useImperativeHandle, useEffect } from 'react';
2-
import { Stack, useTheme } from '@mui/material';
2+
import { Stack, useTheme, ThemeProvider } from '@mui/material';
3+
import { Theme } from '@mui/material/styles';
4+
import defaultTheme from '../theme';
5+
import { CssBaseline } from '@mui/material';
36

47
import { TEditorConfiguration } from '@editor/core';
58
import {
@@ -96,6 +99,11 @@ export interface EmailEditorProps {
9699
* Callback to save a template with a new name.
97100
*/
98101
saveAs?: (templateName: string, content: any) => Promise<{id: string, name: string}>;
102+
/**
103+
* Optional theme override. If not provided, the default theme will be used.
104+
* This allows for easy styling without requiring a separate ThemeProvider.
105+
*/
106+
theme?: Theme;
99107
}
100108

101109
function useDrawerTransition(cssProperty: 'margin-left' | 'margin-right', open: boolean) {
@@ -200,6 +208,7 @@ const EmailEditor = forwardRef<EmailEditorRef, EmailEditorProps>((props, ref) =>
200208
deleteTemplate,
201209
copyTemplate,
202210
saveAs,
211+
theme,
203212
} = props;
204213

205214
// Initialize with the provided template and settings
@@ -213,31 +222,34 @@ const EmailEditor = forwardRef<EmailEditorRef, EmailEditorProps>((props, ref) =>
213222
}, [initialTemplate, persistenceEnabled]);
214223

215224
return (
216-
<div style={{ height: '100%', overflow: 'auto' }}>
217-
<SnackbarProvider>
218-
<EmailEditorProvider
219-
initialTemplate={initialTemplate}
220-
initialTemplateId={initialTemplateId}
221-
initialTemplateName={initialTemplateName}
222-
onSave={onSave}
223-
onChange={onChange}
224-
>
225-
<EmailEditorInternal
226-
ref={ref}
227-
drawerEnterDuration={drawerEnterDuration}
228-
drawerExitDuration={drawerExitDuration}
229-
samplesDrawerEnabled={samplesDrawerEnabled}
230-
minHeight={minHeight}
231-
loadSamples={loadSamples}
232-
loadTemplates={loadTemplates}
233-
loadTemplate={loadTemplate}
234-
deleteTemplate={deleteTemplate}
235-
copyTemplate={copyTemplate}
236-
saveAs={saveAs}
237-
/>
238-
</EmailEditorProvider>
239-
</SnackbarProvider>
240-
</div>
225+
<ThemeProvider theme={theme || defaultTheme}>
226+
<CssBaseline />
227+
<div style={{ height: '100%', overflow: 'auto' }}>
228+
<SnackbarProvider>
229+
<EmailEditorProvider
230+
initialTemplate={initialTemplate}
231+
initialTemplateId={initialTemplateId}
232+
initialTemplateName={initialTemplateName}
233+
onSave={onSave}
234+
onChange={onChange}
235+
>
236+
<EmailEditorInternal
237+
ref={ref}
238+
drawerEnterDuration={drawerEnterDuration}
239+
drawerExitDuration={drawerExitDuration}
240+
samplesDrawerEnabled={samplesDrawerEnabled}
241+
minHeight={minHeight}
242+
loadSamples={loadSamples}
243+
loadTemplates={loadTemplates}
244+
loadTemplate={loadTemplate}
245+
deleteTemplate={deleteTemplate}
246+
copyTemplate={copyTemplate}
247+
saveAs={saveAs}
248+
/>
249+
</EmailEditorProvider>
250+
</SnackbarProvider>
251+
</div>
252+
</ThemeProvider>
241253
);
242254
});
243255

src/app/templates-drawer/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ export default function SamplesDrawer({
158158
variant="persistent"
159159
anchor="left"
160160
open={samplesDrawerOpen}
161-
componentsProps={{
162-
backdrop: { style: { position: "absolute" } },
163-
}}
164161
PaperProps={{
165162
style: { position: "absolute" },
166163
}}

0 commit comments

Comments
 (0)