easy-email-extensions 3.1.0 → 3.1.1

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/index2.js CHANGED
@@ -55,8 +55,8 @@ var __async = (__this, __arguments, generator) => {
55
55
  };
56
56
  import * as React from "react";
57
57
  import React__default, { Children, isValidElement, cloneElement, createContext, useContext, Component, useMemo, memo, forwardRef, useEffect, useRef, useLayoutEffect, useState, createRef, useImperativeHandle, PureComponent, useCallback, useReducer, createElement, Suspense } from "react";
58
- import { IconFont, Stack as Stack$6, TextStyle, getBlockNodeByIdx, useBlock, getEditNode, getEditContent, useEditorProps, getShadowRoot, FIXED_CONTAINER_ID, useEditorContext, useFocusIdx, scrollBlockEleIntoView, useHoverIdx, useDataTransfer, getBlockNodeByChildEle, getDirectionPosition, DATA_ATTRIBUTE_ID, DATA_ATTRIBUTE_DROP_CONTAINER, BlockAvatarWrapper, getEditorRoot, useActiveTab, ActiveTabKeys } from "easy-email-editor";
59
- import { BasicType, ImageManager, getIndexByIdx, getSiblingIdx, BlockManager, getNodeIdxFromClassName, getParentIdx, getNodeIdxClassName, getPageIdx, getChildIdx, createBlockDataByType, getParentByIdx, getValueByIdx, MjmlToJson, JsonToMjml, getNodeTypeFromClassName } from "easy-email-core";
58
+ import { IconFont, Stack as Stack$6, TextStyle, getBlockNodeByIdx, useBlock, getEditNode, getEditContent, useEditorProps, useFocusIdx, useEditorContext, getShadowRoot, FIXED_CONTAINER_ID, scrollBlockEleIntoView, useHoverIdx, useDataTransfer, getBlockNodeByChildEle, getDirectionPosition, DATA_ATTRIBUTE_ID, DATA_ATTRIBUTE_DROP_CONTAINER, BlockAvatarWrapper, getEditorRoot, useActiveTab, ActiveTabKeys } from "easy-email-editor";
59
+ import { BasicType, ImageManager, BlockManager, createBlockDataByType, getParentByIdx, getValueByIdx, getIndexByIdx, getSiblingIdx, getNodeIdxFromClassName, getParentIdx, getNodeIdxClassName, getPageIdx, getChildIdx, MjmlToJson, JsonToMjml, getNodeTypeFromClassName } from "easy-email-core";
60
60
  import ReactDOM, { findDOMNode, createPortal } from "react-dom";
61
61
  import { useField, Field, useForm as useForm$1, Form as Form$3, version as version$2, useFormState } from "react-final-form";
62
62
  var index$2 = "";
@@ -38732,14 +38732,204 @@ function FontFamily$1(props) {
38732
38732
  key: item2.value
38733
38733
  }, item2.label))));
38734
38734
  }
38735
- const MergeTags$1 = React__default.memo((props) => {
38736
- const { mergeTags = {} } = useEditorProps();
38735
+ var styleText$1 = ".easy-email-extensions-Tools-Popover .arco-popover-content{padding:0}.easy-email-extensions-Tools-Popover .arco-popover-content-inner *::-webkit-scrollbar{-webkit-appearance:none;width:5px}.easy-email-extensions-Tools-Popover .arco-popover-content-inner *::-webkit-scrollbar-thumb{border-radius:5px;background-color:#00000080;box-shadow:0 0 1px #ffffff80;-webkit-box-shadow:0 0 1px rgba(255,255,255,.5)}\n";
38736
+ function Help(props) {
38737
+ return /* @__PURE__ */ React__default.createElement(Tooltip$1, __spreadProps(__spreadValues({}, __spreadProps(__spreadValues({}, props), { style: void 0 })), {
38738
+ content: props.title
38739
+ }), /* @__PURE__ */ React__default.createElement("span", {
38740
+ style: { cursor: "pointer" }
38741
+ }, /* @__PURE__ */ React__default.createElement(IconQuestionCircle$1, {
38742
+ style: props.style
38743
+ })));
38744
+ }
38745
+ var ARRAY_ERROR = "FINAL_FORM/array-error";
38746
+ var fieldSubscriptionItems = ["active", "data", "dirty", "dirtySinceLastSubmit", "error", "initial", "invalid", "length", "modified", "modifiedSinceLastSubmit", "pristine", "submitError", "submitFailed", "submitSucceeded", "submitting", "touched", "valid", "value", "visited", "validating"];
38747
+ var version$1 = "4.20.4";
38748
+ function renderComponent(props, name) {
38749
+ var render3 = props.render, children = props.children, component = props.component, rest = _objectWithoutPropertiesLoose(props, ["render", "children", "component"]);
38750
+ if (component) {
38751
+ return /* @__PURE__ */ createElement(component, _extends$f({}, rest, {
38752
+ children,
38753
+ render: render3
38754
+ }));
38755
+ }
38756
+ if (render3) {
38757
+ return render3(children === void 0 ? rest : _extends$f({}, rest, {
38758
+ children
38759
+ }));
38760
+ }
38761
+ if (typeof children !== "function") {
38762
+ throw new Error("Must specify either a render prop, a render function as children, or a component prop to " + name);
38763
+ }
38764
+ return children(rest);
38765
+ }
38766
+ var defaultIsEqual = function defaultIsEqual2(aArray, bArray) {
38767
+ return aArray === bArray || Array.isArray(aArray) && Array.isArray(bArray) && aArray.length === bArray.length && !aArray.some(function(a, index2) {
38768
+ return a !== bArray[index2];
38769
+ });
38770
+ };
38771
+ function useConstant(init) {
38772
+ var ref = React__default.useRef();
38773
+ if (!ref.current) {
38774
+ ref.current = init();
38775
+ }
38776
+ return ref.current;
38777
+ }
38778
+ var all = fieldSubscriptionItems.reduce(function(result, key) {
38779
+ result[key] = true;
38780
+ return result;
38781
+ }, {});
38782
+ var useFieldArray = function useFieldArray2(name, _temp) {
38783
+ var _ref2 = _temp === void 0 ? {} : _temp, _ref$subscription = _ref2.subscription, subscription = _ref$subscription === void 0 ? all : _ref$subscription, defaultValue = _ref2.defaultValue, initialValue = _ref2.initialValue, _ref$isEqual = _ref2.isEqual, isEqual2 = _ref$isEqual === void 0 ? defaultIsEqual : _ref$isEqual, validateProp = _ref2.validate;
38784
+ var form = useForm$1("useFieldArray");
38785
+ var formMutators = form.mutators;
38786
+ var hasMutators = !!(formMutators && formMutators.push && formMutators.pop);
38787
+ if (!hasMutators) {
38788
+ throw new Error("Array mutators not found. You need to provide the mutators from final-form-arrays to your form");
38789
+ }
38790
+ var mutators = useConstant(function() {
38791
+ return Object.keys(formMutators).reduce(function(result, key) {
38792
+ result[key] = function() {
38793
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
38794
+ args[_key] = arguments[_key];
38795
+ }
38796
+ return formMutators[key].apply(formMutators, [name].concat(args));
38797
+ };
38798
+ return result;
38799
+ }, {});
38800
+ });
38801
+ var validate3 = useConstant(function() {
38802
+ return function(value, allValues, meta2) {
38803
+ if (!validateProp)
38804
+ return void 0;
38805
+ var error2 = validateProp(value, allValues, meta2);
38806
+ if (!error2 || Array.isArray(error2)) {
38807
+ return error2;
38808
+ } else {
38809
+ var arrayError = [];
38810
+ arrayError[ARRAY_ERROR] = error2;
38811
+ return arrayError;
38812
+ }
38813
+ };
38814
+ });
38815
+ var _useField = useField(name, {
38816
+ subscription: _extends$f({}, subscription, {
38817
+ length: true
38818
+ }),
38819
+ defaultValue,
38820
+ initialValue,
38821
+ isEqual: isEqual2,
38822
+ validate: validate3,
38823
+ format: function format(v) {
38824
+ return v;
38825
+ }
38826
+ }), _useField$meta = _useField.meta, length = _useField$meta.length, meta = _objectWithoutPropertiesLoose(_useField$meta, ["length"]), input = _useField.input, fieldState = _objectWithoutPropertiesLoose(_useField, ["meta", "input"]);
38827
+ var forEach2 = function forEach3(iterator) {
38828
+ var len = length || 0;
38829
+ for (var i2 = 0; i2 < len; i2++) {
38830
+ iterator(name + "[" + i2 + "]", i2);
38831
+ }
38832
+ };
38833
+ var map2 = function map3(iterator) {
38834
+ var len = length || 0;
38835
+ var results = [];
38836
+ for (var i2 = 0; i2 < len; i2++) {
38837
+ results.push(iterator(name + "[" + i2 + "]", i2));
38838
+ }
38839
+ return results;
38840
+ };
38841
+ return {
38842
+ fields: _extends$f({
38843
+ name,
38844
+ forEach: forEach2,
38845
+ length: length || 0,
38846
+ map: map2
38847
+ }, mutators, fieldState, {
38848
+ value: input.value
38849
+ }),
38850
+ meta
38851
+ };
38852
+ };
38853
+ var version = "3.1.2";
38854
+ var versions = {
38855
+ "final-form": version$1,
38856
+ "react-final-form": version$2,
38857
+ "react-final-form-arrays": version
38858
+ };
38859
+ var FieldArray = function FieldArray2(_ref2) {
38860
+ var name = _ref2.name, subscription = _ref2.subscription, defaultValue = _ref2.defaultValue, initialValue = _ref2.initialValue, isEqual2 = _ref2.isEqual, validate3 = _ref2.validate, rest = _objectWithoutPropertiesLoose(_ref2, ["name", "subscription", "defaultValue", "initialValue", "isEqual", "validate"]);
38861
+ var _useFieldArray = useFieldArray(name, {
38862
+ subscription,
38863
+ defaultValue,
38864
+ initialValue,
38865
+ isEqual: isEqual2,
38866
+ validate: validate3
38867
+ }), fields = _useFieldArray.fields, meta = _useFieldArray.meta;
38868
+ return renderComponent(_extends$f({
38869
+ fields,
38870
+ meta: _extends$f({}, meta, {
38871
+ __versions: versions
38872
+ })
38873
+ }, rest), "FieldArray(" + name + ")");
38874
+ };
38875
+ function AddFont() {
38876
+ const { focusBlock: focusBlock2 } = useBlock();
38877
+ const { focusIdx: focusIdx2 } = useFocusIdx();
38878
+ const value = focusBlock2 == null ? void 0 : focusBlock2.data.value;
38879
+ return /* @__PURE__ */ React__default.createElement(FieldArray, {
38880
+ name: `${focusIdx2}.data.value.fonts`,
38881
+ render: (arrayHelpers) => {
38882
+ var _a;
38883
+ return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(Stack$6, {
38884
+ vertical: true,
38885
+ spacing: "tight"
38886
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
38887
+ distribution: "equalSpacing"
38888
+ }, /* @__PURE__ */ React__default.createElement(TextStyle, {
38889
+ variation: "strong"
38890
+ }, "Import font ", /* @__PURE__ */ React__default.createElement(Help, {
38891
+ title: "Points to a hosted css file"
38892
+ })), /* @__PURE__ */ React__default.createElement(Stack$6, null, /* @__PURE__ */ React__default.createElement(Button$4, {
38893
+ size: "small",
38894
+ icon: /* @__PURE__ */ React__default.createElement(IconPlus$1, null),
38895
+ onClick: () => arrayHelpers.fields.push({ name: "", href: "" })
38896
+ }))), /* @__PURE__ */ React__default.createElement(Stack$6, {
38897
+ vertical: true,
38898
+ spacing: "extraTight"
38899
+ }, (_a = value.fonts) == null ? void 0 : _a.map((item2, index2) => {
38900
+ return /* @__PURE__ */ React__default.createElement("div", {
38901
+ key: index2
38902
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
38903
+ alignment: "center",
38904
+ wrap: false
38905
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
38906
+ fill: true
38907
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
38908
+ inline: true,
38909
+ name: `${focusIdx2}.data.value.fonts.${index2}.name`,
38910
+ label: "Name"
38911
+ })), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
38912
+ fill: true
38913
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
38914
+ inline: true,
38915
+ name: `${focusIdx2}.data.value.fonts.${index2}.href`,
38916
+ label: "Href"
38917
+ })), /* @__PURE__ */ React__default.createElement(Button$4, {
38918
+ icon: /* @__PURE__ */ React__default.createElement(IconDelete$1, null),
38919
+ onClick: () => arrayHelpers.fields.remove(index2)
38920
+ })));
38921
+ }))));
38922
+ }
38923
+ });
38924
+ }
38925
+ const MergeTags = React__default.memo((props) => {
38926
+ const { mergeTags = {}, mergeTagGenerate } = useEditorProps();
38737
38927
  const treeOptions = useMemo(() => {
38738
38928
  const treeData = [];
38739
38929
  const deep = (key, title2, parent2, mapData = []) => {
38740
38930
  const currentMapData = {
38741
- key: `{{${key}}}`,
38742
- value: `{{${key}}}`,
38931
+ key: mergeTagGenerate(key),
38932
+ value: mergeTagGenerate(key),
38743
38933
  title: title2,
38744
38934
  children: []
38745
38935
  };
@@ -38764,7 +38954,7 @@ const MergeTags$1 = React__default.memo((props) => {
38764
38954
  dropdownMenuStyle: { maxHeight: 400, overflow: "auto" },
38765
38955
  placeholder: "Please select",
38766
38956
  treeData: treeOptions,
38767
- onChange: onSelect
38957
+ onChange: (val) => onSelect(val)
38768
38958
  }) : /* @__PURE__ */ React__default.createElement(Tree$1, {
38769
38959
  style: { width: 120 },
38770
38960
  selectedKeys: [],
@@ -38772,1700 +38962,623 @@ const MergeTags$1 = React__default.memo((props) => {
38772
38962
  onSelect: (vals) => onSelect(vals[0])
38773
38963
  }));
38774
38964
  });
38775
- var styleText$1 = ".easy-email-extensions-Tools-Popover .arco-popover-content{padding:0}.easy-email-extensions-Tools-Popover .arco-popover-content-inner *::-webkit-scrollbar{-webkit-appearance:none;width:5px}.easy-email-extensions-Tools-Popover .arco-popover-content-inner *::-webkit-scrollbar-thumb{border-radius:5px;background-color:#00000080;box-shadow:0 0 1px #ffffff80;-webkit-box-shadow:0 0 1px rgba(255,255,255,.5)}\n";
38776
- function Tools(props) {
38777
- const { container: container2 } = props;
38965
+ const AttributesPanelWrapper = (props) => {
38966
+ const { focusBlock: focusBlock2, setFocusBlock } = useBlock();
38778
38967
  const { mergeTags } = useEditorProps();
38779
- const [selectionRange, setSelectionRange] = useState(null);
38780
- useEffect(() => {
38781
- const onSelectionChange = () => {
38782
- try {
38783
- const range2 = getShadowRoot().getSelection().getRangeAt(0);
38784
- if (range2) {
38785
- setSelectionRange(range2);
38786
- }
38787
- } catch (error2) {
38788
- }
38789
- };
38790
- document.addEventListener("selectionchange", onSelectionChange);
38791
- return () => {
38792
- document.removeEventListener("selectionchange", onSelectionChange);
38793
- };
38794
- }, []);
38795
- const restoreRange = useCallback((range2) => {
38796
- const selection = getShadowRoot().getSelection();
38797
- selection.removeAllRanges();
38798
- const newRange = document.createRange();
38799
- newRange.setStart(range2.startContainer, range2.startOffset);
38800
- newRange.setEnd(range2.endContainer, range2.endOffset);
38801
- selection.addRange(newRange);
38802
- }, []);
38803
- const execCommand = (cmd, val) => {
38804
- if (!container2) {
38805
- console.error("No container");
38806
- return;
38807
- }
38808
- if (!selectionRange) {
38809
- console.error("No selectionRange");
38810
- return;
38811
- }
38812
- if (!(container2 == null ? void 0 : container2.contains(selectionRange == null ? void 0 : selectionRange.commonAncestorContainer)) && container2 !== (selectionRange == null ? void 0 : selectionRange.commonAncestorContainer)) {
38813
- console.error("Not commonAncestorContainer");
38968
+ const block2 = focusBlock2 && BlockManager.getBlockByType(focusBlock2.type);
38969
+ const onChangeHidden = useCallback((val) => {
38970
+ if (!focusBlock2)
38814
38971
  return;
38815
- }
38816
- restoreRange(selectionRange);
38817
- if (cmd === "createLink") {
38818
- const linkData = val;
38819
- const target2 = linkData.blank ? "_blank" : "";
38820
- let link;
38821
- if (linkData.linkNode) {
38822
- link = linkData.linkNode;
38823
- } else {
38824
- const uuid2 = (+new Date()).toString();
38825
- document.execCommand(cmd, false, uuid2);
38826
- link = getShadowRoot().querySelector(`a[href="${uuid2}"`);
38827
- }
38828
- if (target2) {
38829
- link.setAttribute("target", target2);
38830
- }
38831
- link.style.color = "inherit";
38832
- link.style.textDecoration = linkData.underline ? "underline" : "none";
38833
- link.setAttribute("href", linkData.link);
38834
- } else {
38835
- document.execCommand(cmd, false, val);
38836
- }
38837
- const html = container2.innerHTML;
38838
- props.onChange(html);
38839
- };
38840
- const getPopoverMountNode = () => document.getElementById(FIXED_CONTAINER_ID);
38841
- return /* @__PURE__ */ React__default.createElement("div", {
38842
- id: "Tools",
38843
- style: { display: "flex", flexWrap: "nowrap" }
38844
- }, /* @__PURE__ */ React__default.createElement("div", {
38972
+ focusBlock2.data.hidden = val;
38973
+ setFocusBlock(__spreadValues({}, focusBlock2));
38974
+ }, [focusBlock2, setFocusBlock]);
38975
+ if (!focusBlock2 || !block2)
38976
+ return null;
38977
+ return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("div", {
38845
38978
  style: {
38846
- display: "flex",
38847
- alignItems: "center"
38979
+ border: "1px solid var(--color-neutral-3, rgb(229, 230, 235))",
38980
+ borderBottom: "none",
38981
+ padding: "12px 24px"
38848
38982
  }
38849
- }, /* @__PURE__ */ React__default.createElement("div", {
38850
- className: "easy-email-extensions-divider"
38851
- }), /* @__PURE__ */ React__default.createElement(Popover$1, {
38852
- className: "easy-email-extensions-Tools-Popover",
38853
- trigger: "click",
38854
- content: /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("style", null, styleText$1), /* @__PURE__ */ React__default.createElement(FontFamily$1, {
38855
- onChange: (val) => execCommand("fontName", val)
38856
- })),
38857
- getPopupContainer: getPopoverMountNode
38858
- }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38859
- title: "font family",
38860
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38861
- iconName: "icon-font-family"
38862
- })
38863
- })), /* @__PURE__ */ React__default.createElement("div", {
38864
- className: "easy-email-extensions-divider"
38865
- }), /* @__PURE__ */ React__default.createElement(Popover$1, {
38866
- className: "easy-email-extensions-Tools-Popover",
38867
- color: "#fff",
38868
- trigger: "click",
38869
- content: /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("style", null, styleText$1), /* @__PURE__ */ React__default.createElement(FontSizeList, {
38870
- onChange: (val) => execCommand("fontSize", val)
38871
- })),
38872
- getPopupContainer: getPopoverMountNode
38873
- }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38874
- title: "line-height",
38875
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38876
- iconName: "icon-line-height"
38877
- })
38878
- })), /* @__PURE__ */ React__default.createElement("div", {
38879
- className: "easy-email-extensions-divider"
38880
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38881
- onClick: () => execCommand("bold"),
38882
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38883
- iconName: "icon-bold"
38884
- }),
38885
- title: "Bold"
38886
- }), /* @__PURE__ */ React__default.createElement("div", {
38887
- className: "easy-email-extensions-divider"
38888
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38889
- onClick: () => execCommand("italic"),
38890
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38891
- iconName: "icon-italic"
38892
- }),
38893
- title: "Italic"
38894
- }), /* @__PURE__ */ React__default.createElement("div", {
38895
- className: "easy-email-extensions-divider"
38896
- }), /* @__PURE__ */ React__default.createElement(ColorPicker, {
38897
- label: "",
38898
- position: "tl",
38899
- onChange: (color) => execCommand("foreColor", color),
38900
- getPopupContainer: getPopoverMountNode,
38901
- showInput: false
38902
- }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38903
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38904
- iconName: "icon-font-color"
38905
- }),
38906
- title: "Text color"
38907
- })), /* @__PURE__ */ React__default.createElement("div", {
38908
- className: "easy-email-extensions-divider"
38909
- }), /* @__PURE__ */ React__default.createElement(ColorPicker, {
38910
- label: "",
38911
- showInput: false,
38912
- position: "tl",
38913
- onChange: (color) => execCommand("hiliteColor", color),
38914
- getPopupContainer: getPopoverMountNode
38915
- }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38916
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38917
- iconName: "icon-bg-colors"
38918
- }),
38919
- title: "Background color"
38920
- })), /* @__PURE__ */ React__default.createElement("div", {
38921
- className: "easy-email-extensions-divider"
38922
- }), /* @__PURE__ */ React__default.createElement(Link$1, {
38923
- currentRange: selectionRange,
38924
- onChange: (values2) => execCommand("createLink", values2),
38925
- getPopupContainer: getPopoverMountNode
38926
- }), /* @__PURE__ */ React__default.createElement("div", {
38927
- className: "easy-email-extensions-divider"
38928
- }), mergeTags && /* @__PURE__ */ React__default.createElement(Tooltip$1, {
38929
- color: "#fff",
38930
- position: "bottom",
38931
- content: /* @__PURE__ */ React__default.createElement(MergeTags$1, {
38932
- value: "",
38933
- onChange: (val) => execCommand("insertHTML", val)
38934
- }),
38935
- getPopupContainer: getPopoverMountNode
38936
- }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38937
- title: "Merge tag",
38938
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38939
- iconName: "icon-merge-tags"
38940
- })
38941
- })), /* @__PURE__ */ React__default.createElement("div", {
38942
- className: "easy-email-extensions-divider"
38943
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38944
- onClick: () => execCommand("justifyLeft"),
38945
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38946
- iconName: "icon-align-left"
38947
- }),
38948
- title: "Align left"
38949
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38950
- onClick: () => execCommand("justifyCenter"),
38951
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38952
- iconName: "icon-align-center"
38953
- }),
38954
- title: "Align center"
38955
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38956
- onClick: () => execCommand("justifyRight"),
38957
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38958
- iconName: "icon-align-right"
38959
- }),
38960
- title: "Align right"
38961
- }), /* @__PURE__ */ React__default.createElement("div", {
38962
- className: "easy-email-extensions-divider"
38963
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38964
- onClick: () => execCommand("insertOrderedList"),
38965
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38966
- iconName: "icon-list-ol"
38967
- }),
38968
- title: "Orderlist"
38969
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38970
- onClick: () => execCommand("insertUnorderedList"),
38971
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38972
- iconName: "icon-list-ul"
38973
- }),
38974
- title: "Unorderlist"
38975
- }), /* @__PURE__ */ React__default.createElement("div", {
38976
- className: "easy-email-extensions-divider"
38977
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38978
- onClick: () => execCommand("strikeThrough"),
38979
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38980
- iconName: "icon-strikethrough"
38981
- }),
38982
- title: "StrikethroughOutlined"
38983
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38984
- onClick: () => execCommand("underline"),
38985
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38986
- iconName: "icon-underline"
38987
- }),
38988
- title: "UnderlineOutlined"
38989
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38990
- onClick: () => execCommand("insertHorizontalRule"),
38991
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
38992
- iconName: "icon-line"
38993
- }),
38994
- title: "Line"
38995
- }), /* @__PURE__ */ React__default.createElement("div", {
38996
- className: "easy-email-extensions-divider"
38997
- }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
38998
- onClick: () => execCommand("removeFormat"),
38999
- icon: /* @__PURE__ */ React__default.createElement(IconFont, {
39000
- iconName: "icon-close"
39001
- }),
39002
- title: "Remove format"
39003
- }), /* @__PURE__ */ React__default.createElement("div", {
39004
- className: "easy-email-extensions-divider"
39005
- })));
38983
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
38984
+ vertical: true
38985
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
38986
+ fill: true
38987
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
38988
+ wrap: false,
38989
+ distribution: "equalSpacing",
38990
+ alignment: "center"
38991
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
38992
+ spacing: "extraTight",
38993
+ alignment: "center"
38994
+ }, /* @__PURE__ */ React__default.createElement(EyeIcon, null), /* @__PURE__ */ React__default.createElement(TextStyle, {
38995
+ variation: "strong",
38996
+ size: "large"
38997
+ }, `${block2.name} attributes`)), /* @__PURE__ */ React__default.createElement(Stack$6.Item, null, props.extra))), Boolean(focusBlock2.data.hidden) && mergeTags && /* @__PURE__ */ React__default.createElement(Stack$6, {
38998
+ spacing: "extraTight"
38999
+ }, /* @__PURE__ */ React__default.createElement(TextStyle, null, "Hide if"), /* @__PURE__ */ React__default.createElement(MergeTags, {
39000
+ isSelect: true,
39001
+ onChange: onChangeHidden,
39002
+ value: String(focusBlock2.data.hidden)
39003
+ })))), /* @__PURE__ */ React__default.createElement("div", {
39004
+ style: __spreadValues({ padding: "0px" }, props.style)
39005
+ }, props.children));
39006
+ };
39007
+ function EyeIcon() {
39008
+ const { setFocusBlock, focusBlock: focusBlock2 } = useBlock();
39009
+ const onToggleVisible = useCallback((e) => {
39010
+ if (!focusBlock2)
39011
+ return null;
39012
+ e.stopPropagation();
39013
+ setFocusBlock(__spreadProps(__spreadValues({}, focusBlock2), {
39014
+ data: __spreadProps(__spreadValues({}, focusBlock2.data), {
39015
+ hidden: !focusBlock2.data.hidden
39016
+ })
39017
+ }));
39018
+ }, [focusBlock2, setFocusBlock]);
39019
+ if (!focusBlock2)
39020
+ return null;
39021
+ if (focusBlock2.type === BasicType.PAGE)
39022
+ return null;
39023
+ return focusBlock2.data.hidden ? /* @__PURE__ */ React__default.createElement(IconEyeInvisible$1, {
39024
+ style: { cursor: "pointer", fontSize: 18 },
39025
+ onClick: onToggleVisible
39026
+ }) : /* @__PURE__ */ React__default.createElement(IconEye$1, {
39027
+ style: { cursor: "pointer", fontSize: 18 },
39028
+ onClick: onToggleVisible
39029
+ });
39006
39030
  }
