@flozy/editor 7.0.7 → 7.0.8

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 (129) hide show
  1. package/dist/Editor/ChatEditor.js +7 -7
  2. package/dist/Editor/CommonEditor.js +74 -25
  3. package/dist/Editor/DialogWrapper.js +31 -25
  4. package/dist/Editor/Editor.css +33 -16
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +2 -12
  6. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  7. package/dist/Editor/Elements/Button/EditorButton.js +26 -9
  8. package/dist/Editor/Elements/Color Picker/ColorButtons.js +57 -12
  9. package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
  10. package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
  11. package/dist/Editor/Elements/Color Picker/Styles.js +1 -1
  12. package/dist/Editor/Elements/DataView/DataView.js +4 -3
  13. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +5 -1
  14. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +5 -1
  15. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +23 -19
  16. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +1 -1
  17. package/dist/Editor/Elements/Embed/Image.js +2 -2
  18. package/dist/Editor/Elements/Form/Form.js +1 -0
  19. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +0 -14
  20. package/dist/Editor/Elements/FreeGrid/styles.js +4 -0
  21. package/dist/Editor/Elements/Grid/GridItem.js +2 -3
  22. package/dist/Editor/Elements/Link/Link.js +70 -43
  23. package/dist/Editor/Elements/List/CheckList.js +2 -1
  24. package/dist/Editor/Elements/Search/SearchAttachment.js +1 -0
  25. package/dist/Editor/Elements/Search/SearchList.js +8 -1
  26. package/dist/Editor/Elements/SimpleText/index.js +8 -1
  27. package/dist/Editor/Elements/SimpleText/style.js +5 -1
  28. package/dist/Editor/Elements/Table/Table.js +3 -3
  29. package/dist/Editor/Elements/Table/TableCell.js +14 -9
  30. package/dist/Editor/Elements/Title/title.js +13 -1
  31. package/dist/Editor/Elements/Variables/Style.js +28 -2
  32. package/dist/Editor/Elements/Variables/VariableButton.js +17 -4
  33. package/dist/Editor/MiniEditor.js +4 -2
  34. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
  35. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
  36. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  37. package/dist/Editor/Toolbar/FormatTools/TextSize.js +7 -15
  38. package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +46 -36
  39. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectAlignment.js +3 -1
  40. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +6 -13
  41. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +3 -1
  42. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +211 -91
  43. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +11 -4
  44. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +16 -12
  45. package/dist/Editor/Toolbar/PopupTool/TemplateCard.js +1 -1
  46. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +99 -7
  47. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +438 -0
  48. package/dist/Editor/Toolbar/PopupTool/index.js +2 -0
  49. package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
  50. package/dist/Editor/assets/svg/ThemeIcons.js +291 -0
  51. package/dist/Editor/common/ColorPickerButton.js +35 -9
  52. package/dist/Editor/common/CustomColorPicker/index.js +106 -0
  53. package/dist/Editor/common/CustomColorPicker/style.js +53 -0
  54. package/dist/Editor/common/CustomDialog/index.js +94 -0
  55. package/dist/Editor/common/CustomDialog/style.js +67 -0
  56. package/dist/Editor/common/CustomSelect.js +33 -0
  57. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  58. package/dist/Editor/common/DnD/Draggable.js +0 -1
  59. package/dist/Editor/common/FontLoader/FontList.js +1 -9
  60. package/dist/Editor/common/FontLoader/FontLoader.js +6 -4
  61. package/dist/Editor/common/Icon.js +28 -0
  62. package/dist/Editor/common/ImageSelector/Styles.js +3 -9
  63. package/dist/Editor/common/MentionsPopup/Styles.js +3 -9
  64. package/dist/Editor/common/MentionsPopup/index.js +0 -1
  65. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +2 -1
  66. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
  67. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
  68. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
  69. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
  70. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +4 -2
  71. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +3 -2
  72. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
  73. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +3 -2
  74. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +14 -2
  75. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
  76. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
  77. package/dist/Editor/common/RnD/Utils/gridDropItem.js +5 -4
  78. package/dist/Editor/common/RnD/Utils/index.js +40 -0
  79. package/dist/Editor/common/RnD/index.js +23 -3
  80. package/dist/Editor/common/Shorthands/elements.js +54 -0
  81. package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
  82. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
  83. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +12 -2
  84. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
  85. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
  86. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +35 -11
  87. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +13 -4
  88. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
  89. package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +79 -0
  90. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
  91. package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +4 -0
  92. package/dist/Editor/common/Uploader.js +8 -0
  93. package/dist/Editor/commonStyle.js +58 -63
  94. package/dist/Editor/helper/ensureWrappedVariables.js +28 -0
  95. package/dist/Editor/helper/index.js +2 -2
  96. package/dist/Editor/helper/theme.js +224 -3
  97. package/dist/Editor/hooks/useEditorTheme.js +153 -0
  98. package/dist/Editor/hooks/useMouseMove.js +13 -5
  99. package/dist/Editor/plugins/withEmbeds.js +1 -1
  100. package/dist/Editor/plugins/withHTML.js +4 -2
  101. package/dist/Editor/plugins/withLayout.js +1 -1
  102. package/dist/Editor/plugins/withTable.js +1 -1
  103. package/dist/Editor/theme/ThemeList.js +50 -173
  104. package/dist/Editor/theme/index.js +144 -0
  105. package/dist/Editor/themeSettings/ActiveTheme.js +72 -0
  106. package/dist/Editor/themeSettings/buttons/index.js +283 -0
  107. package/dist/Editor/themeSettings/buttons/style.js +21 -0
  108. package/dist/Editor/themeSettings/colorTheme/index.js +292 -0
  109. package/dist/Editor/themeSettings/colorTheme/style.js +77 -0
  110. package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
  111. package/dist/Editor/themeSettings/fonts/index.js +220 -0
  112. package/dist/Editor/themeSettings/fonts/style.js +44 -0
  113. package/dist/Editor/themeSettings/icons.js +60 -0
  114. package/dist/Editor/themeSettings/index.js +320 -0
  115. package/dist/Editor/themeSettings/style.js +152 -0
  116. package/dist/Editor/themeSettingsAI/icons.js +96 -0
  117. package/dist/Editor/themeSettingsAI/index.js +356 -0
  118. package/dist/Editor/themeSettingsAI/saveTheme.js +197 -0
  119. package/dist/Editor/themeSettingsAI/style.js +250 -0
  120. package/dist/Editor/utils/SlateUtilityFunctions.js +161 -42
  121. package/dist/Editor/utils/button.js +0 -14
  122. package/dist/Editor/utils/customHooks/useTableResize.js +2 -1
  123. package/dist/Editor/utils/draftToSlate.js +3 -2
  124. package/dist/Editor/utils/font.js +40 -37
  125. package/dist/Editor/utils/helper.js +88 -19
  126. package/dist/Editor/utils/link.js +1 -1
  127. package/dist/Editor/utils/pageSettings.js +14 -2
  128. package/dist/Editor/utils/table.js +21 -0
  129. package/package.json +5 -2
