@kontakto/email-template-editor 1.5.1 → 1.6.0

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.cjs CHANGED
@@ -1126,6 +1126,7 @@ var FONT_FAMILY_SCHEMA6 = zod.z.enum([
1126
1126
  ]).nullable().optional();
1127
1127
  var EmailLayoutPropsSchema = zod.z.object({
1128
1128
  backdropColor: COLOR_SCHEMA9,
1129
+ backdropDisabled: zod.z.boolean().optional().nullable(),
1129
1130
  borderColor: COLOR_SCHEMA9,
1130
1131
  borderRadius: zod.z.number().optional().nullable(),
1131
1132
  canvasColor: COLOR_SCHEMA9,
@@ -1165,22 +1166,27 @@ function getBorder2({ borderColor }) {
1165
1166
  function EmailLayoutReader(props) {
1166
1167
  var _a, _b, _c, _d, _e;
1167
1168
  const childrenIds = (_a = props.childrenIds) != null ? _a : [];
1169
+ const baseStyle = {
1170
+ color: (_b = props.textColor) != null ? _b : "#262626",
1171
+ fontFamily: getFontFamily6(props.fontFamily),
1172
+ fontSize: "16px",
1173
+ fontWeight: "400",
1174
+ letterSpacing: "0.15008px",
1175
+ lineHeight: "1.5",
1176
+ margin: "0"
1177
+ };
1178
+ if (props.backdropDisabled) {
1179
+ return /* @__PURE__ */ React72__default.default.createElement("div", { style: baseStyle }, childrenIds.map((childId) => /* @__PURE__ */ React72__default.default.createElement(ReaderBlock, { key: childId, id: childId })));
1180
+ }
1168
1181
  return /* @__PURE__ */ React72__default.default.createElement(
1169
1182
  "div",
1170
1183
  {
1171
- style: {
1172
- backgroundColor: (_b = props.backdropColor) != null ? _b : "#F5F5F5",
1173
- color: (_c = props.textColor) != null ? _c : "#262626",
1174
- fontFamily: getFontFamily6(props.fontFamily),
1175
- fontSize: "16px",
1176
- fontWeight: "400",
1177
- letterSpacing: "0.15008px",
1178
- lineHeight: "1.5",
1179
- margin: "0",
1184
+ style: __spreadProps(__spreadValues({}, baseStyle), {
1185
+ backgroundColor: (_c = props.backdropColor) != null ? _c : "#F5F5F5",
1180
1186
  padding: "32px 0",
1181
1187
  minHeight: "100%",
1182
1188
  width: "100%"
1183
- }
1189
+ })
1184
1190
  },
1185
1191
  /* @__PURE__ */ React72__default.default.createElement(
1186
1192
  "table",
@@ -1192,6 +1198,7 @@ function EmailLayoutReader(props) {
1192
1198
  maxWidth: "600px",
1193
1199
  backgroundColor: (_d = props.canvasColor) != null ? _d : "#FFFFFF",
1194
1200
  borderRadius: (_e = props.borderRadius) != null ? _e : void 0,
1201
+ overflow: props.borderRadius ? "hidden" : void 0,
1195
1202
  border: getBorder2(props)
1196
1203
  },
1197
1204
  role: "presentation",
@@ -2958,6 +2965,7 @@ var FONT_FAMILY_SCHEMA7 = zod.z.enum([
2958
2965
  ]).nullable().optional();
2959
2966
  var EmailLayoutPropsSchema2 = zod.z.object({
2960
2967
  backdropColor: COLOR_SCHEMA10,
2968
+ backdropDisabled: zod.z.boolean().optional().nullable(),
2961
2969
  borderColor: COLOR_SCHEMA10,
2962
2970
  borderRadius: zod.z.number().optional().nullable(),
2963
2971
  canvasColor: COLOR_SCHEMA10,
@@ -2966,10 +2974,32 @@ var EmailLayoutPropsSchema2 = zod.z.object({
2966
2974
  childrenIds: zod.z.array(zod.z.string()).optional().nullable()
2967
2975
  });
2968
2976
  var email_layout_props_schema_default = EmailLayoutPropsSchema2;
2977
+ function BooleanInput({ label, defaultValue, onChange }) {
2978
+ const [value, setValue] = React72.useState(defaultValue);
2979
+ React72.useEffect(() => {
2980
+ setValue(defaultValue);
2981
+ }, [defaultValue]);
2982
+ return /* @__PURE__ */ React72__default.default.createElement(
2983
+ material.FormControlLabel,
2984
+ {
2985
+ label,
2986
+ control: /* @__PURE__ */ React72__default.default.createElement(
2987
+ material.Switch,
2988
+ {
2989
+ checked: value,
2990
+ onChange: (_, checked) => {
2991
+ setValue(checked);
2992
+ onChange(checked);
2993
+ }
2994
+ }
2995
+ )
2996
+ }
2997
+ );
2998
+ }
2969
2999
 
2970
3000
  // src/app/inspector-drawer/configuration-panel/input-panels/email-layout-sidebar-panel.tsx
2971
3001
  function EmailLayoutSidebarFields({ data, setData }) {
2972
- var _a, _b, _c, _d, _e;
3002
+ var _a, _b, _c, _d, _e, _f;
2973
3003
  const [, setErrors] = React72.useState(null);
2974
3004
  const updateData = (d) => {
2975
3005
  const res = email_layout_props_schema_default.safeParse(d);
@@ -2980,25 +3010,33 @@ function EmailLayoutSidebarFields({ data, setData }) {
2980
3010
  setErrors(res.error);
2981
3011
  }
2982
3012
  };
3013
+ const backdropDisabled = (_a = data.backdropDisabled) != null ? _a : false;
2983
3014
  return /* @__PURE__ */ React72__default.default.createElement(BaseSidebarPanel, { title: "Global" }, /* @__PURE__ */ React72__default.default.createElement(
3015
+ BooleanInput,
3016
+ {
3017
+ label: "Disable backdrop",
3018
+ defaultValue: backdropDisabled,
3019
+ onChange: (backdropDisabled2) => updateData(__spreadProps(__spreadValues({}, data), { backdropDisabled: backdropDisabled2 }))
3020
+ }
3021
+ ), !backdropDisabled && /* @__PURE__ */ React72__default.default.createElement(React72__default.default.Fragment, null, /* @__PURE__ */ React72__default.default.createElement(
2984
3022
  ColorInput2,
2985
3023
  {
2986
3024
  label: "Backdrop color",
2987
- defaultValue: (_a = data.backdropColor) != null ? _a : "#F5F5F5",
3025
+ defaultValue: (_b = data.backdropColor) != null ? _b : "#F5F5F5",
2988
3026
  onChange: (backdropColor) => updateData(__spreadProps(__spreadValues({}, data), { backdropColor }))
2989
3027
  }
2990
3028
  ), /* @__PURE__ */ React72__default.default.createElement(
2991
3029
  ColorInput2,
2992
3030
  {
2993
3031
  label: "Canvas color",
2994
- defaultValue: (_b = data.canvasColor) != null ? _b : "#FFFFFF",
3032
+ defaultValue: (_c = data.canvasColor) != null ? _c : "#FFFFFF",
2995
3033
  onChange: (canvasColor) => updateData(__spreadProps(__spreadValues({}, data), { canvasColor }))
2996
3034
  }
2997
3035
  ), /* @__PURE__ */ React72__default.default.createElement(
2998
3036
  NullableColorInput,
2999
3037
  {
3000
3038
  label: "Canvas border color",
3001
- defaultValue: (_c = data.borderColor) != null ? _c : null,
3039
+ defaultValue: (_d = data.borderColor) != null ? _d : null,
3002
3040
  onChange: (borderColor) => updateData(__spreadProps(__spreadValues({}, data), { borderColor }))
3003
3041
  }
3004
3042
  ), /* @__PURE__ */ React72__default.default.createElement(
@@ -3011,10 +3049,10 @@ function EmailLayoutSidebarFields({ data, setData }) {
3011
3049
  min: 0,
3012
3050
  max: 48,
3013
3051
  label: "Canvas border radius",
3014
- defaultValue: (_d = data.borderRadius) != null ? _d : 0,
3052
+ defaultValue: (_e = data.borderRadius) != null ? _e : 0,
3015
3053
  onChange: (borderRadius) => updateData(__spreadProps(__spreadValues({}, data), { borderRadius }))
3016
3054
  }
3017
- ), /* @__PURE__ */ React72__default.default.createElement(
3055
+ )), /* @__PURE__ */ React72__default.default.createElement(
3018
3056
  NullableFontFamily,
3019
3057
  {
3020
3058
  label: "Font family",
@@ -3025,7 +3063,7 @@ function EmailLayoutSidebarFields({ data, setData }) {
3025
3063
  ColorInput2,
3026
3064
  {
3027
3065
  label: "Text color",
3028
- defaultValue: (_e = data.textColor) != null ? _e : "#262626",
3066
+ defaultValue: (_f = data.textColor) != null ? _f : "#262626",
3029
3067
  onChange: (textColor) => updateData(__spreadProps(__spreadValues({}, data), { textColor }))
3030
3068
  }
3031
3069
  ));
@@ -3351,30 +3389,6 @@ function SpacerSidebarPanel({ data, setData }) {
3351
3389
  }
3352
3390
  ));
3353
3391
  }
3354
- function BooleanInput({ label, defaultValue, onChange }) {
3355
- const [value, setValue] = React72.useState(defaultValue);
3356
- React72.useEffect(() => {
3357
- setValue(defaultValue);
3358
- }, [defaultValue]);
3359
- return /* @__PURE__ */ React72__default.default.createElement(
3360
- material.FormControlLabel,
3361
- {
3362
- label,
3363
- control: /* @__PURE__ */ React72__default.default.createElement(
3364
- material.Switch,
3365
- {
3366
- checked: value,
3367
- onChange: (_, checked) => {
3368
- setValue(checked);
3369
- onChange(checked);
3370
- }
3371
- }
3372
- )
3373
- }
3374
- );
3375
- }
3376
-
3377
- // src/app/inspector-drawer/configuration-panel/input-panels/text-sidebar-panel.tsx
3378
3392
  function TextSidebarPanel({ data, setData }) {
3379
3393
  var _a, _b, _c, _d;
3380
3394
  const [, setErrors] = React72.useState(null);
@@ -3861,7 +3875,7 @@ var BUTTONS = [
3861
3875
  block: () => ({
3862
3876
  type: "Text",
3863
3877
  data: {
3864
- props: { text: "My new text block" },
3878
+ props: { text: "My new text block", markdown: true },
3865
3879
  style: {
3866
3880
  padding: { top: 16, bottom: 16, left: 24, right: 24 },
3867
3881
  fontWeight: "normal"
@@ -3877,7 +3891,7 @@ var BUTTONS = [
3877
3891
  data: {
3878
3892
  props: {
3879
3893
  text: "Button",
3880
- url: "https://www.usewaypoint.com"
3894
+ url: "https://example.com"
3881
3895
  },
3882
3896
  style: { padding: { top: 16, bottom: 16, left: 24, right: 24 } }
3883
3897
  }
@@ -3890,7 +3904,7 @@ var BUTTONS = [
3890
3904
  type: "Image",
3891
3905
  data: {
3892
3906
  props: {
3893
- url: "https://assets.usewaypoint.com/sample-image.jpg",
3907
+ url: "https://placehold.co/600x400/EEE/999?text=Sample+Image",
3894
3908
  alt: "Sample product",
3895
3909
  contentAlignment: "middle",
3896
3910
  linkHref: null
@@ -4405,25 +4419,62 @@ function EmailLayoutEditor(props) {
4405
4419
  window.removeEventListener("paste", handlePaste);
4406
4420
  };
4407
4421
  }, [handleDelete, handleCopy, handlePaste]);
4422
+ const baseStyle = {
4423
+ color: (_b = props.textColor) != null ? _b : "#262626",
4424
+ fontFamily: getFontFamily7(props.fontFamily),
4425
+ fontSize: "16px",
4426
+ fontWeight: "400",
4427
+ letterSpacing: "0.15008px",
4428
+ lineHeight: "1.5",
4429
+ margin: "0"
4430
+ };
4431
+ const editorChildren = /* @__PURE__ */ React72__default.default.createElement(
4432
+ EditorChildrenIds,
4433
+ {
4434
+ childrenIds,
4435
+ onChange: ({ block, blockId, childrenIds: childrenIds2 }) => {
4436
+ setDocument({
4437
+ [blockId]: block,
4438
+ [currentBlockId]: {
4439
+ type: "EmailLayout",
4440
+ data: __spreadProps(__spreadValues({}, document2[currentBlockId].data), {
4441
+ childrenIds: childrenIds2
4442
+ })
4443
+ }
4444
+ });
4445
+ setSelectedBlockId(blockId);
4446
+ }
4447
+ }
4448
+ );
4449
+ if (props.backdropDisabled) {
4450
+ return /* @__PURE__ */ React72__default.default.createElement(
4451
+ "div",
4452
+ {
4453
+ onClick: () => {
4454
+ setSelectedBlockId(null);
4455
+ },
4456
+ style: __spreadProps(__spreadValues({}, baseStyle), {
4457
+ backgroundColor: "#F5F5F5",
4458
+ padding: "32px",
4459
+ width: "100%",
4460
+ minHeight: "100%"
4461
+ })
4462
+ },
4463
+ /* @__PURE__ */ React72__default.default.createElement("div", { style: { maxWidth: "600px" } }, editorChildren)
4464
+ );
4465
+ }
4408
4466
  return /* @__PURE__ */ React72__default.default.createElement(
4409
4467
  "div",
4410
4468
  {
4411
4469
  onClick: () => {
4412
4470
  setSelectedBlockId(null);
4413
4471
  },
4414
- style: {
4415
- backgroundColor: (_b = props.backdropColor) != null ? _b : "#F5F5F5",
4416
- color: (_c = props.textColor) != null ? _c : "#262626",
4417
- fontFamily: getFontFamily7(props.fontFamily),
4418
- fontSize: "16px",
4419
- fontWeight: "400",
4420
- letterSpacing: "0.15008px",
4421
- lineHeight: "1.5",
4422
- margin: "0",
4472
+ style: __spreadProps(__spreadValues({}, baseStyle), {
4473
+ backgroundColor: (_c = props.backdropColor) != null ? _c : "#F5F5F5",
4423
4474
  padding: "32px 0",
4424
4475
  width: "100%",
4425
4476
  minHeight: "100%"
4426
- }
4477
+ })
4427
4478
  },
4428
4479
  /* @__PURE__ */ React72__default.default.createElement(
4429
4480
  "table",
@@ -4435,6 +4486,7 @@ function EmailLayoutEditor(props) {
4435
4486
  maxWidth: "600px",
4436
4487
  backgroundColor: (_d = props.canvasColor) != null ? _d : "#FFFFFF",
4437
4488
  borderRadius: (_e = props.borderRadius) != null ? _e : void 0,
4489
+ overflow: props.borderRadius ? "hidden" : void 0,
4438
4490
  border: (() => {
4439
4491
  const v = props.borderColor;
4440
4492
  if (!v) {
@@ -4448,24 +4500,7 @@ function EmailLayoutEditor(props) {
4448
4500
  cellPadding: "0",
4449
4501
  border: 0
4450
4502
  },
4451
- /* @__PURE__ */ React72__default.default.createElement("tbody", null, /* @__PURE__ */ React72__default.default.createElement("tr", { style: { width: "100%" } }, /* @__PURE__ */ React72__default.default.createElement("td", null, /* @__PURE__ */ React72__default.default.createElement(
4452
- EditorChildrenIds,
4453
- {
4454
- childrenIds,
4455
- onChange: ({ block, blockId, childrenIds: childrenIds2 }) => {
4456
- setDocument({
4457
- [blockId]: block,
4458
- [currentBlockId]: {
4459
- type: "EmailLayout",
4460
- data: __spreadProps(__spreadValues({}, document2[currentBlockId].data), {
4461
- childrenIds: childrenIds2
4462
- })
4463
- }
4464
- });
4465
- setSelectedBlockId(blockId);
4466
- }
4467
- }
4468
- ))))
4503
+ /* @__PURE__ */ React72__default.default.createElement("tbody", null, /* @__PURE__ */ React72__default.default.createElement("tr", { style: { width: "100%" } }, /* @__PURE__ */ React72__default.default.createElement("td", null, editorChildren)))
4469
4504
  )
4470
4505
  );
4471
4506
  }
@@ -5338,7 +5373,7 @@ function TextEditor({ style, props }) {
5338
5373
  element.style.height = `${element.scrollHeight}px`;
5339
5374
  }
5340
5375
  };
5341
- if (isSelected && !isMarkdown) {
5376
+ if (isSelected) {
5342
5377
  return /* @__PURE__ */ React72__default.default.createElement(
5343
5378
  "textarea",
5344
5379
  {