39007
- var styleText = ".easy-email-extensions-emailToolItem{display:inline-flex;position:relative;outline:none;font-weight:400;appearance:none;cursor:pointer!important;white-space:nowrap;transition:all .1s linear;box-sizing:border-box;line-height:1.5715;border:none;background-color:transparent;color:#fff}.easy-email-extensions-divider{position:relative;display:inline-flex;width:1px;height:16px;background-color:#808080e6}\n";
39008
- function RichTextToolBar() {
39009
- const [direction, setDirection] = useState("top");
39010
- const [blockNode, setBlockNode] = useState(null);
39011
- const [offsetX, setOffsetX] = useState(0);
39012
- const { focusBlock: focusBlock2 } = useBlock();
39013
- const { pageData: pageData2 } = useEditorContext();
39031
+ function FontFamily() {
39032
+ const { fontList: fontList2 = [] } = useEditorProps();
39014
39033
  const { focusIdx: focusIdx2 } = useFocusIdx();
39015
- const pageWidth = +(pageData2.attributes.width || "600").replace("px", "");
39016
- useEffect(() => {
39017
- const promiseObj = awaitForElement(focusIdx2);
39018
- promiseObj.promise.then((blockNode2) => {
39019
- setBlockNode(blockNode2);
39034
+ return useMemo(() => {
39035
+ return /* @__PURE__ */ React__default.createElement(AutoCompleteField, {
39036
+ style: { minWidth: 100, flex: 1 },
39037
+ showSearch: true,
39038
+ label: "Font family",
39039
+ name: `${focusIdx2}.attributes.font-family`,
39040
+ options: fontList2
39020
39041
  });
39021
- return () => {
39022
- promiseObj.cancel();
39023
- };
39024
- }, [focusIdx2, focusBlock2]);
39025
- useEffect(() => {
39026
- if (blockNode) {
39027
- const options2 = {
39028
- rootMargin: "-84px 0px 0px 0px",
39029
- root: getShadowRoot().firstChild,
39030
- threshold: [0, 1e-3, 0.1, 0.999, 0.8, 0.9, 1]
39031
- };
39032
- const checkDirection = (ev) => {
39033
- const [current] = ev;
39034
- const { top } = current.intersectionRect;
39035
- const boundingClientRect = current.boundingClientRect;
39036
- const rootBounds = current.rootBounds;
39037
- const intersectionRatio = current.intersectionRatio;
39038
- if (!rootBounds)
39039
- return;
39040
- const paddingLeft = (rootBounds.width - pageWidth) / 2;
39041
- const offsetLeft = boundingClientRect.left - rootBounds.left;
39042
- setOffsetX(paddingLeft - offsetLeft);
39043
- if (intersectionRatio === 1) {
39044
- setDirection("top");
39045
- } else {
39046
- if (top) {
39047
- if (top > rootBounds.top) {
39048
- setDirection("top");
39049
- } else {
39050
- setDirection("bottom");
39051
- }
39052
- }
39053
- }
39054
- };
39055
- const observer = new IntersectionObserver(checkDirection, options2);
39056
- observer.observe(blockNode);
39057
- return () => {
39058
- observer.unobserve(blockNode);
39059
- };
39060
- }
39061
- }, [blockNode, pageWidth]);
39062
- if (!blockNode)
39063
- return null;
39064
- const editorContainer = blockNode && getEditNode(blockNode);
39065
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, createPortal(/* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("style", {
39066
- dangerouslySetInnerHTML: { __html: styleText }
39067
- }), /* @__PURE__ */ React__default.createElement("div", {
39068
- style: {
39069
- transform: direction === "top" ? "translate(0,-100%)" : void 0,
39070
- padding: "4px 8px",
39071
- boxSizing: "border-box",
39072
- position: "absolute",
39073
- zIndex: 100,
39074
- top: direction === "top" ? -40 : "calc(100% + 40px)",
39075
- left: offsetX,
39076
- width: pageWidth
39077
- }
39078
- }, /* @__PURE__ */ React__default.createElement("div", {
39079
- style: {
39080
- position: "absolute",
39081
- backgroundColor: "#41444d",
39082
- height: "100%",
39083
- width: "100%",
39084
- left: 0,
39085
- top: 0
39086
- }
39087
- }), /* @__PURE__ */ React__default.createElement(Tools, {
39088
- container: editorContainer,
39089
- onChange: () => {
39090
- }
39091
- }))), blockNode));
39042
+ }, [focusIdx2, fontList2]);
39092
39043
  }
39093
- const RichTextField = (props) => {
39094
- const { focusBlock: focusBlock2 } = useBlock();
39044
+ function Page() {
39095
39045
  const { focusIdx: focusIdx2 } = useFocusIdx();
39096
- if ((focusBlock2 == null ? void 0 : focusBlock2.type) !== BasicType.TEXT)
39046
+ if (!focusIdx2)
39097
39047
  return null;
39098
- const name = `${focusIdx2}.data.value.content`;
39099
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(RichTextToolBar, null), /* @__PURE__ */ React__default.createElement(Field, {
39100
- name,
39101
- parse: (v) => v
39102
- }, ({ input }) => /* @__PURE__ */ React__default.createElement(FieldWrapper, __spreadProps(__spreadValues({}, props), {
39103
- input
39104
- }))));
39105
- };
39106
- function FieldWrapper(props) {
39107
- const _a = props, { input } = _a, rest = __objRest(_a, ["input"]);
39108
- const debounceCallbackChange = useCallback(lodash.exports.debounce((val) => {
39109
- input.onChange(val);
39110
- }, 500), [input]);
39111
- return /* @__PURE__ */ React__default.createElement(InlineText, __spreadProps(__spreadValues({}, rest), {
39112
- onChange: debounceCallbackChange
39113
- }));
39114
- }
39115
- const TextField = enhancer(Input, (value) => value);
39116
- const SearchField = enhancer(Input$5.Search, (val) => val);
39117
- const TextAreaField = enhancer(Input$5.TextArea, (val) => val);
39118
- const NumberField = enhancer(InputNumber$1, (e) => e);
39119
- const SliderField = enhancer(Slider$2, (e) => e);
39120
- const ColorPickerField = enhancer(ColorPicker, (e) => e);
39121
- const UploadField = enhancer(UploadField$1, (val) => val);
39122
- const ImageUploaderField = enhancer(ImageUploader, (url) => url);
39123
- const SelectField = enhancer(Select, (e) => e);
39124
- const AutoCompleteField = enhancer(AutoComplete, (e) => e);
39125
- const RadioGroupField = enhancer(RadioGroup, (value) => value);
39126
- const SwitchField = enhancer(Switch$1, (e) => e);
39127
- const DatePickerField = enhancer(DatePicker$1, (date) => date);
39128
- const CheckboxField = enhancer(CheckBoxGroup, (e) => e);
39129
- const EditTabField = enhancer(EditTab, (e) => e);
39130
- const InlineTextField = enhancer(InlineText, (value) => value);
39131
- const AddToCollection = ({ visible, setVisible }) => {
39132
- const { focusBlock: focusBlockData } = useBlock();
39133
- const { onAddCollection, onUploadImage } = useEditorProps();
39134
- const onSubmit = (values2) => {
39135
- if (!values2.label)
39136
- return;
39137
- const uuid2 = uuid_1.v4();
39138
- onAddCollection == null ? void 0 : onAddCollection({
39139
- label: values2.label,
39140
- helpText: values2.helpText,
39141
- data: focusBlockData,
39142
- thumbnail: values2.thumbnail,
39143
- id: uuid2
39144
- });
39145
- setVisible(false);
39146
- };
39147
- return /* @__PURE__ */ React__default.createElement(Form$3, {
39148
- initialValues: { label: "", helpText: "", thumbnail: "" },
39149
- onSubmit
39150
- }, ({ handleSubmit }) => /* @__PURE__ */ React__default.createElement(Modal$1, {
39151
- maskClosable: false,
39152
- style: { zIndex: 2e3 },
39153
- visible,
39154
- title: "Add to collection",
39155
- onOk: () => handleSubmit(),
39156
- onCancel: () => setVisible(false)
39048
+ return /* @__PURE__ */ React__default.createElement(AttributesPanelWrapper, {
39049
+ style: { padding: 0 }
39050
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39051
+ fill: true
39052
+ }, /* @__PURE__ */ React__default.createElement(Collapse$1, {
39053
+ defaultActiveKey: ["0", "1"]
39054
+ }, /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
39055
+ name: "0",
39056
+ header: "Email Setting"
39157
39057
  }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39158
- vertical: true
39159
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, null), /* @__PURE__ */ React__default.createElement(TextField, {
39160
- label: "Title",
39161
- name: "label",
39162
- validate: (val) => {
39163
- if (!val)
39164
- return "Title required!";
39165
- return void 0;
39166
- }
39167
- }), /* @__PURE__ */ React__default.createElement(TextAreaField, {
39168
- label: "Description",
39169
- name: "helpText"
39170
- }), /* @__PURE__ */ React__default.createElement(ImageUploaderField, {
39171
- label: "Thumbnail",
39172
- name: "thumbnail",
39173
- uploadHandler: onUploadImage,
39174
- validate: (val) => {
39175
- if (!val)
39176
- return "Thumbnail required!";
39177
- return void 0;
39178
- }
39179
- }))));
39180
- };
39181
- function useAddToCollection() {
39182
- const [modalVisible, setModalVisible] = useState(false);
39183
- const modal = useMemo(() => /* @__PURE__ */ React__default.createElement(AddToCollection, {
39184
- visible: modalVisible,
39185
- setVisible: setModalVisible
39186
- }), [modalVisible]);
39187
- return {
39188
- modal,
39189
- modalVisible,
39190
- setModalVisible
39191
- };
39058
+ vertical: true,
39059
+ spacing: "tight"
39060
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39061
+ label: "Subject",
39062
+ name: "subject",
39063
+ inline: true
39064
+ }), /* @__PURE__ */ React__default.createElement(TextField, {
39065
+ label: "SubTitle",
39066
+ name: "subTitle",
39067
+ inline: true
39068
+ }), /* @__PURE__ */ React__default.createElement(TextField, {
39069
+ label: "Width",
39070
+ name: `${focusIdx2}.attributes.width`,
39071
+ inline: true
39072
+ }), /* @__PURE__ */ React__default.createElement(Stack$6, {
39073
+ alignment: "center"
39074
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39075
+ label: /* @__PURE__ */ React__default.createElement(Stack$6, {
39076
+ spacing: "extraTight"
39077
+ }, /* @__PURE__ */ React__default.createElement(TextStyle, null, "Breakpoint"), /* @__PURE__ */ React__default.createElement(Help, {
39078
+ title: "Allows you to control on which breakpoint the layout should go desktop/mobile."
39079
+ })),
39080
+ quickchange: true,
39081
+ name: `${focusIdx2}.data.value.breakpoint`,
39082
+ inline: true
39083
+ })), /* @__PURE__ */ React__default.createElement(SwitchField, {
39084
+ inline: true,
39085
+ label: "Responsive",
39086
+ name: `${focusIdx2}.data.value.responsive`,
39087
+ checkedText: "True",
39088
+ uncheckedText: "False"
39089
+ }))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
39090
+ name: "1",
39091
+ header: "Theme Setting"
39092
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39093
+ vertical: true,
39094
+ spacing: "tight"
39095
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39096
+ wrap: false
39097
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39098
+ fill: true
39099
+ }, /* @__PURE__ */ React__default.createElement(FontFamily, null)), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39100
+ fill: true
39101
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39102
+ label: "Font size",
39103
+ quickchange: true,
39104
+ name: `${focusIdx2}.data.value.font-size`
39105
+ }))), /* @__PURE__ */ React__default.createElement(Stack$6, {
39106
+ wrap: false
39107
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39108
+ fill: true
39109
+ }, /* @__PURE__ */ React__default.createElement(ColorPickerField, {
39110
+ label: "Text color",
39111
+ name: `${focusIdx2}.data.value.text-color`
39112
+ })), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39113
+ fill: true
39114
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39115
+ label: "Line height",
39116
+ quickchange: true,
39117
+ name: `${focusIdx2}.data.value.line-height`
39118
+ }))), /* @__PURE__ */ React__default.createElement(Stack$6, {
39119
+ wrap: false
39120
+ }, /* @__PURE__ */ React__default.createElement(ColorPickerField, {
39121
+ label: "Background color",
39122
+ name: `${focusIdx2}.attributes.background-color`
39123
+ }), /* @__PURE__ */ React__default.createElement(ColorPickerField, {
39124
+ label: "Content background color",
39125
+ name: `${focusIdx2}.data.value.content-background-color`
39126
+ })), /* @__PURE__ */ React__default.createElement(TextAreaField, {
39127
+ label: "User style",
39128
+ name: `${focusIdx2}.data.value.user-style.content`
39129
+ }), /* @__PURE__ */ React__default.createElement(AddFont, null))))));
39192
39130
  }
