easy-email-pro-theme 1.50.8 → 1.50.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js
CHANGED
|
@@ -15714,19 +15714,91 @@ const MergeTag = React__default.memo(() => {
|
|
|
15714
15714
|
}
|
|
15715
15715
|
));
|
|
15716
15716
|
});
|
|
15717
|
+
function styleStringToObject(styleString) {
|
|
15718
|
+
return styleString.split(";").filter(Boolean).reduce(
|
|
15719
|
+
(acc, style) => {
|
|
15720
|
+
const [property, value] = style.split(":").map((str) => str.trim());
|
|
15721
|
+
acc[property] = value;
|
|
15722
|
+
return acc;
|
|
15723
|
+
},
|
|
15724
|
+
{}
|
|
15725
|
+
);
|
|
15726
|
+
}
|
|
15717
15727
|
const TextAlign$1 = () => {
|
|
15728
|
+
var _a, _b;
|
|
15718
15729
|
const editor = useSlate();
|
|
15719
15730
|
const [match] = Editor.nodes(editor, {
|
|
15720
15731
|
match: (n) => NodeUtils.isContentElement(n),
|
|
15721
15732
|
mode: "all"
|
|
15722
15733
|
});
|
|
15734
|
+
const [matchHtmlBlockNode] = Editor.nodes(editor, {
|
|
15735
|
+
match: (node2) => {
|
|
15736
|
+
return NodeUtils.isHTMLBlockNodeElement(node2);
|
|
15737
|
+
},
|
|
15738
|
+
mode: "lowest"
|
|
15739
|
+
});
|
|
15740
|
+
const { enabledHtmlBlockNodeAlign } = useEditorProps();
|
|
15723
15741
|
const node = match == null ? void 0 : match[0];
|
|
15724
15742
|
const { setFieldValue } = useEditorContext();
|
|
15725
|
-
|
|
15743
|
+
let styleObject;
|
|
15744
|
+
if (matchHtmlBlockNode == null ? void 0 : matchHtmlBlockNode[0]) {
|
|
15745
|
+
styleObject = styleStringToObject(
|
|
15746
|
+
((_b = (_a = matchHtmlBlockNode == null ? void 0 : matchHtmlBlockNode[0]) == null ? void 0 : _a.attributes) == null ? void 0 : _b.style) || ""
|
|
15747
|
+
);
|
|
15748
|
+
}
|
|
15749
|
+
const matchAlign = get(styleObject, "text-align") || get(node.attributes, "align");
|
|
15726
15750
|
const onAlignHandle = (align) => {
|
|
15751
|
+
var _a2;
|
|
15727
15752
|
if (!match)
|
|
15728
15753
|
return;
|
|
15729
|
-
|
|
15754
|
+
if (!enabledHtmlBlockNodeAlign) {
|
|
15755
|
+
setFieldValue(match[1], "attributes.align", align);
|
|
15756
|
+
return;
|
|
15757
|
+
}
|
|
15758
|
+
const selection = editor.selection;
|
|
15759
|
+
const mergeNodeEntry = editor.selection ? editor.findSelfOrAncestorNodeByType({
|
|
15760
|
+
type: ElementType.MERGETAG,
|
|
15761
|
+
path: (_a2 = editor.selection) == null ? void 0 : _a2.anchor.path
|
|
15762
|
+
}) : null;
|
|
15763
|
+
const isCollapsed = Boolean(
|
|
15764
|
+
selection && (Range.isCollapsed(selection) || Editor.string(editor, selection) === "") && !mergeNodeEntry
|
|
15765
|
+
);
|
|
15766
|
+
const htmlBlockNodeElementEntry = Editor.above(editor, {
|
|
15767
|
+
match(node2, path2) {
|
|
15768
|
+
return NodeUtils.isHTMLBlockNodeElement(node2);
|
|
15769
|
+
},
|
|
15770
|
+
mode: "highest"
|
|
15771
|
+
});
|
|
15772
|
+
if (!htmlBlockNodeElementEntry) {
|
|
15773
|
+
if (isCollapsed) {
|
|
15774
|
+
setFieldValue(match[1], "attributes.align", align);
|
|
15775
|
+
return;
|
|
15776
|
+
}
|
|
15777
|
+
Transforms.wrapNodes(
|
|
15778
|
+
editor,
|
|
15779
|
+
{
|
|
15780
|
+
type: ElementType.HTML_BLOCK_NODE,
|
|
15781
|
+
children: [],
|
|
15782
|
+
data: {
|
|
15783
|
+
tagName: "div"
|
|
15784
|
+
},
|
|
15785
|
+
attributes: {
|
|
15786
|
+
style: `text-align:${align};`
|
|
15787
|
+
}
|
|
15788
|
+
},
|
|
15789
|
+
{
|
|
15790
|
+
match: (node2) => NodeUtils.isTextNode(node2) || NodeUtils.isInlineElement(node2),
|
|
15791
|
+
mode: "highest",
|
|
15792
|
+
at: match[1]
|
|
15793
|
+
}
|
|
15794
|
+
);
|
|
15795
|
+
} else {
|
|
15796
|
+
Transforms.setNodes(editor, {
|
|
15797
|
+
attributes: __spreadProps(__spreadValues({}, htmlBlockNodeElementEntry[0].attributes), {
|
|
15798
|
+
style: `text-align:${align};`
|
|
15799
|
+
})
|
|
15800
|
+
});
|
|
15801
|
+
}
|
|
15730
15802
|
};
|
|
15731
15803
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
15732
15804
|
FormatButton,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function styleStringToObject(styleString: string): Record<string, string>;
|