@flozy/editor 11.1.0 → 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.
Files changed (140) hide show
  1. package/dist/Editor/ChatEditor.js +6 -6
  2. package/dist/Editor/CommonEditor.js +21 -82
  3. package/dist/Editor/DialogWrapper.js +25 -31
  4. package/dist/Editor/Editor.css +4 -37
  5. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  6. package/dist/Editor/Elements/Attachments/Attachments.js +11 -153
  7. package/dist/Editor/Elements/Attachments/AttachmentsButton.js +3 -8
  8. package/dist/Editor/Elements/Button/EditorButton.js +7 -22
  9. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
  10. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  11. package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
  12. package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
  13. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +55 -134
  14. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SelectV1.js +8 -7
  15. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +3 -8
  16. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +1 -1
  17. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +1 -1
  18. package/dist/Editor/Elements/Embed/Embed.css +0 -5
  19. package/dist/Editor/Elements/Embed/Embed.js +43 -37
  20. package/dist/Editor/Elements/Embed/Image.js +22 -242
  21. package/dist/Editor/Elements/Embed/Video.js +32 -277
  22. package/dist/Editor/Elements/Form/Form.js +35 -10
  23. package/dist/Editor/Elements/Form/FormField.js +1 -1
  24. package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
  25. package/dist/Editor/Elements/Form/Workflow/constant.js +1 -25
  26. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +75 -34
  27. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +5 -9
  28. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -3
  29. package/dist/Editor/Elements/FreeGrid/styles.js +0 -15
  30. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  31. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +1 -2
  32. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +3 -2
  33. package/dist/Editor/Elements/Signature/SignaturePopup.js +13 -2
  34. package/dist/Editor/Elements/SimpleText/index.js +1 -4
  35. package/dist/Editor/Elements/Table/Table.js +1 -2
  36. package/dist/Editor/Elements/Table/TableCell.js +3 -10
  37. package/dist/Editor/Elements/Title/title.js +5 -4
  38. package/dist/Editor/Elements/TopBanner/TopBanner.js +2 -4
  39. package/dist/Editor/Elements/TopBanner/TopBannerButton.js +3 -5
  40. package/dist/Editor/Styles/EditorStyles.js +5 -16
  41. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  42. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  43. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  44. package/dist/Editor/Toolbar/FormatTools/TextSize.js +29 -33
  45. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  46. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +1 -3
  47. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +23 -25
  48. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
  49. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +5 -15
  50. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
  51. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +7 -65
  52. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +12 -66
  53. package/dist/Editor/Toolbar/PopupTool/index.js +4 -6
  54. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  55. package/dist/Editor/common/ColorPickerButton.js +19 -38
  56. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  57. package/dist/Editor/common/FontLoader/FontLoader.js +0 -1
  58. package/dist/Editor/common/Icon.js +0 -28
  59. package/dist/Editor/common/ImageSelector/ImageSelector.js +7 -45
  60. package/dist/Editor/common/ImageSelector/Options/Upload.js +11 -26
  61. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  62. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
  63. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  64. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  65. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  66. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  67. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -3
  68. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +7 -20
  69. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  70. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +0 -2
  71. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +7 -20
  72. package/dist/Editor/common/RnD/GuideLines/styles.js +1 -1
  73. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
  74. package/dist/Editor/common/RnD/Utils/gridDropItem.js +11 -28
  75. package/dist/Editor/common/RnD/Utils/index.js +1 -3
  76. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +63 -52
  77. package/dist/Editor/common/RnD/VirtualElement/helper.js +68 -248
  78. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -22
  79. package/dist/Editor/common/RnD/index.js +14 -61
  80. package/dist/Editor/common/Shorthands/elements.js +0 -54
  81. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  82. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
  83. package/dist/Editor/common/StyleBuilder/fieldStyle.js +0 -1
  84. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +2 -10
  85. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  86. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  87. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
  88. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +4 -13
  89. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +0 -2
  90. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  91. package/dist/Editor/common/StyleBuilder/formStyle.js +13 -19
  92. package/dist/Editor/common/StyleBuilder/index.js +4 -8
  93. package/dist/Editor/common/Uploader.js +17 -118
  94. package/dist/Editor/common/iconslist.js +0 -21
  95. package/dist/Editor/commonStyle.js +3 -37
  96. package/dist/Editor/helper/index.js +1 -4
  97. package/dist/Editor/helper/theme.js +2 -203
  98. package/dist/Editor/hooks/useMouseMove.js +3 -12
  99. package/dist/Editor/hooks/useTable.js +1 -62
  100. package/dist/Editor/plugins/withEmbeds.js +1 -1
  101. package/dist/Editor/plugins/withHTML.js +3 -56
  102. package/dist/Editor/plugins/withTable.js +1 -1
  103. package/dist/Editor/service/fileupload.js +0 -70
  104. package/dist/Editor/theme/ThemeList.js +173 -50
  105. package/dist/Editor/utils/SlateUtilityFunctions.js +38 -162
  106. package/dist/Editor/utils/button.js +17 -1
  107. package/dist/Editor/utils/font.js +37 -40
  108. package/dist/Editor/utils/helper.js +3 -76
  109. package/dist/Editor/utils/insertAppHeader.js +4 -8
  110. package/package.json +1 -1
  111. package/dist/Editor/Elements/Attachments/AttachmentStyles.js +0 -16
  112. package/dist/Editor/Elements/FreeGrid/helper.js +0 -194
  113. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
  114. package/dist/Editor/assets/svg/BackIcon.js +0 -18
  115. package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
  116. package/dist/Editor/common/CustomColorPicker/index.js +0 -130
  117. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  118. package/dist/Editor/common/CustomDialog2/index.js +0 -94
  119. package/dist/Editor/common/CustomDialog2/style.js +0 -67
  120. package/dist/Editor/common/CustomSelect.js +0 -43
  121. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  122. package/dist/Editor/common/UploaderWithProgress.js +0 -183
  123. package/dist/Editor/hooks/useEditorTheme.js +0 -153
  124. package/dist/Editor/hooks/useThemeValues.js +0 -63
  125. package/dist/Editor/theme/index.js +0 -149
  126. package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
  127. package/dist/Editor/themeSettings/buttons/index.js +0 -300
  128. package/dist/Editor/themeSettings/buttons/style.js +0 -23
  129. package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
  130. package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
  131. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
  132. package/dist/Editor/themeSettings/fonts/index.js +0 -240
  133. package/dist/Editor/themeSettings/fonts/style.js +0 -62
  134. package/dist/Editor/themeSettings/icons.js +0 -60
  135. package/dist/Editor/themeSettings/index.js +0 -380
  136. package/dist/Editor/themeSettings/style.js +0 -299
  137. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  138. package/dist/Editor/themeSettingsAI/index.js +0 -355
  139. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
  140. package/dist/Editor/themeSettingsAI/style.js +0 -332