39193
- function ContextMenu({
39194
- moveBlock,
39195
- copyBlock,
39196
- removeBlock,
39197
- contextMenuData,
39198
- onClose
39199
- }) {
39200
- const { blockData, left, top } = contextMenuData;
39201
- const idx = blockData.id;
39202
- const { modal, modalVisible, setModalVisible } = useAddToCollection();
39203
- const ref = useRef(null);
39204
- const handleMoveUp = () => {
39205
- moveBlock(idx, getSiblingIdx(idx, -1));
39206
- scrollBlockEleIntoView({
39207
- idx: getSiblingIdx(idx, -1)
39208
- });
39209
- onClose();
39210
- };
39211
- const handleMoveDown = () => {
39212
- moveBlock(idx, getSiblingIdx(idx, 1));
39213
- scrollBlockEleIntoView({
39214
- idx: getSiblingIdx(idx, 1)
39215
- });
39216
- onClose();
39217
- };
39218
- const handleCopy = (ev) => {
39219
- copyBlock(idx);
39220
- scrollBlockEleIntoView({
39221
- idx: getSiblingIdx(idx, 1)
39222
- });
39223
- onClose();
39224
- };
39225
- const handleAddToCollection = () => {
39226
- setModalVisible(true);
39227
- };
39228
- const handleDelete = () => {
39229
- removeBlock(idx);
39230
- onClose();
39231
- };
39232
- const isFirst = getIndexByIdx(idx) === 0;
39233
- return /* @__PURE__ */ React__default.createElement("div", {
39234
- ref,
39235
- style: { visibility: modalVisible ? "hidden" : void 0 }
39236
- }, /* @__PURE__ */ React__default.createElement("div", {
39237
- style: {
39131
+ function Padding(props = {}) {
39132
+ const { title: title2 = "Padding", attributeName = "padding" } = props;
39133
+ const { focusBlock: focusBlock2, change } = useBlock();
39134
+ const { focusIdx: focusIdx2 } = useFocusIdx();
39135
+ const type = focusBlock2 && focusBlock2.type;
39136
+ const defaultConfig = useMemo(() => type ? createBlockDataByType(type) : void 0, [type]);
39137
+ const paddingValue = focusBlock2 == null ? void 0 : focusBlock2.attributes[attributeName];
39138
+ const defaultPaddingValue = defaultConfig == null ? void 0 : defaultConfig.attributes[attributeName];
39139
+ const paddingList = paddingValue == null ? void 0 : paddingValue.split(" ");
39140
+ const defaultPaddingList = defaultPaddingValue == null ? void 0 : defaultPaddingValue.split(" ");
39141
+ const paddingFormValues = useMemo(() => {
39142
+ const paddingList2 = paddingValue == null ? void 0 : paddingValue.split(" ");
39143
+ const defaultPaddingList2 = defaultPaddingValue == null ? void 0 : defaultPaddingValue.split(" ");
39144
+ const top = paddingList2 ? paddingList2[0] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[0]) || "";
39145
+ const right = paddingList2 ? paddingList2[1] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[1]) || "";
39146
+ const bottom = paddingList2 ? paddingList2[2] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[2]) || "";
39147
+ const left = paddingList2 ? paddingList2[3] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[3]) || "";
39148
+ return {
39149
+ top,
39238
39150
  left,
39239
- top
39240
- },
39241
- className: styles$5.wrap,
39242
- onClick: (e) => e.stopPropagation()
39243
- }, !isFirst && /* @__PURE__ */ React__default.createElement("div", {
39244
- className: styles$5.listItem,
39245
- onClick: handleMoveUp
39246
- }, /* @__PURE__ */ React__default.createElement(IconFont, {
39247
- iconName: "icon-top",
39248
- style: { marginRight: 10 }
39249
- }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Move up")), /* @__PURE__ */ React__default.createElement("div", {
39250
- className: styles$5.listItem,
39251
- onClick: handleMoveDown
39252
- }, /* @__PURE__ */ React__default.createElement(IconFont, {
39253
- iconName: "icon-bottom",
39254
- style: { marginRight: 10 }
39255
- }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Move down")), /* @__PURE__ */ React__default.createElement("div", {
39256
- className: styles$5.listItem,
39257
- onClick: handleCopy
39258
- }, /* @__PURE__ */ React__default.createElement(IconFont, {
39259
- iconName: "icon-copy",
39260
- style: { marginRight: 10 }
39261
- }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Copy")), /* @__PURE__ */ React__default.createElement("div", {
39262
- className: styles$5.listItem,
39263
- onClick: handleAddToCollection
39264
- }, /* @__PURE__ */ React__default.createElement(IconFont, {
39265
- iconName: "icon-start",
39266
- style: { marginRight: 10 }
39267
- }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Add to collection")), /* @__PURE__ */ React__default.createElement("div", {
39268
- className: styles$5.listItem,
39269
- onClick: handleDelete
39270
- }, /* @__PURE__ */ React__default.createElement(IconFont, {
39271
- iconName: "icon-delete",
39272
- style: { marginRight: 10 }
39273
- }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Delete")), /* @__PURE__ */ React__default.createElement("div", {
39274
- className: styles$5.listItem,
39275
- onClick: handleAddToCollection
39276
- }, /* @__PURE__ */ React__default.createElement(IconFont, {
39277
- iconName: "icon-start",
39278
- style: { marginRight: 10 }
39279
- }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Add to collection"))), /* @__PURE__ */ React__default.createElement("div", {
39280
- className: styles$5.contextmenuMark,
39281
- onClick: onClose,
39282
- onContextMenu: (e) => {
39283
- e.preventDefault();
39284
- onClose(e);
39151
+ bottom,
39152
+ right
39153
+ };
39154
+ }, [paddingList, defaultPaddingList, defaultPaddingValue, paddingValue]);
39155
+ const onChancePadding = useCallback((val) => {
39156
+ change(focusIdx2 + `.attributes[${attributeName}]`, val);
39157
+ }, [focusIdx2, attributeName, change]);
39158
+ return /* @__PURE__ */ React__default.createElement(Form$3, {
39159
+ initialValues: paddingFormValues,
39160
+ subscription: { submitting: true, pristine: true },
39161
+ enableReinitialize: true,
39162
+ onSubmit: () => {
39285
39163
  }
39286
- }), modal);
39164
+ }, () => {
39165
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Stack$6, {
39166
+ vertical: true,
39167
+ spacing: "extraTight"
39168
+ }, /* @__PURE__ */ React__default.createElement(TextStyle, {
39169
+ variation: "strong"
39170
+ }, title2), /* @__PURE__ */ React__default.createElement(Stack$6, {
39171
+ wrap: false
39172
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39173
+ fill: true
39174
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39175
+ label: /* @__PURE__ */ React__default.createElement("span", null, "Top\xA0"),
39176
+ quickchange: true,
39177
+ name: "top",
39178
+ inline: true
39179
+ })), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39180
+ fill: true
39181
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39182
+ label: "Bottom",
39183
+ quickchange: true,
39184
+ name: "bottom",
39185
+ inline: true
39186
+ }))), /* @__PURE__ */ React__default.createElement(Stack$6, {
39187
+ wrap: false
39188
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39189
+ fill: true
39190
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39191
+ label: /* @__PURE__ */ React__default.createElement("span", null, "Left"),
39192
+ quickchange: true,
39193
+ name: "left",
39194
+ inline: true
39195
+ })), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39196
+ fill: true
39197
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39198
+ label: /* @__PURE__ */ React__default.createElement("span", null, "Right\xA0"),
39199
+ quickchange: true,
39200
+ name: "right",
39201
+ inline: true
39202
+ })))), /* @__PURE__ */ React__default.createElement(PaddingChangeWrapper, {
39203
+ onChange: onChancePadding
39204
+ }));
39205
+ });
39287
39206
  }
39288
- function useAvatarWrapperDrop() {
39289
- const [blockLayerRef, setBlockLayerRef] = useState(null);
39290
- const { setHoverIdx, setDirection } = useHoverIdx();
39291
- const { dataTransfer, setDataTransfer } = useDataTransfer();
39207
+ const PaddingChangeWrapper = (props) => {
39292
39208
  const {
39293
- formState: { values: values2 }
39294
- } = useEditorContext();
39295
- const valuesRef = useRef(values2);
39296
- const dataTransferRef = useRef(dataTransfer);
39297
- useEffect(() => {
39298
- valuesRef.current = values2;
39299
- }, [values2]);
39209
+ values: { top, right, bottom, left }
39210
+ } = useFormState();
39300
39211
  useEffect(() => {
39301
- dataTransferRef.current = dataTransfer;
39302
- }, [dataTransfer]);
39303
- function isKeyObject(o) {
39304
- return o.key !== void 0;
39212
+ props.onChange([top, right, bottom, left].join(" "));
39213
+ }, [top, right, bottom, left]);
39214
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
39215
+ };
39216
+ function BackgroundColor({
39217
+ title: title2 = "Background color"
39218
+ }) {
39219
+ const { focusIdx: focusIdx2 } = useFocusIdx();
39220
+ return useMemo(() => {
39221
+ return /* @__PURE__ */ React__default.createElement(ColorPickerField, {
39222
+ label: title2,
39223
+ name: `${focusIdx2}.attributes.background-color`,
39224
+ inline: true,
39225
+ alignment: "center"
39226
+ });
39227
+ }, [focusIdx2, title2]);
39228
+ }
39229
+ const backgroundRepeatOptions = [
39230
+ {
39231
+ value: "no-repeat",
39232
+ label: "No repeat"
39233
+ },
39234
+ {
39235
+ value: "repeat",
39236
+ label: "Repeat"
39237
+ },
39238
+ {
39239
+ value: "repeat-x",
39240
+ label: "Repeat X"
39241
+ },
39242
+ {
39243
+ value: "repeat-y",
39244
+ label: "Repeat Y"
39305
39245
  }
39306
- const removeHightLightClassName = useCallback(() => {
39307
- if (!blockLayerRef)
39246
+ ];
39247
+ function Background() {
39248
+ const { focusIdx: focusIdx2 } = useFocusIdx();
39249
+ const { onUploadImage } = useEditorProps();
39250
+ return useMemo(() => {
39251
+ return /* @__PURE__ */ React__default.createElement(Stack$6, {
39252
+ key: focusIdx2,
39253
+ vertical: true,
39254
+ spacing: "extraTight"
39255
+ }, /* @__PURE__ */ React__default.createElement(ImageUploaderField, {
39256
+ label: "Background image",
39257
+ name: `${focusIdx2}.attributes.background-url`,
39258
+ helpText: "The image suffix should be .jpg, jpeg, png, gif, etc. Otherwise, the picture may not be displayed normally.",
39259
+ uploadHandler: onUploadImage
39260
+ }), /* @__PURE__ */ React__default.createElement(BackgroundColor, null), /* @__PURE__ */ React__default.createElement(Stack$6, {
39261
+ wrap: false
39262
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39263
+ fill: true
39264
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39265
+ label: "Background size",
39266
+ name: `${focusIdx2}.attributes.background-size`
39267
+ })), /* @__PURE__ */ React__default.createElement(SelectField, {
39268
+ label: "Background repeat",
39269
+ name: `${focusIdx2}.attributes.background-repeat`,
39270
+ options: backgroundRepeatOptions
39271
+ })));
39272
+ }, [focusIdx2, onUploadImage]);
39273
+ }
39274
+ function Border() {
39275
+ const { focusIdx: focusIdx2 } = useFocusIdx();
39276
+ return useMemo(() => {
39277
+ return /* @__PURE__ */ React__default.createElement(Stack$6, {
39278
+ vertical: true,
39279
+ spacing: "tight"
39280
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39281
+ label: "Border",
39282
+ name: `${focusIdx2}.attributes.border`,
39283
+ inline: true
39284
+ }), /* @__PURE__ */ React__default.createElement(TextField, {
39285
+ label: "Border radius",
39286
+ name: `${focusIdx2}.attributes.border-radius`,
39287
+ inline: true
39288
+ }));
39289
+ }, [focusIdx2]);
39290
+ }
39291
+ function Section() {
39292
+ const { focusIdx: focusIdx2 } = useFocusIdx();
39293
+ const { focusBlock: focusBlock2, setFocusBlock } = useBlock();
39294
+ const noWrap = focusBlock2 == null ? void 0 : focusBlock2.data.value.noWrap;
39295
+ const changeNoWrap = useCallback((noWrap2) => {
39296
+ var _a;
39297
+ if (!focusBlock2)
39308
39298
  return;
39309
- blockLayerRef.querySelectorAll(".arco-tree-node-title-gap-top, .arco-tree-node-title-gap-bottom, .arco-tree-node-title-highlight").forEach((item2) => {
39310
- item2.classList.remove("arco-tree-node-title-gap-top", "arco-tree-node-title-gap-bottom", "arco-tree-node-title-highlight");
39311
- });
39312
- }, [blockLayerRef]);
39313
- const allowDrop = useCallback((params) => {
39314
- const { dragNode, dropNode, dropPosition } = params;
39315
- let dragType;
39316
- if (isKeyObject(dragNode)) {
39317
- const blockData = lodash.exports.get(valuesRef.current, dragNode.key);
39318
- if (!blockData)
39319
- return false;
39320
- dragType = blockData.type;
39321
- } else {
39322
- dragType = dragNode.type;
39323
- }
39324
- const dragBlock = BlockManager.getBlockByType(dragType);
39325
- if (!dragBlock)
39326
- return false;
39327
- if (dropPosition === 0) {
39328
- if (dragBlock.validParentType.includes(dropNode.dataRef.type) && dropNode.dataRef.children.length === 0) {
39329
- return {
39330
- position: 0,
39331
- key: dropNode.key
39332
- };
39333
- } else if (dropNode.parent && dragBlock.validParentType.includes(dropNode.parent.type)) {
39334
- return {
39335
- position: -1,
39336
- key: dropNode.key
39337
- };
39299
+ if (noWrap2) {
39300
+ const children = [...focusBlock2.children];
39301
+ for (let i2 = 0; i2 < children.length; i2++) {
39302
+ const child = children[i2];
39303
+ if (!child)
39304
+ continue;
39305
+ if (child.type === BasicType.GROUP) {
39306
+ children.splice(i2, 1, ...child.children);
39307
+ }
39338
39308
  }
39309
+ focusBlock2.children = [
39310
+ BlockManager.getBlockByType(BasicType.GROUP).create({
39311
+ children
39312
+ })
39313
+ ];
39339
39314
  } else {
39340
- if (dropNode.parent && dragBlock.validParentType.includes(dropNode.parent.type)) {
39341
- return {
39342
- position: dropPosition,
39343
- key: dropNode.key
39344
- };
39315
+ if (focusBlock2.children.length === 1 && focusBlock2.children[0].type === BasicType.GROUP) {
39316
+ focusBlock2.children = ((_a = focusBlock2.children[0]) == null ? void 0 : _a.children) || [];
39345
39317
  }
39346
39318
  }
39347
- setDirection("");
39348
- setHoverIdx("");
39349
- return false;
39350
- }, [setDirection, setHoverIdx, removeHightLightClassName]);
39319
+ setFocusBlock(__spreadValues({}, focusBlock2));
39320
+ }, [focusBlock2, setFocusBlock]);
39351
39321
  useEffect(() => {
39352
- if (blockLayerRef) {
39353
- const onDragOver = lodash.exports.debounce((ev) => {
39354
- var _a, _b, _c, _d;
39355
- if (!dataTransferRef.current)
39356
- return;
39357
- const blockNode = getBlockNodeByChildEle(ev.target);
39358
- if (!blockNode || !ev.target)
39359
- return;
39360
- const directionPosition = getDirectionPosition(ev, 5);
39361
- const treeNodeEle = (_b = (_a = blockNode.parentNode) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.parentNode;
39362
- if (!treeNodeEle)
39363
- return;
39364
- removeHightLightClassName();
39365
- const dropIdx = getNodeIdxFromClassName(blockNode.classList);
39366
- if (!dropIdx)
39367
- return;
39368
- const dropParentIdx = getParentIdx(dropIdx);
39369
- const dropBlockData = lodash.exports.get(valuesRef.current, dropIdx);
39370
- const dropParentBlockData = dropParentIdx ? lodash.exports.get(valuesRef.current, dropParentIdx) : null;
39371
- let dropPosition = 0;
39372
- if (directionPosition.vertical.direction === "top" && directionPosition.vertical.isEdge) {
39373
- dropPosition = -1;
39374
- } else if (directionPosition.vertical.direction === "bottom" && directionPosition.vertical.isEdge) {
39375
- dropPosition = 1;
39376
- }
39377
- const dropResult = allowDrop({
39378
- dragNode: {
39379
- type: dataTransferRef.current.type
39380
- },
39381
- dropNode: {
39382
- dataRef: dropBlockData,
39383
- key: dropIdx,
39384
- parent: dropParentBlockData
39385
- },
39386
- dropPosition
39387
- });
39388
- if (!dropResult)
39389
- return;
39390
- const node = (_d = (_c = document.querySelector(`[data-tree-idx="${dropResult.key}"]`)) == null ? void 0 : _c.parentNode) == null ? void 0 : _d.parentNode;
39391
- if (node instanceof HTMLElement) {
39392
- removeHightLightClassName();
39393
- node.classList.add("arco-tree-node-title-gap-bottom");
39394
- }
39395
- setDirection(getDirectionFormDropPosition(dropResult.position));
39396
- setHoverIdx(dropResult.key);
39397
- if (dropResult.position === -1) {
39398
- treeNodeEle.classList.add("arco-tree-node-title-gap-top");
39399
- setDataTransfer((dataTransfer2) => {
39400
- return __spreadProps(__spreadValues({}, dataTransfer2), {
39401
- parentIdx: dropParentIdx,
39402
- positionIndex: getIndexByIdx(dropIdx)
39403
- });
39404
- });
39405
- } else if (dropResult.position === 1) {
39406
- setDataTransfer((dataTransfer2) => {
39407
- return __spreadProps(__spreadValues({}, dataTransfer2), {
39408
- parentIdx: dropParentIdx,
39409
- positionIndex: getIndexByIdx(dropIdx) + 1
39410
- });
39411
- });
39412
- treeNodeEle.classList.add("arco-tree-node-title-gap-bottom");
39413
- } else {
39414
- treeNodeEle.classList.add("arco-tree-node-title-highlight");
39415
- setDataTransfer((dataTransfer2) => {
39416
- return __spreadProps(__spreadValues({}, dataTransfer2), {
39417
- parentIdx: getIndexByIdx(dropIdx),
39418
- positionIndex: 0
39419
- });
39420
- });
39421
- }
39422
- });
39423
- const onDragend = (ev) => {
39424
- removeHightLightClassName();
39425
- };
39426
- const onDrop = (ev) => {
39427
- setTimeout(() => {
39428
- removeHightLightClassName();
39429
- }, 0);
39430
- };
39431
- blockLayerRef.addEventListener("dragover", onDragOver);
39432
- blockLayerRef.addEventListener("drop", onDrop);
39433
- blockLayerRef.addEventListener("dragleave", onDragend);
39434
- return () => {
39435
- blockLayerRef.removeEventListener("dragover", onDragOver);
39436
- blockLayerRef.removeEventListener("drop", onDrop);
39437
- blockLayerRef.removeEventListener("dragleave", onDragend);
39438
- };
39439
- }
39440
- }, [blockLayerRef, dataTransferRef, valuesRef, removeHightLightClassName]);
39441
- return {
39442
- setBlockLayerRef,
39443
- blockLayerRef,
39444
- allowDrop,
39445
- removeHightLightClassName
39446
- };
39447
- }
39448
- function getDirectionFormDropPosition(position) {
39449
- if (position === -1)
39450
- return "top";
39451
- if (position === 1)
39452
- return "bottom";
39453
- return "";
39322
+ changeNoWrap(noWrap);
39323
+ }, [noWrap]);
39324
+ return /* @__PURE__ */ React__default.createElement(AttributesPanelWrapper, {
39325
+ style: { padding: 0 }
39326
+ }, /* @__PURE__ */ React__default.createElement(Collapse$1, {
39327
+ defaultActiveKey: ["0", "1", "2"]
39328
+ }, /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
39329
+ name: "0",
39330
+ header: "Dimension"
39331
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39332
+ vertical: true
39333
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39334
+ vertical: true,
39335
+ spacing: "none"
39336
+ }, /* @__PURE__ */ React__default.createElement(TextStyle, {
39337
+ variation: "strong"
39338
+ }, "Group"), /* @__PURE__ */ React__default.createElement(Stack$6, {
39339
+ wrap: false,
39340
+ alignment: "trailing"
39341
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39342
+ fill: true
39343
+ }, /* @__PURE__ */ React__default.createElement(TextStyle, null, "Prevent columns from stacking on mobile.")), /* @__PURE__ */ React__default.createElement(SwitchField, {
39344
+ label: "",
39345
+ labelHidden: true,
39346
+ name: `${focusIdx2}.data.value.noWrap`,
39347
+ checkedText: "True",
39348
+ uncheckedText: "False",
39349
+ inline: true
39350
+ }))), /* @__PURE__ */ React__default.createElement(Padding, null))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
39351
+ name: "1",
39352
+ header: "Background"
39353
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39354
+ vertical: true,
39355
+ spacing: "tight"
39356
+ }, /* @__PURE__ */ React__default.createElement(Background, null))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
39357
+ name: "2",
39358
+ header: "Border"
39359
+ }, /* @__PURE__ */ React__default.createElement(Border, null))));
39454
39360
  }
