@kgalexander/mcreate 1.0.2 → 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.
@@ -815,15 +815,15 @@ function propertyCardTripleMockMjml(block, context) {
815
815
  ${responsiveStyles}
816
816
  <mj-table align="center" width="${width}" padding="0" css-class="${trackingClasses}">
817
817
  <tr class="property-triple-row-${uniqueId}">
818
- <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px"">
818
+ <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px">
819
819
  ${cards[0] || ""}
820
820
  </th>
821
821
  <th class="property-triple-spacer-${uniqueId}" style="font-size:0px;line-height:16px;font-weight:normal;width:4px; height:4px">&nbsp;</th>
822
- <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px" ">
822
+ <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px">
823
823
  ${cards[1] || ""}
824
824
  </th>
825
825
  <th class="property-triple-spacer-${uniqueId}" style="font-size:0px;line-height:16px;font-weight:normal;width:4px; height:4px">&nbsp;</th>
826
- <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px" ">
826
+ <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px">
827
827
  ${cards[2] || ""}
828
828
  </th>
829
829
  </tr>
@@ -5,7 +5,7 @@ import {
5
5
  MAILLOW_EMAIL_EDITOR_VERSION,
6
6
  Preview,
7
7
  useEditorStore
8
- } from "./chunk-G7F7GRJC.mjs";
8
+ } from "./chunk-RSM3GOFU.mjs";
9
9
  export {
10
10
  Editor,
11
11
  History,
package/dist/index.d.mts CHANGED
@@ -287,7 +287,7 @@ 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>;
package/dist/index.d.ts CHANGED
@@ -287,7 +287,7 @@ 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>;
package/dist/index.js CHANGED
@@ -890,15 +890,15 @@ function propertyCardTripleMockMjml(block, context) {
890
890
  ${responsiveStyles}
891
891
  <mj-table align="center" width="${width}" padding="0" css-class="${trackingClasses}">
892
892
  <tr class="property-triple-row-${uniqueId}">
893
- <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px"">
893
+ <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px">
894
894
  ${cards[0] || ""}
895
895
  </th>
896
896
  <th class="property-triple-spacer-${uniqueId}" style="font-size:0px;line-height:16px;font-weight:normal;width:4px; height:4px">&nbsp;</th>
897
- <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px" ">
897
+ <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px">
898
898
  ${cards[1] || ""}
899
899
  </th>
900
900
  <th class="property-triple-spacer-${uniqueId}" style="font-size:0px;line-height:16px;font-weight:normal;width:4px; height:4px">&nbsp;</th>
901
- <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px" ">
901
+ <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px">
902
902
  ${cards[2] || ""}
903
903
  </th>
904
904
  </tr>
@@ -16967,6 +16967,46 @@ function TemplateNameDialog() {
16967
16967
 
16968
16968
  // src/core/editor/components/email-template-v2/header.tsx
16969
16969
  init_editor();
16970
+
16971
+ // src/core/editor/utils/capture-template.ts
16972
+ var import_html_to_image = require("html-to-image");
16973
+ var CAPTURE_WIDTH = 600;
16974
+ async function captureTemplateImage(compiledHtml) {
16975
+ const container = document.createElement("div");
16976
+ container.style.position = "fixed";
16977
+ container.style.top = "0";
16978
+ container.style.left = "0";
16979
+ container.style.zIndex = "99999";
16980
+ container.style.width = `${CAPTURE_WIDTH}px`;
16981
+ container.style.backgroundColor = "#FFFFFF00";
16982
+ container.style.overflow = "hidden";
16983
+ container.style.maxHeight = "100vh";
16984
+ container.style.opacity = "0";
16985
+ container.innerHTML = compiledHtml;
16986
+ document.body.appendChild(container);
16987
+ await new Promise((resolve) => requestAnimationFrame(resolve));
16988
+ await new Promise((resolve) => setTimeout(resolve, 100));
16989
+ try {
16990
+ const dataUrl = await (0, import_html_to_image.toPng)(container, {
16991
+ width: CAPTURE_WIDTH,
16992
+ quality: 0.1,
16993
+ pixelRatio: 1,
16994
+ cacheBust: true,
16995
+ imagePlaceholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN88P/BfwAJhAPkD+pMGAAAAABJRU5ErkJggg==",
16996
+ backgroundColor: "#ffffff",
16997
+ fetchRequestInit: { mode: "cors" },
16998
+ skipFonts: true,
16999
+ // Override opacity on the cloned node (real element is opacity:0 to stay invisible)
17000
+ style: { opacity: "1" }
17001
+ });
17002
+ return dataUrl;
17003
+ } finally {
17004
+ document.body.removeChild(container);
17005
+ }
17006
+ }
17007
+
17008
+ // src/core/editor/components/email-template-v2/header.tsx
17009
+ init_json2mjml();
16970
17010
  init_core();
16971
17011
  var import_jsx_runtime56 = require("react/jsx-runtime");
16972
17012
  function TemplateHeader() {
@@ -16980,14 +17020,22 @@ function TemplateHeader() {
16980
17020
  const onDelete = useEditorStore((s) => s.onDelete);
16981
17021
  const templateName = useEditorStore((s) => s.template?.name);
16982
17022
  const handleExit = async () => {
16983
- console.log("handleExit - templateId:", templateId);
16984
17023
  if (isSaving || !templateId || !onSave) return;
16985
17024
  setIsSaving(true);
16986
17025
  try {
16987
- await onSave(templateId, useEditorStore.getState().template);
17026
+ const template = useEditorStore.getState().template;
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 || "");
17035
+ }
17036
+ await onSave(templateId, template, capturedImage);
16988
17037
  markAsSaved();
16989
17038
  onExit?.();
16990
- console.log("handleExit - onExit called");
16991
17039
  } catch (error) {
16992
17040
  console.error("Failed to save:", error);
16993
17041
  } finally {
package/dist/index.mjs CHANGED
@@ -60,7 +60,7 @@ import {
60
60
  setupDragImage,
61
61
  useEditorStore,
62
62
  useSidebarContext
63
- } from "./chunk-G7F7GRJC.mjs";
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";
@@ -203,6 +203,43 @@ function TemplateNameDialog() {
203
203
  ] });
204
204
  }
205
205
 
206
+ // src/core/editor/utils/capture-template.ts
207
+ import { toPng } from "html-to-image";
208
+ var CAPTURE_WIDTH = 600;
209
+ async function captureTemplateImage(compiledHtml) {
210
+ const container = document.createElement("div");
211
+ container.style.position = "fixed";
212
+ container.style.top = "0";
213
+ container.style.left = "0";
214
+ container.style.zIndex = "99999";
215
+ container.style.width = `${CAPTURE_WIDTH}px`;
216
+ container.style.backgroundColor = "#FFFFFF00";
217
+ container.style.overflow = "hidden";
218
+ container.style.maxHeight = "100vh";
219
+ container.style.opacity = "0";
220
+ container.innerHTML = compiledHtml;
221
+ document.body.appendChild(container);
222
+ await new Promise((resolve) => requestAnimationFrame(resolve));
223
+ await new Promise((resolve) => setTimeout(resolve, 100));
224
+ try {
225
+ const dataUrl = await toPng(container, {
226
+ width: CAPTURE_WIDTH,
227
+ quality: 0.1,
228
+ pixelRatio: 1,
229
+ cacheBust: true,
230
+ imagePlaceholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN88P/BfwAJhAPkD+pMGAAAAABJRU5ErkJggg==",
231
+ backgroundColor: "#ffffff",
232
+ fetchRequestInit: { mode: "cors" },
233
+ skipFonts: true,
234
+ // Override opacity on the cloned node (real element is opacity:0 to stay invisible)
235
+ style: { opacity: "1" }
236
+ });
237
+ return dataUrl;
238
+ } finally {
239
+ document.body.removeChild(container);
240
+ }
241
+ }
242
+
206
243
  // src/core/editor/components/email-template-v2/header.tsx
207
244
  import { jsx as jsx4, jsxs as jsxs5 } from "react/jsx-runtime";
208
245
  function TemplateHeader() {
@@ -216,14 +253,22 @@ function TemplateHeader() {
216
253
  const onDelete = useEditorStore((s) => s.onDelete);
217
254
  const templateName = useEditorStore((s) => s.template?.name);
218
255
  const handleExit = async () => {
219
- console.log("handleExit - templateId:", templateId);
220
256
  if (isSaving || !templateId || !onSave) return;
221
257
  setIsSaving(true);
222
258
  try {
223
- await onSave(templateId, useEditorStore.getState().template);
259
+ const template = useEditorStore.getState().template;
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);
224
270
  markAsSaved();
225
271
  onExit?.();
226
- console.log("handleExit - onExit called");
227
272
  } catch (error) {
228
273
  console.error("Failed to save:", error);
229
274
  } finally {
@@ -11663,7 +11708,7 @@ function useAutoSave() {
11663
11708
  // src/core/editor/components/email-template-v2/template-page.tsx
11664
11709
  import "react-json-view-lite/dist/index.css";
11665
11710
  import { jsx as jsx74, jsxs as jsxs59 } from "react/jsx-runtime";
11666
- var Editor2 = lazy(() => import("./core-P3XCQRWR.mjs").then((module) => ({
11711
+ var Editor2 = lazy(() => import("./core-HSOSY6BB.mjs").then((module) => ({
11667
11712
  default: module.Editor
11668
11713
  })));
11669
11714
  function TemplatePage({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kgalexander/mcreate",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Maillow email template editor",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",