easy-email-extensions 3.1.38 → 3.1.46

Sign up to get free protection for your applications and to get access to all the features.
package/License ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021-2022 AfterShip
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -7,4 +7,7 @@ export interface IBlockDataWithId extends IBlockData {
7
7
  children: IBlockDataWithId[];
8
8
  className?: string;
9
9
  }
10
- export declare function BlockLayer(): JSX.Element | null;
10
+ export interface BlockLayerProps {
11
+ renderTitle?: (block: IBlockDataWithId) => React.ReactNode;
12
+ }
13
+ export declare function BlockLayer(props: BlockLayerProps): JSX.Element | null;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { BlockLayerProps } from '../BlockLayer';
2
3
  export declare const SimpleLayout: React.FC<{
3
4
  showSourceCode?: boolean;
4
- }>;
5
+ } & BlockLayerProps>;
package/lib/index2.js CHANGED
@@ -38305,12 +38305,17 @@ const PresetColorsProvider = (props) => {
38305
38305
  setCurrentColors(newColors);
38306
38306
  }
38307
38307
  }, [currentColors, setCurrentColors]);
38308
- return /* @__PURE__ */ React__default.createElement(PresetColorsContext.Provider, {
38309
- value: {
38308
+ const value = useMemo(() => {
38309
+ return {
38310
38310
  colors: currentColors,
38311
38311
  addCurrentColor
38312
- }
38313
- }, props.children);
38312
+ };
38313
+ }, [addCurrentColor, currentColors]);
38314
+ return useMemo(() => {
38315
+ return /* @__PURE__ */ React__default.createElement(PresetColorsContext.Provider, {
38316
+ value
38317
+ }, props.children);
38318
+ }, [props.children, value]);
38314
38319
  };