39455
- function BlockLayer() {
39456
- const {
39457
- pageData: pageData2,
39458
- formState: { values: values2 }
39459
- } = useEditorContext();
39460
- const { onUploadImage, onAddCollection } = useEditorProps();
39461
- const { focusIdx: focusIdx2, setFocusIdx } = useFocusIdx();
39462
- const { setHoverIdx, setIsDragging, setDirection } = useHoverIdx();
39463
- const { moveBlock, setValueByIdx: setValueByIdx2, copyBlock, removeBlock } = useBlock();
39464
- const {
39465
- setBlockLayerRef,
39466
- allowDrop,
39467
- blockLayerRef,
39468
- removeHightLightClassName
39469
- } = useAvatarWrapperDrop();
39470
- const [contextMenuData, setContextMenuData] = useState(null);
39471
- const onToggleVisible = useCallback(({ id }, e) => {
39472
- e.stopPropagation();
39473
- const blockData = lodash.exports.get(values2, id);
39474
- if (blockData) {
39475
- blockData.data.hidden = !Boolean(blockData.data.hidden);
39476
- setValueByIdx2(id, blockData);
39477
- }
39478
- }, [setValueByIdx2, values2]);
39479
- const renderTitle = useCallback((data) => {
39480
- const block2 = BlockManager.getBlockByType(data.type);
39481
- const isPage = data.type === BasicType.PAGE;
39482
- return /* @__PURE__ */ React__default.createElement("div", {
39483
- "data-tree-idx": data.id,
39484
- className: classnames(styles$6.title, !isPage && getNodeIdxClassName(data.id), !isPage && "email-block")
39485
- }, /* @__PURE__ */ React__default.createElement(TextStyle, {
39486
- size: "smallest"
39487
- }, block2 == null ? void 0 : block2.name), /* @__PURE__ */ React__default.createElement("div", {
39488
- className: styles$6.eyeIcon
39489
- }, /* @__PURE__ */ React__default.createElement(EyeIcon$1, {
39490
- blockData: data,
39491
- onToggleVisible
39492
- })));
39493
- }, [onToggleVisible]);
39494
- const treeData = useMemo(() => {
39495
- const copyData = lodash.exports.cloneDeep(pageData2);
39496
- const loop2 = (item2, id, parent2) => {
39497
- item2.id = id;
39498
- item2.parent = parent2;
39499
- item2.children.map((child, index2) => loop2(child, getChildIdx(id, index2), item2));
39500
- };
39501
- loop2(copyData, getPageIdx(), null);
39502
- return [copyData];
39503
- }, [pageData2]);
39504
- const onSelect = useCallback((selectedId) => {
39505
- setFocusIdx(selectedId);
39506
- scrollBlockEleIntoView({ idx: selectedId });
39507
- }, [setFocusIdx]);
39508
- const onContextMenu = useCallback((blockData, ev) => {
39509
- ev.preventDefault();
39510
- setContextMenuData({ blockData, left: ev.clientX, top: ev.clientY });
39511
- }, []);
39512
- const onCloseContextMenu = useCallback((ev) => {
39513
- setContextMenuData(null);
39514
- }, []);
39515
- const onMouseEnter = useCallback((id) => {
39516
- setHoverIdx(id);
39517
- }, [setHoverIdx]);
39518
- const onMouseLeave = useCallback(() => {
39519
- setHoverIdx("");
39520
- }, [setHoverIdx]);
39521
- const onDragStart = useCallback(() => {
39522
- setIsDragging(true);
39523
- }, [setIsDragging]);
39524
- const onDragEnd = useCallback(() => {
39525
- setIsDragging(false);
39526
- }, [setIsDragging]);
39527
- const onDrop = useCallback((params) => {
39528
- const { dragNode, dropNode, dropPosition } = params;
39529
- const dragBlock = BlockManager.getBlockByType(dragNode.dataRef.type);
39530
- if (!dragBlock)
39531
- return false;
39532
- const dropIndex = getIndexByIdx(dropNode.key);
39533
- if (dropPosition === 0) {
39534
- if (dragBlock.validParentType.includes(dropNode.dataRef.type) && dropNode.dataRef.children.length === 0) {
39535
- moveBlock(dragNode.key, getChildIdx(dropNode.key, 0));
39536
- } else if (dropNode.parent && dragBlock.validParentType.includes(dropNode.parent.type)) {
39537
- moveBlock(dragNode.key, getChildIdx(dropNode.parentKey, dropIndex));
39538
- }
39539
- } else {
39540
- moveBlock(dragNode.key, getChildIdx(dropNode.parentKey, dropPosition > 0 ? dropIndex + 1 : dropIndex));
39541
- }
39542
- }, [moveBlock]);
39543
- useEffect(() => {
39544
- if (!blockLayerRef)
39545
- return;
39546
- if (focusIdx2) {
39547
- setTimeout(() => {
39548
- const selectedNode = blockLayerRef.querySelector(`[${DATA_ATTRIBUTE_ID}="${focusIdx2}"]`);
39549
- if (selectedNode) {
39550
- selectedNode.scrollIntoView({
39551
- block: "center",
39552
- behavior: "smooth"
39553
- });
39554
- }
39555
- }, 50);
39556
- }
39557
- }, [blockLayerRef, focusIdx2]);
39558
- const blockTreeAllowDrop = useCallback((data) => {
39559
- var _a, _b;
39560
- const dropResult = allowDrop(data);
39561
- if (dropResult) {
39562
- const node = (_b = (_a = document.querySelector(`[data-tree-idx="${dropResult.key}"]`)) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.parentNode;
39563
- if (node instanceof HTMLElement) {
39564
- removeHightLightClassName();
39565
- node.classList.add("arco-tree-node-title-gap-bottom");
39566
- }
39567
- setDirection(getDirectionFormDropPosition(dropResult.position));
39568
- setHoverIdx(dropResult.key);
39361
+ function Width({ inline = false }) {
39362
+ var _a;
39363
+ const { focusIdx: focusIdx2 } = useFocusIdx();
39364
+ const { focusBlock: focusBlock2, values: values2 } = useBlock();
39365
+ const parentType = (_a = getParentByIdx(values2, focusIdx2)) == null ? void 0 : _a.type;
39366
+ const validate3 = useCallback((val) => {
39367
+ if ((focusBlock2 == null ? void 0 : focusBlock2.type) === BasicType.COLUMN && parentType === BasicType.GROUP) {
39368
+ return /(\d)*%/.test(val) ? void 0 : "Column inside a group must have a width in percentage, not in pixel";
39569
39369
  }
39570
- return dropResult;
39571
- }, [allowDrop]);
39572
- const hasFocus = Boolean(focusIdx2);
39370
+ return void 0;
39371
+ }, [focusBlock2 == null ? void 0 : focusBlock2.type, parentType]);
39573
39372
  return useMemo(() => {
39574
- if (!hasFocus)
39575
- return null;
39576
- return /* @__PURE__ */ React__default.createElement("div", __spreadValues({
39577
- ref: setBlockLayerRef,
39578
- id: "BlockLayerManager"
39579
- }, {
39580
- [DATA_ATTRIBUTE_DROP_CONTAINER]: "true"
39581
- }), /* @__PURE__ */ React__default.createElement(BlockTree, {
39582
- selectedId: focusIdx2,
39583
- defaultExpandAll: true,
39584
- treeData,
39585
- renderTitle,
39586
- allowDrop: blockTreeAllowDrop,
39587
- onContextMenu,
39588
- onDrop,
39589
- onDragStart,
39590
- onDragEnd,
39591
- onSelect,
39592
- onMouseEnter,
39593
- onMouseLeave
39594
- }), contextMenuData && /* @__PURE__ */ React__default.createElement(ContextMenu, {
39595
- onClose: onCloseContextMenu,
39596
- moveBlock,
39597
- copyBlock,
39598
- removeBlock,
39599
- contextMenuData
39600
- }));
39601
- }, [
39602
- hasFocus,
39603
- focusIdx2,
39604
- treeData,
39605
- renderTitle,
39606
- allowDrop,
39607
- onContextMenu,
39608
- onDrop,
39609
- onSelect,
39610
- onMouseEnter,
39611
- onMouseLeave,
39612
- contextMenuData,
39613
- onCloseContextMenu,
39614
- onUploadImage,
39615
- onAddCollection,
39616
- moveBlock,
39617
- copyBlock,
39618
- removeBlock,
39619
- onDragEnd,
39620
- onDragStart
39621
- ]);
39622
- }
39623
- function Help(props) {
39624
- return /* @__PURE__ */ React__default.createElement(Tooltip$1, __spreadProps(__spreadValues({}, __spreadProps(__spreadValues({}, props), { style: void 0 })), {
39625
- content: props.title
39626
- }), /* @__PURE__ */ React__default.createElement("span", {
39627
- style: { cursor: "pointer" }
39628
- }, /* @__PURE__ */ React__default.createElement(IconQuestionCircle$1, {
39629
- style: props.style
39630
- })));
39373
+ return /* @__PURE__ */ React__default.createElement(Stack$6, {
39374
+ wrap: false
39375
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39376
+ fill: true
39377
+ }, /* @__PURE__ */ React__default.createElement(TextField, {
39378
+ validate: validate3,
39379
+ label: "Width",
39380
+ inline,
39381
+ name: `${focusIdx2}.attributes.width`,
39382
+ quickchange: true
39383
+ })));
39384
+ }, [focusIdx2, inline, validate3]);
39631
39385
  }
39632
- var ARRAY_ERROR = "FINAL_FORM/array-error";
39633
- var fieldSubscriptionItems = ["active", "data", "dirty", "dirtySinceLastSubmit", "error", "initial", "invalid", "length", "modified", "modifiedSinceLastSubmit", "pristine", "submitError", "submitFailed", "submitSucceeded", "submitting", "touched", "valid", "value", "visited", "validating"];
39634
- var version$1 = "4.20.4";
39635
- function renderComponent(props, name) {
39636
- var render3 = props.render, children = props.children, component = props.component, rest = _objectWithoutPropertiesLoose(props, ["render", "children", "component"]);
39637
- if (component) {
39638
- return /* @__PURE__ */ createElement(component, _extends$f({}, rest, {
39639
- children,
39640
- render: render3
39641
- }));
39386
+ const options$a = [
39387
+ {
39388
+ value: "top",
39389
+ label: "top"
39390
+ },
39391
+ {
39392
+ value: "middle",
39393
+ label: "middle"
39394
+ },
39395
+ {
39396
+ value: "bottom",
39397
+ label: "bottom"
39642
39398
  }
39643
- if (render3) {
39644
- return render3(children === void 0 ? rest : _extends$f({}, rest, {
39645
- children
39399
+ ];
39400
+ function VerticalAlign({
39401
+ attributeName = "vertical-align"
39402
+ }) {
39403
+ const { focusIdx: focusIdx2 } = useFocusIdx();
39404
+ return useMemo(() => {
39405
+ return /* @__PURE__ */ React__default.createElement(Stack$6, null, /* @__PURE__ */ React__default.createElement(SelectField, {
39406
+ style: { width: 120 },
39407
+ label: "Vertical align",
39408
+ name: `${focusIdx2}.attributes.${attributeName}`,
39409
+ options: options$a
39646
39410
  }));
39647
- }
39648
- if (typeof children !== "function") {
39649
- throw new Error("Must specify either a render prop, a render function as children, or a component prop to " + name);
39650
- }
39651
- return children(rest);
39411
+ }, [attributeName, focusIdx2]);
39652
39412
  }
39653
- var defaultIsEqual = function defaultIsEqual2(aArray, bArray) {
39654
- return aArray === bArray || Array.isArray(aArray) && Array.isArray(bArray) && aArray.length === bArray.length && !aArray.some(function(a, index2) {
39655
- return a !== bArray[index2];
39656
- });
39657
- };
39658
- function useConstant(init) {
39659
- var ref = React__default.useRef();
39660
- if (!ref.current) {
39661
- ref.current = init();
39662
- }
39663
- return ref.current;
39413
+ function Column() {
39414
+ return /* @__PURE__ */ React__default.createElement(AttributesPanelWrapper, null, /* @__PURE__ */ React__default.createElement(Collapse$1, {
39415
+ defaultActiveKey: ["0", "1", "2"]
39416
+ }, /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
39417
+ name: "0",
39418
+ header: "Dimension"
39419
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39420
+ vertical: true,
39421
+ spacing: "tight"
39422
+ }, /* @__PURE__ */ React__default.createElement(Padding, null), /* @__PURE__ */ React__default.createElement(Stack$6, {
39423
+ wrap: false
39424
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39425
+ fill: true
39426
+ }, /* @__PURE__ */ React__default.createElement(Width, null)), /* @__PURE__ */ React__default.createElement(VerticalAlign, null)))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
39427
+ name: "1",
39428
+ header: "Background"
39429
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39430
+ vertical: true,
39431
+ spacing: "tight"
39432
+ }, /* @__PURE__ */ React__default.createElement(Background, null))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
39433
+ name: "2",
39434
+ header: "Border"
39435
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39436
+ vertical: true,
39437
+ spacing: "tight"
39438
+ }, /* @__PURE__ */ React__default.createElement(Border, null)))));
39664
39439
  }
