easy-email-pro-theme 1.53.1 → 1.54.0
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 +765 -236
- package/lib/style.css +61 -3
- package/lib/typings/components/ConfigurationPanel/Schemas/PageFooter.d.ts +2 -0
- package/lib/typings/components/ConfigurationPanel/Schemas/PageHeader.d.ts +2 -0
- package/lib/typings/components/HoveringToolbar/RichTextBar.d.ts +6 -1
- package/lib/typings/components/index.d.ts +3 -1
- package/lib/typings/utils/normalizeElements.d.ts +2 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -516,36 +516,51 @@ const RetroStyleText = '[data-slate-block=page] {\n min-height: 300px;\n}\n\n[d
|
|
|
516
516
|
const withTheme$1 = (editor) => {
|
|
517
517
|
const { insertBreak, normalizeNode, deleteBackward, apply: apply2, insertSoftBreak } = editor;
|
|
518
518
|
editor.insertBreak = (...args) => {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
519
|
+
try {
|
|
520
|
+
if (!editor.selection) {
|
|
521
|
+
insertBreak(...args);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const node = Editor.above(editor, {
|
|
525
|
+
match: NodeUtils.isTextElement
|
|
526
|
+
});
|
|
527
|
+
if (!node)
|
|
528
|
+
return;
|
|
529
|
+
insertBreak(...args);
|
|
530
|
+
} catch (error2) {
|
|
531
|
+
insertBreak(...args);
|
|
532
|
+
}
|
|
525
533
|
};
|
|
526
534
|
editor.insertSoftBreak = () => {
|
|
527
535
|
};
|
|
528
536
|
editor.deleteBackward = (unit) => {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
if (contentElementEntry && editor.selection) {
|
|
533
|
-
const elementLength = contentElementEntry[1].length;
|
|
534
|
-
const childPath = editor.selection.anchor.path.filter(
|
|
535
|
-
(_, index2) => index2 > elementLength - 1
|
|
536
|
-
);
|
|
537
|
-
const isCollapsed = Boolean(
|
|
538
|
-
editor.selection && (Range.isCollapsed(editor.selection) || Editor.string(editor, editor.selection) === "")
|
|
539
|
-
);
|
|
540
|
-
const isFirstNode = childPath.every((item2) => item2 === 0);
|
|
541
|
-
if (isCollapsed && editor.selection.anchor.offset === 0 && editor.selection.focus.offset === 0 && isFirstNode) {
|
|
542
|
-
if (editor.selection && Editor.string(editor, editor.selection) === Editor.string(editor, contentElementEntry[1])) {
|
|
543
|
-
editor.unwrapNodes({
|
|
544
|
-
match: NodeUtils.isHTMLBlockNodeElement
|
|
545
|
-
});
|
|
546
|
-
}
|
|
537
|
+
try {
|
|
538
|
+
if (!editor.selection) {
|
|
539
|
+
deleteBackward(unit);
|
|
547
540
|
return;
|
|
548
541
|
}
|
|
542
|
+
const contentElementEntry = Editor.above(editor, {
|
|
543
|
+
match: NodeUtils.isContentElement
|
|
544
|
+
});
|
|
545
|
+
if (contentElementEntry && editor.selection) {
|
|
546
|
+
const elementLength = contentElementEntry[1].length;
|
|
547
|
+
const childPath = editor.selection.anchor.path.filter(
|
|
548
|
+
(_, index2) => index2 > elementLength - 1
|
|
549
|
+
);
|
|
550
|
+
const isCollapsed = Boolean(
|
|
551
|
+
editor.selection && (Range.isCollapsed(editor.selection) || Editor.string(editor, editor.selection) === "")
|
|
552
|
+
);
|
|
553
|
+
const isFirstNode = childPath.every((item2) => item2 === 0);
|
|
554
|
+
if (isCollapsed && editor.selection.anchor.offset === 0 && editor.selection.focus.offset === 0 && isFirstNode) {
|
|
555
|
+
if (editor.selection && Editor.string(editor, editor.selection) === Editor.string(editor, contentElementEntry[1])) {
|
|
556
|
+
editor.unwrapNodes({
|
|
557
|
+
match: NodeUtils.isHTMLBlockNodeElement
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
} catch (error2) {
|
|
549
564
|
}
|
|
550
565
|
deleteBackward(unit);
|
|
551
566
|
};
|
|
@@ -906,6 +921,11 @@ const DraggingProvider = ({
|
|
|
906
921
|
removeSelectedStyle();
|
|
907
922
|
return;
|
|
908
923
|
}
|
|
924
|
+
const disableDragElement = NodeUtils.isPageHeaderElement(dropElement) || NodeUtils.isPageFooterElement(dropElement);
|
|
925
|
+
if (disableDragElement) {
|
|
926
|
+
removeSelectedStyle();
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
909
929
|
let dropPath = ReactEditor.findPath(editor, dropElement);
|
|
910
930
|
let source = null;
|
|
911
931
|
if ((propsData == null ? void 0 : propsData.action) === "move") {
|
|
@@ -1817,6 +1837,9 @@ const useCopyBlock = () => {
|
|
|
1817
1837
|
if (lock)
|
|
1818
1838
|
return;
|
|
1819
1839
|
const block = Node.get(editor, path2);
|
|
1840
|
+
if (NodeUtils.isPageHeaderElement(block) || NodeUtils.isPageFooterElement(block)) {
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1820
1843
|
const next = Path.next(path2);
|
|
1821
1844
|
const newBlock = assignIdsToElementTree(block, true);
|
|
1822
1845
|
Transforms.insertNodes(editor, newBlock, {
|
|
@@ -1887,6 +1910,10 @@ const useDeleteBlock = () => {
|
|
|
1887
1910
|
(path2) => {
|
|
1888
1911
|
if (lock)
|
|
1889
1912
|
return;
|
|
1913
|
+
const element = Node.get(editor, path2);
|
|
1914
|
+
if (NodeUtils.isPageHeaderElement(element) || NodeUtils.isPageFooterElement(element)) {
|
|
1915
|
+
return;
|
|
1916
|
+
}
|
|
1890
1917
|
try {
|
|
1891
1918
|
const [entry] = Editor.nodes(editor, {
|
|
1892
1919
|
match(node, currentPath) {
|
|
@@ -2292,6 +2319,7 @@ const ElementTools$1 = ({ element, nodeElement, path: path2 }) => {
|
|
|
2292
2319
|
isHideBackIcon = true;
|
|
2293
2320
|
}
|
|
2294
2321
|
const hideAddToCollection = universalElementEditing || standaloneElementEditing || !universalElementSetting;
|
|
2322
|
+
const hideInnerTools = NodeUtils.isPageHeaderElement(element) || NodeUtils.isPageFooterElement(element);
|
|
2295
2323
|
const renderContent = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
2296
2324
|
"div",
|
|
2297
2325
|
{
|
|
@@ -2320,7 +2348,7 @@ const ElementTools$1 = ({ element, nodeElement, path: path2 }) => {
|
|
|
2320
2348
|
},
|
|
2321
2349
|
/* @__PURE__ */ React__default.createElement(
|
|
2322
2350
|
"div",
|
|
2323
|
-
__spreadProps(__spreadValues({}, isEditingUniversalElement || isEditingStandaloneElement ? {} : dragHandle), {
|
|
2351
|
+
__spreadProps(__spreadValues({}, isEditingUniversalElement || isEditingStandaloneElement || hideInnerTools ? {} : dragHandle), {
|
|
2324
2352
|
style: {
|
|
2325
2353
|
cursor: isEditingUniversalElement || isEditingStandaloneElement ? "default" : "grab",
|
|
2326
2354
|
display: "flex"
|
|
@@ -2335,7 +2363,7 @@ const ElementTools$1 = ({ element, nodeElement, path: path2 }) => {
|
|
|
2335
2363
|
),
|
|
2336
2364
|
BlockManager.getBlockTitle(element)
|
|
2337
2365
|
),
|
|
2338
|
-
ElementToolsInner ? /* @__PURE__ */ React__default.createElement(
|
|
2366
|
+
!hideInnerTools && (ElementToolsInner ? /* @__PURE__ */ React__default.createElement(
|
|
2339
2367
|
ElementToolsInner,
|
|
2340
2368
|
{
|
|
2341
2369
|
element,
|
|
@@ -2349,9 +2377,30 @@ const ElementTools$1 = ({ element, nodeElement, path: path2 }) => {
|
|
|
2349
2377
|
onPointerDown: onSelectParent
|
|
2350
2378
|
},
|
|
2351
2379
|
/* @__PURE__ */ React__default.createElement(IconFont, { iconName: "icon-back-parent" })
|
|
2352
|
-
), !isEditingUniversalElement && !isEditingStandaloneElement && /* @__PURE__ */ React__default.createElement(
|
|
2380
|
+
), !isEditingUniversalElement && !isEditingStandaloneElement && /* @__PURE__ */ React__default.createElement(
|
|
2381
|
+
"div",
|
|
2382
|
+
{
|
|
2383
|
+
className: "element-tools-item",
|
|
2384
|
+
onPointerDown: onCopy
|
|
2385
|
+
},
|
|
2386
|
+
/* @__PURE__ */ React__default.createElement(IconFont, { iconName: "icon-copy" })
|
|
2387
|
+
), !hideAddToCollection && /* @__PURE__ */ React__default.createElement(
|
|
2388
|
+
"div",
|
|
2389
|
+
{
|
|
2390
|
+
className: "element-tools-item",
|
|
2391
|
+
onPointerDown: openModal
|
|
2392
|
+
},
|
|
2393
|
+
/* @__PURE__ */ React__default.createElement(IconFont, { iconName: "icon-collection" })
|
|
2394
|
+
), !isEditingUniversalElement && !isEditingStandaloneElement && /* @__PURE__ */ React__default.createElement(
|
|
2395
|
+
"div",
|
|
2396
|
+
{
|
|
2397
|
+
className: "element-tools-item",
|
|
2398
|
+
onPointerDown: onDelete
|
|
2399
|
+
},
|
|
2400
|
+
/* @__PURE__ */ React__default.createElement(IconFont, { iconName: "icon-delete" })
|
|
2401
|
+
)))
|
|
2353
2402
|
),
|
|
2354
|
-
showDragMoveIcon && !isEditingUniversalElement && !isEditingStandaloneElement && /* @__PURE__ */ React__default.createElement("div", __spreadValues({ className: "element-tools-move-handle" }, dragHandleV2), /* @__PURE__ */ React__default.createElement(IconFont, { iconName: "icon-move" }))
|
|
2403
|
+
showDragMoveIcon && !hideInnerTools && !isEditingUniversalElement && !isEditingStandaloneElement && /* @__PURE__ */ React__default.createElement("div", __spreadValues({ className: "element-tools-move-handle" }, dragHandleV2), /* @__PURE__ */ React__default.createElement(IconFont, { iconName: "icon-move" }))
|
|
2355
2404
|
), /* @__PURE__ */ React__default.createElement("div", { className: "element-dragover" }), /* @__PURE__ */ React__default.createElement("style", null, styleText$g));
|
|
2356
2405
|
return /* @__PURE__ */ React__default.createElement("div", null, renderContent);
|
|
2357
2406
|
};
|
|
@@ -2366,6 +2415,9 @@ const ElementHover$1 = ({
|
|
|
2366
2415
|
return null;
|
|
2367
2416
|
if (NodeUtils.isUnsetElement(element))
|
|
2368
2417
|
return null;
|
|
2418
|
+
if ((NodeUtils.isPageHeaderElement(element) || NodeUtils.isPageFooterElement(element)) && !element.data.editable) {
|
|
2419
|
+
return null;
|
|
2420
|
+
}
|
|
2369
2421
|
const renderContent = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(ElementTools$1, { element, nodeElement, path: path2 }), /* @__PURE__ */ React__default.createElement("style", null, styleText$f));
|
|
2370
2422
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderContent);
|
|
2371
2423
|
};
|
|
@@ -2373,6 +2425,9 @@ const styleText$e = "[data-slate-selected=true] .element-tools-container,\n[data
|
|
|
2373
2425
|
const ElementSelected = ({ element, nodeElement, path: path2 }) => {
|
|
2374
2426
|
if (NodeUtils.isUnsetElement(element))
|
|
2375
2427
|
return null;
|
|
2428
|
+
if ((NodeUtils.isPageHeaderElement(element) || NodeUtils.isPageFooterElement(element)) && !element.data.editable) {
|
|
2429
|
+
return null;
|
|
2430
|
+
}
|
|
2376
2431
|
const renderContent = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(ElementTools$1, { element, nodeElement, path: path2 }), /* @__PURE__ */ React__default.createElement("style", null, styleText$e));
|
|
2377
2432
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderContent);
|
|
2378
2433
|
};
|
|
@@ -7536,6 +7591,21 @@ const BlockLayer = () => {
|
|
|
7536
7591
|
handleCollapseToggle(defaultCollapsedAll);
|
|
7537
7592
|
}
|
|
7538
7593
|
}, [defaultCollapsedAll, handleCollapseToggle]);
|
|
7594
|
+
const filterItems = useMemo(() => {
|
|
7595
|
+
return pageElement.children.filter((child) => {
|
|
7596
|
+
return !(NodeUtils.isPageHeaderElement(child) || NodeUtils.isPageFooterElement(child));
|
|
7597
|
+
});
|
|
7598
|
+
}, [pageElement.children]);
|
|
7599
|
+
const pageHeaderElement = useMemo(() => {
|
|
7600
|
+
return pageElement.children.find(
|
|
7601
|
+
(child) => NodeUtils.isPageHeaderElement(child)
|
|
7602
|
+
);
|
|
7603
|
+
}, [pageElement.children]);
|
|
7604
|
+
const pageFooterElement = useMemo(() => {
|
|
7605
|
+
return pageElement.children.find(
|
|
7606
|
+
(child) => NodeUtils.isPageFooterElement(child)
|
|
7607
|
+
);
|
|
7608
|
+
}, [pageElement.children]);
|
|
7539
7609
|
if (!inited)
|
|
7540
7610
|
return null;
|
|
7541
7611
|
return /* @__PURE__ */ React__default.createElement("div", { onMouseOut: (e) => e.stopPropagation() }, /* @__PURE__ */ React__default.createElement(
|
|
@@ -7557,15 +7627,113 @@ const BlockLayer = () => {
|
|
|
7557
7627
|
style: { marginRight: 12 }
|
|
7558
7628
|
}
|
|
7559
7629
|
), /* @__PURE__ */ React__default.createElement(Typography$1.Text, { style: { fontSize: 14, color: "#333" } }, t("Collapse All")))
|
|
7560
|
-
), /* @__PURE__ */ React__default.createElement(
|
|
7630
|
+
), pageHeaderElement && /* @__PURE__ */ React__default.createElement(HeaderFooterItem, { element: pageHeaderElement }), filterItems.length > 0 && /* @__PURE__ */ React__default.createElement(
|
|
7561
7631
|
ElementList,
|
|
7562
7632
|
{
|
|
7563
|
-
blocks:
|
|
7633
|
+
blocks: filterItems,
|
|
7564
7634
|
collapsedItems,
|
|
7565
7635
|
onToggleCollapse: toggleItemCollapse
|
|
7566
7636
|
}
|
|
7567
|
-
));
|
|
7637
|
+
), pageFooterElement && /* @__PURE__ */ React__default.createElement(HeaderFooterItem, { element: pageFooterElement }));
|
|
7568
7638
|
};
|
|
7639
|
+
function HeaderFooterItem({ element }) {
|
|
7640
|
+
const { setSelectedNodePath, setHoverNodePath } = useEditorActions();
|
|
7641
|
+
const { hoverNodePath, selectedNodePath } = useEditorState();
|
|
7642
|
+
const editor = useSlateStatic();
|
|
7643
|
+
const path2 = useMemo(() => {
|
|
7644
|
+
try {
|
|
7645
|
+
return ReactEditor.findPath(editor, element);
|
|
7646
|
+
} catch (error2) {
|
|
7647
|
+
return null;
|
|
7648
|
+
}
|
|
7649
|
+
}, [element, editor]);
|
|
7650
|
+
const onClick = () => {
|
|
7651
|
+
if (!path2)
|
|
7652
|
+
return;
|
|
7653
|
+
setSelectedNodePath(path2);
|
|
7654
|
+
};
|
|
7655
|
+
const label = BlockManager.getBlockTitle(element);
|
|
7656
|
+
const isHovered = useMemo(() => {
|
|
7657
|
+
if (!path2 || !hoverNodePath)
|
|
7658
|
+
return false;
|
|
7659
|
+
return Path.equals(path2, hoverNodePath);
|
|
7660
|
+
}, [path2, hoverNodePath]);
|
|
7661
|
+
const isSelected = useMemo(() => {
|
|
7662
|
+
if (!path2 || !selectedNodePath)
|
|
7663
|
+
return false;
|
|
7664
|
+
return Path.equals(path2, selectedNodePath);
|
|
7665
|
+
}, [path2, selectedNodePath]);
|
|
7666
|
+
const handleMouseEnter = () => {
|
|
7667
|
+
if (path2) {
|
|
7668
|
+
setHoverNodePath(path2);
|
|
7669
|
+
}
|
|
7670
|
+
};
|
|
7671
|
+
const handleMouseLeave = () => {
|
|
7672
|
+
setHoverNodePath(null);
|
|
7673
|
+
};
|
|
7674
|
+
const getBackgroundColor = () => {
|
|
7675
|
+
if (isSelected) {
|
|
7676
|
+
return "rgba(var(--primary-6), 0.15)";
|
|
7677
|
+
}
|
|
7678
|
+
if (isHovered) {
|
|
7679
|
+
return "#e8e8e8";
|
|
7680
|
+
}
|
|
7681
|
+
return "#f5f5f5";
|
|
7682
|
+
};
|
|
7683
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
7684
|
+
"div",
|
|
7685
|
+
{
|
|
7686
|
+
className: styles$4.item,
|
|
7687
|
+
onClick,
|
|
7688
|
+
onMouseEnter: handleMouseEnter,
|
|
7689
|
+
onMouseLeave: handleMouseLeave,
|
|
7690
|
+
style: {
|
|
7691
|
+
backgroundColor: getBackgroundColor(),
|
|
7692
|
+
marginTop: "8px",
|
|
7693
|
+
marginBottom: "8px",
|
|
7694
|
+
borderRadius: "4px",
|
|
7695
|
+
borderLeft: isSelected ? "3px solid var(--primary-6)" : "none",
|
|
7696
|
+
transition: "background-color 0.2s"
|
|
7697
|
+
}
|
|
7698
|
+
},
|
|
7699
|
+
/* @__PURE__ */ React__default.createElement(
|
|
7700
|
+
"div",
|
|
7701
|
+
{
|
|
7702
|
+
className: styles$4.itemContent,
|
|
7703
|
+
style: {
|
|
7704
|
+
backgroundColor: "transparent",
|
|
7705
|
+
padding: "8px 10px"
|
|
7706
|
+
}
|
|
7707
|
+
},
|
|
7708
|
+
/* @__PURE__ */ React__default.createElement("div", { className: styles$4.itemTitle }, /* @__PURE__ */ React__default.createElement("div", { className: styles$4.itemLabelWrapper }, /* @__PURE__ */ React__default.createElement(
|
|
7709
|
+
SharedComponents.ElementIcon,
|
|
7710
|
+
{
|
|
7711
|
+
type: element.type,
|
|
7712
|
+
width: 16,
|
|
7713
|
+
height: 16
|
|
7714
|
+
}
|
|
7715
|
+
), /* @__PURE__ */ React__default.createElement("div", { className: styles$4.itemLabel }, label))),
|
|
7716
|
+
/* @__PURE__ */ React__default.createElement(
|
|
7717
|
+
"div",
|
|
7718
|
+
{
|
|
7719
|
+
className: styles$4.itemActions,
|
|
7720
|
+
style: { opacity: 1 },
|
|
7721
|
+
onClick: (e) => e.stopPropagation()
|
|
7722
|
+
},
|
|
7723
|
+
/* @__PURE__ */ React__default.createElement("div", { className: styles$4.action }, /* @__PURE__ */ React__default.createElement(
|
|
7724
|
+
"svg",
|
|
7725
|
+
{
|
|
7726
|
+
viewBox: "0 0 1024 1024",
|
|
7727
|
+
width: "16",
|
|
7728
|
+
height: "16",
|
|
7729
|
+
fill: "currentColor"
|
|
7730
|
+
},
|
|
7731
|
+
/* @__PURE__ */ React__default.createElement("path", { d: "M716.8 512L332.8 128c-12.8-12.8-12.8-32 0-44.8s32-12.8 44.8 0l409.6 409.6c12.8 12.8 12.8 32 0 44.8L377.6 940.8c-12.8 12.8-32 12.8-44.8 0s-12.8-32 0-44.8L716.8 512z" })
|
|
7732
|
+
))
|
|
7733
|
+
)
|
|
7734
|
+
)
|
|
7735
|
+
);
|
|
7736
|
+
}
|
|
7569
7737
|
const BlockSideBar = ({ height }) => {
|
|
7570
7738
|
const { setSelectedNodePath } = useEditorActions();
|
|
7571
7739
|
const selectedNodePath = useSelectedNodePath();
|
|
@@ -14489,35 +14657,54 @@ const HoveringToolbar = () => {
|
|
|
14489
14657
|
const { selectedNode } = useSelectedNode();
|
|
14490
14658
|
const [isFocus, setIsFocus] = useState(false);
|
|
14491
14659
|
const { lock } = useEditorState();
|
|
14492
|
-
const
|
|
14493
|
-
const nodePath = selectedNode && (selection == null ? void 0 : selection.anchor.path) ? selection.anchor.path : null;
|
|
14660
|
+
const selection = editor.selection;
|
|
14661
|
+
const nodePath = selectedNode && (selection == null ? void 0 : selection.anchor.path) && Node.has(editor, selection.anchor.path) ? selection.anchor.path : null;
|
|
14494
14662
|
const isTable2 = selectedNode && NodeUtils.isTable2Element(selectedNode);
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14663
|
+
let contentElements = [];
|
|
14664
|
+
try {
|
|
14665
|
+
contentElements = Array.from(
|
|
14666
|
+
Editor.nodes(editor, {
|
|
14667
|
+
match: (node) => isTable2 ? NodeUtils.isTable2TdElement(node) : NodeUtils.isContentElement(node)
|
|
14668
|
+
})
|
|
14669
|
+
);
|
|
14670
|
+
} catch (error2) {
|
|
14671
|
+
}
|
|
14500
14672
|
let selectedContentBlockNodeEntry = null;
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
|
|
14507
|
-
|
|
14508
|
-
|
|
14673
|
+
let mergetagNodeEntry = null;
|
|
14674
|
+
if (nodePath) {
|
|
14675
|
+
try {
|
|
14676
|
+
mergetagNodeEntry = Editor.above(editor, {
|
|
14677
|
+
at: nodePath,
|
|
14678
|
+
match: NodeUtils.isMergetagElement
|
|
14679
|
+
});
|
|
14680
|
+
} catch (error2) {
|
|
14681
|
+
}
|
|
14682
|
+
}
|
|
14683
|
+
let htmlNodeImgEntry = null;
|
|
14684
|
+
if (nodePath) {
|
|
14685
|
+
try {
|
|
14686
|
+
htmlNodeImgEntry = Editor.above(editor, {
|
|
14687
|
+
at: nodePath,
|
|
14688
|
+
match: (node) => NodeUtils.isHTMLNodeElement(node) && node.data.tagName === "img"
|
|
14689
|
+
});
|
|
14690
|
+
} catch (error2) {
|
|
14691
|
+
}
|
|
14692
|
+
}
|
|
14509
14693
|
const mergetagNode = mergetagNodeEntry == null ? void 0 : mergetagNodeEntry[0];
|
|
14510
14694
|
const isMergeTagSelected = Boolean(mergetagNode);
|
|
14511
14695
|
if (nodePath) {
|
|
14512
|
-
|
|
14513
|
-
|
|
14514
|
-
|
|
14515
|
-
|
|
14516
|
-
|
|
14517
|
-
|
|
14518
|
-
|
|
14519
|
-
|
|
14696
|
+
try {
|
|
14697
|
+
selectedContentBlockNodeEntry = Editor.above(editor, {
|
|
14698
|
+
at: nodePath,
|
|
14699
|
+
match: NodeUtils.isTextElement
|
|
14700
|
+
});
|
|
14701
|
+
if (!selectedContentBlockNodeEntry) {
|
|
14702
|
+
const entry = Editor.node(editor, nodePath);
|
|
14703
|
+
if (NodeUtils.isTextElement(entry[0])) {
|
|
14704
|
+
selectedContentBlockNodeEntry = entry;
|
|
14705
|
+
}
|
|
14520
14706
|
}
|
|
14707
|
+
} catch (error2) {
|
|
14521
14708
|
}
|
|
14522
14709
|
}
|
|
14523
14710
|
let contentWindow = null;
|
|
@@ -14527,9 +14714,13 @@ const HoveringToolbar = () => {
|
|
|
14527
14714
|
}
|
|
14528
14715
|
const selectedContentBlockNode = selectedContentBlockNodeEntry == null ? void 0 : selectedContentBlockNodeEntry[0];
|
|
14529
14716
|
const isNotSelect = !selection;
|
|
14530
|
-
|
|
14531
|
-
|
|
14532
|
-
|
|
14717
|
+
let isCollapsed = true;
|
|
14718
|
+
if (selection) {
|
|
14719
|
+
try {
|
|
14720
|
+
isCollapsed = Range.isCollapsed(selection) || Editor.string(editor, selection) === "";
|
|
14721
|
+
} catch (error2) {
|
|
14722
|
+
}
|
|
14723
|
+
}
|
|
14533
14724
|
useEffect(() => {
|
|
14534
14725
|
if (!contentWindow)
|
|
14535
14726
|
return;
|
|
@@ -14551,7 +14742,7 @@ const HoveringToolbar = () => {
|
|
|
14551
14742
|
};
|
|
14552
14743
|
}, [contentWindow, editor]);
|
|
14553
14744
|
const setHoveringBarStyle = useEventCallback(() => {
|
|
14554
|
-
var _a
|
|
14745
|
+
var _a;
|
|
14555
14746
|
if (!selectedNode)
|
|
14556
14747
|
return;
|
|
14557
14748
|
if (hoveringToolbar == null ? void 0 : hoveringToolbar.fixed)
|
|
@@ -14590,9 +14781,12 @@ const HoveringToolbar = () => {
|
|
|
14590
14781
|
pageYOffset
|
|
14591
14782
|
} = layout;
|
|
14592
14783
|
el2.style.opacity = list.length === 0 ? "0" : "1";
|
|
14784
|
+
const sectionPath = [0, 0];
|
|
14785
|
+
if (!Node.has(editor, sectionPath))
|
|
14786
|
+
return;
|
|
14593
14787
|
const sectionDomNode = ReactEditor.toDOMNode(
|
|
14594
14788
|
editor,
|
|
14595
|
-
Node.get(editor,
|
|
14789
|
+
Node.get(editor, sectionPath)
|
|
14596
14790
|
);
|
|
14597
14791
|
const overlayRectWidth = overlayRect.width || relativedElementReact.width;
|
|
14598
14792
|
const sectionDomNodeRect = sectionDomNode.getBoundingClientRect();
|
|
@@ -14623,8 +14817,8 @@ const HoveringToolbar = () => {
|
|
|
14623
14817
|
return;
|
|
14624
14818
|
const domRange = domSelection.getRangeAt(0);
|
|
14625
14819
|
let rect = domRange.getBoundingClientRect();
|
|
14626
|
-
if (rect.top === 0 && rect.left === 0 && ((_a = editor.selection) == null ? void 0 : _a.anchor.path)) {
|
|
14627
|
-
const textNode = Node.get(editor,
|
|
14820
|
+
if (rect.top === 0 && rect.left === 0 && ((_a = editor.selection) == null ? void 0 : _a.anchor.path) && Node.has(editor, editor.selection.anchor.path)) {
|
|
14821
|
+
const textNode = Node.get(editor, editor.selection.anchor.path);
|
|
14628
14822
|
const rangeNode = ReactEditor.toDOMNode(editor, textNode);
|
|
14629
14823
|
const rang = document.createRange();
|
|
14630
14824
|
rang.selectNode(rangeNode);
|
|
@@ -14877,21 +15071,40 @@ function ColorPickerContent(props) {
|
|
|
14877
15071
|
}
|
|
14878
15072
|
const BgColor = () => {
|
|
14879
15073
|
const editor = useSlate();
|
|
14880
|
-
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
15074
|
+
const { getPopupContainer } = useContext(RichTextBarContext);
|
|
15075
|
+
let nodeEntry = null;
|
|
15076
|
+
try {
|
|
15077
|
+
if (editor.selection && Node.has(editor, editor.selection.anchor.path)) {
|
|
15078
|
+
const nodes = Editor.nodes(editor, {
|
|
15079
|
+
match: (node) => {
|
|
15080
|
+
return Text$2.isText(node);
|
|
15081
|
+
},
|
|
15082
|
+
mode: "lowest",
|
|
15083
|
+
voids: true
|
|
15084
|
+
});
|
|
15085
|
+
const first = nodes.next().value;
|
|
15086
|
+
if (first) {
|
|
15087
|
+
nodeEntry = first;
|
|
15088
|
+
}
|
|
15089
|
+
}
|
|
15090
|
+
} catch (error2) {
|
|
15091
|
+
}
|
|
14887
15092
|
if (!nodeEntry) {
|
|
14888
|
-
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
15093
|
+
try {
|
|
15094
|
+
if (editor.selection && Node.has(editor, editor.selection.anchor.path)) {
|
|
15095
|
+
const nodes = Editor.nodes(editor, {
|
|
15096
|
+
match: (node) => {
|
|
15097
|
+
return NodeUtils.isMergetagElement(node);
|
|
15098
|
+
},
|
|
15099
|
+
mode: "lowest"
|
|
15100
|
+
});
|
|
15101
|
+
const first = nodes.next().value;
|
|
15102
|
+
if (first) {
|
|
15103
|
+
nodeEntry = first;
|
|
15104
|
+
}
|
|
15105
|
+
}
|
|
15106
|
+
} catch (error2) {
|
|
15107
|
+
}
|
|
14895
15108
|
}
|
|
14896
15109
|
const { setFieldValue } = useEditorContext();
|
|
14897
15110
|
const activeTab = useActiveTab();
|
|
@@ -14958,6 +15171,9 @@ const BgColor = () => {
|
|
|
14958
15171
|
popupStyle: { padding: "10px" }
|
|
14959
15172
|
},
|
|
14960
15173
|
getPopupContainer: (node) => {
|
|
15174
|
+
if (getPopupContainer) {
|
|
15175
|
+
return getPopupContainer(node);
|
|
15176
|
+
}
|
|
14961
15177
|
return Array.from(document.querySelectorAll(".RichTextBar")).find(
|
|
14962
15178
|
(item2) => item2.contains(node)
|
|
14963
15179
|
);
|
|
@@ -14997,25 +15213,38 @@ const BgColor = () => {
|
|
|
14997
15213
|
"A"
|
|
14998
15214
|
)))
|
|
14999
15215
|
);
|
|
15000
|
-
}, [color2, onChange, onClose, textNode == null ? void 0 : textNode.color]);
|
|
15216
|
+
}, [color2, getPopupContainer, onChange, onClose, textNode == null ? void 0 : textNode.color]);
|
|
15001
15217
|
};
|
|
15002
15218
|
const FontColor = () => {
|
|
15219
|
+
const { getPopupContainer } = useContext(RichTextBarContext);
|
|
15003
15220
|
const editor = useSlate();
|
|
15004
|
-
let
|
|
15005
|
-
|
|
15006
|
-
|
|
15007
|
-
|
|
15008
|
-
|
|
15009
|
-
|
|
15010
|
-
|
|
15221
|
+
let nodeEntry = null;
|
|
15222
|
+
try {
|
|
15223
|
+
if (editor.selection && Node.has(editor, editor.selection.anchor.path)) {
|
|
15224
|
+
const [entry] = Editor.nodes(editor, {
|
|
15225
|
+
match: (node) => {
|
|
15226
|
+
return Text$2.isText(node);
|
|
15227
|
+
},
|
|
15228
|
+
mode: "lowest",
|
|
15229
|
+
voids: true
|
|
15230
|
+
});
|
|
15231
|
+
nodeEntry = entry;
|
|
15232
|
+
}
|
|
15233
|
+
} catch (error2) {
|
|
15234
|
+
}
|
|
15011
15235
|
if (!nodeEntry) {
|
|
15012
|
-
|
|
15013
|
-
|
|
15014
|
-
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15236
|
+
try {
|
|
15237
|
+
if (editor.selection && Node.has(editor, editor.selection.anchor.path)) {
|
|
15238
|
+
const [mergetagNodeEntry] = Editor.nodes(editor, {
|
|
15239
|
+
match: (node) => {
|
|
15240
|
+
return NodeUtils.isMergetagElement(node);
|
|
15241
|
+
},
|
|
15242
|
+
mode: "lowest"
|
|
15243
|
+
});
|
|
15244
|
+
nodeEntry = mergetagNodeEntry;
|
|
15245
|
+
}
|
|
15246
|
+
} catch (error2) {
|
|
15247
|
+
}
|
|
15019
15248
|
}
|
|
15020
15249
|
const { setFieldValue } = useEditorContext();
|
|
15021
15250
|
const activeTab = useActiveTab();
|
|
@@ -15077,6 +15306,9 @@ const FontColor = () => {
|
|
|
15077
15306
|
popupStyle: { padding: "10px" }
|
|
15078
15307
|
},
|
|
15079
15308
|
getPopupContainer: (node) => {
|
|
15309
|
+
if (getPopupContainer) {
|
|
15310
|
+
return getPopupContainer(node);
|
|
15311
|
+
}
|
|
15080
15312
|
return Array.from(document.querySelectorAll(".RichTextBar")).find(
|
|
15081
15313
|
(item2) => item2.contains(node)
|
|
15082
15314
|
);
|
|
@@ -15130,7 +15362,44 @@ const FormatButton = (_a) => {
|
|
|
15130
15362
|
]);
|
|
15131
15363
|
const { setFieldValue, getFieldValue } = useEditorContext();
|
|
15132
15364
|
const editor = useSlate();
|
|
15133
|
-
const
|
|
15365
|
+
const contentNodeEntry = useMemo(() => {
|
|
15366
|
+
var _a2, _b2;
|
|
15367
|
+
return editor.selection ? editor.findSelfOrAncestorNodeByCategory({
|
|
15368
|
+
category: ElementCategory.TEXT,
|
|
15369
|
+
path: (_a2 = editor.selection) == null ? void 0 : _a2.anchor.path
|
|
15370
|
+
}) || editor.findSelfOrAncestorNodeByType({
|
|
15371
|
+
type: ElementType.STANDARD_TABLE2,
|
|
15372
|
+
path: (_b2 = editor.selection) == null ? void 0 : _b2.anchor.path
|
|
15373
|
+
}) : null;
|
|
15374
|
+
}, [editor, editor.selection]);
|
|
15375
|
+
const active = useMemo(() => {
|
|
15376
|
+
if (rest.active)
|
|
15377
|
+
return true;
|
|
15378
|
+
if (!format)
|
|
15379
|
+
return false;
|
|
15380
|
+
if (isFormatActive(editor, format))
|
|
15381
|
+
return true;
|
|
15382
|
+
if (contentNodeEntry) {
|
|
15383
|
+
const node = contentNodeEntry[0];
|
|
15384
|
+
if (format === TextFormat.BOLD) {
|
|
15385
|
+
const val = get(node, "attributes.font-weight");
|
|
15386
|
+
return val === "bold" || parseInt(val) > 500;
|
|
15387
|
+
}
|
|
15388
|
+
if (format === TextFormat.ITALIC) {
|
|
15389
|
+
const val = get(node, "attributes.font-style");
|
|
15390
|
+
return val === "italic";
|
|
15391
|
+
}
|
|
15392
|
+
if (format === TextFormat.UNDERLINE) {
|
|
15393
|
+
const val = get(node, "attributes.text-decoration");
|
|
15394
|
+
return val === "underline" || typeof val === "string" && val.includes("underline");
|
|
15395
|
+
}
|
|
15396
|
+
if (format === TextFormat.STRIKETHROUGH) {
|
|
15397
|
+
const val = get(node, "attributes.text-decoration");
|
|
15398
|
+
return val === "line-through" || typeof val === "string" && val.includes("line-through");
|
|
15399
|
+
}
|
|
15400
|
+
}
|
|
15401
|
+
return false;
|
|
15402
|
+
}, [rest.active, format, editor, contentNodeEntry]);
|
|
15134
15403
|
const onClick = () => {
|
|
15135
15404
|
var _a2, _b2, _c;
|
|
15136
15405
|
if (onClickHandle) {
|
|
@@ -15143,16 +15412,16 @@ const FormatButton = (_a) => {
|
|
|
15143
15412
|
type: ElementType.MERGETAG,
|
|
15144
15413
|
path: (_a2 = editor.selection) == null ? void 0 : _a2.anchor.path
|
|
15145
15414
|
}) : null;
|
|
15146
|
-
const
|
|
15415
|
+
const contentNodeEntry2 = editor.selection ? editor.findSelfOrAncestorNodeByCategory({
|
|
15147
15416
|
category: ElementCategory.TEXT,
|
|
15148
15417
|
path: (_b2 = editor.selection) == null ? void 0 : _b2.anchor.path
|
|
15149
15418
|
}) || editor.findSelfOrAncestorNodeByType({
|
|
15150
15419
|
type: ElementType.STANDARD_TABLE2,
|
|
15151
15420
|
path: (_c = editor.selection) == null ? void 0 : _c.anchor.path
|
|
15152
15421
|
}) : null;
|
|
15153
|
-
if (!
|
|
15422
|
+
if (!contentNodeEntry2)
|
|
15154
15423
|
return;
|
|
15155
|
-
const contentNodePath =
|
|
15424
|
+
const contentNodePath = contentNodeEntry2[1];
|
|
15156
15425
|
const selection = editor.selection;
|
|
15157
15426
|
const isCollapsed = Boolean(
|
|
15158
15427
|
selection && (Range.isCollapsed(selection) || Editor.string(editor, selection) === "") && !mergeNodeEntry
|
|
@@ -15226,14 +15495,18 @@ const FormatButton = (_a) => {
|
|
|
15226
15495
|
));
|
|
15227
15496
|
};
|
|
15228
15497
|
const getLinkNode = (editor) => {
|
|
15229
|
-
|
|
15230
|
-
match
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
|
|
15234
|
-
|
|
15235
|
-
|
|
15236
|
-
|
|
15498
|
+
try {
|
|
15499
|
+
const [match] = Editor.nodes(editor, {
|
|
15500
|
+
match: (n) => {
|
|
15501
|
+
return Text$2.isText(n) && Boolean(n[TextFormat.LINK]);
|
|
15502
|
+
},
|
|
15503
|
+
mode: "lowest",
|
|
15504
|
+
voids: true
|
|
15505
|
+
});
|
|
15506
|
+
return match;
|
|
15507
|
+
} catch (error2) {
|
|
15508
|
+
return void 0;
|
|
15509
|
+
}
|
|
15237
15510
|
};
|
|
15238
15511
|
class Uploader {
|
|
15239
15512
|
constructor(uploadServer, options2) {
|
|
@@ -15689,7 +15962,6 @@ function isValidHttpUrl(str) {
|
|
|
15689
15962
|
const TextLink = () => {
|
|
15690
15963
|
const editor = useSlate();
|
|
15691
15964
|
const linkNodeEntry = getLinkNode(editor);
|
|
15692
|
-
console.log(linkNodeEntry);
|
|
15693
15965
|
const ref = useRef(null);
|
|
15694
15966
|
const linkNode = linkNodeEntry == null ? void 0 : linkNodeEntry[0];
|
|
15695
15967
|
const selectedNodePath = useSelectedNodePath();
|
|
@@ -15985,9 +16257,15 @@ const options$9 = [
|
|
|
15985
16257
|
];
|
|
15986
16258
|
const TurnInto = () => {
|
|
15987
16259
|
const editor = useSlate();
|
|
15988
|
-
|
|
15989
|
-
|
|
15990
|
-
|
|
16260
|
+
let nodeEntry = null;
|
|
16261
|
+
try {
|
|
16262
|
+
if (editor.selection && Node.has(editor, editor.selection.anchor.path)) {
|
|
16263
|
+
nodeEntry = Editor.above(editor, {
|
|
16264
|
+
match: NodeUtils.isBlockElement
|
|
16265
|
+
});
|
|
16266
|
+
}
|
|
16267
|
+
} catch (error2) {
|
|
16268
|
+
}
|
|
15991
16269
|
const node = nodeEntry == null ? void 0 : nodeEntry[0];
|
|
15992
16270
|
const onChange = (value) => {
|
|
15993
16271
|
var _a;
|
|
@@ -16087,26 +16365,46 @@ function styleStringToObject(styleString) {
|
|
|
16087
16365
|
const TextAlign$1 = () => {
|
|
16088
16366
|
var _a, _b;
|
|
16089
16367
|
const editor = useSlate();
|
|
16090
|
-
|
|
16091
|
-
|
|
16092
|
-
|
|
16093
|
-
|
|
16094
|
-
|
|
16095
|
-
|
|
16096
|
-
|
|
16097
|
-
|
|
16098
|
-
|
|
16099
|
-
|
|
16368
|
+
let match = null;
|
|
16369
|
+
try {
|
|
16370
|
+
if (editor.selection && Node.has(editor, editor.selection.anchor.path)) {
|
|
16371
|
+
const nodes = Editor.nodes(editor, {
|
|
16372
|
+
match: (n) => NodeUtils.isContentElement(n),
|
|
16373
|
+
mode: "all"
|
|
16374
|
+
});
|
|
16375
|
+
const first = nodes.next().value;
|
|
16376
|
+
if (first) {
|
|
16377
|
+
match = first;
|
|
16378
|
+
}
|
|
16379
|
+
}
|
|
16380
|
+
} catch (error2) {
|
|
16381
|
+
}
|
|
16382
|
+
let matchHtmlBlockNode = null;
|
|
16383
|
+
try {
|
|
16384
|
+
if (editor.selection && Node.has(editor, editor.selection.anchor.path)) {
|
|
16385
|
+
const nodes = Editor.nodes(editor, {
|
|
16386
|
+
match: (node2) => {
|
|
16387
|
+
return NodeUtils.isHTMLBlockNodeElement(node2);
|
|
16388
|
+
},
|
|
16389
|
+
mode: "lowest"
|
|
16390
|
+
});
|
|
16391
|
+
const first = nodes.next().value;
|
|
16392
|
+
if (first) {
|
|
16393
|
+
matchHtmlBlockNode = first;
|
|
16394
|
+
}
|
|
16395
|
+
}
|
|
16396
|
+
} catch (error2) {
|
|
16397
|
+
}
|
|
16100
16398
|
const { enabledHtmlBlockNodeAlign } = useEditorProps();
|
|
16101
|
-
const node = match == null ? void 0 : match[0];
|
|
16102
16399
|
const { setFieldValue } = useEditorContext();
|
|
16400
|
+
const node = match == null ? void 0 : match[0];
|
|
16103
16401
|
let styleObject;
|
|
16104
16402
|
if (matchHtmlBlockNode == null ? void 0 : matchHtmlBlockNode[0]) {
|
|
16105
16403
|
styleObject = styleStringToObject(
|
|
16106
16404
|
((_b = (_a = matchHtmlBlockNode == null ? void 0 : matchHtmlBlockNode[0]) == null ? void 0 : _a.attributes) == null ? void 0 : _b.style) || ""
|
|
16107
16405
|
);
|
|
16108
16406
|
}
|
|
16109
|
-
const matchAlign = get(styleObject, "text-align") || get(node.attributes, "align");
|
|
16407
|
+
const matchAlign = get(styleObject, "text-align") || ((node == null ? void 0 : node.attributes) ? get(node.attributes, "align") : void 0);
|
|
16110
16408
|
const onAlignHandle = (align) => {
|
|
16111
16409
|
var _a2;
|
|
16112
16410
|
if (!match)
|
|
@@ -16209,22 +16507,41 @@ const FontSize$2 = () => {
|
|
|
16209
16507
|
const { fontSizeList } = useEditorProps();
|
|
16210
16508
|
const [fontSizeValue, setFontSizeValue] = useState();
|
|
16211
16509
|
const { setFieldValue } = useEditorContext();
|
|
16212
|
-
const
|
|
16213
|
-
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
},
|
|
16217
|
-
mode: "lowest",
|
|
16218
|
-
voids: true
|
|
16510
|
+
const { selectedNode } = useSelectedNode();
|
|
16511
|
+
const elementDefault = useElementDefault({
|
|
16512
|
+
path: null,
|
|
16513
|
+
type: (selectedNode == null ? void 0 : selectedNode.type) || null
|
|
16219
16514
|
});
|
|
16515
|
+
const editor = useSlate();
|
|
16516
|
+
let nodeEntry = null;
|
|
16517
|
+
try {
|
|
16518
|
+
const selection = editor.selection;
|
|
16519
|
+
if (selection && Range.isCollapsed(selection) && Node.has(editor, selection.anchor.path)) {
|
|
16520
|
+
const entries = Editor.nodes(editor, {
|
|
16521
|
+
match: (node) => Text$2.isText(node),
|
|
16522
|
+
mode: "lowest",
|
|
16523
|
+
voids: true
|
|
16524
|
+
});
|
|
16525
|
+
const first = entries.next().value;
|
|
16526
|
+
if (first)
|
|
16527
|
+
nodeEntry = first;
|
|
16528
|
+
}
|
|
16529
|
+
} catch (error2) {
|
|
16530
|
+
}
|
|
16220
16531
|
if (!nodeEntry) {
|
|
16221
|
-
|
|
16222
|
-
|
|
16223
|
-
|
|
16224
|
-
|
|
16225
|
-
|
|
16226
|
-
|
|
16227
|
-
|
|
16532
|
+
try {
|
|
16533
|
+
const selection = editor.selection;
|
|
16534
|
+
if (selection && Range.isCollapsed(selection) && Node.has(editor, selection.anchor.path)) {
|
|
16535
|
+
const entries = Editor.nodes(editor, {
|
|
16536
|
+
match: (node) => NodeUtils.isMergetagElement(node),
|
|
16537
|
+
mode: "lowest"
|
|
16538
|
+
});
|
|
16539
|
+
const first = entries.next().value;
|
|
16540
|
+
if (first)
|
|
16541
|
+
nodeEntry = first;
|
|
16542
|
+
}
|
|
16543
|
+
} catch (error2) {
|
|
16544
|
+
}
|
|
16228
16545
|
}
|
|
16229
16546
|
const textNode = nodeEntry == null ? void 0 : nodeEntry[0];
|
|
16230
16547
|
useEffect(() => {
|
|
@@ -16236,6 +16553,9 @@ const FontSize$2 = () => {
|
|
|
16236
16553
|
} catch (error2) {
|
|
16237
16554
|
}
|
|
16238
16555
|
}
|
|
16556
|
+
if (!fontSizeValue2) {
|
|
16557
|
+
fontSizeValue2 = get(elementDefault.attributes, "font-size");
|
|
16558
|
+
}
|
|
16239
16559
|
setFontSizeValue(fontSizeValue2);
|
|
16240
16560
|
}, [editor, textNode, textNode == null ? void 0 : textNode.fontSize]);
|
|
16241
16561
|
const optionsList = useMemo(() => {
|
|
@@ -16309,13 +16629,27 @@ const FontFamily$2 = () => {
|
|
|
16309
16629
|
const editor = useSlate();
|
|
16310
16630
|
const { setFieldValue } = useEditorContext();
|
|
16311
16631
|
const [fontFamilyValue, setFontFamilyValue] = useState();
|
|
16312
|
-
const
|
|
16313
|
-
|
|
16314
|
-
|
|
16315
|
-
|
|
16316
|
-
voids: true,
|
|
16317
|
-
mode: "lowest"
|
|
16632
|
+
const { selectedNode } = useSelectedNode();
|
|
16633
|
+
const elementDefault = useElementDefault({
|
|
16634
|
+
path: null,
|
|
16635
|
+
type: (selectedNode == null ? void 0 : selectedNode.type) || null
|
|
16318
16636
|
});
|
|
16637
|
+
let nodeEntry = null;
|
|
16638
|
+
try {
|
|
16639
|
+
const selection = editor.selection;
|
|
16640
|
+
if (selection && Range.isCollapsed(selection) && Node.has(editor, selection.anchor.path)) {
|
|
16641
|
+
const entries = Editor.nodes(editor, {
|
|
16642
|
+
match: (node) => Text$2.isText(node),
|
|
16643
|
+
voids: true,
|
|
16644
|
+
mode: "lowest"
|
|
16645
|
+
});
|
|
16646
|
+
const first = entries.next().value;
|
|
16647
|
+
if (first)
|
|
16648
|
+
nodeEntry = first;
|
|
16649
|
+
}
|
|
16650
|
+
} catch (error2) {
|
|
16651
|
+
console.warn("FontFamily: failed to get nodes safely", error2);
|
|
16652
|
+
}
|
|
16319
16653
|
const textNode = nodeEntry == null ? void 0 : nodeEntry[0];
|
|
16320
16654
|
useEffect(() => {
|
|
16321
16655
|
var _a;
|
|
@@ -16327,8 +16661,11 @@ const FontFamily$2 = () => {
|
|
|
16327
16661
|
} catch (error2) {
|
|
16328
16662
|
}
|
|
16329
16663
|
}
|
|
16664
|
+
if (!fontFamilyValue2) {
|
|
16665
|
+
fontFamilyValue2 = get(elementDefault.attributes, "font-family");
|
|
16666
|
+
}
|
|
16330
16667
|
setFontFamilyValue(fontFamilyValue2);
|
|
16331
|
-
}, [editor, textNode, textNode == null ? void 0 : textNode.fontFamily]);
|
|
16668
|
+
}, [editor, textNode, textNode == null ? void 0 : textNode.fontFamily, elementDefault.attributes]);
|
|
16332
16669
|
const optionsList = useMemo(() => {
|
|
16333
16670
|
const list = [...fontList];
|
|
16334
16671
|
if (fontFamilyValue) {
|
|
@@ -16401,20 +16738,28 @@ const List = () => {
|
|
|
16401
16738
|
const onToggleList = (format) => {
|
|
16402
16739
|
if (!editor.selection)
|
|
16403
16740
|
return;
|
|
16404
|
-
|
|
16405
|
-
|
|
16406
|
-
|
|
16407
|
-
|
|
16408
|
-
|
|
16409
|
-
|
|
16741
|
+
let elementEntry = null;
|
|
16742
|
+
try {
|
|
16743
|
+
elementEntry = Editor.above(editor, {
|
|
16744
|
+
match(node, path2) {
|
|
16745
|
+
return NodeUtils.isBlockElement(node);
|
|
16746
|
+
},
|
|
16747
|
+
mode: "lowest"
|
|
16748
|
+
});
|
|
16749
|
+
} catch (error2) {
|
|
16750
|
+
}
|
|
16410
16751
|
if (!elementEntry)
|
|
16411
16752
|
return;
|
|
16412
|
-
|
|
16413
|
-
|
|
16414
|
-
|
|
16415
|
-
|
|
16416
|
-
|
|
16417
|
-
|
|
16753
|
+
let htmlBlockNodeElementEntry = null;
|
|
16754
|
+
try {
|
|
16755
|
+
htmlBlockNodeElementEntry = Editor.above(editor, {
|
|
16756
|
+
match(node, path2) {
|
|
16757
|
+
return NodeUtils.isHTMLBlockNodeElement(node);
|
|
16758
|
+
},
|
|
16759
|
+
mode: "lowest"
|
|
16760
|
+
});
|
|
16761
|
+
} catch (error2) {
|
|
16762
|
+
}
|
|
16418
16763
|
if (!htmlBlockNodeElementEntry) {
|
|
16419
16764
|
Transforms.wrapNodes(
|
|
16420
16765
|
editor,
|
|
@@ -16432,12 +16777,16 @@ const List = () => {
|
|
|
16432
16777
|
}
|
|
16433
16778
|
);
|
|
16434
16779
|
}
|
|
16435
|
-
|
|
16436
|
-
|
|
16437
|
-
|
|
16438
|
-
|
|
16439
|
-
|
|
16440
|
-
|
|
16780
|
+
let match = null;
|
|
16781
|
+
try {
|
|
16782
|
+
[match] = Array.from(
|
|
16783
|
+
Editor.nodes(editor, {
|
|
16784
|
+
at: Editor.unhangRange(editor, editor.selection),
|
|
16785
|
+
match: (n) => !Editor.isEditor(n) && NodeUtils.isHTMLBlockNodeElement(n) && n.data.tagName === format
|
|
16786
|
+
})
|
|
16787
|
+
);
|
|
16788
|
+
} catch (error2) {
|
|
16789
|
+
}
|
|
16441
16790
|
const isActive = !!match;
|
|
16442
16791
|
Transforms.unwrapNodes(editor, {
|
|
16443
16792
|
match: (n) => NodeUtils.isHTMLBlockNodeElement(n) && LIST_TYPES.includes(n.data.tagName),
|
|
@@ -16617,23 +16966,42 @@ const Image$5 = () => {
|
|
|
16617
16966
|
/* @__PURE__ */ React__default.createElement("span", { ref, className: classnames$1("formatButton") }, /* @__PURE__ */ React__default.createElement("span", { className: classnames$1(" iconfont icon-img") }))
|
|
16618
16967
|
);
|
|
16619
16968
|
};
|
|
16969
|
+
const RichTextBarContext = React__default.createContext({});
|
|
16620
16970
|
const RichTextBar = ({
|
|
16621
|
-
list
|
|
16971
|
+
list,
|
|
16972
|
+
wrap: wrap2,
|
|
16973
|
+
getPopupContainer
|
|
16622
16974
|
}) => {
|
|
16975
|
+
const contextValue = useMemo(
|
|
16976
|
+
() => ({ getPopupContainer }),
|
|
16977
|
+
[getPopupContainer]
|
|
16978
|
+
);
|
|
16623
16979
|
const { MergetagPopover: MergetagPopover2, mergetags, AIAssistant: AIAssistant2 } = useEditorProps();
|
|
16624
16980
|
const { selectedNode } = useSelectedNode();
|
|
16625
16981
|
const editor = useSlate();
|
|
16626
16982
|
const { selection } = editor;
|
|
16627
|
-
const nodePath = selectedNode && (selection == null ? void 0 : selection.anchor.path) ? selection.anchor.path : null;
|
|
16628
|
-
|
|
16629
|
-
|
|
16630
|
-
|
|
16631
|
-
|
|
16983
|
+
const nodePath = selectedNode && (selection == null ? void 0 : selection.anchor.path) && Node.has(editor, selection.anchor.path) ? selection.anchor.path : null;
|
|
16984
|
+
let mergetagNodeEntry = null;
|
|
16985
|
+
if (nodePath) {
|
|
16986
|
+
try {
|
|
16987
|
+
mergetagNodeEntry = Editor.above(editor, {
|
|
16988
|
+
at: nodePath,
|
|
16989
|
+
match: NodeUtils.isMergetagElement
|
|
16990
|
+
});
|
|
16991
|
+
} catch (error2) {
|
|
16992
|
+
}
|
|
16993
|
+
}
|
|
16632
16994
|
const mergetagNode = mergetagNodeEntry == null ? void 0 : mergetagNodeEntry[0];
|
|
16633
16995
|
const onSave = useCallback(
|
|
16634
16996
|
(val) => {
|
|
16635
16997
|
if (!mergetagNode)
|
|
16636
16998
|
return;
|
|
16999
|
+
let path2;
|
|
17000
|
+
try {
|
|
17001
|
+
path2 = ReactEditor.findPath(editor, mergetagNode);
|
|
17002
|
+
} catch (error2) {
|
|
17003
|
+
return;
|
|
17004
|
+
}
|
|
16637
17005
|
Transforms.setNodes(
|
|
16638
17006
|
editor,
|
|
16639
17007
|
{
|
|
@@ -16642,7 +17010,7 @@ const RichTextBar = ({
|
|
|
16642
17010
|
}
|
|
16643
17011
|
},
|
|
16644
17012
|
{
|
|
16645
|
-
at:
|
|
17013
|
+
at: path2
|
|
16646
17014
|
}
|
|
16647
17015
|
);
|
|
16648
17016
|
},
|
|
@@ -16707,12 +17075,17 @@ const RichTextBar = ({
|
|
|
16707
17075
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: index2 }, isFunction$4(Com) ? /* @__PURE__ */ React__default.createElement(Com, null) : toolsMapping[item2]);
|
|
16708
17076
|
});
|
|
16709
17077
|
}, [AIAssistant2, list, mergetagNode, mergetags]);
|
|
16710
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
17078
|
+
return /* @__PURE__ */ React__default.createElement(RichTextBarContext.Provider, { value: contextValue }, /* @__PURE__ */ React__default.createElement(
|
|
16711
17079
|
"div",
|
|
16712
17080
|
{
|
|
16713
17081
|
id: "RichTextBar",
|
|
16714
17082
|
className: "RichTextBar",
|
|
16715
|
-
style: {
|
|
17083
|
+
style: {
|
|
17084
|
+
display: "inline-flex",
|
|
17085
|
+
alignItems: "center",
|
|
17086
|
+
flexWrap: wrap2 ? "wrap" : "nowrap",
|
|
17087
|
+
rowGap: "4px"
|
|
17088
|
+
}
|
|
16716
17089
|
},
|
|
16717
17090
|
content
|
|
16718
17091
|
), /* @__PURE__ */ React__default.createElement("div", { className: "mergtag-popover" }, mergetagNode && MergetagPopover2 && /* @__PURE__ */ React__default.createElement(
|
|
@@ -28147,9 +28520,19 @@ const RichTextField$1 = "";
|
|
|
28147
28520
|
const loop = () => {
|
|
28148
28521
|
};
|
|
28149
28522
|
const RichtextBar = (props) => {
|
|
28150
|
-
const { clientId } = useEditorProps();
|
|
28523
|
+
const { clientId, enabledAutoComplete } = useEditorProps();
|
|
28151
28524
|
const editor = useMemo(() => createEditor(), []);
|
|
28152
28525
|
const lastTemplateRef = useRef(null);
|
|
28526
|
+
const propsOnChangeRef = useRef(props.onChange);
|
|
28527
|
+
useEffect(() => {
|
|
28528
|
+
propsOnChangeRef.current = props.onChange;
|
|
28529
|
+
}, [props.onChange]);
|
|
28530
|
+
const debouncedChange = useMemo(
|
|
28531
|
+
() => debounce$2((value) => {
|
|
28532
|
+
propsOnChangeRef.current(value);
|
|
28533
|
+
}, 100),
|
|
28534
|
+
[]
|
|
28535
|
+
);
|
|
28153
28536
|
const calculateData = useMemo(() => {
|
|
28154
28537
|
if (!props.pageElement) {
|
|
28155
28538
|
const path22 = [0, 0, 0, 0];
|
|
@@ -28186,6 +28569,8 @@ const RichtextBar = (props) => {
|
|
|
28186
28569
|
return [{ subject: "", content }, path22];
|
|
28187
28570
|
}
|
|
28188
28571
|
const pageElement = cloneDeep(omit$2(props.pageElement, "children"));
|
|
28572
|
+
pageElement.attributes["margin-top"] = "0px";
|
|
28573
|
+
pageElement.attributes["margin-bottom"] = "0px";
|
|
28189
28574
|
const template2 = {
|
|
28190
28575
|
subject: "Blank",
|
|
28191
28576
|
content: pageElement
|
|
@@ -28215,34 +28600,47 @@ const RichtextBar = (props) => {
|
|
|
28215
28600
|
}));
|
|
28216
28601
|
path2 = [0, 0, 0];
|
|
28217
28602
|
} else if (NodeUtils.isContentElement(props.value)) {
|
|
28218
|
-
|
|
28219
|
-
|
|
28220
|
-
|
|
28603
|
+
if (enabledAutoComplete) {
|
|
28604
|
+
template2.content = BlockManager.getBlockByType(ElementType.PAGE).create(
|
|
28605
|
+
__spreadProps(__spreadValues({}, pageElement), {
|
|
28606
|
+
children: [props.value]
|
|
28607
|
+
})
|
|
28608
|
+
);
|
|
28609
|
+
path2 = [0, 0];
|
|
28610
|
+
} else {
|
|
28611
|
+
template2.content = BlockManager.getBlockByType(ElementType.PAGE).create(
|
|
28612
|
+
__spreadProps(__spreadValues({}, pageElement), {
|
|
28221
28613
|
children: [
|
|
28222
|
-
BlockManager.getBlockByType(ElementType.
|
|
28614
|
+
BlockManager.getBlockByType(ElementType.STANDARD_SECTION).create({
|
|
28223
28615
|
children: [
|
|
28224
28616
|
BlockManager.getBlockByType(
|
|
28225
|
-
ElementType.
|
|
28617
|
+
ElementType.STANDARD_COLUMN
|
|
28226
28618
|
).create({
|
|
28227
|
-
children: [
|
|
28619
|
+
children: [
|
|
28620
|
+
BlockManager.getBlockByType(
|
|
28621
|
+
ElementType.STANDARD_PARAGRAPH
|
|
28622
|
+
).create({
|
|
28623
|
+
children: [props.value]
|
|
28624
|
+
})
|
|
28625
|
+
]
|
|
28228
28626
|
})
|
|
28229
|
-
]
|
|
28627
|
+
],
|
|
28628
|
+
attributes: {
|
|
28629
|
+
"padding-bottom": "0px",
|
|
28630
|
+
"padding-left": "0px",
|
|
28631
|
+
"padding-right": "0px",
|
|
28632
|
+
"padding-top": "0px"
|
|
28633
|
+
}
|
|
28230
28634
|
})
|
|
28231
|
-
]
|
|
28232
|
-
attributes: {
|
|
28233
|
-
"padding-bottom": "0px",
|
|
28234
|
-
"padding-left": "0px",
|
|
28235
|
-
"padding-right": "0px",
|
|
28236
|
-
"padding-top": "0px"
|
|
28237
|
-
}
|
|
28635
|
+
]
|
|
28238
28636
|
})
|
|
28239
|
-
|
|
28240
|
-
|
|
28241
|
-
|
|
28637
|
+
);
|
|
28638
|
+
path2 = [0, 0, 0, 0];
|
|
28639
|
+
}
|
|
28242
28640
|
}
|
|
28243
28641
|
return [template2, path2];
|
|
28244
|
-
}, [props.pageElement, props.value]);
|
|
28245
|
-
const template = calculateData[0];
|
|
28642
|
+
}, [enabledAutoComplete, props.pageElement, props.value]);
|
|
28643
|
+
const template = useMemo(() => cloneDeep(calculateData[0]), [calculateData]);
|
|
28246
28644
|
const initialValue = useMemo(() => {
|
|
28247
28645
|
if (!isEqual(lastTemplateRef.current, template)) {
|
|
28248
28646
|
lastTemplateRef.current = template;
|
|
@@ -28251,12 +28649,17 @@ const RichtextBar = (props) => {
|
|
|
28251
28649
|
}, [template]);
|
|
28252
28650
|
const onPageChange = useEventCallback(
|
|
28253
28651
|
(page, editor2) => {
|
|
28254
|
-
|
|
28255
|
-
|
|
28256
|
-
|
|
28257
|
-
|
|
28652
|
+
try {
|
|
28653
|
+
if (!Node.has(editor2, calculateData[1]))
|
|
28654
|
+
return;
|
|
28655
|
+
const currentElement = Node.get(editor2, calculateData[1]);
|
|
28656
|
+
if (!currentElement) {
|
|
28657
|
+
console.error("Element not found");
|
|
28658
|
+
return;
|
|
28659
|
+
}
|
|
28660
|
+
debouncedChange(cloneDeep(currentElement));
|
|
28661
|
+
} catch (error2) {
|
|
28258
28662
|
}
|
|
28259
|
-
props.onChange(currentElement);
|
|
28260
28663
|
}
|
|
28261
28664
|
);
|
|
28262
28665
|
return useMemo(() => {
|
|
@@ -28268,16 +28671,59 @@ const RichtextBar = (props) => {
|
|
|
28268
28671
|
initialValues: initialValue,
|
|
28269
28672
|
editor,
|
|
28270
28673
|
withEnhanceEditor: withTheme$1,
|
|
28674
|
+
EnhanceProvider: PluginsProvider,
|
|
28271
28675
|
onSubmit: loop,
|
|
28272
28676
|
onPageChange,
|
|
28273
28677
|
newLineWithBr: true
|
|
28274
28678
|
},
|
|
28275
|
-
/* @__PURE__ */ React__default.createElement(
|
|
28276
|
-
|
|
28679
|
+
/* @__PURE__ */ React__default.createElement("div", { className: "RichTextField-fixed-toolbar" }, /* @__PURE__ */ React__default.createElement(
|
|
28680
|
+
SharedComponents.RichTextBar,
|
|
28681
|
+
{
|
|
28682
|
+
wrap: true,
|
|
28683
|
+
getPopupContainer: () => document.body,
|
|
28684
|
+
list: [
|
|
28685
|
+
TextFormat.FONT_SIZE,
|
|
28686
|
+
TextFormat.TEXT_COLOR,
|
|
28687
|
+
TextFormat.BACKGROUND_COLOR,
|
|
28688
|
+
TextFormat.ALIGN,
|
|
28689
|
+
TextFormat.LIST,
|
|
28690
|
+
TextFormat.BOLD,
|
|
28691
|
+
TextFormat.ITALIC,
|
|
28692
|
+
TextFormat.UNDERLINE,
|
|
28693
|
+
TextFormat.STRIKETHROUGH,
|
|
28694
|
+
TextFormat.LINK,
|
|
28695
|
+
TextFormat.MERGETAG,
|
|
28696
|
+
TextFormat.REMOVE_FORMAT
|
|
28697
|
+
]
|
|
28698
|
+
}
|
|
28699
|
+
)),
|
|
28700
|
+
/* @__PURE__ */ React__default.createElement(
|
|
28701
|
+
"div",
|
|
28702
|
+
{
|
|
28703
|
+
className: "RichTextField-content",
|
|
28704
|
+
style: { minHeight: props.height }
|
|
28705
|
+
},
|
|
28706
|
+
/* @__PURE__ */ React__default.createElement(EmailEditor, null)
|
|
28707
|
+
),
|
|
28277
28708
|
/* @__PURE__ */ React__default.createElement(SharedComponents.Hotkeys, null),
|
|
28278
|
-
/* @__PURE__ */ React__default.createElement("style", null, styleText$h)
|
|
28709
|
+
/* @__PURE__ */ React__default.createElement("style", null, styleText$h),
|
|
28710
|
+
/* @__PURE__ */ React__default.createElement(AuthSelectBlockPath, { path: calculateData[1] })
|
|
28279
28711
|
);
|
|
28280
|
-
}, [
|
|
28712
|
+
}, [
|
|
28713
|
+
props.height,
|
|
28714
|
+
clientId,
|
|
28715
|
+
initialValue,
|
|
28716
|
+
editor,
|
|
28717
|
+
onPageChange,
|
|
28718
|
+
calculateData
|
|
28719
|
+
]);
|
|
28720
|
+
};
|
|
28721
|
+
const AuthSelectBlockPath = ({ path: path2 }) => {
|
|
28722
|
+
const setSelectedNodePath = useSetSelectedNodePath();
|
|
28723
|
+
useEffect(() => {
|
|
28724
|
+
setSelectedNodePath(path2);
|
|
28725
|
+
}, [path2, setSelectedNodePath]);
|
|
28726
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
|
|
28281
28727
|
};
|
|
28282
28728
|
const DefaultRichTextField = enhancer(RichtextBar);
|
|
28283
28729
|
const RichTextField = (props) => {
|
|
@@ -33685,6 +34131,52 @@ const ConfigPanelsMap = {
|
|
|
33685
34131
|
[ElementType.STANDARD_TABLE2]: Table2,
|
|
33686
34132
|
[ElementType.STANDARD_BLOCK_QUOTE]: Blockquote
|
|
33687
34133
|
};
|
|
34134
|
+
const PageHeaderSchema = [
|
|
34135
|
+
{
|
|
34136
|
+
type: "CollapseGroup",
|
|
34137
|
+
name: "0",
|
|
34138
|
+
header: t("Logo"),
|
|
34139
|
+
defaultActive: true,
|
|
34140
|
+
children: [
|
|
34141
|
+
{
|
|
34142
|
+
type: "ImageUrl",
|
|
34143
|
+
// section->column->image
|
|
34144
|
+
name: "data.content.0.children.0.children.0.attributes.src",
|
|
34145
|
+
label: t("Logo")
|
|
34146
|
+
},
|
|
34147
|
+
{
|
|
34148
|
+
type: "PixelField",
|
|
34149
|
+
name: "data.content.0.children.0.children.0.attributes.width",
|
|
34150
|
+
label: t("Width")
|
|
34151
|
+
},
|
|
34152
|
+
{
|
|
34153
|
+
type: "BackgroundColor",
|
|
34154
|
+
name: "attributes.background-color",
|
|
34155
|
+
label: t("Background color")
|
|
34156
|
+
}
|
|
34157
|
+
]
|
|
34158
|
+
}
|
|
34159
|
+
];
|
|
34160
|
+
const PageFooterSchema = [
|
|
34161
|
+
{
|
|
34162
|
+
type: "CollapseGroup",
|
|
34163
|
+
name: "0",
|
|
34164
|
+
header: t("Footer"),
|
|
34165
|
+
defaultActive: true,
|
|
34166
|
+
children: [
|
|
34167
|
+
{
|
|
34168
|
+
type: "TextField",
|
|
34169
|
+
name: "data.content.0.children.0.children.0.children.0.text",
|
|
34170
|
+
label: t("Text")
|
|
34171
|
+
},
|
|
34172
|
+
{
|
|
34173
|
+
type: "BackgroundColor",
|
|
34174
|
+
name: "attributes.background-color",
|
|
34175
|
+
label: t("Background color")
|
|
34176
|
+
}
|
|
34177
|
+
]
|
|
34178
|
+
}
|
|
34179
|
+
];
|
|
33688
34180
|
const BlockSchemasMap = {
|
|
33689
34181
|
// // Text elements
|
|
33690
34182
|
// [ElementType.TEXT]: TextSchema,
|
|
@@ -33726,6 +34218,8 @@ const BlockSchemasMap = {
|
|
|
33726
34218
|
// [ElementType.STANDARD_SOCIAL]: SocialSchema,
|
|
33727
34219
|
// Note: Code and Widget components are too complex for schema-based approach
|
|
33728
34220
|
// They will continue to use component-based configuration
|
|
34221
|
+
[ElementType.PAGE_HEADER]: PageHeaderSchema,
|
|
34222
|
+
[ElementType.PAGE_FOOTER]: PageFooterSchema
|
|
33729
34223
|
};
|
|
33730
34224
|
const SchemaPanelRenderer = ({
|
|
33731
34225
|
schema,
|
|
@@ -39496,6 +39990,34 @@ const EditorContainer = ({
|
|
|
39496
39990
|
}
|
|
39497
39991
|
), children);
|
|
39498
39992
|
};
|
|
39993
|
+
const normalizeElements = (element) => {
|
|
39994
|
+
const pageHeaderElements = element.children.filter(
|
|
39995
|
+
NodeUtils.isPageHeaderElement
|
|
39996
|
+
);
|
|
39997
|
+
if (pageHeaderElements.length > 1) {
|
|
39998
|
+
throw new Error("Only one page header element is allowed");
|
|
39999
|
+
}
|
|
40000
|
+
const pageFooterElements = element.children.filter(
|
|
40001
|
+
NodeUtils.isPageFooterElement
|
|
40002
|
+
);
|
|
40003
|
+
if (pageFooterElements.length > 1) {
|
|
40004
|
+
throw new Error("Only one page footer element is allowed");
|
|
40005
|
+
}
|
|
40006
|
+
if (pageHeaderElements.length === 0 && pageFooterElements.length === 0) {
|
|
40007
|
+
return assignIdsToElementTree(element);
|
|
40008
|
+
}
|
|
40009
|
+
const otherElements = element.children.filter(
|
|
40010
|
+
(child) => !NodeUtils.isPageHeaderElement(child) && !NodeUtils.isPageFooterElement(child)
|
|
40011
|
+
);
|
|
40012
|
+
const sortedChildren = [
|
|
40013
|
+
...pageHeaderElements.length > 0 ? pageHeaderElements : [],
|
|
40014
|
+
...otherElements,
|
|
40015
|
+
...pageFooterElements.length > 0 ? pageFooterElements : []
|
|
40016
|
+
];
|
|
40017
|
+
return assignIdsToElementTree(__spreadProps(__spreadValues({}, element), {
|
|
40018
|
+
children: sortedChildren
|
|
40019
|
+
}));
|
|
40020
|
+
};
|
|
39499
40021
|
const useCreateConfig$1 = (_k) => {
|
|
39500
40022
|
var _l = _k, {
|
|
39501
40023
|
interactiveStyle,
|
|
@@ -39505,7 +40027,7 @@ const useCreateConfig$1 = (_k) => {
|
|
|
39505
40027
|
"hoveringToolbar"
|
|
39506
40028
|
]);
|
|
39507
40029
|
const editor = useMemo(() => createEditor(), []);
|
|
39508
|
-
rest.initialValues.content =
|
|
40030
|
+
rest.initialValues.content = normalizeElements(
|
|
39509
40031
|
rest.initialValues.content
|
|
39510
40032
|
);
|
|
39511
40033
|
let initialValues = rest.initialValues;
|
|
@@ -40484,52 +41006,59 @@ const withTheme = (editor) => {
|
|
|
40484
41006
|
};
|
|
40485
41007
|
editor.deleteBackward = (unit) => {
|
|
40486
41008
|
var _a;
|
|
40487
|
-
|
|
40488
|
-
|
|
40489
|
-
|
|
40490
|
-
if (textElementEntry) {
|
|
40491
|
-
const text = Editor.string(editor, textElementEntry[1]);
|
|
40492
|
-
if (text.length === 0 && textElementEntry[0].type !== ElementType.STANDARD_PARAGRAPH && !NodeUtils.isTextListItemElement(textElementEntry[0])) {
|
|
40493
|
-
Transforms.setNodes(
|
|
40494
|
-
editor,
|
|
40495
|
-
{
|
|
40496
|
-
type: ElementType.STANDARD_PARAGRAPH
|
|
40497
|
-
},
|
|
40498
|
-
{
|
|
40499
|
-
at: textElementEntry[1]
|
|
40500
|
-
}
|
|
40501
|
-
);
|
|
41009
|
+
try {
|
|
41010
|
+
if (!editor.selection) {
|
|
41011
|
+
deleteBackward(unit);
|
|
40502
41012
|
return;
|
|
40503
41013
|
}
|
|
40504
|
-
|
|
40505
|
-
|
|
40506
|
-
|
|
40507
|
-
|
|
40508
|
-
|
|
40509
|
-
|
|
40510
|
-
|
|
40511
|
-
|
|
40512
|
-
|
|
40513
|
-
|
|
40514
|
-
|
|
40515
|
-
|
|
40516
|
-
|
|
40517
|
-
return NodeUtils.isTextElement(node) || NodeUtils.isButtonElement(node);
|
|
40518
|
-
},
|
|
40519
|
-
at: previousText[1]
|
|
40520
|
-
}) : [];
|
|
40521
|
-
if (previousEntry) {
|
|
40522
|
-
Transforms.select(editor, Editor.end(editor, previousEntry[1]));
|
|
40523
|
-
} else {
|
|
40524
|
-
Transforms.deselect(editor);
|
|
41014
|
+
const textElementEntry = Editor.above(editor, {
|
|
41015
|
+
match: NodeUtils.isTextElement
|
|
41016
|
+
});
|
|
41017
|
+
if (textElementEntry) {
|
|
41018
|
+
const text = Editor.string(editor, textElementEntry[1]);
|
|
41019
|
+
if (text.length === 0 && textElementEntry[0].type !== ElementType.STANDARD_PARAGRAPH && !NodeUtils.isTextListItemElement(textElementEntry[0])) {
|
|
41020
|
+
Transforms.setNodes(
|
|
41021
|
+
editor,
|
|
41022
|
+
{
|
|
41023
|
+
type: ElementType.STANDARD_PARAGRAPH
|
|
41024
|
+
},
|
|
41025
|
+
{
|
|
41026
|
+
at: textElementEntry[1]
|
|
40525
41027
|
}
|
|
40526
|
-
|
|
40527
|
-
at: contentElementEntry[1]
|
|
40528
|
-
});
|
|
40529
|
-
});
|
|
41028
|
+
);
|
|
40530
41029
|
return;
|
|
40531
41030
|
}
|
|
40532
41031
|
}
|
|
41032
|
+
const contentElementEntry = Editor.above(editor, {
|
|
41033
|
+
match: NodeUtils.isContentElement
|
|
41034
|
+
});
|
|
41035
|
+
if (contentElementEntry && !NodeUtils.isTextListItemElement(contentElementEntry[0])) {
|
|
41036
|
+
const isVoid = NodeUtils.isVoidBlockElement(contentElementEntry[0]);
|
|
41037
|
+
const textElement = contentElementEntry[0];
|
|
41038
|
+
if (textElement.children.length === 1 && !isVoid) {
|
|
41039
|
+
if (((_a = editor.selection) == null ? void 0 : _a.focus.offset) === 0) {
|
|
41040
|
+
editor.withoutNormalizing(() => {
|
|
41041
|
+
const previousText = Editor.previous(editor);
|
|
41042
|
+
const [previousEntry] = previousText ? Editor.nodes(editor, {
|
|
41043
|
+
match: (node) => {
|
|
41044
|
+
return NodeUtils.isTextElement(node) || NodeUtils.isButtonElement(node);
|
|
41045
|
+
},
|
|
41046
|
+
at: previousText[1]
|
|
41047
|
+
}) : [];
|
|
41048
|
+
if (previousEntry) {
|
|
41049
|
+
Transforms.select(editor, Editor.end(editor, previousEntry[1]));
|
|
41050
|
+
} else {
|
|
41051
|
+
Transforms.deselect(editor);
|
|
41052
|
+
}
|
|
41053
|
+
Transforms.delete(editor, {
|
|
41054
|
+
at: contentElementEntry[1]
|
|
41055
|
+
});
|
|
41056
|
+
});
|
|
41057
|
+
return;
|
|
41058
|
+
}
|
|
41059
|
+
}
|
|
41060
|
+
}
|
|
41061
|
+
} catch (error2) {
|
|
40533
41062
|
}
|
|
40534
41063
|
deleteBackward(unit);
|
|
40535
41064
|
};
|