@@ -185,6 +185,9 @@ const SearchAndDocList = ({
185
185
  gap: 1,
186
186
  children: [/*#__PURE__*/_jsx(Grid, {
187
187
  item: true,
188
+ sx: {
189
+ maxWidth: 'calc(100% - 45px)'
190
+ },
188
191
  children: /*#__PURE__*/_jsxs(Grid, {
189
192
  container: true,
190
193
  alignItems: "center",
@@ -207,6 +210,9 @@ const SearchAndDocList = ({
207
210
  })
208
211
  }), /*#__PURE__*/_jsx(Grid, {
209
212
  item: true,
213
+ sx: {
214
+ maxWidth: '100%'
215
+ },
210
216
  children: /*#__PURE__*/_jsx(Typography, {
211
217
  sx: {
212
218
  fontSize: "12px",
@@ -219,7 +225,8 @@ const SearchAndDocList = ({
219
225
  maxWidth: '230px',
220
226
  textAlign: 'left',
221
227
  '@media only screen and (min-width: 350px) and (max-width: 899px)': {
222
- maxWidth: '100%'
228
+ maxWidth: '100%',
229
+ width: '100%'
223
230
  }
224
231
  },
225
232
  children: title
@@ -5,6 +5,7 @@ import { Box } from "@mui/material";
5
5
  import { isTextSelected } from "../../utils/helper";
6
6
  import { useEditorContext } from "../../hooks/useMouseMove";
7
7
  import SimpleTextStyle from "./style";
8
+ import { getBreakpointLineSpacing } from "../../helper/theme";
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
10
  import { Fragment as _Fragment } from "react/jsx-runtime";
10
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -28,8 +29,14 @@ const SimpleText = props => {
28
29
  } = customProps;
29
30
  // const { element: pageSt } = getPageSettings(editor) || {};
30
31
  // const { pageColor } = pageSt?.pageProps || {};
32
+ const {
33
+ activeBreakPoint
34
+ } = useEditorContext();
35
+ const lineHeight = element?.children[0]?.lineHeight;
36
+ const lineH = getBreakpointLineSpacing(lineHeight, activeBreakPoint);
31
37
  const classes = SimpleTextStyle({
32
- pageColor: "#FFFFFF"
38
+ pageColor: "#FFFFFF",
39
+ lineHeight: lineH
33
40
  });
34
41
  const selected = useSelected();
35
42
  const path = ReactEditor.findPath(editor, element);
@@ -1,10 +1,12 @@
1
1
  import { invertColor } from "../../helper";
2
2
  const SimpleTextStyle = ({
3
- pageColor
3
+ pageColor,
4
+ lineHeight
4
5
  }) => ({
5
6
  root: {
6
7
  position: "relative",
7
8
  padding: "0px",
9
+ lineHeight: lineHeight,
8
10
  "&.dataView": {
9
11
  "& .placeholder-simple-text": {
10
12
  opacity: 0
@@ -33,6 +35,8 @@ const SimpleTextStyle = ({
33
35
  height: "24px",
34
36
  overflow: "hidden",
35
37
  fontSize: "14px",
38
+ display: "inline-flex",
39
+ alignItems: "center",
36
40
  "& .bg-pad-sl": {
37
41
  padding: "2px 4px 2px 4px",
38
42
  background: "transparent",
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
2
2
  import { Editor, Transforms } from "slate";
3
3
  import { ReactEditor, useSelected, useSlateStatic } from "slate-react";
4
4
  import { Box, IconButton, Tooltip, Table as TableComp, TableBody, useTheme, Popper, ClickAwayListener } from "@mui/material";
5
- import { TableUtil } from "../../utils/table";
5
+ import { TableUtil, getTableColumns, getTableRows } from "../../utils/table";
6
6
  import TablePopup from "./TablePopup";
7
7
  import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
8
8
  import TableStyles from "./Styles";
@@ -206,7 +206,7 @@ const Table = props => {
206
206
  }
207
207
  }, theme);
208
208
  const addRow = () => {
209
- const lastRow = element?.rows - 1;
209
+ const lastRow = getTableRows(element) - 1;
210
210
  const firstCol = 0;
211
211
  const lastRowPath = [...path, lastRow, firstCol];
212
212
  const position = Editor.start(editor, lastRowPath);
@@ -221,7 +221,7 @@ const Table = props => {
221
221
  Transforms.deselect(editor);
222
222
  };
223
223
  const addCol = () => {
224
- const lastCol = element?.columns - 1;
224
+ const lastCol = getTableColumns(element) - 1;
225
225
  const firstRow = 0;
226
226
  const lastColumnPath = [...path, firstRow, lastCol];
227
227
  const position = Editor.start(editor, lastColumnPath);
@@ -50,6 +50,7 @@ const TableCell = props => {
50
50
  const {
51
51
  readOnly
52
52
  } = customProps;
53
+ const isMobile = window.matchMedia("(max-width: 899px)")?.matches || false;
53
54
  const {
54
55
  bgColor,
55
56
  borderColor,
@@ -247,20 +248,24 @@ const TableCell = props => {
247
248
  isDragging: false
248
249
  });
249
250
  };
250
- const tbProps = tableResizing || resizing || over || readOnly ? {
251
- ...commonTdProps,
252
- contentEditable: false
251
+ const eventProps = isMobile ? {
252
+ // mobile events for selection
253
+ onTouchStart: onMouseDownInCell,
254
+ onTouchMove: handleTouchMove,
255
+ onTouchEnd: handleTouchEnd
253
256
  } : {
254
- ...commonTdProps,
255
257
  onMouseEnter: () => onMouseEnter(path),
256
258
  onMouseLeave,
257
259
  onMouseDown: onMouseDownInCell,
258
260
  onMouseUp,
259
- onClick,
260
- // mobile events for selection
261
- onTouchStart: onMouseDownInCell,
262
- onTouchMove: handleTouchMove,
263
- onTouchEnd: handleTouchEnd
261
+ onClick
262
+ };
263
+ const tbProps = tableResizing || resizing || over || readOnly ? {
264
+ ...commonTdProps,
265
+ contentEditable: false
266
+ } : {
267
+ ...commonTdProps,
268
+ ...eventProps
264
269
  };
265
270
  const dndProps = {
266
271
  id: cellId,
@@ -1,12 +1,24 @@
1
1
  import React from "react";
2
+ import { Text } from "slate";
2
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
+ const isEmptyTextNode = node => {
5
+ if (Text.isText(node)) {
6
+ return !node.text.trim();
7
+ }
8
+ return false;
9
+ };
3
10
  const Title = props => {
4
11
  const {
12
+ element,
5
13
  attributes,
6
- children
14
+ children,
15
+ customProps
7
16
  } = props;
17
+ const isEmpty = !customProps?.readOnly && isEmptyTextNode(element?.children[0]) ? "empty" : "";
8
18
  return /*#__PURE__*/_jsx("div", {
9
19
  ...attributes,
20
+ placeholder: "Title",
21
+ className: `content-editable ${isEmpty}`,
10
22
  style: {
11
23
  fontWeight: "bold",
12
24
  fontSize: "20px"
@@ -1,4 +1,4 @@
1
- const VariableStyles = () => ({
1
+ const VariableStyles = theme => ({
2
2
  variablesItem: {
3
3
  color: "#2563EB",
4
4
  background: "#EEEEEE"
@@ -37,8 +37,34 @@ const VariableStyles = () => ({
37
37
  "& .MuiMenuItem-root": {
38
38
  color: "#64748B"
39
39
  },
40
+ "& .MuiPaper-root": {
41
+ borderRadius: '8px',
42
+ backgroundColor: `${theme?.palette?.editor?.miniToolBarBackground} !important`,
43
+ marginTop: '5px',
44
+ "@media only screen and (max-width: 599px)": {
45
+ padding: '10px 0px'
46
+ }
47
+ },
48
+ "& .MuiList-root": {
49
+ padding: '0px'
50
+ },
51
+ "& .MuiButtonBase-root": {
52
+ margin: '6px',
53
+ borderRadius: '8px',
54
+ padding: '6px 14px',
55
+ fontSize: '14px',
56
+ fontWeight: '400',
57
+ color: theme?.palette?.editor?.deletePopUpButtonTextColor,
58
+ "&:hover": {
59
+ background: `${theme?.palette?.editor?.menuOptionHoverBackground} !important`
60
+ },
61
+ "@media only screen and (max-width: 599px)": {
62
+ minHeight: '30px',
63
+ margin: '0px 6px'
64
+ }
65
+ },
40
66
  "& .Mui-selected": {
41
- backgroundColor: "rgba(0, 0, 0, 0.04) !important"
67
+ backgroundColor: 'unset !important'
42
68
  }
43
69
  }
44
70
  });
@@ -3,11 +3,15 @@ import { useSlateStatic } from "slate-react";
3
3
  import { MenuItem, Select } from "@mui/material";
4
4
  import { insertVariables } from "../../utils/variables";
5
5
  import VariableStyles from "./Style";
6
- import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
6
+ import KeyboardArrowDownRoundedIcon from '@mui/icons-material/KeyboardArrowDownRounded';
7
+ import { useEditorContext } from "../../hooks/useMouseMove";
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
10
  const VariableButton = props => {
10
- const classes = VariableStyles();
11
+ const {
12
+ theme
13
+ } = useEditorContext();
14
+ const classes = VariableStyles(theme);
11
15
  const editor = useSlateStatic();
12
16
  const {
13
17
  options
@@ -24,13 +28,14 @@ const VariableButton = props => {
24
28
  value: "",
25
29
  sx: classes.variableBtn,
26
30
  onChange: updateVariable,
27
- IconComponent: () => /*#__PURE__*/_jsx(KeyboardArrowDownIcon, {}),
31
+ IconComponent: () => /*#__PURE__*/_jsx(KeyboardArrowDownRoundedIcon, {}),
28
32
  MenuProps: {
29
33
  sx: classes.variableMenuItem,
30
34
  PaperProps: {
31
35
  style: {
32
36
  maxHeight: 300,
33
- overflowY: "auto"
37
+ overflowY: "auto",
38
+ transformOrigin: 'top left'
34
39
  },
35
40
  sx: {
36
41
  "&::-webkit-scrollbar-track": {
@@ -40,6 +45,14 @@ const VariableButton = props => {
40
45
  borderRadius: "16px"
41
46
  }
42
47
  }
48
+ },
49
+ anchorOrigin: {
50
+ vertical: 'bottom',
51
+ horizontal: 'right'
52
+ },
53
+ transformOrigin: {
54
+ vertical: 'top',
55
+ horizontal: 'right'
43
56
  }
44
57
  },
45
58
  children: [/*#__PURE__*/_jsx(MenuItem, {
@@ -11,6 +11,7 @@ import withCommon from "./hooks/withCommon";
11
11
  import { serializeToText } from "./utils/serializeToText";
12
12
  import "./Editor.css";
13
13
  import { EditorProvider } from "./hooks/useMouseMove";
14
+ import { ensureWrappedVariables } from "./helper/ensureWrappedVariables";
14
15
  import { jsx as _jsx } from "react/jsx-runtime";
15
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
17
  const MiniEditor = props => {
@@ -36,7 +37,8 @@ const MiniEditor = props => {
36
37
  needLayout: false
37
38
  }));
38
39
  const [isInteracted, setIsInteracted] = useState(false);
39
- const [value, setValue] = useState(content);
40
+ const updatedContent = ensureWrappedVariables(content);
41
+ const [value, setValue] = useState(ensureWrappedVariables(updatedContent));
40
42
  const [deboundedValue] = useDebounce(value, 500);
41
43
  const isReadOnly = readOnly === "readonly";
42
44
  const customProps = {
@@ -149,7 +151,7 @@ const MiniEditor = props => {
149
151
  theme: theme,
150
152
  children: /*#__PURE__*/_jsxs(Slate, {
151
153
  editor: editor,
152
- initialValue: content,
154
+ initialValue: updatedContent,
153
155
  onChange: onChange,
154
156
  children: [/*#__PURE__*/_jsx(BasicToolbar, {
155
157
  ...props,
@@ -1,8 +1,32 @@
1
1
  import React from "react";
2
2
  import { Select, MenuItem } from "@mui/material";
3
- import { addMarkData, activeMark } from "../../utils/SlateUtilityFunctions.js";
3
+ import { addMarkData, activeMark, getSelectedElementStyle } from "../../utils/SlateUtilityFunctions.js";
4
+ import { toolbarGroups } from "../toolbarGroups.js";
4
5
  import KeyboardArrowDownRoundedIcon from "@mui/icons-material/KeyboardArrowDownRounded";
6
+ import { googleFontList as defaultFonts } from "../../common/FontLoader/FontList.js";
5
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
+ const allTools = toolbarGroups.flat();
9
+ const fontWeight = allTools.find(f => f.format === "fontWeight");
10
+ export const getValue = (editor, format) => {
11
+ switch (format) {
12
+ case "fontFamily":
13
+ {
14
+ const style = getSelectedElementStyle("font-family", editor);
15
+ return style || defaultFonts[0];
16
+ }
17
+ case "fontWeight":
18
+ {
19
+ const {
20
+ options
21
+ } = fontWeight || {};
22
+ const fontWeightStyle = getSelectedElementStyle("font-weight", editor);
23
+ const selected = options?.find(o => o.value === fontWeightStyle || o.numVal === fontWeightStyle);
24
+ return selected?.value;
25
+ }
26
+ default:
27
+ return activeMark(editor, format);
28
+ }
29
+ };
6
30
  const Dropdown = ({
7
31
  classes,
8
32
  editor,
@@ -10,7 +34,7 @@ const Dropdown = ({
10
34
  options,
11
35
  width
12
36
  }) => {
13
- const value = activeMark(editor, format);
37
+ const value = getValue(editor, format);
14
38
  const changeMarkData = (event, format) => {
15
39
  event.preventDefault();
16
40
  const value = event.target.value;
@@ -20,7 +44,7 @@ const Dropdown = ({
20
44
  });
21
45
  };
22
46
  return /*#__PURE__*/_jsx(Select, {
23
- value: value,
47
+ value: value || options?.[0]?.value,
24
48
  className: "editor-dd",
25
49
  onChange: e => changeMarkData(e, format),
26
50
  MenuProps: {
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
2
  import { Autocomplete, TextField } from "@mui/material";
3
- import { activeMark, addMarkData } from "../../utils/SlateUtilityFunctions.js";
3
+ import { addMarkData } from "../../utils/SlateUtilityFunctions.js";
4
4
  import usePopupStyle from "../PopupTool/PopupToolStyle.js";
5
5
  import { useEditorContext } from "../../hooks/useMouseMove.js";
6
- import KeyboardArrowDownRoundedIcon from '@mui/icons-material/KeyboardArrowDownRounded';
6
+ import KeyboardArrowDownRoundedIcon from "@mui/icons-material/KeyboardArrowDownRounded";
7
+ import { getValue } from "./Dropdown.js";
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
9
  const FontFamilyAutocomplete = ({
9
10
  editor,
@@ -14,7 +15,7 @@ const FontFamilyAutocomplete = ({
14
15
  val = "",
15
16
  webFont = false
16
17
  }) => {
17
- const markValue = activeMark(editor, format);
18
+ const markValue = getValue(editor, format);
18
19
  const value = !webFont ? markValue : val;
19
20
  const changeMarkData = (event, newValue, format) => {
20
21
  if (!webFont) {
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import Icon from "../../common/Icon";
3
3
  import Button from "../../common/Button";
4
- import { toggleMark, isMarkActive } from "../../utils/SlateUtilityFunctions.js";
4
+ import { toggleMark, isMarkBtnActive } from "../../utils/SlateUtilityFunctions.js";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
6
  const MarkButton = ({
7
7
  editor,
@@ -9,7 +9,7 @@ const MarkButton = ({
9
9
  title
10
10
  }) => {
11
11
  return /*#__PURE__*/_jsx(Button, {
12
- active: isMarkActive(editor, format),
12
+ active: isMarkBtnActive(editor, format),
13
13
  format: format,
14
14
  onMouseDown: e => {
15
15
  e.preventDefault();
@@ -1,10 +1,7 @@
1
1
  import React, { useEffect, useRef, useState } from "react";
2
2
  import { TextField, IconButton } from "@mui/material";
3
- import { addMarkData, activeMark, isBlockActive } from "../../utils/SlateUtilityFunctions.js";
4
- import { headingMap, sizeMap } from "../../utils/font.js";
5
- import ExpandLessRoundedIcon from "@mui/icons-material/ExpandLessRounded";
6
- import ExpandMoreRoundedIcon from "@mui/icons-material/ExpandMoreRounded";
7
- import { getBreakPointsValue } from "../../helper/theme.js";
3
+ import { addMarkData, activeMark } from "../../utils/SlateUtilityFunctions.js";
4
+ import { getBreakPointsValue, getTextSizeVal } from "../../helper/theme.js";
8
5
  import useWindowResize from "../../hooks/useWindowResize.js";
9
6
  import { BREAKPOINTS_DEVICES } from "../../helper/theme.js";
10
7
  import { TextSizeDownArrow, TextSizeUpArrow } from "../../common/iconListV2.js";
@@ -17,11 +14,12 @@ const TextSize = ({
17
14
  format,
18
15
  fullWidth
19
16
  }) => {
20
- const [size] = useWindowResize();
21
- const val = activeMark(editor, format);
22
- const value = getBreakPointsValue(val, size?.device);
23
17
  const [fontSize, setFontSize] = useState();
24
18
  const timerRef = useRef();
19
+ const [size] = useWindowResize();
20
+ const val = activeMark(editor, format);
21
+ const noFontSize = val === "normal" || typeof val === "object" && !Object.keys(val)?.length;
22
+ const value = noFontSize ? getTextSizeVal(editor) : getBreakPointsValue(val, size?.device);
25
23
  useEffect(() => {
26
24
  setFontSize(getSizeVal());
27
25
  }, [value]);
@@ -57,13 +55,7 @@ const TextSize = ({
57
55
  };
58
56
  const getSizeVal = () => {
59
57
  try {
60
- let size = `${value}`?.indexOf("px") >= 0 ? value : sizeMap[value] || value;
61
- Object.entries(headingMap).forEach(([format, value]) => {
62
- if (isBlockActive(editor, format) && isNaN(parseInt(size))) {
63
- size = value;
64
- }
65
- });
66
- return parseInt(size);
58
+ return parseInt(value);
67
59
  } catch (err) {
68
60
  return "";
69
61
  }
@@ -3,16 +3,18 @@ import { Grid, Tabs, Tab, CircularProgress } from "@mui/material";
3
3
  import TemplateCard from "./TemplateCard";
4
4
  import FullViewCard from "./FullViewCard";
5
5
  import ButtonTemplateCard from "./ButtonTemplatesCard";
6
+
7
+ // const CATEGORIES_SORT_INDEX = {
8
+ // Brief: 1,
9
+ // Buttons: 2,
10
+ // Banners: 3,
11
+ // Tables: 4,
12
+ // Contract: 5,
13
+ // Proposal: 6,
14
+ // };
6
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { Fragment as _Fragment } from "react/jsx-runtime";
7
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
8
- const CATEGORIES_SORT_INDEX = {
9
- Brief: 1,
10
- Buttons: 2,
11
- Banners: 3,
12
- Tables: 4,
13
- Contract: 5,
14
- Proposal: 6
15
- };
16
18
  const Categories = props => {
17
19
  const {
18
20
  value,
@@ -46,7 +48,7 @@ const ProgressBar = ({
46
48
  alignItems: "center",
47
49
  margin: 0,
48
50
  padding: 0,
49
- height: "50px",
51
+ height: "300px",
50
52
  overflow: "hidden"
51
53
  },
52
54
  children: /*#__PURE__*/_jsx(CircularProgress, {})
@@ -69,41 +71,49 @@ const AddTemplates = props => {
69
71
  const [categories, setCategories] = useState([]);
70
72
  const [category, setCategory] = useState("");
71
73
  const [templates, setTemplates] = useState([]);
72
- const [filteredTemplates, setFilteredTemplates] = useState([]);
73
74
  useEffect(() => {
74
- getTemplatesList();
75
+ getCategoryList();
75
76
  }, []);
76
- const sortCategory = (a, b) => {
77
- return (CATEGORIES_SORT_INDEX[a] || Infinity) - (CATEGORIES_SORT_INDEX[b] || Infinity);
77
+ const getCategoryList = async () => {
78
+ setLoading(true);
79
+ const categoryDB = await services("listCategory");
80
+ if (categoryDB?.data?.Template?.length > 0) {
81
+ setCategories(categoryDB.data.Template);
82
+ setCategory(categoryDB.data.Template[0]);
83
+ getTemplatesList(categoryDB.data.Template[0]);
84
+ }
85
+ setLoading(false);
78
86
  };
79
- const getTemplatesList = async () => {
87
+ const getTemplatesList = async selectedCategory => {
80
88
  setLoading(true);
81
- const result = await services("listTemplates", {});
82
- const tempList = result?.data?.filter(f => f.type === "Template");
83
- const lic = tempList?.reduce((a, b) => {
84
- if (a.indexOf(b.category) < 0) {
85
- a.push(b.category);
86
- }
87
- return a;
88
- }, []).sort(sortCategory);
89
- const ft = tempList?.filter(f => f.category === lic[0]);
90
- setTemplates(tempList);
91
- setCategories(lic);
92
- setCategory(lic[0]);
93
- setFilteredTemplates(ft);
89
+ const result = await services("listTemplates", {
90
+ category: selectedCategory
91
+ });
92
+ setTemplates(result?.data || []);
94
93
  setLoading(false);
95
94
  };
96
95
  const handleChange = (event, newValue) => {
96
+ setTemplates([]);
97
97
  onSearch("");
98
98
  setCategory(newValue);
99
- setFilteredTemplates(templates.filter(f => f.category === newValue));
99
+ getTemplatesList(newValue);
100
100
  };
101
- const onSelectTemplate = card => () => {
101
+ const onSelectTemplate = card => async () => {
102
102
  try {
103
- editor.insertNode(JSON.parse(card.content));
103
+ const {
104
+ data
105
+ } = await services("templateContent", {
106
+ id: card?.id
107
+ });
108
+ const content = data?.content;
109
+ if (content) {
110
+ editor.insertNode(JSON.parse(content));
111
+ } else {
112
+ console.log("No data found");
113
+ }
104
114
  onClose();
105
115
  } catch (err) {
106
- console.log(err);
116
+ console.log("Error inserting template content into editor:", err);
107
117
  }
108
118
  };
109
119
  const filterByTitle = f => {
@@ -173,16 +183,16 @@ const AddTemplates = props => {
173
183
  data: categories,
174
184
  handleChange: handleChange
175
185
  })
176
- }), /*#__PURE__*/_jsxs(Grid, {
186
+ }), /*#__PURE__*/_jsx(Grid, {
177
187
  container: true,
178
188
  spacing: 0,
179
189
  className: `${fullScreen ? "fullscreen" : ""}`,
180
190
  sx: classes.templateCardsWrpr,
181
- children: [/*#__PURE__*/_jsx(ProgressBar, {
191
+ children: loading ? /*#__PURE__*/_jsx(ProgressBar, {
182
192
  loading: loading
183
- }), filteredTemplates.filter(filterByTitle).map(m => {
184
- return renderTemplate(m);
185
- })]
193
+ }) : /*#__PURE__*/_jsx(_Fragment, {
194
+ children: templates.filter(filterByTitle).map(renderTemplate)
195
+ })
186
196
  })]
187
197
  });
188
198
  };
@@ -51,7 +51,8 @@ const alignmentOptions = [{
51
51
  }];
52
52
  function SelectAlignment({
53
53
  editor,
54
- classes
54
+ classes,
55
+ closeMainPopup
55
56
  }) {
56
57
  const selected = useMemo(() => {
57
58
  return alignmentOptions.find(t => isBlockActive(editor, t.value));
@@ -59,6 +60,7 @@ function SelectAlignment({
59
60
  const onChange = (format, option) => {
60
61
  if (option.type === "block") {
61
62
  toggleBlock(editor, format);
63
+ closeMainPopup();
62
64
  }
63
65
  };
64
66
  return /*#__PURE__*/_jsx(CustomSelectTool, {
@@ -1,10 +1,9 @@
1
1
  import { useEffect, useRef, useState } from "react";
2
- import { activeMark, addMarkData, isBlockActive } from "../../../utils/SlateUtilityFunctions";
2
+ import { activeMark, addMarkData } from "../../../utils/SlateUtilityFunctions";
3
3
  import { Button, IconButton, Popover, TextField } from "@mui/material";
4
4
  import DownArrowIcon from "../../../assets/svg/DownArrowIcon";
5
5
  import useWindowResize from "../../../hooks/useWindowResize";
6
- import { BREAKPOINTS_DEVICES, getBreakPointsValue } from "../../../helper/theme";
7
- import { headingMap, sizeMap } from "../../../utils/font";
6
+ import { BREAKPOINTS_DEVICES, getBreakPointsValue, getTextSizeVal } from "../../../helper/theme";
8
7
  import { jsx as _jsx } from "react/jsx-runtime";
9
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
10
9
  const fontSizeOptions = [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 26, 32, 36, 40, 48, 64, 96, 128];
@@ -19,7 +18,7 @@ function SelectFontSize({
19
18
  const containerRef = useRef();
20
19
  const [size] = useWindowResize();
21
20
  const val = activeMark(editor, format);
22
- const value = getBreakPointsValue(val, size?.device);
21
+ const value = getTextSizeVal(editor);
23
22
  const timerRef = useRef();
24
23
  const updateMarkData = newVal => {
25
24
  let upData = {
@@ -53,13 +52,7 @@ function SelectFontSize({
53
52
  };
54
53
  const getSizeVal = () => {
55
54
  try {
56
- let size = `${value}`?.indexOf("px") >= 0 ? value : sizeMap[value] || value;
57
- Object.entries(headingMap).forEach(([format, value]) => {
58
- if (isBlockActive(editor, format) && isNaN(parseInt(size))) {
59
- size = value;
60
- }
61
- });
62
- return parseInt(size);
55
+ return parseInt(value);
63
56
  } catch (err) {
64
57
  return "";
65
58
  }
@@ -97,8 +90,8 @@ function SelectFontSize({
97
90
  anchorEl: anchorEl,
98
91
  onClose: () => setAnchorEl(null),
99
92
  anchorOrigin: {
100
- vertical: 'bottom',
101
- horizontal: 'left'
93
+ vertical: "bottom",
94
+ horizontal: "left"
102
95
  },
103
96
  sx: classes.customSelectPopoverWrapper,
104
97
  children: fontSizeOptions.map((s, i) => {
@@ -68,7 +68,8 @@ const listOptions = [{
68
68
  }];
69
69
  function SelectList({
70
70
  editor,
71
- classes
71
+ classes,
72
+ closeMainPopup
72
73
  }) {
73
74
  const selectedList = useMemo(() => {
74
75
  return listOptions.find(t => isBlockActive(editor, t.value));
@@ -79,6 +80,7 @@ function SelectList({
79
80
  } else if (option.type === "accordion") {
80
81
  insertAccordion(editor);
81
82
  }
83
+ closeMainPopup();
82
84
  };
83
85
  return /*#__PURE__*/_jsx(CustomSelectTool, {
84
86
  options: listOptions,