39665
- var all = fieldSubscriptionItems.reduce(function(result, key) {
39666
- result[key] = true;
39667
- return result;
39668
- }, {});
39669
- var useFieldArray = function useFieldArray2(name, _temp) {
39670
- var _ref2 = _temp === void 0 ? {} : _temp, _ref$subscription = _ref2.subscription, subscription = _ref$subscription === void 0 ? all : _ref$subscription, defaultValue = _ref2.defaultValue, initialValue = _ref2.initialValue, _ref$isEqual = _ref2.isEqual, isEqual2 = _ref$isEqual === void 0 ? defaultIsEqual : _ref$isEqual, validateProp = _ref2.validate;
39671
- var form = useForm$1("useFieldArray");
39672
- var formMutators = form.mutators;
39673
- var hasMutators = !!(formMutators && formMutators.push && formMutators.pop);
39674
- if (!hasMutators) {
39675
- throw new Error("Array mutators not found. You need to provide the mutators from final-form-arrays to your form");
39440
+ const options$9 = [
39441
+ {
39442
+ value: "",
39443
+ label: "None"
39444
+ },
39445
+ {
39446
+ value: "underline",
39447
+ label: "Underline"
39448
+ },
39449
+ {
39450
+ value: "overline",
39451
+ label: "Overline"
39452
+ },
39453
+ {
39454
+ value: "line-through",
39455
+ label: "Line through"
39456
+ },
39457
+ {
39458
+ value: "blink",
39459
+ label: "Blink"
39460
+ },
39461
+ {
39462
+ value: "inherit",
39463
+ label: "Inherit"
39676
39464
  }
39677
- var mutators = useConstant(function() {
39678
- return Object.keys(formMutators).reduce(function(result, key) {
39679
- result[key] = function() {
39680
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
39681
- args[_key] = arguments[_key];
39682
- }
39683
- return formMutators[key].apply(formMutators, [name].concat(args));
39684
- };
39685
- return result;
39686
- }, {});
39687
- });
39688
- var validate3 = useConstant(function() {
39689
- return function(value, allValues, meta2) {
39690
- if (!validateProp)
39691
- return void 0;
39692
- var error2 = validateProp(value, allValues, meta2);
39693
- if (!error2 || Array.isArray(error2)) {
39694
- return error2;
39695
- } else {
39696
- var arrayError = [];
39697
- arrayError[ARRAY_ERROR] = error2;
39698
- return arrayError;
39699
- }
39700
- };
39701
- });
39702
- var _useField = useField(name, {
39703
- subscription: _extends$f({}, subscription, {
39704
- length: true
39705
- }),
39706
- defaultValue,
39707
- initialValue,
39708
- isEqual: isEqual2,
39709
- validate: validate3,
39710
- format: function format(v) {
39711
- return v;
39712
- }
39713
- }), _useField$meta = _useField.meta, length = _useField$meta.length, meta = _objectWithoutPropertiesLoose(_useField$meta, ["length"]), input = _useField.input, fieldState = _objectWithoutPropertiesLoose(_useField, ["meta", "input"]);
39714
- var forEach2 = function forEach3(iterator) {
39715
- var len = length || 0;
39716
- for (var i2 = 0; i2 < len; i2++) {
39717
- iterator(name + "[" + i2 + "]", i2);
39718
- }
39719
- };
39720
- var map2 = function map3(iterator) {
39721
- var len = length || 0;
39722
- var results = [];
39723
- for (var i2 = 0; i2 < len; i2++) {
39724
- results.push(iterator(name + "[" + i2 + "]", i2));
39725
- }
39726
- return results;
39727
- };
39728
- return {
39729
- fields: _extends$f({
39730
- name,
39731
- forEach: forEach2,
39732
- length: length || 0,
39733
- map: map2
39734
- }, mutators, fieldState, {
39735
- value: input.value
39736
- }),
39737
- meta
39738
- };
39739
- };
39740
- var version = "3.1.2";
39741
- var versions = {
39742
- "final-form": version$1,
39743
- "react-final-form": version$2,
39744
- "react-final-form-arrays": version
39745
- };
39746
- var FieldArray = function FieldArray2(_ref2) {
39747
- var name = _ref2.name, subscription = _ref2.subscription, defaultValue = _ref2.defaultValue, initialValue = _ref2.initialValue, isEqual2 = _ref2.isEqual, validate3 = _ref2.validate, rest = _objectWithoutPropertiesLoose(_ref2, ["name", "subscription", "defaultValue", "initialValue", "isEqual", "validate"]);
39748
- var _useFieldArray = useFieldArray(name, {
39749
- subscription,
39750
- defaultValue,
39751
- initialValue,
39752
- isEqual: isEqual2,
39753
- validate: validate3
39754
- }), fields = _useFieldArray.fields, meta = _useFieldArray.meta;
39755
- return renderComponent(_extends$f({
39756
- fields,
39757
- meta: _extends$f({}, meta, {
39758
- __versions: versions
39759
- })
39760
- }, rest), "FieldArray(" + name + ")");
39761
- };
39762
- function AddFont() {
39763
- const { focusBlock: focusBlock2 } = useBlock();
39465
+ ];
39466
+ function TextDecoration() {
39764
39467
  const { focusIdx: focusIdx2 } = useFocusIdx();
39765
- const value = focusBlock2 == null ? void 0 : focusBlock2.data.value;
39766
- return /* @__PURE__ */ React__default.createElement(FieldArray, {
39767
- name: `${focusIdx2}.data.value.fonts`,
39768
- render: (arrayHelpers) => {
39769
- var _a;
39770
- return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(Stack$6, {
39771
- vertical: true,
39772
- spacing: "tight"
39773
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39774
- distribution: "equalSpacing"
39775
- }, /* @__PURE__ */ React__default.createElement(TextStyle, {
39776
- variation: "strong"
39777
- }, "Import font ", /* @__PURE__ */ React__default.createElement(Help, {
39778
- title: "Points to a hosted css file"
39779
- })), /* @__PURE__ */ React__default.createElement(Stack$6, null, /* @__PURE__ */ React__default.createElement(Button$4, {
39780
- size: "small",
39781
- icon: /* @__PURE__ */ React__default.createElement(IconPlus$1, null),
39782
- onClick: () => arrayHelpers.fields.push({ name: "", href: "" })
39783
- }))), /* @__PURE__ */ React__default.createElement(Stack$6, {
39784
- vertical: true,
39785
- spacing: "extraTight"
39786
- }, (_a = value.fonts) == null ? void 0 : _a.map((item2, index2) => {
39787
- return /* @__PURE__ */ React__default.createElement("div", {
39788
- key: index2
39789
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39790
- alignment: "center",
39791
- wrap: false
39792
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39793
- fill: true
39794
- }, /* @__PURE__ */ React__default.createElement(TextField, {
39795
- inline: true,
39796
- name: `${focusIdx2}.data.value.fonts.${index2}.name`,
39797
- label: "Name"
39798
- })), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39799
- fill: true
39800
- }, /* @__PURE__ */ React__default.createElement(TextField, {
39801
- inline: true,
39802
- name: `${focusIdx2}.data.value.fonts.${index2}.href`,
39803
- label: "Href"
39804
- })), /* @__PURE__ */ React__default.createElement(Button$4, {
39805
- icon: /* @__PURE__ */ React__default.createElement(IconDelete$1, null),
39806
- onClick: () => arrayHelpers.fields.remove(index2)
39807
- })));
39808
- }))));
39809
- }
39810
- });
39811
- }
39812
- const MergeTags = React__default.memo((props) => {
39813
- const { mergeTags = {} } = useEditorProps();
39814
- const treeOptions = useMemo(() => {
39815
- const treeData = [];
39816
- const deep = (key, title2, parent2, mapData = []) => {
39817
- const currentMapData = {
39818
- key: `{{${key}}}`,
39819
- value: `{{${key}}}`,
39820
- title: title2,
39821
- children: []
39822
- };
39823
- mapData.push(currentMapData);
39824
- const current = parent2[key];
39825
- if (lodash.exports.isObject(current)) {
39826
- Object.keys(current).map((childKey) => deep(key + "." + childKey, childKey, current, currentMapData.children));
39827
- }
39828
- };
39829
- Object.keys(mergeTags).map((key) => deep(key, key, mergeTags, treeData));
39830
- return treeData;
39831
- }, [mergeTags]);
39832
- const onSelect = useCallback((value) => {
39833
- return props.onChange(value);
39834
- }, [props]);
39835
- return /* @__PURE__ */ React__default.createElement("div", {
39836
- style: { color: "#333" }
39837
- }, props.isSelect ? /* @__PURE__ */ React__default.createElement(TreeSelect$1, {
39838
- value: props.value,
39839
- size: "small",
39840
- style: { width: 120 },
39841
- dropdownMenuStyle: { maxHeight: 400, overflow: "auto" },
39842
- placeholder: "Please select",
39843
- treeData: treeOptions,
39844
- onChange: (val) => onSelect(val)
39845
- }) : /* @__PURE__ */ React__default.createElement(Tree$1, {
39846
- style: { width: 120 },
39847
- selectedKeys: [],
39848
- treeData: treeOptions,
39849
- onSelect: (vals) => onSelect(vals[0])
39850
- }));
39851
- });
39852
- const AttributesPanelWrapper = (props) => {
39853
- const { focusBlock: focusBlock2, setFocusBlock } = useBlock();
39854
- const { mergeTags } = useEditorProps();
39855
- const block2 = focusBlock2 && BlockManager.getBlockByType(focusBlock2.type);
39856
- const onChangeHidden = useCallback((val) => {
39857
- if (!focusBlock2)
39858
- return;
39859
- focusBlock2.data.hidden = val;
39860
- setFocusBlock(__spreadValues({}, focusBlock2));
39861
- }, [focusBlock2, setFocusBlock]);
39862
- if (!focusBlock2 || !block2)
39863
- return null;
39864
- return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("div", {
39865
- style: {
39866
- border: "1px solid var(--color-neutral-3, rgb(229, 230, 235))",
39867
- borderBottom: "none",
39868
- padding: "12px 24px"
39869
- }
39870
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39871
- vertical: true
39872
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39873
- fill: true
39874
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39875
- wrap: false,
39876
- distribution: "equalSpacing",
39877
- alignment: "center"
39878
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39879
- spacing: "extraTight",
39880
- alignment: "center"
39881
- }, /* @__PURE__ */ React__default.createElement(EyeIcon, null), /* @__PURE__ */ React__default.createElement(TextStyle, {
39882
- variation: "strong",
39883
- size: "large"
39884
- }, `${block2.name} attributes`)), /* @__PURE__ */ React__default.createElement(Stack$6.Item, null, props.extra))), Boolean(focusBlock2.data.hidden) && mergeTags && /* @__PURE__ */ React__default.createElement(Stack$6, {
39885
- spacing: "extraTight"
39886
- }, /* @__PURE__ */ React__default.createElement(TextStyle, null, "Hide if"), /* @__PURE__ */ React__default.createElement(MergeTags, {
39887
- isSelect: true,
39888
- onChange: onChangeHidden,
39889
- value: String(focusBlock2.data.hidden)
39890
- })))), /* @__PURE__ */ React__default.createElement("div", {
39891
- style: __spreadValues({ padding: "0px" }, props.style)
39892
- }, props.children));
39893
- };
39894
- function EyeIcon() {
39895
- const { setFocusBlock, focusBlock: focusBlock2 } = useBlock();
39896
- const onToggleVisible = useCallback((e) => {
39897
- if (!focusBlock2)
39898
- return null;
39899
- e.stopPropagation();
39900
- setFocusBlock(__spreadProps(__spreadValues({}, focusBlock2), {
39901
- data: __spreadProps(__spreadValues({}, focusBlock2.data), {
39902
- hidden: !focusBlock2.data.hidden
39903
- })
39904
- }));
39905
- }, [focusBlock2, setFocusBlock]);
39906
- if (!focusBlock2)
39907
- return null;
39908
- if (focusBlock2.type === BasicType.PAGE)
39909
- return null;
39910
- return focusBlock2.data.hidden ? /* @__PURE__ */ React__default.createElement(IconEyeInvisible$1, {
39911
- style: { cursor: "pointer", fontSize: 18 },
39912
- onClick: onToggleVisible
39913
- }) : /* @__PURE__ */ React__default.createElement(IconEye$1, {
39914
- style: { cursor: "pointer", fontSize: 18 },
39915
- onClick: onToggleVisible
39916
- });
39468
+ return useMemo(() => {
39469
+ return /* @__PURE__ */ React__default.createElement(SelectField, {
39470
+ label: "Text decoration",
39471
+ name: `${focusIdx2}.attributes.text-decoration`,
39472
+ options: options$9
39473
+ });
39474
+ }, [focusIdx2]);
39917
39475
  }
39918
- function FontFamily() {
39919
- const { fontList: fontList2 = [] } = useEditorProps();
39476
+ const options$8 = [
39477
+ {
39478
+ value: "normal",
39479
+ label: "Normal"
39480
+ },
39481
+ {
39482
+ value: "bold",
39483
+ label: "Bold"
39484
+ },
39485
+ {
39486
+ value: "100",
39487
+ label: "100"
39488
+ },
39489
+ {
39490
+ value: "200",
39491
+ label: "200"
39492
+ },
39493
+ {
39494
+ value: "300",
39495
+ label: "300"
39496
+ },
39497
+ {
39498
+ value: "400",
39499
+ label: "400"
39500
+ },
39501
+ {
39502
+ value: "500",
39503
+ label: "500"
39504
+ },
39505
+ {
39506
+ value: "600",
39507
+ label: "600"
39508
+ },
39509
+ {
39510
+ value: "700",
39511
+ label: "700"
39512
+ },
39513
+ {
39514
+ value: "800",
39515
+ label: "800"
39516
+ },
39517
+ {
39518
+ value: "900",
39519
+ label: "900"
39520
+ }
39521
+ ];
39522
+ function FontWeight() {
39920
39523
  const { focusIdx: focusIdx2 } = useFocusIdx();
39921
39524
  return useMemo(() => {
39922
- return /* @__PURE__ */ React__default.createElement(AutoCompleteField, {
39923
- style: { minWidth: 100, flex: 1 },
39924
- showSearch: true,
39925
- label: "Font family",
39926
- name: `${focusIdx2}.attributes.font-family`,
39927
- options: fontList2
39525
+ return /* @__PURE__ */ React__default.createElement(SelectField, {
39526
+ label: "Font weight",
39527
+ name: `${focusIdx2}.attributes.font-weight`,
39528
+ options: options$8
39928
39529
  });
39929
- }, [focusIdx2, fontList2]);
39530
+ }, [focusIdx2]);
39930
39531
  }
39931
- function Page() {
39532
+ const options$7 = [
39533
+ {
39534
+ value: "normal",
39535
+ label: "Normal"
39536
+ },
39537
+ {
39538
+ value: "italic",
39539
+ label: "Italic"
39540
+ }
39541
+ ];
39542
+ function FontStyle({ inline = true }) {
39932
39543
  const { focusIdx: focusIdx2 } = useFocusIdx();
39933
- if (!focusIdx2)
39934
- return null;
39935
- return /* @__PURE__ */ React__default.createElement(AttributesPanelWrapper, {
39936
- style: { padding: 0 }
39937
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39938
- fill: true
39939
- }, /* @__PURE__ */ React__default.createElement(Collapse$1, {
39940
- defaultActiveKey: ["0", "1"]
39941
- }, /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
39942
- name: "0",
39943
- header: "Email Setting"
39944
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39945
- vertical: true,
39946
- spacing: "tight"
39947
- }, /* @__PURE__ */ React__default.createElement(TextField, {
39948
- label: "Subject",
39949
- name: "subject",
39950
- inline: true
39951
- }), /* @__PURE__ */ React__default.createElement(TextField, {
39952
- label: "SubTitle",
39953
- name: "subTitle",
39954
- inline: true
39955
- }), /* @__PURE__ */ React__default.createElement(TextField, {
39956
- label: "Width",
39957
- name: `${focusIdx2}.attributes.width`,
39958
- inline: true
39959
- }), /* @__PURE__ */ React__default.createElement(Stack$6, {
39960
- alignment: "center"
39961
- }, /* @__PURE__ */ React__default.createElement(TextField, {
39962
- label: /* @__PURE__ */ React__default.createElement(Stack$6, {
39963
- spacing: "extraTight"
39964
- }, /* @__PURE__ */ React__default.createElement(TextStyle, null, "Breakpoint"), /* @__PURE__ */ React__default.createElement(Help, {
39965
- title: "Allows you to control on which breakpoint the layout should go desktop/mobile."
39966
- })),
39967
- quickchange: true,
39968
- name: `${focusIdx2}.data.value.breakpoint`,
39969
- inline: true
39970
- })), /* @__PURE__ */ React__default.createElement(SwitchField, {
39971
- inline: true,
39972
- label: "Responsive",
39973
- name: `${focusIdx2}.data.value.responsive`,
39974
- checkedText: "True",
39975
- uncheckedText: "False"
39976
- }))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
39977
- name: "1",
39978
- header: "Theme Setting"
39979
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39980
- vertical: true,
39981
- spacing: "tight"
39982
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
39983
- wrap: false
39984
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39985
- fill: true
39986
- }, /* @__PURE__ */ React__default.createElement(FontFamily, null)), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39987
- fill: true
39988
- }, /* @__PURE__ */ React__default.createElement(TextField, {
39989
- label: "Font size",
39990
- quickchange: true,
39991
- name: `${focusIdx2}.data.value.font-size`
39992
- }))), /* @__PURE__ */ React__default.createElement(Stack$6, {
39993
- wrap: false
39994
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
39995
- fill: true
39996
- }, /* @__PURE__ */ React__default.createElement(ColorPickerField, {
39997
- label: "Text color",
39998
- name: `${focusIdx2}.data.value.text-color`
39999
- })), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40000
- fill: true
40001
- }, /* @__PURE__ */ React__default.createElement(TextField, {
40002
- label: "Line height",
40003
- quickchange: true,
40004
- name: `${focusIdx2}.data.value.line-height`
40005
- }))), /* @__PURE__ */ React__default.createElement(Stack$6, {
40006
- wrap: false
40007
- }, /* @__PURE__ */ React__default.createElement(ColorPickerField, {
40008
- label: "Background color",
40009
- name: `${focusIdx2}.attributes.background-color`
40010
- }), /* @__PURE__ */ React__default.createElement(ColorPickerField, {
40011
- label: "Content background color",
40012
- name: `${focusIdx2}.data.value.content-background-color`
40013
- })), /* @__PURE__ */ React__default.createElement(TextAreaField, {
40014
- label: "User style",
40015
- name: `${focusIdx2}.data.value.user-style.content`
40016
- }), /* @__PURE__ */ React__default.createElement(AddFont, null))))));
39544
+ return useMemo(() => {
39545
+ return /* @__PURE__ */ React__default.createElement(RadioGroupField, {
39546
+ label: "Font style",
39547
+ name: `${focusIdx2}.attributes.font-style`,
39548
+ options: options$7,
39549
+ inline
39550
+ });
39551
+ }, [focusIdx2, inline]);
40017
39552
  }
