@flozy/editor 11.0.9 → 11.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 +16 -17
- package/dist/Editor/CommonEditor.js +28 -141
- package/dist/Editor/DialogWrapper.js +25 -31
- package/dist/Editor/Editor.css +11 -39
- package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
- package/dist/Editor/Elements/AI/Styles.js +0 -1
- package/dist/Editor/Elements/Accordion/Accordion.js +22 -28
- package/dist/Editor/Elements/Accordion/AccordionButton.js +3 -12
- package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
- package/dist/Editor/Elements/Attachments/Attachments.js +11 -153
- package/dist/Editor/Elements/Attachments/AttachmentsButton.js +3 -8
- package/dist/Editor/Elements/Button/EditorButton.js +7 -23
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
- package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +454 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +55 -134
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SelectV1.js +8 -7
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +3 -8
- package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +1 -1
- package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +1 -1
- package/dist/Editor/Elements/Embed/Embed.css +0 -5
- package/dist/Editor/Elements/Embed/Embed.js +43 -36
- package/dist/Editor/Elements/Embed/Image.js +23 -242
- package/dist/Editor/Elements/Embed/Video.js +32 -277
- package/dist/Editor/Elements/Form/FormField.js +1 -1
- package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
- package/dist/Editor/Elements/Form/Workflow/constant.js +1 -25
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +74 -31
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +5 -9
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -3
- package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
- package/dist/Editor/Elements/FreeGrid/styles.js +0 -15
- package/dist/Editor/Elements/Grid/GridItem.js +1 -1
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +1 -2
- package/dist/Editor/Elements/Signature/SignaturePopup.js +6 -13
- package/dist/Editor/Elements/SimpleText/index.js +1 -4
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/Table.js +4 -5
- package/dist/Editor/Elements/Table/TableCell.js +3 -10
- package/dist/Editor/Elements/Title/title.js +11 -10
- package/dist/Editor/Elements/TopBanner/TopBanner.js +2 -4
- package/dist/Editor/Elements/TopBanner/TopBannerButton.js +3 -5
- package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
- package/dist/Editor/MiniEditor.js +1 -2
- package/dist/Editor/Styles/EditorStyles.js +5 -20
- 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 +29 -33
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +23 -25
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +7 -25
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +8 -24
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +10 -70
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +14 -73
- package/dist/Editor/Toolbar/PopupTool/index.js +4 -7
- package/dist/Editor/Toolbar/toolbarGroups.js +10 -56
- package/dist/Editor/common/ColorPickerButton.js +16 -38
- package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +0 -4
- package/dist/Editor/common/Icon.js +0 -28
- package/dist/Editor/common/ImageSelector/ImageSelector.js +7 -45
- package/dist/Editor/common/ImageSelector/Options/Upload.js +11 -26
- package/dist/Editor/common/ImageSelector/Styles.js +9 -3
- package/dist/Editor/common/LinkSettings/NavComponents.js +2 -6
- package/dist/Editor/common/MentionsPopup/index.js +1 -9
- 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 +7 -20
- package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -9
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +7 -20
- package/dist/Editor/common/RnD/GuideLines/styles.js +1 -1
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +11 -28
- package/dist/Editor/common/RnD/Utils/index.js +1 -3
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +63 -52
- package/dist/Editor/common/RnD/VirtualElement/helper.js +130 -320
- package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -22
- package/dist/Editor/common/RnD/index.js +14 -61
- package/dist/Editor/common/Shorthands/elements.js +4 -62
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
- package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
- package/dist/Editor/common/StyleBuilder/fieldStyle.js +0 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +2 -15
- 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 +8 -16
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +0 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
- package/dist/Editor/common/StyleBuilder/formStyle.js +13 -19
- package/dist/Editor/common/StyleBuilder/index.js +4 -8
- package/dist/Editor/common/Uploader.js +17 -125
- package/dist/Editor/common/iconslist.js +0 -21
- package/dist/Editor/commonStyle.js +18 -67
- package/dist/Editor/helper/index.js +2 -10
- package/dist/Editor/helper/theme.js +2 -203
- package/dist/Editor/hooks/useMouseMove.js +3 -9
- package/dist/Editor/hooks/useTable.js +1 -62
- package/dist/Editor/plugins/withEmbeds.js +1 -12
- package/dist/Editor/plugins/withHTML.js +3 -58
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/service/fileupload.js +0 -70
- package/dist/Editor/theme/ThemeList.js +173 -50
- package/dist/Editor/utils/SlateUtilityFunctions.js +40 -191
- package/dist/Editor/utils/accordion.js +39 -67
- package/dist/Editor/utils/button.js +17 -1
- package/dist/Editor/utils/draftToSlate.js +2 -3
- package/dist/Editor/utils/events.js +89 -94
- package/dist/Editor/utils/font.js +37 -40
- package/dist/Editor/utils/helper.js +23 -100
- package/dist/Editor/utils/insertAppHeader.js +4 -8
- package/package.json +4 -4
- package/dist/Editor/Elements/Attachments/AttachmentStyles.js +0 -16
- package/dist/Editor/Elements/FreeGrid/helper.js +0 -194
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
- package/dist/Editor/assets/svg/BackIcon.js +0 -18
- package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
- package/dist/Editor/common/CustomColorPicker/index.js +0 -130
- package/dist/Editor/common/CustomColorPicker/style.js +0 -53
- package/dist/Editor/common/CustomDialog2/index.js +0 -94
- package/dist/Editor/common/CustomDialog2/style.js +0 -67
- package/dist/Editor/common/CustomSelect.js +0 -43
- package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
- package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
- package/dist/Editor/common/UploaderWithProgress.js +0 -183
- package/dist/Editor/helper/textIndeces.js +0 -58
- package/dist/Editor/hooks/useEditorTheme.js +0 -153
- package/dist/Editor/hooks/useThemeValues.js +0 -63
- package/dist/Editor/theme/index.js +0 -149
- package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
- package/dist/Editor/themeSettings/buttons/index.js +0 -300
- package/dist/Editor/themeSettings/buttons/style.js +0 -23
- package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
- package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
- package/dist/Editor/themeSettings/fonts/index.js +0 -240
- package/dist/Editor/themeSettings/fonts/style.js +0 -62
- package/dist/Editor/themeSettings/icons.js +0 -60
- package/dist/Editor/themeSettings/index.js +0 -380
- package/dist/Editor/themeSettings/style.js +0 -299
- package/dist/Editor/themeSettingsAI/icons.js +0 -96
- package/dist/Editor/themeSettingsAI/index.js +0 -355
- package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
- package/dist/Editor/themeSettingsAI/style.js +0 -332
@@ -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;
|
@@ -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 { getBreakpointLineSpacing, getBreakPointsValue, getDevice,
|
37
|
+
import { getBreakpointLineSpacing, getBreakPointsValue, getDevice, 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, getSlateDom } 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,27 +47,17 @@ 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"];
|
54
54
|
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", "headingFour", "headingFive", "headingSix"];
|
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);
|
72
62
|
const isIndent = alignment.includes(format);
|
73
63
|
const isAligned = alignment.some(alignmentType => isBlockActive(editor, alignmentType));
|
@@ -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,91 +126,12 @@ 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, format) => {
|
174
|
-
try {
|
175
|
-
if (!editor.selection) {
|
176
|
-
return "";
|
177
|
-
}
|
178
|
-
if (Range.isCollapsed(editor.selection)) {
|
179
|
-
return "";
|
180
|
-
}
|
181
|
-
if (format) {
|
182
|
-
const value = activeMark(editor, format, true);
|
183
|
-
if (value) {
|
184
|
-
return value;
|
185
|
-
}
|
186
|
-
}
|
187
|
-
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
188
|
-
const selectedDomNode = domRange.commonAncestorContainer;
|
189
|
-
|
190
|
-
// If it's a text node, get its parent element
|
191
|
-
const selectedElement = selectedDomNode.nodeType === 3 ? selectedDomNode.parentElement : selectedDomNode;
|
192
|
-
if (selectedElement) {
|
193
|
-
return getElementProperty(selectedElement, styleProperty);
|
194
|
-
}
|
195
|
-
} catch (err) {
|
196
|
-
console.log(err);
|
197
|
-
}
|
198
|
-
};
|
199
129
|
export const isBlockActive = (editor, format) => {
|
200
130
|
const [match] = Editor.nodes(editor, {
|
201
131
|
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
|
202
132
|
});
|
203
133
|
return !!match;
|
204
134
|
};
|
205
|
-
export const isListActive = editor => {
|
206
|
-
const list_types = ["orderedList", "unorderedList", "check-list-item", "accordion"];
|
207
|
-
const [match] = Editor.nodes(editor, {
|
208
|
-
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && list_types.includes(n.type),
|
209
|
-
mode: "lowest" // To ensure it's the closest parent
|
210
|
-
});
|
211
|
-
|
212
|
-
if (match) {
|
213
|
-
const [matchNode] = match;
|
214
|
-
return matchNode.type;
|
215
|
-
}
|
216
|
-
};
|
217
|
-
export const getListType = editor => {
|
218
|
-
const [accordionSummary] = Editor.nodes(editor, {
|
219
|
-
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === "accordion-summary"
|
220
|
-
});
|
221
|
-
if (accordionSummary) {
|
222
|
-
return "accordion-summary";
|
223
|
-
}
|
224
|
-
const listItems = ["list-item", "check-list-item"];
|
225
|
-
const [listItem] = Editor.nodes(editor, {
|
226
|
-
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && listItems.includes(n.type)
|
227
|
-
});
|
228
|
-
if (listItem) {
|
229
|
-
return "list-item";
|
230
|
-
}
|
231
|
-
};
|
232
135
|
export const getBlockActive = (editor, format) => {
|
233
136
|
const [match] = Editor.nodes(editor, {
|
234
137
|
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
|
@@ -248,7 +151,7 @@ export const upateBlockActive = (editor, format, attr = {}) => {
|
|
248
151
|
});
|
249
152
|
}
|
250
153
|
};
|
251
|
-
export const activeMark = (editor, format
|
154
|
+
export const activeMark = (editor, format) => {
|
252
155
|
const defaultMarkData = {
|
253
156
|
color: "#000000",
|
254
157
|
bgColor: "#FFFFFF",
|
@@ -258,7 +161,7 @@ export const activeMark = (editor, format, noDefaultValue) => {
|
|
258
161
|
};
|
259
162
|
try {
|
260
163
|
const marks = Editor.marks(editor);
|
261
|
-
let defaultValue =
|
164
|
+
let defaultValue = defaultMarkData[format];
|
262
165
|
const {
|
263
166
|
selection
|
264
167
|
} = editor || {};
|
@@ -275,31 +178,6 @@ export const activeMark = (editor, format, noDefaultValue) => {
|
|
275
178
|
return null;
|
276
179
|
}
|
277
180
|
};
|
278
|
-
|
279
|
-
// to avoid the styles, that automatically assign from themes
|
280
|
-
const getThemeMarkedLeaf = (leaf, children) => {
|
281
|
-
const {
|
282
|
-
italic,
|
283
|
-
bold
|
284
|
-
} = leaf || {};
|
285
|
-
const style = {};
|
286
|
-
if (italic === false) {
|
287
|
-
style.fontStyle = "normal";
|
288
|
-
}
|
289
|
-
if (bold === false) {
|
290
|
-
style.fontWeight = "normal";
|
291
|
-
}
|
292
|
-
if (Object.keys(style).length) {
|
293
|
-
children = /*#__PURE__*/_jsx(Box, {
|
294
|
-
component: "span",
|
295
|
-
sx: {
|
296
|
-
"& span": style
|
297
|
-
},
|
298
|
-
children: children
|
299
|
-
});
|
300
|
-
}
|
301
|
-
return children;
|
302
|
-
};
|
303
181
|
export const getMarked = (leaf, children, theme) => {
|
304
182
|
const className = leaf?.doublequote ? "doublequote" : "";
|
305
183
|
const lineH = leaf?.lineHeight;
|
@@ -329,7 +207,6 @@ export const getMarked = (leaf, children, theme) => {
|
|
329
207
|
children: children
|
330
208
|
});
|
331
209
|
}
|
332
|
-
children = getThemeMarkedLeaf(leaf, children);
|
333
210
|
if (leaf.strikethrough) {
|
334
211
|
children = /*#__PURE__*/_jsx("span", {
|
335
212
|
style: {
|
@@ -357,15 +234,6 @@ export const getMarked = (leaf, children, theme) => {
|
|
357
234
|
if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || lineHeight || className) {
|
358
235
|
const family = leaf?.fontFamily;
|
359
236
|
const textStyles = getTextColor(leaf?.color);
|
360
|
-
const fontSize = {
|
361
|
-
lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
362
|
-
...getBreakPointsValue(leaf.fontSize, null, "overrideText")
|
363
|
-
};
|
364
|
-
const fontSizesImportant = {};
|
365
|
-
Object.entries(fontSize).forEach(([key, value]) => {
|
366
|
-
fontSizesImportant[key] = `${value} !important`;
|
367
|
-
});
|
368
|
-
const fontSizeWithBreakpoints = wrapThemeBreakpoints(fontSizesImportant, "fontSize", theme);
|
369
237
|
children = /*#__PURE__*/_jsx("span", {
|
370
238
|
style: {
|
371
239
|
background: leaf.bgColor
|
@@ -374,13 +242,12 @@ export const getMarked = (leaf, children, theme) => {
|
|
374
242
|
className: `${className} leaf-item`,
|
375
243
|
component: "span",
|
376
244
|
sx: {
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
},
|
383
|
-
...fontSizeWithBreakpoints,
|
245
|
+
...groupByBreakpoint({
|
246
|
+
fontSize: {
|
247
|
+
lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
248
|
+
...getBreakPointsValue(leaf.fontSize, null, "overrideText")
|
249
|
+
}
|
250
|
+
}, theme),
|
384
251
|
// ...wrapThemeBreakpoints(
|
385
252
|
// {
|
386
253
|
// lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
@@ -401,8 +268,7 @@ export const getMarked = (leaf, children, theme) => {
|
|
401
268
|
WebkitTextFillColor: "unset !important"
|
402
269
|
},
|
403
270
|
style: {
|
404
|
-
"--fontSize_xs": leaf?.fontSize?.xs || "auto"
|
405
|
-
"--fontSize_lg": leaf?.fontSize?.lg || "auto"
|
271
|
+
"--fontSize_xs": leaf?.fontSize?.xs || "auto"
|
406
272
|
},
|
407
273
|
children: children
|
408
274
|
})
|
@@ -433,74 +299,58 @@ export const getBlock = props => {
|
|
433
299
|
const {
|
434
300
|
translation
|
435
301
|
} = customProps;
|
436
|
-
const commonHeadingProps = () => ({
|
437
|
-
...attributes,
|
438
|
-
...element.attr,
|
439
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} theme-element disablePointerEvent`
|
440
|
-
});
|
441
|
-
const commonParaProps = paraType => ({
|
442
|
-
...attributes,
|
443
|
-
...element.attr,
|
444
|
-
className: `edt-paragraphs content-editable ${isEmpty ? "empty" : ""} theme-element disablePointerEvent ${paraType}`
|
445
|
-
});
|
446
302
|
const breakpoint = getDevice(window.innerWidth);
|
447
303
|
const lineH = element?.children[0]?.lineHeight;
|
448
304
|
const selectedLineHeight = getBreakpointLineSpacing(lineH, breakpoint);
|
449
305
|
switch (element.type) {
|
450
306
|
case "headingOne":
|
451
307
|
return /*#__PURE__*/_jsx("h1", {
|
452
|
-
...
|
308
|
+
...attributes,
|
309
|
+
...element.attr,
|
310
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
453
311
|
placeholder: translation("Heading 1"),
|
454
312
|
children: children
|
455
313
|
});
|
456
314
|
case "headingTwo":
|
457
315
|
return /*#__PURE__*/_jsx("h2", {
|
458
|
-
...
|
316
|
+
...attributes,
|
317
|
+
...element.attr,
|
318
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
459
319
|
placeholder: translation("Heading 2"),
|
460
320
|
children: children
|
461
321
|
});
|
462
322
|
case "headingThree":
|
463
323
|
return /*#__PURE__*/_jsx("h3", {
|
464
|
-
...
|
324
|
+
...attributes,
|
325
|
+
...element.attr,
|
326
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
465
327
|
placeholder: translation("Heading 3"),
|
466
328
|
children: children
|
467
329
|
});
|
468
330
|
case "headingFour":
|
469
331
|
return /*#__PURE__*/_jsx("h4", {
|
470
|
-
...
|
332
|
+
...attributes,
|
333
|
+
...element.attr,
|
334
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
471
335
|
placeholder: translation("Heading 4"),
|
472
336
|
children: children
|
473
337
|
});
|
474
338
|
case "headingFive":
|
475
339
|
return /*#__PURE__*/_jsx("h5", {
|
476
|
-
...
|
340
|
+
...attributes,
|
341
|
+
...element.attr,
|
342
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
477
343
|
placeholder: translation("Heading 5"),
|
478
344
|
children: children
|
479
345
|
});
|
480
346
|
case "headingSix":
|
481
347
|
return /*#__PURE__*/_jsx("h6", {
|
482
|
-
...
|
348
|
+
...attributes,
|
349
|
+
...element.attr,
|
350
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
483
351
|
placeholder: translation("Heading 6"),
|
484
352
|
children: children
|
485
353
|
});
|
486
|
-
case "paragraphOne":
|
487
|
-
return /*#__PURE__*/_jsx("p", {
|
488
|
-
...commonParaProps("para1"),
|
489
|
-
placeholder: "Paragraph 1",
|
490
|
-
children: children
|
491
|
-
});
|
492
|
-
case "paragraphTwo":
|
493
|
-
return /*#__PURE__*/_jsx("p", {
|
494
|
-
...commonParaProps("para2"),
|
495
|
-
placeholder: "Paragraph 2",
|
496
|
-
children: children
|
497
|
-
});
|
498
|
-
case "paragraphThree":
|
499
|
-
return /*#__PURE__*/_jsx("p", {
|
500
|
-
...commonParaProps("para3"),
|
501
|
-
placeholder: "Paragraph 3",
|
502
|
-
children: children
|
503
|
-
});
|
504
354
|
case "blockquote":
|
505
355
|
return /*#__PURE__*/_jsx("blockquote", {
|
506
356
|
...attributes,
|
@@ -735,8 +585,7 @@ export const getBlock = props => {
|
|
735
585
|
case "docs":
|
736
586
|
case "pdf":
|
737
587
|
case "xls":
|
738
|
-
case "
|
739
|
-
case "ppt":
|
588
|
+
case "csv":
|
740
589
|
return /*#__PURE__*/_jsx(Attachments, {
|
741
590
|
...props
|
742
591
|
});
|