easy-email-pro-theme 1.57.8 → 1.57.10
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
|
@@ -58,8 +58,8 @@ import { classnames, useEditorActions, useDragNodePath, useStandaloneElementEdit
|
|
|
58
58
|
import { useSlate, ReactEditor, useSlateStatic, useSelected } from "slate-react";
|
|
59
59
|
import * as React$2 from "react";
|
|
60
60
|
import React__default, { useRef, useState, useEffect, useCallback, useMemo, createContext, useContext, useLayoutEffect, memo, useReducer, cloneElement, forwardRef, createElement, Suspense, Component } from "react";
|
|
61
|
-
import { NodeUtils, BlockManager, ElementType, EditorCore, t, ElementCategory, classnames as classnames$1, StandardType, PluginManager, EditorAuth,
|
|
62
|
-
import { cloneDeep, get, isEqual, set, omit as omit$2, merge as merge$1, debounce as debounce$2, isUndefined as isUndefined$1, uniqueId,
|
|
61
|
+
import { NodeUtils, BlockManager, ElementType, EditorCore, t, ElementCategory, classnames as classnames$1, StandardType, PluginManager, EditorAuth, mjmlToJsonCore, ConditionOperator, ConditionOperatorSymbol, EmailRenderProvider, components, HtmlNodeAdapter, I18nManager } from "easy-email-pro-core";
|
|
62
|
+
import { cloneDeep, get, isEqual, set, omit as omit$2, merge as merge$1, debounce as debounce$2, isUndefined as isUndefined$1, uniqueId, isFunction as isFunction$4, isString as isString$1, isNumber as isNumber$1, upperFirst, sum, flatMap } from "lodash";
|
|
63
63
|
import { Editor, Range, Node, Transforms, Path, Text as Text$4, createEditor } from "slate";
|
|
64
64
|
import { nanoid } from "nanoid";
|
|
65
65
|
import { Form, Input, Modal, Collapse, Space, Empty, Card, Grid, Button as Button$2, Drawer, Switch, Typography as Typography$1, Tabs, Radio, Tooltip, Divider as Divider$2, Alert, Popconfirm, Message, PageHeader as PageHeader$1, Spin, Layout as Layout$2, Popover, Select as Select$1, Slider, InputNumber, Tag, Link as Link$3, List as List$1, Skeleton, Trigger } from "@arco-design/web-react";
|
|
@@ -15754,6 +15754,15 @@ const BgColor = () => {
|
|
|
15754
15754
|
} catch (error2) {
|
|
15755
15755
|
}
|
|
15756
15756
|
}
|
|
15757
|
+
if (!nodeEntry) {
|
|
15758
|
+
[nodeEntry] = Editor.nodes(editor, {
|
|
15759
|
+
match: (node) => {
|
|
15760
|
+
return Text$4.isText(node);
|
|
15761
|
+
},
|
|
15762
|
+
mode: "lowest",
|
|
15763
|
+
voids: true
|
|
15764
|
+
});
|
|
15765
|
+
}
|
|
15757
15766
|
const { setFieldValue } = useEditorContext();
|
|
15758
15767
|
const activeTab = useActiveTab();
|
|
15759
15768
|
const selectedNodePath = useSelectedNodePath();
|
|
@@ -15894,6 +15903,15 @@ const FontColor = () => {
|
|
|
15894
15903
|
} catch (error2) {
|
|
15895
15904
|
}
|
|
15896
15905
|
}
|
|
15906
|
+
if (!nodeEntry) {
|
|
15907
|
+
[nodeEntry] = Editor.nodes(editor, {
|
|
15908
|
+
match: (node) => {
|
|
15909
|
+
return Text$4.isText(node);
|
|
15910
|
+
},
|
|
15911
|
+
mode: "lowest",
|
|
15912
|
+
voids: true
|
|
15913
|
+
});
|
|
15914
|
+
}
|
|
15897
15915
|
const { setFieldValue } = useEditorContext();
|
|
15898
15916
|
const activeTab = useActiveTab();
|
|
15899
15917
|
const selectedNodePath = useSelectedNodePath();
|
|
@@ -16331,242 +16349,12 @@ const PreventFocusWrapper = ({
|
|
|
16331
16349
|
children
|
|
16332
16350
|
);
|
|
16333
16351
|
};
|
|
16334
|
-
const formatPadding = (element) => {
|
|
16335
|
-
if (element.attributes.padding) {
|
|
16336
|
-
const div = document.createElement("div");
|
|
16337
|
-
div.style.padding = get(element.attributes, "padding");
|
|
16338
|
-
if (get(element.attributes, "padding-top")) {
|
|
16339
|
-
div.style.paddingTop = get(element.attributes, "padding-top");
|
|
16340
|
-
}
|
|
16341
|
-
if (get(element.attributes, "padding-bottom")) {
|
|
16342
|
-
div.style.paddingTop = get(element.attributes, "padding-bottom");
|
|
16343
|
-
}
|
|
16344
|
-
if (get(element.attributes, "padding-left")) {
|
|
16345
|
-
div.style.paddingTop = get(element.attributes, "padding-left");
|
|
16346
|
-
}
|
|
16347
|
-
if (get(element.attributes, "padding-right")) {
|
|
16348
|
-
div.style.paddingTop = get(element.attributes, "padding-right");
|
|
16349
|
-
}
|
|
16350
|
-
delete element.attributes.padding;
|
|
16351
|
-
element.attributes["padding-top"] = div.style.paddingTop;
|
|
16352
|
-
element.attributes["padding-bottom"] = div.style.paddingBottom;
|
|
16353
|
-
element.attributes["padding-left"] = div.style.paddingLeft;
|
|
16354
|
-
element.attributes["padding-right"] = div.style.paddingRight;
|
|
16355
|
-
}
|
|
16356
|
-
if (element.attributes["inner-padding"]) {
|
|
16357
|
-
const div = document.createElement("div");
|
|
16358
|
-
div.style.padding = get(element.attributes, "inner-padding");
|
|
16359
|
-
if (get(element.attributes, "inner-padding-top")) {
|
|
16360
|
-
div.style.paddingTop = get(element.attributes, "inner-padding-top");
|
|
16361
|
-
}
|
|
16362
|
-
if (get(element.attributes, "inner-padding-bottom")) {
|
|
16363
|
-
div.style.paddingTop = get(element.attributes, "inner-padding-bottom");
|
|
16364
|
-
}
|
|
16365
|
-
if (get(element.attributes, "inner-padding-left")) {
|
|
16366
|
-
div.style.paddingTop = get(element.attributes, "inner-padding-left");
|
|
16367
|
-
}
|
|
16368
|
-
if (get(element.attributes, "inner-padding-right")) {
|
|
16369
|
-
div.style.paddingTop = get(element.attributes, "inner-padding-right");
|
|
16370
|
-
}
|
|
16371
|
-
delete element.attributes["inner-padding"];
|
|
16372
|
-
element.attributes["inner-padding-top"] = div.style.paddingTop;
|
|
16373
|
-
element.attributes["inner-padding-bottom"] = div.style.paddingBottom;
|
|
16374
|
-
element.attributes["inner-padding-left"] = div.style.paddingLeft;
|
|
16375
|
-
element.attributes["inner-padding-right"] = div.style.paddingRight;
|
|
16376
|
-
}
|
|
16377
|
-
return element;
|
|
16378
|
-
};
|
|
16379
|
-
function basicElementToStandardElement(element) {
|
|
16380
|
-
const standardType = "standard-" + element.type;
|
|
16381
|
-
switch (element.type) {
|
|
16382
|
-
case ElementType.WRAPPER:
|
|
16383
|
-
case ElementType.HERO:
|
|
16384
|
-
case ElementType.SECTION:
|
|
16385
|
-
case ElementType.GROUP:
|
|
16386
|
-
case ElementType.COLUMN:
|
|
16387
|
-
case ElementType.TEXT:
|
|
16388
|
-
case ElementType.BUTTON:
|
|
16389
|
-
case ElementType.IMAGE:
|
|
16390
|
-
case ElementType.NAVBAR:
|
|
16391
|
-
case ElementType.SOCIAL:
|
|
16392
|
-
case ElementType.DIVIDER:
|
|
16393
|
-
case ElementType.SPACER:
|
|
16394
|
-
case ElementType.SOCIAL_ELEMENT:
|
|
16395
|
-
case ElementType.NAVBAR_LINK:
|
|
16396
|
-
case ElementType.TABLE:
|
|
16397
|
-
const standardElement = __spreadValues({}, element);
|
|
16398
|
-
if ([ElementType.HERO, ElementType.SECTION].includes(
|
|
16399
|
-
element.type
|
|
16400
|
-
)) {
|
|
16401
|
-
standardElement.attributes["background-image-enabled"] = true;
|
|
16402
|
-
}
|
|
16403
|
-
if ([
|
|
16404
|
-
ElementType.BUTTON,
|
|
16405
|
-
ElementType.IMAGE,
|
|
16406
|
-
ElementType.SECTION
|
|
16407
|
-
].includes(element.type)) {
|
|
16408
|
-
if (standardElement.attributes["border"] && standardElement.attributes["border"].trim() !== "none" || standardElement.attributes["border-width"]) {
|
|
16409
|
-
standardElement.attributes["border-enabled"] = true;
|
|
16410
|
-
}
|
|
16411
|
-
}
|
|
16412
|
-
return __spreadProps(__spreadValues({}, formatPadding(element)), {
|
|
16413
|
-
type: standardType
|
|
16414
|
-
});
|
|
16415
|
-
}
|
|
16416
|
-
return element;
|
|
16417
|
-
}
|
|
16418
16352
|
const mjmlToJson = (content2) => {
|
|
16419
|
-
|
|
16420
|
-
|
|
16421
|
-
|
|
16422
|
-
|
|
16423
|
-
|
|
16424
|
-
const root2 = dom.firstChild;
|
|
16425
|
-
if (root2.tagName !== "mjml") {
|
|
16426
|
-
throw new Error("mjmlToJson: invalid mjml. First node must be mjml");
|
|
16427
|
-
}
|
|
16428
|
-
if (root2.tagName === "mjml") {
|
|
16429
|
-
const { json } = mjml(content2, {
|
|
16430
|
-
validationLevel: "soft"
|
|
16431
|
-
});
|
|
16432
|
-
const parseValue = mjmlTransform(json);
|
|
16433
|
-
return parseValue;
|
|
16434
|
-
}
|
|
16435
|
-
const transform = (node) => {
|
|
16436
|
-
if (node.tagName === "parsererror") {
|
|
16437
|
-
throw new Error("Invalid content");
|
|
16438
|
-
}
|
|
16439
|
-
const attributes = {};
|
|
16440
|
-
node.getAttributeNames().forEach((name) => {
|
|
16441
|
-
const value = node.getAttribute(name);
|
|
16442
|
-
if (isString$1(value)) {
|
|
16443
|
-
attributes[name] = value;
|
|
16444
|
-
}
|
|
16445
|
-
});
|
|
16446
|
-
const type = node.tagName.replace("mj-", "");
|
|
16447
|
-
if (!BlockManager.getBlockByType(type)) {
|
|
16448
|
-
if (!node.parentElement || node.parentElement.tagName !== "mj-text")
|
|
16449
|
-
throw new Error("Invalid content");
|
|
16450
|
-
}
|
|
16451
|
-
const block = {
|
|
16452
|
-
type,
|
|
16453
|
-
attributes,
|
|
16454
|
-
data: {},
|
|
16455
|
-
children: [...node.children].filter((item2) => item2 instanceof Element).map(transform)
|
|
16456
|
-
};
|
|
16457
|
-
switch (type) {
|
|
16458
|
-
case ElementType.TEXT:
|
|
16459
|
-
block.data.value.content = node.innerHTML;
|
|
16460
|
-
block.children = [];
|
|
16461
|
-
}
|
|
16462
|
-
return block;
|
|
16463
|
-
};
|
|
16464
|
-
return transform(root2);
|
|
16465
|
-
};
|
|
16466
|
-
function mjmlTransform(data) {
|
|
16467
|
-
const transform = (item2) => {
|
|
16468
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
16469
|
-
const attributes = item2.attributes;
|
|
16470
|
-
switch (item2.tagName) {
|
|
16471
|
-
case "mjml":
|
|
16472
|
-
const body = (_a = item2.children) == null ? void 0 : _a.find((item22) => item22.tagName === "mj-body");
|
|
16473
|
-
if (!body) {
|
|
16474
|
-
throw new Error("Invalid content");
|
|
16475
|
-
}
|
|
16476
|
-
const head = (_b = item2.children) == null ? void 0 : _b.find((item22) => item22.tagName === "mj-head");
|
|
16477
|
-
const fonts = ((_c = head == null ? void 0 : head.children) == null ? void 0 : _c.filter((child) => child.tagName === "mj-font").map((child) => ({
|
|
16478
|
-
name: child.attributes.name,
|
|
16479
|
-
href: child.attributes.href
|
|
16480
|
-
}))) || [];
|
|
16481
|
-
const headStyles = (_d = head == null ? void 0 : head.children) == null ? void 0 : _d.filter((item22) => item22.tagName === "mj-style").map((item22) => ({
|
|
16482
|
-
content: item22.content || "",
|
|
16483
|
-
inline: item22.inline
|
|
16484
|
-
}));
|
|
16485
|
-
const breakpoint = (_e = head == null ? void 0 : head.children) == null ? void 0 : _e.find(
|
|
16486
|
-
(item22) => item22.tagName === "mj-breakpoint"
|
|
16487
|
-
);
|
|
16488
|
-
const preheader = (_f = head == null ? void 0 : head.children) == null ? void 0 : _f.find(
|
|
16489
|
-
(item22) => item22.tagName === "mj-preview"
|
|
16490
|
-
);
|
|
16491
|
-
const page = BlockManager.getBlockByType(ElementType.PAGE).create({
|
|
16492
|
-
attributes: __spreadValues({
|
|
16493
|
-
"margin-top": "0px",
|
|
16494
|
-
"margin-bottom": "0px"
|
|
16495
|
-
}, body.attributes),
|
|
16496
|
-
children: (_g = body.children) == null ? void 0 : _g.map(transform),
|
|
16497
|
-
data: {
|
|
16498
|
-
headStyles,
|
|
16499
|
-
fonts,
|
|
16500
|
-
breakpoint: breakpoint == null ? void 0 : breakpoint.attributes.breakpoint,
|
|
16501
|
-
preheader: preheader == null ? void 0 : preheader.content
|
|
16502
|
-
}
|
|
16503
|
-
});
|
|
16504
|
-
const mjAttributes = ((_i = (_h = head == null ? void 0 : head.children) == null ? void 0 : _h.find((item22) => item22.tagName === "mj-attributes")) == null ? void 0 : _i.children) || [];
|
|
16505
|
-
mjAttributes.forEach((item22) => {
|
|
16506
|
-
item22 = formatPadding(item22);
|
|
16507
|
-
if (item22.tagName === "mj-all") {
|
|
16508
|
-
page.data.globalAttributes = __spreadValues(__spreadValues({}, page.data.globalAttributes), item22.attributes);
|
|
16509
|
-
} else if (item22.tagName === "mj-class") {
|
|
16510
|
-
const name = item22.attributes.name;
|
|
16511
|
-
delete item22.attributes.name;
|
|
16512
|
-
page.data.classAttributes = __spreadProps(__spreadValues({}, page.data.classAttributes), {
|
|
16513
|
-
[name]: item22.attributes
|
|
16514
|
-
});
|
|
16515
|
-
} else {
|
|
16516
|
-
page.data.categoryAttributes = __spreadProps(__spreadValues({}, page.data.categoryAttributes), {
|
|
16517
|
-
[item22.tagName.replace("mj-", "")]: item22.attributes
|
|
16518
|
-
});
|
|
16519
|
-
}
|
|
16520
|
-
});
|
|
16521
|
-
return page;
|
|
16522
|
-
default:
|
|
16523
|
-
const tag = item2.tagName.replace("mj-", "").toLowerCase();
|
|
16524
|
-
const block = BlockManager.getBlockByType(tag);
|
|
16525
|
-
if (!block) {
|
|
16526
|
-
throw new Error(`${tag} block no found `);
|
|
16527
|
-
}
|
|
16528
|
-
if (tag === "social") {
|
|
16529
|
-
const childrenNoPadding = (_j = item2.children) == null ? void 0 : _j.every(
|
|
16530
|
-
(item22) => item22.tagName === "mj-social-element" && !get(item22, "attributes.padding") && !get(item22, "attributes.padding-left") && !get(item22, "attributes.padding-right") && !get(item22, "attributes.padding-top") && !get(item22, "attributes.padding-bottom")
|
|
16531
|
-
);
|
|
16532
|
-
if (childrenNoPadding) {
|
|
16533
|
-
attributes.spacing = "8px";
|
|
16534
|
-
}
|
|
16535
|
-
}
|
|
16536
|
-
if (tag === "social-element" && attributes.src) {
|
|
16537
|
-
attributes.mode = "custom";
|
|
16538
|
-
}
|
|
16539
|
-
const payload = {
|
|
16540
|
-
type: block.type,
|
|
16541
|
-
attributes,
|
|
16542
|
-
data: {},
|
|
16543
|
-
children: []
|
|
16544
|
-
};
|
|
16545
|
-
switch (block.type) {
|
|
16546
|
-
case ElementType.TEXT:
|
|
16547
|
-
case ElementType.BUTTON:
|
|
16548
|
-
case ElementType.NAVBAR_LINK:
|
|
16549
|
-
case ElementType.SOCIAL_ELEMENT:
|
|
16550
|
-
payload.children = HtmlNodeAdapter(item2.content || "");
|
|
16551
|
-
break;
|
|
16552
|
-
case ElementType.TABLE:
|
|
16553
|
-
payload.data.code = item2.content || "";
|
|
16554
|
-
break;
|
|
16555
|
-
default:
|
|
16556
|
-
if (item2.children) {
|
|
16557
|
-
payload.children = item2.children.map(transform);
|
|
16558
|
-
}
|
|
16559
|
-
}
|
|
16560
|
-
if (payload.children.length === 0) {
|
|
16561
|
-
payload.children = [{ text: "" }];
|
|
16562
|
-
}
|
|
16563
|
-
const blockData = block.create(payload);
|
|
16564
|
-
return basicElementToStandardElement(blockData);
|
|
16565
|
-
}
|
|
16566
|
-
};
|
|
16567
|
-
const result = transform(data);
|
|
16568
|
-
return result;
|
|
16569
|
-
}
|
|
16353
|
+
return mjmlToJsonCore({
|
|
16354
|
+
content: content2,
|
|
16355
|
+
mjmlHelper: mjml
|
|
16356
|
+
});
|
|
16357
|
+
};
|
|
16570
16358
|
function previewLoadImage(url) {
|
|
16571
16359
|
return new Promise((resolve) => {
|
|
16572
16360
|
const img = new Image();
|
|
@@ -17170,7 +16958,7 @@ const FontSize$2 = () => {
|
|
|
17170
16958
|
const [fontSizeValue, setFontSizeValue] = useState();
|
|
17171
16959
|
const { setFieldValue } = useEditorContext();
|
|
17172
16960
|
const { selectedNode } = useSelectedNode();
|
|
17173
|
-
|
|
16961
|
+
useElementDefault({
|
|
17174
16962
|
path: null,
|
|
17175
16963
|
type: (selectedNode == null ? void 0 : selectedNode.type) || null
|
|
17176
16964
|
});
|
|
@@ -17205,9 +16993,19 @@ const FontSize$2 = () => {
|
|
|
17205
16993
|
} catch (error2) {
|
|
17206
16994
|
}
|
|
17207
16995
|
}
|
|
16996
|
+
if (!nodeEntry) {
|
|
16997
|
+
[nodeEntry] = Editor.nodes(editor, {
|
|
16998
|
+
match: (node) => {
|
|
16999
|
+
return Text$4.isText(node);
|
|
17000
|
+
},
|
|
17001
|
+
mode: "lowest",
|
|
17002
|
+
voids: true
|
|
17003
|
+
});
|
|
17004
|
+
}
|
|
17208
17005
|
const textNode = nodeEntry == null ? void 0 : nodeEntry[0];
|
|
17209
17006
|
useEffect(() => {
|
|
17210
17007
|
let fontSizeValue2 = textNode == null ? void 0 : textNode.fontSize;
|
|
17008
|
+
console.log(textNode, "textNode?");
|
|
17211
17009
|
if (!fontSizeValue2 && textNode) {
|
|
17212
17010
|
try {
|
|
17213
17011
|
const textDomNode = ReactEditor.toDOMNode(editor, textNode);
|
|
@@ -17215,9 +17013,6 @@ const FontSize$2 = () => {
|
|
|
17215
17013
|
} catch (error2) {
|
|
17216
17014
|
}
|
|
17217
17015
|
}
|
|
17218
|
-
if (!fontSizeValue2) {
|
|
17219
|
-
fontSizeValue2 = get(elementDefault.attributes, "font-size");
|
|
17220
|
-
}
|
|
17221
17016
|
setFontSizeValue(fontSizeValue2);
|
|
17222
17017
|
}, [editor, textNode, textNode == null ? void 0 : textNode.fontSize]);
|
|
17223
17018
|
const optionsList = useMemo(() => {
|
|
@@ -17312,6 +17107,15 @@ const FontFamily$2 = () => {
|
|
|
17312
17107
|
} catch (error2) {
|
|
17313
17108
|
console.warn("FontFamily: failed to get nodes safely", error2);
|
|
17314
17109
|
}
|
|
17110
|
+
if (!nodeEntry) {
|
|
17111
|
+
[nodeEntry] = Editor.nodes(editor, {
|
|
17112
|
+
match: (node) => {
|
|
17113
|
+
return Text$4.isText(node);
|
|
17114
|
+
},
|
|
17115
|
+
mode: "lowest",
|
|
17116
|
+
voids: true
|
|
17117
|
+
});
|
|
17118
|
+
}
|
|
17315
17119
|
const textNode = nodeEntry == null ? void 0 : nodeEntry[0];
|
|
17316
17120
|
useEffect(() => {
|
|
17317
17121
|
var _a;
|
|
@@ -24281,7 +24085,7 @@ function requireReactIs_development() {
|
|
|
24281
24085
|
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
24282
24086
|
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
24283
24087
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
24284
|
-
var
|
|
24088
|
+
var Element = REACT_ELEMENT_TYPE;
|
|
24285
24089
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
24286
24090
|
var Fragment = REACT_FRAGMENT_TYPE;
|
|
24287
24091
|
var Lazy = REACT_LAZY_TYPE;
|
|
@@ -24340,7 +24144,7 @@ function requireReactIs_development() {
|
|
|
24340
24144
|
reactIs_development.ConcurrentMode = ConcurrentMode;
|
|
24341
24145
|
reactIs_development.ContextConsumer = ContextConsumer;
|
|
24342
24146
|
reactIs_development.ContextProvider = ContextProvider;
|
|
24343
|
-
reactIs_development.Element =
|
|
24147
|
+
reactIs_development.Element = Element;
|
|
24344
24148
|
reactIs_development.ForwardRef = ForwardRef;
|
|
24345
24149
|
reactIs_development.Fragment = Fragment;
|
|
24346
24150
|
reactIs_development.Lazy = Lazy;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mjmlToJson: (content: string | Object) => import("easy-email-pro-core").PageElement;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const formatPadding: <T extends Record<string, any>>(element: T) => T;
|