easy-email-pro-theme 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -54,11 +54,11 @@ var __async = (__this, __arguments, generator) => {
54
54
  step((generator = generator.apply(__this, __arguments)).next());
55
55
  });
56
56
  };
57
- import { classnames, useEditorState, useEditorProps, useRefState, isDOMElement, useEditorContext, useEventCallback, validation, CustomEvent, ActiveTabKeys, BeacasEditorProvider, BeacasEditor, useSelectedNode, useForceUpdate, toggleFormat, TextFormat, IframeComponent, HtmlStringToReactNodes, isFormatActive } from "easy-email-pro-editor";
57
+ import { classnames, useEditorState, useEditorProps, useRefState, isDOMElement, useEditorContext, useEventCallback, validation, CustomEvent, ActiveTabKeys, EmailEditorProvider, EmailEditor, useSelectedNode, useForceUpdate, toggleFormat, TextFormat, IframeComponent, HtmlStringToReactNodes, isFormatActive } from "easy-email-pro-editor";
58
58
  import { useSlate, ReactEditor, useSlateStatic } from "slate-react";
59
59
  import * as React$2 from "react";
60
60
  import React__default, { useRef, useCallback as useCallback$1, useEffect, useMemo as useMemo$1, useState, forwardRef, memo, Component, PureComponent, useContext, useLayoutEffect, useReducer, Suspense } from "react";
61
- import { NodeUtils, BlockManager, ElementType, t, BeacasCore, ElementCategory, classnames as classnames$1, StandardType, MERGE_TAG_PATTERN, PluginManager, ConditionOperator, ConditionOperatorSymbol } from "easy-email-pro-core";
61
+ import { NodeUtils, BlockManager, ElementType, t, EditorCore, ElementCategory, classnames as classnames$1, StandardType, PluginManager, ConditionOperator, ConditionOperatorSymbol } from "easy-email-pro-core";
62
62
  import { Editor, Transforms, Path, Node as Node$1, createEditor, Text as Text$1, Range, Element as Element$1, Point } from "slate";
63
63
  import ReactDOM, { unstable_batchedUpdates, createPortal } from "react-dom";
64
64
  import { cloneDeep, debounce as debounce$2, get, isEqual as isEqual$3, set, omit as omit$2, merge as merge$1, isUndefined as isUndefined$1, isString as isString$1, isNumber as isNumber$1, uniqueId, upperFirst, flatMap, sum, camelCase } from "lodash";
