easy-email-extensions 4.16.2 → 4.16.3
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 +193 -117
- package/lib/index2.js.map +1 -1
- package/package.json +2 -2
package/lib/index2.js
CHANGED
@@ -56,7 +56,7 @@ var __async = (__this, __arguments, generator) => {
|
|
56
56
|
};
|
57
57
|
import * as React from "react";
|
58
58
|
import React__default, { Children, isValidElement, cloneElement, createContext, useContext, Component, useMemo, memo, forwardRef, useEffect, useRef, useLayoutEffect, useState, useImperativeHandle, PureComponent, useCallback, useReducer, createRef, Fragment, createElement, Suspense } from "react";
|
59
|
-
import { IconFont, useEditorProps, Stack as Stack$4, useRefState, getShadowRoot, DATA_CONTENT_EDITABLE_TYPE, ContentEditableType, TextStyle, useEditorContext, useBlock, useFocusIdx, DATA_CONTENT_EDITABLE_IDX, useFocusBlockLayout, MergeTagBadge, FIXED_CONTAINER_ID, getPluginElement, RICH_TEXT_BAR_ID, CONTENT_EDITABLE_CLASS_NAME, getEditorRoot, scrollBlockEleIntoView, useHoverIdx, useDataTransfer, getBlockNodeByChildEle, getDirectionPosition, DATA_ATTRIBUTE_DROP_CONTAINER, BlockAvatarWrapper, isTextBlock, getBlockNodeByIdx, useLazyState, useActiveTab, ActiveTabKeys } from "easy-email-editor";
|
59
|
+
import { IconFont, useEditorProps, Stack as Stack$4, useRefState, getShadowRoot, DATA_CONTENT_EDITABLE_TYPE, ContentEditableType, TextStyle, useEditorContext, useBlock, useFocusIdx, DATA_CONTENT_EDITABLE_IDX, useFocusBlockLayout, MergeTagBadge, AvailableTools, FIXED_CONTAINER_ID, getPluginElement, RICH_TEXT_BAR_ID, CONTENT_EDITABLE_CLASS_NAME, getEditorRoot, scrollBlockEleIntoView, useHoverIdx, useDataTransfer, getBlockNodeByChildEle, getDirectionPosition, DATA_ATTRIBUTE_DROP_CONTAINER, BlockAvatarWrapper, isTextBlock, getBlockNodeByIdx, useLazyState, useActiveTab, ActiveTabKeys } from "easy-email-editor";
|
60
60
|
import { BasicType, ImageManager, EMAIL_BLOCK_CLASS_NAME, BlockManager, createBlockDataByType, AdvancedType, Operator, OperatorSymbol, isAdvancedBlock, getParentByIdx, getParentIdx, getIndexByIdx, getSiblingIdx, getNodeIdxFromClassName, getNodeIdxClassName, getPageIdx, getChildIdx, JsonToMjml, getNodeTypeFromClassName } from "easy-email-core";
|
61
61
|
import ReactDOM, { findDOMNode, render, createPortal } from "react-dom";
|
62
62
|
import { Field, useForm as useForm$1, useField, Form as Form$3, version as version$2, useFormState } from "react-final-form";
|
@@ -37529,11 +37529,12 @@ function FontSize(props) {
|
|
37529
37529
|
}));
|
37530
37530
|
}
|
37531
37531
|
function Tools(props) {
|
37532
|
-
|
37532
|
+
var _a, _b;
|
37533
|
+
const { mergeTags: mergeTags2, enabledMergeTagsBadge, toolbar } = useEditorProps();
|
37533
37534
|
const { focusBlockNode } = useFocusBlockLayout();
|
37534
37535
|
const { selectionRange, restoreRange, setRangeByElement } = useSelectionRange();
|
37535
37536
|
const execCommand = useCallback((cmd, val) => {
|
37536
|
-
var
|
37537
|
+
var _a2;
|
37537
37538
|
if (!selectionRange) {
|
37538
37539
|
console.error(t("No selectionRange"));
|
37539
37540
|
return;
|
@@ -37576,7 +37577,7 @@ function Tools(props) {
|
|
37576
37577
|
}
|
37577
37578
|
const contenteditableElement = getShadowRoot().activeElement;
|
37578
37579
|
if ((contenteditableElement == null ? void 0 : contenteditableElement.getAttribute("contenteditable")) === "true") {
|
37579
|
-
const html = ((
|
37580
|
+
const html = ((_a2 = getShadowRoot().activeElement) == null ? void 0 : _a2.innerHTML) || "";
|
37580
37581
|
props.onChange(html);
|
37581
37582
|
}
|
37582
37583
|
}, [
|
@@ -37588,15 +37589,194 @@ function Tools(props) {
|
|
37588
37589
|
setRangeByElement
|
37589
37590
|
]);
|
37590
37591
|
const execCommandWithRange = useCallback((cmd, val) => {
|
37591
|
-
var
|
37592
|
+
var _a2;
|
37592
37593
|
document.execCommand(cmd, false, val);
|
37593
37594
|
const contenteditableElement = getShadowRoot().activeElement;
|
37594
37595
|
if ((contenteditableElement == null ? void 0 : contenteditableElement.getAttribute("contenteditable")) === "true") {
|
37595
|
-
const html = ((
|
37596
|
+
const html = ((_a2 = getShadowRoot().activeElement) == null ? void 0 : _a2.innerHTML) || "";
|
37596
37597
|
props.onChange(html);
|
37597
37598
|
}
|
37598
37599
|
}, [props.onChange]);
|
37599
37600
|
const getPopoverMountNode = () => document.getElementById(FIXED_CONTAINER_ID);
|
37601
|
+
const enabledTools = (_a = toolbar == null ? void 0 : toolbar.tools) != null ? _a : [
|
37602
|
+
AvailableTools.MergeTags,
|
37603
|
+
AvailableTools.FontFamily,
|
37604
|
+
AvailableTools.FontSize,
|
37605
|
+
AvailableTools.Bold,
|
37606
|
+
AvailableTools.Italic,
|
37607
|
+
AvailableTools.StrikeThrough,
|
37608
|
+
AvailableTools.Underline,
|
37609
|
+
AvailableTools.IconFontColor,
|
37610
|
+
AvailableTools.IconBgColor,
|
37611
|
+
AvailableTools.Link,
|
37612
|
+
AvailableTools.Justify,
|
37613
|
+
AvailableTools.Lists,
|
37614
|
+
AvailableTools.HorizontalRule,
|
37615
|
+
AvailableTools.RemoveFormat
|
37616
|
+
];
|
37617
|
+
const tools = enabledTools.flatMap((tool) => {
|
37618
|
+
switch (tool) {
|
37619
|
+
case AvailableTools.MergeTags:
|
37620
|
+
if (!mergeTags2)
|
37621
|
+
return [];
|
37622
|
+
return [
|
37623
|
+
/* @__PURE__ */ React__default.createElement(MergeTags, {
|
37624
|
+
key: tool,
|
37625
|
+
execCommand,
|
37626
|
+
getPopupContainer: getPopoverMountNode
|
37627
|
+
})
|
37628
|
+
];
|
37629
|
+
case AvailableTools.FontFamily:
|
37630
|
+
return [
|
37631
|
+
/* @__PURE__ */ React__default.createElement(FontFamily$1, {
|
37632
|
+
key: tool,
|
37633
|
+
execCommand,
|
37634
|
+
getPopupContainer: getPopoverMountNode
|
37635
|
+
})
|
37636
|
+
];
|
37637
|
+
case AvailableTools.FontSize:
|
37638
|
+
return [
|
37639
|
+
/* @__PURE__ */ React__default.createElement(FontSize, {
|
37640
|
+
key: tool,
|
37641
|
+
execCommand,
|
37642
|
+
getPopupContainer: getPopoverMountNode
|
37643
|
+
})
|
37644
|
+
];
|
37645
|
+
case AvailableTools.Bold:
|
37646
|
+
return [
|
37647
|
+
/* @__PURE__ */ React__default.createElement(Bold, {
|
37648
|
+
key: tool,
|
37649
|
+
currentRange: selectionRange,
|
37650
|
+
onChange: () => execCommandWithRange("bold")
|
37651
|
+
})
|
37652
|
+
];
|
37653
|
+
case AvailableTools.Italic:
|
37654
|
+
return [
|
37655
|
+
/* @__PURE__ */ React__default.createElement(Italic, {
|
37656
|
+
key: tool,
|
37657
|
+
currentRange: selectionRange,
|
37658
|
+
onChange: () => execCommandWithRange("italic")
|
37659
|
+
})
|
37660
|
+
];
|
37661
|
+
case AvailableTools.StrikeThrough:
|
37662
|
+
return [
|
37663
|
+
/* @__PURE__ */ React__default.createElement(StrikeThrough, {
|
37664
|
+
key: tool,
|
37665
|
+
currentRange: selectionRange,
|
37666
|
+
onChange: () => execCommandWithRange("strikeThrough")
|
37667
|
+
})
|
37668
|
+
];
|
37669
|
+
case AvailableTools.Underline:
|
37670
|
+
return [
|
37671
|
+
/* @__PURE__ */ React__default.createElement(Underline, {
|
37672
|
+
key: tool,
|
37673
|
+
currentRange: selectionRange,
|
37674
|
+
onChange: () => execCommandWithRange("underline")
|
37675
|
+
})
|
37676
|
+
];
|
37677
|
+
case AvailableTools.IconFontColor:
|
37678
|
+
return [
|
37679
|
+
/* @__PURE__ */ React__default.createElement(IconFontColor, {
|
37680
|
+
selectionRange,
|
37681
|
+
execCommand,
|
37682
|
+
getPopoverMountNode
|
37683
|
+
})
|
37684
|
+
];
|
37685
|
+
case AvailableTools.IconBgColor:
|
37686
|
+
return [
|
37687
|
+
/* @__PURE__ */ React__default.createElement(IconBgColor, {
|
37688
|
+
selectionRange,
|
37689
|
+
execCommand,
|
37690
|
+
getPopoverMountNode
|
37691
|
+
})
|
37692
|
+
];
|
37693
|
+
case AvailableTools.Link:
|
37694
|
+
return [
|
37695
|
+
/* @__PURE__ */ React__default.createElement(Link$1, {
|
37696
|
+
key: `${tool}-link`,
|
37697
|
+
currentRange: selectionRange,
|
37698
|
+
onChange: (values2) => execCommand("createLink", values2),
|
37699
|
+
getPopupContainer: getPopoverMountNode
|
37700
|
+
}),
|
37701
|
+
/* @__PURE__ */ React__default.createElement(Unlink, {
|
37702
|
+
key: `${tool}-unlink`,
|
37703
|
+
currentRange: selectionRange,
|
37704
|
+
onChange: () => execCommand("")
|
37705
|
+
})
|
37706
|
+
];
|
37707
|
+
case "justify":
|
37708
|
+
return [
|
37709
|
+
/* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37710
|
+
key: `${tool}-justify-left`,
|
37711
|
+
onClick: () => execCommand("justifyLeft"),
|
37712
|
+
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37713
|
+
iconName: "icon-align-left"
|
37714
|
+
}),
|
37715
|
+
title: t("Align left")
|
37716
|
+
}),
|
37717
|
+
/* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37718
|
+
key: `${tool}-justify-center`,
|
37719
|
+
onClick: () => execCommand("justifyCenter"),
|
37720
|
+
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37721
|
+
iconName: "icon-align-center"
|
37722
|
+
}),
|
37723
|
+
title: t("Align center")
|
37724
|
+
}),
|
37725
|
+
/* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37726
|
+
key: `${tool}-justify-right`,
|
37727
|
+
onClick: () => execCommand("justifyRight"),
|
37728
|
+
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37729
|
+
iconName: "icon-align-right"
|
37730
|
+
}),
|
37731
|
+
title: t("Align right")
|
37732
|
+
})
|
37733
|
+
];
|
37734
|
+
case AvailableTools.Lists:
|
37735
|
+
return [
|
37736
|
+
/* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37737
|
+
key: `${tool}-ordered-list`,
|
37738
|
+
onClick: () => execCommand("insertOrderedList"),
|
37739
|
+
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37740
|
+
iconName: "icon-list-ol"
|
37741
|
+
}),
|
37742
|
+
title: t("Orderlist")
|
37743
|
+
}),
|
37744
|
+
/* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37745
|
+
key: `${tool}-unordered-list`,
|
37746
|
+
onClick: () => execCommand("insertUnorderedList"),
|
37747
|
+
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37748
|
+
iconName: "icon-list-ul"
|
37749
|
+
}),
|
37750
|
+
title: t("Unorderlist")
|
37751
|
+
})
|
37752
|
+
];
|
37753
|
+
case AvailableTools.HorizontalRule:
|
37754
|
+
return [
|
37755
|
+
/* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37756
|
+
key: tool,
|
37757
|
+
onClick: () => execCommand("insertHorizontalRule"),
|
37758
|
+
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37759
|
+
iconName: "icon-line"
|
37760
|
+
}),
|
37761
|
+
title: t("Line")
|
37762
|
+
})
|
37763
|
+
];
|
37764
|
+
case AvailableTools.RemoveFormat:
|
37765
|
+
return [
|
37766
|
+
/* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37767
|
+
key: tool,
|
37768
|
+
onClick: () => execCommand("removeFormat"),
|
37769
|
+
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37770
|
+
iconName: "icon-close"
|
37771
|
+
}),
|
37772
|
+
title: t("Remove format")
|
37773
|
+
})
|
37774
|
+
];
|
37775
|
+
default:
|
37776
|
+
console.error("Not existing tool", tool);
|
37777
|
+
throw new Error(`Not existing tool ${tool}`);
|
37778
|
+
}
|
37779
|
+
});
|
37600
37780
|
return /* @__PURE__ */ React__default.createElement("div", {
|
37601
37781
|
id: RICH_TEXT_TOOL_BAR,
|
37602
37782
|
style: { display: "flex", flexWrap: "nowrap" }
|
@@ -37605,117 +37785,13 @@ function Tools(props) {
|
|
37605
37785
|
display: "flex",
|
37606
37786
|
alignItems: "center"
|
37607
37787
|
}
|
37608
|
-
}, /* @__PURE__ */ React__default.createElement(BasicTools, null),
|
37609
|
-
|
37610
|
-
|
37611
|
-
|
37612
|
-
|
37613
|
-
|
37614
|
-
|
37615
|
-
}), /* @__PURE__ */ React__default.createElement(FontFamily$1, {
|
37616
|
-
execCommand,
|
37617
|
-
getPopupContainer: getPopoverMountNode
|
37618
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37619
|
-
className: "easy-email-extensions-divider"
|
37620
|
-
}), /* @__PURE__ */ React__default.createElement(FontSize, {
|
37621
|
-
execCommand,
|
37622
|
-
getPopupContainer: getPopoverMountNode
|
37623
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37624
|
-
className: "easy-email-extensions-divider"
|
37625
|
-
}), /* @__PURE__ */ React__default.createElement(Bold, {
|
37626
|
-
currentRange: selectionRange,
|
37627
|
-
onChange: () => execCommandWithRange("bold")
|
37628
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37629
|
-
className: "easy-email-extensions-divider"
|
37630
|
-
}), /* @__PURE__ */ React__default.createElement(Italic, {
|
37631
|
-
currentRange: selectionRange,
|
37632
|
-
onChange: () => execCommandWithRange("italic")
|
37633
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37634
|
-
className: "easy-email-extensions-divider"
|
37635
|
-
}), /* @__PURE__ */ React__default.createElement(StrikeThrough, {
|
37636
|
-
currentRange: selectionRange,
|
37637
|
-
onChange: () => execCommandWithRange("strikeThrough")
|
37638
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37639
|
-
className: "easy-email-extensions-divider"
|
37640
|
-
}), /* @__PURE__ */ React__default.createElement(Underline, {
|
37641
|
-
currentRange: selectionRange,
|
37642
|
-
onChange: () => execCommandWithRange("underline")
|
37643
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37644
|
-
className: "easy-email-extensions-divider"
|
37645
|
-
}), /* @__PURE__ */ React__default.createElement(IconFontColor, {
|
37646
|
-
selectionRange,
|
37647
|
-
execCommand,
|
37648
|
-
getPopoverMountNode
|
37649
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37650
|
-
className: "easy-email-extensions-divider"
|
37651
|
-
}), /* @__PURE__ */ React__default.createElement(IconBgColor, {
|
37652
|
-
selectionRange,
|
37653
|
-
execCommand,
|
37654
|
-
getPopoverMountNode
|
37655
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37656
|
-
className: "easy-email-extensions-divider"
|
37657
|
-
}), /* @__PURE__ */ React__default.createElement(Link$1, {
|
37658
|
-
currentRange: selectionRange,
|
37659
|
-
onChange: (values2) => execCommand("createLink", values2),
|
37660
|
-
getPopupContainer: getPopoverMountNode
|
37661
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37662
|
-
className: "easy-email-extensions-divider"
|
37663
|
-
}), /* @__PURE__ */ React__default.createElement(Unlink, {
|
37664
|
-
currentRange: selectionRange,
|
37665
|
-
onChange: () => execCommand("")
|
37666
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37667
|
-
className: "easy-email-extensions-divider"
|
37668
|
-
}), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37669
|
-
onClick: () => execCommand("justifyLeft"),
|
37670
|
-
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37671
|
-
iconName: "icon-align-left"
|
37672
|
-
}),
|
37673
|
-
title: t("Align left")
|
37674
|
-
}), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37675
|
-
onClick: () => execCommand("justifyCenter"),
|
37676
|
-
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37677
|
-
iconName: "icon-align-center"
|
37678
|
-
}),
|
37679
|
-
title: t("Align center")
|
37680
|
-
}), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37681
|
-
onClick: () => execCommand("justifyRight"),
|
37682
|
-
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37683
|
-
iconName: "icon-align-right"
|
37684
|
-
}),
|
37685
|
-
title: t("Align right")
|
37686
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37687
|
-
className: "easy-email-extensions-divider"
|
37688
|
-
}), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37689
|
-
onClick: () => execCommand("insertOrderedList"),
|
37690
|
-
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37691
|
-
iconName: "icon-list-ol"
|
37692
|
-
}),
|
37693
|
-
title: t("Orderlist")
|
37694
|
-
}), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37695
|
-
onClick: () => execCommand("insertUnorderedList"),
|
37696
|
-
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37697
|
-
iconName: "icon-list-ul"
|
37698
|
-
}),
|
37699
|
-
title: t("Unorderlist")
|
37700
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37701
|
-
className: "easy-email-extensions-divider"
|
37702
|
-
}), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37703
|
-
onClick: () => execCommand("insertHorizontalRule"),
|
37704
|
-
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37705
|
-
iconName: "icon-line"
|
37706
|
-
}),
|
37707
|
-
title: t("Line")
|
37708
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37709
|
-
className: "easy-email-extensions-divider"
|
37710
|
-
}), /* @__PURE__ */ React__default.createElement(ToolItem$1, {
|
37711
|
-
onClick: () => execCommand("removeFormat"),
|
37712
|
-
icon: /* @__PURE__ */ React__default.createElement(IconFont, {
|
37713
|
-
iconName: "icon-close"
|
37714
|
-
}),
|
37715
|
-
title: t("Remove format")
|
37716
|
-
}), /* @__PURE__ */ React__default.createElement("div", {
|
37717
|
-
className: "easy-email-extensions-divider"
|
37718
|
-
})));
|
37788
|
+
}, /* @__PURE__ */ React__default.createElement(BasicTools, null), tools.flatMap((tool, index2) => [
|
37789
|
+
tool,
|
37790
|
+
/* @__PURE__ */ React__default.createElement("div", {
|
37791
|
+
className: "easy-email-extensions-divider",
|
37792
|
+
key: `divider-${index2}`
|
37793
|
+
})
|
37794
|
+
])), (_b = toolbar == null ? void 0 : toolbar.suffix) == null ? void 0 : _b.call(toolbar, execCommand));
|
37719
37795
|
}
|
37720
37796
|
var styleText = ".easy-email-extensions-emailToolItem{display:inline-flex;align-items:center;justify-content:center;position:relative;outline:none;font-weight:400;appearance:none;cursor:pointer!important;white-space:nowrap;transition:all .1s linear;box-sizing:border-box;border-radius:2px;border:none;background-color:transparent;color:#fff;width:28px;height:27px}.easy-email-extensions-emailToolItem:hover,.easy-email-extensions-emailToolItem-active{background-color:#f2f3f5;color:#4e5969}.easy-email-extensions-divider{position:relative;display:inline-flex;width:1px;height:16px;background-color:#808080e6}\n";
|
37721
37797
|
function RichTextToolBar(props) {
|