easy-email-extensions 3.0.8 → 3.0.9

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.
@@ -3,6 +3,5 @@ export interface InlineTextProps {
3
3
  idx: string;
4
4
  children?: React.ReactNode;
5
5
  onChange: (content: string) => void;
6
- mutators: Record<string, (...args: any[]) => any>;
7
6
  }
8
- export declare function InlineText({ idx, onChange, children, mutators: { setFieldTouched }, }: InlineTextProps): JSX.Element | null;
7
+ export declare function InlineText({ idx, onChange, children }: InlineTextProps): JSX.Element | null;
@@ -0,0 +1 @@
1
+ export declare function RenderCount(): JSX.Element;
package/lib/index2.js CHANGED
@@ -58,7 +58,7 @@ import React__default, { useCallback, useState, useRef, useEffect, useMemo, Chil
58
58
  import { IconFont, Stack as Stack$6, TextStyle, getBlockNodeByIdx, useBlock, getEditNode, getShadowRoot, FIXED_CONTAINER_ID, getEditContent, getEditorRoot, useEditorProps, useFocusIdx, useActiveTab, scrollBlockEleIntoView, useEditorContext, useHoverIdx, DATA_ATTRIBUTE_DROP_CONTAINER, BlockAvatarWrapper, ActiveTabKeys } from "easy-email-editor";
59
59
  import { BasicType, ImageManager, getIndexByIdx, getSiblingIdx, BlockManager, getPageIdx, getChildIdx, createBlockDataByType, getParentByIdx, getValueByIdx, MjmlToJson, JsonToMjml, getParentIdx, getNodeTypeFromClassName } from "easy-email-core";
60
60
  import { ReactSortable } from "react-sortablejs";
61
- import { useField, useForm as useForm$1, Form as Form$3, version as version$2 } from "react-final-form";
61
+ import { useField, Field, useForm as useForm$1, Form as Form$3, version as version$2, useFormState } from "react-final-form";
62
62
  import ReactDOM, { findDOMNode, createPortal } from "react-dom";
63
63
  var arco = "";
64
64
  const title = "_title_1gyaq_1";
@@ -38484,75 +38484,76 @@ function enhancer(Component2, changeAdapter) {
38484
38484
  "debounceTime"
38485
38485
  ]);
38486
38486
  const {
38487
- input: { value, onBlur: onBlur3 },
38488
- meta: { touched, error: error2 }
38487
+ input: { value, onChange }
38489
38488
  } = useField(name, {
38490
38489
  validate: validate3
38491
38490
  });
38492
38491
  const [currentValue, setCurrentValue] = useState(value);
38493
- const id = useMemo(() => {
38494
- return `enhancer-${primaryId++}`;
38495
- }, []);
38496
- const { change, mutators } = useForm$1();
38497
38492
  const debounceCallbackChange = useCallback(lodash.exports.debounce((val) => {
38498
- change(name, val);
38499
- }, 60, {
38500
- maxWait: 60
38501
- }), [change, name]);
38493
+ onChange(val);
38494
+ }, 100, {
38495
+ maxWait: 500
38496
+ }), []);
38502
38497
  useEffect(() => {
38503
38498
  setCurrentValue(value);
38504
38499
  }, [value]);
