easy-email-pro-theme 1.6.0 → 1.6.2

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/lib/index.js CHANGED
@@ -16329,7 +16329,10 @@ function ImageUploader(props) {
16329
16329
  const onChange = props.onChange;
16330
16330
  const onUpload = useCallback$1(() => {
16331
16331
  if (handleUploadClick) {
16332
- handleUploadClick({ onChange });
16332
+ handleUploadClick({
16333
+ onChange,
16334
+ accept: "image/jpg,image/png,image/jpeg,image/gif"
16335
+ });
16333
16336
  return;
16334
16337
  }
16335
16338
  if (isUploading) {
@@ -32506,14 +32509,67 @@ const getLinkNode = (editor) => {
32506
32509
  });
32507
32510
  return match2;
32508
32511
  };
32512
+ const PreventFocusWrapper = ({
32513
+ children
32514
+ }) => {
32515
+ return /* @__PURE__ */ React__default.createElement(
32516
+ "div",
32517
+ {
32518
+ style: { display: "flex", alignItems: "center" },
32519
+ onMouseDown: (e) => {
32520
+ e.preventDefault();
32521
+ }
32522
+ },
32523
+ children
32524
+ );
32525
+ };
32509
32526
  const TextLink = () => {
32510
32527
  const editor = useSlate();
32511
32528
  const linkNodeEntry = getLinkNode(editor);
32512
32529
  const ref2 = useRef(null);
32513
32530
  const linkNode = linkNodeEntry == null ? void 0 : linkNodeEntry[0];
32531
+ const { handleUploadClick, showSelectFileButton, onUpload } = useEditorProps();
32532
+ const [isUploading, setIsUploading] = useState(false);
32533
+ const uploadHandlerRef = useRef(onUpload);
32514
32534
  const [formState, setFormState] = useState(__spreadProps(__spreadValues({}, linkNode == null ? void 0 : linkNode.link), {
32515
32535
  text: (linkNode == null ? void 0 : linkNode.text) || ""
32516
32536
  }));
32537
+ const [from] = Form.useForm();
32538
+ const handleUpload = useCallback$1(
32539
+ (e) => {
32540
+ e.stopPropagation();
32541
+ e.preventDefault();
32542
+ if (handleUploadClick) {
32543
+ handleUploadClick({
32544
+ onChange: (url) => from.setFieldValue("href", url),
32545
+ accept: "*"
32546
+ });
32547
+ return;
32548
+ }
32549
+ if (isUploading) {
32550
+ return Message.warning("Uploading...");
32551
+ }
32552
+ if (!uploadHandlerRef.current)
32553
+ return;
32554
+ const uploader = new Uploader(uploadHandlerRef.current, {
32555
+ limit: 1,
32556
+ accept: "*"
32557
+ });
32558
+ uploader.on("start", (photos) => {
32559
+ setIsUploading(true);
32560
+ uploader.on("end", (data) => __async(void 0, null, function* () {
32561
+ var _a2;
32562
+ const url = (_a2 = data[0]) == null ? void 0 : _a2.url;
32563
+ if (url) {
32564
+ from.setFieldValue("href", url);
32565
+ }
32566
+ setIsUploading(false);
32567
+ }));
32568
+ });
32569
+ uploader.chooseFile();
32570
+ },
32571
+ [from, handleUploadClick, isUploading]
32572
+ );
32517
32573
  useEffect(() => {
32518
32574
  setFormState(__spreadProps(__spreadValues({}, linkNode == null ? void 0 : linkNode.link), { text: (linkNode == null ? void 0 : linkNode.text) || "" }));
32519
32575
  }, [linkNode == null ? void 0 : linkNode.link, linkNode == null ? void 0 : linkNode.text]);
@@ -32545,7 +32601,6 @@ const TextLink = () => {
32545
32601
  const onChange = (values2) => {
32546
32602
  setFormState(values2);
32547
32603
  };
32548
- const [from] = Form.useForm();
32549
32604
  return /* @__PURE__ */ React__default.createElement(
32550
32605
  Popover,
32551
32606
  {
@@ -32598,7 +32653,16 @@ const TextLink = () => {
32598
32653
  padding: 10
32599
32654
  }
32600
32655
  },
32601
- /* @__PURE__ */ React__default.createElement(Grid.Row, { justify: "end" }, /* @__PURE__ */ React__default.createElement(Space, null, linkNode && /* @__PURE__ */ React__default.createElement(
32656
+ /* @__PURE__ */ React__default.createElement(Grid.Row, { justify: "space-between" }, /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, showSelectFileButton && /* @__PURE__ */ React__default.createElement(
32657
+ Button$1,
32658
+ {
32659
+ style: { width: "100%" },
32660
+ type: "outline",
32661
+ status: "danger",
32662
+ onClick: handleUpload
32663
+ },
32664
+ t(`Select File`)
32665
+ )), /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(Space, null, linkNode && /* @__PURE__ */ React__default.createElement(
32602
32666
  Button$1,
32603
32667
  {
32604
32668
  style: { width: "100%" },
@@ -32614,7 +32678,7 @@ const TextLink = () => {
32614
32678
  type: "primary"
32615
32679
  },
32616
32680
  "Apply"
32617
- )))
32681
+ ))))
32618
32682
  ))
32619
32683
  },
32620
32684
  /* @__PURE__ */ React__default.createElement(
@@ -32738,6 +32802,8 @@ const MergeTagComponent = React__default.memo((props) => {
32738
32802
  return;
32739
32803
  const onKeyDown = (ev) => {
32740
32804
  var _a2, _b;
32805
+ if (!ev.code)
32806
+ return;
32741
32807
  if (ev.code.toLowerCase() === "enter" && ((_a2 = ref2.current) == null ? void 0 : _a2.contains(document.activeElement))) {
32742
32808
  if (document.activeElement instanceof HTMLElement) {
32743
32809
  ev.preventDefault();
@@ -33004,54 +33070,54 @@ const RichTextBar = ({ list }) => {
33004
33070
  );
33005
33071
  const content = useMemo$1(() => {
33006
33072
  const toolsMapping = {
33007
- [TextFormat.TURN_INTO]: /* @__PURE__ */ React__default.createElement(TurnInto, null),
33008
- [TextFormat.FONT_SIZE]: /* @__PURE__ */ React__default.createElement(FontSize, null),
33009
- [TextFormat.FONT_FAMILY]: /* @__PURE__ */ React__default.createElement(FontFamily, null),
33073
+ [TextFormat.TURN_INTO]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(TurnInto, null)),
33074
+ [TextFormat.FONT_SIZE]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(FontSize, null)),
33075
+ [TextFormat.FONT_FAMILY]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(FontFamily, null)),
33010
33076
  [TextFormat.LINK]: /* @__PURE__ */ React__default.createElement(TextLink, null),
33011
- [TextFormat.BOLD]: /* @__PURE__ */ React__default.createElement(
33077
+ [TextFormat.BOLD]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(
33012
33078
  FormatButton,
33013
33079
  {
33014
33080
  title: t("Bold"),
33015
33081
  format: TextFormat.BOLD,
33016
33082
  icon: "icon-bold"
33017
33083
  }
33018
- ),
33019
- [TextFormat.ITALIC]: /* @__PURE__ */ React__default.createElement(
33084
+ )),
33085
+ [TextFormat.ITALIC]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(
33020
33086
  FormatButton,
33021
33087
  {
33022
33088
  title: t("Italic"),
33023
33089
  format: TextFormat.ITALIC,
33024
33090
  icon: "icon-italic"
33025
33091
  }
33026
- ),
33027
- [TextFormat.UNDERLINE]: /* @__PURE__ */ React__default.createElement(
33092
+ )),
33093
+ [TextFormat.UNDERLINE]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(
33028
33094
  FormatButton,
33029
33095
  {
33030
33096
  title: t("Underline"),
33031
33097
  format: TextFormat.UNDERLINE,
33032
33098
  icon: "icon-underline"
33033
33099
  }
33034
- ),
33035
- [TextFormat.STRIKETHROUGH]: /* @__PURE__ */ React__default.createElement(
33100
+ )),
33101
+ [TextFormat.STRIKETHROUGH]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(
33036
33102
  FormatButton,
33037
33103
  {
33038
33104
  title: t("Strikethrough"),
33039
33105
  format: TextFormat.STRIKETHROUGH,
33040
33106
  icon: "icon-strikethrough"
33041
33107
  }
33042
- ),
33043
- [TextFormat.TEXT_COLOR]: /* @__PURE__ */ React__default.createElement(FontColor, null),
33044
- [TextFormat.BACKGROUND_COLOR]: /* @__PURE__ */ React__default.createElement(BgColor, null),
33045
- [TextFormat.MERGETAG]: mergetags && !mergetagNode && /* @__PURE__ */ React__default.createElement(MergeTag, null),
33046
- [TextFormat.ALIGN]: /* @__PURE__ */ React__default.createElement(TextAlign, null),
33047
- [TextFormat.REMOVE_FORMAT]: /* @__PURE__ */ React__default.createElement(
33108
+ )),
33109
+ [TextFormat.TEXT_COLOR]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(FontColor, null)),
33110
+ [TextFormat.BACKGROUND_COLOR]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(BgColor, null)),
33111
+ [TextFormat.MERGETAG]: mergetags && !mergetagNode && /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(MergeTag, null)),
33112
+ [TextFormat.ALIGN]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(TextAlign, null)),
33113
+ [TextFormat.REMOVE_FORMAT]: /* @__PURE__ */ React__default.createElement(PreventFocusWrapper, null, /* @__PURE__ */ React__default.createElement(
33048
33114
  FormatButton,
33049
33115
  {
33050
33116
  title: t("Remove format"),
33051
33117
  format: TextFormat.REMOVE_FORMAT,
33052
33118
  icon: "icon-remove"
33053
33119
  }
33054
- )
33120
+ ))
33055
33121
  };
33056
33122
  return list.map((key2, index2) => {
33057
33123
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: key2 + index2 }, toolsMapping[key2]);
@@ -33181,10 +33247,7 @@ const HoveringToolbar = () => {
33181
33247
  ref: ref2,
33182
33248
  key: String(isNotSelect),
33183
33249
  id: "HoveringToolbar",
33184
- className: "HoveringToolbar RichTextBar",
33185
- onMouseDown: (e) => {
33186
- e.preventDefault();
33187
- }
33250
+ className: "HoveringToolbar RichTextBar"
33188
33251
  },
33189
33252
  /* @__PURE__ */ React__default.createElement("div", { className: "HoveringToolbarWrapper" }, hoveringToolbar == null ? void 0 : hoveringToolbar.prefix, /* @__PURE__ */ React__default.createElement(RichTextBar, { list }), hoveringToolbar == null ? void 0 : hoveringToolbar.subfix),
33190
33253
  /* @__PURE__ */ React__default.createElement("style", null, styleText$c)
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export declare const PreventFocusWrapper: ({ children, }: {
3
+ children: React.ReactNode;
4
+ }) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-email-pro-theme",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "",
5
5
  "files": [
6
6
  "lib"