38315
38320
  function ColorPicker(props) {
38316
38321
  const { colors: presetColors, addCurrentColor } = useContext(PresetColorsContext);
@@ -40265,7 +40270,6 @@ const MergeTags = React__default.memo((props) => {
40265
40270
  const value = lodash.exports.get(contextMergeTags, key);
40266
40271
  if (lodash.exports.isObject(value)) {
40267
40272
  setExpandedKeys((keys2) => {
40268
- console.log("keys", keys2, key);
40269
40273
  if (keys2.includes(key)) {
40270
40274
  return keys2.filter((k) => k !== key);
40271
40275
  } else {
@@ -40274,7 +40278,7 @@ const MergeTags = React__default.memo((props) => {
40274
40278
  });
40275
40279
  return;
40276
40280
  }
40277
- return props.onChange(mergeTagGenerate(value));
40281
+ return props.onChange(mergeTagGenerate(key));
40278
40282
  }, [contextMergeTags, props, mergeTagGenerate]);
40279
40283
  const mergeTagContent = useMemo(() => renderMergeTagContent ? renderMergeTagContent({
40280
40284
  onChange: props.onChange,
@@ -41315,6 +41319,40 @@ class BlockAttributeConfigurationManager {
41315
41319
  }
41316
41320
  }
41317
41321
  __publicField(BlockAttributeConfigurationManager, "map", __spreadValues({}, blocks));
41322
+ const SelectionRangeContext = React__default.createContext({
41323
+ selectionRange: null,
41324
+ setSelectionRange: () => {
41325
+ }
41326
+ });
41327
+ const SelectionRangeProvider = (props) => {
41328
+ const [selectionRange, setSelectionRange] = useState(null);
41329
+ useEffect(() => {
41330
+ const onSelectionChange = () => {
41331
+ try {
41332
+ const range2 = getShadowRoot().getSelection().getRangeAt(0);
41333
+ if (range2) {
41334
+ setSelectionRange(range2);
41335
+ }
41336
+ } catch (error2) {
41337
+ }
41338
+ };
41339
+ document.addEventListener("selectionchange", onSelectionChange);
41340
+ return () => {
41341
+ document.removeEventListener("selectionchange", onSelectionChange);
41342
+ };
41343
+ }, []);
41344
+ const value = useMemo(() => {
41345
+ return {
41346
+ selectionRange,
41347
+ setSelectionRange
41348
+ };
41349
+ }, [selectionRange]);
41350
+ return useMemo(() => {
41351
+ return /* @__PURE__ */ React__default.createElement(SelectionRangeContext.Provider, {
41352
+ value
41353
+ }, props.children);
41354
+ }, [props.children, value]);
41355
+ };
41318
41356
  function AttributePanel() {
41319
41357
  const { values: values2, focusBlock: focusBlock2 } = useBlock();
41320
41358
  const { initialized } = useEditorContext();
@@ -41324,7 +41362,7 @@ function AttributePanel() {
41324
41362
  const shadowRoot = getShadowRoot();
41325
41363
  if (!value || !initialized)
41326
41364
  return null;
41327
- return /* @__PURE__ */ React__default.createElement(PresetColorsProvider, null, Com ? /* @__PURE__ */ React__default.createElement(Com, {
41365
+ return /* @__PURE__ */ React__default.createElement(SelectionRangeProvider, null, /* @__PURE__ */ React__default.createElement(PresetColorsProvider, null, Com ? /* @__PURE__ */ React__default.createElement(Com, {
41328
41366
  key: focusIdx2
41329
41367
  }) : /* @__PURE__ */ React__default.createElement("div", {
41330
41368
  style: { marginTop: 200, padding: "0 50px" }
@@ -41340,27 +41378,10 @@ function AttributePanel() {
41340
41378
  outline: none;
41341
41379
  cursor: text;
41342
41380
  }
41343
- `), shadowRoot));
41381
+ `), shadowRoot)));
41344
41382
  }
41345
- function Tools(props) {
41346
- const { container: container2 } = props;
41347
- const { mergeTags: mergeTags2 } = useEditorProps();
41348
- const [selectionRange, setSelectionRange] = useState(null);
41349
- useEffect(() => {
41350
- const onSelectionChange = () => {
41351
- try {
41352
- const range2 = getShadowRoot().getSelection().getRangeAt(0);
41353
- if (range2) {
41354
- setSelectionRange(range2);
41355
- }
41356
- } catch (error2) {
41357
- }
41358
- };
41359
- document.addEventListener("selectionchange", onSelectionChange);
41360
- return () => {
41361
- document.removeEventListener("selectionchange", onSelectionChange);
41362
- };
41363
- }, []);
41383
+ function useSelectionRange() {
41384
+ const { selectionRange, setSelectionRange } = useContext(SelectionRangeContext);
41364
41385
  const restoreRange = useCallback((range2) => {
41365
41386
  const selection = getShadowRoot().getSelection();
41366
41387
  selection.removeAllRanges();
@@ -41369,6 +41390,16 @@ function Tools(props) {
41369
41390
  newRange.setEnd(range2.endContainer, range2.endOffset);
41370
41391
  selection.addRange(newRange);
41371
41392
  }, []);
41393
+ return {
41394
+ selectionRange,
41395
+ setSelectionRange,
41396
+ restoreRange
41397
+ };
41398
+ }
41399
+ function Tools(props) {
41400
+ const { container: container2 } = props;
41401
+ const { mergeTags: mergeTags2 } = useEditorProps();
41402
+ const { selectionRange, restoreRange } = useSelectionRange();
41372
41403
  const execCommand = (cmd, val) => {
41373
41404
  if (!container2) {
41374
41405
  console.error("No container");
@@ -41623,6 +41654,7 @@ function FieldWrapper(props) {
41623
41654
  const _a = props, { input } = _a, rest = __objRest(_a, ["input"]);
41624
41655
  const debounceCallbackChange = useCallback(lodash.exports.debounce((val) => {
41625
41656
  input.onChange(val);
41657
+ input.onBlur();
41626
41658
  }, 100), [input]);
41627
41659
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(RichTextToolBar, {
41628
41660
  onChange: debounceCallbackChange
@@ -41983,7 +42015,7 @@ const iconsMap = {
41983
42015
  [BasicType.NAVBAR]: "icon-navbar",
41984
42016
  [BasicType.HERO]: "icon-hero",
41985
42017
  [BasicType.SPACER]: "icon-spacing",
41986
- [BasicType.SOCIAL]: "icon-soc",
42018
+ [BasicType.SOCIAL]: "icon-social",
41987
42019
  [BasicType.CAROUSEL]: "icon-carousel",
41988
42020
  [BasicType.ACCORDION]: "icon-accordion"
41989
42021
  };
@@ -41999,11 +42031,12 @@ function getBlockTitle(blockData, isFromContent = true) {
41999
42031
  tempEle.innerHTML = blockData.data.value.content;
42000
42032
  return tempEle.innerText;
42001
42033
  }
42002
- const blockName = (_a = BlockManager.getBlockByType(blockData.type)) == null ? void 0 : _a.name;
42034
+ const blockName = ((_a = BlockManager.getBlockByType(blockData.type)) == null ? void 0 : _a.name) || "";
42003
42035
  return blockName;
42004
42036
  }
42005
- function BlockLayer() {
42037
+ function BlockLayer(props) {
42006
42038
  const { pageData: pageData2 } = useEditorContext();
42039
+ const { renderTitle: propsRenderTitle } = props;
42007
42040
  const { focusIdx: focusIdx2, setFocusIdx } = useFocusIdx();
42008
42041
  const { setHoverIdx, setIsDragging, setDirection } = useHoverIdx();
42009
42042
  const { moveBlock, setValueByIdx: setValueByIdx2, copyBlock, removeBlock, values: values2 } = useBlock();
@@ -42020,7 +42053,7 @@ function BlockLayer() {
42020
42053
  }, [setValueByIdx2, valueRef]);
42021
42054
  const renderTitle = useCallback((data) => {
42022
42055
  const isPage = data.type === BasicType.PAGE;
42023
- const title2 = getBlockTitle(data);
42056
+ const title2 = propsRenderTitle ? propsRenderTitle(data) : getBlockTitle(data);
42024
42057
  return /* @__PURE__ */ React__default.createElement("div", {
42025
42058
  "data-tree-idx": data.id,
42026
42059
  className: classnames(styles$6.title, !isPage && getNodeIdxClassName(data.id), !isPage && "email-block")
@@ -42031,7 +42064,7 @@ function BlockLayer() {
42031
42064
  iconName: getIconNameByBlockType(data.type),
42032
42065
  style: { fontSize: 12, color: "#999" }
42033
42066
  }), /* @__PURE__ */ React__default.createElement("div", {
42034
- title: title2,
42067
+ title: lodash.exports.isString(title2) ? title2 : "",
42035
42068
  style: { overflow: "hidden", whiteSpace: "nowrap", width: "5em" }
42036
42069
  }, /* @__PURE__ */ React__default.createElement(TextStyle, {
42037
42070
  size: "smallest"
@@ -42041,7 +42074,7 @@ function BlockLayer() {
42041
42074
  blockData: data,
42042
42075
  onToggleVisible
42043
42076
  })));
42044
- }, [onToggleVisible]);
42077
+ }, [onToggleVisible, propsRenderTitle]);
42045
42078
  const treeData = useMemo(() => {
42046
42079
  const copyData = lodash.exports.cloneDeep(pageData2);
42047
42080
  const loop2 = (item2, id, parent2) => {
@@ -45175,7 +45208,9 @@ const SimpleLayout = (props) => {
45175
45208
  }, /* @__PURE__ */ React__default.createElement(Card$1, {
45176
45209
  title: "Layout",
45177
45210
  style: { border: "none" }
45178
- }, /* @__PURE__ */ React__default.createElement(BlockLayer, null))))), /* @__PURE__ */ React__default.createElement(Layout$1, {
45211
+ }, /* @__PURE__ */ React__default.createElement(BlockLayer, {
45212
+ renderTitle: props.renderTitle
45213
+ }))))), /* @__PURE__ */ React__default.createElement(Layout$1, {
45179
45214
  style: { height: containerHeight }
45180
45215
  }, props.children), /* @__PURE__ */ React__default.createElement(Layout$1.Sider, {
45181
45216
  style: {