easy-email-extensions 3.1.37 → 3.1.44
Sign up to get free protection for your applications and to get access to all the features.
- package/License +22 -0
- package/lib/BlockLayer/index.d.ts +4 -1
- package/lib/SimpleLayout/SimpleLayout.d.ts +2 -1
- package/lib/index2.js +182 -145
- package/lib/index2.js.map +1 -1
- package/lib/style.css +1 -1
- package/lib/utils/getBlockTitle.d.ts +1 -1
- package/package.json +2 -2
package/License
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2021-2022 AfterShip
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -7,4 +7,7 @@ export interface IBlockDataWithId extends IBlockData {
|
|
7
7
|
children: IBlockDataWithId[];
|
8
8
|
className?: string;
|
9
9
|
}
|
10
|
-
export
|
10
|
+
export interface BlockLayerProps {
|
11
|
+
renderTitle?: (block: IBlockDataWithId) => React.ReactNode;
|
12
|
+
}
|
13
|
+
export declare function BlockLayer(props: BlockLayerProps): JSX.Element | null;
|
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
|
};
|
@@ -38305,12 +38305,17 @@ const PresetColorsProvider = (props) => {
|
|
38305
38305
|
setCurrentColors(newColors);
|
38306
38306
|
}
|
38307
38307
|
}, [currentColors, setCurrentColors]);
|
38308
|
-
|
38309
|
-
|
38308
|
+
const value = useMemo(() => {
|
38309
|
+
return {
|
38310
38310
|
colors: currentColors,
|
38311
38311
|
addCurrentColor
|
38312
|
-
}
|
38313
|
-
},
|
38312
|
+
};
|
38313
|
+
}, [addCurrentColor, currentColors]);
|
38314
|
+
return useMemo(() => {
|
38315
|
+
return /* @__PURE__ */ React__default.createElement(PresetColorsContext.Provider, {
|
38316
|
+
value
|
38317
|
+
}, props.children);
|
38318
|
+
}, [props.children, value]);
|
38314
38319
|
};
|
38315
38320
|
function ColorPicker(props) {
|
38316
38321
|
const { colors: presetColors, addCurrentColor } = useContext(PresetColorsContext);
|
@@ -38463,9 +38468,7 @@ function enhancer(Component2, changeAdapter) {
|
|
38463
38468
|
const [currentValue, setCurrentValue] = useState(value);
|
38464
38469
|
const debounceCallbackChange = useCallback(lodash.exports.debounce((val) => {
|
38465
38470
|
onChange(val);
|
38466
|
-
},
|
38467
|
-
maxWait: 500
|
38468
|
-
}), [onChange]);
|
38471
|
+
}, 500, {}), [onChange]);
|
38469
38472
|
useEffect(() => {
|
38470
38473
|
setCurrentValue(value);
|
38471
38474
|
}, [value]);
|
@@ -39157,105 +39160,10 @@ function AddFont() {
|
|
39157
39160
|
}
|
39158
39161
|
});
|
39159
39162
|
}
|
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
39163
|
const AttributesPanelWrapper = (props) => {
|
39255
39164
|
const { focusBlock: focusBlock2, setFocusBlock } = useBlock();
|
39256
|
-
const { mergeTags: mergeTags2 } = useEditorProps();
|
39257
39165
|
const block2 = focusBlock2 && BlockManager.getBlockByType(focusBlock2.type);
|
39258
|
-
|
39166
|
+
useCallback((val) => {
|
39259
39167
|
if (!focusBlock2)
|
39260
39168
|
return;
|
39261
39169
|
focusBlock2.data.hidden = val;
|
@@ -39283,13 +39191,7 @@ const AttributesPanelWrapper = (props) => {
|
|
39283
39191
|
}, /* @__PURE__ */ React__default.createElement(EyeIcon, null), /* @__PURE__ */ React__default.createElement(TextStyle, {
|
39284
39192
|
variation: "strong",
|
39285
39193
|
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", {
|
39194
|
+
}, `${block2.name} attributes`)), /* @__PURE__ */ React__default.createElement(Stack$6.Item, null, props.extra))))), /* @__PURE__ */ React__default.createElement("div", {
|
39293
39195
|
style: __spreadValues({ padding: "0px" }, props.style)
|
39294
39196
|
}, props.children));
|
39295
39197
|
};
|
@@ -39362,12 +39264,6 @@ function Page() {
|
|
39362
39264
|
helpText: "Allows you to control on which breakpoint the layout should go desktop/mobile.",
|
39363
39265
|
name: `${focusIdx2}.data.value.breakpoint`,
|
39364
39266
|
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
39267
|
}))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
|
39372
39268
|
name: "1",
|
39373
39269
|
header: "Theme Setting"
|
@@ -40303,6 +40199,116 @@ function BorderColor() {
|
|
40303
40199
|
});
|
40304
40200
|
}, [focusIdx2]);
|
40305
40201
|
}
|
40202
|
+
function getContextMergeTags(mergeTags2, context, idx) {
|
40203
|
+
const loop2 = (currentIdx, combineMergeTags) => {
|
40204
|
+
var _a, _b;
|
40205
|
+
const parentBlockData = lodash.exports.get(context, currentIdx);
|
40206
|
+
if (!parentBlockData)
|
40207
|
+
return combineMergeTags;
|
40208
|
+
const parentBlock = BlockManager.getBlockByType(parentBlockData.type);
|
40209
|
+
if (parentBlock && parentBlock.render) {
|
40210
|
+
const dataSource = (_b = (_a = parentBlockData.data) == null ? void 0 : _a.value) == null ? void 0 : _b.dataSource;
|
40211
|
+
if (!dataSource)
|
40212
|
+
return combineMergeTags;
|
40213
|
+
Object.keys(dataSource).forEach((key) => {
|
40214
|
+
let formatKey = dataSource[key];
|
40215
|
+
const loopFormatKey = (currentLoopKeyIdx) => {
|
40216
|
+
const currentParentIdx = getParentIdx(currentLoopKeyIdx);
|
40217
|
+
if (currentParentIdx) {
|
40218
|
+
const currentBlockData = lodash.exports.get(context, currentParentIdx);
|
40219
|
+
if (!currentBlockData)
|
40220
|
+
return formatKey;
|
40221
|
+
currentBlockData.data.value.dataSource && Object.keys(currentBlockData.data.value.dataSource).forEach((item2) => {
|
40222
|
+
formatKey = formatKey.replace(item2, currentBlockData.data.value.dataSource[item2].replace(/{{([^}}]+)}}/g, "$1"));
|
40223
|
+
});
|
40224
|
+
loopFormatKey(currentParentIdx);
|
40225
|
+
}
|
40226
|
+
};
|
40227
|
+
loopFormatKey(currentIdx);
|
40228
|
+
const dataSourcePath = formatKey.replace(/{{([^}}]+)}}/g, "$1");
|
40229
|
+
combineMergeTags = __spreadValues({
|
40230
|
+
[key]: lodash.exports.get(combineMergeTags, dataSourcePath)
|
40231
|
+
}, combineMergeTags);
|
40232
|
+
});
|
40233
|
+
}
|
40234
|
+
const parentIdx = getParentIdx(currentIdx);
|
40235
|
+
if (!parentIdx)
|
40236
|
+
return combineMergeTags;
|
40237
|
+
return loop2(parentIdx, combineMergeTags);
|
40238
|
+
};
|
40239
|
+
return loop2(idx, lodash.exports.cloneDeep(mergeTags2));
|
40240
|
+
}
|
40241
|
+
const MergeTags = React__default.memo((props) => {
|
40242
|
+
const [expandedKeys, setExpandedKeys] = useState([]);
|
40243
|
+
const { focusIdx: focusIdx2 } = useFocusIdx();
|
40244
|
+
const {
|
40245
|
+
mergeTags: mergeTags2 = {},
|
40246
|
+
mergeTagGenerate = (m) => `{{${m}}}`,
|
40247
|
+
renderMergeTagContent
|
40248
|
+
} = useEditorProps();
|
40249
|
+
const { values: values2 } = useBlock();
|
40250
|
+
const contextMergeTags = useMemo(() => getContextMergeTags(mergeTags2, values2, focusIdx2), [mergeTags2, values2, focusIdx2]);
|
40251
|
+
const treeOptions = useMemo(() => {
|
40252
|
+
const treeData = [];
|
40253
|
+
const deep = (key, title2, parent2, mapData = []) => {
|
40254
|
+
const currentMapData = {
|
40255
|
+
key,
|
40256
|
+
value: key,
|
40257
|
+
title: title2,
|
40258
|
+
children: []
|
40259
|
+
};
|
40260
|
+
mapData.push(currentMapData);
|
40261
|
+
const current = parent2[title2];
|
40262
|
+
if (current && typeof current === "object") {
|
40263
|
+
Object.keys(current).map((childKey) => deep(key + "." + childKey, childKey, current, currentMapData.children));
|
40264
|
+
}
|
40265
|
+
};
|
40266
|
+
Object.keys(contextMergeTags).map((key) => deep(key, key, contextMergeTags, treeData));
|
40267
|
+
return treeData;
|
40268
|
+
}, [contextMergeTags]);
|
40269
|
+
const onSelect = useCallback((key) => {
|
40270
|
+
const value = lodash.exports.get(contextMergeTags, key);
|
40271
|
+
if (lodash.exports.isObject(value)) {
|
40272
|
+
setExpandedKeys((keys2) => {
|
40273
|
+
if (keys2.includes(key)) {
|
40274
|
+
return keys2.filter((k) => k !== key);
|
40275
|
+
} else {
|
40276
|
+
return [...keys2, key];
|
40277
|
+
}
|
40278
|
+
});
|
40279
|
+
return;
|
40280
|
+
}
|
40281
|
+
return props.onChange(mergeTagGenerate(key));
|
40282
|
+
}, [contextMergeTags, props, mergeTagGenerate]);
|
40283
|
+
const mergeTagContent = useMemo(() => renderMergeTagContent ? renderMergeTagContent({
|
40284
|
+
onChange: props.onChange,
|
40285
|
+
isSelect: Boolean(props.isSelect),
|
40286
|
+
value: props.value
|
40287
|
+
}) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null), [renderMergeTagContent, props.onChange, props.isSelect, props.value]);
|
40288
|
+
if (renderMergeTagContent) {
|
40289
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, mergeTagContent);
|
40290
|
+
}
|
40291
|
+
return /* @__PURE__ */ React__default.createElement("div", {
|
40292
|
+
style: { color: "#333" }
|
40293
|
+
}, props.isSelect ? /* @__PURE__ */ React__default.createElement(TreeSelect$1, {
|
40294
|
+
value: props.value,
|
40295
|
+
size: "small",
|
40296
|
+
dropdownMenuStyle: { maxHeight: 400, overflow: "auto" },
|
40297
|
+
placeholder: "Please select",
|
40298
|
+
treeData: treeOptions,
|
40299
|
+
onChange: (val) => onSelect(val)
|
40300
|
+
}) : /* @__PURE__ */ React__default.createElement(Tree$1, {
|
40301
|
+
expandedKeys,
|
40302
|
+
onExpand: setExpandedKeys,
|
40303
|
+
selectedKeys: [],
|
40304
|
+
treeData: treeOptions,
|
40305
|
+
onSelect: (vals) => onSelect(vals[0]),
|
40306
|
+
style: {
|
40307
|
+
maxHeight: 400,
|
40308
|
+
overflow: "auto"
|
40309
|
+
}
|
40310
|
+
}));
|
40311
|
+
});
|
40306
40312
|
const borderStyleOptions = [
|
40307
40313
|
{
|
40308
40314
|
value: "dashed",
|
@@ -41313,6 +41319,40 @@ class BlockAttributeConfigurationManager {
|
|
41313
41319
|
}
|
41314
41320
|
}
|
41315
41321
|
__publicField(BlockAttributeConfigurationManager, "map", __spreadValues({}, blocks));
|
41322
|
+
const SelectionRangeContext = React__default.createContext({
|
41323
|
+
selectionRange: null,
|
41324
|
+
setSelectionRange: () => {
|
41325
|
+
}
|
41326
|
+
});
|
41327
|
+
const SelectionRangeProvider = (props) => {
|
41328
|
+
const [selectionRange, setSelectionRange] = useState(null);
|
41329
|
+
useEffect(() => {
|
41330
|
+
const onSelectionChange = () => {
|
41331
|
+
try {
|
41332
|
+
const range2 = getShadowRoot().getSelection().getRangeAt(0);
|
41333
|
+
if (range2) {
|
41334
|
+
setSelectionRange(range2);
|
41335
|
+
}
|
41336
|
+
} catch (error2) {
|
41337
|
+
}
|
41338
|
+
};
|
41339
|
+
document.addEventListener("selectionchange", onSelectionChange);
|
41340
|
+
return () => {
|
41341
|
+
document.removeEventListener("selectionchange", onSelectionChange);
|
41342
|
+
};
|
41343
|
+
}, []);
|
41344
|
+
const value = useMemo(() => {
|
41345
|
+
return {
|
41346
|
+
selectionRange,
|
41347
|
+
setSelectionRange
|
41348
|
+
};
|
41349
|
+
}, [selectionRange]);
|
41350
|
+
return useMemo(() => {
|
41351
|
+
return /* @__PURE__ */ React__default.createElement(SelectionRangeContext.Provider, {
|
41352
|
+
value
|
41353
|
+
}, props.children);
|
41354
|
+
}, [props.children, value]);
|
41355
|
+
};
|
41316
41356
|
function AttributePanel() {
|
41317
41357
|
const { values: values2, focusBlock: focusBlock2 } = useBlock();
|
41318
41358
|
const { initialized } = useEditorContext();
|
@@ -41322,7 +41362,7 @@ function AttributePanel() {
|
|
41322
41362
|
const shadowRoot = getShadowRoot();
|
41323
41363
|
if (!value || !initialized)
|
41324
41364
|
return null;
|
41325
|
-
return /* @__PURE__ */ React__default.createElement(PresetColorsProvider, null, Com ? /* @__PURE__ */ React__default.createElement(Com, {
|
41365
|
+
return /* @__PURE__ */ React__default.createElement(SelectionRangeProvider, null, /* @__PURE__ */ React__default.createElement(PresetColorsProvider, null, Com ? /* @__PURE__ */ React__default.createElement(Com, {
|
41326
41366
|
key: focusIdx2
|
41327
41367
|
}) : /* @__PURE__ */ React__default.createElement("div", {
|
41328
41368
|
style: { marginTop: 200, padding: "0 50px" }
|
@@ -41338,27 +41378,10 @@ function AttributePanel() {
|
|
41338
41378
|
outline: none;
|
41339
41379
|
cursor: text;
|
41340
41380
|
}
|
41341
|
-
`), shadowRoot));
|
41381
|
+
`), shadowRoot)));
|
41342
41382
|
}
|
41343
|
-
function
|
41344
|
-
const {
|
41345
|
-
const { mergeTags: mergeTags2 } = useEditorProps();
|
41346
|
-
const [selectionRange, setSelectionRange] = useState(null);
|
41347
|
-
useEffect(() => {
|
41348
|
-
const onSelectionChange = () => {
|
41349
|
-
try {
|
41350
|
-
const range2 = getShadowRoot().getSelection().getRangeAt(0);
|
41351
|
-
if (range2) {
|
41352
|
-
setSelectionRange(range2);
|
41353
|
-
}
|
41354
|
-
} catch (error2) {
|
41355
|
-
}
|
41356
|
-
};
|
41357
|
-
document.addEventListener("selectionchange", onSelectionChange);
|
41358
|
-
return () => {
|
41359
|
-
document.removeEventListener("selectionchange", onSelectionChange);
|
41360
|
-
};
|
41361
|
-
}, []);
|
41383
|
+
function useSelectionRange() {
|
41384
|
+
const { selectionRange, setSelectionRange } = useContext(SelectionRangeContext);
|
41362
41385
|
const restoreRange = useCallback((range2) => {
|
41363
41386
|
const selection = getShadowRoot().getSelection();
|
41364
41387
|
selection.removeAllRanges();
|
@@ -41367,6 +41390,16 @@ function Tools(props) {
|
|
41367
41390
|
newRange.setEnd(range2.endContainer, range2.endOffset);
|
41368
41391
|
selection.addRange(newRange);
|
41369
41392
|
}, []);
|
41393
|
+
return {
|
41394
|
+
selectionRange,
|
41395
|
+
setSelectionRange,
|
41396
|
+
restoreRange
|
41397
|
+
};
|
41398
|
+
}
|
41399
|
+
function Tools(props) {
|
41400
|
+
const { container: container2 } = props;
|
41401
|
+
const { mergeTags: mergeTags2 } = useEditorProps();
|
41402
|
+
const { selectionRange, restoreRange } = useSelectionRange();
|
41370
41403
|
const execCommand = (cmd, val) => {
|
41371
41404
|
if (!container2) {
|
41372
41405
|
console.error("No container");
|
@@ -41621,6 +41654,7 @@ function FieldWrapper(props) {
|
|
41621
41654
|
const _a = props, { input } = _a, rest = __objRest(_a, ["input"]);
|
41622
41655
|
const debounceCallbackChange = useCallback(lodash.exports.debounce((val) => {
|
41623
41656
|
input.onChange(val);
|
41657
|
+
input.onBlur();
|
41624
41658
|
}, 100), [input]);
|
41625
41659
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(RichTextToolBar, {
|
41626
41660
|
onChange: debounceCallbackChange
|
@@ -41997,11 +42031,12 @@ function getBlockTitle(blockData, isFromContent = true) {
|
|
41997
42031
|
tempEle.innerHTML = blockData.data.value.content;
|
41998
42032
|
return tempEle.innerText;
|
41999
42033
|
}
|
42000
|
-
const blockName = (_a = BlockManager.getBlockByType(blockData.type)) == null ? void 0 : _a.name;
|
42034
|
+
const blockName = ((_a = BlockManager.getBlockByType(blockData.type)) == null ? void 0 : _a.name) || "";
|
42001
42035
|
return blockName;
|
42002
42036
|
}
|
42003
|
-
function BlockLayer() {
|
42037
|
+
function BlockLayer(props) {
|
42004
42038
|
const { pageData: pageData2 } = useEditorContext();
|
42039
|
+
const { renderTitle: propsRenderTitle } = props;
|
42005
42040
|
const { focusIdx: focusIdx2, setFocusIdx } = useFocusIdx();
|
42006
42041
|
const { setHoverIdx, setIsDragging, setDirection } = useHoverIdx();
|
42007
42042
|
const { moveBlock, setValueByIdx: setValueByIdx2, copyBlock, removeBlock, values: values2 } = useBlock();
|
@@ -42018,7 +42053,7 @@ function BlockLayer() {
|
|
42018
42053
|
}, [setValueByIdx2, valueRef]);
|
42019
42054
|
const renderTitle = useCallback((data) => {
|
42020
42055
|
const isPage = data.type === BasicType.PAGE;
|
42021
|
-
const title2 = getBlockTitle(data);
|
42056
|
+
const title2 = propsRenderTitle ? propsRenderTitle(data) : getBlockTitle(data);
|
42022
42057
|
return /* @__PURE__ */ React__default.createElement("div", {
|
42023
42058
|
"data-tree-idx": data.id,
|
42024
42059
|
className: classnames(styles$6.title, !isPage && getNodeIdxClassName(data.id), !isPage && "email-block")
|
@@ -42029,7 +42064,7 @@ function BlockLayer() {
|
|
42029
42064
|
iconName: getIconNameByBlockType(data.type),
|
42030
42065
|
style: { fontSize: 12, color: "#999" }
|
42031
42066
|
}), /* @__PURE__ */ React__default.createElement("div", {
|
42032
|
-
title: title2,
|
42067
|
+
title: lodash.exports.isString(title2) ? title2 : "",
|
42033
42068
|
style: { overflow: "hidden", whiteSpace: "nowrap", width: "5em" }
|
42034
42069
|
}, /* @__PURE__ */ React__default.createElement(TextStyle, {
|
42035
42070
|
size: "smallest"
|
@@ -42039,7 +42074,7 @@ function BlockLayer() {
|
|
42039
42074
|
blockData: data,
|
42040
42075
|
onToggleVisible
|
42041
42076
|
})));
|
42042
|
-
}, [onToggleVisible]);
|
42077
|
+
}, [onToggleVisible, propsRenderTitle]);
|
42043
42078
|
const treeData = useMemo(() => {
|
42044
42079
|
const copyData = lodash.exports.cloneDeep(pageData2);
|
42045
42080
|
const loop2 = (item2, id, parent2) => {
|
@@ -45173,7 +45208,9 @@ const SimpleLayout = (props) => {
|
|
45173
45208
|
}, /* @__PURE__ */ React__default.createElement(Card$1, {
|
45174
45209
|
title: "Layout",
|
45175
45210
|
style: { border: "none" }
|
45176
|
-
}, /* @__PURE__ */ React__default.createElement(BlockLayer,
|
45211
|
+
}, /* @__PURE__ */ React__default.createElement(BlockLayer, {
|
45212
|
+
renderTitle: props.renderTitle
|
45213
|
+
}))))), /* @__PURE__ */ React__default.createElement(Layout$1, {
|
45177
45214
|
style: { height: containerHeight }
|
45178
45215
|
}, props.children), /* @__PURE__ */ React__default.createElement(Layout$1.Sider, {
|
45179
45216
|
style: {
|