@flozy/editor 11.2.2 → 11.2.3
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.
@@ -35,6 +35,11 @@ const EditorButton = props => {
|
|
35
35
|
} = customProps;
|
36
36
|
const editor = useSlateStatic();
|
37
37
|
const path = ReactEditor.findPath(editor, element);
|
38
|
+
|
39
|
+
// Helper function to detect if a color value is a gradient
|
40
|
+
const isGradientColor = color => {
|
41
|
+
return color && typeof color === "string" && color.includes("gradient");
|
42
|
+
};
|
38
43
|
const [edit, setEdit] = useState(false);
|
39
44
|
const [openNav, setOpenNav] = useState(false);
|
40
45
|
const [openMoreOptions, setOpenMoreOptions] = useState(false);
|
@@ -76,6 +81,9 @@ const EditorButton = props => {
|
|
76
81
|
const isTrigger = linkType === "nextTrigger" || linkType === "prevTrigger";
|
77
82
|
const refURl = isTrigger ? buttonLink?.url : url;
|
78
83
|
const BtnIcon = buttonIcon ? buttonIcon : null;
|
84
|
+
|
85
|
+
// Check if borderColor is a gradient
|
86
|
+
const isBorderGradient = isGradientColor(borderColor);
|
79
87
|
windowVar.lastButtonProps = element;
|
80
88
|
const handleTrigger = async () => {
|
81
89
|
if (!readOnly) {
|
@@ -201,6 +209,32 @@ const EditorButton = props => {
|
|
201
209
|
...getTRBLBreakPoints(bannerSpacing)
|
202
210
|
}
|
203
211
|
}, theme);
|
212
|
+
const btnSp2 = groupByBreakpoint({
|
213
|
+
borderRadius: {
|
214
|
+
...getBreakPointsValue(borderRadius || {}, null, "overrideBorderRadius", true)
|
215
|
+
}
|
216
|
+
}, theme);
|
217
|
+
const buttonBoxSx = {
|
218
|
+
position: "relative",
|
219
|
+
display: "inline-block",
|
220
|
+
...btnSp2,
|
221
|
+
...(isBorderGradient ? {
|
222
|
+
padding: borderWidth !== undefined ? borderWidth : borderColor ? "1px" : "0px",
|
223
|
+
background: borderColor,
|
224
|
+
backgroundClip: "padding-box, border-box",
|
225
|
+
boxSizing: "border-box",
|
226
|
+
"&:hover": {
|
227
|
+
background: borderColorHover || borderColor
|
228
|
+
}
|
229
|
+
} : {
|
230
|
+
borderWidth: borderWidth !== undefined ? borderWidth : borderColor ? "1px" : "0px",
|
231
|
+
borderStyle: borderStyle || "solid",
|
232
|
+
borderColor: borderColor || "transparent",
|
233
|
+
"&:hover": {
|
234
|
+
borderColor: borderColorHover || borderColor || "transparent"
|
235
|
+
}
|
236
|
+
})
|
237
|
+
};
|
204
238
|
const pSp = groupByBreakpoint({
|
205
239
|
display: {
|
206
240
|
xs: xsHidden ? "none" : "inline-block",
|
@@ -259,22 +293,16 @@ const EditorButton = props => {
|
|
259
293
|
},
|
260
294
|
position: "relative"
|
261
295
|
},
|
262
|
-
children: /*#__PURE__*/_jsxs(
|
263
|
-
|
264
|
-
|
265
|
-
display: "inline-block"
|
266
|
-
},
|
296
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
297
|
+
component: "span",
|
298
|
+
sx: buttonBoxSx,
|
267
299
|
children: [/*#__PURE__*/_jsxs(Box, {
|
268
300
|
ref: buttonRef,
|
269
301
|
className: `btn textAlign-${tAlign}`,
|
270
302
|
sx: {
|
271
303
|
textDecoration: "none",
|
272
304
|
background: bgColor || "rgb(30, 75, 122)",
|
273
|
-
borderBlockStyle: "solid",
|
274
|
-
borderColor: borderColor || "transparent",
|
275
|
-
borderWidth: borderWidth !== undefined ? borderWidth : borderColor || borderColorHover ? "1px" : "0px",
|
276
305
|
...btnSp,
|
277
|
-
borderStyle: borderStyle || "solid",
|
278
306
|
color: `${textColor || "#FFFFFF"}`,
|
279
307
|
fontSize: textSize || "inherit",
|
280
308
|
fontFamily: fontFamily || "PoppinsRegular",
|
@@ -288,7 +316,6 @@ const EditorButton = props => {
|
|
288
316
|
"&:hover": {
|
289
317
|
color: `${textColorHover || textColor || "#FFFFFF"}`,
|
290
318
|
background: bgColorHover || bgColor || "rgb(30, 75, 122)",
|
291
|
-
borderColor: borderColorHover || borderColor || "transparent",
|
292
319
|
"& .element-toolbar": {
|
293
320
|
display: "flex"
|
294
321
|
}
|
@@ -297,7 +324,7 @@ const EditorButton = props => {
|
|
297
324
|
...buttonProps,
|
298
325
|
children: [BtnIcon && iconPosition === "start" && /*#__PURE__*/_jsx(MUIIcon, {
|
299
326
|
...muiIconProps
|
300
|
-
}), label || translation("My Button"), BtnIcon && iconPosition === "end" && /*#__PURE__*/_jsx(MUIIcon, {
|
327
|
+
}), label || translation("My Button 12"), BtnIcon && iconPosition === "end" && /*#__PURE__*/_jsx(MUIIcon, {
|
301
328
|
...muiIconProps
|
302
329
|
})]
|
303
330
|
}), !readOnly && buttonRef?.current && /*#__PURE__*/_jsx(Popper, {
|
@@ -1,5 +1,16 @@
|
|
1
1
|
import { fontOptions } from "../../utils/font";
|
2
|
+
|
3
|
+
// Helper function to detect if a color value is a gradient
|
2
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
const isGradientColor = color => {
|
6
|
+
return color && typeof color === 'string' && color.includes('gradient');
|
7
|
+
};
|
8
|
+
|
9
|
+
// Helper function to check if any color in the element is a gradient
|
10
|
+
const hasGradientColors = element => {
|
11
|
+
const colorFields = ['bgColor', 'bgColorHover', 'borderColor', 'borderColorHover', 'textColor', 'textColorHover'];
|
12
|
+
return colorFields.some(field => isGradientColor(element[field]));
|
13
|
+
};
|
3
14
|
const buttonStyle = [{
|
4
15
|
tab: "General",
|
5
16
|
value: "size",
|
@@ -108,7 +119,8 @@ const buttonStyle = [{
|
|
108
119
|
return /*#__PURE__*/_jsx("span", {
|
109
120
|
children: translation(option.text)
|
110
121
|
});
|
111
|
-
}
|
122
|
+
},
|
123
|
+
condition: element => !hasGradientColors(element)
|
112
124
|
}]
|
113
125
|
}, {
|
114
126
|
tab: "Icon",
|
@@ -35,11 +35,19 @@ export const StyleContent = props => {
|
|
35
35
|
fields: []
|
36
36
|
};
|
37
37
|
const filteredFields = (hideTools || [])?.length > 0 ? fields.filter(f => (hideTools || []).indexOf(f.key) === -1) : fields;
|
38
|
+
|
39
|
+
// Apply conditional field visibility
|
40
|
+
const conditionallyFilteredFields = filteredFields.filter(field => {
|
41
|
+
if (field.condition && typeof field.condition === 'function') {
|
42
|
+
return field.condition(element);
|
43
|
+
}
|
44
|
+
return true;
|
45
|
+
});
|
38
46
|
return /*#__PURE__*/_jsx(Grid, {
|
39
47
|
container: true,
|
40
48
|
spacing: 2,
|
41
49
|
className: "sidebar-wrpr-eds",
|
42
|
-
children: [...
|
50
|
+
children: [...conditionallyFilteredFields].map((m, i) => {
|
43
51
|
const FieldComponent = FieldMap[m.type];
|
44
52
|
return FieldComponent ? /*#__PURE__*/_jsx(FieldComponent, {
|
45
53
|
data: m,
|
@@ -210,7 +218,12 @@ const StyleBuilder = props => {
|
|
210
218
|
sx: {
|
211
219
|
padding: "5px"
|
212
220
|
},
|
213
|
-
children: m?.fields.filter(f => (hideTools || []).indexOf(f.value) === -1).
|
221
|
+
children: m?.fields.filter(f => (hideTools || []).indexOf(f.value) === -1).filter(field => {
|
222
|
+
if (field.condition && typeof field.condition === 'function') {
|
223
|
+
return field.condition(elementProps);
|
224
|
+
}
|
225
|
+
return true;
|
226
|
+
}).map((field, index) => {
|
214
227
|
return /*#__PURE__*/_jsx(StyleContent, {
|
215
228
|
renderTabs: [field],
|
216
229
|
value: field.value,
|