@edmissioncrm/editor 0.0.0-stage → 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Edmission CRM India Private Limited
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 CHANGED
@@ -1,3 +1,112 @@
1
- # Temporary Holding Version
1
+ # @edmissioncrm/editor
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An embeddable, **drag-and-drop email and document builder** for React, a drop-in `<EmailEditor>` that talks to
4
+ your own backend for uploads, AI and file storage.
5
+
6
+ - Drag-and-drop editor (15 blocks: heading, text, image, button, divider, spacer, social, video, GIF, HTML,
7
+ menu, form, timer, table, carousel)
8
+ - **Email** and **PDF / document** modes; export clean email-safe HTML and the design JSON
9
+ - Merge tags that stay intact, desktop and mobile preview, and **inbox previews** (Gmail, Apple Mail,
10
+ Outlook, Yahoo) with an audit check
11
+ - Undo / redo, saved versions with compare and restore, custom themes
12
+ - AI helper in every text field: improve writing, fix grammar, shorter / longer, change tone
13
+ - Image library: upload, **Amazon S3** and **Google Drive**
14
+ - Opens existing `react-email-editor` designs and keeps its component API, so migrating is a one-line change
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install @edmissioncrm/editor
20
+ # peer deps: react >= 18, react-dom >= 18
21
+ ```
22
+
23
+ The editor's CSS is injected automatically; there is nothing else to import.
24
+
25
+ ## Quick start
26
+
27
+ ```tsx
28
+ import EmailEditor, { type EmailEditorRef } from "@edmissioncrm/editor";
29
+ import { useRef } from "react";
30
+
31
+ export function MyEditor() {
32
+ const ref = useRef<EmailEditorRef>(null);
33
+
34
+ const save = () =>
35
+ ref.current?.editor.exportHtml(({ design, html }) => {
36
+ // persist `design` (JSON) and send `html`
37
+ });
38
+
39
+ return (
40
+ // the editor fills its parent, so give the parent a height
41
+ <div style={{ height: "100vh" }}>
42
+ <button onClick={save}>Save</button>
43
+ <EmailEditor
44
+ ref={ref}
45
+ edmission={{ apiBaseUrl: "https://api.example.com" }} // your backend
46
+ options={{ displayMode: "email" }} // or "document" for PDF
47
+ onReady={() => console.log("editor ready")}
48
+ />
49
+ </div>
50
+ );
51
+ }
52
+ ```
53
+
54
+ Moving from `react-email-editor`: change the import to `@edmissioncrm/editor`. Designs saved by
55
+ `react-email-editor` are converted automatically when you load them.
56
+
57
+ ## Ref API
58
+
59
+ `ref.current.editor` exposes a `react-email-editor` compatible handle:
60
+
61
+ - `loadDesign(design)` / `saveDesign(cb)`, the design JSON
62
+ - `exportHtml(cb)`, email-ready HTML together with the design
63
+ - `setMergeTags(tags)` (same as `options.mergeTags`)
64
+ - `addEventListener(event, handler)` / `removeEventListener(event, handler)`, e.g. `"design:updated"`
65
+
66
+ ## Configuration
67
+
68
+ **Merge tags** go in `options.mergeTags` (the `react-email-editor` format or a flat map):
69
+
70
+ ```tsx
71
+ options={{ mergeTags: { first_name: { name: "First name", value: "{{first_name}}", sample: "Aditi" } } }}
72
+ ```
73
+
74
+ **Backend connection** is the `edmission` prop. Every option has a default:
75
+
76
+ | Option | Default | Description |
77
+ | --- | --- | --- |
78
+ | `apiBaseUrl` | page origin | Base URL of your API |
79
+ | `orgId` | first UUID in the page URL | Sent as the `organization-id` header |
80
+ | `authToken` | `localStorage.token` | Sent as `Authorization: Bearer …` (session cookies are always sent too) |
81
+ | `uploadPath` | `/buzz-communication/upload/template-assets` | Image upload endpoint |
82
+ | `aiGeneratePath` | `/mail-templates/ai-generate` | AI endpoint |
83
+ | `s3ListEndpoint` | `${apiBaseUrl}/buzz-communication/upload/template-assets` | Files shown in the Amazon S3 tab |
84
+ | `googleClientId` | none | Shows the Google Drive tab (OAuth Web client id) |
85
+
86
+ **Your backend** holds every secret; the editor never does. Requests are sent with
87
+ `credentials: "include"` and the `organization-id` / `Authorization` headers, so allow those in CORS.
88
+
89
+ | Endpoint | Request | Response |
90
+ | --- | --- | --- |
91
+ | Upload `POST {uploadPath}` | multipart form, field `file` | `{ "file": { "url": "https://…" } }` |
92
+ | AI `POST {aiGeneratePath}` | JSON `{ prompt, allowedVariables?, currentSubject?, currentHtmlContent? }` | `{ "subject": "…", "htmlContent": "<html>…" }` |
93
+ | List `GET {s3ListEndpoint}` | none | `{ "items": [{ "id", "key", "url", "name", "kind" }] }`, `kind` is `image`, `gif`, `video` or `pdf` |
94
+
95
+ Return only the signed-in organization's files from the list endpoint, and use public URLs for uploaded
96
+ images so they load in the recipient's inbox.
97
+
98
+ **Google Drive** needs an OAuth *Web application* client with the Google Drive API and Google Picker API
99
+ enabled, the `drive.file` scope, and your app's origin under *Authorized JavaScript origins*. Picked files are
100
+ set to "anyone with the link" so they display in sent emails.
101
+
102
+ **Branding:** `logoUrl` / `logoAlt` replace the logo at the bottom of the side panel.
103
+
104
+ **Typed component:** `EdmissionEmailEditor` is also exported, for apps that prefer props
105
+ (`initialDesign`, `onDesignChange`, `builder`) and a ref with `getDesign()`, `exportHtml()` and `loadDesign()`.
106
+
107
+ If you use Vite and see an "Invalid hook call", add `resolve: { dedupe: ["react", "react-dom"] }`.
108
+
109
+ ## License
110
+
111
+ MIT, see [LICENSE](./LICENSE). Licences of the bundled open-source packages are in
112
+ [THIRD_PARTY_LICENSES.md](./THIRD_PARTY_LICENSES.md).