@kgalexander/mcreate 1.0.3 → 1.0.5
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.
|
@@ -1707,6 +1707,7 @@ var empty_default = {
|
|
|
1707
1707
|
version: "1.0.0",
|
|
1708
1708
|
published: true,
|
|
1709
1709
|
creator: "Kevin Guerrero",
|
|
1710
|
+
image: "https://mzyngaqmbvhpgmmipndy.supabase.co/storage/v1/object/public/Maillow/placeholder_image.png",
|
|
1710
1711
|
content: [
|
|
1711
1712
|
{
|
|
1712
1713
|
id: "main-body",
|
|
@@ -1823,7 +1824,6 @@ var useEditorStore = create()(
|
|
|
1823
1824
|
onImageUpload: null,
|
|
1824
1825
|
onDuplicate: null,
|
|
1825
1826
|
onDelete: null,
|
|
1826
|
-
onTemplateCapture: null,
|
|
1827
1827
|
previewMode: false,
|
|
1828
1828
|
focusIdx: null,
|
|
1829
1829
|
hoverIdx: null,
|
|
@@ -1864,7 +1864,7 @@ var useEditorStore = create()(
|
|
|
1864
1864
|
});
|
|
1865
1865
|
},
|
|
1866
1866
|
// Initialize store with external template (for npm package usage)
|
|
1867
|
-
initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete
|
|
1867
|
+
initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete) => {
|
|
1868
1868
|
set((state) => {
|
|
1869
1869
|
state.templateId = templateId;
|
|
1870
1870
|
state.template = template;
|
|
@@ -1874,7 +1874,6 @@ var useEditorStore = create()(
|
|
|
1874
1874
|
state.onImageUpload = onImageUpload ?? null;
|
|
1875
1875
|
state.onDuplicate = onDuplicate ?? null;
|
|
1876
1876
|
state.onDelete = onDelete ?? null;
|
|
1877
|
-
state.onTemplateCapture = onTemplateCapture ?? null;
|
|
1878
1877
|
state.isPaidLevel = data?.isPaidLevel ?? 0;
|
|
1879
1878
|
state.images = data?.images ?? [];
|
|
1880
1879
|
state.userData = data?.userData ?? null;
|
package/dist/index.d.mts
CHANGED
|
@@ -253,6 +253,7 @@ type SocialItemElement = {
|
|
|
253
253
|
type TemplateJSON = {
|
|
254
254
|
id: string;
|
|
255
255
|
name: string;
|
|
256
|
+
image: string;
|
|
256
257
|
version: string;
|
|
257
258
|
published: boolean;
|
|
258
259
|
creator: string;
|
|
@@ -287,12 +288,11 @@ interface MergeField {
|
|
|
287
288
|
label: string;
|
|
288
289
|
value: string;
|
|
289
290
|
}
|
|
290
|
-
type OnSaveCallback = (templateId: string, template: TemplateJSON) => void | Promise<void>;
|
|
291
|
+
type OnSaveCallback = (templateId: string, template: TemplateJSON, capturedImage?: string) => void | Promise<void>;
|
|
291
292
|
type OnExitCallback = () => void;
|
|
292
293
|
type OnImageUploadCallback = (file: File) => Promise<ImageData>;
|
|
293
294
|
type OnDuplicateCallback = (templateId: string, template: TemplateJSON) => void | Promise<void>;
|
|
294
295
|
type OnDeleteCallback = (templateId: string) => void | Promise<void>;
|
|
295
|
-
type OnTemplateCaptureCallback = (templateId: string, imageDataUrl: string) => void | Promise<void>;
|
|
296
296
|
type PaidLevel = 0 | 1 | 2 | 3;
|
|
297
297
|
|
|
298
298
|
interface EditorProps {
|
|
@@ -301,7 +301,7 @@ interface EditorProps {
|
|
|
301
301
|
}
|
|
302
302
|
declare function Editor({ setEditorLoading }: EditorProps): react_jsx_runtime.JSX.Element;
|
|
303
303
|
|
|
304
|
-
declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, onExit, onImageUpload, onDuplicate, onDelete,
|
|
304
|
+
declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, onExit, onImageUpload, onDuplicate, onDelete, data, }: {
|
|
305
305
|
templateId: string;
|
|
306
306
|
initialTemplate: TemplateJSON;
|
|
307
307
|
onSave?: OnSaveCallback;
|
|
@@ -310,7 +310,6 @@ declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, on
|
|
|
310
310
|
onImageUpload?: OnImageUploadCallback;
|
|
311
311
|
onDuplicate?: OnDuplicateCallback;
|
|
312
312
|
onDelete?: OnDeleteCallback;
|
|
313
|
-
onTemplateCapture?: OnTemplateCaptureCallback;
|
|
314
313
|
data?: {
|
|
315
314
|
isPaidLevel?: PaidLevel;
|
|
316
315
|
images?: ImageData[];
|
|
@@ -339,4 +338,4 @@ interface RenderOptions {
|
|
|
339
338
|
*/
|
|
340
339
|
declare function json2mjml(template: TemplateJSON, mode?: RenderMode, options?: RenderOptions): string;
|
|
341
340
|
|
|
342
|
-
export { Editor, type ImageData, MAX_TEMPLATE_SIZE, type MergeField, type OnDeleteCallback, type OnDuplicateCallback, type OnExitCallback, type OnImageUploadCallback, type OnSaveCallback, type
|
|
341
|
+
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
|
@@ -253,6 +253,7 @@ type SocialItemElement = {
|
|
|
253
253
|
type TemplateJSON = {
|
|
254
254
|
id: string;
|
|
255
255
|
name: string;
|
|
256
|
+
image: string;
|
|
256
257
|
version: string;
|
|
257
258
|
published: boolean;
|
|
258
259
|
creator: string;
|
|
@@ -287,12 +288,11 @@ interface MergeField {
|
|
|
287
288
|
label: string;
|
|
288
289
|
value: string;
|
|
289
290
|
}
|
|
290
|
-
type OnSaveCallback = (templateId: string, template: TemplateJSON) => void | Promise<void>;
|
|
291
|
+
type OnSaveCallback = (templateId: string, template: TemplateJSON, capturedImage?: string) => void | Promise<void>;
|
|
291
292
|
type OnExitCallback = () => void;
|
|
292
293
|
type OnImageUploadCallback = (file: File) => Promise<ImageData>;
|
|
293
294
|
type OnDuplicateCallback = (templateId: string, template: TemplateJSON) => void | Promise<void>;
|
|
294
295
|
type OnDeleteCallback = (templateId: string) => void | Promise<void>;
|
|
295
|
-
type OnTemplateCaptureCallback = (templateId: string, imageDataUrl: string) => void | Promise<void>;
|
|
296
296
|
type PaidLevel = 0 | 1 | 2 | 3;
|
|
297
297
|
|
|
298
298
|
interface EditorProps {
|
|
@@ -301,7 +301,7 @@ interface EditorProps {
|
|
|
301
301
|
}
|
|
302
302
|
declare function Editor({ setEditorLoading }: EditorProps): react_jsx_runtime.JSX.Element;
|
|
303
303
|
|
|
304
|
-
declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, onExit, onImageUpload, onDuplicate, onDelete,
|
|
304
|
+
declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, onExit, onImageUpload, onDuplicate, onDelete, data, }: {
|
|
305
305
|
templateId: string;
|
|
306
306
|
initialTemplate: TemplateJSON;
|
|
307
307
|
onSave?: OnSaveCallback;
|
|
@@ -310,7 +310,6 @@ declare function TemplatePage({ templateId, initialTemplate, onSave, onToast, on
|
|
|
310
310
|
onImageUpload?: OnImageUploadCallback;
|
|
311
311
|
onDuplicate?: OnDuplicateCallback;
|
|
312
312
|
onDelete?: OnDeleteCallback;
|
|
313
|
-
onTemplateCapture?: OnTemplateCaptureCallback;
|
|
314
313
|
data?: {
|
|
315
314
|
isPaidLevel?: PaidLevel;
|
|
316
315
|
images?: ImageData[];
|
|
@@ -339,4 +338,4 @@ interface RenderOptions {
|
|
|
339
338
|
*/
|
|
340
339
|
declare function json2mjml(template: TemplateJSON, mode?: RenderMode, options?: RenderOptions): string;
|
|
341
340
|
|
|
342
|
-
export { Editor, type ImageData, MAX_TEMPLATE_SIZE, type MergeField, type OnDeleteCallback, type OnDuplicateCallback, type OnExitCallback, type OnImageUploadCallback, type OnSaveCallback, type
|
|
341
|
+
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
|
@@ -1817,6 +1817,7 @@ var init_empty = __esm({
|
|
|
1817
1817
|
version: "1.0.0",
|
|
1818
1818
|
published: true,
|
|
1819
1819
|
creator: "Kevin Guerrero",
|
|
1820
|
+
image: "https://mzyngaqmbvhpgmmipndy.supabase.co/storage/v1/object/public/Maillow/placeholder_image.png",
|
|
1820
1821
|
content: [
|
|
1821
1822
|
{
|
|
1822
1823
|
id: "main-body",
|
|
@@ -2004,7 +2005,6 @@ var init_editor = __esm({
|
|
|
2004
2005
|
onImageUpload: null,
|
|
2005
2006
|
onDuplicate: null,
|
|
2006
2007
|
onDelete: null,
|
|
2007
|
-
onTemplateCapture: null,
|
|
2008
2008
|
previewMode: false,
|
|
2009
2009
|
focusIdx: null,
|
|
2010
2010
|
hoverIdx: null,
|
|
@@ -2045,7 +2045,7 @@ var init_editor = __esm({
|
|
|
2045
2045
|
});
|
|
2046
2046
|
},
|
|
2047
2047
|
// Initialize store with external template (for npm package usage)
|
|
2048
|
-
initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete
|
|
2048
|
+
initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete) => {
|
|
2049
2049
|
set((state) => {
|
|
2050
2050
|
state.templateId = templateId;
|
|
2051
2051
|
state.template = template;
|
|
@@ -2055,7 +2055,6 @@ var init_editor = __esm({
|
|
|
2055
2055
|
state.onImageUpload = onImageUpload ?? null;
|
|
2056
2056
|
state.onDuplicate = onDuplicate ?? null;
|
|
2057
2057
|
state.onDelete = onDelete ?? null;
|
|
2058
|
-
state.onTemplateCapture = onTemplateCapture ?? null;
|
|
2059
2058
|
state.isPaidLevel = data?.isPaidLevel ?? 0;
|
|
2060
2059
|
state.images = data?.images ?? [];
|
|
2061
2060
|
state.userData = data?.userData ?? null;
|
|
@@ -17020,30 +17019,24 @@ function TemplateHeader() {
|
|
|
17020
17019
|
const onExit = useEditorStore((s) => s.onExit);
|
|
17021
17020
|
const onDuplicate = useEditorStore((s) => s.onDuplicate);
|
|
17022
17021
|
const onDelete = useEditorStore((s) => s.onDelete);
|
|
17023
|
-
const onTemplateCapture = useEditorStore((s) => s.onTemplateCapture);
|
|
17024
17022
|
const templateName = useEditorStore((s) => s.template?.name);
|
|
17025
17023
|
const handleExit = async () => {
|
|
17026
|
-
console.log("handleExit - templateId:", templateId);
|
|
17027
17024
|
if (isSaving || !templateId || !onSave) return;
|
|
17028
17025
|
setIsSaving(true);
|
|
17029
17026
|
try {
|
|
17030
17027
|
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
|
-
}
|
|
17028
|
+
let capturedImage;
|
|
17029
|
+
try {
|
|
17030
|
+
const { default: mjml2html } = await import("mjml-browser");
|
|
17031
|
+
const mjmlString = json2mjml(template, "editing");
|
|
17032
|
+
const result = mjml2html(mjmlString);
|
|
17033
|
+
capturedImage = await captureTemplateImage(result.html);
|
|
17034
|
+
} catch (err) {
|
|
17035
|
+
console.error("[TemplateCapture] Failed:", err?.message || JSON.stringify(err) || err, err?.stack || "");
|
|
17044
17036
|
}
|
|
17037
|
+
await onSave(templateId, template, capturedImage);
|
|
17038
|
+
markAsSaved();
|
|
17045
17039
|
onExit?.();
|
|
17046
|
-
console.log("handleExit - onExit called");
|
|
17047
17040
|
} catch (error) {
|
|
17048
17041
|
console.error("Failed to save:", error);
|
|
17049
17042
|
} finally {
|
|
@@ -28748,11 +28741,10 @@ function TemplatePage({
|
|
|
28748
28741
|
onImageUpload,
|
|
28749
28742
|
onDuplicate,
|
|
28750
28743
|
onDelete,
|
|
28751
|
-
onTemplateCapture,
|
|
28752
28744
|
data
|
|
28753
28745
|
}) {
|
|
28754
28746
|
(0, import_react97.useState)(() => {
|
|
28755
|
-
useEditorStore.getState().initializeWithTemplate(templateId, initialTemplate, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete
|
|
28747
|
+
useEditorStore.getState().initializeWithTemplate(templateId, initialTemplate, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete);
|
|
28756
28748
|
});
|
|
28757
28749
|
useAutoSave();
|
|
28758
28750
|
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-B46UUREH.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-FWDS3AQF.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);
|