@flozy/editor 6.0.3 → 6.0.5
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/ChatEditor.js +7 -7
- package/dist/Editor/CommonEditor.js +25 -81
- package/dist/Editor/DialogWrapper.js +25 -31
- package/dist/Editor/Editor.css +16 -22
- package/dist/Editor/Elements/AI/PopoverAIInput.js +12 -2
- package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
- package/dist/Editor/Elements/Button/EditorButton.js +9 -26
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +12 -57
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
- package/dist/Editor/Elements/Color Picker/Styles.js +1 -1
- package/dist/Editor/Elements/DataView/DataView.js +3 -4
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +1 -5
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +1 -5
- package/dist/Editor/Elements/DataView/Layouts/FilterView.js +19 -23
- package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +1 -1
- package/dist/Editor/Elements/Embed/Image.js +2 -2
- package/dist/Editor/Elements/Form/Form.js +0 -1
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +14 -0
- package/dist/Editor/Elements/FreeGrid/styles.js +0 -4
- package/dist/Editor/Elements/Grid/GridItem.js +3 -2
- package/dist/Editor/Elements/Link/Link.js +43 -70
- package/dist/Editor/Elements/List/CheckList.js +1 -2
- package/dist/Editor/Elements/Search/SearchAttachment.js +0 -1
- package/dist/Editor/Elements/Search/SearchList.js +1 -8
- package/dist/Editor/Elements/SimpleText/index.js +1 -8
- package/dist/Editor/Elements/SimpleText/style.js +1 -5
- package/dist/Editor/Elements/Table/Table.js +3 -3
- package/dist/Editor/Elements/Table/TableCell.js +9 -14
- package/dist/Editor/Elements/Title/title.js +1 -13
- package/dist/Editor/Elements/Variables/Style.js +2 -28
- package/dist/Editor/Elements/Variables/VariableButton.js +4 -17
- package/dist/Editor/MiniEditor.js +2 -4
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +15 -7
- package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +36 -46
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectAlignment.js +1 -3
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +13 -6
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +1 -3
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +91 -211
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -11
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +12 -16
- package/dist/Editor/Toolbar/PopupTool/TemplateCard.js +1 -1
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +7 -99
- package/dist/Editor/Toolbar/PopupTool/index.js +0 -2
- package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
- package/dist/Editor/common/ColorPickerButton.js +9 -32
- package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
- package/dist/Editor/common/DnD/Draggable.js +1 -0
- package/dist/Editor/common/FontLoader/FontList.js +9 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +4 -6
- package/dist/Editor/common/Icon.js +0 -28
- package/dist/Editor/common/ImageSelector/Styles.js +9 -3
- package/dist/Editor/common/MentionsPopup/Styles.js +9 -3
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +2 -3
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -14
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +4 -5
- package/dist/Editor/common/RnD/Utils/index.js +0 -40
- package/dist/Editor/common/RnD/index.js +3 -23
- package/dist/Editor/common/Shorthands/elements.js +0 -54
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +2 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +11 -35
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +4 -13
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +0 -4
- package/dist/Editor/common/Uploader.js +0 -8
- package/dist/Editor/commonStyle.js +63 -58
- package/dist/Editor/helper/deserialize/index.js +1 -1
- package/dist/Editor/helper/index.js +2 -2
- package/dist/Editor/helper/theme.js +3 -224
- package/dist/Editor/hooks/useMouseMove.js +5 -13
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +2 -2
- package/dist/Editor/plugins/withLayout.js +1 -1
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/theme/ThemeList.js +173 -50
- package/dist/Editor/utils/SlateUtilityFunctions.js +42 -161
- package/dist/Editor/utils/button.js +14 -0
- package/dist/Editor/utils/customHooks/useTableResize.js +1 -2
- package/dist/Editor/utils/draftToSlate.js +2 -3
- package/dist/Editor/utils/font.js +37 -40
- package/dist/Editor/utils/helper.js +19 -88
- package/dist/Editor/utils/link.js +1 -1
- package/dist/Editor/utils/pageSettings.js +2 -14
- package/dist/Editor/utils/table.js +0 -21
- package/package.json +2 -5
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -438
- package/dist/Editor/assets/svg/ThemeIcons.js +0 -291
- package/dist/Editor/common/CustomColorPicker/index.js +0 -106
- package/dist/Editor/common/CustomColorPicker/style.js +0 -53
- package/dist/Editor/common/CustomDialog/index.js +0 -94
- package/dist/Editor/common/CustomDialog/style.js +0 -67
- package/dist/Editor/common/CustomSelect.js +0 -33
- package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +0 -79
- package/dist/Editor/helper/ensureWrappedVariables.js +0 -28
- package/dist/Editor/hooks/useEditorTheme.js +0 -153
- package/dist/Editor/theme/index.js +0 -144
- package/dist/Editor/themeSettings/ActiveTheme.js +0 -72
- package/dist/Editor/themeSettings/buttons/index.js +0 -283
- package/dist/Editor/themeSettings/buttons/style.js +0 -21
- package/dist/Editor/themeSettings/colorTheme/index.js +0 -292
- package/dist/Editor/themeSettings/colorTheme/style.js +0 -77
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
- package/dist/Editor/themeSettings/fonts/index.js +0 -220
- package/dist/Editor/themeSettings/fonts/style.js +0 -44
- package/dist/Editor/themeSettings/icons.js +0 -60
- package/dist/Editor/themeSettings/index.js +0 -320
- package/dist/Editor/themeSettings/style.js +0 -152
- package/dist/Editor/themeSettingsAI/icons.js +0 -96
- package/dist/Editor/themeSettingsAI/index.js +0 -356
- package/dist/Editor/themeSettingsAI/saveTheme.js +0 -197
- package/dist/Editor/themeSettingsAI/style.js +0 -250
@@ -1,58 +1,181 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { useEffect, useState } from "react";
|
1
|
+
import { MenuItem, Select, useTheme } from "@mui/material";
|
2
|
+
import { fontOptions } from "../utils/font";
|
3
|
+
import { toolbarGroups } from "../Toolbar/toolbarGroups";
|
5
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
6
5
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
}
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
} catch (err) {
|
20
|
-
console.log(err);
|
21
|
-
}
|
22
|
-
setLoading(false);
|
23
|
-
};
|
6
|
+
const themes = [{
|
7
|
+
label: "Theme 1",
|
8
|
+
colors: ["#c90c1f", "#ff5d05"]
|
9
|
+
}, {
|
10
|
+
label: "Theme 2",
|
11
|
+
colors: ["#4c0be3", "#43f7ee"]
|
12
|
+
}, {
|
13
|
+
label: "Theme 3",
|
14
|
+
colors: ["#22f20f", "#fff705"]
|
15
|
+
}];
|
16
|
+
const allTools = toolbarGroups.flat();
|
17
|
+
function ThemeList(props) {
|
24
18
|
const {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
19
|
+
selectedTheme,
|
20
|
+
setSelectedTheme
|
21
|
+
} = props;
|
22
|
+
const fontWeight = allTools.find(f => f.format === "fontWeight");
|
23
|
+
const fontStyles = [{
|
24
|
+
text: "Bold",
|
25
|
+
value: "bold",
|
26
|
+
styleField: "fontWeight"
|
27
|
+
}, {
|
28
|
+
text: "Italic",
|
29
|
+
value: "italic",
|
30
|
+
styleField: "fontStyle"
|
31
|
+
}
|
32
|
+
// {
|
33
|
+
// text: "Underline",
|
34
|
+
// value: "underline",
|
35
|
+
// styleField: "textDecoration",
|
36
|
+
// },
|
37
|
+
// {
|
38
|
+
// text: "Line through",
|
39
|
+
// value: "line-through",
|
40
|
+
// styleField: "textDecoration",
|
41
|
+
// },
|
42
|
+
];
|
43
|
+
|
44
|
+
const theme = useTheme();
|
45
|
+
const colorVars = theme?.vars?.colors || {};
|
46
|
+
const handleTypographyTheme = (key, value, elementType) => {
|
47
|
+
setSelectedTheme(prev => {
|
48
|
+
const newValue = {
|
49
|
+
...prev,
|
50
|
+
typography: {
|
51
|
+
...(prev.typography || {}),
|
52
|
+
[elementType]: {
|
53
|
+
...(prev?.typography?.[elementType] || {}),
|
54
|
+
[key]: value
|
55
|
+
}
|
56
|
+
}
|
57
|
+
};
|
58
|
+
if (!value) {
|
59
|
+
delete newValue?.typography?.[elementType]?.[key];
|
60
|
+
}
|
61
|
+
return newValue;
|
62
|
+
});
|
36
63
|
};
|
37
|
-
return /*#__PURE__*/
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
64
|
+
return /*#__PURE__*/_jsxs("div", {
|
65
|
+
children: [themes.map((theme, i) => {
|
66
|
+
return /*#__PURE__*/_jsxs("button", {
|
67
|
+
style: {
|
68
|
+
margin: "10px"
|
69
|
+
},
|
70
|
+
onClick: () => setSelectedTheme(prev => ({
|
71
|
+
...prev,
|
72
|
+
colors: theme.colors
|
73
|
+
})),
|
74
|
+
children: [theme.label, /*#__PURE__*/_jsx("div", {
|
75
|
+
children: theme.colors.map((c, j) => {
|
76
|
+
return /*#__PURE__*/_jsx("div", {
|
77
|
+
style: {
|
78
|
+
width: "20px",
|
79
|
+
height: "20px",
|
80
|
+
background: c,
|
81
|
+
margin: "10px"
|
82
|
+
}
|
83
|
+
}, j);
|
84
|
+
})
|
85
|
+
})]
|
86
|
+
}, i);
|
87
|
+
}), /*#__PURE__*/_jsxs("div", {
|
88
|
+
children: ["Heading 1 Font Family", /*#__PURE__*/_jsx(Select
|
89
|
+
// value={""}
|
90
|
+
, {
|
91
|
+
label: "Font Family",
|
92
|
+
onChange: e => {
|
93
|
+
handleTypographyTheme("fontFamily", e.target.value, "h1");
|
94
|
+
},
|
95
|
+
children: fontOptions.map((font, i) => {
|
96
|
+
const {
|
97
|
+
text,
|
98
|
+
value
|
99
|
+
} = font;
|
100
|
+
return /*#__PURE__*/_jsx(MenuItem, {
|
101
|
+
value: value,
|
102
|
+
children: text
|
103
|
+
}, i);
|
104
|
+
})
|
105
|
+
}), "Font Weight", /*#__PURE__*/_jsx(Select
|
106
|
+
// value={""}
|
107
|
+
, {
|
108
|
+
label: "Font Weight",
|
109
|
+
onChange: e => {
|
110
|
+
handleTypographyTheme("fontWeight", e.target.value, "h1");
|
111
|
+
},
|
112
|
+
children: fontWeight.options.map((option, i) => {
|
113
|
+
const {
|
114
|
+
text,
|
115
|
+
value
|
116
|
+
} = option;
|
117
|
+
return /*#__PURE__*/_jsx(MenuItem, {
|
118
|
+
value: value,
|
119
|
+
children: text
|
120
|
+
}, i);
|
121
|
+
})
|
122
|
+
}), /*#__PURE__*/_jsx("input", {
|
123
|
+
type: "number",
|
124
|
+
placeholder: "font size",
|
125
|
+
onChange: e => {
|
126
|
+
handleTypographyTheme("fontSize", e.target.value, "h1");
|
127
|
+
}
|
128
|
+
}), /*#__PURE__*/_jsxs("div", {
|
129
|
+
children: ["Text", /*#__PURE__*/_jsx("br", {}), "Theme color", Object.values(colorVars).map((colorVar, i) => {
|
130
|
+
return /*#__PURE__*/_jsx("button", {
|
131
|
+
style: {
|
132
|
+
width: "20px",
|
133
|
+
height: "20px",
|
134
|
+
background: colorVar,
|
135
|
+
margin: "10px",
|
136
|
+
outline: "none"
|
137
|
+
},
|
138
|
+
onClick: () => handleTypographyTheme("color", colorVar, "h1")
|
139
|
+
}, i);
|
140
|
+
}), "normal color", /*#__PURE__*/_jsx("button", {
|
141
|
+
style: {
|
142
|
+
width: "20px",
|
143
|
+
height: "20px",
|
144
|
+
background: "#ff00e1",
|
145
|
+
margin: "10px",
|
146
|
+
outline: "none"
|
147
|
+
},
|
148
|
+
onClick: () => handleTypographyTheme("color", "#ff00e1", "h1")
|
149
|
+
})]
|
150
|
+
}), /*#__PURE__*/_jsxs("div", {
|
151
|
+
children: ["Font styles", fontStyles.map((option, i) => {
|
152
|
+
const styles = selectedTheme?.typography?.h1 || {};
|
153
|
+
const {
|
154
|
+
text,
|
155
|
+
value,
|
156
|
+
styleField
|
157
|
+
} = option;
|
158
|
+
return /*#__PURE__*/_jsxs("button", {
|
159
|
+
onClick: () => {
|
160
|
+
handleTypographyTheme(styleField, styles[styleField] === value ? null : value, "h1");
|
161
|
+
},
|
162
|
+
children: [text, " ", styles[styleField] === value]
|
163
|
+
}, i);
|
164
|
+
})]
|
165
|
+
}), /*#__PURE__*/_jsx("input", {
|
166
|
+
type: "number",
|
167
|
+
placeholder: "Margin text Spacing",
|
168
|
+
onChange: e => {
|
169
|
+
handleTypographyTheme("letterSpacing", e.target.value, "h1");
|
170
|
+
}
|
171
|
+
}), /*#__PURE__*/_jsx("input", {
|
172
|
+
type: "number",
|
173
|
+
placeholder: "Line spacing",
|
174
|
+
onChange: e => {
|
175
|
+
handleTypographyTheme("lineHeight", e.target.value, "h1");
|
176
|
+
}
|
54
177
|
})]
|
55
|
-
})
|
178
|
+
})]
|
56
179
|
});
|
57
180
|
}
|
58
181
|
export default ThemeList;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Editor, Transforms, Element as SlateElement
|
1
|
+
import { Editor, Transforms, Element as SlateElement } from "slate";
|
2
2
|
import { Box } from "@mui/material";
|
3
3
|
import { sizeMap } from "./font";
|
4
4
|
import Link from "../Elements/Link/Link";
|
@@ -34,12 +34,12 @@ import SimpleText from "../Elements/SimpleText";
|
|
34
34
|
import CheckList from "../Elements/List/CheckList";
|
35
35
|
import { getTextColor, isEmptyTextNode } from "../helper";
|
36
36
|
import Attachments from "../Elements/Attachments/Attachments";
|
37
|
-
import { getBreakPointsValue,
|
37
|
+
import { getBreakPointsValue, groupByBreakpoint } from "../helper/theme";
|
38
38
|
import Variables from "../Elements/Variables/Variable";
|
39
|
+
import insertNewLine from "./insertNewLine";
|
39
40
|
import Divider from "../Elements/Divider/Divider";
|
40
41
|
import { getBorderColor } from "./helper";
|
41
42
|
import Code from "../Elements/EmbedScript/Code";
|
42
|
-
import { ReactEditor } from "slate-react";
|
43
43
|
import FreeGrid from "../Elements/FreeGrid/FreeGrid";
|
44
44
|
import FreeGridItem from "../Elements/FreeGrid/FreeGridItem";
|
45
45
|
import FreeGridBox from "../Elements/FreeGrid/FreeGridBox";
|
@@ -47,7 +47,7 @@ import DataView from "../Elements/DataView/DataView";
|
|
47
47
|
import ViewData from "../Elements/DataView/Layouts/ViewData";
|
48
48
|
import ColumnView from "../Elements/DataView/Layouts/ColumnView";
|
49
49
|
import SearchAttachment from "../Elements/Search/SearchAttachment";
|
50
|
-
import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
|
50
|
+
// import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
|
51
51
|
import { jsx as _jsx } from "react/jsx-runtime";
|
52
52
|
const alignment = ["alignLeft", "alignRight", "alignCenter", "alignJustify"];
|
53
53
|
const list_types = ["orderedList", "unorderedList"];
|
@@ -55,17 +55,7 @@ const LIST_FORMAT_TYPE = {
|
|
55
55
|
orderedList: "list-item",
|
56
56
|
unorderedList: "list-item"
|
57
57
|
};
|
58
|
-
|
59
|
-
// const NEWLINESAFTER = [
|
60
|
-
// "headingOne",
|
61
|
-
// "headingTwo",
|
62
|
-
// "headingThree",
|
63
|
-
// "headingFour",
|
64
|
-
// "headingFive",
|
65
|
-
// "headingSix",
|
66
|
-
// ];
|
67
|
-
|
68
|
-
const THEME_BLOCK_FIELDS = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
|
58
|
+
const NEWLINESAFTER = ["headingOne", "headingTwo", "headingThree"];
|
69
59
|
export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
70
60
|
const isActive = isBlockActive(editor, format);
|
71
61
|
const isList = list_types.includes(format);
|
@@ -98,9 +88,8 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
98
88
|
if (!selection) {
|
99
89
|
Transforms.insertText(editor, "");
|
100
90
|
}
|
101
|
-
const forActiveType = THEME_BLOCK_FIELDS.some(f => f === format) ? format : "paragraph";
|
102
91
|
Transforms.setNodes(editor, {
|
103
|
-
type: isActive ?
|
92
|
+
type: isActive ? "paragraph" : isList ? LIST_FORMAT_TYPE[format] : format,
|
104
93
|
...attr
|
105
94
|
});
|
106
95
|
if (isList && !isActive) {
|
@@ -109,12 +98,10 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
109
98
|
children: []
|
110
99
|
});
|
111
100
|
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
// }
|
101
|
+
if (NEWLINESAFTER.indexOf(format) > -1) {
|
102
|
+
insertNewLine(editor);
|
103
|
+
}
|
116
104
|
};
|
117
|
-
|
118
105
|
export const addMarkData = (editor, data) => {
|
119
106
|
try {
|
120
107
|
Editor.addMark(editor, data.format, data.value);
|
@@ -123,14 +110,9 @@ export const addMarkData = (editor, data) => {
|
|
123
110
|
}
|
124
111
|
};
|
125
112
|
export const toggleMark = (editor, format) => {
|
126
|
-
const isActive =
|
113
|
+
const isActive = isMarkActive(editor, format);
|
127
114
|
if (isActive) {
|
128
|
-
|
129
|
-
if (isThemeSupportedMark) {
|
130
|
-
Editor.addMark(editor, format, false);
|
131
|
-
} else {
|
132
|
-
Editor.removeMark(editor, format);
|
133
|
-
}
|
115
|
+
Editor.removeMark(editor, format);
|
134
116
|
} else {
|
135
117
|
Editor.addMark(editor, format, true);
|
136
118
|
}
|
@@ -144,52 +126,6 @@ export const isMarkActive = (editor, format) => {
|
|
144
126
|
return null;
|
145
127
|
}
|
146
128
|
};
|
147
|
-
export const isMarkBtnActive = (editor, format) => {
|
148
|
-
switch (format) {
|
149
|
-
case "bold":
|
150
|
-
{
|
151
|
-
const style = getSelectedElementStyle("font-weight", editor);
|
152
|
-
return style === "700";
|
153
|
-
}
|
154
|
-
case "italic":
|
155
|
-
{
|
156
|
-
const style = getSelectedElementStyle("font-style", editor);
|
157
|
-
return style === format;
|
158
|
-
}
|
159
|
-
// case "underline": {
|
160
|
-
// const style = getSelectedElementStyle("text-decoration");
|
161
|
-
|
162
|
-
// return style?.includes(format);
|
163
|
-
// }
|
164
|
-
// case "strikethrough": {
|
165
|
-
// const style = getSelectedElementStyle("text-decoration");
|
166
|
-
|
167
|
-
// return style?.includes("line-through");
|
168
|
-
// }
|
169
|
-
default:
|
170
|
-
return isMarkActive(editor, format);
|
171
|
-
}
|
172
|
-
};
|
173
|
-
export const getSelectedElementStyle = (styleProperty, editor) => {
|
174
|
-
try {
|
175
|
-
if (!editor.selection) {
|
176
|
-
return "";
|
177
|
-
}
|
178
|
-
if (Range.isCollapsed(editor.selection)) {
|
179
|
-
return "";
|
180
|
-
}
|
181
|
-
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
182
|
-
const selectedDomNode = domRange.commonAncestorContainer;
|
183
|
-
|
184
|
-
// If it's a text node, get its parent element
|
185
|
-
const selectedElement = selectedDomNode.nodeType === 3 ? selectedDomNode.parentElement : selectedDomNode;
|
186
|
-
if (selectedElement) {
|
187
|
-
return getElementProperty(selectedElement, styleProperty);
|
188
|
-
}
|
189
|
-
} catch (err) {
|
190
|
-
console.log(err);
|
191
|
-
}
|
192
|
-
};
|
193
129
|
export const isBlockActive = (editor, format) => {
|
194
130
|
const [match] = Editor.nodes(editor, {
|
195
131
|
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
|
@@ -232,39 +168,15 @@ export const activeMark = (editor, format) => {
|
|
232
168
|
return null;
|
233
169
|
}
|
234
170
|
};
|
235
|
-
|
236
|
-
// to avoid the styles, that automatically assign from themes
|
237
|
-
const getThemeMarkedLeaf = (leaf, children) => {
|
238
|
-
const {
|
239
|
-
italic,
|
240
|
-
bold
|
241
|
-
} = leaf || {};
|
242
|
-
const style = {};
|
243
|
-
if (italic === false) {
|
244
|
-
style.fontStyle = "normal";
|
245
|
-
}
|
246
|
-
if (bold === false) {
|
247
|
-
style.fontWeight = "normal";
|
248
|
-
}
|
249
|
-
if (Object.keys(style).length) {
|
250
|
-
children = /*#__PURE__*/_jsx(Box, {
|
251
|
-
component: "span",
|
252
|
-
sx: {
|
253
|
-
"& span": style
|
254
|
-
},
|
255
|
-
children: children
|
256
|
-
});
|
257
|
-
}
|
258
|
-
return children;
|
259
|
-
};
|
260
171
|
export const getMarked = (leaf, children, theme) => {
|
261
172
|
const className = leaf?.doublequote ? "doublequote" : "";
|
262
173
|
if (leaf.highlight) {
|
263
174
|
children = /*#__PURE__*/_jsx("span", {
|
264
175
|
style: {
|
265
|
-
color: "inherit"
|
266
|
-
background: "var(--slate-highlight-bg)"
|
176
|
+
color: "inherit"
|
267
177
|
},
|
178
|
+
className: "slate-highlight" // while opening AI, we will use this element to highlight the selection. (PopoverAIInput.js)
|
179
|
+
,
|
268
180
|
children: children
|
269
181
|
});
|
270
182
|
}
|
@@ -283,7 +195,6 @@ export const getMarked = (leaf, children, theme) => {
|
|
283
195
|
children: children
|
284
196
|
});
|
285
197
|
}
|
286
|
-
children = getThemeMarkedLeaf(leaf, children);
|
287
198
|
if (leaf.strikethrough) {
|
288
199
|
children = /*#__PURE__*/_jsx("span", {
|
289
200
|
style: {
|
@@ -311,27 +222,20 @@ export const getMarked = (leaf, children, theme) => {
|
|
311
222
|
if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || className) {
|
312
223
|
const family = leaf?.fontFamily;
|
313
224
|
const textStyles = getTextColor(leaf?.color);
|
314
|
-
const fontSize = {
|
315
|
-
lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
316
|
-
...getBreakPointsValue(leaf.fontSize, null, "overrideText")
|
317
|
-
};
|
318
|
-
const fontSizesImportant = {};
|
319
|
-
Object.entries(fontSize).forEach(([key, value]) => {
|
320
|
-
fontSizesImportant[key] = `${value} !important`;
|
321
|
-
});
|
322
|
-
const fontSizeWithBreakpoints = wrapThemeBreakpoints(fontSizesImportant, "fontSize", theme);
|
323
225
|
children = /*#__PURE__*/_jsx("span", {
|
226
|
+
style: {
|
227
|
+
background: leaf.bgColor
|
228
|
+
},
|
324
229
|
children: /*#__PURE__*/_jsx(Box, {
|
325
230
|
className: className,
|
326
231
|
component: "span",
|
327
232
|
sx: {
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
},
|
334
|
-
...fontSizeWithBreakpoints,
|
233
|
+
...groupByBreakpoint({
|
234
|
+
fontSize: {
|
235
|
+
lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
236
|
+
...getBreakPointsValue(leaf.fontSize, null, "overrideText")
|
237
|
+
}
|
238
|
+
}, theme),
|
335
239
|
// ...wrapThemeBreakpoints(
|
336
240
|
// {
|
337
241
|
// lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
@@ -373,71 +277,55 @@ export const getBlock = props => {
|
|
373
277
|
} = props;
|
374
278
|
const attributes = props.attributes ?? {};
|
375
279
|
const isEmpty = isEmptyTextNode(element);
|
376
|
-
const commonHeadingProps = () => ({
|
377
|
-
...attributes,
|
378
|
-
...element.attr,
|
379
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} theme-element`
|
380
|
-
});
|
381
|
-
const commonParaProps = paraType => ({
|
382
|
-
...attributes,
|
383
|
-
...element.attr,
|
384
|
-
className: `content-editable ${isEmpty ? "empty" : ""} theme-element ${paraType}`
|
385
|
-
});
|
386
280
|
switch (element.type) {
|
387
281
|
case "headingOne":
|
388
282
|
return /*#__PURE__*/_jsx("h1", {
|
389
|
-
...
|
283
|
+
...attributes,
|
284
|
+
...element.attr,
|
285
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
390
286
|
placeholder: "Heading 1",
|
391
287
|
children: children
|
392
288
|
});
|
393
289
|
case "headingTwo":
|
394
290
|
return /*#__PURE__*/_jsx("h2", {
|
395
|
-
...
|
291
|
+
...attributes,
|
292
|
+
...element.attr,
|
293
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
396
294
|
placeholder: "Heading 2",
|
397
295
|
children: children
|
398
296
|
});
|
399
297
|
case "headingThree":
|
400
298
|
return /*#__PURE__*/_jsx("h3", {
|
401
|
-
...
|
299
|
+
...attributes,
|
300
|
+
...element.attr,
|
301
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
402
302
|
placeholder: "Heading 3",
|
403
303
|
children: children
|
404
304
|
});
|
405
305
|
case "headingFour":
|
406
306
|
return /*#__PURE__*/_jsx("h4", {
|
407
|
-
...
|
307
|
+
...attributes,
|
308
|
+
...element.attr,
|
309
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
408
310
|
placeholder: "Heading 4",
|
409
311
|
children: children
|
410
312
|
});
|
411
313
|
case "headingFive":
|
412
314
|
return /*#__PURE__*/_jsx("h5", {
|
413
|
-
...
|
315
|
+
...attributes,
|
316
|
+
...element.attr,
|
317
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
414
318
|
placeholder: "Heading 5",
|
415
319
|
children: children
|
416
320
|
});
|
417
321
|
case "headingSix":
|
418
322
|
return /*#__PURE__*/_jsx("h6", {
|
419
|
-
...
|
323
|
+
...attributes,
|
324
|
+
...element.attr,
|
325
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
420
326
|
placeholder: "Heading 6",
|
421
327
|
children: children
|
422
328
|
});
|
423
|
-
case "paragraphOne":
|
424
|
-
return /*#__PURE__*/_jsx("p", {
|
425
|
-
...commonParaProps("para1"),
|
426
|
-
placeholder: "Paragraph 1",
|
427
|
-
children: children
|
428
|
-
});
|
429
|
-
case "paragraphTwo":
|
430
|
-
return /*#__PURE__*/_jsx("p", {
|
431
|
-
...commonParaProps("para2"),
|
432
|
-
placeholder: "Paragraph 2",
|
433
|
-
children: children
|
434
|
-
});
|
435
|
-
case "paragraphThree":
|
436
|
-
return /*#__PURE__*/_jsx("p", {
|
437
|
-
...commonParaProps("para3"),
|
438
|
-
placeholder: "Paragraph 3",
|
439
|
-
children: children
|
440
|
-
});
|
441
329
|
case "blockquote":
|
442
330
|
return /*#__PURE__*/_jsx("blockquote", {
|
443
331
|
...attributes,
|
@@ -450,8 +338,7 @@ export const getBlock = props => {
|
|
450
338
|
borderRadius: `${element?.color ? "0px" : "12px"} 12px 12px ${element?.color ? "0px" : "12px"}`,
|
451
339
|
margin: `${element?.bgColor ? "16px" : "0px"} 0px`,
|
452
340
|
width: element?.bgColor ? "calc(100% - 16px)" : "100%",
|
453
|
-
borderWidth: element?.color ? "0px 0px 0px 3px" : "0px"
|
454
|
-
lineHeight: 1.43
|
341
|
+
borderWidth: element?.color ? "0px 0px 0px 3px" : "0px"
|
455
342
|
},
|
456
343
|
children: children
|
457
344
|
});
|
@@ -511,9 +398,6 @@ export const getBlock = props => {
|
|
511
398
|
});
|
512
399
|
case "orderedList":
|
513
400
|
return /*#__PURE__*/_jsx("ol", {
|
514
|
-
style: {
|
515
|
-
lineHeight: 1.43
|
516
|
-
},
|
517
401
|
className: "listItemMargin",
|
518
402
|
type: "1",
|
519
403
|
...attributes,
|
@@ -521,9 +405,6 @@ export const getBlock = props => {
|
|
521
405
|
});
|
522
406
|
case "unorderedList":
|
523
407
|
return /*#__PURE__*/_jsx("ul", {
|
524
|
-
style: {
|
525
|
-
lineHeight: 1.43
|
526
|
-
},
|
527
408
|
className: "listItemMargin",
|
528
409
|
...attributes,
|
529
410
|
children: children
|
@@ -11,6 +11,20 @@ export const insertButton = editor => {
|
|
11
11
|
linkType: "webAddress"
|
12
12
|
},
|
13
13
|
iconPosition: "start",
|
14
|
+
bgColor: "#2563EB",
|
15
|
+
textColor: "#FFF",
|
16
|
+
borderRadius: {
|
17
|
+
topLeft: 30,
|
18
|
+
topRight: 30,
|
19
|
+
bottomLeft: 30,
|
20
|
+
bottomRight: 30
|
21
|
+
},
|
22
|
+
bannerSpacing: {
|
23
|
+
left: 16,
|
24
|
+
top: 8,
|
25
|
+
right: 16,
|
26
|
+
bottom: 8
|
27
|
+
},
|
14
28
|
...(windowVar.lastButtonProps || {})
|
15
29
|
};
|
16
30
|
Transforms.insertNodes(editor, button);
|
@@ -43,8 +43,7 @@ const useTableResize = ({
|
|
43
43
|
minWidth
|
44
44
|
} = minMaxProps || {};
|
45
45
|
setSize(currentSize => {
|
46
|
-
const
|
47
|
-
const calcWidth = width + e.movementX;
|
46
|
+
const calcWidth = currentSize?.width + e.movementX;
|
48
47
|
return {
|
49
48
|
width: minWidth && calcWidth < minWidth ? minWidth : calcWidth,
|
50
49
|
height: currentSize.height + e.movementY,
|
@@ -82,8 +82,7 @@ const splitInlineStyleRanges = (text, inlineStyleRanges, data) => {
|
|
82
82
|
};
|
83
83
|
export const draftToSlate = props => {
|
84
84
|
const {
|
85
|
-
data
|
86
|
-
needLayout
|
85
|
+
data
|
87
86
|
} = props;
|
88
87
|
if (data?.blocks && data?.blocks?.length > 0) {
|
89
88
|
const converted = data?.blocks?.reduce((a, b) => {
|
@@ -105,7 +104,7 @@ export const draftToSlate = props => {
|
|
105
104
|
return data;
|
106
105
|
} else {
|
107
106
|
return [{
|
108
|
-
type:
|
107
|
+
type: "paragraph",
|
109
108
|
children: [{
|
110
109
|
text: ""
|
111
110
|
}]
|