@flozy/editor 10.6.6 → 10.6.7

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 (133) hide show
  1. package/dist/Editor/ChatEditor.js +16 -17
  2. package/dist/Editor/CommonEditor.js +13 -116
  3. package/dist/Editor/DialogWrapper.js +25 -31
  4. package/dist/Editor/Editor.css +11 -31
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
  6. package/dist/Editor/Elements/AI/Styles.js +0 -1
  7. package/dist/Editor/Elements/Accordion/Accordion.js +4 -3
  8. package/dist/Editor/Elements/Accordion/AccordionSummary.js +1 -2
  9. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  10. package/dist/Editor/Elements/Button/EditorButton.js +9 -25
  11. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
  12. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  13. package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
  14. package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
  15. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +454 -0
  16. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +4 -4
  17. package/dist/Editor/Elements/Embed/Video.js +1 -1
  18. package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +1 -1
  19. package/dist/Editor/Elements/Form/FormField.js +1 -1
  20. package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
  21. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +30 -31
  22. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +4 -7
  23. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  24. package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +1 -1
  25. package/dist/Editor/Elements/FreeGrid/styles.js +0 -9
  26. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  27. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  28. package/dist/Editor/Elements/Table/Table.js +3 -3
  29. package/dist/Editor/Elements/Title/title.js +6 -6
  30. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  31. package/dist/Editor/MiniEditor.js +1 -2
  32. package/dist/Editor/Styles/EditorStyles.js +4 -4
  33. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  34. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  35. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  36. package/dist/Editor/Toolbar/FormatTools/TextSize.js +13 -10
  37. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  38. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
  39. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +13 -6
  40. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
  41. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -7
  42. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
  43. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +9 -69
  44. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +10 -58
  45. package/dist/Editor/Toolbar/PopupTool/index.js +2 -5
  46. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  47. package/dist/Editor/common/ColorPickerButton.js +16 -38
  48. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  49. package/dist/Editor/common/FontLoader/FontLoader.js +0 -3
  50. package/dist/Editor/common/Icon.js +0 -28
  51. package/dist/Editor/common/ImageSelector/ImageSelector.js +2 -2
  52. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  53. package/dist/Editor/common/LinkSettings/NavComponents.js +2 -6
  54. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
  55. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  56. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  57. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  58. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  59. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
  60. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +2 -3
  61. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  62. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -3
  63. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +2 -3
  64. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
  65. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
  66. package/dist/Editor/common/RnD/Utils/gridDropItem.js +18 -28
  67. package/dist/Editor/common/RnD/Utils/index.js +1 -3
  68. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +58 -45
  69. package/dist/Editor/common/RnD/VirtualElement/helper.js +130 -320
  70. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -22
  71. package/dist/Editor/common/RnD/index.js +11 -42
  72. package/dist/Editor/common/Shorthands/elements.js +0 -54
  73. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  74. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
  75. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  76. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  77. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  78. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  79. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
  80. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
  81. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  82. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +0 -2
  83. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  84. package/dist/Editor/common/Uploader.js +0 -16
  85. package/dist/Editor/common/iconListV2.js +20 -20
  86. package/dist/Editor/common/iconslist.js +0 -21
  87. package/dist/Editor/commonStyle.js +64 -107
  88. package/dist/Editor/helper/index.js +2 -7
  89. package/dist/Editor/helper/theme.js +2 -203
  90. package/dist/Editor/hooks/useMouseMove.js +3 -9
  91. package/dist/Editor/plugins/withEmbeds.js +1 -1
  92. package/dist/Editor/plugins/withHTML.js +1 -3
  93. package/dist/Editor/plugins/withTable.js +1 -1
  94. package/dist/Editor/theme/ThemeList.js +173 -50
  95. package/dist/Editor/utils/SlateUtilityFunctions.js +18 -152
  96. package/dist/Editor/utils/accordion.js +24 -55
  97. package/dist/Editor/utils/button.js +17 -1
  98. package/dist/Editor/utils/draftToSlate.js +2 -3
  99. package/dist/Editor/utils/events.js +1 -1
  100. package/dist/Editor/utils/font.js +37 -40
  101. package/dist/Editor/utils/helper.js +24 -99
  102. package/dist/Editor/utils/insertAppHeader.js +4 -8
  103. package/package.json +4 -4
  104. package/dist/Editor/Elements/FreeGrid/helper.js +0 -115
  105. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
  106. package/dist/Editor/assets/svg/BackIcon.js +0 -18
  107. package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
  108. package/dist/Editor/common/CustomColorPicker/index.js +0 -130
  109. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  110. package/dist/Editor/common/CustomDialog2/index.js +0 -94
  111. package/dist/Editor/common/CustomDialog2/style.js +0 -67
  112. package/dist/Editor/common/CustomSelect.js +0 -43
  113. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  114. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
  115. package/dist/Editor/helper/textIndeces.js +0 -58
  116. package/dist/Editor/hooks/useEditorTheme.js +0 -153
  117. package/dist/Editor/hooks/useThemeValues.js +0 -63
  118. package/dist/Editor/theme/index.js +0 -149
  119. package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
  120. package/dist/Editor/themeSettings/buttons/index.js +0 -300
  121. package/dist/Editor/themeSettings/buttons/style.js +0 -23
  122. package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
  123. package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
  124. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
  125. package/dist/Editor/themeSettings/fonts/index.js +0 -240
  126. package/dist/Editor/themeSettings/fonts/style.js +0 -62
  127. package/dist/Editor/themeSettings/icons.js +0 -60
  128. package/dist/Editor/themeSettings/index.js +0 -380
  129. package/dist/Editor/themeSettings/style.js +0 -299
  130. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  131. package/dist/Editor/themeSettingsAI/index.js +0 -355
  132. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
  133. 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, getElementProperty, textThemeFields } 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,
