@flozy/editor 9.5.1 → 9.5.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.
- package/dist/Editor/Elements/Carousel/slick.min.css +13 -0
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +6 -3
- package/dist/Editor/Elements/FreeGrid/styles.js +3 -0
- package/dist/Editor/Elements/Search/SearchAttachment.js +12 -0
- package/dist/Editor/Elements/Search/SearchList.js +3 -0
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +5 -2
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +4 -2
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +6 -4
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +2 -1
- package/dist/Editor/common/CustomColorPicker/index.js +8 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +7 -9
- package/dist/Editor/commonStyle.js +3 -0
- package/dist/Editor/helper/theme.js +3 -1
- package/dist/Editor/hooks/useThemeValues.js +36 -4
- package/dist/Editor/theme/index.js +4 -1
- package/dist/Editor/themeSettings/colorTheme/index.js +8 -6
- package/dist/Editor/themeSettings/fonts/style.js +4 -3
- package/dist/Editor/utils/SlateUtilityFunctions.js +1 -1
- package/dist/Editor/utils/helper.js +43 -0
- package/package.json +1 -1
@@ -83,3 +83,16 @@
|
|
83
83
|
.slick-arrow.slick-hidden {
|
84
84
|
display: none;
|
85
85
|
}
|
86
|
+
|
87
|
+
.slick-dots li {
|
88
|
+
margin-top: 4px;
|
89
|
+
border: 0.5px solid #FFFFFF
|
90
|
+
}
|
91
|
+
|
92
|
+
.slick-dots .slick-active {
|
93
|
+
background-color: #2563EB !important;
|
94
|
+
}
|
95
|
+
|
96
|
+
.slick-dots li {
|
97
|
+
background-color: #9DA9BA;
|
98
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useState } from "react";
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
|
-
import { IconButton, Tooltip, Box, Popover } from "@mui/material";
|
3
|
+
import { IconButton, Tooltip, Box, Popover, useTheme } from "@mui/material";
|
4
4
|
import { addMarkData, activeMark } from "../../utils/SlateUtilityFunctions";
|
5
5
|
import ColorButtons from "./ColorButtons";
|
6
6
|
import ColorPickerStyles from "./Styles";
|
@@ -8,6 +8,7 @@ import colorWheel from "./colorWheel.png";
|
|
8
8
|
import "./ColorPicker.css";
|
9
9
|
import { useEditorContext } from "../../hooks/useMouseMove";
|
10
10
|
import CustomColorPicker from "../../common/CustomColorPicker";
|
11
|
+
import { getSelectedElementColor } from "../../utils/helper";
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
12
13
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
13
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
@@ -25,7 +26,8 @@ const ColorPicker = props => {
|
|
25
26
|
classes,
|
26
27
|
forMiniTool,
|
27
28
|
openColorTool,
|
28
|
-
closeColorTool
|
29
|
+
closeColorTool,
|
30
|
+
type
|
29
31
|
} = props;
|
30
32
|
const {
|
31
33
|
theme
|
@@ -34,6 +36,7 @@ const ColorPicker = props => {
|
|
34
36
|
const [anchorEl, setAnchorEl] = useState(null);
|
35
37
|
const open = Boolean(anchorEl);
|
36
38
|
const pickerStyles = ColorPickerStyles(theme);
|
39
|
+
const muiTheme = useTheme();
|
37
40
|
const onOpen = e => {
|
38
41
|
e.preventDefault();
|
39
42
|
setAnchorEl(e.currentTarget);
|
@@ -58,7 +61,7 @@ const ColorPicker = props => {
|
|
58
61
|
setAnchorEl(null);
|
59
62
|
setSelection(null);
|
60
63
|
};
|
61
|
-
const activeColor = activeMark(editor, format) || DEFAULT_COLOR[format];
|
64
|
+
const activeColor = type === "textColor" ? getSelectedElementColor(editor, format, muiTheme) : activeMark(editor, format) || DEFAULT_COLOR[format];
|
62
65
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
63
66
|
children: [forMiniTool ? null : /*#__PURE__*/_jsx(Tooltip, {
|
64
67
|
title: title,
|
@@ -50,12 +50,18 @@ const SearchAttachment = props => {
|
|
50
50
|
cursor: 'pointer',
|
51
51
|
margin: '4px 0px',
|
52
52
|
lineHeight: 1.43,
|
53
|
+
"&.MuiPaper-root": {
|
54
|
+
width: "fit-content !important"
|
55
|
+
},
|
53
56
|
"&.MuiPaper-root.MuiPaper-rounded": {
|
54
57
|
borderRadius: "7px !important",
|
55
58
|
paddingTop: '0px !important'
|
56
59
|
},
|
57
60
|
"& *::selection": {
|
58
61
|
background: "#000"
|
62
|
+
},
|
63
|
+
"&.MuiPaper-root > div": {
|
64
|
+
width: "unset !important"
|
59
65
|
}
|
60
66
|
},
|
61
67
|
onClick: handleClick,
|
@@ -65,6 +71,9 @@ const SearchAttachment = props => {
|
|
65
71
|
'& path': {
|
66
72
|
stroke: theme?.palette?.text?.slashBrainText
|
67
73
|
}
|
74
|
+
},
|
75
|
+
"&.MuiPaper-root > div": {
|
76
|
+
width: "unset !important"
|
68
77
|
}
|
69
78
|
},
|
70
79
|
children: /*#__PURE__*/_jsx(Icon, {
|
@@ -80,6 +89,9 @@ const SearchAttachment = props => {
|
|
80
89
|
color: "#2563EB",
|
81
90
|
'&.MuiCardContent-root:last-child': {
|
82
91
|
paddingBottom: '3px'
|
92
|
+
},
|
93
|
+
"&.MuiPaper-root > div": {
|
94
|
+
width: "unset !important"
|
83
95
|
}
|
84
96
|
},
|
85
97
|
children: /*#__PURE__*/_jsxs(Typography, {
|
@@ -18,8 +18,11 @@ const TextSize = ({
|
|
18
18
|
const timerRef = useRef();
|
19
19
|
const [size] = useWindowResize();
|
20
20
|
const val = activeMark(editor, format);
|
21
|
-
|
22
|
-
const
|
21
|
+
|
22
|
+
// const noFontSize =
|
23
|
+
// val === "normal" || (typeof val === "object" && !Object.keys(val)?.length);
|
24
|
+
|
25
|
+
const value = getTextSizeVal(editor);
|
23
26
|
useEffect(() => {
|
24
27
|
setFontSize(getSizeVal());
|
25
28
|
}, [value]);
|
@@ -12,7 +12,8 @@ function MiniColorPicker(props) {
|
|
12
12
|
classes,
|
13
13
|
id,
|
14
14
|
editor,
|
15
|
-
customProps
|
15
|
+
customProps,
|
16
|
+
type
|
16
17
|
} = props;
|
17
18
|
const [openColorTool, setOpenColorTool] = useState(null);
|
18
19
|
const {
|
@@ -38,7 +39,8 @@ function MiniColorPicker(props) {
|
|
38
39
|
classes: classes,
|
39
40
|
forMiniTool: true,
|
40
41
|
openColorTool: openColorTool,
|
41
|
-
closeColorTool: () => setOpenColorTool(null)
|
42
|
+
closeColorTool: () => setOpenColorTool(null),
|
43
|
+
type: type
|
42
44
|
}, id)]
|
43
45
|
});
|
44
46
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Fade, Grid, IconButton, Paper, Popper } from "@mui/material";
|
1
|
+
import { Fade, Grid, IconButton, Paper, Popper, useTheme } from "@mui/material";
|
2
2
|
import SelectTypography from "./SelectTypography";
|
3
3
|
import SelectList from "./SelectList";
|
4
4
|
import { toolbarGroups } from "../../toolbarGroups";
|
@@ -14,7 +14,7 @@ import MiniColorPicker from "./MiniColorPicker";
|
|
14
14
|
import SelectAlignment from "./SelectAlignment";
|
15
15
|
import SelectFontSize from "./SelectFontSize";
|
16
16
|
import InfinityAITool from "./InfinityAITool";
|
17
|
-
import { viewSlateSelection } from "../../../utils/helper";
|
17
|
+
import { getSelectedElementColor, viewSlateSelection } from "../../../utils/helper";
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
19
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
20
20
|
const DEFAULT_COLOR = {
|
@@ -35,11 +35,12 @@ const MiniTextFormat = props => {
|
|
35
35
|
const open = Boolean(anchorEl);
|
36
36
|
const id = open ? "popup-edit-tool" : "";
|
37
37
|
const [size] = useWindowResize();
|
38
|
+
const theme = useTheme();
|
38
39
|
const removeFontStyles = ["superscript", "subscript"];
|
39
40
|
const fontStyle = allTools.filter(f => f.type === "mark" && !removeFontStyles.includes(f.format));
|
40
41
|
const link = allTools.find(f => f.format?.indexOf("link") >= 0);
|
41
42
|
const fontAlign = allTools.filter(f => f.format?.indexOf("align") >= 0);
|
42
|
-
const activeColor =
|
43
|
+
const activeColor = getSelectedElementColor(editor, textColorFormat, theme);
|
43
44
|
const activeBg = activeMark(editor, textBgFormat) || DEFAULT_COLOR[textBgFormat];
|
44
45
|
return /*#__PURE__*/_jsx(Grid, {
|
45
46
|
container: true,
|
@@ -93,7 +94,8 @@ const MiniTextFormat = props => {
|
|
93
94
|
activeColor: activeColor,
|
94
95
|
id: "11_cc",
|
95
96
|
editor: editor,
|
96
|
-
customProps: customProps
|
97
|
+
customProps: customProps,
|
98
|
+
type: "textColor"
|
97
99
|
}), /*#__PURE__*/_jsx(MiniColorPicker, {
|
98
100
|
format: textBgFormat,
|
99
101
|
classes: classes,
|
@@ -2,9 +2,10 @@ import { Box, Button, Paper, Typography, useTheme } from "@mui/material";
|
|
2
2
|
import ColorPickerTool from "react-gcolor-picker";
|
3
3
|
import customColorPickerStyles from "./style";
|
4
4
|
import { colors } from "../../Elements/Color Picker/defaultColors";
|
5
|
-
import { useMemo, useState } from "react";
|
5
|
+
import { useCallback, useMemo, useState } from "react";
|
6
6
|
import { useEditorContext } from "../../hooks/useMouseMove";
|
7
7
|
import { getVariableValue } from "../../helper/theme";
|
8
|
+
import { getSelectedColor } from "../../utils/helper";
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
9
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
11
|
const getColors = (colors, colorTab, key) => {
|
@@ -25,7 +26,7 @@ function CustomColorPicker(props) {
|
|
25
26
|
const {
|
26
27
|
gradient,
|
27
28
|
color,
|
28
|
-
onChange,
|
29
|
+
onChange: onChangeColor,
|
29
30
|
defaultColors,
|
30
31
|
recentColors,
|
31
32
|
closeDrawer,
|
@@ -39,6 +40,9 @@ function CustomColorPicker(props) {
|
|
39
40
|
const classes = customColorPickerStyles();
|
40
41
|
const theme = useTheme();
|
41
42
|
const colorVars = theme?.vars?.colors || {};
|
43
|
+
const onChange = useCallback(color => {
|
44
|
+
onChangeColor(getSelectedColor(color, theme));
|
45
|
+
}, [onChangeColor, theme]);
|
42
46
|
const colorTabs = useMemo(() => {
|
43
47
|
const otherColors = {
|
44
48
|
title: "Recent colours",
|
@@ -63,6 +67,7 @@ function CustomColorPicker(props) {
|
|
63
67
|
tabs.push(otherColors);
|
64
68
|
return tabs;
|
65
69
|
}, [recentColors, defaultColors, onChange, colorVars]);
|
70
|
+
const selectValue = getSelectedColor(color, theme);
|
66
71
|
return /*#__PURE__*/_jsxs(Paper, {
|
67
72
|
component: "div",
|
68
73
|
sx: classes.customColorPickerContainer,
|
@@ -100,7 +105,7 @@ function CustomColorPicker(props) {
|
|
100
105
|
component: "div",
|
101
106
|
className: "colorPickerBtnContainer",
|
102
107
|
children: getColors(colors, colorTab, key).map((colorVar, i) => {
|
103
|
-
const isSelected = colorVar ===
|
108
|
+
const isSelected = colorVar === selectValue;
|
104
109
|
return /*#__PURE__*/_jsx(Box, {
|
105
110
|
className: isSelected ? "colorPicketBtnActive" : "",
|
106
111
|
component: "div",
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import React, { useEffect, useMemo, useState } from "react";
|
2
2
|
import { Grid, TextField, InputAdornment, Typography, Tooltip } from "@mui/material";
|
3
3
|
import ColorPickerButton from "../../ColorPickerButton";
|
4
|
-
import { useSlateStatic } from "slate-react";
|
5
4
|
import { getVariableValue } from "../../../helper/theme";
|
6
5
|
import { useButtonStyle } from "../../../hooks/useThemeValues";
|
7
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
@@ -29,22 +28,21 @@ const Color = props => {
|
|
29
28
|
translation
|
30
29
|
} = customProps;
|
31
30
|
const [recentColors, setRecentColors] = useState({});
|
32
|
-
const editor = useSlateStatic();
|
33
31
|
const {
|
34
32
|
buttonStyle
|
35
|
-
} = useButtonStyle(val,
|
33
|
+
} = useButtonStyle(val, key, elementProps);
|
34
|
+
const newValue = buttonStyle?.color;
|
36
35
|
const {
|
37
36
|
value,
|
38
37
|
inputValue
|
39
38
|
} = useMemo(() => {
|
40
|
-
const isVariable =
|
41
|
-
const
|
42
|
-
const inputValue = isVariable ? getVariableValue(val) : buttonStyle;
|
39
|
+
const isVariable = newValue && newValue.startsWith("var");
|
40
|
+
const inputValue = isVariable ? getVariableValue(newValue) : newValue;
|
43
41
|
return {
|
44
|
-
value:
|
45
|
-
inputValue: inputValue
|
42
|
+
value: newValue,
|
43
|
+
inputValue: inputValue
|
46
44
|
};
|
47
|
-
}, [buttonStyle
|
45
|
+
}, [buttonStyle?.color]);
|
48
46
|
const getLable = label === "Text" ? translation("selectTextColor") : label === "Background" ? translation("selectBgColor") : translation(label);
|
49
47
|
useEffect(() => {
|
50
48
|
const storedColors = JSON.parse(localStorage.getItem("recentColors"));
|
@@ -164,7 +164,9 @@ const MAP_PROPERTY_KEYS = {
|
|
164
164
|
fontFamily: "font-family",
|
165
165
|
fontSize: "font-size",
|
166
166
|
textSize: "font-size",
|
167
|
-
fontWeight: "font-weight"
|
167
|
+
fontWeight: "font-weight",
|
168
|
+
color: "color",
|
169
|
+
bgColor: "background-color"
|
168
170
|
};
|
169
171
|
export function getElementProperty(element, styleProperty) {
|
170
172
|
if (!element) {
|
@@ -2,20 +2,52 @@ import { useEffect, useState } from "react";
|
|
2
2
|
import { getElementProperty } from "../helper/theme";
|
3
3
|
import { ReactEditor } from "slate-react";
|
4
4
|
import { Node } from "slate";
|
5
|
+
import { useEditorTheme } from "./useEditorTheme";
|
5
6
|
function useThemeValues() {
|
6
7
|
return {};
|
7
8
|
}
|
8
9
|
export default useThemeValues;
|
9
|
-
export function useButtonStyle(value,
|
10
|
+
export function useButtonStyle(value, key, element) {
|
10
11
|
const [buttonStyle, setButtonStyle] = useState(value);
|
12
|
+
const {
|
13
|
+
selectedTheme
|
14
|
+
} = useEditorTheme();
|
15
|
+
const themeBtnProps = selectedTheme?.elementProps?.button || {};
|
11
16
|
useEffect(() => {
|
12
|
-
const
|
13
|
-
setButtonStyle(
|
14
|
-
|
17
|
+
const color = getColorValue(value, key, element, themeBtnProps);
|
18
|
+
setButtonStyle({
|
19
|
+
color
|
20
|
+
});
|
21
|
+
}, [value, key, element]);
|
15
22
|
return {
|
16
23
|
buttonStyle
|
17
24
|
};
|
18
25
|
}
|
26
|
+
const DEFAULT_MAP_THEMES = {
|
27
|
+
textColor: "color",
|
28
|
+
bgColor: "backgroundColor"
|
29
|
+
};
|
30
|
+
const hoverMap = (theme, format) => {
|
31
|
+
const hover = theme?.hover || {};
|
32
|
+
const key = DEFAULT_MAP_THEMES[format];
|
33
|
+
return hover[key];
|
34
|
+
};
|
35
|
+
const MAP_THEME_KEYS = {
|
36
|
+
...DEFAULT_MAP_THEMES,
|
37
|
+
textColorHover: hoverMap,
|
38
|
+
bgColorHover: hoverMap
|
39
|
+
};
|
40
|
+
const getColorValue = (val, key, elementProps, themeBtnProps) => {
|
41
|
+
const themeKey = MAP_THEME_KEYS[key];
|
42
|
+
if (elementProps?.type === "button" && !val && themeKey) {
|
43
|
+
if (typeof themeKey === "string") {
|
44
|
+
return themeBtnProps[themeKey];
|
45
|
+
} else {
|
46
|
+
return themeKey(themeBtnProps, key);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
return val;
|
50
|
+
};
|
19
51
|
export function getButtonElementStyle(editor, element, stylePropertyName) {
|
20
52
|
try {
|
21
53
|
const path = ReactEditor.findPath(editor, element);
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { getDevice } from "../helper/theme";
|
1
2
|
const themeClassName = ".theme-element";
|
2
3
|
function getTextStyles(props) {
|
3
4
|
const {
|
@@ -5,11 +6,13 @@ function getTextStyles(props) {
|
|
5
6
|
textDecoration,
|
6
7
|
...rest
|
7
8
|
} = props;
|
9
|
+
const device = getDevice();
|
10
|
+
const fontS = typeof fontSize === "object" ? fontSize[device] : fontSize;
|
8
11
|
return {
|
9
12
|
...rest,
|
10
13
|
'& span[data-slate-string="true"]': {
|
11
14
|
textDecoration,
|
12
|
-
fontSize
|
15
|
+
fontSize: fontS
|
13
16
|
}
|
14
17
|
|
15
18
|
// "&::after": {
|
@@ -112,14 +112,15 @@ const ColorTheme = props => {
|
|
112
112
|
onColorChange(selectedColor, i);
|
113
113
|
}
|
114
114
|
},
|
115
|
-
hideThemeColors: true
|
116
|
-
hideGradient
|
115
|
+
hideThemeColors: true
|
116
|
+
// hideGradient={true}
|
117
|
+
,
|
117
118
|
classes: classes,
|
118
119
|
value: color,
|
119
120
|
children: /*#__PURE__*/_jsxs(Grid, {
|
120
121
|
className: "pmBox",
|
121
122
|
style: {
|
122
|
-
|
123
|
+
background: color
|
123
124
|
},
|
124
125
|
children: [/*#__PURE__*/_jsx(IconButton, {
|
125
126
|
className: "editBtn",
|
@@ -163,14 +164,15 @@ const ColorTheme = props => {
|
|
163
164
|
onColorChange(selectedColor, colorIndex);
|
164
165
|
}
|
165
166
|
},
|
166
|
-
hideThemeColors: true
|
167
|
-
hideGradient
|
167
|
+
hideThemeColors: true
|
168
|
+
// hideGradient={true}
|
169
|
+
,
|
168
170
|
classes: classes,
|
169
171
|
value: color,
|
170
172
|
children: /*#__PURE__*/_jsxs(Grid, {
|
171
173
|
className: "sdBox",
|
172
174
|
style: {
|
173
|
-
|
175
|
+
background: color
|
174
176
|
},
|
175
177
|
children: [/*#__PURE__*/_jsx(IconButton, {
|
176
178
|
className: "editBtn",
|
@@ -29,8 +29,8 @@ const Style = ({
|
|
29
29
|
fontSize: "12px",
|
30
30
|
color: "#64748B",
|
31
31
|
".dotColor": {
|
32
|
-
width: "
|
33
|
-
height: "
|
32
|
+
width: "14px",
|
33
|
+
height: "14px",
|
34
34
|
borderRadius: "12px",
|
35
35
|
background: "#0F172A",
|
36
36
|
marginRight: "3px"
|
@@ -40,7 +40,8 @@ const Style = ({
|
|
40
40
|
width: "200px",
|
41
41
|
whiteSpace: "nowrap",
|
42
42
|
overflow: "hidden",
|
43
|
-
textOverflow: "ellipsis"
|
43
|
+
textOverflow: "ellipsis",
|
44
|
+
color: `${appTheme?.palette?.editor?.textColor} !important`
|
44
45
|
},
|
45
46
|
".MuiAutocomplete-input": {
|
46
47
|
color: appTheme?.palette?.editor?.textColor
|
@@ -396,7 +396,7 @@ export const getBlock = props => {
|
|
396
396
|
const commonParaProps = paraType => ({
|
397
397
|
...attributes,
|
398
398
|
...element.attr,
|
399
|
-
className: `content-editable ${isEmpty ? "empty" : ""} theme-element ${paraType}`
|
399
|
+
className: `edt-paragraphs content-editable ${isEmpty ? "empty" : ""} theme-element ${paraType}`
|
400
400
|
});
|
401
401
|
switch (element.type) {
|
402
402
|
case "headingOne":
|
@@ -2,6 +2,7 @@ import { Editor, Node, Transforms, Element, Path, Range, Text } from "slate";
|
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
3
|
import insertNewLine from "./insertNewLine";
|
4
4
|
import { getDevice } from "../helper/theme";
|
5
|
+
import { activeMark, getSelectedElementStyle } from "./SlateUtilityFunctions";
|
5
6
|
export const windowVar = {};
|
6
7
|
let ST_TIMEOUT = null;
|
7
8
|
const BLOCKS = ["grid", "dataView"];
|
@@ -886,4 +887,46 @@ export const getCurrentNodeText = editor => {
|
|
886
887
|
} catch (error) {
|
887
888
|
console.log("Error:", error);
|
888
889
|
}
|
890
|
+
};
|
891
|
+
function convertColorToRgb(color) {
|
892
|
+
if (color?.startsWith("#")) {
|
893
|
+
// HEX to RGB
|
894
|
+
let hex = color.replace("#", "");
|
895
|
+
let r, g, b;
|
896
|
+
if (hex.length === 3) {
|
897
|
+
hex = hex.split("").map(x => x + x).join("");
|
898
|
+
}
|
899
|
+
if (hex.length === 6) {
|
900
|
+
[r, g, b] = [hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)].map(val => parseInt(val, 16));
|
901
|
+
return `rgb(${r}, ${g}, ${b})`;
|
902
|
+
}
|
903
|
+
} else {
|
904
|
+
return color;
|
905
|
+
}
|
906
|
+
}
|
907
|
+
export const getSelectedColor = (selectedColor, theme) => {
|
908
|
+
const colorVars = theme?.vars?.colors;
|
909
|
+
let selectedValue = selectedColor;
|
910
|
+
if (colorVars) {
|
911
|
+
const convertedColor = convertColorToRgb(selectedColor);
|
912
|
+
Object.entries(theme.colors).forEach(([key, value]) => {
|
913
|
+
const convertedThemeColor = convertColorToRgb(value);
|
914
|
+
if (convertedThemeColor === convertedColor) {
|
915
|
+
selectedValue = colorVars[key];
|
916
|
+
}
|
917
|
+
});
|
918
|
+
}
|
919
|
+
return selectedValue;
|
920
|
+
};
|
921
|
+
const themeTextFormats = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
|
922
|
+
export const getSelectedElementColor = (editor, format, theme) => {
|
923
|
+
const [isThemeText] = Editor.nodes(editor, {
|
924
|
+
at: editor.selection,
|
925
|
+
match: n => themeTextFormats.includes(n?.type)
|
926
|
+
});
|
927
|
+
if (!isThemeText) {
|
928
|
+
return activeMark(editor, "color") || "#000000";
|
929
|
+
}
|
930
|
+
const color = getSelectedElementStyle(format, editor, format);
|
931
|
+
return getSelectedColor(color, theme);
|
889
932
|
};
|