@flozy/editor 10.6.8 → 10.7.0

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 (128) 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 +17 -25
  8. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  9. package/dist/Editor/Elements/Button/EditorButton.js +7 -23
  10. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
  11. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  12. package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
  13. package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
  14. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +454 -0
  15. package/dist/Editor/Elements/Embed/Video.js +1 -1
  16. package/dist/Editor/Elements/Form/FormField.js +1 -1
  17. package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
  18. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +30 -31
  19. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +4 -7
  20. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  21. package/dist/Editor/Elements/FreeGrid/styles.js +0 -9
  22. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  23. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  24. package/dist/Editor/Elements/Table/Table.js +3 -3
  25. package/dist/Editor/Elements/Title/title.js +6 -6
  26. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  27. package/dist/Editor/MiniEditor.js +1 -2
  28. package/dist/Editor/Styles/EditorStyles.js +5 -9
  29. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  30. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  31. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  32. package/dist/Editor/Toolbar/FormatTools/TextSize.js +13 -10
  33. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  34. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
  35. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +13 -6
  36. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +2 -4
  37. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
  38. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -7
  39. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
  40. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +9 -69
  41. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +10 -58
  42. package/dist/Editor/Toolbar/PopupTool/index.js +2 -5
  43. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  44. package/dist/Editor/common/ColorPickerButton.js +16 -38
  45. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  46. package/dist/Editor/common/FontLoader/FontLoader.js +0 -3
  47. package/dist/Editor/common/Icon.js +0 -28
  48. package/dist/Editor/common/ImageSelector/ImageSelector.js +2 -2
  49. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  50. package/dist/Editor/common/LinkSettings/NavComponents.js +2 -6
  51. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
  52. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  53. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  54. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  55. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  56. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
  57. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +2 -3
  58. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  59. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -3
  60. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +2 -3
  61. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
  62. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
  63. package/dist/Editor/common/RnD/Utils/gridDropItem.js +18 -28
  64. package/dist/Editor/common/RnD/Utils/index.js +1 -3
  65. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +58 -45
  66. package/dist/Editor/common/RnD/VirtualElement/helper.js +130 -320
  67. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -22
  68. package/dist/Editor/common/RnD/index.js +11 -42
  69. package/dist/Editor/common/Shorthands/elements.js +0 -54
  70. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  71. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
  72. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  73. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  74. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  75. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  76. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
  77. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
  78. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  79. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +0 -2
  80. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  81. package/dist/Editor/common/Uploader.js +0 -16
  82. package/dist/Editor/common/iconslist.js +0 -21
  83. package/dist/Editor/commonStyle.js +64 -107
  84. package/dist/Editor/helper/index.js +2 -7
  85. package/dist/Editor/helper/theme.js +2 -203
  86. package/dist/Editor/hooks/useMouseMove.js +3 -9
  87. package/dist/Editor/plugins/withEmbeds.js +1 -1
  88. package/dist/Editor/plugins/withHTML.js +1 -3
  89. package/dist/Editor/plugins/withTable.js +1 -1
  90. package/dist/Editor/theme/ThemeList.js +173 -50
  91. package/dist/Editor/utils/SlateUtilityFunctions.js +24 -229
  92. package/dist/Editor/utils/accordion.js +34 -62
  93. package/dist/Editor/utils/button.js +17 -1
  94. package/dist/Editor/utils/draftToSlate.js +2 -3
  95. package/dist/Editor/utils/font.js +37 -40
  96. package/dist/Editor/utils/helper.js +21 -97
  97. package/dist/Editor/utils/insertAppHeader.js +4 -8
  98. package/package.json +4 -4
  99. package/dist/Editor/Elements/FreeGrid/helper.js +0 -115
  100. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
  101. package/dist/Editor/assets/svg/BackIcon.js +0 -18
  102. package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
  103. package/dist/Editor/common/CustomColorPicker/index.js +0 -130
  104. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  105. package/dist/Editor/common/CustomDialog2/index.js +0 -94
  106. package/dist/Editor/common/CustomDialog2/style.js +0 -67
  107. package/dist/Editor/common/CustomSelect.js +0 -43
  108. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  109. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
  110. package/dist/Editor/helper/textIndeces.js +0 -58
  111. package/dist/Editor/hooks/useEditorTheme.js +0 -153
  112. package/dist/Editor/hooks/useThemeValues.js +0 -63
  113. package/dist/Editor/theme/index.js +0 -149
  114. package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
  115. package/dist/Editor/themeSettings/buttons/index.js +0 -300
  116. package/dist/Editor/themeSettings/buttons/style.js +0 -23
  117. package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
  118. package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
  119. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
  120. package/dist/Editor/themeSettings/fonts/index.js +0 -240
  121. package/dist/Editor/themeSettings/fonts/style.js +0 -62
  122. package/dist/Editor/themeSettings/icons.js +0 -60
  123. package/dist/Editor/themeSettings/index.js +0 -380
  124. package/dist/Editor/themeSettings/style.js +0 -299
  125. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  126. package/dist/Editor/themeSettingsAI/index.js +0 -355
  127. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
  128. package/dist/Editor/themeSettingsAI/style.js +0 -332