@@ -405,16 +299,6 @@ export const getBlock = props => {
405
299
  const {
406
300
  translation
407
301
  } = customProps;
408
- const commonHeadingProps = () => ({
409
- ...attributes,
410
- ...element.attr,
411
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} theme-element`
412
- });
413
- const commonParaProps = paraType => ({
414
- ...attributes,
415
- ...element.attr,
416
- className: `edt-paragraphs content-editable ${isEmpty ? "empty" : ""} theme-element ${paraType}`
417
- });
418
302
  const breakpoint = getDevice(window.innerWidth);
419
303
  const lineH = element?.children[0]?.lineHeight;
420
304
  const selectedLineHeight = getBreakpointLineSpacing(lineH, breakpoint);
@@ -467,24 +351,6 @@ export const getBlock = props => {
467
351
  placeholder: translation("Heading 6"),
468
352
  children: children
469
353
  });
470
- case "paragraphOne":
471
- return /*#__PURE__*/_jsx("p", {
472
- ...commonParaProps("para1"),
473
- placeholder: "Paragraph 1",
474
- children: children
475
- });
476
- case "paragraphTwo":
477
- return /*#__PURE__*/_jsx("p", {
478
- ...commonParaProps("para2"),
479
- placeholder: "Paragraph 2",
480
- children: children
481
- });
482
- case "paragraphThree":
483
- return /*#__PURE__*/_jsx("p", {
484
- ...commonParaProps("para3"),
485
- placeholder: "Paragraph 3",
486
- children: children
487
- });
488
354
  case "blockquote":
489
355
  return /*#__PURE__*/_jsx("blockquote", {
490
356
  ...attributes,
@@ -10,42 +10,12 @@ const focusAccordion = (editor, upPath) => {
10
10
  offset: 0
11
11
  });
12
12
  };
13
- const getAccordionNode = summaryNode => {
14
- return {
15
- type: "accordion",
16
- children: [{
17
- type: "accordion-summary",
18
- children: summaryNode
19
- }, {
20
- type: "accordion-details",
21
- children: [{
22
- type: "paragraph",
23
- children: [{
24
- text: ""
25
- }]
26
- }]
27
- }]
28
- };
29
- };
30
13
  export const insertAccordion = (editor, path) => {
31
14
  try {
32
15
  const {
33
16
  selection
34
17
  } = editor;
35
- let accordionPath;
36
- if (path) {
37
- const summaryNode = {
38
- type: "paragraph",
39
- children: [{
40
- text: ""
41
- }]
42
- };
43
- const accordion = getAccordionNode([summaryNode]);
44
- Transforms.insertNodes(editor, accordion, {
45
- at: path
46
- });
47
- accordionPath = path;
48
- } else if (selection) {
18
+ if (selection) {
49
19
  const selectedNodes = Array.from(Editor.nodes(editor, {
50
20
  at: selection,
51
21
  match: n => Element.isElement(n),
@@ -53,21 +23,21 @@ export const insertAccordion = (editor, path) => {
53
23
  }));
54
24
 
55
25
  for (const [node, path] of selectedNodes) {
56
- let currNode = node;
57
- const isListItem = node.type === "list-item";
58
- if (isListItem) {
59
- currNode = {
60
- type: "paragraph",
61
- children: node.children
62
- };
63
- }
64
- let accordion = getAccordionNode([currNode]);
65
- if (isListItem) {
66
- accordion = {
67
- type: "list-item",
68
- children: [accordion]
69
- };
70
- }
26
+ const accordion = {
27
+ type: "accordion",
28
+ children: [{
29
+ type: "accordion-summary",
30
+ children: [node]
31
+ }, {
32
+ type: "accordion-details",
33
+ children: [{
34
+ type: "paragraph",
35
+ children: [{
36
+ text: ""
37
+ }]
38
+ }]
39
+ }]
40
+ };
71
41
  Transforms.removeNodes(editor, {
72
42
  at: path
73
43
  });
@@ -77,16 +47,15 @@ export const insertAccordion = (editor, path) => {
77
47
  }
78
48
  const lastNode = selectedNodes[selectedNodes.length - 1];
79
49
  const lastNodePath = lastNode[1];
80
- accordionPath = lastNodePath;
81
- }
82
- const focusPath = [...accordionPath, 0, 0, 0];
83
- if (isMobileWindow()) {
84
- // timeout to resolve focus issue in mobile
85
- setTimeout(() => focusAccordion(editor, focusPath), 0);
86
- } else {
87
- focusAccordion(editor, focusPath);
50
+ const accordionPath = [...lastNodePath, 0, 0, 0];
51
+ if (isMobileWindow()) {
52
+ // timeout to resolve focus issue in mobile
53
+ setTimeout(() => focusAccordion(editor, accordionPath), 0);
54
+ } else {
55
+ focusAccordion(editor, accordionPath);
56
+ }
57
+ insertNewLine(editor);
88
58
  }
89
- insertNewLine(editor);
90
59
  } catch (err) {
91
60
  console.log(err);
92
61
  }
@@ -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;
@@ -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: needLayout ? "title" : "paragraph",
107
+ type: "paragraph",
109
108
  children: [{
110
109
  text: ""
111
110
  }]
@@ -1,4 +1,4 @@
1
- import { Editor, Transforms, Element, Node, Path, Range, Point } from "slate";
1
+ import { Editor, Transforms, Element, Node, Path, Range } from "slate";
2
2
  import { toggleBlock } from "./SlateUtilityFunctions";
3
3
  import insertNewLine from "./insertNewLine";
4
4
  import { insertAccordion } from "./accordion";