@go-mailer/easy-email-extensions 5.0.1 → 5.0.3

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,4 +1,6 @@
1
1
  import React from 'react';
2
- export declare function Heading(props: {
3
- onChange: (val: string) => void;
4
- }): React.JSX.Element;
2
+ export interface HeadingProps {
3
+ execCommand: (cmd: string, value: any) => void;
4
+ getPopupContainer: () => HTMLElement;
5
+ }
6
+ export declare function Heading(props: HeadingProps): React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface FontFamilyProps {
3
+ execCommand: (cmd: string, value: any) => void;
4
+ getPopupContainer: () => HTMLElement;
5
+ }
6
+ export declare function Personalization(props: FontFamilyProps): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export declare function usePersonalization(): {
3
+ personalizations: {
4
+ value: string;
5
+ label: React.JSX.Element;
6
+ }[];
7
+ };
package/lib/index2.js CHANGED
@@ -38066,6 +38066,79 @@ function Link$1(props) {
38066
38066
  }));
38067
38067
  });
38068
38068
  }
38069
+ function Heading(props) {
38070
+ const list2 = [
38071
+ {
38072
+ value: "H1",
38073
+ label: "Heading 1"
38074
+ },
38075
+ {
38076
+ value: "H2",
38077
+ label: "Heading 2"
38078
+ },
38079
+ {
38080
+ value: "H3",
38081
+ label: "Heading 3"
38082
+ },
38083
+ {
38084
+ value: "H4",
38085
+ label: "Heading 4"
38086
+ },
38087
+ {
38088
+ value: "H5",
38089
+ label: "Heading 5"
38090
+ },
38091
+ {
38092
+ value: "H6",
38093
+ label: "Heading 6"
38094
+ },
38095
+ {
38096
+ value: "P",
38097
+ label: t("Paragraph")
38098
+ }
38099
+ ];
38100
+ const { execCommand } = props;
38101
+ const [visible, setVisible] = React__default.useState(false);
38102
+ const onChange = useCallback(
38103
+ (val) => {
38104
+ execCommand("formatBlock", val);
38105
+ setVisible(false);
38106
+ },
38107
+ [execCommand]
38108
+ );
38109
+ const onVisibleChange = useCallback((v2) => {
38110
+ setVisible(v2);
38111
+ }, []);
38112
+ return /* @__PURE__ */ React__default.createElement(Popover$1, {
38113
+ trigger: "click",
38114
+ color: "#fff",
38115
+ position: "left",
38116
+ className: "easy-email-extensions-Tools-Popover",
38117
+ popupVisible: visible,
38118
+ onVisibleChange,
38119
+ content: /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", {
38120
+ style: {
38121
+ maxWidth: 200,
38122
+ maxHeight: 350,
38123
+ overflowY: "auto",
38124
+ overflowX: "hidden"
38125
+ }
38126
+ }, /* @__PURE__ */ React__default.createElement(Menu$1, {
38127
+ onClickMenuItem: onChange,
38128
+ selectedKeys: [],
38129
+ style: { border: "none" }
38130
+ }, list2.map((item2) => /* @__PURE__ */ React__default.createElement(Menu$1.Item, {
38131
+ style: { lineHeight: "30px", height: 30 },
38132
+ key: item2.value
38133
+ }, item2.label))))),
38134
+ getPopupContainer: props.getPopupContainer
38135
+ }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38136
+ title: t("Heading"),
38137
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38138
+ iconName: "icon-heading"
38139
+ })
38140
+ }));
38141
+ }
38069
38142
  function useFontFamily() {
38070
38143
  const { fontList: defaultFontList } = useEditorProps();
38071
38144
  const { pageData: pageData2 } = useEditorContext();
@@ -42580,6 +42653,75 @@ function FontSize(props) {
42580
42653
  })
42581
42654
  }));
42582
42655
  }
