@flozy/editor 3.6.9 → 3.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/dist/Editor/CommonEditor.js +111 -169
  2. package/dist/Editor/Elements/Accordion/Accordion.js +7 -74
  3. package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +2 -3
  4. package/dist/Editor/Elements/Accordion/AccordionSummary.js +60 -4
  5. package/dist/Editor/Elements/AppHeader/AppHeader.js +4 -26
  6. package/dist/Editor/Elements/Button/EditorButton.js +18 -34
  7. package/dist/Editor/Elements/ChipText/ChipText.js +3 -3
  8. package/dist/Editor/Elements/Color Picker/ColorButtons.js +17 -60
  9. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  10. package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
  11. package/dist/Editor/Elements/Color Picker/Styles.js +1 -2
  12. package/dist/Editor/Elements/Embed/Frames/ImageFrame.js +0 -1
  13. package/dist/Editor/Elements/Emoji/EmojiButton.js +2 -2
  14. package/dist/Editor/Elements/Emoji/EmojiPicker.js +0 -16
  15. package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +3 -12
  16. package/dist/Editor/Elements/Form/Workflow/UserInputs.js +1 -2
  17. package/dist/Editor/Elements/Grid/Grid.js +1 -3
  18. package/dist/Editor/Elements/Grid/GridItem.js +2 -4
  19. package/dist/Editor/Elements/InlineIcon/InlineIcon.js +3 -2
  20. package/dist/Editor/Elements/Link/Link.js +1 -6
  21. package/dist/Editor/Elements/Link/LinkButton.js +2 -4
  22. package/dist/Editor/Elements/Link/LinkPopup.js +3 -11
  23. package/dist/Editor/Elements/List/CheckList.js +2 -6
  24. package/dist/Editor/Elements/Table/TableCell.js +1 -1
  25. package/dist/Editor/MiniEditor.js +1 -3
  26. package/dist/Editor/Styles/EditorStyles.js +2 -3
  27. package/dist/Editor/Toolbar/Basic/index.js +2 -4
  28. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +2 -26
  29. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  30. package/dist/Editor/Toolbar/FormatTools/TextSize.js +11 -5
  31. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +11 -4
  32. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +86 -213
  33. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +1 -2
  34. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +13 -20
  35. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +7 -52
  36. package/dist/Editor/Toolbar/PopupTool/index.js +2 -9
  37. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  38. package/dist/Editor/common/ColorPickerButton.js +9 -25
  39. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  40. package/dist/Editor/common/Icon.js +2 -30
  41. package/dist/Editor/common/MentionsPopup/MentionsListCard.js +2 -5
  42. package/dist/Editor/common/MentionsPopup/Styles.js +3 -6
  43. package/dist/Editor/common/Shorthands/elements.js +0 -54
  44. package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +7 -7
  45. package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +16 -16
  46. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  47. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +3 -13
  48. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  49. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +7 -31
  50. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +4 -13
  51. package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +28 -12
  52. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +4 -14
  53. package/dist/Editor/common/StyleBuilder/formStyle.js +26 -25
  54. package/dist/Editor/common/StyleBuilder/index.js +1 -1
  55. package/dist/Editor/helper/index.js +0 -15
  56. package/dist/Editor/helper/theme.js +4 -190
  57. package/dist/Editor/hooks/useMouseMove.js +6 -15
  58. package/dist/Editor/plugins/withEmbeds.js +1 -1
  59. package/dist/Editor/plugins/withHTML.js +5 -47
  60. package/dist/Editor/plugins/withLayout.js +10 -15
  61. package/dist/Editor/plugins/withTable.js +2 -2
  62. package/dist/Editor/theme/ThemeList.js +173 -50
  63. package/dist/Editor/utils/SlateUtilityFunctions.js +25 -157
  64. package/dist/Editor/utils/button.js +17 -1
  65. package/dist/Editor/utils/events.js +4 -11
  66. package/dist/Editor/utils/font.js +37 -40
  67. package/dist/Editor/utils/form.js +2 -2
  68. package/dist/Editor/utils/helper.js +12 -71
  69. package/dist/Editor/utils/serializeToHTML.js +13 -25
  70. package/dist/index.js +1 -5
  71. package/package.json +4 -4
  72. package/dist/Editor/ChatEditor.js +0 -211
  73. package/dist/Editor/Elements/Link/LinkPopupStyles.js +0 -28
  74. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -438
  75. package/dist/Editor/assets/svg/ThemeIcons.js +0 -291
  76. package/dist/Editor/common/CustomColorPicker/index.js +0 -106
  77. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  78. package/dist/Editor/common/CustomDialog/index.js +0 -94
  79. package/dist/Editor/common/CustomDialog/style.js +0 -67
  80. package/dist/Editor/common/CustomSelect.js +0 -33
  81. package/dist/Editor/common/EditorCmds.js +0 -35
  82. package/dist/Editor/common/MUIIcon/index.js +0 -48
  83. package/dist/Editor/common/StyleBuilder/fieldTypes/loadIcon.js +0 -13
  84. package/dist/Editor/common/StyleBuilder/fieldTypes/mui_filled_icons.js +0 -2
  85. package/dist/Editor/hooks/useEditorTheme.js +0 -139
  86. package/dist/Editor/theme/index.js +0 -144
  87. package/dist/Editor/themeSettings/ActiveTheme.js +0 -72
  88. package/dist/Editor/themeSettings/buttons/index.js +0 -290
  89. package/dist/Editor/themeSettings/buttons/style.js +0 -21
  90. package/dist/Editor/themeSettings/colorTheme/index.js +0 -290
  91. package/dist/Editor/themeSettings/colorTheme/style.js +0 -77
  92. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -123
  93. package/dist/Editor/themeSettings/fonts/index.js +0 -213
  94. package/dist/Editor/themeSettings/fonts/style.js +0 -44
  95. package/dist/Editor/themeSettings/icons.js +0 -60
  96. package/dist/Editor/themeSettings/index.js +0 -320
  97. package/dist/Editor/themeSettings/style.js +0 -152
  98. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  99. package/dist/Editor/themeSettingsAI/index.js +0 -356
  100. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -190
  101. package/dist/Editor/themeSettingsAI/style.js +0 -247
  102. package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +0 -361
