esender-email-editor 1.0.3 → 1.1.2

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/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ interface TemplateDocument {
23
23
  _id: string;
24
24
  userId: string;
25
25
  projectId: string;
26
+ templateId?: string;
26
27
  HTML: string;
27
28
  JSON: unknown;
28
29
  createdAt?: string;
@@ -34,8 +35,45 @@ interface TemplateApiResponse {
34
35
  template?: TemplateDocument;
35
36
  }
36
37
 
38
+ /**
39
+ * Editor event callbacks exposed to consumers via <Package />.
40
+ *
41
+ * Internal components reach these through `useEditorEvents()` instead of
42
+ * prop-drilling. Callbacks are stored in a ref so re-renders never re-fire
43
+ * subscribers, and a no-op fallback is returned when a callback is unset —
44
+ * call sites don't need to null-check.
45
+ */
46
+ interface MediaUploadEvent {
47
+ url: string;
48
+ /** Original File object the user picked, if available. */
49
+ file?: File;
50
+ /** Raw API response body, untyped — varies by backend. */
51
+ response?: unknown;
52
+ }
53
+ interface SaveEvent {
54
+ projectId: string;
55
+ templateId?: string;
56
+ /** API response body from the save call. */
57
+ response: unknown;
58
+ }
59
+ interface LoadEvent {
60
+ projectId: string;
61
+ templateId?: string;
62
+ /** API response body from the load call. */
63
+ response: unknown;
64
+ }
65
+ interface EditorEventCallbacks {
66
+ onSave?: (event: SaveEvent) => void;
67
+ onLoad?: (event: LoadEvent) => void;
68
+ onTemplateChange?: (json: unknown) => void;
69
+ onHtmlExport?: (html: string) => void;
70
+ onMediaUpload?: (event: MediaUploadEvent) => void;
71
+ }
72
+
37
73
  interface SaveTemplateOptions {
38
74
  projectId: string;
75
+ /** Provide to update an existing template instead of creating a new one. */
76
+ templateId?: string;
39
77
  }
40
78
  interface LoadTemplateOptions {
41
79
  projectId: string;
@@ -48,7 +86,8 @@ interface EditorHandle {
48
86
  loadJson: (json: string, raw?: boolean) => void;
49
87
  /**
50
88
  * Export the current editor state (HTML + JSON) and persist it to the
51
- * eSender template API. apiKey comes from the Package's prop.
89
+ * template API. apiKey comes from the Package's prop. Pass `templateId` to
90
+ * update an existing template.
52
91
  */
53
92
  saveTemplate: (options: SaveTemplateOptions) => Promise<TemplateApiResponse>;
54
93
  /**
@@ -57,10 +96,10 @@ interface EditorHandle {
57
96
  */
58
97
  loadTemplate: (options: LoadTemplateOptions) => Promise<TemplateApiResponse>;
59
98
  }
60
- interface PackageProps {
99
+ interface PackageProps extends EditorEventCallbacks {
61
100
  apiKey: string;
62
101
  /**
63
- * @deprecated The new eSender license flow does not use projectId. Kept for
102
+ * @deprecated The license flow does not use projectId. Kept for
64
103
  * backwards-compatible prop signatures during the migration. Ignored at runtime.
65
104
  */
66
105
  projectId?: string;
@@ -71,4 +110,4 @@ interface PackageProps {
71
110
  declare const Package: React.ForwardRefExoticComponent<PackageProps & React.RefAttributes<EditorHandle>>;
72
111
 
73
112
  export { Package, Package as default };
74
- export type { EditorHandle, LicenseError, LicenseErrorCode, LoadTemplateOptions, PackageProps, RefreshTokenResponse, SaveTemplateOptions, TemplateApiResponse, TemplateDocument, VerifyLicenseResponse };
113
+ export type { EditorEventCallbacks, EditorHandle, LicenseError, LicenseErrorCode, LoadEvent, LoadTemplateOptions, MediaUploadEvent, PackageProps, RefreshTokenResponse, SaveEvent, SaveTemplateOptions, TemplateApiResponse, TemplateDocument, VerifyLicenseResponse };