40018
- function Padding(props = {}) {
40019
- const { title: title2 = "Padding", attributeName = "padding" } = props;
40020
- const { focusBlock: focusBlock2, change } = useBlock();
39553
+ function Height({ inline }) {
40021
39554
  const { focusIdx: focusIdx2 } = useFocusIdx();
40022
- const type = focusBlock2 && focusBlock2.type;
40023
- const defaultConfig = useMemo(() => type ? createBlockDataByType(type) : void 0, [type]);
40024
- const paddingValue = focusBlock2 == null ? void 0 : focusBlock2.attributes[attributeName];
40025
- const defaultPaddingValue = defaultConfig == null ? void 0 : defaultConfig.attributes[attributeName];
40026
- const paddingList = paddingValue == null ? void 0 : paddingValue.split(" ");
40027
- const defaultPaddingList = defaultPaddingValue == null ? void 0 : defaultPaddingValue.split(" ");
40028
- const paddingFormValues = useMemo(() => {
40029
- const paddingList2 = paddingValue == null ? void 0 : paddingValue.split(" ");
40030
- const defaultPaddingList2 = defaultPaddingValue == null ? void 0 : defaultPaddingValue.split(" ");
40031
- const top = paddingList2 ? paddingList2[0] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[0]) || "";
40032
- const right = paddingList2 ? paddingList2[1] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[1]) || "";
40033
- const bottom = paddingList2 ? paddingList2[2] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[2]) || "";
40034
- const left = paddingList2 ? paddingList2[3] : (defaultPaddingList2 == null ? void 0 : defaultPaddingList2[3]) || "";
40035
- return {
40036
- top,
40037
- left,
40038
- bottom,
40039
- right
40040
- };
40041
- }, [paddingList, defaultPaddingList, defaultPaddingValue, paddingValue]);
40042
- const onChancePadding = useCallback((val) => {
40043
- change(focusIdx2 + `.attributes[${attributeName}]`, val);
40044
- }, [focusIdx2, attributeName, change]);
40045
- return /* @__PURE__ */ React__default.createElement(Form$3, {
40046
- initialValues: paddingFormValues,
40047
- subscription: { submitting: true, pristine: true },
40048
- enableReinitialize: true,
40049
- onSubmit: () => {
40050
- }
40051
- }, () => {
40052
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Stack$6, {
40053
- vertical: true,
40054
- spacing: "extraTight"
40055
- }, /* @__PURE__ */ React__default.createElement(TextStyle, {
40056
- variation: "strong"
40057
- }, title2), /* @__PURE__ */ React__default.createElement(Stack$6, {
40058
- wrap: false
40059
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40060
- fill: true
40061
- }, /* @__PURE__ */ React__default.createElement(TextField, {
40062
- label: /* @__PURE__ */ React__default.createElement("span", null, "Top\xA0"),
40063
- quickchange: true,
40064
- name: "top",
40065
- inline: true
40066
- })), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40067
- fill: true
40068
- }, /* @__PURE__ */ React__default.createElement(TextField, {
40069
- label: "Bottom",
40070
- quickchange: true,
40071
- name: "bottom",
40072
- inline: true
40073
- }))), /* @__PURE__ */ React__default.createElement(Stack$6, {
39555
+ return useMemo(() => {
39556
+ return /* @__PURE__ */ React__default.createElement(Stack$6, {
40074
39557
  wrap: false
40075
39558
  }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40076
39559
  fill: true
40077
39560
  }, /* @__PURE__ */ React__default.createElement(TextField, {
40078
- label: /* @__PURE__ */ React__default.createElement("span", null, "Left"),
40079
- quickchange: true,
40080
- name: "left",
40081
- inline: true
40082
- })), /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40083
- fill: true
40084
- }, /* @__PURE__ */ React__default.createElement(TextField, {
40085
- label: /* @__PURE__ */ React__default.createElement("span", null, "Right\xA0"),
39561
+ label: "Height",
39562
+ name: `${focusIdx2}.attributes.height`,
40086
39563
  quickchange: true,
40087
- name: "right",
40088
- inline: true
40089
- })))), /* @__PURE__ */ React__default.createElement(PaddingChangeWrapper, {
40090
- onChange: onChancePadding
40091
- }));
40092
- });
39564
+ inline
39565
+ })));
39566
+ }, [focusIdx2, inline]);
40093
39567
  }
40094
- const PaddingChangeWrapper = (props) => {
40095
- const {
40096
- values: { top, right, bottom, left }
40097
- } = useFormState();
40098
- useEffect(() => {
40099
- props.onChange([top, right, bottom, left].join(" "));
40100
- }, [top, right, bottom, left]);
40101
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
40102
- };
40103
- function BackgroundColor({
40104
- title: title2 = "Background color"
39568
+ function ContainerBackgroundColor({
39569
+ title: title2 = "Container background color"
40105
39570
  }) {
40106
39571
  const { focusIdx: focusIdx2 } = useFocusIdx();
40107
39572
  return useMemo(() => {
40108
39573
  return /* @__PURE__ */ React__default.createElement(ColorPickerField, {
40109
39574
  label: title2,
40110
- name: `${focusIdx2}.attributes.background-color`,
39575
+ name: `${focusIdx2}.attributes.container-background-color`,
40111
39576
  inline: true,
40112
39577
  alignment: "center"
40113
39578
  });
40114
39579
  }, [focusIdx2, title2]);
40115
39580
  }
40116
- const backgroundRepeatOptions = [
40117
- {
40118
- value: "no-repeat",
40119
- label: "No repeat"
40120
- },
40121
- {
40122
- value: "repeat",
40123
- label: "Repeat"
40124
- },
40125
- {
40126
- value: "repeat-x",
40127
- label: "Repeat X"
40128
- },
40129
- {
40130
- value: "repeat-y",
40131
- label: "Repeat Y"
40132
- }
40133
- ];
40134
- function Background() {
40135
- const { focusIdx: focusIdx2 } = useFocusIdx();
40136
- const { onUploadImage } = useEditorProps();
40137
- return useMemo(() => {
40138
- return /* @__PURE__ */ React__default.createElement(Stack$6, {
40139
- key: focusIdx2,
40140
- vertical: true,
40141
- spacing: "extraTight"
40142
- }, /* @__PURE__ */ React__default.createElement(ImageUploaderField, {
40143
- label: "Background image",
40144
- name: `${focusIdx2}.attributes.background-url`,
40145
- helpText: "The image suffix should be .jpg, jpeg, png, gif, etc. Otherwise, the picture may not be displayed normally.",
40146
- uploadHandler: onUploadImage
40147
- }), /* @__PURE__ */ React__default.createElement(BackgroundColor, null), /* @__PURE__ */ React__default.createElement(Stack$6, {
40148
- wrap: false
40149
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40150
- fill: true
40151
- }, /* @__PURE__ */ React__default.createElement(TextField, {
40152
- label: "Background size",
40153
- name: `${focusIdx2}.attributes.background-size`
40154
- })), /* @__PURE__ */ React__default.createElement(SelectField, {
40155
- label: "Background repeat",
40156
- name: `${focusIdx2}.attributes.background-repeat`,
40157
- options: backgroundRepeatOptions
40158
- })));
40159
- }, [focusIdx2, onUploadImage]);
40160
- }
40161
- function Border() {
40162
- const { focusIdx: focusIdx2 } = useFocusIdx();
40163
- return useMemo(() => {
40164
- return /* @__PURE__ */ React__default.createElement(Stack$6, {
40165
- vertical: true,
40166
- spacing: "tight"
40167
- }, /* @__PURE__ */ React__default.createElement(TextField, {
40168
- label: "Border",
40169
- name: `${focusIdx2}.attributes.border`,
40170
- inline: true
40171
- }), /* @__PURE__ */ React__default.createElement(TextField, {
40172
- label: "Border radius",
40173
- name: `${focusIdx2}.attributes.border-radius`,
40174
- inline: true
40175
- }));
40176
- }, [focusIdx2]);
40177
- }
40178
- function Section() {
40179
- const { focusIdx: focusIdx2 } = useFocusIdx();
40180
- const { focusBlock: focusBlock2, setFocusBlock } = useBlock();
40181
- const noWrap = focusBlock2 == null ? void 0 : focusBlock2.data.value.noWrap;
40182
- const changeNoWrap = useCallback((noWrap2) => {
40183
- var _a;
40184
- if (!focusBlock2)
40185
- return;
40186
- if (noWrap2) {
40187
- const children = [...focusBlock2.children];
40188
- for (let i2 = 0; i2 < children.length; i2++) {
40189
- const child = children[i2];
40190
- if (!child)
40191
- continue;
40192
- if (child.type === BasicType.GROUP) {
40193
- children.splice(i2, 1, ...child.children);
40194
- }
40195
- }
40196
- focusBlock2.children = [
40197
- BlockManager.getBlockByType(BasicType.GROUP).create({
40198
- children
40199
- })
40200
- ];
40201
- } else {
40202
- if (focusBlock2.children.length === 1 && focusBlock2.children[0].type === BasicType.GROUP) {
40203
- focusBlock2.children = ((_a = focusBlock2.children[0]) == null ? void 0 : _a.children) || [];
40204
- }
40205
- }
40206
- setFocusBlock(__spreadValues({}, focusBlock2));
40207
- }, [focusBlock2, setFocusBlock]);
40208
- useEffect(() => {
40209
- changeNoWrap(noWrap);
40210
- }, [noWrap]);
40211
- return /* @__PURE__ */ React__default.createElement(AttributesPanelWrapper, {
40212
- style: { padding: 0 }
40213
- }, /* @__PURE__ */ React__default.createElement(Collapse$1, {
40214
- defaultActiveKey: ["0", "1", "2"]
40215
- }, /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
40216
- name: "0",
40217
- header: "Dimension"
40218
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
40219
- vertical: true
40220
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
40221
- vertical: true,
40222
- spacing: "none"
40223
- }, /* @__PURE__ */ React__default.createElement(TextStyle, {
40224
- variation: "strong"
40225
- }, "Group"), /* @__PURE__ */ React__default.createElement(Stack$6, {
40226
- wrap: false,
40227
- alignment: "trailing"
40228
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40229
- fill: true
40230
- }, /* @__PURE__ */ React__default.createElement(TextStyle, null, "Prevent columns from stacking on mobile.")), /* @__PURE__ */ React__default.createElement(SwitchField, {
40231
- label: "",
40232
- labelHidden: true,
40233
- name: `${focusIdx2}.data.value.noWrap`,
40234
- checkedText: "True",
40235
- uncheckedText: "False",
40236
- inline: true
40237
- }))), /* @__PURE__ */ React__default.createElement(Padding, null))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
40238
- name: "1",
40239
- header: "Background"
40240
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
40241
- vertical: true,
40242
- spacing: "tight"
40243
- }, /* @__PURE__ */ React__default.createElement(Background, null))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
40244
- name: "2",
40245
- header: "Border"
40246
- }, /* @__PURE__ */ React__default.createElement(Border, null))));
40247
- }
40248
- function Width({ inline = false }) {
40249
- var _a;
40250
- const { focusIdx: focusIdx2 } = useFocusIdx();
40251
- const { focusBlock: focusBlock2, values: values2 } = useBlock();
40252
- const parentType = (_a = getParentByIdx(values2, focusIdx2)) == null ? void 0 : _a.type;
40253
- const validate3 = useCallback((val) => {
40254
- if ((focusBlock2 == null ? void 0 : focusBlock2.type) === BasicType.COLUMN && parentType === BasicType.GROUP) {
40255
- return /(\d)*%/.test(val) ? void 0 : "Column inside a group must have a width in percentage, not in pixel";
40256
- }
40257
- return void 0;
40258
- }, [focusBlock2 == null ? void 0 : focusBlock2.type, parentType]);
40259
- return useMemo(() => {
40260
- return /* @__PURE__ */ React__default.createElement(Stack$6, {
40261
- wrap: false
40262
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40263
- fill: true
40264
- }, /* @__PURE__ */ React__default.createElement(TextField, {
40265
- validate: validate3,
40266
- label: "Width",
40267
- inline,
40268
- name: `${focusIdx2}.attributes.width`,
40269
- quickchange: true
40270
- })));
40271
- }, [focusIdx2, inline, validate3]);
40272
- }
40273
- const options$a = [
40274
- {
40275
- value: "top",
40276
- label: "top"
40277
- },
40278
- {
40279
- value: "middle",
40280
- label: "middle"
40281
- },
40282
- {
40283
- value: "bottom",
40284
- label: "bottom"
40285
- }
40286
- ];
40287
- function VerticalAlign({
40288
- attributeName = "vertical-align"
40289
- }) {
40290
- const { focusIdx: focusIdx2 } = useFocusIdx();
40291
- return useMemo(() => {
40292
- return /* @__PURE__ */ React__default.createElement(Stack$6, null, /* @__PURE__ */ React__default.createElement(SelectField, {
40293
- style: { width: 120 },
40294
- label: "Vertical align",
40295
- name: `${focusIdx2}.attributes.${attributeName}`,
40296
- options: options$a
40297
- }));
40298
- }, [attributeName, focusIdx2]);
40299
- }
40300
- function Column() {
40301
- return /* @__PURE__ */ React__default.createElement(AttributesPanelWrapper, null, /* @__PURE__ */ React__default.createElement(Collapse$1, {
40302
- defaultActiveKey: ["0", "1", "2"]
40303
- }, /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
40304
- name: "0",
40305
- header: "Dimension"
40306
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
40307
- vertical: true,
40308
- spacing: "tight"
40309
- }, /* @__PURE__ */ React__default.createElement(Padding, null), /* @__PURE__ */ React__default.createElement(Stack$6, {
40310
- wrap: false
40311
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40312
- fill: true
40313
- }, /* @__PURE__ */ React__default.createElement(Width, null)), /* @__PURE__ */ React__default.createElement(VerticalAlign, null)))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
40314
- name: "1",
40315
- header: "Background"
40316
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
40317
- vertical: true,
40318
- spacing: "tight"
40319
- }, /* @__PURE__ */ React__default.createElement(Background, null))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
40320
- name: "2",
40321
- header: "Border"
40322
- }, /* @__PURE__ */ React__default.createElement(Stack$6, {
40323
- vertical: true,
40324
- spacing: "tight"
40325
- }, /* @__PURE__ */ React__default.createElement(Border, null)))));
40326
- }
40327
- const options$9 = [
40328
- {
40329
- value: "",
40330
- label: "None"
40331
- },
40332
- {
40333
- value: "underline",
40334
- label: "Underline"
40335
- },
40336
- {
40337
- value: "overline",
40338
- label: "Overline"
40339
- },
40340
- {
40341
- value: "line-through",
40342
- label: "Line through"
40343
- },
40344
- {
40345
- value: "blink",
40346
- label: "Blink"
40347
- },
40348
- {
40349
- value: "inherit",
40350
- label: "Inherit"
40351
- }
40352
- ];
40353
- function TextDecoration() {
40354
- const { focusIdx: focusIdx2 } = useFocusIdx();
40355
- return useMemo(() => {
40356
- return /* @__PURE__ */ React__default.createElement(SelectField, {
40357
- label: "Text decoration",
40358
- name: `${focusIdx2}.attributes.text-decoration`,
40359
- options: options$9
40360
- });
40361
- }, [focusIdx2]);
40362
- }
40363
- const options$8 = [
40364
- {
40365
- value: "normal",
40366
- label: "Normal"
40367
- },
40368
- {
40369
- value: "bold",
40370
- label: "Bold"
40371
- },
40372
- {
40373
- value: "100",
40374
- label: "100"
40375
- },
40376
- {
40377
- value: "200",
40378
- label: "200"
40379
- },
40380
- {
40381
- value: "300",
40382
- label: "300"
40383
- },
40384
- {
40385
- value: "400",
40386
- label: "400"
40387
- },
40388
- {
40389
- value: "500",
40390
- label: "500"
40391
- },
40392
- {
40393
- value: "600",
40394
- label: "600"
40395
- },
40396
- {
40397
- value: "700",
40398
- label: "700"
40399
- },
40400
- {
40401
- value: "800",
40402
- label: "800"
40403
- },
40404
- {
40405
- value: "900",
40406
- label: "900"
40407
- }
40408
- ];
40409
- function FontWeight() {
40410
- const { focusIdx: focusIdx2 } = useFocusIdx();
40411
- return useMemo(() => {
40412
- return /* @__PURE__ */ React__default.createElement(SelectField, {
40413
- label: "Font weight",
40414
- name: `${focusIdx2}.attributes.font-weight`,
40415
- options: options$8
40416
- });
40417
- }, [focusIdx2]);
40418
- }
40419
- const options$7 = [
40420
- {
40421
- value: "normal",
40422
- label: "Normal"
40423
- },
40424
- {
40425
- value: "italic",
40426
- label: "Italic"
40427
- }
40428
- ];
40429
- function FontStyle({ inline = true }) {
40430
- const { focusIdx: focusIdx2 } = useFocusIdx();
40431
- return useMemo(() => {
40432
- return /* @__PURE__ */ React__default.createElement(RadioGroupField, {
40433
- label: "Font style",
40434
- name: `${focusIdx2}.attributes.font-style`,
40435
- options: options$7,
40436
- inline
40437
- });
40438
- }, [focusIdx2, inline]);
40439
- }
40440
- function Height({ inline }) {
40441
- const { focusIdx: focusIdx2 } = useFocusIdx();
40442
- return useMemo(() => {
40443
- return /* @__PURE__ */ React__default.createElement(Stack$6, {
40444
- wrap: false
40445
- }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, {
40446
- fill: true
40447
- }, /* @__PURE__ */ React__default.createElement(TextField, {
40448
- label: "Height",
40449
- name: `${focusIdx2}.attributes.height`,
40450
- quickchange: true,
40451
- inline
40452
- })));
40453
- }, [focusIdx2, inline]);
40454
- }
40455
- function ContainerBackgroundColor({
40456
- title: title2 = "Container background color"
40457
- }) {
40458
- const { focusIdx: focusIdx2 } = useFocusIdx();
40459
- return useMemo(() => {
40460
- return /* @__PURE__ */ React__default.createElement(ColorPickerField, {
40461
- label: title2,
40462
- name: `${focusIdx2}.attributes.container-background-color`,
40463
- inline: true,
40464
- alignment: "center"
40465
- });
40466
- }, [focusIdx2, title2]);
40467
- }
40468
- function FontSize() {
39581
+ function FontSize() {
40469
39582
  const { focusIdx: focusIdx2 } = useFocusIdx();
40470
39583
  return useMemo(() => {
40471
39584
  return /* @__PURE__ */ React__default.createElement(TextField, {
@@ -41851,6 +40964,854 @@ function Margin() {
41851
40964
  }))));
41852
40965
  }, [focusIdx2]);
41853
40966
  }
