@flozy/editor 9.1.0 → 9.1.1
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 +3 -2
- package/dist/Editor/CommonEditor.js +103 -24
- package/dist/Editor/DialogWrapper.js +31 -25
- package/dist/Editor/Editor.css +19 -1
- package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
- package/dist/Editor/Elements/Button/EditorButton.js +25 -9
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +57 -12
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +5 -5
- package/dist/Editor/Elements/Color Picker/Styles.js +1 -1
- package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +4 -1
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +3 -4
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +6 -1
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +19 -9
- package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +32 -2
- package/dist/Editor/Elements/DataView/Layouts/TableView.js +126 -29
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +3 -3
- package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +1 -1
- package/dist/Editor/Elements/DataView/styles.js +8 -8
- package/dist/Editor/Elements/Embed/Image.js +2 -2
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +0 -14
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +2 -1
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +2 -1
- package/dist/Editor/Elements/FreeGrid/styles.js +3 -0
- package/dist/Editor/Elements/Grid/GridItem.js +2 -3
- package/dist/Editor/Elements/Link/Link.js +70 -43
- package/dist/Editor/Elements/SimpleText/index.js +0 -1
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/Table.js +5 -4
- package/dist/Editor/Elements/Table/TableCell.js +4 -3
- package/dist/Editor/Elements/Title/title.js +13 -1
- package/dist/Editor/Elements/Variables/Style.js +28 -2
- package/dist/Editor/Elements/Variables/VariableButton.js +17 -4
- package/dist/Editor/Styles/EditorStyles.js +5 -5
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +7 -15
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -0
- package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +9 -8
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +6 -13
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +210 -85
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +16 -12
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +57 -13
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +438 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +2 -1
- package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
- package/dist/Editor/assets/svg/ThemeIcons.js +291 -0
- package/dist/Editor/common/ColorPickerButton.js +35 -9
- package/dist/Editor/common/CustomColorPicker/index.js +106 -0
- package/dist/Editor/common/CustomColorPicker/style.js +53 -0
- package/dist/Editor/common/CustomDialog/index.js +90 -0
- package/dist/Editor/common/CustomDialog/styles.js +80 -0
- package/dist/Editor/common/CustomDialog2/index.js +94 -0
- package/dist/Editor/common/CustomDialog2/style.js +67 -0
- package/dist/Editor/common/CustomSelect.js +33 -0
- package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
- package/dist/Editor/common/DnD/Draggable.js +0 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +3 -0
- package/dist/Editor/common/Icon.js +28 -0
- package/dist/Editor/common/ImageSelector/Styles.js +3 -9
- package/dist/Editor/common/ImageSelector/UploadStyles.js +0 -1
- package/dist/Editor/common/MentionsPopup/Styles.js +6 -12
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +2 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +4 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +3 -2
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +8 -2
- package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +5 -4
- package/dist/Editor/common/RnD/Utils/index.js +45 -0
- package/dist/Editor/common/RnD/index.js +23 -3
- package/dist/Editor/common/Shorthands/elements.js +54 -0
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +12 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +35 -11
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +13 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
- package/dist/Editor/common/Uploader.js +8 -0
- package/dist/Editor/commonStyle.js +114 -69
- package/dist/Editor/helper/index.js +2 -2
- package/dist/Editor/helper/theme.js +200 -2
- package/dist/Editor/hooks/useEditorTheme.js +153 -0
- package/dist/Editor/hooks/useMouseMove.js +9 -3
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +19 -14
- package/dist/Editor/plugins/withLayout.js +1 -1
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/theme/ThemeList.js +50 -173
- package/dist/Editor/theme/index.js +144 -0
- package/dist/Editor/themeSettings/ActiveTheme.js +72 -0
- package/dist/Editor/themeSettings/buttons/index.js +283 -0
- package/dist/Editor/themeSettings/buttons/style.js +21 -0
- package/dist/Editor/themeSettings/colorTheme/index.js +292 -0
- package/dist/Editor/themeSettings/colorTheme/style.js +77 -0
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
- package/dist/Editor/themeSettings/fonts/index.js +220 -0
- package/dist/Editor/themeSettings/fonts/style.js +44 -0
- package/dist/Editor/themeSettings/icons.js +60 -0
- package/dist/Editor/themeSettings/index.js +320 -0
- package/dist/Editor/themeSettings/style.js +152 -0
- package/dist/Editor/themeSettingsAI/icons.js +96 -0
- package/dist/Editor/themeSettingsAI/index.js +356 -0
- package/dist/Editor/themeSettingsAI/saveTheme.js +197 -0
- package/dist/Editor/themeSettingsAI/style.js +250 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +150 -37
- package/dist/Editor/utils/button.js +0 -14
- package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +23 -0
- package/dist/Editor/utils/draftToSlate.js +3 -2
- package/dist/Editor/utils/font.js +40 -37
- package/dist/Editor/utils/helper.js +59 -19
- package/dist/Editor/utils/link.js +1 -1
- package/package.json +5 -2
@@ -0,0 +1,250 @@
|
|
1
|
+
const style = () => ({
|
2
|
+
".fs-12": {
|
3
|
+
fontSize: "12px"
|
4
|
+
},
|
5
|
+
".fs-14": {
|
6
|
+
fontSize: "14px"
|
7
|
+
},
|
8
|
+
".fw-500": {
|
9
|
+
fontWeight: "500"
|
10
|
+
},
|
11
|
+
".fw-600": {
|
12
|
+
fontWeight: "600"
|
13
|
+
},
|
14
|
+
".pointer": {
|
15
|
+
cursor: "pointer"
|
16
|
+
},
|
17
|
+
".transformNone": {
|
18
|
+
textTransform: "none"
|
19
|
+
},
|
20
|
+
".settingsContainer": {
|
21
|
+
width: "340px",
|
22
|
+
padding: "16px 16px",
|
23
|
+
background: "#fff",
|
24
|
+
".header": {
|
25
|
+
borderBottom: `1px solid #DCE4EC`,
|
26
|
+
paddingBottom: "8px"
|
27
|
+
// marginBottom: "16px",
|
28
|
+
}
|
29
|
+
},
|
30
|
+
|
31
|
+
".title": {
|
32
|
+
fontWeight: "700",
|
33
|
+
fontSize: "14px"
|
34
|
+
},
|
35
|
+
".closeBtn": {
|
36
|
+
width: "26px",
|
37
|
+
height: "26px",
|
38
|
+
BorderRadius: "4px",
|
39
|
+
flexShrik: "0",
|
40
|
+
padding: "4px",
|
41
|
+
background: " #F8FAFC",
|
42
|
+
borderRadius: "4px"
|
43
|
+
},
|
44
|
+
".MuiTabs-scroller": {
|
45
|
+
borderBottom: `1px solid #DCE4EC`
|
46
|
+
},
|
47
|
+
".themeCardWrapper": {
|
48
|
+
borderRadius: "4px",
|
49
|
+
".active": {
|
50
|
+
background: "#ECF2FF"
|
51
|
+
}
|
52
|
+
},
|
53
|
+
".primaryCard, .secondaryCard": {
|
54
|
+
width: "44px",
|
55
|
+
height: "44px",
|
56
|
+
borderRadius: "5px",
|
57
|
+
border: `1px solid #929292`
|
58
|
+
},
|
59
|
+
".flexAlign": {
|
60
|
+
display: "flex",
|
61
|
+
alignItems: "center"
|
62
|
+
},
|
63
|
+
".activeColorBox, .xsColorBox": {
|
64
|
+
width: "24px",
|
65
|
+
height: "24px",
|
66
|
+
borderRadius: "5px",
|
67
|
+
border: `1px solid #929292`
|
68
|
+
},
|
69
|
+
".themeCard": {
|
70
|
+
borderRadius: "7px",
|
71
|
+
padding: "16px",
|
72
|
+
border: "1px solid #F3F3F3",
|
73
|
+
boxShadow: "1px 2px 5px 0px #00000014",
|
74
|
+
position: "relative",
|
75
|
+
flexWrap: "nowrap",
|
76
|
+
".tickIcon": {
|
77
|
+
visibility: "hidden",
|
78
|
+
opacity: "0",
|
79
|
+
position: "absolute",
|
80
|
+
right: "-8px",
|
81
|
+
top: "-8px"
|
82
|
+
},
|
83
|
+
"&.selected": {
|
84
|
+
".tickIcon": {
|
85
|
+
visibility: "visible",
|
86
|
+
opacity: "1"
|
87
|
+
}
|
88
|
+
}
|
89
|
+
},
|
90
|
+
".otherColors": {
|
91
|
+
display: "flex",
|
92
|
+
flexWrap: "wrap",
|
93
|
+
width: "48px",
|
94
|
+
".smallCard": {
|
95
|
+
width: "20px",
|
96
|
+
height: "20px",
|
97
|
+
borderRadius: "5px",
|
98
|
+
border: `1px solid #929292`
|
99
|
+
}
|
100
|
+
},
|
101
|
+
".imageUpload": {
|
102
|
+
background: "#F3F3F3",
|
103
|
+
borderRadius: "12px",
|
104
|
+
padding: "10px",
|
105
|
+
height: "208px",
|
106
|
+
position: "relative",
|
107
|
+
"& .resetIcon": {
|
108
|
+
position: "absolute",
|
109
|
+
right: "10px",
|
110
|
+
top: "10px"
|
111
|
+
},
|
112
|
+
".changeImgText": {
|
113
|
+
position: "absolute",
|
114
|
+
left: "50%",
|
115
|
+
top: "50%",
|
116
|
+
transform: "translate(-50%, -50%)",
|
117
|
+
zIndex: 1,
|
118
|
+
background: "#0000004D",
|
119
|
+
color: "#fff",
|
120
|
+
padding: "6px",
|
121
|
+
borderRadius: "6px",
|
122
|
+
fontSize: "12px",
|
123
|
+
fontWeight: 600,
|
124
|
+
opacity: "0",
|
125
|
+
visibility: "hidden"
|
126
|
+
},
|
127
|
+
"&:hover": {
|
128
|
+
".changeImgText": {
|
129
|
+
opacity: "1",
|
130
|
+
visibility: "visible"
|
131
|
+
}
|
132
|
+
}
|
133
|
+
},
|
134
|
+
".imgUploadInner": {
|
135
|
+
background: "#fff",
|
136
|
+
borderRadius: "10px",
|
137
|
+
border: "0.79px dashed #8360FD",
|
138
|
+
height: "100%"
|
139
|
+
},
|
140
|
+
".outlineBtn": {
|
141
|
+
color: "#2563EB",
|
142
|
+
borderRadius: "8px",
|
143
|
+
boxShadow: "0px 4px 10px 0px #00000026",
|
144
|
+
border: "1px solid #2563EB",
|
145
|
+
background: "#EBF1F9",
|
146
|
+
height: "34px",
|
147
|
+
textTransform: "unset"
|
148
|
+
},
|
149
|
+
".seondaryOutlineBtn": {
|
150
|
+
border: "1px solid #D8DDE1",
|
151
|
+
borderRadius: "8px",
|
152
|
+
// boxShadow: "0px 4px 10px 0px #00000026",
|
153
|
+
height: "34px",
|
154
|
+
textTransform: "unset",
|
155
|
+
background: "#eceef3",
|
156
|
+
color: "#64748B"
|
157
|
+
},
|
158
|
+
".blueBtn": {
|
159
|
+
boxShadow: "0px 4px 10px 0px #00000026",
|
160
|
+
background: "#2563EB",
|
161
|
+
borderRadius: "8px",
|
162
|
+
textTransform: "unset",
|
163
|
+
height: "34px",
|
164
|
+
color: "#fff",
|
165
|
+
"&.disabled": {
|
166
|
+
background: "#D9D9DD !important",
|
167
|
+
color: "#fff !important"
|
168
|
+
}
|
169
|
+
},
|
170
|
+
".generatedItem": {
|
171
|
+
border: "1px solid #E4E6E9",
|
172
|
+
borderRadius: "7px",
|
173
|
+
padding: "14px",
|
174
|
+
display: "flex",
|
175
|
+
gap: "16px",
|
176
|
+
position: "relative",
|
177
|
+
justifyContent: "space-between",
|
178
|
+
marginBottom: "12px",
|
179
|
+
".tickIcon": {
|
180
|
+
visibility: "hidden",
|
181
|
+
opacity: "0",
|
182
|
+
position: "absolute",
|
183
|
+
right: "-8px",
|
184
|
+
top: "-8px"
|
185
|
+
},
|
186
|
+
"&.selected": {
|
187
|
+
border: "1px solid #2563EB",
|
188
|
+
boxShadow: " 3px 3px 8px 0px #2563EB40",
|
189
|
+
".tickIcon": {
|
190
|
+
visibility: "visible",
|
191
|
+
opacity: "1"
|
192
|
+
}
|
193
|
+
},
|
194
|
+
".colorBox": {
|
195
|
+
border: "1px solid #929292",
|
196
|
+
height: "28px",
|
197
|
+
width: "28px",
|
198
|
+
borderRadius: "5px"
|
199
|
+
}
|
200
|
+
},
|
201
|
+
".textArea": {
|
202
|
+
background: "#F3F3F3",
|
203
|
+
borderRadius: "12px",
|
204
|
+
padding: "10px",
|
205
|
+
height: "208px",
|
206
|
+
"& textarea": {
|
207
|
+
width: "100%",
|
208
|
+
height: "100% !important",
|
209
|
+
border: "0.79px solid #8360FD",
|
210
|
+
background: "#FFFFFF",
|
211
|
+
borderRadius: "8px",
|
212
|
+
padding: "10px"
|
213
|
+
}
|
214
|
+
},
|
215
|
+
".imageUrl": {
|
216
|
+
height: "auto !important",
|
217
|
+
".MuiOutlinedInput-root": {
|
218
|
+
border: "0.79px solid #8360FD",
|
219
|
+
background: "#FFFFFF",
|
220
|
+
borderRadius: "8px",
|
221
|
+
".tickIcon": {
|
222
|
+
width: "18px"
|
223
|
+
}
|
224
|
+
},
|
225
|
+
"&.invalidUrl": {
|
226
|
+
".MuiInputAdornment-root": {
|
227
|
+
".tickIcon": {
|
228
|
+
".fillPath": {
|
229
|
+
fill: "#D9D9DD!important"
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|
234
|
+
},
|
235
|
+
".saveThemeContainer": {
|
236
|
+
".MuiOutlinedInput-root": {
|
237
|
+
borderRadius: "8px",
|
238
|
+
boxShadow: "0px 4px 16px 0px #0000000D"
|
239
|
+
}
|
240
|
+
},
|
241
|
+
".uploadedImage": {
|
242
|
+
width: "126px",
|
243
|
+
height: "126px",
|
244
|
+
borderRadius: "126px"
|
245
|
+
},
|
246
|
+
".MuiDialog-paper": {
|
247
|
+
borderRadius: "10px"
|
248
|
+
}
|
249
|
+
});
|
250
|
+
export default style;
|
@@ -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, textThemeFields, getElementProperty } from "../helper/theme";
|
38
38
|
import Variables from "../Elements/Variables/Variable";
|
39
|
-
import insertNewLine from "./insertNewLine";
|
40
39
|
import Divider from "../Elements/Divider/Divider";
|
41
40
|
import { getBorderColor, getSlateDom } from "./helper";
|
42
41
|
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
|
-
|
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,7 +55,17 @@ const LIST_FORMAT_TYPE = {
|
|
55
55
|
orderedList: "list-item",
|
56
56
|
unorderedList: "list-item"
|
57
57
|
};
|
58
|
-
|
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"];
|
59
69
|
export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
60
70
|
const isActive = isBlockActive(editor, format);
|
61
71
|
const isList = list_types.includes(format);
|
@@ -88,8 +98,9 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
88
98
|
if (!selection) {
|
89
99
|
Transforms.insertText(editor, "");
|
90
100
|
}
|
101
|
+
const forActiveType = THEME_BLOCK_FIELDS.some(f => f === format) ? format : "paragraph";
|
91
102
|
Transforms.setNodes(editor, {
|
92
|
-
type: isActive ?
|
103
|
+
type: isActive ? forActiveType : isList ? LIST_FORMAT_TYPE[format] : format,
|
93
104
|
...attr
|
94
105
|
});
|
95
106
|
if (isList && !isActive) {
|
@@ -98,10 +109,12 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
98
109
|
children: []
|
99
110
|
});
|
100
111
|
}
|
101
|
-
|
102
|
-
|
103
|
-
|
112
|
+
|
113
|
+
// if (NEWLINESAFTER.indexOf(format) > -1) {
|
114
|
+
// insertNewLine(editor);
|
115
|
+
// }
|
104
116
|
};
|
117
|
+
|
105
118
|
export const addMarkData = (editor, data) => {
|
106
119
|
try {
|
107
120
|
Editor.addMark(editor, data.format, data.value);
|
@@ -110,9 +123,14 @@ export const addMarkData = (editor, data) => {
|
|
110
123
|
}
|
111
124
|
};
|
112
125
|
export const toggleMark = (editor, format) => {
|
113
|
-
const isActive =
|
126
|
+
const isActive = isMarkBtnActive(editor, format);
|
114
127
|
if (isActive) {
|
115
|
-
|
128
|
+
const isThemeSupportedMark = textThemeFields.some(f => f === format);
|
129
|
+
if (isThemeSupportedMark) {
|
130
|
+
Editor.addMark(editor, format, false);
|
131
|
+
} else {
|
132
|
+
Editor.removeMark(editor, format);
|
133
|
+
}
|
116
134
|
} else {
|
117
135
|
Editor.addMark(editor, format, true);
|
118
136
|
}
|
@@ -126,6 +144,52 @@ export const isMarkActive = (editor, format) => {
|
|
126
144
|
return null;
|
127
145
|
}
|
128
146
|
};
|
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
|
+
};
|
129
193
|
export const isBlockActive = (editor, format) => {
|
130
194
|
const [match] = Editor.nodes(editor, {
|
131
195
|
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
|
@@ -178,6 +242,31 @@ export const activeMark = (editor, format) => {
|
|
178
242
|
return null;
|
179
243
|
}
|
180
244
|
};
|
245
|
+
|
246
|
+
// to avoid the styles, that automatically assign from themes
|
247
|
+
const getThemeMarkedLeaf = (leaf, children) => {
|
248
|
+
const {
|
249
|
+
italic,
|
250
|
+
bold
|
251
|
+
} = leaf || {};
|
252
|
+
const style = {};
|
253
|
+
if (italic === false) {
|
254
|
+
style.fontStyle = "normal";
|
255
|
+
}
|
256
|
+
if (bold === false) {
|
257
|
+
style.fontWeight = "normal";
|
258
|
+
}
|
259
|
+
if (Object.keys(style).length) {
|
260
|
+
children = /*#__PURE__*/_jsx(Box, {
|
261
|
+
component: "span",
|
262
|
+
sx: {
|
263
|
+
"& span": style
|
264
|
+
},
|
265
|
+
children: children
|
266
|
+
});
|
267
|
+
}
|
268
|
+
return children;
|
269
|
+
};
|
181
270
|
export const getMarked = (leaf, children, theme) => {
|
182
271
|
const className = leaf?.doublequote ? "doublequote" : "";
|
183
272
|
if (leaf.highlight) {
|
@@ -204,6 +293,7 @@ export const getMarked = (leaf, children, theme) => {
|
|
204
293
|
children: children
|
205
294
|
});
|
206
295
|
}
|
296
|
+
children = getThemeMarkedLeaf(leaf, children);
|
207
297
|
if (leaf.strikethrough) {
|
208
298
|
children = /*#__PURE__*/_jsx("span", {
|
209
299
|
style: {
|
@@ -231,20 +321,27 @@ export const getMarked = (leaf, children, theme) => {
|
|
231
321
|
if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || className) {
|
232
322
|
const family = leaf?.fontFamily;
|
233
323
|
const textStyles = getTextColor(leaf?.color);
|
324
|
+
const fontSize = {
|
325
|
+
lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
326
|
+
...getBreakPointsValue(leaf.fontSize, null, "overrideText")
|
327
|
+
};
|
328
|
+
const fontSizesImportant = {};
|
329
|
+
Object.entries(fontSize).forEach(([key, value]) => {
|
330
|
+
fontSizesImportant[key] = `${value} !important`;
|
331
|
+
});
|
332
|
+
const fontSizeWithBreakpoints = wrapThemeBreakpoints(fontSizesImportant, "fontSize", theme);
|
234
333
|
children = /*#__PURE__*/_jsx("span", {
|
235
|
-
style: {
|
236
|
-
background: leaf.bgColor
|
237
|
-
},
|
238
334
|
children: /*#__PURE__*/_jsx(Box, {
|
239
335
|
className: className,
|
240
336
|
component: "span",
|
241
337
|
sx: {
|
242
|
-
|
243
|
-
fontSize:
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
},
|
338
|
+
"& span": {
|
339
|
+
// fontSize: fontSizesImportant,
|
340
|
+
// ...groupByBreakpoint(fontSizesImportant, theme),
|
341
|
+
background: leaf.bgColor,
|
342
|
+
...fontSizeWithBreakpoints
|
343
|
+
},
|
344
|
+
...fontSizeWithBreakpoints,
|
248
345
|
// ...wrapThemeBreakpoints(
|
249
346
|
// {
|
250
347
|
// lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
@@ -286,55 +383,71 @@ export const getBlock = props => {
|
|
286
383
|
} = props;
|
287
384
|
const attributes = props.attributes ?? {};
|
288
385
|
const isEmpty = isEmptyTextNode(element);
|
386
|
+
const commonHeadingProps = () => ({
|
387
|
+
...attributes,
|
388
|
+
...element.attr,
|
389
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} theme-element`
|
390
|
+
});
|
391
|
+
const commonParaProps = paraType => ({
|
392
|
+
...attributes,
|
393
|
+
...element.attr,
|
394
|
+
className: `content-editable ${isEmpty ? "empty" : ""} theme-element ${paraType}`
|
395
|
+
});
|
289
396
|
switch (element.type) {
|
290
397
|
case "headingOne":
|
291
398
|
return /*#__PURE__*/_jsx("h1", {
|
292
|
-
...
|
293
|
-
...element.attr,
|
294
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
399
|
+
...commonHeadingProps(),
|
295
400
|
placeholder: "Heading 1",
|
296
401
|
children: children
|
297
402
|
});
|
298
403
|
case "headingTwo":
|
299
404
|
return /*#__PURE__*/_jsx("h2", {
|
300
|
-
...
|
301
|
-
...element.attr,
|
302
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
405
|
+
...commonHeadingProps(),
|
303
406
|
placeholder: "Heading 2",
|
304
407
|
children: children
|
305
408
|
});
|
306
409
|
case "headingThree":
|
307
410
|
return /*#__PURE__*/_jsx("h3", {
|
308
|
-
...
|
309
|
-
...element.attr,
|
310
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
411
|
+
...commonHeadingProps(),
|
311
412
|
placeholder: "Heading 3",
|
312
413
|
children: children
|
313
414
|
});
|
314
415
|
case "headingFour":
|
315
416
|
return /*#__PURE__*/_jsx("h4", {
|
316
|
-
...
|
317
|
-
...element.attr,
|
318
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
417
|
+
...commonHeadingProps(),
|
319
418
|
placeholder: "Heading 4",
|
320
419
|
children: children
|
321
420
|
});
|
322
421
|
case "headingFive":
|
323
422
|
return /*#__PURE__*/_jsx("h5", {
|
324
|
-
...
|
325
|
-
...element.attr,
|
326
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
423
|
+
...commonHeadingProps(),
|
327
424
|
placeholder: "Heading 5",
|
328
425
|
children: children
|
329
426
|
});
|
330
427
|
case "headingSix":
|
331
428
|
return /*#__PURE__*/_jsx("h6", {
|
332
|
-
...
|
333
|
-
...element.attr,
|
334
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
429
|
+
...commonHeadingProps(),
|
335
430
|
placeholder: "Heading 6",
|
336
431
|
children: children
|
337
432
|
});
|
433
|
+
case "paragraphOne":
|
434
|
+
return /*#__PURE__*/_jsx("p", {
|
435
|
+
...commonParaProps("para1"),
|
436
|
+
placeholder: "Paragraph 1",
|
437
|
+
children: children
|
438
|
+
});
|
439
|
+
case "paragraphTwo":
|
440
|
+
return /*#__PURE__*/_jsx("p", {
|
441
|
+
...commonParaProps("para2"),
|
442
|
+
placeholder: "Paragraph 2",
|
443
|
+
children: children
|
444
|
+
});
|
445
|
+
case "paragraphThree":
|
446
|
+
return /*#__PURE__*/_jsx("p", {
|
447
|
+
...commonParaProps("para3"),
|
448
|
+
placeholder: "Paragraph 3",
|
449
|
+
children: children
|
450
|
+
});
|
338
451
|
case "blockquote":
|
339
452
|
return /*#__PURE__*/_jsx("blockquote", {
|
340
453
|
...attributes,
|
@@ -11,20 +11,6 @@ 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
|
-
},
|
28
14
|
...(windowVar.lastButtonProps || {})
|
29
15
|
};
|
30
16
|
Transforms.insertNodes(editor, button);
|
@@ -8,6 +8,9 @@ import { isEmptyTextNode } from "../../helper";
|
|
8
8
|
import { getBreakPointsValue } from "../../helper/theme";
|
9
9
|
import insertNewLine from "../insertNewLine";
|
10
10
|
import { getBorderColor } from "../helper";
|
11
|
+
import Table from "../../Elements/Table/Table";
|
12
|
+
import TableRow from "../../Elements/Table/TableRow";
|
13
|
+
import TableCell from "../../Elements/Table/TableCell";
|
11
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
12
15
|
const alignment = ["alignLeft", "alignRight", "alignCenter"];
|
13
16
|
const list_types = ["orderedList", "unorderedList"];
|
@@ -406,6 +409,26 @@ export const getBlock = props => {
|
|
406
409
|
return /*#__PURE__*/_jsx(Mentions, {
|
407
410
|
...props
|
408
411
|
});
|
412
|
+
case "table":
|
413
|
+
return /*#__PURE__*/_jsx(Table, {
|
414
|
+
...props
|
415
|
+
});
|
416
|
+
case "table-head":
|
417
|
+
return /*#__PURE__*/_jsx("thead", {
|
418
|
+
children: children
|
419
|
+
});
|
420
|
+
case "table-body":
|
421
|
+
return /*#__PURE__*/_jsx("tbody", {
|
422
|
+
children: children
|
423
|
+
});
|
424
|
+
case "table-row":
|
425
|
+
return /*#__PURE__*/_jsx(TableRow, {
|
426
|
+
...props
|
427
|
+
});
|
428
|
+
case "table-cell":
|
429
|
+
return /*#__PURE__*/_jsx(TableCell, {
|
430
|
+
...props
|
431
|
+
});
|
409
432
|
default:
|
410
433
|
return /*#__PURE__*/_jsx(SimpleText, {
|
411
434
|
...props,
|
@@ -82,7 +82,8 @@ const splitInlineStyleRanges = (text, inlineStyleRanges, data) => {
|
|
82
82
|
};
|
83
83
|
export const draftToSlate = props => {
|
84
84
|
const {
|
85
|
-
data
|
85
|
+
data,
|
86
|
+
needLayout
|
86
87
|
} = props;
|
87
88
|
if (data?.blocks && data?.blocks?.length > 0) {
|
88
89
|
const converted = data?.blocks?.reduce((a, b) => {
|
@@ -104,7 +105,7 @@ export const draftToSlate = props => {
|
|
104
105
|
return data;
|
105
106
|
} else {
|
106
107
|
return [{
|
107
|
-
type: "paragraph",
|
108
|
+
type: needLayout ? "title" : "paragraph",
|
108
109
|
children: [{
|
109
110
|
text: ""
|
110
111
|
}]
|