@@ -1,4 +1,4 @@
1
- import { Transforms, Editor, Element, Node, Path } from "slate";
1
+ import { Transforms, Editor, Element, Node } from "slate";
2
2
  import deserialize from "../helper/deserialize";
3
3
  import { decodeAndParseBase64 } from "../utils/helper";
4
4
  const avoidDefaultInsert = ["table", "grid"];
@@ -15,7 +15,7 @@ const loopChildren = (children = [], defaultInsert) => {
15
15
  }
16
16
  return defaultInsert;
17
17
  };
18
- export const getCurrentElement = editor => {
18
+ const getCurrentElement = editor => {
19
19
  try {
20
20
  if (editor.selection) {
21
21
  return Node.parent(editor, editor?.selection?.anchor?.path);
@@ -26,48 +26,6 @@ export const getCurrentElement = editor => {
26
26
  return null;
27
27
  }
28
28
  };
29
- const getCurrentElementText = editor => {
30
- try {
31
- if (editor.selection) {
32
- return Editor.string(editor, editor?.selection?.anchor?.path);
33
- } else {
34
- return null;
35
- }
36
- } catch (err) {
37
- return null;
38
- }
39
- };
40
- const insertAtNextNode = (editor, formattedFragment) => {
41
- try {
42
- const {
43
- selection
44
- } = editor;
45
- if (selection) {
46
- const parentPath = Path.parent(editor?.selection?.anchor?.path);
47
- const nextPath = Path.next(parentPath);
48
- Transforms.insertNodes(editor, {
49
- type: "paragraph",
50
- children: [{
51
- text: ""
52
- }]
53
- }, {
54
- at: nextPath
55
- });
56
- Transforms.insertFragment(editor, formattedFragment, {
57
- at: nextPath
58
- });
59
- }
60
- } catch (err) {
61
- console.log(err);
62
- }
63
- };
64
- const handleInsert = (editor, defaultInsert, fragment = []) => {
65
- if (getCurrentElementText(editor) && fragment.some(f => f.type === "table")) {
66
- insertAtNextNode(editor, fragment);
67
- } else {
68
- defaultInsert();
69
- }
70
- };
71
29
  const formatFragment = {
72
30
  "list-item": fragment => {
73
31
  let refactorFragment = [];
@@ -106,11 +64,11 @@ const withHtml = editor => {
106
64
  const currentEl = getCurrentElement(editor);
107
65
  const eltype = currentEl?.type;
108
66
  if (slateHTML && !formatFragment[eltype]) {
109
- const decoded = decodeAndParseBase64(slateHTML);
110
67
  const [tableNode] = Editor.nodes(editor, {
111
68
  match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
112
69
  });
113
70
  if (tableNode && tableNode[0]) {
71
+ const decoded = decodeAndParseBase64(slateHTML);
114
72
  const defaultInsert = loopChildren(decoded, true);
115
73
  if (defaultInsert) {
116
74
  insertData(data);
@@ -121,7 +79,7 @@ const withHtml = editor => {
121
79
  Transforms.insertText(editor, text);
122
80
  }
123
81
  } else {
124
- handleInsert(editor, () => insertData(data), decoded);
82
+ insertData(data);
125
83
  }
126
84
  } else if (html) {
127
85
  const parsed = new DOMParser().parseFromString(html, "text/html");
@@ -138,7 +96,7 @@ const withHtml = editor => {
138
96
  }
139
97
  const fragment = deserialize(parsed.body);
140
98
  const formattedFragment = formatFragment[eltype] ? formatFragment[eltype](fragment) : fragment;
141
- handleInsert(editor, () => Transforms.insertFragment(editor, formattedFragment), formattedFragment);
99
+ Transforms.insertFragment(editor, formattedFragment);
142
100
  return;
143
101
  } else {
144
102
  insertData(data);
@@ -32,21 +32,16 @@ const withLayout = editor => {
32
32
  editor.normalizeNode = ([node, path]) => {
33
33
  if (path.length === 0) {
34
34
  if (editor.children.length <= 1 && Editor.string(editor, [0, 0]) === "") {
35
- const {
36
- anchor
37
- } = editor?.selection || {};
38
- if (anchor?.offset !== 0) {
39
- const title = {
40
- type: "title",
41
- children: [{
42
- text: "Untitled"
43
- }]
44
- };
45
- Transforms.insertNodes(editor, title, {
46
- at: path.concat(0),
47
- select: true
48
- });
49
- }
35
+ const title = {
36
+ type: "title",
37
+ children: [{
38
+ text: "Untitled"
39
+ }]
40
+ };
41
+ Transforms.insertNodes(editor, title, {
42
+ at: path.concat(0),
43
+ select: true
44
+ });
50
45
  }
51
46
  if (editor.children.length === 0) {
52
47
  const paragraph = {
@@ -1,6 +1,6 @@
1
1
  import { Editor, Range, Point, Element, Transforms, Node } from "slate";
2
2
  import { TableUtil, createTableCell } from "../utils/table";
3
- const NON_DELETABLE_BLOCKS = ["table-cell", "carousel-item", "page-settings"];
3
+ const NON_DELETABLE_BLOCKS = ["table-cell", "carousel-item"];
4
4
  const withTable = editor => {
5
5
  const {
6
6
  deleteBackward,
@@ -8,7 +8,7 @@ const withTable = editor => {
8
8
  delete: slateDelete
9
9
  } = editor;
10
10
  editor.delete = arg => {
11
- if (arg?.reverse) {
11
+ if (arg.reverse) {
12
12
  const table = new TableUtil(editor);
13
13
  const cellsSelected = table.isCellSelected(editor.selection);
14
14
  if (cellsSelected && cellsSelected.length > 1) {
@@ -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;
@@ -1,4 +1,4 @@
1
- import { Editor, Transforms, Element as SlateElement, Range } from "slate";
1
+ import { Editor, Transforms, Element as SlateElement } from "slate";
2
2
  import { Box } from "@mui/material";
3
3
  import { fontFamilyMap, sizeMap } from "./font";
4
4
  import Link from "../Elements/Link/Link";
@@ -34,12 +34,12 @@ import SimpleText from "../Elements/SimpleText";
34
34
  import CheckList from "../Elements/List/CheckList";
35
35
  import { isEmptyTextNode } from "../helper";
36
36
  import Attachments from "../Elements/Attachments/Attachments";
37
- import { getBreakPointsValue, textThemeFields } from "../helper/theme";
37
+ import { getBreakPointsValue } from "../helper/theme";
38
38
  import Variables from "../Elements/Variables/Variable";
39
+ import insertNewLine from "./insertNewLine";
39
40
  import Divider from "../Elements/Divider/Divider";
40
41
  import { getBorderColor } from "./helper";
41
42
  import Code from "../Elements/EmbedScript/Code";
42
- import { ReactEditor } from "slate-react";
43
43
  import { jsx as _jsx } from "react/jsx-runtime";
44
44
  const alignment = ["alignLeft", "alignRight", "alignCenter"];
45
45
  const list_types = ["orderedList", "unorderedList"];
@@ -47,17 +47,7 @@ const LIST_FORMAT_TYPE = {
47
47
  orderedList: "list-item",
48
48
  unorderedList: "list-item"
49
49
  };
50
-
51
- // const NEWLINESAFTER = [
52
- // "headingOne",
53
- // "headingTwo",
54
- // "headingThree",
55
- // "headingFour",
56
- // "headingFive",
57
- // "headingSix",
58
- // ];
59
-
60
- const THEME_BLOCK_FIELDS = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
50
+ const NEWLINESAFTER = ["headingOne", "headingTwo", "headingThree"];
61
51
  export const toggleBlock = (editor, format, selection = true, attr = {}) => {
62
52
  const isActive = isBlockActive(editor, format);
63
53
  const isList = list_types.includes(format);
@@ -90,9 +80,8 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
90
80
  if (!selection) {
91
81
  Transforms.insertText(editor, "");
92
82
  }
93
- const forActiveType = THEME_BLOCK_FIELDS.some(f => f === format) ? format : "paragraph";
94
83
  Transforms.setNodes(editor, {
95
- type: isActive ? forActiveType : isList ? LIST_FORMAT_TYPE[format] : format,
84
+ type: isActive ? "paragraph" : isList ? LIST_FORMAT_TYPE[format] : format,
96
85
  ...attr
97
86
  });
98
87
  if (isList && !isActive) {
@@ -101,12 +90,10 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
101
90
  children: []
102
91
  });
103
92
  }
104
-
105
- // if (NEWLINESAFTER.indexOf(format) > -1) {
106
- // insertNewLine(editor);
107
- // }
93
+ if (NEWLINESAFTER.indexOf(format) > -1) {
94
+ insertNewLine(editor);
95
+ }
108
96
  };
109
-
110
97
  export const addMarkData = (editor, data) => {
111
98
  try {
112
99
  Editor.addMark(editor, data.format, data.value);
@@ -115,14 +102,9 @@ export const addMarkData = (editor, data) => {
115
102
  }
116
103
  };
117
104
  export const toggleMark = (editor, format) => {
118
- const isActive = isMarkBtnActive(editor, format);
105
+ const isActive = isMarkActive(editor, format);
119
106
  if (isActive) {
120
- const isThemeSupportedMark = textThemeFields.some(f => f === format);
121
- if (isThemeSupportedMark) {
122
- Editor.addMark(editor, format, false);
123
- } else {
124
- Editor.removeMark(editor, format);
125
- }
107
+ Editor.removeMark(editor, format);
126
108
  } else {
127
109
  Editor.addMark(editor, format, true);
128
110
  }
@@ -136,49 +118,6 @@ export const isMarkActive = (editor, format) => {
136
118
  return null;
137
119
  }
138
120
  };
139
- export const isMarkBtnActive = (editor, format) => {
140
- switch (format) {
141
- case "bold":
142
- {
143
- const style = getSelectedElementStyle("font-weight", editor);
144
- return style === "700";
145
- }
146
- case "italic":
147
- {
148
- const style = getSelectedElementStyle("font-style", editor);
149
- return style === format;
150
- }
151
- // case "underline": {
152
- // const style = getSelectedElementStyle("text-decoration");
153
-
154
- // return style?.includes(format);
155
- // }
156
- // case "strikethrough": {
157
- // const style = getSelectedElementStyle("text-decoration");
158
-
159
- // return style?.includes("line-through");
160
- // }
161
- default:
162
- return isMarkActive(editor, format);
163
- }
164
- };
165
- export const getSelectedElementStyle = (styleProperty, editor) => {
166
- if (!editor.selection) {
167
- return "";
168
- }
169
- if (Range.isCollapsed(editor.selection)) {
170
- return "";
171
- }
172
- const domRange = ReactEditor.toDOMRange(editor, editor.selection);
173
- const selectedDomNode = domRange.commonAncestorContainer;
174
-
175
- // If it's a text node, get its parent element
176
- const selectedElement = selectedDomNode.nodeType === 3 ? selectedDomNode.parentElement : selectedDomNode;
177
- if (selectedElement) {
178
- const computedStyle = window.getComputedStyle(selectedElement);
179
- return computedStyle.getPropertyValue(styleProperty) || "";
180
- }
181
- };
182
121
  export const isBlockActive = (editor, format) => {
183
122
  const [match] = Editor.nodes(editor, {
184
123
  match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
@@ -221,31 +160,6 @@ export const activeMark = (editor, format) => {
221
160
  return null;
222
161
  }
223
162
  };
224
-
225
- // to avoid the styles, that automatically assign from themes
226
- const getThemeMarkedLeaf = (leaf, children) => {
227
- const {
228
- italic,
229
- bold
230
- } = leaf || {};
231
- const style = {};
232
- if (italic === false) {
233
- style.fontStyle = "normal";
234
- }
235
- if (bold === false) {
236
- style.fontWeight = "normal";
237
- }
238
- if (Object.keys(style).length) {
239
- children = /*#__PURE__*/_jsx(Box, {
240
- component: "span",
241
- sx: {
242
- "& span": style
243
- },
244
- children: children
245
- });
246
- }
247
- return children;
248
- };
249
163
  export const getMarked = (leaf, children) => {
250
164
  const className = leaf?.doublequote ? "doublequote" : "";
251
165
  if (leaf.bold) {
@@ -263,7 +177,6 @@ export const getMarked = (leaf, children) => {
263
177
  children: children
264
178
  });
265
179
  }
266
- children = getThemeMarkedLeaf(leaf, children);
267
180
  if (leaf.strikethrough) {
268
181
  children = /*#__PURE__*/_jsx("span", {
269
182
  style: {
@@ -297,22 +210,17 @@ export const getMarked = (leaf, children) => {
297
210
  } : {
298
211
  color: leaf.color
299
212
  };
300
- const fontSize = {
301
- lg: sizeMap[leaf.fontSize] || leaf.fontSize,
302
- ...getBreakPointsValue(leaf.fontSize, null, "overrideText")
303
- };
304
- const fontSizesImportant = {};
305
- Object.entries(fontSize).forEach(([key, value]) => {
306
- fontSizesImportant[key] = `${value} !important`;
307
- });
308
213
  children = /*#__PURE__*/_jsx("span", {
214
+ style: {
215
+ background: leaf.bgColor
216
+ },
309
217
  children: /*#__PURE__*/_jsx(Box, {
310
218
  className: className,
311
219
  component: "span",
312
220
  sx: {
313
- "& span": {
314
- fontSize: fontSizesImportant,
315
- background: leaf.bgColor
221
+ fontSize: {
222
+ lg: sizeMap[leaf.fontSize] || leaf.fontSize,
223
+ ...getBreakPointsValue(leaf.fontSize, null, "overrideText")
316
224
  },
317
225
  ...textStyles,
318
226
  fontFamily: family,
@@ -342,71 +250,31 @@ export const getBlock = props => {
342
250
  } = props;
343
251
  const attributes = props.attributes ?? {};
344
252
  const isEmpty = isEmptyTextNode(element);
345
- const commonHeadingProps = () => ({
346
- ...attributes,
347
- ...element.attr,
348
- className: `content-editable ${isEmpty ? "empty" : ""} theme-element`
349
- });
350
- const commonParaProps = paraType => ({
351
- ...attributes,
352
- ...element.attr,
353
- className: `content-editable ${isEmpty ? "empty" : ""} theme-element ${paraType}`
354
- });
355
253
  switch (element.type) {
356
254
  case "headingOne":
357
255
  return /*#__PURE__*/_jsx("h1", {
358
- ...commonHeadingProps(),
256
+ ...attributes,
257
+ ...element.attr,
258
+ className: `content-editable ${isEmpty ? "empty" : ""}`,
359
259
  placeholder: "Heading 1",
360
260
  children: children
361
261
  });
362
262
  case "headingTwo":
363
263
  return /*#__PURE__*/_jsx("h2", {
364
- ...commonHeadingProps(),
264
+ ...attributes,
265
+ ...element.attr,
266
+ className: `content-editable ${isEmpty ? "empty" : ""}`,
365
267
  placeholder: "Heading 2",
366
268
  children: children
367
269
  });
368
270
  case "headingThree":
369
271
  return /*#__PURE__*/_jsx("h3", {
370
- ...commonHeadingProps(),
272
+ ...attributes,
273
+ ...element.attr,
274
+ className: `content-editable ${isEmpty ? "empty" : ""}`,
371
275
  placeholder: "Heading 3",
372
276
  children: children
373
277
  });
374
- case "headingFour":
375
- return /*#__PURE__*/_jsx("h4", {
376
- ...commonHeadingProps(),
377
- placeholder: "Heading 4",
378
- children: children
379
- });
380
- case "headingFive":
381
- return /*#__PURE__*/_jsx("h5", {
382
- ...commonHeadingProps(),
383
- placeholder: "Heading 5",
384
- children: children
385
- });
386
- case "headingSix":
387
- return /*#__PURE__*/_jsx("h6", {
388
- ...commonHeadingProps(),
389
- placeholder: "Heading 6",
390
- children: children
391
- });
392
- case "paragraphOne":
393
- return /*#__PURE__*/_jsx("p", {
394
- ...commonParaProps("para1"),
395
- placeholder: "Paragraph 1",
396
- children: children
397
- });
398
- case "paragraphTwo":
399
- return /*#__PURE__*/_jsx("p", {
400
- ...commonParaProps("para2"),
401
- placeholder: "Paragraph 2",
402
- children: children
403
- });
404
- case "paragraphThree":
405
- return /*#__PURE__*/_jsx("p", {
406
- ...commonParaProps("para3"),
407
- placeholder: "Paragraph 3",
408
- children: children
409
- });
410
278
  case "blockquote":
411
279
  return /*#__PURE__*/_jsx("blockquote", {
412
280
  ...attributes,
@@ -1,5 +1,6 @@
1
1
  import { Transforms } from "slate";
2
2
  import insertNewLine from "./insertNewLine";
3
+ import { windowVar } from "./helper";
3
4
  export const insertButton = editor => {
4
5
  const button = {
5
6
  type: "button",
@@ -9,7 +10,22 @@ export const insertButton = editor => {
9
10
  buttonLink: {
10
11
  linkType: "webAddress"
11
12
  },
12
- iconPosition: "start"
13
+ iconPosition: "start",
14
+ bgColor: "#2563EB",
15
+ textColor: "#FFF",
16
+ borderRadius: {
17
+ topLeft: 30,
18
+ topRight: 30,
19
+ bottomLeft: 30,
20
+ bottomRight: 30
21
+ },
22
+ bannerSpacing: {
23
+ left: 16,
24
+ top: 8,
25
+ right: 16,
26
+ bottom: 8
27
+ },
28
+ ...(windowVar.lastButtonProps || {})
13
29
  };
14
30
  Transforms.insertNodes(editor, button);
15
31
  Transforms.move(editor);