40967
+ function Tools(props) {
40968
+ const { container: container2 } = props;
40969
+ const { mergeTags } = useEditorProps();
40970
+ const [selectionRange, setSelectionRange] = useState(null);
40971
+ useEffect(() => {
40972
+ const onSelectionChange = () => {
40973
+ try {
40974
+ const range2 = getShadowRoot().getSelection().getRangeAt(0);
40975
+ if (range2) {
40976
+ setSelectionRange(range2);
40977
+ }
40978
+ } catch (error2) {
40979
+ }
40980
+ };
40981
+ document.addEventListener("selectionchange", onSelectionChange);
40982
+ return () => {
40983
+ document.removeEventListener("selectionchange", onSelectionChange);
40984
+ };
40985
+ }, []);
40986
+ const restoreRange = useCallback((range2) => {
40987
+ const selection = getShadowRoot().getSelection();
40988
+ selection.removeAllRanges();
40989
+ const newRange = document.createRange();
40990
+ newRange.setStart(range2.startContainer, range2.startOffset);
40991
+ newRange.setEnd(range2.endContainer, range2.endOffset);
40992
+ selection.addRange(newRange);
40993
+ }, []);
40994
+ const execCommand = (cmd, val) => {
40995
+ if (!container2) {
40996
+ console.error("No container");
40997
+ return;
40998
+ }
40999
+ if (!selectionRange) {
41000
+ console.error("No selectionRange");
41001
+ return;
41002
+ }
41003
+ if (!(container2 == null ? void 0 : container2.contains(selectionRange == null ? void 0 : selectionRange.commonAncestorContainer)) && container2 !== (selectionRange == null ? void 0 : selectionRange.commonAncestorContainer)) {
41004
+ console.error("Not commonAncestorContainer");
41005
+ return;
41006
+ }
41007
+ restoreRange(selectionRange);
41008
+ if (cmd === "createLink") {
41009
+ const linkData = val;
41010
+ const target2 = linkData.blank ? "_blank" : "";
41011
+ let link;
41012
+ if (linkData.linkNode) {
41013
+ link = linkData.linkNode;
41014
+ } else {
41015
+ const uuid2 = (+new Date()).toString();
41016
+ document.execCommand(cmd, false, uuid2);
41017
+ link = getShadowRoot().querySelector(`a[href="${uuid2}"`);
41018
+ }
41019
+ if (target2) {
41020
+ link.setAttribute("target", target2);
41021
+ }
41022
+ link.style.color = "inherit";
41023
+ link.style.textDecoration = linkData.underline ? "underline" : "none";
41024
+ link.setAttribute("href", linkData.link);
41025
+ } else {
41026
+ document.execCommand(cmd, false, val);
41027
+ }
41028
+ const html = container2.innerHTML;
41029
+ props.onChange(html);
41030
+ };
41031
+ const getPopoverMountNode = () => document.getElementById(FIXED_CONTAINER_ID);
41032
+ return /* @__PURE__ */ React__default.createElement("div", {
41033
+ id: "Tools",
41034
+ style: { display: "flex", flexWrap: "nowrap" }
41035
+ }, /* @__PURE__ */ React__default.createElement("div", {
41036
+ style: {
41037
+ display: "flex",
41038
+ alignItems: "center"
41039
+ }
41040
+ }, /* @__PURE__ */ React__default.createElement("div", {
41041
+ className: "easy-email-extensions-divider"
41042
+ }), /* @__PURE__ */ React__default.createElement(Popover$1, {
41043
+ className: "easy-email-extensions-Tools-Popover",
41044
+ trigger: "click",
41045
+ content: /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("style", null, styleText$1), /* @__PURE__ */ React__default.createElement(FontFamily$1, {
41046
+ onChange: (val) => execCommand("fontName", val)
41047
+ })),
41048
+ getPopupContainer: getPopoverMountNode
41049
+ }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41050
+ title: "font family",
41051
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41052
+ iconName: "icon-font-family"
41053
+ })
41054
+ })), /* @__PURE__ */ React__default.createElement("div", {
41055
+ className: "easy-email-extensions-divider"
41056
+ }), /* @__PURE__ */ React__default.createElement(Popover$1, {
41057
+ className: "easy-email-extensions-Tools-Popover",
41058
+ color: "#fff",
41059
+ trigger: "click",
41060
+ content: /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("style", null, styleText$1), /* @__PURE__ */ React__default.createElement(FontSizeList, {
41061
+ onChange: (val) => execCommand("fontSize", val)
41062
+ })),
41063
+ getPopupContainer: getPopoverMountNode
41064
+ }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41065
+ title: "line-height",
41066
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41067
+ iconName: "icon-line-height"
41068
+ })
41069
+ })), /* @__PURE__ */ React__default.createElement("div", {
41070
+ className: "easy-email-extensions-divider"
41071
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41072
+ onClick: () => execCommand("bold"),
41073
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41074
+ iconName: "icon-bold"
41075
+ }),
41076
+ title: "Bold"
41077
+ }), /* @__PURE__ */ React__default.createElement("div", {
41078
+ className: "easy-email-extensions-divider"
41079
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41080
+ onClick: () => execCommand("italic"),
41081
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41082
+ iconName: "icon-italic"
41083
+ }),
41084
+ title: "Italic"
41085
+ }), /* @__PURE__ */ React__default.createElement("div", {
41086
+ className: "easy-email-extensions-divider"
41087
+ }), /* @__PURE__ */ React__default.createElement(ColorPicker, {
41088
+ label: "",
41089
+ position: "tl",
41090
+ onChange: (color) => execCommand("foreColor", color),
41091
+ getPopupContainer: getPopoverMountNode,
41092
+ showInput: false
41093
+ }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41094
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41095
+ iconName: "icon-font-color"
41096
+ }),
41097
+ title: "Text color"
41098
+ })), /* @__PURE__ */ React__default.createElement("div", {
41099
+ className: "easy-email-extensions-divider"
41100
+ }), /* @__PURE__ */ React__default.createElement(ColorPicker, {
41101
+ label: "",
41102
+ showInput: false,
41103
+ position: "tl",
41104
+ onChange: (color) => execCommand("hiliteColor", color),
41105
+ getPopupContainer: getPopoverMountNode
41106
+ }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41107
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41108
+ iconName: "icon-bg-colors"
41109
+ }),
41110
+ title: "Background color"
41111
+ })), /* @__PURE__ */ React__default.createElement("div", {
41112
+ className: "easy-email-extensions-divider"
41113
+ }), /* @__PURE__ */ React__default.createElement(Link$1, {
41114
+ currentRange: selectionRange,
41115
+ onChange: (values2) => execCommand("createLink", values2),
41116
+ getPopupContainer: getPopoverMountNode
41117
+ }), /* @__PURE__ */ React__default.createElement("div", {
41118
+ className: "easy-email-extensions-divider"
41119
+ }), mergeTags && /* @__PURE__ */ React__default.createElement(Popover$1, {
41120
+ trigger: "click",
41121
+ color: "#fff",
41122
+ position: "bottom",
41123
+ content: /* @__PURE__ */ React__default.createElement(MergeTags, {
41124
+ value: "",
41125
+ onChange: (val) => execCommand("insertHTML", val)
41126
+ }),
41127
+ getPopupContainer: getPopoverMountNode
41128
+ }, /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41129
+ title: "Merge tag",
41130
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41131
+ iconName: "icon-merge-tags"
41132
+ })
41133
+ })), /* @__PURE__ */ React__default.createElement("div", {
41134
+ className: "easy-email-extensions-divider"
41135
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41136
+ onClick: () => execCommand("justifyLeft"),
41137
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41138
+ iconName: "icon-align-left"
41139
+ }),
41140
+ title: "Align left"
41141
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41142
+ onClick: () => execCommand("justifyCenter"),
41143
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41144
+ iconName: "icon-align-center"
41145
+ }),
41146
+ title: "Align center"
41147
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41148
+ onClick: () => execCommand("justifyRight"),
41149
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41150
+ iconName: "icon-align-right"
41151
+ }),
41152
+ title: "Align right"
41153
+ }), /* @__PURE__ */ React__default.createElement("div", {
41154
+ className: "easy-email-extensions-divider"
41155
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41156
+ onClick: () => execCommand("insertOrderedList"),
41157
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41158
+ iconName: "icon-list-ol"
41159
+ }),
41160
+ title: "Orderlist"
41161
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41162
+ onClick: () => execCommand("insertUnorderedList"),
41163
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41164
+ iconName: "icon-list-ul"
41165
+ }),
41166
+ title: "Unorderlist"
41167
+ }), /* @__PURE__ */ React__default.createElement("div", {
41168
+ className: "easy-email-extensions-divider"
41169
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41170
+ onClick: () => execCommand("strikeThrough"),
41171
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41172
+ iconName: "icon-strikethrough"
41173
+ }),
41174
+ title: "StrikethroughOutlined"
41175
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41176
+ onClick: () => execCommand("underline"),
41177
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41178
+ iconName: "icon-underline"
41179
+ }),
41180
+ title: "UnderlineOutlined"
41181
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41182
+ onClick: () => execCommand("insertHorizontalRule"),
41183
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41184
+ iconName: "icon-line"
41185
+ }),
41186
+ title: "Line"
41187
+ }), /* @__PURE__ */ React__default.createElement("div", {
41188
+ className: "easy-email-extensions-divider"
41189
+ }), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
41190
+ onClick: () => execCommand("removeFormat"),
41191
+ icon: /* @__PURE__ */ React__default.createElement(IconFont, {
41192
+ iconName: "icon-close"
41193
+ }),
41194
+ title: "Remove format"
41195
+ }), /* @__PURE__ */ React__default.createElement("div", {
41196
+ className: "easy-email-extensions-divider"
41197
+ })));
41198
+ }
41199
+ var styleText = ".easy-email-extensions-emailToolItem{display:inline-flex;position:relative;outline:none;font-weight:400;appearance:none;cursor:pointer!important;white-space:nowrap;transition:all .1s linear;box-sizing:border-box;line-height:1.5715;border:none;background-color:transparent;color:#fff}.easy-email-extensions-divider{position:relative;display:inline-flex;width:1px;height:16px;background-color:#808080e6}\n";
41200
+ function RichTextToolBar() {
41201
+ const [direction, setDirection] = useState("top");
41202
+ const [blockNode, setBlockNode] = useState(null);
41203
+ const [offsetX, setOffsetX] = useState(0);
41204
+ const { focusBlock: focusBlock2 } = useBlock();
41205
+ const { pageData: pageData2 } = useEditorContext();
41206
+ const { focusIdx: focusIdx2 } = useFocusIdx();
41207
+ const pageWidth = +(pageData2.attributes.width || "600").replace("px", "");
41208
+ useEffect(() => {
41209
+ const promiseObj = awaitForElement(focusIdx2);
41210
+ promiseObj.promise.then((blockNode2) => {
41211
+ setBlockNode(blockNode2);
41212
+ });
41213
+ return () => {
41214
+ promiseObj.cancel();
41215
+ };
41216
+ }, [focusIdx2, focusBlock2]);
41217
+ useEffect(() => {
41218
+ if (blockNode) {
41219
+ const options2 = {
41220
+ rootMargin: "-84px 0px 0px 0px",
41221
+ root: getShadowRoot().firstChild,
41222
+ threshold: [0, 1e-3, 0.1, 0.999, 0.8, 0.9, 1]
41223
+ };
41224
+ const checkDirection = (ev) => {
41225
+ const [current] = ev;
41226
+ const { top } = current.intersectionRect;
41227
+ const boundingClientRect = current.boundingClientRect;
41228
+ const rootBounds = current.rootBounds;
41229
+ const intersectionRatio = current.intersectionRatio;
41230
+ if (!rootBounds)
41231
+ return;
41232
+ const paddingLeft = (rootBounds.width - pageWidth) / 2;
41233
+ const offsetLeft = boundingClientRect.left - rootBounds.left;
41234
+ setOffsetX(paddingLeft - offsetLeft);
41235
+ if (intersectionRatio === 1) {
41236
+ setDirection("top");
41237
+ } else {
41238
+ if (top) {
41239
+ if (top > rootBounds.top) {
41240
+ setDirection("top");
41241
+ } else {
41242
+ setDirection("bottom");
41243
+ }
41244
+ }
41245
+ }
41246
+ };
41247
+ const observer = new IntersectionObserver(checkDirection, options2);
41248
+ observer.observe(blockNode);
41249
+ return () => {
41250
+ observer.unobserve(blockNode);
41251
+ };
41252
+ }
41253
+ }, [blockNode, pageWidth]);
41254
+ if (!blockNode)
41255
+ return null;
41256
+ const editorContainer = blockNode && getEditNode(blockNode);
41257
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, createPortal(/* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("style", {
41258
+ dangerouslySetInnerHTML: { __html: styleText }
41259
+ }), /* @__PURE__ */ React__default.createElement("div", {
41260
+ style: {
41261
+ transform: direction === "top" ? "translate(0,-100%)" : void 0,
41262
+ padding: "4px 8px",
41263
+ boxSizing: "border-box",
41264
+ position: "absolute",
41265
+ zIndex: 100,
41266
+ top: direction === "top" ? -40 : "calc(100% + 40px)",
41267
+ left: offsetX,
41268
+ width: pageWidth
41269
+ }
41270
+ }, /* @__PURE__ */ React__default.createElement("div", {
41271
+ style: {
41272
+ position: "absolute",
41273
+ backgroundColor: "#41444d",
41274
+ height: "100%",
41275
+ width: "100%",
41276
+ left: 0,
41277
+ top: 0
41278
+ }
41279
+ }), /* @__PURE__ */ React__default.createElement(Tools, {
41280
+ container: editorContainer,
41281
+ onChange: () => {
41282
+ }
41283
+ }))), blockNode));
41284
+ }
41285
+ const RichTextField = (props) => {
41286
+ const { focusBlock: focusBlock2 } = useBlock();
41287
+ const { focusIdx: focusIdx2 } = useFocusIdx();
41288
+ if ((focusBlock2 == null ? void 0 : focusBlock2.type) !== BasicType.TEXT)
41289
+ return null;
41290
+ const name = `${focusIdx2}.data.value.content`;
41291
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(RichTextToolBar, null), /* @__PURE__ */ React__default.createElement(Field, {
41292
+ name,
41293
+ parse: (v) => v
41294
+ }, ({ input }) => /* @__PURE__ */ React__default.createElement(FieldWrapper, __spreadProps(__spreadValues({}, props), {
41295
+ input
41296
+ }))));
41297
+ };
41298
+ function FieldWrapper(props) {
41299
+ const _a = props, { input } = _a, rest = __objRest(_a, ["input"]);
41300
+ const debounceCallbackChange = useCallback(lodash.exports.debounce((val) => {
41301
+ input.onChange(val);
41302
+ }, 500), [input]);
41303
+ return /* @__PURE__ */ React__default.createElement(InlineText, __spreadProps(__spreadValues({}, rest), {
41304
+ onChange: debounceCallbackChange
41305
+ }));
41306
+ }
41307
+ const TextField = enhancer(Input, (value) => value);
41308
+ const SearchField = enhancer(Input$5.Search, (val) => val);
41309
+ const TextAreaField = enhancer(Input$5.TextArea, (val) => val);
41310
+ const NumberField = enhancer(InputNumber$1, (e) => e);
41311
+ const SliderField = enhancer(Slider$2, (e) => e);
41312
+ const ColorPickerField = enhancer(ColorPicker, (e) => e);
41313
+ const UploadField = enhancer(UploadField$1, (val) => val);
41314
+ const ImageUploaderField = enhancer(ImageUploader, (url) => url);
41315
+ const SelectField = enhancer(Select, (e) => e);
41316
+ const AutoCompleteField = enhancer(AutoComplete, (e) => e);
41317
+ const RadioGroupField = enhancer(RadioGroup, (value) => value);
41318
+ const SwitchField = enhancer(Switch$1, (e) => e);
41319
+ const DatePickerField = enhancer(DatePicker$1, (date) => date);
41320
+ const CheckboxField = enhancer(CheckBoxGroup, (e) => e);
41321
+ const EditTabField = enhancer(EditTab, (e) => e);
41322
+ const InlineTextField = enhancer(InlineText, (value) => value);
41323
+ const AddToCollection = ({ visible, setVisible }) => {
41324
+ const { focusBlock: focusBlockData } = useBlock();
41325
+ const { onAddCollection, onUploadImage } = useEditorProps();
41326
+ const onSubmit = (values2) => {
41327
+ if (!values2.label)
41328
+ return;
41329
+ const uuid2 = uuid_1.v4();
41330
+ onAddCollection == null ? void 0 : onAddCollection({
41331
+ label: values2.label,
41332
+ helpText: values2.helpText,
41333
+ data: focusBlockData,
41334
+ thumbnail: values2.thumbnail,
41335
+ id: uuid2
41336
+ });
41337
+ setVisible(false);
41338
+ };
41339
+ return /* @__PURE__ */ React__default.createElement(Form$3, {
41340
+ initialValues: { label: "", helpText: "", thumbnail: "" },
41341
+ onSubmit
41342
+ }, ({ handleSubmit }) => /* @__PURE__ */ React__default.createElement(Modal$1, {
41343
+ maskClosable: false,
41344
+ style: { zIndex: 2e3 },
41345
+ visible,
41346
+ title: "Add to collection",
41347
+ onOk: () => handleSubmit(),
41348
+ onCancel: () => setVisible(false)
41349
+ }, /* @__PURE__ */ React__default.createElement(Stack$6, {
41350
+ vertical: true
41351
+ }, /* @__PURE__ */ React__default.createElement(Stack$6.Item, null), /* @__PURE__ */ React__default.createElement(TextField, {
41352
+ label: "Title",
41353
+ name: "label",
41354
+ validate: (val) => {
41355
+ if (!val)
41356
+ return "Title required!";
41357
+ return void 0;
41358
+ }
41359
+ }), /* @__PURE__ */ React__default.createElement(TextAreaField, {
41360
+ label: "Description",
41361
+ name: "helpText"
41362
+ }), /* @__PURE__ */ React__default.createElement(ImageUploaderField, {
41363
+ label: "Thumbnail",
41364
+ name: "thumbnail",
41365
+ uploadHandler: onUploadImage,
41366
+ validate: (val) => {
41367
+ if (!val)
41368
+ return "Thumbnail required!";
41369
+ return void 0;
41370
+ }
41371
+ }))));
41372
+ };
41373
+ function useAddToCollection() {
41374
+ const [modalVisible, setModalVisible] = useState(false);
41375
+ const modal = useMemo(() => /* @__PURE__ */ React__default.createElement(AddToCollection, {
41376
+ visible: modalVisible,
41377
+ setVisible: setModalVisible
41378
+ }), [modalVisible]);
41379
+ return {
41380
+ modal,
41381
+ modalVisible,
41382
+ setModalVisible
41383
+ };
41384
+ }
41385
+ function ContextMenu({
41386
+ moveBlock,
41387
+ copyBlock,
41388
+ removeBlock,
41389
+ contextMenuData,
41390
+ onClose
41391
+ }) {
41392
+ const { blockData, left, top } = contextMenuData;
41393
+ const idx = blockData.id;
41394
+ const { modal, modalVisible, setModalVisible } = useAddToCollection();
41395
+ const ref = useRef(null);
41396
+ const handleMoveUp = () => {
41397
+ moveBlock(idx, getSiblingIdx(idx, -1));
41398
+ scrollBlockEleIntoView({
41399
+ idx: getSiblingIdx(idx, -1)
41400
+ });
41401
+ onClose();
41402
+ };
41403
+ const handleMoveDown = () => {
41404
+ moveBlock(idx, getSiblingIdx(idx, 1));
41405
+ scrollBlockEleIntoView({
41406
+ idx: getSiblingIdx(idx, 1)
41407
+ });
41408
+ onClose();
41409
+ };
41410
+ const handleCopy = (ev) => {
41411
+ copyBlock(idx);
41412
+ scrollBlockEleIntoView({
41413
+ idx: getSiblingIdx(idx, 1)
41414
+ });
41415
+ onClose();
41416
+ };
41417
+ const handleAddToCollection = () => {
41418
+ setModalVisible(true);
41419
+ };
41420
+ const handleDelete = () => {
41421
+ removeBlock(idx);
41422
+ onClose();
41423
+ };
41424
+ const isFirst = getIndexByIdx(idx) === 0;
41425
+ return /* @__PURE__ */ React__default.createElement("div", {
41426
+ ref,
41427
+ style: { visibility: modalVisible ? "hidden" : void 0 }
41428
+ }, /* @__PURE__ */ React__default.createElement("div", {
41429
+ style: {
41430
+ left,
41431
+ top
41432
+ },
41433
+ className: styles$5.wrap,
41434
+ onClick: (e) => e.stopPropagation()
41435
+ }, !isFirst && /* @__PURE__ */ React__default.createElement("div", {
41436
+ className: styles$5.listItem,
41437
+ onClick: handleMoveUp
41438
+ }, /* @__PURE__ */ React__default.createElement(IconFont, {
41439
+ iconName: "icon-top",
41440
+ style: { marginRight: 10 }
41441
+ }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Move up")), /* @__PURE__ */ React__default.createElement("div", {
41442
+ className: styles$5.listItem,
41443
+ onClick: handleMoveDown
41444
+ }, /* @__PURE__ */ React__default.createElement(IconFont, {
41445
+ iconName: "icon-bottom",
41446
+ style: { marginRight: 10 }
41447
+ }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Move down")), /* @__PURE__ */ React__default.createElement("div", {
41448
+ className: styles$5.listItem,
41449
+ onClick: handleCopy
41450
+ }, /* @__PURE__ */ React__default.createElement(IconFont, {
41451
+ iconName: "icon-copy",
41452
+ style: { marginRight: 10 }
41453
+ }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Copy")), /* @__PURE__ */ React__default.createElement("div", {
41454
+ className: styles$5.listItem,
41455
+ onClick: handleAddToCollection
41456
+ }, /* @__PURE__ */ React__default.createElement(IconFont, {
41457
+ iconName: "icon-start",
41458
+ style: { marginRight: 10 }
41459
+ }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Add to collection")), /* @__PURE__ */ React__default.createElement("div", {
41460
+ className: styles$5.listItem,
41461
+ onClick: handleDelete
41462
+ }, /* @__PURE__ */ React__default.createElement(IconFont, {
41463
+ iconName: "icon-delete",
41464
+ style: { marginRight: 10 }
41465
+ }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Delete")), /* @__PURE__ */ React__default.createElement("div", {
41466
+ className: styles$5.listItem,
41467
+ onClick: handleAddToCollection
41468
+ }, /* @__PURE__ */ React__default.createElement(IconFont, {
41469
+ iconName: "icon-start",
41470
+ style: { marginRight: 10 }
41471
+ }), " ", /* @__PURE__ */ React__default.createElement(TextStyle, null, "Add to collection"))), /* @__PURE__ */ React__default.createElement("div", {
41472
+ className: styles$5.contextmenuMark,
41473
+ onClick: onClose,
41474
+ onContextMenu: (e) => {
41475
+ e.preventDefault();
41476
+ onClose(e);
41477
+ }
41478
+ }), modal);
41479
+ }
41480
+ function useAvatarWrapperDrop() {
41481
+ const [blockLayerRef, setBlockLayerRef] = useState(null);
41482
+ const { setHoverIdx, setDirection } = useHoverIdx();
41483
+ const { dataTransfer, setDataTransfer } = useDataTransfer();
41484
+ const {
41485
+ formState: { values: values2 }
41486
+ } = useEditorContext();
41487
+ const valuesRef = useRef(values2);
41488
+ const dataTransferRef = useRef(dataTransfer);
41489
+ useEffect(() => {
41490
+ valuesRef.current = values2;
41491
+ }, [values2]);
41492
+ useEffect(() => {
41493
+ dataTransferRef.current = dataTransfer;
41494
+ }, [dataTransfer]);
41495
+ function isKeyObject(o) {
41496
+ return o.key !== void 0;
41497
+ }
41498
+ const removeHightLightClassName = useCallback(() => {
41499
+ if (!blockLayerRef)
41500
+ return;
41501
+ blockLayerRef.querySelectorAll(".arco-tree-node-title-gap-top, .arco-tree-node-title-gap-bottom, .arco-tree-node-title-highlight").forEach((item2) => {
41502
+ item2.classList.remove("arco-tree-node-title-gap-top", "arco-tree-node-title-gap-bottom", "arco-tree-node-title-highlight");
41503
+ });
41504
+ }, [blockLayerRef]);
41505
+ const allowDrop = useCallback((params) => {
41506
+ const { dragNode, dropNode, dropPosition } = params;
41507
+ let dragType;
41508
+ if (isKeyObject(dragNode)) {
41509
+ const blockData = lodash.exports.get(valuesRef.current, dragNode.key);
41510
+ if (!blockData)
41511
+ return false;
41512
+ dragType = blockData.type;
41513
+ } else {
41514
+ dragType = dragNode.type;
41515
+ }
41516
+ const dragBlock = BlockManager.getBlockByType(dragType);
41517
+ if (!dragBlock)
41518
+ return false;
41519
+ if (dropPosition === 0) {
41520
+ if (dragBlock.validParentType.includes(dropNode.dataRef.type) && dropNode.dataRef.children.length === 0) {
41521
+ return {
41522
+ position: 0,
41523
+ key: dropNode.key
41524
+ };
41525
+ } else if (dropNode.parent && dragBlock.validParentType.includes(dropNode.parent.type)) {
41526
+ return {
41527
+ position: -1,
41528
+ key: dropNode.key
41529
+ };
41530
+ }
41531
+ } else {
41532
+ if (dropNode.parent && dragBlock.validParentType.includes(dropNode.parent.type)) {
41533
+ return {
41534
+ position: dropPosition,
41535
+ key: dropNode.key
41536
+ };
41537
+ }
41538
+ }
41539
+ setDirection("");
41540
+ setHoverIdx("");
41541
+ return false;
41542
+ }, [setDirection, setHoverIdx, removeHightLightClassName]);
41543
+ useEffect(() => {
41544
+ if (blockLayerRef) {
41545
+ const onDragOver = lodash.exports.debounce((ev) => {
41546
+ var _a, _b, _c, _d;
41547
+ if (!dataTransferRef.current)
41548
+ return;
41549
+ const blockNode = getBlockNodeByChildEle(ev.target);
41550
+ if (!blockNode || !ev.target)
41551
+ return;
41552
+ const directionPosition = getDirectionPosition(ev, 5);
41553
+ const treeNodeEle = (_b = (_a = blockNode.parentNode) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.parentNode;
41554
+ if (!treeNodeEle)
41555
+ return;
41556
+ removeHightLightClassName();
41557
+ const dropIdx = getNodeIdxFromClassName(blockNode.classList);
41558
+ if (!dropIdx)
41559
+ return;
41560
+ const dropParentIdx = getParentIdx(dropIdx);
41561
+ const dropBlockData = lodash.exports.get(valuesRef.current, dropIdx);
41562
+ const dropParentBlockData = dropParentIdx ? lodash.exports.get(valuesRef.current, dropParentIdx) : null;
41563
+ let dropPosition = 0;
41564
+ if (directionPosition.vertical.direction === "top" && directionPosition.vertical.isEdge) {
41565
+ dropPosition = -1;
41566
+ } else if (directionPosition.vertical.direction === "bottom" && directionPosition.vertical.isEdge) {
41567
+ dropPosition = 1;
41568
+ }
41569
+ const dropResult = allowDrop({
41570
+ dragNode: {
41571
+ type: dataTransferRef.current.type
41572
+ },
41573
+ dropNode: {
41574
+ dataRef: dropBlockData,
41575
+ key: dropIdx,
41576
+ parent: dropParentBlockData
41577
+ },
41578
+ dropPosition
41579
+ });
41580
+ if (!dropResult)
41581
+ return;
41582
+ const node = (_d = (_c = document.querySelector(`[data-tree-idx="${dropResult.key}"]`)) == null ? void 0 : _c.parentNode) == null ? void 0 : _d.parentNode;
41583
+ if (node instanceof HTMLElement) {
41584
+ removeHightLightClassName();
41585
+ node.classList.add("arco-tree-node-title-gap-bottom");
41586
+ }
41587
+ setDirection(getDirectionFormDropPosition(dropResult.position));
41588
+ setHoverIdx(dropResult.key);
41589
+ if (dropResult.position === -1) {
41590
+ treeNodeEle.classList.add("arco-tree-node-title-gap-top");
41591
+ setDataTransfer((dataTransfer2) => {
41592
+ return __spreadProps(__spreadValues({}, dataTransfer2), {
41593
+ parentIdx: dropParentIdx,
41594
+ positionIndex: getIndexByIdx(dropIdx)
41595
+ });
41596
+ });
41597
+ } else if (dropResult.position === 1) {
41598
+ setDataTransfer((dataTransfer2) => {
41599
+ return __spreadProps(__spreadValues({}, dataTransfer2), {
41600
+ parentIdx: dropParentIdx,
41601
+ positionIndex: getIndexByIdx(dropIdx) + 1
41602
+ });
41603
+ });
41604
+ treeNodeEle.classList.add("arco-tree-node-title-gap-bottom");
41605
+ } else {
41606
+ treeNodeEle.classList.add("arco-tree-node-title-highlight");
41607
+ setDataTransfer((dataTransfer2) => {
41608
+ return __spreadProps(__spreadValues({}, dataTransfer2), {
41609
+ parentIdx: getIndexByIdx(dropIdx),
41610
+ positionIndex: 0
41611
+ });
41612
+ });
41613
+ }
41614
+ });
41615
+ const onDragend = (ev) => {
41616
+ removeHightLightClassName();
41617
+ };
41618
+ const onDrop = (ev) => {
41619
+ setTimeout(() => {
41620
+ removeHightLightClassName();
41621
+ }, 0);
41622
+ };
41623
+ blockLayerRef.addEventListener("dragover", onDragOver);
41624
+ blockLayerRef.addEventListener("drop", onDrop);
41625
+ blockLayerRef.addEventListener("dragleave", onDragend);
41626
+ return () => {
41627
+ blockLayerRef.removeEventListener("dragover", onDragOver);
41628
+ blockLayerRef.removeEventListener("drop", onDrop);
41629
+ blockLayerRef.removeEventListener("dragleave", onDragend);
41630
+ };
41631
+ }
41632
+ }, [blockLayerRef, dataTransferRef, valuesRef, removeHightLightClassName]);
41633
+ return {
41634
+ setBlockLayerRef,
41635
+ blockLayerRef,
41636
+ allowDrop,
41637
+ removeHightLightClassName
41638
+ };
41639
+ }
41640
+ function getDirectionFormDropPosition(position) {
41641
+ if (position === -1)
41642
+ return "top";
41643
+ if (position === 1)
41644
+ return "bottom";
41645
+ return "";
41646
+ }
41647
+ function BlockLayer() {
41648
+ const {
41649
+ pageData: pageData2,
41650
+ formState: { values: values2 }
41651
+ } = useEditorContext();
41652
+ const { onUploadImage, onAddCollection } = useEditorProps();
41653
+ const { focusIdx: focusIdx2, setFocusIdx } = useFocusIdx();
41654
+ const { setHoverIdx, setIsDragging, setDirection } = useHoverIdx();
41655
+ const { moveBlock, setValueByIdx: setValueByIdx2, copyBlock, removeBlock } = useBlock();
41656
+ const {
41657
+ setBlockLayerRef,
41658
+ allowDrop,
41659
+ blockLayerRef,
41660
+ removeHightLightClassName
41661
+ } = useAvatarWrapperDrop();
41662
+ const [contextMenuData, setContextMenuData] = useState(null);
41663
+ const onToggleVisible = useCallback(({ id }, e) => {
41664
+ e.stopPropagation();
41665
+ const blockData = lodash.exports.get(values2, id);
41666
+ if (blockData) {
41667
+ blockData.data.hidden = !Boolean(blockData.data.hidden);
41668
+ setValueByIdx2(id, blockData);
41669
+ }
41670
+ }, [setValueByIdx2, values2]);
41671
+ const renderTitle = useCallback((data) => {
41672
+ const block2 = BlockManager.getBlockByType(data.type);
41673
+ const isPage = data.type === BasicType.PAGE;
41674
+ return /* @__PURE__ */ React__default.createElement("div", {
41675
+ "data-tree-idx": data.id,
41676
+ className: classnames(styles$6.title, !isPage && getNodeIdxClassName(data.id), !isPage && "email-block")
41677
+ }, /* @__PURE__ */ React__default.createElement(TextStyle, {
41678
+ size: "smallest"
41679
+ }, block2 == null ? void 0 : block2.name), /* @__PURE__ */ React__default.createElement("div", {
41680
+ className: styles$6.eyeIcon
41681
+ }, /* @__PURE__ */ React__default.createElement(EyeIcon$1, {
41682
+ blockData: data,
41683
+ onToggleVisible
41684
+ })));
41685
+ }, [onToggleVisible]);
41686
+ const treeData = useMemo(() => {
41687
+ const copyData = lodash.exports.cloneDeep(pageData2);
41688
+ const loop2 = (item2, id, parent2) => {
41689
+ item2.id = id;
41690
+ item2.parent = parent2;
41691
+ item2.children.map((child, index2) => loop2(child, getChildIdx(id, index2), item2));
41692
+ };
41693
+ loop2(copyData, getPageIdx(), null);
41694
+ return [copyData];
41695
+ }, [pageData2]);
41696
+ const onSelect = useCallback((selectedId) => {
41697
+ setFocusIdx(selectedId);
41698
+ scrollBlockEleIntoView({ idx: selectedId });
41699
+ }, [setFocusIdx]);
41700
+ const onContextMenu = useCallback((blockData, ev) => {
41701
+ ev.preventDefault();
41702
+ setContextMenuData({ blockData, left: ev.clientX, top: ev.clientY });
41703
+ }, []);
41704
+ const onCloseContextMenu = useCallback((ev) => {
41705
+ setContextMenuData(null);
41706
+ }, []);
41707
+ const onMouseEnter = useCallback((id) => {
41708
+ setHoverIdx(id);
41709
+ }, [setHoverIdx]);
41710
+ const onMouseLeave = useCallback(() => {
41711
+ setHoverIdx("");
41712
+ }, [setHoverIdx]);
41713
+ const onDragStart = useCallback(() => {
41714
+ setIsDragging(true);
41715
+ }, [setIsDragging]);
41716
+ const onDragEnd = useCallback(() => {
41717
+ setIsDragging(false);
41718
+ }, [setIsDragging]);
41719
+ const onDrop = useCallback((params) => {
41720
+ const { dragNode, dropNode, dropPosition } = params;
41721
+ const dragBlock = BlockManager.getBlockByType(dragNode.dataRef.type);
41722
+ if (!dragBlock)
41723
+ return false;
41724
+ const dropIndex = getIndexByIdx(dropNode.key);
41725
+ if (dropPosition === 0) {
41726
+ if (dragBlock.validParentType.includes(dropNode.dataRef.type) && dropNode.dataRef.children.length === 0) {
41727
+ moveBlock(dragNode.key, getChildIdx(dropNode.key, 0));
41728
+ } else if (dropNode.parent && dragBlock.validParentType.includes(dropNode.parent.type)) {
41729
+ moveBlock(dragNode.key, getChildIdx(dropNode.parentKey, dropIndex));
41730
+ }
41731
+ } else {
41732
+ moveBlock(dragNode.key, getChildIdx(dropNode.parentKey, dropPosition > 0 ? dropIndex + 1 : dropIndex));
41733
+ }
41734
+ }, [moveBlock]);
41735
+ useEffect(() => {
41736
+ if (!blockLayerRef)
41737
+ return;
41738
+ if (focusIdx2) {
41739
+ setTimeout(() => {
41740
+ const selectedNode = blockLayerRef.querySelector(`[${DATA_ATTRIBUTE_ID}="${focusIdx2}"]`);
41741
+ if (selectedNode) {
41742
+ selectedNode.scrollIntoView({
41743
+ block: "center",
41744
+ behavior: "smooth"
41745
+ });
41746
+ }
41747
+ }, 50);
41748
+ }
41749
+ }, [blockLayerRef, focusIdx2]);
41750
+ const blockTreeAllowDrop = useCallback((data) => {
41751
+ var _a, _b;
41752
+ const dropResult = allowDrop(data);
41753
+ if (dropResult) {
41754
+ const node = (_b = (_a = document.querySelector(`[data-tree-idx="${dropResult.key}"]`)) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.parentNode;
41755
+ if (node instanceof HTMLElement) {
41756
+ removeHightLightClassName();
41757
+ node.classList.add("arco-tree-node-title-gap-bottom");
41758
+ }
41759
+ setDirection(getDirectionFormDropPosition(dropResult.position));
41760
+ setHoverIdx(dropResult.key);
41761
+ }
41762
+ return dropResult;
41763
+ }, [allowDrop]);
41764
+ const hasFocus = Boolean(focusIdx2);
41765
+ return useMemo(() => {
41766
+ if (!hasFocus)
41767
+ return null;
41768
+ return /* @__PURE__ */ React__default.createElement("div", __spreadValues({
41769
+ ref: setBlockLayerRef,
41770
+ id: "BlockLayerManager"
41771
+ }, {
41772
+ [DATA_ATTRIBUTE_DROP_CONTAINER]: "true"
41773
+ }), /* @__PURE__ */ React__default.createElement(BlockTree, {
41774
+ selectedId: focusIdx2,
41775
+ defaultExpandAll: true,
41776
+ treeData,
41777
+ renderTitle,
41778
+ allowDrop: blockTreeAllowDrop,
41779
+ onContextMenu,
41780
+ onDrop,
41781
+ onDragStart,
41782
+ onDragEnd,
41783
+ onSelect,
41784
+ onMouseEnter,
41785
+ onMouseLeave
41786
+ }), contextMenuData && /* @__PURE__ */ React__default.createElement(ContextMenu, {
41787
+ onClose: onCloseContextMenu,
41788
+ moveBlock,
41789
+ copyBlock,
41790
+ removeBlock,
41791
+ contextMenuData
41792
+ }));
41793
+ }, [
41794
+ hasFocus,
41795
+ focusIdx2,
41796
+ treeData,
41797
+ renderTitle,
41798
+ allowDrop,
41799
+ onContextMenu,
41800
+ onDrop,
41801
+ onSelect,
41802
+ onMouseEnter,
41803
+ onMouseLeave,
41804
+ contextMenuData,
41805
+ onCloseContextMenu,
41806
+ onUploadImage,
41807
+ onAddCollection,
41808
+ moveBlock,
41809
+ copyBlock,
41810
+ removeBlock,
41811
+ onDragEnd,
41812
+ onDragStart
41813
+ ]);
41814
+ }
41854
41815
  const BlocksPanel$1 = "_BlocksPanel_15fho_1";
41855
41816
  const blockItem = "_blockItem_15fho_5";
41856
41817
  const closeBtn = "_closeBtn_15fho_12";