@@ -6133,7 +6133,7 @@ const useEditorForm = () => {
6133
6133
  try {
6134
6134
  let pageBlock = newValues.content;
6135
6135
  if (universalElementSetting) {
6136
- pageBlock = BeacasCore.transformUniversalElements({
6136
+ pageBlock = EditorCore.transformUniversalElements({
6137
6137
  content: pageBlock,
6138
6138
  universalElements: universalElementSetting.elements
6139
6139
  });
@@ -6553,6 +6553,9 @@ function BlockItem({
6553
6553
  }) {
6554
6554
  const { universalElementEditing } = useEditorState();
6555
6555
  const block = BlockManager.getBlockByType(type);
6556
+ if (!block) {
6557
+ throw new Error(`block ${type} not found`);
6558
+ }
6556
6559
  const element = useMemo$1(() => block.create(payload), [block, payload]);
6557
6560
  const { dragHandle: dragHandle2 } = useDragging({
6558
6561
  element,
@@ -6712,63 +6715,7 @@ const defaultCategories = [
6712
6715
  className: "block-list-grid-item-icon",
6713
6716
  iconName: "icon-navbar"
6714
6717
  }
6715
- ),
6716
- payload: {
6717
- children: [
6718
- {
6719
- data: {},
6720
- type: "standard-navbar-link",
6721
- children: [
6722
- {
6723
- text: "Shop"
6724
- }
6725
- ],
6726
- attributes: {
6727
- href: "",
6728
- "font-size": "20px"
6729
- }
6730
- },
6731
- {
6732
- data: {},
6733
- type: "standard-navbar-link",
6734
- children: [
6735
- {
6736
- text: "About"
6737
- }
6738
- ],
6739
- attributes: {
6740
- href: "",
6741
- "font-size": "20px"
6742
- }
6743
- },
6744
- {
6745
- data: {},
6746
- type: "standard-navbar-link",
6747
- children: [
6748
- {
6749
- text: "Contact"
6750
- }
6751
- ],
6752
- attributes: {
6753
- href: "",
6754
- "font-size": "20px"
6755
- }
6756
- },
6757
- {
6758
- data: {},
6759
- type: "standard-navbar-link",
6760
- children: [
6761
- {
6762
- text: "Blog"
6763
- }
6764
- ],
6765
- attributes: {
6766
- href: "",
6767
- "font-size": "20px"
6768
- }
6769
- }
6770
- ]
6771
- }
6718
+ )
6772
6719
  },
6773
6720
  {
6774
6721
  type: ElementType.STANDARD_SOCIAL,
@@ -6785,60 +6732,7 @@ const defaultCategories = [
6785
6732
  attributes: {
6786
6733
  "icon-size": "30px",
6787
6734
  spacing: "20px"
6788
- },
6789
- children: [
6790
- {
6791
- data: {},
6792
- type: "standard-social-element",
6793
- children: [
6794
- {
6795
- text: ""
6796
- }
6797
- ],
6798
- attributes: {
6799
- src: "https://res.cloudinary.com/dfite2e16/image/upload/v1681908489/clgnivsuj0018z9ltiixmxf6k/xkd0kfnytbfywsofk8t6.png",
6800
- href: "",
6801
- "padding-left": "0px",
6802
- "padding-right": "0px",
6803
- "padding-top": "0px",
6804
- "padding-bottom": "0px"
6805
- }
6806
- },
6807
- {
6808
- data: {},
6809
- type: "standard-social-element",
6810
- children: [
6811
- {
6812
- text: ""
6813
- }
6814
- ],
6815
- attributes: {
6816
- src: "https://res.cloudinary.com/dfite2e16/image/upload/v1681908521/clgnivsuj0018z9ltiixmxf6k/ulyduaza1votoacctoi3.png",
6817
- href: "",
6818
- "padding-left": "20px",
6819
- "padding-right": "0px",
6820
- "padding-top": "0px",
6821
- "padding-bottom": "0px"
6822
- }
6823
- },
6824
- {
6825
- data: {},
6826
- type: "standard-social-element",
6827
- children: [
6828
- {
6829
- text: ""
6830
- }
6831
- ],
6832
- attributes: {
6833
- src: "https://res.cloudinary.com/dfite2e16/image/upload/v1681908543/clgnivsuj0018z9ltiixmxf6k/wtefhsfwaapcdbz7knqw.png",
6834
- href: "",
6835
- "padding-left": "20px",
6836
- "padding-right": "0px",
6837
- "padding-top": "0px",
6838
- "padding-bottom": "0px"
6839
- }
6840
- }
6841
- ]
6735
+ }
6842
6736
  }
6843
6737
  },
6844
6738
  {
@@ -8915,10 +8809,15 @@ function ColorPicker(props) {
8915
8809
  placeholder: placeholder2 = ""
8916
8810
  } = props;
8917
8811
  const [popupVisible, setPopupVisible] = useState(false);
8812
+ const { mergetagsData, pageDataVariables } = useEditorContext();
8813
+ const isPageVarMatch = EditorCore.isPageDataVariable(value);
8814
+ const isTemplateVarMatch = PluginManager.isVariable(value);
8918
8815
  const mergeTagColor = useMemo$1(() => {
8919
- const isMatch = MERGE_TAG_PATTERN.test(value);
8920
- if (isMatch) {
8921
- return PluginManager.renderWithData(value, {});
8816
+ if (isPageVarMatch) {
8817
+ return EditorCore.renderWithPageVariables(value, pageDataVariables);
8818
+ }
8819
+ if (isTemplateVarMatch) {
8820
+ return PluginManager.renderWithData(value, mergetagsData);
8922
8821
  }
8923
8822
  try {
8924
8823
  if (Color$1(`#${value}`).hex())
@@ -8926,14 +8825,20 @@ function ColorPicker(props) {
8926
8825
  } catch (error2) {
8927
8826
  }
8928
8827
  return value;
8929
- }, [value]);
8828
+ }, [
8829
+ isPageVarMatch,
8830
+ isTemplateVarMatch,
8831
+ mergetagsData,
8832
+ pageDataVariables,
8833
+ value
8834
+ ]);
8930
8835
  const onInputChange = useEventCallback((value2) => {
8931
8836
  onChange == null ? void 0 : onChange(value2);
8932
8837
  });
8933
8838
  const onClose = useEventCallback(() => {
8934
8839
  setPopupVisible(false);
8935
8840
  });
8936
- const inputColor = mergeTagColor.replace(/#/, "");
8841
+ const inputColor = value.replace(/#/, "");
8937
8842
  useEffect(() => {
8938
8843
  const onHandle = () => {
8939
8844
  setPopupVisible(false);
@@ -9014,7 +8919,7 @@ function ColorPicker(props) {
9014
8919
  ), showInput && /* @__PURE__ */ React__default.createElement(
9015
8920
  Input,
9016
8921
  {
9017
- prefix: "#",
8922
+ prefix: !isPageVarMatch && !isTemplateVarMatch && !value.includes("rgb") ? "#" : "",
9018
8923
  value: inputColor,
9019
8924
  style: { outline: "none", flex: 1 },
9020
8925
  onChange: onInputChange,
@@ -9033,6 +8938,11 @@ const ColorPickerField = (props) => {
9033
8938
  rules: [
9034
8939
  {
9035
8940
  validator(value, callback) {
8941
+ const isPageVarMatch = EditorCore.isPageDataVariable(value);
8942
+ const isTemplateVarMatch = PluginManager.isVariable(value);
8943
+ if (isPageVarMatch || isTemplateVarMatch) {
8944
+ return callback();
8945
+ }
9036
8946
  const Validate = validation.color.typeConstructor();
9037
8947
  const errMsg = new Validate(value || "").getErrorMessage();
9038
8948
  if (errMsg) {
@@ -21098,10 +21008,13 @@ function ImageUploader(props) {
21098
21008
  })
21099
21009
  );
21100
21010
  const image2 = useMemo$1(() => {
21101
- const isMatch = NodeUtils.isMergeTag(props.value);
21011
+ const isPageVarMatch = EditorCore.isPageDataVariable(props.value);
21012
+ const isTemplateVarMatch = PluginManager.isVariable(props.value);
21102
21013
  try {
21103
- if (isMatch) {
21104
- return PluginManager.renderWithData(props.value, __spreadValues(__spreadValues({}, mergetagsData), pageDataVariables)) || imagePlaceholder;
21014
+ if (isPageVarMatch) {
21015
+ return EditorCore.renderWithPageVariables(props.value, __spreadValues({}, pageDataVariables)) || imagePlaceholder;
21016
+ } else if (isTemplateVarMatch) {
21017
+ return PluginManager.renderWithData(props.value, __spreadValues({}, mergetagsData)) || imagePlaceholder;
21105
21018
  }
21106
21019
  } catch (error2) {
21107
21020
  console.error((error2 == null ? void 0 : error2.message) || error2);
@@ -21651,7 +21564,7 @@ const RichtextBar = (props) => {
21651
21564
  props.onChange(currentElement);
21652
21565
  };
21653
21566
  return /* @__PURE__ */ React__default.createElement(
21654
- BeacasEditorProvider,
21567
+ EmailEditorProvider,
21655
21568
  {
21656
21569
  initialValues: initialValue,
21657
21570
  editor,
@@ -21662,7 +21575,7 @@ const RichtextBar = (props) => {
21662
21575
  newLineWithBr: true
21663
21576
  },
21664
21577
  /* @__PURE__ */ React__default.createElement(SharedComponents.HoveringToolbar, null),
21665
- /* @__PURE__ */ React__default.createElement(BeacasEditor, null),
21578
+ /* @__PURE__ */ React__default.createElement(EmailEditor, null),
21666
21579
  /* @__PURE__ */ React__default.createElement(SharedComponents.Hotkeys, null),
21667
21580
  /* @__PURE__ */ React__default.createElement(ResetContent, { initialValue }),
21668
21581
  /* @__PURE__ */ React__default.createElement("style", null, styleText$c)
@@ -23337,7 +23250,7 @@ function Link(props) {
23337
23250
  rules: [
23338
23251
  {
23339
23252
  validator(value, callback) {
23340
- const isValid = isValidHttpUrl(value) || NodeUtils.isMergeTag(value);
23253
+ const isValid = isValidHttpUrl(value) || PluginManager.isVariable(value);
23341
23254
  if (!isValid) {
23342
23255
  callback(t("Invalid URL"));
23343
23256
  }
@@ -23720,7 +23633,7 @@ const SourceCodePanel = () => {
23720
23633
  if (!selectedNode)
23721
23634
  return;
23722
23635
  try {
23723
- const mjml22 = BeacasCore.toMJML({
23636
+ const mjml22 = EditorCore.toMJML({
23724
23637
  element: selectedNode,
23725
23638
  pageElement: values2.content,
23726
23639
  mode: "production",
@@ -26655,10 +26568,10 @@ const PreviewEmail = observer(
26655
26568
  mergetagsData
26656
26569
  }) => {
26657
26570
  const pageVariables = useMemo$1(() => {
26658
- return BeacasCore.getPageDataVariables(values2.content);
26571
+ return EditorCore.getPageDataVariables(values2.content);
26659
26572
  }, [values2.content]);
26660
26573
  const mjmlString = useMemo$1(() => {
26661
- return BeacasCore.toMJML({
26574
+ return EditorCore.toMJML({
26662
26575
  element: values2.content,
26663
26576
  mode: "production",
26664
26577
  universalElements: universalElementSetting,
@@ -32579,6 +32492,7 @@ const TextAlign = () => {
32579
32492
  const options$1 = ["12px", "14px", "16px", "18px", "24px", "32px", "48px"];
32580
32493
  const FontSize = () => {
32581
32494
  const { fontSizeList } = useEditorProps();
32495
+ const [fontSizeValue, setFontSizeValue] = useState();
32582
32496
  const editor = useSlate();
32583
32497
  const [nodeEntry] = Editor.nodes(editor, {
32584
32498
  match: (node) => {
@@ -32587,14 +32501,17 @@ const FontSize = () => {
32587
32501
  mode: "lowest"
32588
32502
  });
32589
32503
  const textNode = nodeEntry == null ? void 0 : nodeEntry[0];
32590
- let fontSizeValue = textNode == null ? void 0 : textNode.fontSize;
32591
- if (!fontSizeValue && textNode) {
32592
- try {
32593
- const textDomNode = ReactEditor.toDOMNode(editor, textNode);
32594
- fontSizeValue = window.getComputedStyle(textDomNode).fontSize;
32595
- } catch (error2) {
32504
+ useEffect(() => {
32505
+ let fontSizeValue2 = textNode == null ? void 0 : textNode.fontSize;
32506
+ if (!fontSizeValue2 && textNode) {
32507
+ try {
32508
+ const textDomNode = ReactEditor.toDOMNode(editor, textNode);
32509
+ fontSizeValue2 = window.getComputedStyle(textDomNode).fontSize;
32510
+ } catch (error2) {
32511
+ }
32596
32512
  }
32597
- }
32513
+ setFontSizeValue(fontSizeValue2);
32514
+ }, [editor, textNode, textNode == null ? void 0 : textNode.fontSize]);
32598
32515
  const optionsList = useMemo$1(() => {
32599
32516
  const list = [...fontSizeList || options$1];
32600
32517
  if (fontSizeValue) {
@@ -32629,9 +32546,9 @@ const FontSize = () => {
32629
32546
  ), /* @__PURE__ */ React__default.createElement("style", null, `.easy-email-pro-font-size .arco-select-view { border: none; }`));
32630
32547
  };
32631
32548
  const FontFamily = () => {
32632
- var _a2;
32633
32549
  const { fontList } = useFontFamily();
32634
32550
  const editor = useSlate();
32551
+ const [fontFamilyValue, setFontFamilyValue] = useState();
32635
32552
  const [nodeEntry] = Editor.nodes(editor, {
32636
32553
  match: (node) => {
32637
32554
  return Text$1.isText(node);
@@ -32639,14 +32556,18 @@ const FontFamily = () => {
32639
32556
  mode: "lowest"
32640
32557
  });
32641
32558
  const textNode = nodeEntry == null ? void 0 : nodeEntry[0];
32642
- let fontFamilyValue = textNode == null ? void 0 : textNode.fontFamily;
32643
- if (!fontFamilyValue && textNode) {
32644
- try {
32645
- const textDomNode = ReactEditor.toDOMNode(editor, textNode);
32646
- fontFamilyValue = ((_a2 = window.getComputedStyle(textDomNode).fontFamily.split(",")) == null ? void 0 : _a2[0]) || "";
32647
- } catch (error2) {
32559
+ useEffect(() => {
32560
+ var _a2;
32561
+ let fontFamilyValue2 = textNode == null ? void 0 : textNode.fontFamily;
32562
+ if (!fontFamilyValue2 && textNode) {
32563
+ try {
32564
+ const textDomNode = ReactEditor.toDOMNode(editor, textNode);
32565
+ fontFamilyValue2 = ((_a2 = window.getComputedStyle(textDomNode).fontFamily.split(",")) == null ? void 0 : _a2[0]) || "";
32566
+ } catch (error2) {
32567
+ }
32648
32568
  }
32649
- }
32569
+ setFontFamilyValue(fontFamilyValue2);
32570
+ }, [editor, textNode, textNode == null ? void 0 : textNode.fontFamily]);
32650
32571
  const optionsList = useMemo$1(() => {
32651
32572
  const list = [...fontList];
32652
32573
  if (fontFamilyValue) {
@@ -38695,7 +38616,7 @@ const Layout$1 = ({
38695
38616
  },
38696
38617
  /* @__PURE__ */ React__default.createElement(SharedComponents.BlockSideBar, { height })
38697
38618
  ),
38698
- /* @__PURE__ */ React__default.createElement("div", { style: { height, minWidth: 800, flex: 1 } }, /* @__PURE__ */ React__default.createElement(SharedComponents.EditorTabs, null, /* @__PURE__ */ React__default.createElement(BeacasEditor, null, /* @__PURE__ */ React__default.createElement("style", { id: "Retro-CSS" }, styleText$c, RetroStyleText)), children))
38619
+ /* @__PURE__ */ React__default.createElement("div", { style: { height, minWidth: 800, flex: 1 } }, /* @__PURE__ */ React__default.createElement(SharedComponents.EditorTabs, null, /* @__PURE__ */ React__default.createElement(EmailEditor, null, /* @__PURE__ */ React__default.createElement("style", { id: "Retro-CSS" }, styleText$c, RetroStyleText)), children))
38699
38620
  )
38700
38621
  ));
38701
38622
  if (!root2 || !inited)
@@ -40547,7 +40468,7 @@ const Layout = ({
40547
40468
  flex: showSidebar ? 1 : void 0
40548
40469
  }
40549
40470
  },
40550
- /* @__PURE__ */ React__default.createElement(SharedComponents.EditorTabs, null, /* @__PURE__ */ React__default.createElement(BeacasEditor, null, /* @__PURE__ */ React__default.createElement("style", { id: "Retro-CSS" }, styleText$c, minimaliststyleText)), children)
40471
+ /* @__PURE__ */ React__default.createElement(SharedComponents.EditorTabs, null, /* @__PURE__ */ React__default.createElement(EmailEditor, null, /* @__PURE__ */ React__default.createElement("style", { id: "Retro-CSS" }, styleText$c, minimaliststyleText)), children)
40551
40472
  )
40552
40473
  )
40553
40474
  ));
@@ -1,2 +1,2 @@
1
- import { Element as BeacasElement, TextNode } from "easy-email-pro-core";
2
- export declare const HtmlNodeAdapter: (content: string) => (BeacasElement | TextNode)[];
1
+ import { Element as NodeElement, TextNode } from "easy-email-pro-core";
2
+ export declare const HtmlNodeAdapter: (content: string) => (NodeElement | TextNode)[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-email-pro-theme",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "files": [
6
6
  "lib"