42656
+ function usePersonalization() {
42657
+ const { personalizations: defaultPersonalizations } = useEditorProps();
42658
+ const { pageData: pageData2 } = useEditorContext();
42659
+ const personalizationsOptions = pageData2.data.value.personalization;
42660
+ const personalizations = useMemo(() => {
42661
+ const placeholders = [];
42662
+ if (defaultPersonalizations) {
42663
+ placeholders.push(...defaultPersonalizations);
42664
+ }
42665
+ if (personalizationsOptions) {
42666
+ const options2 = personalizationsOptions.map((item2) => ({
42667
+ value: item2.value,
42668
+ label: item2.label
42669
+ }));
42670
+ placeholders.unshift(...options2);
42671
+ }
42672
+ return placeholders.map((item2) => ({
42673
+ value: item2.value,
42674
+ label: /* @__PURE__ */ React__default.createElement("span", null, item2.label)
42675
+ }));
42676
+ }, [personalizationsOptions, defaultPersonalizations]);
42677
+ return {
42678
+ personalizations
42679
+ };
42680
+ }
42681
+ function Personalization(props) {
42682
+ const { personalizations } = usePersonalization();
42683
+ const { execCommand } = props;
42684
+ const [visible, setVisible] = React__default.useState(false);
42685
+ const onChange = useCallback(
42686
+ (val) => {
42687
+ execCommand("insertText", val);
42688
+ setVisible(false);
42689
+ },
42690
+ [execCommand]
42691
+ );
42692
+ const onVisibleChange = useCallback((v2) => {
42693
+ setVisible(v2);
42694
+ }, []);
42695
+ return /* @__PURE__ */ React__default.createElement(Popover$1, {
42696
+ trigger: "click",
42697
+ color: "#fff",
42698
+ position: "left",
42699
+ className: "easy-email-extensions-Tools-Popover",
42700
+ popupVisible: visible,
42701
+ onVisibleChange,
42702
+ content: /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("style", null, styleText$2), /* @__PURE__ */ React__default.createElement("div", {
42703
+ style: {
42704
+ maxWidth: 200,
42705
+ maxHeight: 350,
42706
+ overflowY: "auto",
42707
+ overflowX: "hidden"
42708
+ }
42709
+ }, /* @__PURE__ */ React__default.createElement(Menu$1, {
42710
+ onClickMenuItem: onChange,
42711
+ selectedKeys: [],
42712
+ style: { border: "none", padding: 0 }
42713
+ }, personalizations.map((item2) => /* @__PURE__ */ React__default.createElement(Menu$1.Item, {
42714
+ style: { lineHeight: "30px", height: 30 },
42715
+ key: item2.value
42716
+ }, item2.label))))),
42717
+ getPopupContainer: props.getPopupContainer
42718
+ }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
42719
+ title: t("Add Message Personalization"),
42720
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
42721
+ iconName: "icon-personalization"
42722
+ })
42723
+ }));
42724
+ }
42583
42725
  function Tools(props) {
42584
42726
  var _a2, _b2;
42585
42727
  const { mergeTags: mergeTags2, enabledMergeTagsBadge, toolbar } = useEditorProps();
@@ -42658,6 +42800,7 @@ function Tools(props) {
42658
42800
  const getPopoverMountNode = () => document.getElementById(FIXED_CONTAINER_ID);
42659
42801
  const enabledTools = (_a2 = toolbar == null ? void 0 : toolbar.tools) != null ? _a2 : [
42660
42802
  AvailableTools.MergeTags,
42803
+ AvailableTools.Heading,
42661
42804
  AvailableTools.FontFamily,
42662
42805
  AvailableTools.FontSize,
42663
42806
  AvailableTools.Bold,
@@ -42669,6 +42812,7 @@ function Tools(props) {
42669
42812
  AvailableTools.Link,
42670
42813
  AvailableTools.Justify,
42671
42814
  AvailableTools.Lists,
42815
+ AvailableTools.Personalization,
42672
42816
  AvailableTools.HorizontalRule,
42673
42817
  AvailableTools.RemoveFormat
42674
42818
  ];
@@ -42684,6 +42828,14 @@ function Tools(props) {
42684
42828
  getPopupContainer: getPopoverMountNode
42685
42829
  })
42686
42830
  ];
42831
+ case AvailableTools.Heading:
42832
+ return [
42833
+ /* @__PURE__ */ React__default.createElement(Heading, {
42834
+ key: tool,
42835
+ execCommand,
42836
+ getPopupContainer: getPopoverMountNode
42837
+ })
42838
+ ];
42687
42839
  case AvailableTools.FontFamily:
42688
42840
  return [
42689
42841
  /* @__PURE__ */ React__default.createElement(FontFamily$1, {
@@ -42819,6 +42971,14 @@ function Tools(props) {
42819
42971
  title: t("Line")
42820
42972
  })
42821
42973
  ];
42974
+ case AvailableTools.Personalization:
42975
+ return [
42976
+ /* @__PURE__ */ React__default.createElement(Personalization, {
42977
+ key: tool,
42978
+ execCommand,
42979
+ getPopupContainer: getPopoverMountNode
42980
+ })
42981
+ ];
42822
42982
  case AvailableTools.RemoveFormat:
42823
42983
  return [
42824
42984
  /* @__PURE__ */ React__default.createElement(ToolItem$1, {