easy-email-extensions 3.1.39 → 3.1.47

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.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useBlock } from '../../../../easy-email-editor';
2
+ import { useBlock } from 'easy-email-editor';
3
3
  import { IBlockDataWithId } from '../../../BlockLayer';
4
4
  export declare function ContextMenu({ moveBlock, copyBlock, removeBlock, contextMenuData, onClose, }: {
5
5
  onClose: (ev?: React.MouseEvent) => void;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { IBlockData } from '../../easy-email-core';
2
+ import { IBlockData } from 'easy-email-core';
3
3
  export interface IBlockDataWithId extends IBlockData {
4
4
  id: string;
5
5
  icon?: React.ReactElement;
@@ -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,5 +1,5 @@
1
1
  import React from 'react';
2
- import { BlockType } from '../../../../easy-email-core';
2
+ import { BlockType } from 'easy-email-core';
3
3
  export declare const BlockMaskWrapper: React.FC<{
4
4
  type: BlockType | string;
5
5
  payload: any;
@@ -1,4 +1,4 @@
1
- import { BasicType } from '../../../../../easy-email-core';
1
+ import { BasicType } from 'easy-email-core';
2
2
  import { TextBlockItem } from './TextBlockItem';
3
3
  import { ImageBlockItem } from './ImageBlockItem';
4
4
  export declare const defaultCategories: {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { IBlockData } from '../../../easy-email-core';
2
+ import { IBlockData } from 'easy-email-core';
3
3
  export interface BlockMarketCategory {
4
4
  name: string;
5
5
  title: string;
@@ -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>;
@@ -1,4 +1,4 @@
1
- import { StackProps } from '../../../easy-email-editor';
1
+ import { StackProps } from 'easy-email-editor';
2
2
  import { FieldProps } from 'react-final-form';
3
3
  import React from 'react';
4
4
  import { InputProps } from './Input';
package/lib/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from './SimpleLayout';
8
8
  export * from './components/Form';
9
9
  export { getContextMergeTags } from './utils/getContextMergeTags';
10
10
  export { getIconNameByBlockType } from './utils/getIconNameByBlockType';
11
+ export { getBlockTitle } from './utils/getBlockTitle';
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { d as Align, A as AttributePanel, e as AttributesPanelWrapper, _ as AutoCompleteField, i as Background, l as BackgroundColor, b as BlockAttributeConfigurationManager, B as BlockLayer, w as BlockMarketManager, x as BlockMaskWrapper, o as Border, p as BorderColor, s as BorderStyle, u as BorderWidth, a2 as CheckboxField, C as Color, R as ColorPickerField, f as ContainerBackgroundColor, a1 as DatePickerField, D as Decoration, m as Direction, a3 as EditTabField, F as FontFamily, q as FontSize, t as FontStyle, v as FontWeight, H as Height, X as ImageUploaderField, a4 as InlineTextField, G as InputWithUnitField, I as InteractivePrompt, L as LetterSpacing, j as LineHeight, n as Link, M as Margin, r as MergeTags, N as NavbarLinkPadding, O as NumberField, P as Padding, $ as RadioGroupField, a6 as RichTextField, J as SearchField, Y as SelectField, S as ShortcutToolbar, z as SimpleLayout, Q as SliderField, y as SourceCodePanel, a0 as SwitchField, T as TextAlign, K as TextAreaField, h as TextDecoration, E as TextField, k as TextTransform, Z as TreeSelectField, U as UploadField, V as VerticalAlign, W as Width, a5 as enhancer, g as getContextMergeTags, a as getIconNameByBlockType } from "./index2.js";
1
+ export { e as Align, A as AttributePanel, f as AttributesPanelWrapper, $ as AutoCompleteField, j as Background, m as BackgroundColor, d as BlockAttributeConfigurationManager, B as BlockLayer, x as BlockMarketManager, y as BlockMaskWrapper, p as Border, q as BorderColor, t as BorderStyle, v as BorderWidth, a3 as CheckboxField, C as Color, U as ColorPickerField, h as ContainerBackgroundColor, a2 as DatePickerField, D as Decoration, n as Direction, a4 as EditTabField, F as FontFamily, r as FontSize, u as FontStyle, w as FontWeight, H as Height, Y as ImageUploaderField, a5 as InlineTextField, J as InputWithUnitField, I as InteractivePrompt, L as LetterSpacing, k as LineHeight, o as Link, M as Margin, s as MergeTags, N as NavbarLinkPadding, Q as NumberField, P as Padding, a0 as RadioGroupField, a7 as RichTextField, K as SearchField, Z as SelectField, S as ShortcutToolbar, E as SimpleLayout, R as SliderField, z as SourceCodePanel, a1 as SwitchField, T as TextAlign, O as TextAreaField, i as TextDecoration, G as TextField, l as TextTransform, _ as TreeSelectField, X as UploadField, V as VerticalAlign, W as Width, a6 as enhancer, b as getBlockTitle, g as getContextMergeTags, a as getIconNameByBlockType } from "./index2.js";
2
2
  import "react";
3
3
  import "easy-email-editor";
4
4
  import "easy-email-core";
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");
@@ -41984,7 +42015,7 @@ const iconsMap = {
41984
42015
  [BasicType.NAVBAR]: "icon-navbar",
41985
42016
  [BasicType.HERO]: "icon-hero",
41986
42017
  [BasicType.SPACER]: "icon-spacing",
41987
- [BasicType.SOCIAL]: "icon-soc",
42018
+ [BasicType.SOCIAL]: "icon-social",
41988
42019
  [BasicType.CAROUSEL]: "icon-carousel",
41989
42020
  [BasicType.ACCORDION]: "icon-accordion"
41990
42021
  };
@@ -42000,11 +42031,12 @@ function getBlockTitle(blockData, isFromContent = true) {
42000
42031
  tempEle.innerHTML = blockData.data.value.content;
42001
42032
  return tempEle.innerText;
42002
42033
  }
42003
- 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) || "";
42004
42035
  return blockName;
42005
42036
  }
42006
- function BlockLayer() {
42037
+ function BlockLayer(props) {
42007
42038
  const { pageData: pageData2 } = useEditorContext();
42039
+ const { renderTitle: propsRenderTitle } = props;
42008
42040
  const { focusIdx: focusIdx2, setFocusIdx } = useFocusIdx();
42009
42041
  const { setHoverIdx, setIsDragging, setDirection } = useHoverIdx();
42010
42042
  const { moveBlock, setValueByIdx: setValueByIdx2, copyBlock, removeBlock, values: values2 } = useBlock();
@@ -42021,7 +42053,7 @@ function BlockLayer() {
42021
42053
  }, [setValueByIdx2, valueRef]);
42022
42054
  const renderTitle = useCallback((data) => {
42023
42055
  const isPage = data.type === BasicType.PAGE;
42024
- const title2 = getBlockTitle(data);
42056
+ const title2 = propsRenderTitle ? propsRenderTitle(data) : getBlockTitle(data);
42025
42057
  return /* @__PURE__ */ React__default.createElement("div", {
42026
42058
  "data-tree-idx": data.id,
42027
42059
  className: classnames(styles$6.title, !isPage && getNodeIdxClassName(data.id), !isPage && "email-block")
@@ -42032,7 +42064,7 @@ function BlockLayer() {
42032
42064
  iconName: getIconNameByBlockType(data.type),
42033
42065
  style: { fontSize: 12, color: "#999" }
42034
42066
  }), /* @__PURE__ */ React__default.createElement("div", {
42035
- title: title2,
42067
+ title: lodash.exports.isString(title2) ? title2 : "",
42036
42068
  style: { overflow: "hidden", whiteSpace: "nowrap", width: "5em" }
42037
42069
  }, /* @__PURE__ */ React__default.createElement(TextStyle, {
42038
42070
  size: "smallest"
@@ -42042,7 +42074,7 @@ function BlockLayer() {
42042
42074
  blockData: data,
42043
42075
  onToggleVisible
42044
42076
  })));
42045
- }, [onToggleVisible]);
42077
+ }, [onToggleVisible, propsRenderTitle]);
42046
42078
  const treeData = useMemo(() => {
42047
42079
  const copyData = lodash.exports.cloneDeep(pageData2);
42048
42080
  const loop2 = (item2, id, parent2) => {
@@ -45176,7 +45208,9 @@ const SimpleLayout = (props) => {
45176
45208
  }, /* @__PURE__ */ React__default.createElement(Card$1, {
45177
45209
  title: "Layout",
45178
45210
  style: { border: "none" }
45179
- }, /* @__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, {
45180
45214
  style: { height: containerHeight }
45181
45215
  }, props.children), /* @__PURE__ */ React__default.createElement(Layout$1.Sider, {
45182
45216
  style: {
@@ -45203,5 +45237,5 @@ const SimpleLayout = (props) => {
45203
45237
  title: "Source code"
45204
45238
  }, /* @__PURE__ */ React__default.createElement(SourceCodePanel, null))))), /* @__PURE__ */ React__default.createElement(InteractivePrompt, null)));
45205
45239
  };
45206
- export { RadioGroupField as $, AttributePanel as A, BlockLayer as B, Color as C, Decoration as D, TextField as E, FontFamily as F, InputWithUnitField as G, Height as H, InteractivePrompt as I, SearchField as J, TextAreaField as K, LetterSpacing as L, Margin as M, NavbarLinkPadding as N, NumberField as O, Padding as P, SliderField as Q, ColorPickerField as R, ShortcutToolbar as S, TextAlign as T, UploadField as U, VerticalAlign as V, Width as W, ImageUploaderField as X, SelectField as Y, TreeSelectField as Z, AutoCompleteField as _, getIconNameByBlockType as a, SwitchField as a0, DatePickerField as a1, CheckboxField as a2, EditTabField as a3, InlineTextField as a4, enhancer as a5, RichTextField as a6, BlockAttributeConfigurationManager as b, commonjsGlobal as c, Align as d, AttributesPanelWrapper as e, ContainerBackgroundColor as f, getContextMergeTags as g, TextDecoration as h, Background as i, LineHeight as j, TextTransform as k, BackgroundColor as l, Direction as m, Link as n, Border as o, BorderColor as p, FontSize as q, MergeTags as r, BorderStyle as s, FontStyle as t, BorderWidth as u, FontWeight as v, BlockMarketManager as w, BlockMaskWrapper as x, SourceCodePanel as y, SimpleLayout as z };
45240
+ export { AutoCompleteField as $, AttributePanel as A, BlockLayer as B, Color as C, Decoration as D, SimpleLayout as E, FontFamily as F, TextField as G, Height as H, InteractivePrompt as I, InputWithUnitField as J, SearchField as K, LetterSpacing as L, Margin as M, NavbarLinkPadding as N, TextAreaField as O, Padding as P, NumberField as Q, SliderField as R, ShortcutToolbar as S, TextAlign as T, ColorPickerField as U, VerticalAlign as V, Width as W, UploadField as X, ImageUploaderField as Y, SelectField as Z, TreeSelectField as _, getIconNameByBlockType as a, RadioGroupField as a0, SwitchField as a1, DatePickerField as a2, CheckboxField as a3, EditTabField as a4, InlineTextField as a5, enhancer as a6, RichTextField as a7, getBlockTitle as b, commonjsGlobal as c, BlockAttributeConfigurationManager as d, Align as e, AttributesPanelWrapper as f, getContextMergeTags as g, ContainerBackgroundColor as h, TextDecoration as i, Background as j, LineHeight as k, TextTransform as l, BackgroundColor as m, Direction as n, Link as o, Border as p, BorderColor as q, FontSize as r, MergeTags as s, BorderStyle as t, FontStyle as u, BorderWidth as v, FontWeight as w, BlockMarketManager as x, BlockMaskWrapper as y, SourceCodePanel as z };
45207
45241
  //# sourceMappingURL=index2.js.map