@edmissioncrm/editor 0.0.0-stage → 0.1.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/index.d.ts ADDED
@@ -0,0 +1,144 @@
1
+ // Public type surface for @edmissioncrm/editor.
2
+ //
3
+ // Hand-written and self-contained (the editor engine is bundled into this package, so its
4
+ // generated types are not available for consumers to resolve). The `typecheck` script (tsc against the
5
+ // real src) fails the build if this surface drifts from the implementation.
6
+
7
+ import type { CSSProperties, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
8
+
9
+ /** An opaque design document (the editor's saved/loaded JSON). */
10
+ export type Design = Record<string, unknown>;
11
+
12
+ /** Backend wiring: your API base URL and the headers sent with every request. No secret belongs here. */
13
+ export interface EdmissionApiOptions {
14
+ /** Base URL of your API, e.g. "https://api.example.com". Defaults to the page origin. */
15
+ apiBaseUrl: string;
16
+ /** Organization id, sent as the `organization-id` header. Defaults to the first UUID found in the page URL path. */
17
+ orgId: string;
18
+ /** Bearer token. Defaults to `localStorage.token`; omit both to rely on the session cookie. */
19
+ authToken?: string;
20
+ /** Image upload endpoint. Default `/buzz-communication/upload/template-assets`. */
21
+ uploadPath?: string;
22
+ /** AI "generate email" endpoint. Default `/mail-templates/ai-generate`. */
23
+ aiGeneratePath?: string;
24
+ /** Google OAuth Web client id. When set, the image library shows a Google Drive tab. */
25
+ googleClientId?: string;
26
+ /** Full URL of the S3 asset-list endpoint. Default `${apiBaseUrl}/buzz-communication/upload/template-assets`. */
27
+ s3ListEndpoint?: string;
28
+ }
29
+
30
+ /** Google Drive mode. Default "off". */
31
+ export type DriveMode = "off" | "client-id";
32
+
33
+ /** What the editor builds. "email" = mail, "document" = PDF. */
34
+ export type EdmissionBuilderMode = "email" | "page" | "document" | "popup";
35
+
36
+ /** Merge-tag map for the picker and the preview. */
37
+ export type EdmissionMergeTags = Record<string, { label: string; value: string; sample?: string }>;
38
+
39
+ export interface EdmissionEmailEditorProps {
40
+ edmission: EdmissionApiOptions;
41
+ /** "email" (mail) or "document" (PDF); also "page"/"popup". Default "email". */
42
+ builder?: EdmissionBuilderMode;
43
+ mergeTags?: EdmissionMergeTags;
44
+ logoUrl?: string;
45
+ logoAlt?: string;
46
+ driveMode?: DriveMode;
47
+ googleClientId?: string;
48
+ initialDesign?: Design;
49
+ onDesignChange?: (design: Design) => void;
50
+ className?: string;
51
+ style?: CSSProperties;
52
+ }
53
+
54
+ /** Imperative handle for the editor. */
55
+ export interface EdmEditorRef {
56
+ getDesign: () => Design;
57
+ exportHtml: (mergeTags?: Record<string, string>) => string;
58
+ exportAmp: (mergeTags?: Record<string, string>) => string;
59
+ /** Export a print-optimized document (document builder → print to PDF). */
60
+ exportDocument: (mergeTags?: Record<string, string>) => string;
61
+ exportZip: (mergeTags?: Record<string, string>) => Uint8Array;
62
+ loadDesign: (design: Design) => void;
63
+ saveSnapshot: (label?: string) => void;
64
+ getSnapshots: () => Array<{ id: string; label: string; createdAt: string }>;
65
+ restoreSnapshot: (snapshotId: string) => void;
66
+ }
67
+
68
+ /** The bring-your-own AI adapter shape (what createEdmissionAiAdapter returns). */
69
+ export interface EdmAiAdapter {
70
+ generateDesignFromPrompt: (input: { prompt: string; design: Design; mergeTags?: Record<string, string> }) => Promise<{ design?: Design; summary?: string }>;
71
+ rewriteText: (input: { prompt: string; block: unknown; design: Design; mergeTags?: Record<string, string>; selectedText?: string }) => Promise<{ text?: string; html?: string }>;
72
+ generateSubjectLines: (input: { prompt: string; design: Design; count?: number }) => Promise<{ subjects: string[] }>;
73
+ generateAltText: (input: { assetUrl: string; assetKind: "image" | "gif" | "video"; title?: string; currentAlt?: string; design: Design }) => Promise<{ alt: string }>;
74
+ }
75
+
76
+ export declare const EdmissionEmailEditor: ForwardRefExoticComponent<
77
+ PropsWithoutRef<EdmissionEmailEditorProps> & RefAttributes<EdmEditorRef>
78
+ >;
79
+
80
+ // ---- react-email-editor (Unlayer) DROP-IN (default export) ----------------------------------------
81
+
82
+ /** Unlayer `options` (only the fields the editor reads). */
83
+ export interface EmailEditorOptions {
84
+ mergeTags?: unknown;
85
+ displayMode?: "email" | "web" | "page" | "document" | "popup";
86
+ [key: string]: unknown;
87
+ }
88
+
89
+ /** The Unlayer-shaped imperative editor API (`ref.current.editor.*`). */
90
+ export interface UnlayerEditorApi {
91
+ loadDesign: (design: Design) => void;
92
+ saveDesign: (cb: (design: Design) => void) => void;
93
+ exportHtml: (cb: (data: { design: Design; html: string }) => void) => void;
94
+ exportPlainText?: (cb: (data: { design: Design; text: string }) => void) => void;
95
+ setMergeTags: (tags: unknown) => void;
96
+ addEventListener: (event: string, handler: (data?: unknown) => void) => void;
97
+ removeEventListener: (event: string, handler: (data?: unknown) => void) => void;
98
+ registerCallback: (type: string, cb: (...args: unknown[]) => void) => void;
99
+ }
100
+
101
+ export interface EmailEditorRef {
102
+ editor: UnlayerEditorApi;
103
+ }
104
+
105
+ export interface EmailEditorProps {
106
+ /** Backend wiring. Optional: apiBaseUrl defaults to the page origin, orgId to the UUID in the URL, bearer to localStorage.token. */
107
+ edmission?: Partial<EdmissionApiOptions>;
108
+ options?: EmailEditorOptions;
109
+ onReady?: (editor: UnlayerEditorApi) => void;
110
+ onLoad?: (data?: unknown) => void;
111
+ logoUrl?: string;
112
+ logoAlt?: string;
113
+ style?: CSSProperties;
114
+ minHeight?: string | number;
115
+ className?: string;
116
+ }
117
+
118
+ /** react-email-editor DROP-IN. `import EmailEditor from "@edmissioncrm/editor"`. */
119
+ export declare const EmailEditor: ForwardRefExoticComponent<
120
+ PropsWithoutRef<EmailEditorProps> & RefAttributes<EmailEditorRef>
121
+ >;
122
+ export default EmailEditor;
123
+
124
+ /** Build the editor's `onImageUpload` handler (POSTs the file to your upload endpoint). */
125
+ export declare function createEdmissionUploadHandler(
126
+ options: EdmissionApiOptions
127
+ ): (
128
+ file: File, context: { kind: "image" | "gif" | "video" | "pdf"; onProgress?: (percent: number) => void }
129
+ ) => Promise<{ url: string; alt?: string }>;
130
+
131
+ /** Build an AI adapter wired to your AI endpoint (provider keys stay on your server). */
132
+ export declare function createEdmissionAiAdapter(options: EdmissionApiOptions): EdmAiAdapter;
133
+
134
+ /** Headers (organization-id + optional bearer) sent with every request. */
135
+ export declare function edmissionConnectorHeaders(options: EdmissionApiOptions): Record<string, string>;
136
+
137
+ /** Build the `googleDrive` config value for the chosen mode. */
138
+ export declare function buildEdmissionGoogleDrive(
139
+ mode?: DriveMode, clientId?: string
140
+ ): boolean | { clientId: string };
141
+
142
+ export declare const DEFAULT_EDMISSION_UPLOAD_PATH: string;
143
+ export declare const DEFAULT_EDMISSION_AI_GENERATE_PATH: string;
144
+ export declare const DEFAULT_EDMISSION_S3_LIST_PATH: string;
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@edmissioncrm/editor",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Embeddable drag-and-drop email and document builder for React, a drop-in react-email-editor replacement.",
5
+ "keywords": [
6
+ "email",
7
+ "editor",
8
+ "email-builder",
9
+ "react-email-editor",
10
+ "react",
11
+ "newsletter",
12
+ "pdf",
13
+ "template-builder"
14
+ ],
15
+ "license": "MIT",
16
+ "type": "module",
17
+ "main": "./dist/index.cjs",
18
+ "module": "./dist/index.js",
19
+ "types": "./index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "index.d.ts",
30
+ "README.md",
31
+ "LICENSE",
32
+ "THIRD_PARTY_LICENSES.md"
33
+ ],
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {
38
+ "build": "vite build",
39
+ "prepublishOnly": "pnpm --filter \"edm-react...\" build && pnpm run build",
40
+ "typecheck": "tsc --noEmit -p tsconfig.json"
41
+ },
42
+ "peerDependencies": {
43
+ "react": ">=18",
44
+ "react-dom": ">=18"
45
+ },
46
+ "devDependencies": {
47
+ "edm-core": "workspace:*",
48
+ "edm-react": "workspace:*",
49
+ "edm-renderer": "workspace:*"
50
+ }
51
+ }