@flozy/editor 3.9.0 → 3.9.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/ChatEditor.js +16 -0
- package/dist/Editor/Elements/Accordion/Accordion.js +1 -1
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +10 -5
- package/dist/Editor/Elements/List/CheckList.js +2 -1
- package/dist/Editor/common/ColorPickerButton.js +12 -4
- package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +2 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +6 -4
- package/dist/Editor/helper/index.js +22 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +2 -8
- package/package.json +1 -1
@@ -54,6 +54,22 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
54
54
|
if (editor) {
|
55
55
|
ReactEditor.focus(editor);
|
56
56
|
insertEmoji(editor, emoji?.native, editor.selection);
|
57
|
+
if (editor.selection) {
|
58
|
+
// const path = editor.selection.anchor.path;
|
59
|
+
// const offset = editor.selection.anchor.offset + emoji?.native.length;
|
60
|
+
const position = {
|
61
|
+
anchor: {
|
62
|
+
path: [0],
|
63
|
+
offset: 0
|
64
|
+
},
|
65
|
+
focus: {
|
66
|
+
path: [0],
|
67
|
+
offset: 0
|
68
|
+
}
|
69
|
+
};
|
70
|
+
// Create a new selection
|
71
|
+
Transforms.select(editor, position);
|
72
|
+
}
|
57
73
|
ReactEditor.focus(editor);
|
58
74
|
}
|
59
75
|
},
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from "react";
|
2
|
+
import { getBorderColor, getTextColor } from "../../helper";
|
2
3
|
import { Box } from "@mui/material";
|
3
4
|
import { getBreakPointsValue, getTRBLBreakPoints } from "../../helper/theme";
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
@@ -15,21 +16,25 @@ const AccordionSummary = props => {
|
|
15
16
|
borderRadius,
|
16
17
|
bannerSpacing
|
17
18
|
} = element;
|
19
|
+
const textStyles = getTextColor(textColor);
|
20
|
+
const borderStyle = getBorderColor(borderColor);
|
18
21
|
return /*#__PURE__*/_jsx(Box, {
|
19
22
|
className: `accordion-summary-container`,
|
20
23
|
...attributes,
|
21
|
-
|
24
|
+
style: {
|
22
25
|
width: "100%",
|
23
26
|
position: "relative",
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
background: bgColor,
|
28
|
+
...borderStyle
|
29
|
+
},
|
30
|
+
sx: {
|
27
31
|
borderRadius: {
|
28
32
|
...getBreakPointsValue(borderRadius || {}, null, "overrideBorderRadius", true)
|
29
33
|
},
|
30
34
|
padding: {
|
31
35
|
...getTRBLBreakPoints(bannerSpacing)
|
32
|
-
}
|
36
|
+
},
|
37
|
+
'& span[data-slate-string="true"]': textStyles
|
33
38
|
},
|
34
39
|
component: "div",
|
35
40
|
children: children
|
@@ -68,7 +68,8 @@ const CheckList = ({
|
|
68
68
|
style: {
|
69
69
|
flex: 1,
|
70
70
|
opacity: checked ? 1 : 1,
|
71
|
-
textDecoration: !checked ? "none" : "none"
|
71
|
+
textDecoration: !checked ? "none" : "none",
|
72
|
+
width: '90%'
|
72
73
|
},
|
73
74
|
className: `checkbox-list content-editable ${isEmpty ? "empty" : ""}`,
|
74
75
|
placeholder: nestedCheckList ? "" : "Todo List",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useState } from "react";
|
1
|
+
import React, { useMemo, useState } from "react";
|
2
2
|
import { Grid, Button, Popover } from "@mui/material";
|
3
3
|
import ColorPickerTool from "react-gcolor-picker";
|
4
4
|
import { colors } from "../Elements/Color Picker/defaultColors";
|
@@ -11,7 +11,8 @@ const ColorPickerButton = props => {
|
|
11
11
|
onSave,
|
12
12
|
defaultColors = [],
|
13
13
|
classes = {},
|
14
|
-
recentColors = []
|
14
|
+
recentColors = [],
|
15
|
+
hideGradient
|
15
16
|
} = props;
|
16
17
|
const [anchorEl, setAnchorEl] = useState(null);
|
17
18
|
const [color, setColor] = useState(value);
|
@@ -29,6 +30,13 @@ const ColorPickerButton = props => {
|
|
29
30
|
const handleColorChange = color => {
|
30
31
|
setColor(color);
|
31
32
|
};
|
33
|
+
const initialColors = useMemo(() => {
|
34
|
+
let colors = [...recentColors, ...defaultColors];
|
35
|
+
if (hideGradient) {
|
36
|
+
colors = colors.filter(c => c && !c.includes("gradient"));
|
37
|
+
}
|
38
|
+
return colors;
|
39
|
+
}, [recentColors, defaultColors, hideGradient]);
|
32
40
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
33
41
|
children: [/*#__PURE__*/_jsx(Button, {
|
34
42
|
style: {
|
@@ -61,10 +69,10 @@ const ColorPickerButton = props => {
|
|
61
69
|
xs: 12,
|
62
70
|
children: [/*#__PURE__*/_jsx("div", {
|
63
71
|
children: /*#__PURE__*/_jsx(ColorPickerTool, {
|
64
|
-
gradient: true,
|
72
|
+
gradient: hideGradient ? false : true,
|
65
73
|
value: color,
|
66
74
|
onChange: handleColorChange,
|
67
|
-
defaultColors:
|
75
|
+
defaultColors: initialColors
|
68
76
|
})
|
69
77
|
}), /*#__PURE__*/_jsxs("div", {
|
70
78
|
style: {
|
@@ -12,11 +12,12 @@ const Color = props => {
|
|
12
12
|
} = props;
|
13
13
|
const {
|
14
14
|
key,
|
15
|
-
label
|
15
|
+
label,
|
16
|
+
hideGradient
|
16
17
|
} = data;
|
17
18
|
const [recentColors, setRecentColors] = useState({});
|
18
19
|
useEffect(() => {
|
19
|
-
const storedColors = JSON.parse(localStorage.getItem(
|
20
|
+
const storedColors = JSON.parse(localStorage.getItem("recentColors"));
|
20
21
|
if (storedColors) {
|
21
22
|
setRecentColors(storedColors);
|
22
23
|
}
|
@@ -39,7 +40,7 @@ const Color = props => {
|
|
39
40
|
[key]: updatedColors
|
40
41
|
};
|
41
42
|
setRecentColors(updatedColors);
|
42
|
-
localStorage.setItem(
|
43
|
+
localStorage.setItem("recentColors", JSON.stringify(updatedColors));
|
43
44
|
};
|
44
45
|
return /*#__PURE__*/_jsxs(Grid, {
|
45
46
|
item: true,
|
@@ -68,7 +69,8 @@ const Color = props => {
|
|
68
69
|
classes: classes,
|
69
70
|
value: value,
|
70
71
|
onSave: onSave,
|
71
|
-
recentColors: recentColors[key]
|
72
|
+
recentColors: recentColors[key],
|
73
|
+
hideGradient: hideGradient
|
72
74
|
})
|
73
75
|
})
|
74
76
|
}
|
@@ -154,4 +154,26 @@ export const debounce = function (func, wait, immediate) {
|
|
154
154
|
timeout = setTimeout(later, wait);
|
155
155
|
if (callNow) func.apply(context, args);
|
156
156
|
};
|
157
|
+
};
|
158
|
+
export const getTextColor = (color = "") => {
|
159
|
+
return color?.indexOf("gradient") >= 0 ? {
|
160
|
+
background: color?.concat("text"),
|
161
|
+
WebkitBackgroundClip: "text",
|
162
|
+
WebkitTextFillColor: "transparent",
|
163
|
+
color: "transparent",
|
164
|
+
caretColor: "black"
|
165
|
+
} : {
|
166
|
+
color
|
167
|
+
};
|
168
|
+
};
|
169
|
+
export const getBorderColor = (borderColor = "") => {
|
170
|
+
const borderStyle = borderColor ? {
|
171
|
+
border: "1px solid"
|
172
|
+
} : {};
|
173
|
+
if (borderColor?.indexOf("gradient") >= 0) {
|
174
|
+
borderStyle.borderImage = `${borderColor} 1`;
|
175
|
+
} else {
|
176
|
+
borderStyle.borderColor = borderColor;
|
177
|
+
}
|
178
|
+
return borderStyle;
|
157
179
|
};
|
@@ -32,7 +32,7 @@ import FormField from "../Elements/Form/FormField";
|
|
32
32
|
import InlineIcon from "../Elements/InlineIcon/InlineIcon";
|
33
33
|
import SimpleText from "../Elements/SimpleText";
|
34
34
|
import CheckList from "../Elements/List/CheckList";
|
35
|
-
import { isEmptyTextNode } from "../helper";
|
35
|
+
import { getTextColor, isEmptyTextNode } from "../helper";
|
36
36
|
import Attachments from "../Elements/Attachments/Attachments";
|
37
37
|
import { getBreakPointsValue } from "../helper/theme";
|
38
38
|
import Variables from "../Elements/Variables/Variable";
|
@@ -203,13 +203,7 @@ export const getMarked = (leaf, children) => {
|
|
203
203
|
// cover under single span
|
204
204
|
if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || className) {
|
205
205
|
const family = fontFamilyMap[leaf?.fontFamily];
|
206
|
-
const textStyles = leaf?.color
|
207
|
-
background: leaf?.color?.concat("text"),
|
208
|
-
WebkitBackgroundClip: "text",
|
209
|
-
WebkitTextFillColor: "transparent"
|
210
|
-
} : {
|
211
|
-
color: leaf.color
|
212
|
-
};
|
206
|
+
const textStyles = getTextColor(leaf?.color);
|
213
207
|
children = /*#__PURE__*/_jsx("span", {
|
214
208
|
style: {
|
215
209
|
background: leaf.bgColor
|