monto-email-builder 1.0.7 → 1.0.8

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.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- export default function SidebarButton({ href, children }: {
3
- href: string;
2
+ export default function SidebarButton({ sampleName, children }: {
3
+ sampleName: string;
4
4
  children: JSX.Element | string;
5
5
  }): React.JSX.Element;
6
6
  //# sourceMappingURL=SidebarButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SidebarButton.d.ts","sourceRoot":"","sources":["../../../src/App/SamplesDrawer/SidebarButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAOxC,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAA;CAAE,qBA2BzG"}
1
+ {"version":3,"file":"SidebarButton.d.ts","sourceRoot":"","sources":["../../../src/App/SamplesDrawer/SidebarButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAOxC,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAA;CAAE,qBAoBrH"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/App/SamplesDrawer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,aAAa,sBA2FpC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/App/SamplesDrawer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,aAAa,sBAoFpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"highlighters.d.ts","sourceRoot":"","sources":["../../../../src/App/TemplatePanel/helper/highlighters.tsx"],"names":[],"mappings":"AAiEA,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAsCzD;AAED,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiCzD"}
1
+ {"version":3,"file":"highlighters.d.ts","sourceRoot":"","sources":["../../../../src/App/TemplatePanel/helper/highlighters.tsx"],"names":[],"mappings":"AA+HA,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA+MzD;AAED,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA0DzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/App/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAmBzC,MAAM,CAAC,OAAO,UAAU,GAAG,sBAoE1B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/App/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAkB1B,MAAM,CAAC,OAAO,UAAU,GAAG,sBAsC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/EmailBuilder/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAezC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA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C;AAED,wBAAgB,qBAAqB,gBA9KH,oBAAoB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,cAgL9E;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,oBAAoB,CAAC,QAE1E;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,QAQnG;AAED,wBAAgB,OAAO,WAEtB;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,QAMnC;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,cAAc,CAAC,QAE9D"}
package/dist/index.d.ts CHANGED
@@ -8,5 +8,4 @@ export type { EmailBuilderProps } from './EmailBuilder';
8
8
  export type { TEditorConfiguration, TEditorBlock } from './documents/editor/core';
9
9
  export type { Language } from './i18n';
10
10
  export { useDocument, useLanguage } from './documents/editor/EditorContext';
11
- export { configToHash } from './getConfiguration';
12
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAClF,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAClF,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC"}
package/dist/index.js CHANGED
@@ -19,66 +19,6 @@ import { SpacerPropsDefaults, SpacerPropsSchema, Spacer } from "@usewaypoint/blo
19
19
  import { TextPropsSchema, Text } from "@usewaypoint/block-text";
20
20
  import { renderToStaticMarkup, Reader } from "@usewaypoint/email-builder";
21
21
  import { buildBlockConfigurationDictionary, buildBlockComponent, buildBlockConfigurationSchema } from "@usewaypoint/document-core";
22
- const sampleTemplates = {
23
- welcome: () => import("./samples-BnRgwIcn.js").then((n) => n.w).then((m) => m.default),
24
- "one-time-password": () => import("./samples-BnRgwIcn.js").then((n) => n.o).then((m) => m.default),
25
- "order-ecomerce": () => import("./samples-BnRgwIcn.js").then((n) => n.a).then((m) => m.default),
26
- "post-metrics-report": () => import("./samples-BnRgwIcn.js").then((n) => n.p).then((m) => m.default),
27
- "reservation-reminder": () => import("./samples-BnRgwIcn.js").then((n) => n.r).then((m) => m.default),
28
- "reset-password": () => import("./samples-BnRgwIcn.js").then((n) => n.b).then((m) => m.default),
29
- "respond-to-message": () => import("./samples-BnRgwIcn.js").then((n) => n.c).then((m) => m.default),
30
- "subscription-receipt": () => import("./samples-BnRgwIcn.js").then((n) => n.s).then((m) => m.default),
31
- "basic-template": () => import("./samples-BnRgwIcn.js").then((n) => n.d).then((m) => m.default)
32
- };
33
- const templateCache = {};
34
- function getConfiguration(template) {
35
- if (template.startsWith("#sample/")) {
36
- return EMPTY_EMAIL_MESSAGE;
37
- }
38
- if (template.startsWith("#code/")) {
39
- const encodedString = template.replace("#code/", "");
40
- try {
41
- const configurationString = decodeURIComponent(atob(encodedString));
42
- return JSON.parse(configurationString);
43
- } catch (error) {
44
- console.error(`Couldn't load configuration from hash (code format):`, error);
45
- return EMPTY_EMAIL_MESSAGE;
46
- }
47
- }
48
- if (template.startsWith("#json/")) {
49
- const encodedString = template.replace("#json/", "");
50
- try {
51
- const configurationString = decodeURIComponent(encodedString);
52
- return JSON.parse(configurationString);
53
- } catch (error) {
54
- console.error(`Couldn't load configuration from hash (json format):`, error);
55
- return EMPTY_EMAIL_MESSAGE;
56
- }
57
- }
58
- return EMPTY_EMAIL_MESSAGE;
59
- }
60
- async function loadSampleTemplate(sampleName) {
61
- const loader = sampleTemplates[sampleName];
62
- if (!loader) {
63
- return EMPTY_EMAIL_MESSAGE;
64
- }
65
- if (templateCache[sampleName]) {
66
- return templateCache[sampleName];
67
- }
68
- const template = await loader();
69
- templateCache[sampleName] = template;
70
- return template;
71
- }
72
- function configToHash(config, format = "json") {
73
- const jsonString = JSON.stringify(config);
74
- if (format === "code") {
75
- const encoded = btoa(encodeURIComponent(jsonString));
76
- return `#code/${encoded}`;
77
- } else {
78
- const encoded = encodeURIComponent(jsonString);
79
- return `#json/${encoded}`;
80
- }
81
- }
82
22
  const common$1 = {
83
23
  newDocument: "New Blank Document",
84
24
  useBuiltInTemplates: "Use Built-in Templates",
@@ -87,7 +27,7 @@ const common$1 = {
87
27
  saving: "Saving...",
88
28
  saveAndExit: "Save and Exit",
89
29
  namePlaceholder: "Enter template name",
90
- unnamedTemplate: "Unnamed Template",
30
+ unnamedTemplate: "",
91
31
  desktopView: "Desktop view",
92
32
  mobileView: "Mobile view",
93
33
  downloadJson: "Download JSON file",
@@ -264,7 +204,7 @@ function setLanguage$1(lang) {
264
204
  }
265
205
  }
266
206
  const editorStateStore = create((set, get) => ({
267
- document: getConfiguration(typeof window !== "undefined" ? window.location.hash : ""),
207
+ document: EMPTY_EMAIL_MESSAGE,
268
208
  selectedBlockId: null,
269
209
  selectedSidebarTab: "styles",
270
210
  selectedMainTab: "editor",
@@ -317,22 +257,22 @@ function setSelectedBlockId(selectedBlockId) {
317
257
  function setSidebarTab(selectedSidebarTab) {
318
258
  return editorStateStore.setState({ selectedSidebarTab });
319
259
  }
320
- function resetDocument(document) {
260
+ function resetDocument(document2) {
321
261
  editorStateStore.setState({
322
- document,
262
+ document: document2,
323
263
  selectedSidebarTab: "styles",
324
264
  selectedBlockId: null
325
265
  });
326
266
  const onChange = editorStateStore.getState().onChange;
327
267
  if (onChange) {
328
- onChange(document);
268
+ onChange(document2);
329
269
  }
330
270
  }
331
- function setDocument(document) {
271
+ function setDocument(document2) {
332
272
  const originalDocument = editorStateStore.getState().document;
333
273
  const newDocument = {
334
274
  ...originalDocument,
335
- ...document
275
+ ...document2
336
276
  };
337
277
  editorStateStore.setState({
338
278
  document: newDocument
@@ -376,10 +316,10 @@ function setSaveHandler(handler) {
376
316
  return editorStateStore.setState({ saveHandler: handler });
377
317
  }
378
318
  async function saveDocument() {
379
- const document = editorStateStore.getState().document;
319
+ const document2 = editorStateStore.getState().document;
380
320
  const saveHandler = editorStateStore.getState().saveHandler;
381
321
  if (saveHandler) {
382
- await saveHandler(document);
322
+ await saveHandler(document2);
383
323
  }
384
324
  }
385
325
  function useSaveAndExitHandler() {
@@ -389,9 +329,9 @@ function setSaveAndExitHandler(handler) {
389
329
  return editorStateStore.setState({ saveAndExitHandler: handler });
390
330
  }
391
331
  function saveAndExitDocument(onExit) {
392
- const document = editorStateStore.getState().document;
332
+ const document2 = editorStateStore.getState().document;
393
333
  if (onExit) {
394
- Promise.resolve(onExit(document)).catch((error) => {
334
+ Promise.resolve(onExit(document2)).catch((error) => {
395
335
  console.error("Error in exit handler:", error);
396
336
  });
397
337
  }
@@ -2289,12 +2229,12 @@ function renderMessage(val) {
2289
2229
  }
2290
2230
  function ConfigurationPanel() {
2291
2231
  const { t: t2 } = useTranslation();
2292
- const document = useDocument();
2232
+ const document2 = useDocument();
2293
2233
  const selectedBlockId = useSelectedBlockId();
2294
2234
  if (!selectedBlockId) {
2295
2235
  return renderMessage(t2("inspector.clickBlockToInspect"));
2296
2236
  }
2297
- const block = document[selectedBlockId];
2237
+ const block = document2[selectedBlockId];
2298
2238
  if (!block) {
2299
2239
  return renderMessage(t2("inspector.blockNotFound", { id: selectedBlockId }));
2300
2240
  }
@@ -2388,38 +2328,51 @@ function InspectorDrawer() {
2388
2328
  }
2389
2329
  );
2390
2330
  }
2391
- function SidebarButton({ href, children }) {
2331
+ const sampleTemplates = {
2332
+ welcome: () => import("./samples-BnRgwIcn.js").then((n) => n.w).then((m) => m.default),
2333
+ "one-time-password": () => import("./samples-BnRgwIcn.js").then((n) => n.o).then((m) => m.default),
2334
+ "order-ecomerce": () => import("./samples-BnRgwIcn.js").then((n) => n.a).then((m) => m.default),
2335
+ "post-metrics-report": () => import("./samples-BnRgwIcn.js").then((n) => n.p).then((m) => m.default),
2336
+ "reservation-reminder": () => import("./samples-BnRgwIcn.js").then((n) => n.r).then((m) => m.default),
2337
+ "reset-password": () => import("./samples-BnRgwIcn.js").then((n) => n.b).then((m) => m.default),
2338
+ "respond-to-message": () => import("./samples-BnRgwIcn.js").then((n) => n.c).then((m) => m.default),
2339
+ "subscription-receipt": () => import("./samples-BnRgwIcn.js").then((n) => n.s).then((m) => m.default),
2340
+ "basic-template": () => import("./samples-BnRgwIcn.js").then((n) => n.d).then((m) => m.default)
2341
+ };
2342
+ const templateCache = {};
2343
+ async function loadSampleTemplate(sampleName) {
2344
+ const loader = sampleTemplates[sampleName];
2345
+ if (!loader) {
2346
+ return EMPTY_EMAIL_MESSAGE;
2347
+ }
2348
+ if (templateCache[sampleName]) {
2349
+ return templateCache[sampleName];
2350
+ }
2351
+ const template = await loader();
2352
+ templateCache[sampleName] = template;
2353
+ return template;
2354
+ }
2355
+ function SidebarButton({ sampleName, children }) {
2392
2356
  const [loading, setLoading] = useState(false);
2393
2357
  const handleClick = async () => {
2394
- if (href.startsWith("#sample/")) {
2395
- setLoading(true);
2396
- try {
2397
- const sampleName = href.replace("#sample/", "");
2398
- const template = await loadSampleTemplate(sampleName);
2399
- resetDocument(template);
2400
- } catch (error) {
2401
- console.error("Failed to load template:", error);
2402
- } finally {
2403
- setLoading(false);
2404
- }
2405
- } else {
2406
- const config = getConfiguration(href);
2407
- resetDocument(config);
2358
+ setLoading(true);
2359
+ try {
2360
+ const template = await loadSampleTemplate(sampleName);
2361
+ resetDocument(template);
2362
+ } catch (error) {
2363
+ console.error("Failed to load template:", error);
2364
+ } finally {
2365
+ setLoading(false);
2408
2366
  }
2409
2367
  };
2410
- return /* @__PURE__ */ jsx(Button, { size: "small", href, onClick: handleClick, disabled: loading, children: loading ? "Loading..." : children });
2368
+ return /* @__PURE__ */ jsx(Button, { size: "small", onClick: handleClick, disabled: loading, children: loading ? "Loading..." : children });
2411
2369
  }
2412
2370
  const SAMPLES_DRAWER_WIDTH = 240;
2413
2371
  function SamplesDrawer() {
2414
2372
  const { t: t2 } = useTranslation();
2415
2373
  const samplesDrawerOpen = useSamplesDrawerOpen();
2416
- const currentHash = typeof window !== "undefined" ? window.location.hash : "";
2417
- const isNewDocument = !currentHash || currentHash === "#";
2418
2374
  const handleNewDocumentClick = () => {
2419
- resetDocument(getConfiguration("#"));
2420
- if (typeof window !== "undefined") {
2421
- window.location.hash = "#";
2422
- }
2375
+ resetDocument(EMPTY_EMAIL_MESSAGE);
2423
2376
  };
2424
2377
  return /* @__PURE__ */ jsx(
2425
2378
  Drawer,
@@ -2456,10 +2409,9 @@ function SamplesDrawer() {
2456
2409
  size: "small",
2457
2410
  variant: "contained",
2458
2411
  color: "primary",
2459
- href: "#",
2460
2412
  onClick: handleNewDocumentClick,
2461
2413
  sx: {
2462
- fontWeight: isNewDocument ? 600 : 400,
2414
+ fontWeight: 600,
2463
2415
  width: "100%",
2464
2416
  justifyContent: "flex-start"
2465
2417
  },
@@ -2470,9 +2422,9 @@ function SamplesDrawer() {
2470
2422
  /* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
2471
2423
  /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", sx: { px: 0.75, fontWeight: 500 }, children: t2("common.useBuiltInTemplates") }),
2472
2424
  /* @__PURE__ */ jsxs(Stack, { alignItems: "flex-start", children: [
2473
- /* @__PURE__ */ jsx(SidebarButton, { href: "#sample/basic-template", children: t2("samples.quickStart") }),
2474
- /* @__PURE__ */ jsx(SidebarButton, { href: "#sample/welcome", children: t2("samples.welcomeEmail") }),
2475
- /* @__PURE__ */ jsx(SidebarButton, { href: "#sample/reservation-reminder", children: t2("samples.reservationReminder") })
2425
+ /* @__PURE__ */ jsx(SidebarButton, { sampleName: "basic-template", children: t2("samples.quickStart") }),
2426
+ /* @__PURE__ */ jsx(SidebarButton, { sampleName: "welcome", children: t2("samples.welcomeEmail") }),
2427
+ /* @__PURE__ */ jsx(SidebarButton, { sampleName: "reservation-reminder", children: t2("samples.reservationReminder") })
2476
2428
  ] })
2477
2429
  ] })
2478
2430
  ] }) })
@@ -2836,7 +2788,7 @@ function ColumnsContainerEditor({ style, props }) {
2836
2788
  }
2837
2789
  function ContainerEditor({ style, props }) {
2838
2790
  const childrenIds = (props == null ? void 0 : props.childrenIds) ?? [];
2839
- const document = useDocument();
2791
+ const document2 = useDocument();
2840
2792
  const currentBlockId = useCurrentBlockId();
2841
2793
  return /* @__PURE__ */ jsx(Container, { style, children: /* @__PURE__ */ jsx(
2842
2794
  EditorChildrenIds,
@@ -2848,7 +2800,7 @@ function ContainerEditor({ style, props }) {
2848
2800
  [currentBlockId]: {
2849
2801
  type: "Container",
2850
2802
  data: {
2851
- ...document[currentBlockId].data,
2803
+ ...document2[currentBlockId].data,
2852
2804
  props: { childrenIds: childrenIds2 }
2853
2805
  }
2854
2806
  }
@@ -2883,7 +2835,7 @@ function getFontFamily(fontFamily) {
2883
2835
  }
2884
2836
  function EmailLayoutEditor(props) {
2885
2837
  const childrenIds = props.childrenIds ?? [];
2886
- const document = useDocument();
2838
+ const document2 = useDocument();
2887
2839
  const currentBlockId = useCurrentBlockId();
2888
2840
  return /* @__PURE__ */ jsx(
2889
2841
  "div",
@@ -2936,7 +2888,7 @@ function EmailLayoutEditor(props) {
2936
2888
  [currentBlockId]: {
2937
2889
  type: "EmailLayout",
2938
2890
  data: {
2939
- ...document[currentBlockId].data,
2891
+ ...document2[currentBlockId].data,
2940
2892
  childrenIds: childrenIds2
2941
2893
  }
2942
2894
  }
@@ -2983,7 +2935,7 @@ const sx = {
2983
2935
  zIndex: "fab"
2984
2936
  };
2985
2937
  function TuneMenu({ blockId }) {
2986
- const document = useDocument();
2938
+ const document2 = useDocument();
2987
2939
  const handleDeleteClick = () => {
2988
2940
  var _a, _b, _c;
2989
2941
  const filterChildrenIds = (childrenIds) => {
@@ -2992,7 +2944,7 @@ function TuneMenu({ blockId }) {
2992
2944
  }
2993
2945
  return childrenIds.filter((f) => f !== blockId);
2994
2946
  };
2995
- const nDocument = { ...document };
2947
+ const nDocument = { ...document2 };
2996
2948
  for (const [id, b] of Object.entries(nDocument)) {
2997
2949
  const block = b;
2998
2950
  if (id === blockId) {
@@ -3059,7 +3011,7 @@ function TuneMenu({ blockId }) {
3059
3011
  }
3060
3012
  return childrenIds;
3061
3013
  };
3062
- const nDocument = { ...document };
3014
+ const nDocument = { ...document2 };
3063
3015
  for (const [id, b] of Object.entries(nDocument)) {
3064
3016
  const block = b;
3065
3017
  if (id === blockId) {
@@ -3212,8 +3164,8 @@ const EditorConfigurationSchema = z.record(z.string(), EditorBlockSchema);
3212
3164
  const EditorBlockContext = createContext(null);
3213
3165
  const useCurrentBlockId = () => useContext(EditorBlockContext);
3214
3166
  function EditorBlock({ id }) {
3215
- const document = useDocument();
3216
- const block = document[id];
3167
+ const document2 = useDocument();
3168
+ const block = document2[id];
3217
3169
  if (!block) {
3218
3170
  throw new Error("Could not find block");
3219
3171
  }
@@ -3253,15 +3205,48 @@ let jsonHighlighter;
3253
3205
  let xmlHighlighter;
3254
3206
  let prettierFormat;
3255
3207
  let prettierPluginHtml;
3208
+ function escapeHtml(text) {
3209
+ if (typeof document === "undefined") {
3210
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3211
+ }
3212
+ const div = document.createElement("div");
3213
+ div.textContent = text;
3214
+ return div.innerHTML;
3215
+ }
3216
+ function loadHighlightJsCSS() {
3217
+ if (typeof document === "undefined") return;
3218
+ const existingLink = document.querySelector("link[data-highlight-js-css]");
3219
+ if (existingLink) return;
3220
+ try {
3221
+ const link = document.createElement("link");
3222
+ link.rel = "stylesheet";
3223
+ link.href = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css";
3224
+ link.setAttribute("data-highlight-js-css", "true");
3225
+ document.head.appendChild(link);
3226
+ } catch (error) {
3227
+ console.warn("Failed to load highlight.js CSS:", error);
3228
+ }
3229
+ }
3256
3230
  async function loadHighlightJs() {
3257
3231
  if (!hljs) {
3258
- hljs = await import("highlight.js");
3259
- jsonHighlighter = await import("highlight.js/lib/languages/json");
3260
- xmlHighlighter = await import("highlight.js/lib/languages/xml");
3261
- hljs.default.registerLanguage("json", jsonHighlighter.default);
3262
- hljs.default.registerLanguage("html", xmlHighlighter.default);
3232
+ try {
3233
+ const hljsModule = await import("highlight.js");
3234
+ hljs = hljsModule.default || hljsModule;
3235
+ jsonHighlighter = await import("highlight.js/lib/languages/json");
3236
+ xmlHighlighter = await import("highlight.js/lib/languages/xml");
3237
+ const jsonLang = jsonHighlighter.default || jsonHighlighter;
3238
+ const xmlLang = xmlHighlighter.default || xmlHighlighter;
3239
+ hljs.registerLanguage("json", jsonLang);
3240
+ hljs.registerLanguage("html", xmlLang);
3241
+ loadHighlightJsCSS();
3242
+ } catch (error) {
3243
+ console.error("Failed to load highlight.js. Please ensure highlight.js is installed:", error);
3244
+ hljs = {
3245
+ highlight: (code) => ({ value: escapeHtml(code) })
3246
+ };
3247
+ }
3263
3248
  }
3264
- return hljs.default;
3249
+ return hljs;
3265
3250
  }
3266
3251
  function dynamicImport(path) {
3267
3252
  const importFunc = new Function("path", "return import(path)");
@@ -3271,6 +3256,13 @@ async function loadPrettier() {
3271
3256
  if (!prettierFormat) {
3272
3257
  try {
3273
3258
  const prettierMain = await import("prettier");
3259
+ const prettierVersion = prettierMain.version || "2.0.0";
3260
+ const majorVersion = parseInt(prettierVersion.split(".")[0], 10);
3261
+ if (majorVersion < 3) {
3262
+ prettierFormat = prettierMain.format;
3263
+ prettierPluginHtml = null;
3264
+ return prettierFormat;
3265
+ }
3274
3266
  try {
3275
3267
  const prettierStandalone = await dynamicImport("prettier/standalone");
3276
3268
  prettierFormat = prettierStandalone.format;
@@ -3295,39 +3287,171 @@ async function loadPrettier() {
3295
3287
  return prettierFormat;
3296
3288
  }
3297
3289
  async function html(value) {
3298
- const [hljsInstance, format] = await Promise.all([loadHighlightJs(), loadPrettier()]);
3299
- const isPrettierV3 = !!prettierPluginHtml;
3290
+ let hljsInstance;
3291
+ let format;
3292
+ try {
3293
+ [hljsInstance, format] = await Promise.all([loadHighlightJs(), loadPrettier()]);
3294
+ } catch (error) {
3295
+ console.error("Failed to load highlight.js or prettier:", error);
3296
+ return escapeHtml(value);
3297
+ }
3300
3298
  const formatOptions = {
3301
- parser: "html"
3299
+ parser: "html",
3300
+ printWidth: 120,
3301
+ tabWidth: 2,
3302
+ useTabs: false,
3303
+ htmlWhitespaceSensitivity: "ignore",
3304
+ // 忽略HTML空白敏感度,避免不必要的缩进
3305
+ bracketSameLine: false
3306
+ // 确保开始和结束标签在不同行,便于对齐
3302
3307
  };
3303
- if (isPrettierV3 && prettierPluginHtml) {
3308
+ if (prettierPluginHtml) {
3304
3309
  const htmlParser = prettierPluginHtml.default || prettierPluginHtml;
3305
3310
  formatOptions.plugins = [htmlParser];
3306
3311
  }
3312
+ const removeLeadingIndent = (text) => {
3313
+ const lines = text.split("\n");
3314
+ if (lines.length === 0) return text;
3315
+ const firstNonEmptyLine = lines.find((line) => line.trim().length > 0);
3316
+ if (!firstNonEmptyLine) return text;
3317
+ const trimmedFirstLine = firstNonEmptyLine.trim();
3318
+ const isRootTag = trimmedFirstLine.startsWith("<!DOCTYPE") || trimmedFirstLine.startsWith("<html");
3319
+ if (isRootTag) {
3320
+ const leadingSpaces = firstNonEmptyLine.length - firstNonEmptyLine.trimStart().length;
3321
+ if (leadingSpaces > 0) {
3322
+ return lines.map((line) => {
3323
+ if (line.trim().length === 0) return line;
3324
+ const currentLeading = line.length - line.trimStart().length;
3325
+ if (currentLeading >= leadingSpaces) {
3326
+ return line.substring(leadingSpaces);
3327
+ }
3328
+ return line;
3329
+ }).join("\n");
3330
+ }
3331
+ }
3332
+ return text;
3333
+ };
3334
+ const fixTagAlignment = (text) => {
3335
+ var _a, _b;
3336
+ const lines = text.split("\n");
3337
+ const stack = [];
3338
+ const result = [];
3339
+ for (let i = 0; i < lines.length; i++) {
3340
+ const line = lines[i];
3341
+ const trimmed = line.trim();
3342
+ if (!trimmed) {
3343
+ result.push(line);
3344
+ continue;
3345
+ }
3346
+ const currentIndent = line.length - line.trimStart().length;
3347
+ const isClosingTag = trimmed.startsWith("</");
3348
+ const isSelfClosing = trimmed.endsWith("/>");
3349
+ const isOpeningTag = trimmed.startsWith("<") && !isClosingTag && !isSelfClosing;
3350
+ if (isClosingTag) {
3351
+ const tagName = (_a = trimmed.match(/<\/(\w+)/)) == null ? void 0 : _a[1];
3352
+ if (tagName && stack.length > 0) {
3353
+ const opening = stack[stack.length - 1];
3354
+ if (opening.tag === tagName) {
3355
+ const correctIndent = opening.indent;
3356
+ result.push(" ".repeat(correctIndent) + trimmed);
3357
+ stack.pop();
3358
+ continue;
3359
+ }
3360
+ }
3361
+ result.push(line);
3362
+ } else if (isOpeningTag) {
3363
+ const tagName = (_b = trimmed.match(/<(\w+)/)) == null ? void 0 : _b[1];
3364
+ if (tagName) {
3365
+ stack.push({ tag: tagName, indent: currentIndent });
3366
+ }
3367
+ result.push(line);
3368
+ } else {
3369
+ result.push(line);
3370
+ }
3371
+ }
3372
+ return result.join("\n");
3373
+ };
3307
3374
  let prettyValue;
3308
3375
  try {
3309
3376
  prettyValue = await format(value, formatOptions);
3377
+ if (!prettyValue || typeof prettyValue !== "string") {
3378
+ throw new Error("Prettier returned invalid value");
3379
+ }
3380
+ prettyValue = removeLeadingIndent(prettyValue);
3381
+ prettyValue = fixTagAlignment(prettyValue);
3310
3382
  } catch (error) {
3311
- if (isPrettierV3) {
3383
+ try {
3384
+ const prettierMain = await import("prettier");
3385
+ const mainFormatOptions = {
3386
+ parser: "html",
3387
+ printWidth: 120,
3388
+ tabWidth: 2,
3389
+ useTabs: false,
3390
+ htmlWhitespaceSensitivity: "ignore",
3391
+ bracketSameLine: false
3392
+ // 确保开始和结束标签在不同行,便于对齐
3393
+ };
3394
+ prettyValue = await prettierMain.format(value, mainFormatOptions);
3395
+ if (!prettyValue || typeof prettyValue !== "string") {
3396
+ throw new Error("Prettier main package returned invalid value");
3397
+ }
3398
+ prettyValue = removeLeadingIndent(prettyValue);
3399
+ prettyValue = fixTagAlignment(prettyValue);
3400
+ } catch (fallbackError) {
3312
3401
  try {
3313
- const prettierMain = await import("prettier");
3314
- prettyValue = await prettierMain.format(value, { parser: "html" });
3402
+ let formatted = value.replace(/></g, ">\n<").replace(/\n\s*\n/g, "\n").split("\n");
3403
+ let indent = 0;
3404
+ const indentSize = 2;
3405
+ const result = [];
3406
+ for (let i = 0; i < formatted.length; i++) {
3407
+ const line = formatted[i];
3408
+ const trimmed = line.trim();
3409
+ if (!trimmed) {
3410
+ result.push("");
3411
+ continue;
3412
+ }
3413
+ const isClosingTag = trimmed.startsWith("</");
3414
+ const isSelfClosing = trimmed.endsWith("/>");
3415
+ const isOpeningTag = trimmed.startsWith("<") && !isClosingTag && !isSelfClosing;
3416
+ if (isClosingTag) {
3417
+ indent = Math.max(0, indent - indentSize);
3418
+ result.push(" ".repeat(indent) + trimmed);
3419
+ } else if (isOpeningTag) {
3420
+ result.push(" ".repeat(indent) + trimmed);
3421
+ indent += indentSize;
3422
+ } else if (isSelfClosing) {
3423
+ result.push(" ".repeat(indent) + trimmed);
3424
+ } else {
3425
+ result.push(" ".repeat(indent) + trimmed);
3426
+ }
3427
+ }
3428
+ prettyValue = result.filter((line) => line.length > 0).join("\n");
3315
3429
  } catch {
3316
3430
  console.warn("Failed to format HTML, returning original value:", error);
3317
3431
  prettyValue = value;
3318
3432
  }
3319
- } else {
3320
- throw error;
3321
3433
  }
3322
3434
  }
3323
- return hljsInstance.highlight(prettyValue, { language: "html" }).value;
3435
+ try {
3436
+ return hljsInstance.highlight(prettyValue, { language: "html" }).value;
3437
+ } catch (error) {
3438
+ console.error("Failed to highlight HTML:", error);
3439
+ return escapeHtml(prettyValue);
3440
+ }
3324
3441
  }
3325
3442
  async function json(value) {
3326
- const [hljsInstance, format] = await Promise.all([loadHighlightJs(), loadPrettier()]);
3443
+ let hljsInstance;
3444
+ let format;
3445
+ try {
3446
+ [hljsInstance, format] = await Promise.all([loadHighlightJs(), loadPrettier()]);
3447
+ } catch (error) {
3448
+ console.error("Failed to load highlight.js or prettier:", error);
3449
+ return escapeHtml(value);
3450
+ }
3327
3451
  const formatOptions = {
3328
- parser: "json",
3329
- printWidth: 0,
3330
- trailingComma: "all"
3452
+ parser: "json"
3453
+ // 移除 printWidth: 0,使用默认值或设置一个合理的值
3454
+ // trailingComma: 'all' 在 JSON 中可能不支持,移除
3331
3455
  };
3332
3456
  let prettyValue;
3333
3457
  try {
@@ -3336,16 +3460,27 @@ async function json(value) {
3336
3460
  try {
3337
3461
  const prettierMain = await import("prettier");
3338
3462
  prettyValue = await prettierMain.format(value, {
3339
- parser: "json",
3340
- printWidth: 0,
3341
- trailingComma: "all"
3463
+ parser: "json"
3342
3464
  });
3343
- } catch {
3344
- console.warn("Failed to format JSON, returning original value:", error);
3345
- prettyValue = value;
3465
+ } catch (fallbackError) {
3466
+ try {
3467
+ const parsed = JSON.parse(value);
3468
+ prettyValue = JSON.stringify(parsed, null, 2);
3469
+ } catch {
3470
+ console.warn("Failed to format JSON, returning original value:", error);
3471
+ prettyValue = value;
3472
+ }
3346
3473
  }
3347
3474
  }
3348
- return hljsInstance.highlight(prettyValue, { language: "json" }).value;
3475
+ if (typeof prettyValue !== "string") {
3476
+ prettyValue = JSON.stringify(prettyValue, null, 2);
3477
+ }
3478
+ try {
3479
+ return hljsInstance.highlight(prettyValue, { language: "json" }).value;
3480
+ } catch (error) {
3481
+ console.error("Failed to highlight JSON:", error);
3482
+ return escapeHtml(prettyValue);
3483
+ }
3349
3484
  }
3350
3485
  function HighlightedCodePanel({ type, value }) {
3351
3486
  const [code, setCode] = useState(null);
@@ -3378,8 +3513,8 @@ function HighlightedCodePanel({ type, value }) {
3378
3513
  );
3379
3514
  }
3380
3515
  function HtmlPanel() {
3381
- const document = useDocument();
3382
- const code = useMemo(() => renderToStaticMarkup(document, { rootBlockId: "root" }), [document]);
3516
+ const document2 = useDocument();
3517
+ const code = useMemo(() => renderToStaticMarkup(document2, { rootBlockId: "root" }), [document2]);
3383
3518
  return /* @__PURE__ */ jsx(HighlightedCodePanel, { type: "html", value: code });
3384
3519
  }
3385
3520
  function validateTextAreaValue(value) {
@@ -3479,8 +3614,8 @@ function ImportJson() {
3479
3614
  ] });
3480
3615
  }
3481
3616
  function JsonPanel() {
3482
- const document = useDocument();
3483
- const code = useMemo(() => JSON.stringify(document, null, " "), [document]);
3617
+ const document2 = useDocument();
3618
+ const code = useMemo(() => JSON.stringify(document2, null, " "), [document2]);
3484
3619
  return /* @__PURE__ */ jsx(HighlightedCodePanel, { type: "json", value: code });
3485
3620
  }
3486
3621
  function MainTabsGroup() {
@@ -3615,7 +3750,7 @@ function SaveButton() {
3615
3750
  }
3616
3751
  function TemplatePanel() {
3617
3752
  const { t: t2 } = useTranslation();
3618
- const document = useDocument();
3753
+ const document2 = useDocument();
3619
3754
  const selectedMainTab = useSelectedMainTab();
3620
3755
  const selectedScreenSize = useSelectedScreenSize();
3621
3756
  let mainBoxSx = {
@@ -3646,7 +3781,7 @@ function TemplatePanel() {
3646
3781
  case "editor":
3647
3782
  return /* @__PURE__ */ jsx(Box, { sx: mainBoxSx, children: /* @__PURE__ */ jsx(EditorBlock, { id: "root" }) });
3648
3783
  case "preview":
3649
- return /* @__PURE__ */ jsx(Box, { sx: mainBoxSx, children: /* @__PURE__ */ jsx(Reader, { document, rootBlockId: "root" }) });
3784
+ return /* @__PURE__ */ jsx(Box, { sx: mainBoxSx, children: /* @__PURE__ */ jsx(Reader, { document: document2, rootBlockId: "root" }) });
3650
3785
  case "html":
3651
3786
  return /* @__PURE__ */ jsx(HtmlPanel, {});
3652
3787
  case "json":
@@ -3705,29 +3840,6 @@ function App() {
3705
3840
  const samplesDrawerOpen = useSamplesDrawerOpen();
3706
3841
  const marginLeftTransition = useDrawerTransition("margin-left", samplesDrawerOpen);
3707
3842
  const marginRightTransition = useDrawerTransition("margin-right", inspectorDrawerOpen);
3708
- useEffect(() => {
3709
- const handleHashLoad = async () => {
3710
- if (typeof window === "undefined") return;
3711
- const hash = window.location.hash;
3712
- if (hash.startsWith("#sample/")) {
3713
- const sampleName = hash.replace("#sample/", "");
3714
- try {
3715
- const template = await loadSampleTemplate(sampleName);
3716
- resetDocument(template);
3717
- } catch (error) {
3718
- console.error("Failed to load template from hash:", error);
3719
- }
3720
- }
3721
- };
3722
- handleHashLoad();
3723
- const handleHashChange = () => {
3724
- handleHashLoad();
3725
- };
3726
- window.addEventListener("hashchange", handleHashChange);
3727
- return () => {
3728
- window.removeEventListener("hashchange", handleHashChange);
3729
- };
3730
- }, []);
3731
3843
  return /* @__PURE__ */ jsxs(
3732
3844
  Box,
3733
3845
  {
@@ -3771,17 +3883,16 @@ function EmailBuilder({
3771
3883
  onNameChange,
3772
3884
  theme: customTheme
3773
3885
  }) {
3774
- const currentLanguage = useLanguage();
3775
3886
  useEffect(() => {
3776
3887
  if (initialDocument !== void 0) {
3777
3888
  resetDocument(initialDocument);
3778
3889
  }
3779
3890
  }, [initialDocument]);
3780
3891
  useEffect(() => {
3781
- if (initialLanguage && initialLanguage !== currentLanguage) {
3892
+ if (initialLanguage !== void 0) {
3782
3893
  setLanguage(initialLanguage);
3783
3894
  }
3784
- }, [initialLanguage, currentLanguage]);
3895
+ }, [initialLanguage]);
3785
3896
  useEffect(() => {
3786
3897
  setImageUploadHandler(imageUploadHandler);
3787
3898
  }, [imageUploadHandler]);
@@ -3822,7 +3933,6 @@ function EmailBuilder({
3822
3933
  }
3823
3934
  export {
3824
3935
  EmailBuilder,
3825
- configToHash,
3826
3936
  useDocument,
3827
3937
  useLanguage
3828
3938
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monto-email-builder",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A powerful and customizable email template builder React component library with visual editing, internationalization, and image upload support",
5
5
  "keywords": [
6
6
  "email",