@kgalexander/mcreate 1.0.3 → 1.0.4
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.
|
@@ -1823,7 +1823,6 @@ var useEditorStore = create()(
|
|
|
1823
1823
|
onImageUpload: null,
|
|
1824
1824
|
onDuplicate: null,
|
|
1825
1825
|
onDelete: null,
|
|
1826
|
-
onTemplateCapture: null,
|
|
1827
1826
|
previewMode: false,
|
|
1828
1827
|
focusIdx: null,
|
|
1829
1828
|
hoverIdx: null,
|
|
@@ -1864,7 +1863,7 @@ var useEditorStore = create()(
|
|
|
1864
1863
|
});
|
|
1865
1864
|
},
|
|
1866
1865
|
// Initialize store with external template (for npm package usage)
|
|
1867
|
-
initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete
|
|
1866
|
+
initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete) => {
|
|
1868
1867
|
set((state) => {
|
|
1869
1868
|
state.templateId = templateId;
|
|
1870
1869
|
state.template = template;
|
|
@@ -1874,7 +1873,6 @@ var useEditorStore = create()(
|
|
|
1874
1873
|
state.onImageUpload = onImageUpload ?? null;
|
|
1875
1874
|
state.onDuplicate = onDuplicate ?? null;
|
|
1876
1875
|
state.onDelete = onDelete ?? null;
|
|
1877
|
-
state.onTemplateCapture = onTemplateCapture ?? null;
|
|
1878
1876
|
state.isPaidLevel = data?.isPaidLevel ?? 0;
|
|
1879
1877
|
state.images = data?.images ?? [];
|
|
1880
1878
|
state.userData = data?.userData ?? null;
|
package/dist/index.d.mts
CHANGED
|
@@ -287,12 +287,11 @@ interface MergeField {
|
|
|
287
287
|
label: string;
|
|
288
288
|
value: string;
|
|
289
289
|
}
|
|
290
|
-
type OnSaveCallback = (templateId: string, template: TemplateJSON) => void | Promise<void>;
|
|
290
|
+
type OnSaveCallback = (templateId: string, template: TemplateJSON, capturedImage?: string) => void | Promise<void>;
|
|
291
291
|
type OnExitCallback = () => void;
|
|
292
292
|
type OnImageUploadCallback = (file: File) => Promise<ImageData>;
|
|
293
293
|
type OnDuplicateCallback = (templateId: string, template: TemplateJSON) => void | Promise<void>;
|
|
294
294
|
type OnDeleteCallback = (templateId: string) => void | Promise<void>;
|
|
295
|
-
type OnTemplateCaptureCallback = (templateId: string, imageDataUrl: string) => void | Promise<void>;
|
|
296
295
|
type PaidLevel = 0 | 1 | 2 | 3;
|
|
297
296
|
|
|
298
297
|
interface EditorProps {
|
|
@@ -301,7 +300,7 @@ interface EditorProps {
|
|
|
301
300
|
}
|
|
302
301
|
declare function Editor({ setEditorLoading }: EditorProps): react_jsx_runtime.JSX.Element;
|
|
303
302
|
|
|
304
|
-
declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, onExit, onImageUpload, onDuplicate, onDelete,
|
|
303
|
+
declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, onExit, onImageUpload, onDuplicate, onDelete, data, }: {
|
|
305
304
|
templateId: string;
|
|
306
305
|
initialTemplate: TemplateJSON;
|
|
307
306
|
onSave?: OnSaveCallback;
|
|
@@ -310,7 +309,6 @@ declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, on
|
|
|
310
309
|
onImageUpload?: OnImageUploadCallback;
|
|
311
310
|
onDuplicate?: OnDuplicateCallback;
|
|
312
311
|
onDelete?: OnDeleteCallback;
|
|
313
|
-
onTemplateCapture?: OnTemplateCaptureCallback;
|
|
314
312
|
data?: {
|
|
315
313
|
isPaidLevel?: PaidLevel;
|
|
316
314
|
images?: ImageData[];
|
|
@@ -339,4 +337,4 @@ interface RenderOptions {
|
|
|
339
337
|
*/
|
|
340
338
|
declare function json2mjml(template: TemplateJSON, mode?: RenderMode, options?: RenderOptions): string;
|
|
341
339
|
|
|
342
|
-
export { Editor, type ImageData, MAX_TEMPLATE_SIZE, type MergeField, type OnDeleteCallback, type OnDuplicateCallback, type OnExitCallback, type OnImageUploadCallback, type OnSaveCallback, type
|
|
340
|
+
export { Editor, type ImageData, MAX_TEMPLATE_SIZE, type MergeField, type OnDeleteCallback, type OnDuplicateCallback, type OnExitCallback, type OnImageUploadCallback, type OnSaveCallback, type OnToastCallback, type PaidLevel, type TemplateJSON, TemplatePage, type ToastOptions, type ToastType, json2mjml };
|
package/dist/index.d.ts
CHANGED
|
@@ -287,12 +287,11 @@ interface MergeField {
|
|
|
287
287
|
label: string;
|
|
288
288
|
value: string;
|
|
289
289
|
}
|
|
290
|
-
type OnSaveCallback = (templateId: string, template: TemplateJSON) => void | Promise<void>;
|
|
290
|
+
type OnSaveCallback = (templateId: string, template: TemplateJSON, capturedImage?: string) => void | Promise<void>;
|
|
291
291
|
type OnExitCallback = () => void;
|
|
292
292
|
type OnImageUploadCallback = (file: File) => Promise<ImageData>;
|
|
293
293
|
type OnDuplicateCallback = (templateId: string, template: TemplateJSON) => void | Promise<void>;
|
|
294
294
|
type OnDeleteCallback = (templateId: string) => void | Promise<void>;
|
|
295
|
-
type OnTemplateCaptureCallback = (templateId: string, imageDataUrl: string) => void | Promise<void>;
|
|
296
295
|
type PaidLevel = 0 | 1 | 2 | 3;
|
|
297
296
|
|
|
298
297
|
interface EditorProps {
|
|
@@ -301,7 +300,7 @@ interface EditorProps {
|
|
|
301
300
|
}
|
|
302
301
|
declare function Editor({ setEditorLoading }: EditorProps): react_jsx_runtime.JSX.Element;
|
|
303
302
|
|
|
304
|
-
declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, onExit, onImageUpload, onDuplicate, onDelete,
|
|
303
|
+
declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, onExit, onImageUpload, onDuplicate, onDelete, data, }: {
|
|
305
304
|
templateId: string;
|
|
306
305
|
initialTemplate: TemplateJSON;
|
|
307
306
|
onSave?: OnSaveCallback;
|
|
@@ -310,7 +309,6 @@ declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, on
|
|
|
310
309
|
onImageUpload?: OnImageUploadCallback;
|
|
311
310
|
onDuplicate?: OnDuplicateCallback;
|
|
312
311
|
onDelete?: OnDeleteCallback;
|
|
313
|
-
onTemplateCapture?: OnTemplateCaptureCallback;
|
|
314
312
|
data?: {
|
|
315
313
|
isPaidLevel?: PaidLevel;
|
|
316
314
|
images?: ImageData[];
|
|
@@ -339,4 +337,4 @@ interface RenderOptions {
|
|
|
339
337
|
*/
|
|
340
338
|
declare function json2mjml(template: TemplateJSON, mode?: RenderMode, options?: RenderOptions): string;
|
|
341
339
|
|
|
342
|
-
export { Editor, type ImageData, MAX_TEMPLATE_SIZE, type MergeField, type OnDeleteCallback, type OnDuplicateCallback, type OnExitCallback, type OnImageUploadCallback, type OnSaveCallback, type
|
|
340
|
+
export { Editor, type ImageData, MAX_TEMPLATE_SIZE, type MergeField, type OnDeleteCallback, type OnDuplicateCallback, type OnExitCallback, type OnImageUploadCallback, type OnSaveCallback, type OnToastCallback, type PaidLevel, type TemplateJSON, TemplatePage, type ToastOptions, type ToastType, json2mjml };
|
package/dist/index.js
CHANGED
|
@@ -2004,7 +2004,6 @@ var init_editor = __esm({
|
|
|
2004
2004
|
onImageUpload: null,
|
|
2005
2005
|
onDuplicate: null,
|
|
2006
2006
|
onDelete: null,
|
|
2007
|
-
onTemplateCapture: null,
|
|
2008
2007
|
previewMode: false,
|
|
2009
2008
|
focusIdx: null,
|
|
2010
2009
|
hoverIdx: null,
|
|
@@ -2045,7 +2044,7 @@ var init_editor = __esm({
|
|
|
2045
2044
|
});
|
|
2046
2045
|
},
|
|
2047
2046
|
// Initialize store with external template (for npm package usage)
|
|
2048
|
-
initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete
|
|
2047
|
+
initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete) => {
|
|
2049
2048
|
set((state) => {
|
|
2050
2049
|
state.templateId = templateId;
|
|
2051
2050
|
state.template = template;
|
|
@@ -2055,7 +2054,6 @@ var init_editor = __esm({
|
|
|
2055
2054
|
state.onImageUpload = onImageUpload ?? null;
|
|
2056
2055
|
state.onDuplicate = onDuplicate ?? null;
|
|
2057
2056
|
state.onDelete = onDelete ?? null;
|
|
2058
|
-
state.onTemplateCapture = onTemplateCapture ?? null;
|
|
2059
2057
|
state.isPaidLevel = data?.isPaidLevel ?? 0;
|
|
2060
2058
|
state.images = data?.images ?? [];
|
|
2061
2059
|
state.userData = data?.userData ?? null;
|
|
@@ -17020,30 +17018,24 @@ function TemplateHeader() {
|
|
|
17020
17018
|
const onExit = useEditorStore((s) => s.onExit);
|
|
17021
17019
|
const onDuplicate = useEditorStore((s) => s.onDuplicate);
|
|
17022
17020
|
const onDelete = useEditorStore((s) => s.onDelete);
|
|
17023
|
-
const onTemplateCapture = useEditorStore((s) => s.onTemplateCapture);
|
|
17024
17021
|
const templateName = useEditorStore((s) => s.template?.name);
|
|
17025
17022
|
const handleExit = async () => {
|
|
17026
|
-
console.log("handleExit - templateId:", templateId);
|
|
17027
17023
|
if (isSaving || !templateId || !onSave) return;
|
|
17028
17024
|
setIsSaving(true);
|
|
17029
17025
|
try {
|
|
17030
17026
|
const template = useEditorStore.getState().template;
|
|
17031
|
-
|
|
17032
|
-
|
|
17033
|
-
|
|
17034
|
-
|
|
17035
|
-
|
|
17036
|
-
|
|
17037
|
-
|
|
17038
|
-
|
|
17039
|
-
const imageDataUrl = await captureTemplateImage(result.html);
|
|
17040
|
-
await onTemplateCapture(templateId, imageDataUrl);
|
|
17041
|
-
} catch (err) {
|
|
17042
|
-
console.error("[TemplateCapture] Failed:", err?.message || JSON.stringify(err) || err, err?.stack || "");
|
|
17043
|
-
}
|
|
17027
|
+
let capturedImage;
|
|
17028
|
+
try {
|
|
17029
|
+
const { default: mjml2html } = await import("mjml-browser");
|
|
17030
|
+
const mjmlString = json2mjml(template, "editing");
|
|
17031
|
+
const result = mjml2html(mjmlString);
|
|
17032
|
+
capturedImage = await captureTemplateImage(result.html);
|
|
17033
|
+
} catch (err) {
|
|
17034
|
+
console.error("[TemplateCapture] Failed:", err?.message || JSON.stringify(err) || err, err?.stack || "");
|
|
17044
17035
|
}
|
|
17036
|
+
await onSave(templateId, template, capturedImage);
|
|
17037
|
+
markAsSaved();
|
|
17045
17038
|
onExit?.();
|
|
17046
|
-
console.log("handleExit - onExit called");
|
|
17047
17039
|
} catch (error) {
|
|
17048
17040
|
console.error("Failed to save:", error);
|
|
17049
17041
|
} finally {
|
|
@@ -28748,11 +28740,10 @@ function TemplatePage({
|
|
|
28748
28740
|
onImageUpload,
|
|
28749
28741
|
onDuplicate,
|
|
28750
28742
|
onDelete,
|
|
28751
|
-
onTemplateCapture,
|
|
28752
28743
|
data
|
|
28753
28744
|
}) {
|
|
28754
28745
|
(0, import_react97.useState)(() => {
|
|
28755
|
-
useEditorStore.getState().initializeWithTemplate(templateId, initialTemplate, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete
|
|
28746
|
+
useEditorStore.getState().initializeWithTemplate(templateId, initialTemplate, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete);
|
|
28756
28747
|
});
|
|
28757
28748
|
useAutoSave();
|
|
28758
28749
|
const [editorLoading, setEditorLoading] = (0, import_react97.useState)(false);
|
package/dist/index.mjs
CHANGED
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
setupDragImage,
|
|
61
61
|
useEditorStore,
|
|
62
62
|
useSidebarContext
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-RSM3GOFU.mjs";
|
|
64
64
|
|
|
65
65
|
// src/core/editor/components/email-template-v2/header.tsx
|
|
66
66
|
import { ArrowLeftIcon, CopyIcon, MegaphoneIcon, MoreHorizontalIcon, PencilIcon, SendIcon, TrashIcon } from "lucide-react";
|
|
@@ -251,30 +251,24 @@ function TemplateHeader() {
|
|
|
251
251
|
const onExit = useEditorStore((s) => s.onExit);
|
|
252
252
|
const onDuplicate = useEditorStore((s) => s.onDuplicate);
|
|
253
253
|
const onDelete = useEditorStore((s) => s.onDelete);
|
|
254
|
-
const onTemplateCapture = useEditorStore((s) => s.onTemplateCapture);
|
|
255
254
|
const templateName = useEditorStore((s) => s.template?.name);
|
|
256
255
|
const handleExit = async () => {
|
|
257
|
-
console.log("handleExit - templateId:", templateId);
|
|
258
256
|
if (isSaving || !templateId || !onSave) return;
|
|
259
257
|
setIsSaving(true);
|
|
260
258
|
try {
|
|
261
259
|
const template = useEditorStore.getState().template;
|
|
262
|
-
|
|
260
|
+
let capturedImage;
|
|
261
|
+
try {
|
|
262
|
+
const { default: mjml2html } = await import("mjml-browser");
|
|
263
|
+
const mjmlString = json2mjml(template, "editing");
|
|
264
|
+
const result = mjml2html(mjmlString);
|
|
265
|
+
capturedImage = await captureTemplateImage(result.html);
|
|
266
|
+
} catch (err) {
|
|
267
|
+
console.error("[TemplateCapture] Failed:", err?.message || JSON.stringify(err) || err, err?.stack || "");
|
|
268
|
+
}
|
|
269
|
+
await onSave(templateId, template, capturedImage);
|
|
263
270
|
markAsSaved();
|
|
264
|
-
if (onTemplateCapture) {
|
|
265
|
-
try {
|
|
266
|
-
const { default: mjml2html } = await import("mjml-browser");
|
|
267
|
-
const mjmlString = json2mjml(template, "editing");
|
|
268
|
-
const result = mjml2html(mjmlString);
|
|
269
|
-
console.log("Result:", result.html);
|
|
270
|
-
const imageDataUrl = await captureTemplateImage(result.html);
|
|
271
|
-
await onTemplateCapture(templateId, imageDataUrl);
|
|
272
|
-
} catch (err) {
|
|
273
|
-
console.error("[TemplateCapture] Failed:", err?.message || JSON.stringify(err) || err, err?.stack || "");
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
271
|
onExit?.();
|
|
277
|
-
console.log("handleExit - onExit called");
|
|
278
272
|
} catch (error) {
|
|
279
273
|
console.error("Failed to save:", error);
|
|
280
274
|
} finally {
|
|
@@ -11714,7 +11708,7 @@ function useAutoSave() {
|
|
|
11714
11708
|
// src/core/editor/components/email-template-v2/template-page.tsx
|
|
11715
11709
|
import "react-json-view-lite/dist/index.css";
|
|
11716
11710
|
import { jsx as jsx74, jsxs as jsxs59 } from "react/jsx-runtime";
|
|
11717
|
-
var Editor2 = lazy(() => import("./core-
|
|
11711
|
+
var Editor2 = lazy(() => import("./core-HSOSY6BB.mjs").then((module) => ({
|
|
11718
11712
|
default: module.Editor
|
|
11719
11713
|
})));
|
|
11720
11714
|
function TemplatePage({
|
|
@@ -11726,11 +11720,10 @@ function TemplatePage({
|
|
|
11726
11720
|
onImageUpload,
|
|
11727
11721
|
onDuplicate,
|
|
11728
11722
|
onDelete,
|
|
11729
|
-
onTemplateCapture,
|
|
11730
11723
|
data
|
|
11731
11724
|
}) {
|
|
11732
11725
|
useState25(() => {
|
|
11733
|
-
useEditorStore.getState().initializeWithTemplate(templateId, initialTemplate, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete
|
|
11726
|
+
useEditorStore.getState().initializeWithTemplate(templateId, initialTemplate, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete);
|
|
11734
11727
|
});
|
|
11735
11728
|
useAutoSave();
|
|
11736
11729
|
const [editorLoading, setEditorLoading] = useState25(false);
|