@@ -1,43 +0,0 @@
1
- import { MenuItem, Select } from "@mui/material";
2
- import { fontFamilyMap } from "../utils/font";
3
- import KeyboardArrowDownRoundedIcon from "@mui/icons-material/KeyboardArrowDownRounded";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- function CustomSelect(props) {
6
- const {
7
- classes,
8
- onChange,
9
- options = [],
10
- value
11
- } = props;
12
- return /*#__PURE__*/_jsx(Select, {
13
- fullWidth: true,
14
- value: value,
15
- onChange: onChange,
16
- className: "editor-dd",
17
- style: {
18
- fontFamily: fontFamilyMap[value],
19
- width: "100%",
20
- height: "36px",
21
- borderRadius: "10px",
22
- fontSize: "14px"
23
- },
24
- MenuProps: {
25
- PaperProps: {
26
- sx: classes?.textOptions
27
- }
28
- },
29
- sx: classes.textFormatSelect,
30
- IconComponent: KeyboardArrowDownRoundedIcon,
31
- children: options.map((option, i) => {
32
- return /*#__PURE__*/_jsx(MenuItem, {
33
- value: option.value,
34
- style: {
35
- fontFamily: option.text || "inherit"
36
- },
37
- sx: classes.textFormatSelectOptions,
38
- children: option?.label || option?.text
39
- }, i);
40
- })
41
- });
42
- }
43
- export default CustomSelect;
@@ -1,17 +0,0 @@
1
- import { Experimental_CssVarsProvider as CssVarsProvider, experimental_extendTheme as extendTheme } from "@mui/material/styles";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- function MainThemeProvider({
4
- children,
5
- userSelectedTheme,
6
- theme = {}
7
- }) {
8
- const themeVars = extendTheme(userSelectedTheme?.theme?.cssVars || {});
9
- return /*#__PURE__*/_jsx(CssVarsProvider, {
10
- theme: {
11
- ...themeVars,
12
- ...theme
13
- },
14
- children: children
15
- });
16
- }
17
- export default MainThemeProvider;
@@ -1,115 +0,0 @@
1
- import React, { useState } from "react";
2
- import { Grid, Button, Typography } from "@mui/material";
3
- import ImageSelector from "../../ImageSelector/ImageSelector";
4
- import UploadStyles from "../../ImageSelector/UploadStyles";
5
- import Icon from "../../Icon";
6
- import { useEditorContext } from "../../../hooks/useMouseMove";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- import { jsxs as _jsxs } from "react/jsx-runtime";
9
- const EmbedUpload = props => {
10
- const {
11
- value,
12
- data,
13
- customProps,
14
- onChange
15
- } = props;
16
- const {
17
- translation
18
- } = customProps;
19
- const {
20
- key
21
- } = data;
22
- const [base64, setBase64] = useState(value);
23
- const [open, setOpen] = useState(false);
24
- const {
25
- theme
26
- } = useEditorContext();
27
- const classes = UploadStyles(theme);
28
- const onRemoveBG = () => {
29
- setBase64(null);
30
- onChange({
31
- [key]: "none"
32
- });
33
- };
34
- const handleClick = () => {
35
- setOpen(true);
36
- };
37
- const handleClose = () => {
38
- setOpen(false);
39
- };
40
- const onSelectImage = img => {
41
- setBase64(img);
42
- onChange({
43
- [key]: img
44
- });
45
- handleClose();
46
- };
47
- return /*#__PURE__*/_jsxs(Grid, {
48
- item: true,
49
- xs: 12,
50
- children: [/*#__PURE__*/_jsx(Typography, {
51
- variant: "body1",
52
- color: "primary",
53
- sx: {
54
- fontSize: "14px",
55
- fontWeight: "500",
56
- marginBottom: "8px"
57
- },
58
- children: translation("Upload Video")
59
- }), /*#__PURE__*/_jsx(Grid, {
60
- container: true,
61
- sx: classes.uploadContainer,
62
- children: /*#__PURE__*/_jsx(Grid, {
63
- item: true,
64
- xs: 12,
65
- sx: classes.uploadField,
66
- children: /*#__PURE__*/_jsx(Grid, {
67
- className: "uploadImageSection",
68
- children: base64 ? /*#__PURE__*/_jsxs(Grid, {
69
- justifyItems: "center",
70
- alignItems: "center",
71
- children: [/*#__PURE__*/_jsx(Typography, {
72
- style: {
73
- padding: "8px",
74
- fontSize: "8px",
75
- color: theme?.palette?.editor?.textColor,
76
- textAlign: "center"
77
- },
78
- children: base64
79
- }), /*#__PURE__*/_jsx(Grid, {
80
- className: "removeImageText",
81
- onClick: onRemoveBG,
82
- children: translation("REMOVE")
83
- })]
84
- }) : /*#__PURE__*/_jsx(Grid, {
85
- className: "uploadImageText",
86
- children: /*#__PURE__*/_jsxs(Button, {
87
- component: "label",
88
- variant: "text",
89
- style: {
90
- background: "none"
91
- },
92
- onClick: handleClick,
93
- sx: classes.uploadIcon,
94
- children: [/*#__PURE__*/_jsx(Icon, {
95
- icon: "fileUpload"
96
- }), /*#__PURE__*/_jsx("span", {
97
- style: {
98
- paddingLeft: "8px"
99
- },
100
- children: translation("Upload a Video")
101
- })]
102
- })
103
- })
104
- })
105
- })
106
- }), /*#__PURE__*/_jsx(ImageSelector, {
107
- open: open,
108
- title: "Video",
109
- onClose: handleClose,
110
- customProps: customProps,
111
- onSelectImage: onSelectImage
112
- })]
113
- });
114
- };
115
- export default EmbedUpload;
@@ -1,58 +0,0 @@
1
- export function extractTextWithPath(data, path = []) {
2
- let result = [];
3
- data.forEach((item, index) => {
4
- const currentPath = [...path, index];
5
- if (item.text) {
6
- result.push({
7
- path_id: currentPath.join(","),
8
- text: item.text
9
- });
10
- }
11
- if (item.children) {
12
- result = result.concat(extractTextWithPath(item.children, currentPath));
13
- }
14
- });
15
- return result;
16
- }
17
- export function replaceTextPath(nestedJson, pathIdJson) {
18
- // Create a map from path_id JSON for quick lookup
19
- const pathIdMap = new Map(pathIdJson.map(item => [item.path_id, item.text]));
20
- console.log(pathIdMap);
21
- function extractTextWithPath(data, path = []) {
22
- data.forEach((item, index) => {
23
- const currentPath = [...path, index];
24
- if (item.text) {
25
- if (pathIdMap.has(currentPath?.join(","))) {
26
- item.text = pathIdMap.get(currentPath?.join(","));
27
- }
28
- }
29
- if (item.children) {
30
- extractTextWithPath(item.children, currentPath);
31
- }
32
- });
33
- }
34
- extractTextWithPath(nestedJson, []);
35
- return nestedJson;
36
- }
37
-
38
- // export function replaceTextPath(nestedJson, pathIdJson) {
39
- // // Create a map from path_id JSON for quick lookup
40
- // const pathIdMap = new Map(
41
- // pathIdJson.map((item) => [item.path_id, item.text])
42
- // );
43
-
44
- // function traverseAndReplace(node) {
45
- // if (Array.isArray(node)) {
46
- // node.forEach(traverseAndReplace);
47
- // } else if (typeof node === "object" && node !== null) {
48
- // console.log(node);
49
- // if (node.text && pathIdMap.has(node.text)) {
50
- // node.text = pathIdMap.get(node.path_id);
51
- // }
52
- // Object.values(node).forEach(traverseAndReplace);
53
- // }
54
- // }
55
-
56
- // traverseAndReplace(nestedJson);
57
- // return nestedJson;
58
- // }
@@ -1,153 +0,0 @@
1
- import { useSlate } from "slate-react";
2
- import { defaultTheme } from "../theme";
3
- import { getPageSettings, updatePageSettings } from "../utils/pageSettings";
4
- import { HEADING_THEME_FIELDS, PARAGRAPH_THEME_FIELDS } from "../helper/theme";
5
- import { useEditorContext } from "./useMouseMove";
6
- const MAP_FIELDS = {
7
- HEADING: HEADING_THEME_FIELDS,
8
- PARAGRAPH: PARAGRAPH_THEME_FIELDS
9
- };
10
- const MAP_FONT_FIELD_KEYS = {
11
- HEADING: "headingFontFamily",
12
- PARAGRAPH: "paragraphFontFamily"
13
- };
14
- function getUpdatePayload(prevTheme = {}, update, actionData) {
15
- const {
16
- action,
17
- fieldName
18
- } = actionData || {};
19
- const {
20
- theme: prev
21
- } = prevTheme;
22
- let theme = {};
23
- let themeProps = {};
24
- switch (action) {
25
- case "THEME_CHANGE":
26
- theme = update;
27
- break;
28
- case "CSS_VAR_CHANGE":
29
- const prevCssVars = prev?.cssVars || {};
30
- const prevValue = prevCssVars[fieldName] || {};
31
- themeProps = {
32
- ...(prev || {}),
33
- cssVars: {
34
- ...prevCssVars,
35
- [fieldName]: {
36
- ...prevValue,
37
- ...update
38
- }
39
- }
40
- };
41
- theme = {
42
- ...prevTheme,
43
- theme: themeProps
44
- };
45
- break;
46
- case "ELEMENT_PROPS_CHANGE":
47
- const prevEleProps = prev?.elementProps || {};
48
- const prevEleValue = prevEleProps[fieldName] || {};
49
- themeProps = {
50
- ...(prev || {}),
51
- elementProps: {
52
- ...prevEleProps,
53
- [fieldName]: {
54
- ...prevEleValue,
55
- ...update
56
- }
57
- }
58
- };
59
- theme = {
60
- ...prevTheme,
61
- theme: themeProps
62
- };
63
- break;
64
- case "OTHER_PROPS_CHANGE":
65
- themeProps = {
66
- ...(prev || {}),
67
- otherProps: {
68
- ...(prev.otherProps || {}),
69
- ...update
70
- }
71
- };
72
- theme = {
73
- ...prevTheme,
74
- theme: themeProps
75
- };
76
- break;
77
- case "FONT_CHANGE":
78
- const {
79
- elementProps = {},
80
- otherProps = {}
81
- } = prev;
82
- const {
83
- fieldType
84
- } = actionData || {};
85
- const fields = MAP_FIELDS[fieldType];
86
- const fontFieldsUpdate = {};
87
- fields?.forEach(field => {
88
- const prevFieldData = elementProps[field];
89
- fontFieldsUpdate[field] = {
90
- ...prevFieldData,
91
- ...update
92
- };
93
- });
94
- const FONT_KEY_FOR_FIELD = MAP_FONT_FIELD_KEYS[fieldType];
95
- themeProps = {
96
- ...(prev || {}),
97
- elementProps: {
98
- ...elementProps,
99
- ...fontFieldsUpdate
100
- },
101
- otherProps: {
102
- ...otherProps,
103
- [FONT_KEY_FOR_FIELD]: update?.fontFamily
104
- }
105
- };
106
- theme = {
107
- ...prevTheme,
108
- theme: themeProps
109
- };
110
- break;
111
- default:
112
- theme = {
113
- ...prevTheme,
114
- ...(update || {})
115
- };
116
- break;
117
- }
118
- return theme;
119
- }
120
- const updateTheme = (editor, pageSt, update, actionData, triggerRender) => {
121
- const {
122
- pageProps
123
- } = pageSt || {};
124
- const {
125
- theme
126
- } = pageProps || {};
127
- const updatedTheme = getUpdatePayload(theme, update, actionData);
128
- updatePageSettings(editor, {
129
- ...(pageProps || {}),
130
- theme: updatedTheme
131
- });
132
- triggerRender();
133
- };
134
- export const useEditorTheme = () => {
135
- const editor = useSlate();
136
- const {
137
- triggerRender
138
- } = useEditorContext();
139
- const {
140
- element: pageSt
141
- } = getPageSettings(editor) || {};
142
- const {
143
- pageProps
144
- } = pageSt || {};
145
- const {
146
- theme
147
- } = pageProps || {};
148
- return {
149
- selectedTheme: theme?.theme || defaultTheme?.theme,
150
- updateTheme: (update, actionData) => updateTheme(editor, pageSt, update, actionData, triggerRender),
151
- theme
152
- };
153
- };
@@ -1,63 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { getElementProperty } from "../helper/theme";
3
- import { ReactEditor } from "slate-react";
4
- import { Node } from "slate";
5
- import { useEditorTheme } from "./useEditorTheme";
6
- function useThemeValues() {
7
- return {};
8
- }
9
- export default useThemeValues;
10
- export function useButtonStyle(value, key, element) {
11
- const [buttonStyle, setButtonStyle] = useState(value);
12
- const {
13
- selectedTheme
14
- } = useEditorTheme();
15
- const themeBtnProps = selectedTheme?.elementProps?.button || {};
16
- useEffect(() => {
17
- const color = getColorValue(value, key, element, themeBtnProps);
18
- setButtonStyle({
19
- color
20
- });
21
- }, [value, key, element]);
22
- return {
23
- buttonStyle
24
- };
25
- }
26
- const DEFAULT_MAP_THEMES = {
27
- textColor: "color",
28
- bgColor: "backgroundColor"
29
- };
30
- const hoverMap = (theme, format) => {
31
- const hover = theme?.hover || {};
32
- const key = DEFAULT_MAP_THEMES[format];
33
- return hover[key];
34
- };
35
- const MAP_THEME_KEYS = {
36
- ...DEFAULT_MAP_THEMES,
37
- textColorHover: hoverMap,
38
- bgColorHover: hoverMap
39
- };
40
- const getColorValue = (val, key, elementProps, themeBtnProps) => {
41
- const themeKey = MAP_THEME_KEYS[key];
42
- if (elementProps?.type === "button" && !val && themeKey) {
43
- if (typeof themeKey === "string") {
44
- return themeBtnProps[themeKey];
45
- } else {
46
- return themeKey(themeBtnProps, key);
47
- }
48
- }
49
- return val;
50
- };
51
- export function getButtonElementStyle(editor, element, stylePropertyName) {
52
- try {
53
- const path = ReactEditor.findPath(editor, element);
54
- if (path?.length) {
55
- const currentEle = Node.get(editor, path);
56
- const dom = ReactEditor.toDOMNode(editor, currentEle);
57
- const editorBtn = dom?.querySelector(".button.theme-element");
58
- return getElementProperty(editorBtn, stylePropertyName);
59
- }
60
- } catch (err) {
61
- // console.log(err);
62
- }
63
- }
@@ -1,149 +0,0 @@
1
- import { getDevice } from "../helper/theme";
2
- const themeClassName = ".theme-element";
3
- function getTextStyles(props) {
4
- const {
5
- fontSize,
6
- textDecoration,
7
- color,
8
- ...rest
9
- } = props;
10
- const device = getDevice(window.innerWidth);
11
- const fontS = typeof fontSize === "object" ? fontSize[device] : fontSize;
12
- return {
13
- ...rest,
14
- '& span[data-slate-string="true"]': {
15
- textDecoration,
16
- fontSize: fontS,
17
- color: color || "inherit"
18
- }
19
-
20
- // "&::after": {
21
- // // for placeholder
22
- // fontSize,
23
- // },
24
- };
25
- }
26
-
27
- const transformHeading = (props, elementType) => {
28
- return {
29
- [`& ${elementType}${themeClassName}`]: getTextStyles(props)
30
- };
31
- };
32
- const transformParagraph = (props, paraType) => {
33
- return {
34
- [`& p${themeClassName}.${paraType}`]: getTextStyles(props)
35
- };
36
- };
37
- const transformButton = props => {
38
- const {
39
- borderRadius,
40
- lockRadius,
41
- bannerSpacing,
42
- buttonIcon,
43
- hover,
44
- ...classProps
45
- } = props;
46
- return {
47
- [`& .button${themeClassName}`]: {
48
- ...classProps,
49
- "&:hover": hover
50
- },
51
- buttonTheme: {
52
- borderRadius,
53
- lockRadius,
54
- bannerSpacing,
55
- buttonIcon
56
- }
57
- };
58
- };
59
- const transformProps = (elementType, props) => {
60
- let transformedProp = {};
61
- let otherProps = {};
62
- switch (elementType) {
63
- case "h1":
64
- case "h2":
65
- case "h3":
66
- case "h4":
67
- case "h5":
68
- case "h6":
69
- transformedProp = transformHeading(props, elementType);
70
- break;
71
- case "para1":
72
- case "para2":
73
- case "para3":
74
- transformedProp = transformParagraph(props, elementType);
75
- break;
76
- case "button":
77
- const {
78
- buttonTheme,
79
- ...classProps
80
- } = transformButton(props, elementType);
81
- transformedProp = classProps;
82
- otherProps = {
83
- buttonTheme
84
- };
85
- break;
86
- default:
87
- }
88
- return {
89
- transformedProp,
90
- otherProps
91
- };
92
- };
93
- export const transformTheme = (selectedTheme = {}) => {
94
- let sxProps = {};
95
- let others = {};
96
- const {
97
- elementProps
98
- } = selectedTheme;
99
- if (elementProps) {
100
- Object.entries(elementProps).forEach(([key, value]) => {
101
- const {
102
- transformedProp,
103
- otherProps
104
- } = transformProps(key, value);
105
- sxProps = {
106
- ...sxProps,
107
- ...transformedProp
108
- };
109
- others = {
110
- ...others,
111
- ...otherProps
112
- };
113
- });
114
- }
115
- return {
116
- sxProps,
117
- ...others
118
- };
119
- };
120
- export const defaultTheme = {
121
- theme: {
122
- cssVars: {},
123
- elementProps: {
124
- button: {
125
- color: "#FFFFFF",
126
- background: "#2563EB",
127
- fontFamily: "PoppinsRegular",
128
- fontWeight: 400,
129
- fontSize: "inherit",
130
- borderColor: "transparent",
131
- borderRadius: {
132
- topLeft: 30,
133
- topRight: 30,
134
- bottomLeft: 30,
135
- bottomRight: 30
136
- },
137
- bannerSpacing: {
138
- left: 16,
139
- top: 8,
140
- right: 16,
141
- bottom: 8
142
- }
143
- }
144
- }
145
- }
146
- };
147
- export function getTheme(selectedTheme) {
148
- return transformTheme(selectedTheme?.theme || defaultTheme.theme);
149
- }
@@ -1,82 +0,0 @@
1
- import { Grid, Link, Typography } from "@mui/material";
2
- import { useEditorTheme } from "../hooks/useEditorTheme";
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- import { jsxs as _jsxs } from "react/jsx-runtime";
5
- import { Fragment as _Fragment } from "react/jsx-runtime";
6
- function ActiveTheme(props) {
7
- const {
8
- onExplore
9
- } = props;
10
- const {
11
- theme
12
- } = useEditorTheme();
13
- const {
14
- colors = {}
15
- } = theme?.theme?.cssVars || {};
16
- const {
17
- id,
18
- name,
19
- mood_name = ""
20
- } = theme || {};
21
- const themeColors = Object.values(colors || {});
22
- return /*#__PURE__*/_jsxs(Grid, {
23
- className: "activeThemeInnner",
24
- children: [/*#__PURE__*/_jsx(Typography, {
25
- variant: "body1",
26
- className: "title activeThemeTitle",
27
- children: id ? "Active Theme" : "No theme activated"
28
- }), /*#__PURE__*/_jsx(Grid, {
29
- className: "flexAlign",
30
- children: id ? /*#__PURE__*/_jsxs(_Fragment, {
31
- children: [/*#__PURE__*/_jsx(Typography, {
32
- variant: "body1",
33
- className: "fs-14 flexItem",
34
- title: name,
35
- children: name
36
- }), /*#__PURE__*/_jsxs(Typography, {
37
- variant: "body2",
38
- className: "fs-12 textSecondary flexItem",
39
- style: {
40
- marginLeft: id ? "4px" : "0px"
41
- },
42
- children: ["- ", mood_name]
43
- })]
44
- }) : /*#__PURE__*/_jsx(Typography, {
45
- variant: "body2",
46
- className: "fs-12 textSecondary",
47
- style: {
48
- marginLeft: id ? "4px" : "0px"
49
- },
50
- children: `Select 'Explore More' to activate a theme and customize your design.`
51
- })
52
- }), /*#__PURE__*/_jsxs(Grid, {
53
- container: true,
54
- justifyContent: "space-between",
55
- alignItems: "end",
56
- sx: {
57
- mt: 1
58
- },
59
- children: [/*#__PURE__*/_jsx(Grid, {
60
- className: "flexAlign",
61
- sx: {
62
- gap: "10px"
63
- },
64
- children: id ? /*#__PURE__*/_jsx(_Fragment, {
65
- children: themeColors?.map((color, i) => {
66
- return /*#__PURE__*/_jsx(Grid, {
67
- className: "activeColorBox",
68
- style: {
69
- background: color
70
- }
71
- }, i);
72
- })
73
- }) : null
74
- }), onExplore && /*#__PURE__*/_jsx(Link, {
75
- className: "pointer fs-12 fw-500 exploreBtn",
76
- onClick: onExplore,
77
- children: "Explore More"
78
- })]
79
- })]
80
- });
81
- }
82
- export default ActiveTheme;