@@ -1,58 +1,181 @@
1
- import { Box, MenuItem, Select } from "@mui/material";
2
- import { defaultTheme } from ".";
3
- import { useEditorTheme } from "../hooks/useEditorTheme";
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
- function ThemeList({
8
- editor,
9
- services = () => {}
10
- }) {
11
- const [themes, setThemes] = useState([]);
12
- const [loading, setLoading] = useState(false);
13
- console.log("loading", loading);
14
- const getThemesList = async () => {
15
- setLoading(true);
16
- try {
17
- const result = await services("getThemes", {});
18
- setThemes(result?.data || []);
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
- updateTheme
26
- } = useEditorTheme();
27
- useEffect(() => {
28
- getThemesList();
29
- }, []);
30
- const handleThemeChange = e => {
31
- const {
32
- value
33
- } = e.target;
34
- const selectedTheme = themes.find(t => t.id === value) || defaultTheme();
35
- updateTheme(selectedTheme, "THEME_CHANGE");
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__*/_jsx(Box, {
38
- sx: {
39
- padding: "10px",
40
- background: "#efefef",
41
- borderRadius: "6px"
42
- },
43
- children: /*#__PURE__*/_jsxs(Select, {
44
- onChange: handleThemeChange,
45
- defaultValue: 0,
46
- children: [/*#__PURE__*/_jsx(MenuItem, {
47
- value: 0,
48
- children: "Default Theme"
49
- }), themes.map((theme, i) => {
50
- return /*#__PURE__*/_jsx(MenuItem, {
51
- value: theme?.id,
52
- children: theme?.name
53
- }, i);
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, textThemeFields, getElementProperty } from "../helper/theme";
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,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", "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);
@@ -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 ? forActiveType : isList ? LIST_FORMAT_TYPE[format] : format,
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
- // if (NEWLINESAFTER.indexOf(format) > -1) {
114
- // insertNewLine(editor);
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 = isMarkBtnActive(editor, format);
113
+ const isActive = isMarkActive(editor, format);
127
114
  if (isActive) {
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
- }
115
+ Editor.removeMark(editor, format);
134
116
  } else {
135
117
  Editor.addMark(editor, format, true);
136
118
  }
@@ -144,58 +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, 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
@@ -221,7 +151,7 @@ export const upateBlockActive = (editor, format, attr = {}) => {
221
151
  });
222
152
  }
223
153
  };
224
- export const activeMark = (editor, format, noDefaultValue) => {
154
+ export const activeMark = (editor, format) => {
225
155
  const defaultMarkData = {
226
156
  color: "#000000",
227
157
  bgColor: "#FFFFFF",
@@ -231,7 +161,7 @@ export const activeMark = (editor, format, noDefaultValue) => {
231
161
  };
232
162
  try {
233
163
  const marks = Editor.marks(editor);
234
- let defaultValue = noDefaultValue ? "" : defaultMarkData[format];
164
+ let defaultValue = defaultMarkData[format];
235
165
  const {
236
166
  selection
237
167
  } = editor || {};
@@ -248,31 +178,6 @@ export const activeMark = (editor, format, noDefaultValue) => {
248
178
  return null;
249
179
  }
250
180
  };
251
-
252
- // to avoid the styles, that automatically assign from themes
253
- const getThemeMarkedLeaf = (leaf, children) => {
254
- const {
255
- italic,
256
- bold
257
- } = leaf || {};
258
- const style = {};
259
- if (italic === false) {
260
- style.fontStyle = "normal";
261
- }
262
- if (bold === false) {
263
- style.fontWeight = "normal";
264
- }
265
- if (Object.keys(style).length) {
266
- children = /*#__PURE__*/_jsx(Box, {
267
- component: "span",
268
- sx: {
269
- "& span": style
270
- },
271
- children: children
272
- });
273
- }
274
- return children;
275
- };
276
181
  export const getMarked = (leaf, children, theme) => {
277
182
  const className = leaf?.doublequote ? "doublequote" : "";
278
183
  const lineH = leaf?.lineHeight;
@@ -302,7 +207,6 @@ export const getMarked = (leaf, children, theme) => {
302
207
  children: children
303
208
  });
304
209
  }
305
- children = getThemeMarkedLeaf(leaf, children);
306
210
  if (leaf.strikethrough) {
307
211
  children = /*#__PURE__*/_jsx("span", {
308
212
  style: {
@@ -330,15 +234,6 @@ export const getMarked = (leaf, children, theme) => {
330
234
  if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || lineHeight || className) {
331
235
  const family = leaf?.fontFamily;
332
236
  const textStyles = getTextColor(leaf?.color);
333
- const fontSize = {
334
- lg: sizeMap[leaf.fontSize] || leaf.fontSize,
335
- ...getBreakPointsValue(leaf.fontSize, null, "overrideText")
336
- };
337
- const fontSizesImportant = {};
338
- Object.entries(fontSize).forEach(([key, value]) => {
339
- fontSizesImportant[key] = `${value} !important`;
340
- });
341
- const fontSizeWithBreakpoints = wrapThemeBreakpoints(fontSizesImportant, "fontSize", theme);
342
237
  children = /*#__PURE__*/_jsx("span", {
343
238
  style: {
344
239
  background: leaf.bgColor
@@ -347,13 +242,12 @@ export const getMarked = (leaf, children, theme) => {
347
242
  className: `${className} leaf-item`,
348
243
  component: "span",
349
244
  sx: {
350
- "& span": {
351
- // fontSize: fontSizesImportant,
352
- // ...groupByBreakpoint(fontSizesImportant, theme),
353
- background: leaf.bgColor,
354
- ...fontSizeWithBreakpoints
355
- },
356
- ...fontSizeWithBreakpoints,
245
+ ...groupByBreakpoint({
246
+ fontSize: {
247
+ lg: sizeMap[leaf.fontSize] || leaf.fontSize,
248
+ ...getBreakPointsValue(leaf.fontSize, null, "overrideText")
249
+ }
250
+ }, theme),
357
251
  // ...wrapThemeBreakpoints(
358
252
  // {
359
253
  // lg: sizeMap[leaf.fontSize] || leaf.fontSize,
@@ -374,8 +268,7 @@ export const getMarked = (leaf, children, theme) => {
374
268
  WebkitTextFillColor: "unset !important"
375
269
  },
376
270
  style: {
377
- "--fontSize_xs": leaf?.fontSize?.xs || "auto",
378
- "--fontSize_lg": leaf?.fontSize?.lg || "auto"
271
+ "--fontSize_xs": leaf?.fontSize?.xs || "auto"
379
272
  },
380
273
  children: children
381
274
  })
@@ -406,74 +299,58 @@ export const getBlock = props => {
406
299
  const {
407
300
  translation
408
301
  } = customProps;
409
- const commonHeadingProps = () => ({
410
- ...attributes,
411
- ...element.attr,
412
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} theme-element disablePointerEvent`
413
- });
414
- const commonParaProps = paraType => ({
415
- ...attributes,
416
- ...element.attr,
417
- className: `edt-paragraphs content-editable ${isEmpty ? "empty" : ""} theme-element disablePointerEvent ${paraType}`
418
- });
419
302
  const breakpoint = getDevice(window.innerWidth);
420
303
  const lineH = element?.children[0]?.lineHeight;
421
304
  const selectedLineHeight = getBreakpointLineSpacing(lineH, breakpoint);
422
305
  switch (element.type) {
423
306
  case "headingOne":
424
307
  return /*#__PURE__*/_jsx("h1", {
425
- ...commonHeadingProps(),
308
+ ...attributes,
309
+ ...element.attr,
310
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
426
311
  placeholder: translation("Heading 1"),
427
312
  children: children
428
313
  });
429
314
  case "headingTwo":
430
315
  return /*#__PURE__*/_jsx("h2", {
431
- ...commonHeadingProps(),
316
+ ...attributes,
317
+ ...element.attr,
318
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
432
319
  placeholder: translation("Heading 2"),
433
320
  children: children
434
321
  });
435
322
  case "headingThree":
436
323
  return /*#__PURE__*/_jsx("h3", {
437
- ...commonHeadingProps(),
324
+ ...attributes,
325
+ ...element.attr,
326
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
438
327
  placeholder: translation("Heading 3"),
439
328
  children: children
440
329
  });
441
330
  case "headingFour":
442
331
  return /*#__PURE__*/_jsx("h4", {
443
- ...commonHeadingProps(),
332
+ ...attributes,
333
+ ...element.attr,
334
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
444
335
  placeholder: translation("Heading 4"),
445
336
  children: children
446
337
  });
447
338
  case "headingFive":
448
339
  return /*#__PURE__*/_jsx("h5", {
449
- ...commonHeadingProps(),
340
+ ...attributes,
341
+ ...element.attr,
342
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
450
343
  placeholder: translation("Heading 5"),
451
344
  children: children
452
345
  });
453
346
  case "headingSix":
454
347
  return /*#__PURE__*/_jsx("h6", {
455
- ...commonHeadingProps(),
348
+ ...attributes,
349
+ ...element.attr,
350
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
456
351
  placeholder: translation("Heading 6"),
457
352
  children: children
458
353
  });
459
- case "paragraphOne":
460
- return /*#__PURE__*/_jsx("p", {
461
- ...commonParaProps("para1"),
462
- placeholder: "Paragraph 1",
463
- children: children
464
- });
465
- case "paragraphTwo":
466
- return /*#__PURE__*/_jsx("p", {
467
- ...commonParaProps("para2"),
468
- placeholder: "Paragraph 2",
469
- children: children
470
- });
471
- case "paragraphThree":
472
- return /*#__PURE__*/_jsx("p", {
473
- ...commonParaProps("para3"),
474
- placeholder: "Paragraph 3",
475
- children: children
476
- });
477
354
  case "blockquote":
478
355
  return /*#__PURE__*/_jsx("blockquote", {
479
356
  ...attributes,
@@ -708,8 +585,7 @@ export const getBlock = props => {
708
585
  case "docs":
709
586
  case "pdf":
710
587
  case "xls":
711
- case "doc":
712
- case "ppt":
588
+ case "csv":
713
589
  return /*#__PURE__*/_jsx(Attachments, {
714
590
  ...props
715
591
  });
@@ -1,5 +1,6 @@
1
1
  import { Path, Transforms } from "slate";
2
2
  import insertNewLine from "./insertNewLine";
3
+ import { windowVar } from "./helper";
3
4
  import { getCurrentElementText } from "../plugins/withHTML";
4
5
  export const insertButton = editor => {
5
6
  const button = {
@@ -10,7 +11,22 @@ export const insertButton = editor => {
10
11
  buttonLink: {
11
12
  linkType: "webAddress"
12
13
  },
13
- iconPosition: "start"
14
+ iconPosition: "start",
15
+ bgColor: "#2563EB",
16
+ textColor: "#FFF",
17
+ borderRadius: {
18
+ topLeft: 30,
19
+ topRight: 30,
20
+ bottomLeft: 30,
21
+ bottomRight: 30
22
+ },
23
+ bannerSpacing: {
24
+ left: 16,
25
+ top: 8,
26
+ right: 16,
27
+ bottom: 8
28
+ },
29
+ ...(windowVar.lastButtonProps || {})
14
30
  };
15
31
  const hasText = getCurrentElementText(editor);
16
32
  const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor?.selection.focus.path;