easy-email-pro-theme 1.57.7 → 1.57.9
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";
|
|
@@ -16331,239 +16331,12 @@ const PreventFocusWrapper = ({
|
|
|
16331
16331
|
children
|
|
16332
16332
|
);
|
|
16333
16333
|
};
|
|
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
16334
|
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
|
-
const payload = {
|
|
16537
|
-
type: block.type,
|
|
16538
|
-
attributes,
|
|
16539
|
-
data: {},
|
|
16540
|
-
children: []
|
|
16541
|
-
};
|
|
16542
|
-
switch (block.type) {
|
|
16543
|
-
case ElementType.TEXT:
|
|
16544
|
-
case ElementType.BUTTON:
|
|
16545
|
-
case ElementType.NAVBAR_LINK:
|
|
16546
|
-
case ElementType.SOCIAL_ELEMENT:
|
|
16547
|
-
payload.children = HtmlNodeAdapter(item2.content || "");
|
|
16548
|
-
break;
|
|
16549
|
-
case ElementType.TABLE:
|
|
16550
|
-
payload.data.code = item2.content || "";
|
|
16551
|
-
break;
|
|
16552
|
-
default:
|
|
16553
|
-
if (item2.children) {
|
|
16554
|
-
payload.children = item2.children.map(transform);
|
|
16555
|
-
}
|
|
16556
|
-
}
|
|
16557
|
-
if (payload.children.length === 0) {
|
|
16558
|
-
payload.children = [{ text: "" }];
|
|
16559
|
-
}
|
|
16560
|
-
const blockData = block.create(payload);
|
|
16561
|
-
return basicElementToStandardElement(blockData);
|
|
16562
|
-
}
|
|
16563
|
-
};
|
|
16564
|
-
const result = transform(data);
|
|
16565
|
-
return result;
|
|
16566
|
-
}
|
|
16335
|
+
return mjmlToJsonCore({
|
|
16336
|
+
content: content2,
|
|
16337
|
+
mjmlHelper: mjml
|
|
16338
|
+
});
|
|
16339
|
+
};
|
|
16567
16340
|
function previewLoadImage(url) {
|
|
16568
16341
|
return new Promise((resolve) => {
|
|
16569
16342
|
const img = new Image();
|
|
@@ -24278,7 +24051,7 @@ function requireReactIs_development() {
|
|
|
24278
24051
|
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
24279
24052
|
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
24280
24053
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
24281
|
-
var
|
|
24054
|
+
var Element = REACT_ELEMENT_TYPE;
|
|
24282
24055
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
24283
24056
|
var Fragment = REACT_FRAGMENT_TYPE;
|
|
24284
24057
|
var Lazy = REACT_LAZY_TYPE;
|
|
@@ -24337,7 +24110,7 @@ function requireReactIs_development() {
|
|
|
24337
24110
|
reactIs_development.ConcurrentMode = ConcurrentMode;
|
|
24338
24111
|
reactIs_development.ContextConsumer = ContextConsumer;
|
|
24339
24112
|
reactIs_development.ContextProvider = ContextProvider;
|
|
24340
|
-
reactIs_development.Element =
|
|
24113
|
+
reactIs_development.Element = Element;
|
|
24341
24114
|
reactIs_development.ForwardRef = ForwardRef;
|
|
24342
24115
|
reactIs_development.Fragment = Fragment;
|
|
24343
24116
|
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;
|