38505
- const onFieldChange = useCallback((e) => {
38506
- const newVal = onChangeAdapter ? onChangeAdapter(changeAdapter(e)) : changeAdapter(e);
38507
- setCurrentValue(newVal);
38508
- debounceCallbackChange(newVal);
38509
- onBlur3();
38510
- }, [onBlur3, onChangeAdapter, debounceCallbackChange]);
38511
- if (!wrapper2)
38512
- return /* @__PURE__ */ React__default.createElement(Component2, __spreadProps(__spreadValues({}, rest), {
38513
- mutators,
38500
+ const id = useMemo(() => {
38501
+ return `enhancer-${primaryId++}`;
38502
+ }, []);
38503
+ return /* @__PURE__ */ React__default.createElement(Field, {
38504
+ name,
38505
+ validate: validate3
38506
+ }, ({ input: { onBlur: onBlur3 }, meta: { touched, error: error2 } }) => {
38507
+ const onFieldChange = useCallback((e) => {
38508
+ const newVal = onChangeAdapter ? onChangeAdapter(changeAdapter(e)) : changeAdapter(e);
38509
+ setCurrentValue(newVal);
38510
+ debounceCallbackChange(newVal);
38511
+ onBlur3();
38512
+ }, [onBlur3, onChangeAdapter, debounceCallbackChange]);
38513
+ if (!wrapper2)
38514
+ return /* @__PURE__ */ React__default.createElement(Component2, __spreadProps(__spreadValues({}, rest), {
38515
+ id,
38516
+ name,
38517
+ checked: valueAdapter ? valueAdapter(currentValue) : currentValue,
38518
+ value: valueAdapter ? valueAdapter(currentValue) : currentValue,
38519
+ onChange: onFieldChange
38520
+ }));
38521
+ return /* @__PURE__ */ React__default.createElement(Form.Item, {
38522
+ noStyle: true,
38523
+ validateStatus: touched && error2 ? "error" : void 0,
38524
+ help: touched && error2
38525
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
38526
+ vertical: true,
38527
+ spacing: "extraTight"
38528
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
38529
+ spacing: inline ? void 0 : "extraTight",
38530
+ wrap: false,
38531
+ vertical: !inline,
38532
+ alignment: alignment ? alignment : inline ? "center" : void 0,
38533
+ distribution
38534
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, null, /* @__PURE__ */ React__default.createElement("label", {
38535
+ className: labelHidden2 ? styles$5["label-hidden"] : void 0,
38536
+ htmlFor: id
38537
+ }, /* @__PURE__ */ React__default.createElement("span", {
38538
+ style: { whiteSpace: "pre" }
38539
+ }, required && /* @__PURE__ */ React__default.createElement("span", {
38540
+ style: { color: "#ff4d4f" }
38541
+ }, "* "), /* @__PURE__ */ React__default.createElement(TextStyle, {
38542
+ size: size === "small" ? "smallest" : "small"
38543
+ }, label)))), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
38544
+ fill: inline
38545
+ }, /* @__PURE__ */ React__default.createElement(Component2, __spreadProps(__spreadValues({
38546
+ size
38547
+ }, rest), {
38514
38548
  id,
38515
38549
  name,
38516
38550
  checked: valueAdapter ? valueAdapter(currentValue) : currentValue,
38517
38551
  value: valueAdapter ? valueAdapter(currentValue) : currentValue,
38518
38552
  onChange: onFieldChange
38519
- }));
38520
- return /* @__PURE__ */ React__default.createElement(Form.Item, {
38521
- noStyle: true,
38522
- validateStatus: touched && error2 ? "error" : void 0,
38523
- help: touched && error2
38524
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
38525
- vertical: true,
38526
- spacing: "extraTight"
38527
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
38528
- spacing: inline ? void 0 : "extraTight",
38529
- wrap: false,
38530
- vertical: !inline,
38531
- alignment: alignment ? alignment : inline ? "center" : void 0,
38532
- distribution
38533
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, null, /* @__PURE__ */ React__default.createElement("label", {
38534
- className: labelHidden2 ? styles$5["label-hidden"] : void 0,
38535
- htmlFor: id
38536
- }, /* @__PURE__ */ React__default.createElement("span", {
38537
- style: { whiteSpace: "pre" }
38538
- }, required && /* @__PURE__ */ React__default.createElement("span", {
38539
- style: { color: "#ff4d4f" }
38540
- }, "* "), /* @__PURE__ */ React__default.createElement(TextStyle, {
38541
- size: size === "small" ? "smallest" : "small"
38542
- }, label)))), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
38543
- fill: inline
38544
- }, /* @__PURE__ */ React__default.createElement(Component2, __spreadProps(__spreadValues({
38545
- size
38546
- }, rest), {
38547
- mutators,
38548
- id,
38549
- name,
38550
- checked: valueAdapter ? valueAdapter(currentValue) : currentValue,
38551
- value: valueAdapter ? valueAdapter(currentValue) : currentValue,
38552
- onChange: onFieldChange
38553
- })))), /* @__PURE__ */ React__default.createElement("div", {
38554
- className: styles$5.helperText
38555
- }, /* @__PURE__ */ React__default.createElement("small", null, helpText))));
38553
+ })))), /* @__PURE__ */ React__default.createElement("div", {
38554
+ className: styles$5.helperText
38555
+ }, /* @__PURE__ */ React__default.createElement("small", null, helpText))));
38556
+ });
38556
38557
  };
