easy-email-pro-theme 1.8.4 → 1.10.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.
Files changed (2) hide show
  1. package/lib/index.js +28 -14
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -860,6 +860,12 @@ const getNodePathName = (path2, name) => {
860
860
  return path2.join(".children.");
861
861
  return path2.join(".children.") + "." + name;
862
862
  };
863
+ const unauthorizedHtml = `<div style="position: fixed;z-index: 9999999999;bottom: 40px;right: 40px;background-color: #ffffff;width: 320px;padding: 20px;box-sizing: border-box;box-shadow: 1px 1px 5px 0px #ccc;">
864
+ <div style="font-weight:bold">Authorization Terminated</div>
865
+ <div>We regret to inform you that your authorization has been terminated.</div>
866
+ <div>Please contact us: <a target="_blank" style="font-weight: bold;color: rgb(0, 120, 212);cursor:pointer;" href="mailto:ch.mao@qq.com">ch.mao@qq.com</a></div>
867
+
868
+ </div>`;
863
869
  const EditorContext = createContext({});
864
870
  const getInited = (editor) => {
865
871
  let inited = false;
@@ -884,6 +890,7 @@ const EditorContextProvider = (props) => {
884
890
  const mergetagsDataRef = useRefState(mergetagsData);
885
891
  const [inited, setInited] = useState(false);
886
892
  const [hasAuth, setHasAuth] = useState(false);
893
+ const [isUnauthorized, setIsUnauthorized] = useState(false);
887
894
  useEffect(() => {
888
895
  if (isEqual$3(props.mergetagsData, mergetagsDataRef.current))
889
896
  return;
@@ -893,16 +900,16 @@ const EditorContextProvider = (props) => {
893
900
  useEffect(() => {
894
901
  EditorCore.auth(props.clientId).then(() => {
895
902
  setHasAuth(true);
896
- }).catch(() => {
897
- const errorMessage = `<div style="position: fixed;z-index: 9999999999;bottom: 40px;right: 40px;background-color: #ffffff;width: 320px;padding: 20px;box-sizing: border-box;box-shadow: 1px 1px 5px 0px #ccc;">
898
- <div style="font-weight:bold">Authorization Terminated</div>
899
- <div>We regret to inform you that your authorization has been terminated.</div>
900
- <div>Please contact us: <a target="_blank" style="font-weight: bold;color: rgb(0, 120, 212);cursor:pointer;" href="mailto:962491243@qq.com">962491243@qq.com</a></div>
901
-
902
- </div>`;
903
- const div = document.createElement("div");
904
- div.innerHTML = errorMessage;
905
- document.body.appendChild(div);
903
+ }).catch((error2) => {
904
+ const status = get(error2, "response.status");
905
+ if (status === 401) {
906
+ setIsUnauthorized(true);
907
+ } else {
908
+ const errorMessage = unauthorizedHtml;
909
+ const div = document.createElement("div");
910
+ div.innerHTML = errorMessage;
911
+ document.body.appendChild(div);
912
+ }
906
913
  });
907
914
  }, [props.clientId]);
908
915
  useEffect(() => {
@@ -1057,7 +1064,8 @@ const EditorContextProvider = (props) => {
1057
1064
  valid,
1058
1065
  reset,
1059
1066
  getFieldValue,
1060
- submit
1067
+ submit,
1068
+ hasAuth
1061
1069
  };
1062
1070
  }, [
1063
1071
  adapterValues,
@@ -1069,11 +1077,15 @@ const EditorContextProvider = (props) => {
1069
1077
  valid,
1070
1078
  reset,
1071
1079
  getFieldValue,
1072
- submit
1080
+ submit,
1081
+ hasAuth
1073
1082
  ]);
1074
1083
  return useMemo$1(() => {
1084
+ if (isUnauthorized) {
1085
+ return /* @__PURE__ */ React__default.createElement("div", { dangerouslySetInnerHTML: { __html: unauthorizedHtml } });
1086
+ }
1075
1087
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(EditorContext.Provider, { value: data }, props.children));
1076
- }, [data, props.children]);
1088
+ }, [data, isUnauthorized, props.children]);
1077
1089
  };
1078
1090
  const FormProvider = ({ children }) => {
1079
1091
  const props = useEditorProps();
@@ -33268,7 +33280,9 @@ const HoveringToolbar = () => {
33268
33280
  } = layout;
33269
33281
  el.style.opacity = "1";
33270
33282
  el.style.top = `${isTopEnough ? pageYOffset - overlayRect.height - 10 : pageYOffset + relativedElementReact.height + 10}px`;
33271
- el.style.left = `${rect.left + iframeRect.left - 30}px`;
33283
+ const left = iframeRect.left + rect.left + overlayRect.width;
33284
+ const offsetLeft = document.documentElement.clientWidth - left;
33285
+ el.style.left = offsetLeft > 0 ? `${rect.left + iframeRect.left - 30}px` : `${rect.left + iframeRect.left + offsetLeft - 30}px`;
33272
33286
  } catch (error2) {
33273
33287
  }
33274
33288
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-email-pro-theme",
3
- "version": "1.8.4",
3
+ "version": "1.10.0",
4
4
  "description": "",
5
5
  "files": [
6
6
  "lib"