easy-email-extensions 3.1.37 → 3.1.38
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index2.js +116 -114
- package/lib/index2.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +2 -2
package/lib/index2.js
CHANGED
@@ -56,11 +56,11 @@ var __async = (__this, __arguments, generator) => {
|
|
56
56
|
import * as React from "react";
|
57
57
|
import React__default, { Children, isValidElement, cloneElement, createContext, useContext, Component, useMemo, memo, forwardRef, useEffect, useRef, useLayoutEffect, useState, createRef, useImperativeHandle, PureComponent, useCallback, useReducer, Fragment, createElement, Suspense } from "react";
|
58
58
|
import { IconFont, useEditorProps, Stack as Stack$6, getBlockNodeByIdx, useBlock, getEditNode, getEditContent, TextStyle, useFocusIdx, useEditorContext, getShadowRoot, FIXED_CONTAINER_ID, useFocusBlockLayout, scrollBlockEleIntoView, useHoverIdx, useDataTransfer, useRefState, getBlockNodeByChildEle, getDirectionPosition, DATA_ATTRIBUTE_DROP_CONTAINER, BlockAvatarWrapper, getEditorRoot, useActiveTab, ActiveTabKeys } from "easy-email-editor";
|
59
|
-
import { BasicType, ImageManager, BlockManager,
|
59
|
+
import { BasicType, ImageManager, BlockManager, createBlockDataByType, getParentByIdx, getParentIdx, getValueByIdx, getIndexByIdx, getSiblingIdx, getNodeIdxFromClassName, getNodeIdxClassName, getPageIdx, getChildIdx, MjmlToJson, JsonToMjml, getNodeTypeFromClassName } from "easy-email-core";
|
60
60
|
import ReactDOM, { findDOMNode, createPortal } from "react-dom";
|
61
61
|
import { useField, Field, useForm as useForm$1, Form as Form$3, version as version$2, useFormState } from "react-final-form";
|
62
62
|
var index$2 = "";
|
63
|
-
const title = "
|
63
|
+
const title = "_title_15b2l_1";
|
64
64
|
var styles$6 = {
|
65
65
|
title
|
66
66
|
};
|
@@ -38463,9 +38463,7 @@ function enhancer(Component2, changeAdapter) {
|
|
38463
38463
|
const [currentValue, setCurrentValue] = useState(value);
|
38464
38464
|
const debounceCallbackChange = useCallback(lodash.exports.debounce((val) => {
|
38465
38465
|
onChange(val);
|
38466
|
-
},
|
38467
|
-
maxWait: 500
|
38468
|
-
}), [onChange]);
|
38466
|
+
}, 500, {}), [onChange]);
|
38469
38467
|
useEffect(() => {
|
38470
38468
|
setCurrentValue(value);
|
38471
38469
|
}, [value]);
|
@@ -39157,105 +39155,10 @@ function AddFont() {
|
|
39157
39155
|
}
|
39158
39156
|
});
|
39159
39157
|
}
|
39160
|
-
function getContextMergeTags(mergeTags2, context, idx) {
|
39161
|
-
const loop2 = (currentIdx, combineMergeTags) => {
|
39162
|
-
var _a, _b;
|
39163
|
-
const parentBlockData = lodash.exports.get(context, currentIdx);
|
39164
|
-
if (!parentBlockData)
|
39165
|
-
return combineMergeTags;
|
39166
|
-
const parentBlock = BlockManager.getBlockByType(parentBlockData.type);
|
39167
|
-
if (parentBlock && parentBlock.render) {
|
39168
|
-
const dataSource = (_b = (_a = parentBlockData.data) == null ? void 0 : _a.value) == null ? void 0 : _b.dataSource;
|
39169
|
-
if (!dataSource)
|
39170
|
-
return combineMergeTags;
|
39171
|
-
Object.keys(dataSource).forEach((key) => {
|
39172
|
-
let formatKey = dataSource[key];
|
39173
|
-
const loopFormatKey = (currentLoopKeyIdx) => {
|
39174
|
-
const currentParentIdx = getParentIdx(currentLoopKeyIdx);
|
39175
|
-
if (currentParentIdx) {
|
39176
|
-
const currentBlockData = lodash.exports.get(context, currentParentIdx);
|
39177
|
-
if (!currentBlockData)
|
39178
|
-
return formatKey;
|
39179
|
-
currentBlockData.data.value.dataSource && Object.keys(currentBlockData.data.value.dataSource).forEach((item2) => {
|
39180
|
-
formatKey = formatKey.replace(item2, currentBlockData.data.value.dataSource[item2].replace(/{{([^}}]+)}}/g, "$1"));
|
39181
|
-
});
|
39182
|
-
loopFormatKey(currentParentIdx);
|
39183
|
-
}
|
39184
|
-
};
|
39185
|
-
loopFormatKey(currentIdx);
|
39186
|
-
const dataSourcePath = formatKey.replace(/{{([^}}]+)}}/g, "$1");
|
39187
|
-
combineMergeTags = __spreadValues({
|
39188
|
-
[key]: lodash.exports.get(combineMergeTags, dataSourcePath)
|
39189
|
-
}, combineMergeTags);
|
39190
|
-
});
|
39191
|
-
}
|
39192
|
-
const parentIdx = getParentIdx(currentIdx);
|
39193
|
-
if (!parentIdx)
|
39194
|
-
return combineMergeTags;
|
39195
|
-
return loop2(parentIdx, combineMergeTags);
|
39196
|
-
};
|
39197
|
-
return loop2(idx, lodash.exports.cloneDeep(mergeTags2));
|
39198
|
-
}
|
39199
|
-
const MergeTags = React__default.memo((props) => {
|
39200
|
-
const { focusIdx: focusIdx2 } = useFocusIdx();
|
39201
|
-
const {
|
39202
|
-
mergeTags: mergeTags2 = {},
|
39203
|
-
mergeTagGenerate = (m) => `{{${m}}}`,
|
39204
|
-
renderMergeTagContent
|
39205
|
-
} = useEditorProps();
|
39206
|
-
const { values: values2 } = useBlock();
|
39207
|
-
const contextMergeTags = useMemo(() => getContextMergeTags(mergeTags2, values2, focusIdx2), [mergeTags2, values2, focusIdx2]);
|
39208
|
-
const treeOptions = useMemo(() => {
|
39209
|
-
const treeData = [];
|
39210
|
-
const deep = (key, title2, parent2, mapData = []) => {
|
39211
|
-
const currentMapData = {
|
39212
|
-
key: mergeTagGenerate(key),
|
39213
|
-
value: mergeTagGenerate(key),
|
39214
|
-
title: title2,
|
39215
|
-
disabled: lodash.exports.isObject(parent2[key]) || !parent2[title2],
|
39216
|
-
children: []
|
39217
|
-
};
|
39218
|
-
mapData.push(currentMapData);
|
39219
|
-
const current = parent2[title2];
|
39220
|
-
if (current && typeof current === "object") {
|
39221
|
-
Object.keys(current).map((childKey) => deep(key + "." + childKey, childKey, current, currentMapData.children));
|
39222
|
-
}
|
39223
|
-
};
|
39224
|
-
Object.keys(contextMergeTags).map((key) => deep(key, key, contextMergeTags, treeData));
|
39225
|
-
return treeData;
|
39226
|
-
}, [contextMergeTags, mergeTagGenerate]);
|
39227
|
-
const onSelect = useCallback((value) => {
|
39228
|
-
return props.onChange(value);
|
39229
|
-
}, [props]);
|
39230
|
-
const mergeTagContent = useMemo(() => renderMergeTagContent ? renderMergeTagContent({
|
39231
|
-
onChange: props.onChange,
|
39232
|
-
isSelect: Boolean(props.isSelect),
|
39233
|
-
value: props.value
|
39234
|
-
}) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null), [renderMergeTagContent, props.onChange, props.isSelect, props.value]);
|
39235
|
-
if (renderMergeTagContent) {
|
39236
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, mergeTagContent);
|
39237
|
-
}
|
39238
|
-
return /* @__PURE__ */ React__default.createElement("div", {
|
39239
|
-
style: { color: "#333" }
|
39240
|
-
}, props.isSelect ? /* @__PURE__ */ React__default.createElement(TreeSelect$1, {
|
39241
|
-
value: props.value,
|
39242
|
-
size: "small",
|
39243
|
-
dropdownMenuStyle: { maxHeight: 400, overflow: "auto" },
|
39244
|
-
placeholder: "Please select",
|
39245
|
-
treeData: treeOptions,
|
39246
|
-
onChange: (val) => onSelect(val)
|
39247
|
-
}) : /* @__PURE__ */ React__default.createElement(Tree$1, {
|
39248
|
-
defaultExpandedKeys: [],
|
39249
|
-
selectedKeys: [],
|
39250
|
-
treeData: treeOptions,
|
39251
|
-
onSelect: (vals) => onSelect(vals[0])
|
39252
|
-
}));
|
39253
|
-
});
|
39254
39158
|
const AttributesPanelWrapper = (props) => {
|
39255
39159
|
const { focusBlock: focusBlock2, setFocusBlock } = useBlock();
|
39256
|
-
const { mergeTags: mergeTags2 } = useEditorProps();
|
39257
39160
|
const block2 = focusBlock2 && BlockManager.getBlockByType(focusBlock2.type);
|
39258
|
-
|
39161
|
+
useCallback((val) => {
|
39259
39162
|
if (!focusBlock2)
|
39260
39163
|
return;
|
39261
39164
|
focusBlock2.data.hidden = val;
|
@@ -39283,13 +39186,7 @@ const AttributesPanelWrapper = (props) => {
|
|
39283
39186
|
}, /* @__PURE__ */ React__default.createElement(EyeIcon, null), /* @__PURE__ */ React__default.createElement(TextStyle, {
|
39284
39187
|
variation: "strong",
|
39285
39188
|
size: "large"
|
39286
|
-
}, `${block2.name} attributes`)), /* @__PURE__ */ React__default.createElement(Stack$6.Item, null, props.extra))),
|
39287
|
-
spacing: "extraTight"
|
39288
|
-
}, /* @__PURE__ */ React__default.createElement(TextStyle, null, "Hide if"), /* @__PURE__ */ React__default.createElement(MergeTags, {
|
39289
|
-
isSelect: true,
|
39290
|
-
onChange: onChangeHidden,
|
39291
|
-
value: String(focusBlock2.data.hidden)
|
39292
|
-
})))), /* @__PURE__ */ React__default.createElement("div", {
|
39189
|
+
}, `${block2.name} attributes`)), /* @__PURE__ */ React__default.createElement(Stack$6.Item, null, props.extra))))), /* @__PURE__ */ React__default.createElement("div", {
|
39293
39190
|
style: __spreadValues({ padding: "0px" }, props.style)
|
39294
39191
|
}, props.children));
|
39295
39192
|
};
|
@@ -39362,12 +39259,6 @@ function Page() {
|
|
39362
39259
|
helpText: "Allows you to control on which breakpoint the layout should go desktop/mobile.",
|
39363
39260
|
name: `${focusIdx2}.data.value.breakpoint`,
|
39364
39261
|
inline: true
|
39365
|
-
}), /* @__PURE__ */ React__default.createElement(SwitchField, {
|
39366
|
-
inline: true,
|
39367
|
-
label: "Responsive",
|
39368
|
-
name: `${focusIdx2}.data.value.responsive`,
|
39369
|
-
checkedText: "True",
|
39370
|
-
uncheckedText: "False"
|
39371
39262
|
}))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
|
39372
39263
|
name: "1",
|
39373
39264
|
header: "Theme Setting"
|
@@ -40303,6 +40194,117 @@ function BorderColor() {
|
|
40303
40194
|
});
|
40304
40195
|
}, [focusIdx2]);
|
40305
40196
|
}
|
40197
|
+
function getContextMergeTags(mergeTags2, context, idx) {
|
40198
|
+
const loop2 = (currentIdx, combineMergeTags) => {
|
40199
|
+
var _a, _b;
|
40200
|
+
const parentBlockData = lodash.exports.get(context, currentIdx);
|
40201
|
+
if (!parentBlockData)
|
40202
|
+
return combineMergeTags;
|
40203
|
+
const parentBlock = BlockManager.getBlockByType(parentBlockData.type);
|
40204
|
+
if (parentBlock && parentBlock.render) {
|
40205
|
+
const dataSource = (_b = (_a = parentBlockData.data) == null ? void 0 : _a.value) == null ? void 0 : _b.dataSource;
|
40206
|
+
if (!dataSource)
|
40207
|
+
return combineMergeTags;
|
40208
|
+
Object.keys(dataSource).forEach((key) => {
|
40209
|
+
let formatKey = dataSource[key];
|
40210
|
+
const loopFormatKey = (currentLoopKeyIdx) => {
|
40211
|
+
const currentParentIdx = getParentIdx(currentLoopKeyIdx);
|
40212
|
+
if (currentParentIdx) {
|
40213
|
+
const currentBlockData = lodash.exports.get(context, currentParentIdx);
|
40214
|
+
if (!currentBlockData)
|
40215
|
+
return formatKey;
|
40216
|
+
currentBlockData.data.value.dataSource && Object.keys(currentBlockData.data.value.dataSource).forEach((item2) => {
|
40217
|
+
formatKey = formatKey.replace(item2, currentBlockData.data.value.dataSource[item2].replace(/{{([^}}]+)}}/g, "$1"));
|
40218
|
+
});
|
40219
|
+
loopFormatKey(currentParentIdx);
|
40220
|
+
}
|
40221
|
+
};
|
40222
|
+
loopFormatKey(currentIdx);
|
40223
|
+
const dataSourcePath = formatKey.replace(/{{([^}}]+)}}/g, "$1");
|
40224
|
+
combineMergeTags = __spreadValues({
|
40225
|
+
[key]: lodash.exports.get(combineMergeTags, dataSourcePath)
|
40226
|
+
}, combineMergeTags);
|
40227
|
+
});
|
40228
|
+
}
|
40229
|
+
const parentIdx = getParentIdx(currentIdx);
|
40230
|
+
if (!parentIdx)
|
40231
|
+
return combineMergeTags;
|
40232
|
+
return loop2(parentIdx, combineMergeTags);
|
40233
|
+
};
|
40234
|
+
return loop2(idx, lodash.exports.cloneDeep(mergeTags2));
|
40235
|
+
}
|
40236
|
+
const MergeTags = React__default.memo((props) => {
|
40237
|
+
const [expandedKeys, setExpandedKeys] = useState([]);
|
40238
|
+
const { focusIdx: focusIdx2 } = useFocusIdx();
|
40239
|
+
const {
|
40240
|
+
mergeTags: mergeTags2 = {},
|
40241
|
+
mergeTagGenerate = (m) => `{{${m}}}`,
|
40242
|
+
renderMergeTagContent
|
40243
|
+
} = useEditorProps();
|
40244
|
+
const { values: values2 } = useBlock();
|
40245
|
+
const contextMergeTags = useMemo(() => getContextMergeTags(mergeTags2, values2, focusIdx2), [mergeTags2, values2, focusIdx2]);
|
40246
|
+
const treeOptions = useMemo(() => {
|
40247
|
+
const treeData = [];
|
40248
|
+
const deep = (key, title2, parent2, mapData = []) => {
|
40249
|
+
const currentMapData = {
|
40250
|
+
key,
|
40251
|
+
value: key,
|
40252
|
+
title: title2,
|
40253
|
+
children: []
|
40254
|
+
};
|
40255
|
+
mapData.push(currentMapData);
|
40256
|
+
const current = parent2[title2];
|
40257
|
+
if (current && typeof current === "object") {
|
40258
|
+
Object.keys(current).map((childKey) => deep(key + "." + childKey, childKey, current, currentMapData.children));
|
40259
|
+
}
|
40260
|
+
};
|
40261
|
+
Object.keys(contextMergeTags).map((key) => deep(key, key, contextMergeTags, treeData));
|
40262
|
+
return treeData;
|
40263
|
+
}, [contextMergeTags]);
|
40264
|
+
const onSelect = useCallback((key) => {
|
40265
|
+
const value = lodash.exports.get(contextMergeTags, key);
|
40266
|
+
if (lodash.exports.isObject(value)) {
|
40267
|
+
setExpandedKeys((keys2) => {
|
40268
|
+
console.log("keys", keys2, key);
|
40269
|
+
if (keys2.includes(key)) {
|
40270
|
+
return keys2.filter((k) => k !== key);
|
40271
|
+
} else {
|
40272
|
+
return [...keys2, key];
|
40273
|
+
}
|
40274
|
+
});
|
40275
|
+
return;
|
40276
|
+
}
|
40277
|
+
return props.onChange(mergeTagGenerate(value));
|
40278
|
+
}, [contextMergeTags, props, mergeTagGenerate]);
|
40279
|
+
const mergeTagContent = useMemo(() => renderMergeTagContent ? renderMergeTagContent({
|
40280
|
+
onChange: props.onChange,
|
40281
|
+
isSelect: Boolean(props.isSelect),
|
40282
|
+
value: props.value
|
40283
|
+
}) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null), [renderMergeTagContent, props.onChange, props.isSelect, props.value]);
|
40284
|
+
if (renderMergeTagContent) {
|
40285
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, mergeTagContent);
|
40286
|
+
}
|
40287
|
+
return /* @__PURE__ */ React__default.createElement("div", {
|
40288
|
+
style: { color: "#333" }
|
40289
|
+
}, props.isSelect ? /* @__PURE__ */ React__default.createElement(TreeSelect$1, {
|
40290
|
+
value: props.value,
|
40291
|
+
size: "small",
|
40292
|
+
dropdownMenuStyle: { maxHeight: 400, overflow: "auto" },
|
40293
|
+
placeholder: "Please select",
|
40294
|
+
treeData: treeOptions,
|
40295
|
+
onChange: (val) => onSelect(val)
|
40296
|
+
}) : /* @__PURE__ */ React__default.createElement(Tree$1, {
|
40297
|
+
expandedKeys,
|
40298
|
+
onExpand: setExpandedKeys,
|
40299
|
+
selectedKeys: [],
|
40300
|
+
treeData: treeOptions,
|
40301
|
+
onSelect: (vals) => onSelect(vals[0]),
|
40302
|
+
style: {
|
40303
|
+
maxHeight: 400,
|
40304
|
+
overflow: "auto"
|
40305
|
+
}
|
40306
|
+
}));
|
40307
|
+
});
|
40306
40308
|
const borderStyleOptions = [
|
40307
40309
|
{
|
40308
40310
|
value: "dashed",
|