38557
38558
  }
38558
38559
  function Input(props) {
@@ -38650,12 +38651,10 @@ function awaitForElement$1(idx) {
38650
38651
  });
38651
38652
  return promiseObj;
38652
38653
  }
38653
- function InlineText({
38654
- idx,
38655
- onChange,
38656
- children,
38657
- mutators: { setFieldTouched }
38658
- }) {
38654
+ function InlineText({ idx, onChange, children }) {
38655
+ const {
38656
+ mutators: { setFieldTouched }
38657
+ } = useForm$1();
38659
38658
  const [isFocus, setIsFocus] = useState(false);
38660
38659
  const [textContainer, setTextContainer] = useState(null);
38661
38660
  useField(idx);
@@ -39983,32 +39982,39 @@ function Page() {
39983
39982
  }
39984
39983
  function Padding(props = {}) {
39985
39984
  const { title: title2 = "Padding", attributeName = "padding" } = props;
39986
- const { focusBlock: focusBlock2 } = useBlock();
39985
+ const { focusBlock: focusBlock2, change } = useBlock();
39987
39986
  const { focusIdx: focusIdx2 } = useFocusIdx();
39988
- const defaultConfig = useMemo(() => focusBlock2 && createBlockDataByType(focusBlock2.type), [focusBlock2]);
39989
- const getVal = useCallback((index2) => {
39990
- return () => {
39991
- var _a, _b;
39992
- return ((_a = focusBlock2 == null ? void 0 : focusBlock2.attributes[attributeName]) == null ? void 0 : _a.split(" ")[index2]) || ((_b = defaultConfig == null ? void 0 : defaultConfig.attributes[attributeName]) == null ? void 0 : _b.split(" ")[index2]);
39993
- };
39994
- }, [attributeName, defaultConfig == null ? void 0 : defaultConfig.attributes, focusBlock2 == null ? void 0 : focusBlock2.attributes]);
39995
- const setVal = useCallback((index2) => {
39996
- return (newVal) => {
39997
- if (newVal === "") {
39998
- newVal = "0px";
39999
- }
40000
- const vals = [
40001
- getVal(0)(),
40002
- getVal(1)(),
40003
- getVal(2)(),
40004
- getVal(3)()
40005
- ];
40006
- vals[index2] = newVal;
40007
- return vals.join(" ");
39987
+ const type = focusBlock2 && focusBlock2.type;
39988
+ const defaultConfig = useMemo(() => type ? createBlockDataByType(type) : void 0, [type]);
39989
+ const paddingValue = focusBlock2 == null ? void 0 : focusBlock2.attributes[attributeName];
39990
+ const defaultPaddingValue = defaultConfig == null ? void 0 : defaultConfig.attributes[attributeName];
39991
+ const paddingList = paddingValue == null ? void 0 : paddingValue.split(" ");
39992
+ const defaultPaddingList = defaultPaddingValue == null ? void 0 : defaultPaddingValue.split(" ");
39993
+ const paddingFormValues = useMemo(() => {
39994
+ const paddingList2 = paddingValue == null ? void 0 : paddingValue.split(" ");
39995
+ const defaultPaddingList2 = defaultPaddingValue == null ? void 0 : defaultPaddingValue.split(" ");
39996
+ const top = paddingList2 ? paddingList2[0] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[0]) || "";
39997
+ const right = paddingList2 ? paddingList2[1] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[1]) || "";
39998
+ const bottom = paddingList2 ? paddingList2[2] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[2]) || "";
39999
+ const left = paddingList2 ? paddingList2[3] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[3]) || "";
40000
+ return {
40001
+ top,
40002
+ left,
40003
+ bottom,
40004
+ right
40008
40005
  };
40009
- }, [getVal]);
40010
- return useMemo(() => {
40011
- return /* @__PURE__ */ React__default.createElement(Stack$6, {
40006
+ }, [paddingList, defaultPaddingList]);
40007
+ const onChancePadding = useCallback((val) => {
40008
+ change(focusIdx2 + `.attributes[${attributeName}]`, val);
40009
+ }, [focusIdx2, attributeName]);
40010
+ return /* @__PURE__ */ React__default.createElement(Form$3, {
40011
+ initialValues: paddingFormValues,
40012
+ subscription: { submitting: true, pristine: true },
40013
+ enableReinitialize: true,
40014
+ onSubmit: () => {
40015
+ }
40016
+ }, () => {
40017
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Stack$6, {
40012
40018
  vertical: true,
40013
40019
  spacing: "extraTight"
40014
40020
  }, /* @__PURE__ */ React__default.createElement(TextStyle, {
@@ -40020,18 +40026,14 @@ function Padding(props = {}) {
40020
40026
  }, /* @__PURE__ */ React__default.createElement(TextField, {
40021
40027
  label: /* @__PURE__ */ React__default.createElement("span", null, "Top\xA0"),
40022
40028
  quickchange: true,
40023
- name: `${focusIdx2}.attributes.${attributeName}`,
40024
- valueAdapter: getVal(0),
40025
- onChangeAdapter: setVal(0),
40029
+ name: "top",
40026
40030
  inline: true
40027
40031
  })), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40028
40032
  fill: true
40029
40033
  }, /* @__PURE__ */ React__default.createElement(TextField, {
40030
40034
  label: "Bottom",
40031
40035
  quickchange: true,
40032
- name: `${focusIdx2}.attributes.${attributeName}`,
40033
- valueAdapter: getVal(2),
40034
- onChangeAdapter: setVal(2),
40036
+ name: "bottom",
40035
40037
  inline: true
40036
40038
  }))), /* @__PURE__ */ React__default.createElement(Stack$6, {
40037
40039
  wrap: false
@@ -40040,22 +40042,29 @@ function Padding(props = {}) {
40040
40042
  }, /* @__PURE__ */ React__default.createElement(TextField, {
40041
40043
  label: /* @__PURE__ */ React__default.createElement("span", null, "Left"),
40042
40044
  quickchange: true,
40043
- name: `${focusIdx2}.attributes.${attributeName}`,
40044
- valueAdapter: getVal(3),
40045
- onChangeAdapter: setVal(3),
40045
+ name: "left",
40046
40046
  inline: true
40047
40047
  })), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40048
40048
  fill: true
40049
40049
  }, /* @__PURE__ */ React__default.createElement(TextField, {
40050
40050
  label: /* @__PURE__ */ React__default.createElement("span", null, "Right\xA0"),
40051
40051
  quickchange: true,
40052
- name: `${focusIdx2}.attributes.${attributeName}`,
40053
- valueAdapter: getVal(1),
40054
- onChangeAdapter: setVal(1),
40052
+ name: "right",
40055
40053
  inline: true
40056
- }))));
40057
- }, [attributeName, focusIdx2, getVal, setVal, title2]);
40054
+ })))), /* @__PURE__ */ React__default.createElement(PaddingChangeWrapper, {
40055
+ onChange: onChancePadding
40056
+ }));
40057
+ });
40058
40058
  }
40059
+ const PaddingChangeWrapper = (props) => {
40060
+ const {
40061
+ values: { top, right, bottom, left }
40062
+ } = useFormState();
40063
+ useEffect(() => {
40064
+ props.onChange([top, right, bottom, left].join(" "));
40065
+ }, [top, right, bottom, left]);
40066
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
40067
+ };
40059
40068
  function BackgroundColor({
40060
40069
  title: title2 = "Background color"
40061
40070
  }) {