@flozy/editor 1.9.8 → 2.0.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 (31) hide show
  1. package/dist/Editor/CommonEditor.js +4 -6
  2. package/dist/Editor/DialogWrapper.js +10 -2
  3. package/dist/Editor/Editor.css +1 -2
  4. package/dist/Editor/Elements/Accordion/Accordion.js +13 -5
  5. package/dist/Editor/Elements/Accordion/AccordionSummary.js +3 -1
  6. package/dist/Editor/Elements/Button/EditorButton.js +43 -38
  7. package/dist/Editor/Elements/Embed/Image.js +4 -3
  8. package/dist/Editor/Elements/Form/Form.js +36 -3
  9. package/dist/Editor/Elements/Form/FormElements/FormEmail.js +59 -0
  10. package/dist/Editor/Elements/Form/FormElements/index.js +2 -1
  11. package/dist/Editor/Elements/Form/FormElements/validations.js +35 -0
  12. package/dist/Editor/Elements/Grid/Grid.js +4 -3
  13. package/dist/Editor/Elements/Grid/GridItem.js +3 -2
  14. package/dist/Editor/Elements/Signature/SignaturePopup.js +8 -3
  15. package/dist/Editor/Elements/Table/Table.js +4 -2
  16. package/dist/Editor/Elements/Table/TableCell.js +3 -1
  17. package/dist/Editor/Elements/TopBanner/TopBanner.js +2 -1
  18. package/dist/Editor/Styles/EditorStyles.js +22 -1
  19. package/dist/Editor/Toolbar/Mini/Styles.js +1 -1
  20. package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +12 -3
  21. package/dist/Editor/Toolbar/PopupTool/FullViewCard.js +4 -2
  22. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +7 -1
  23. package/dist/Editor/common/Icon.js +5 -3
  24. package/dist/Editor/common/Section/index.js +4 -2
  25. package/dist/Editor/common/StyleBuilder/fieldStyle.js +5 -0
  26. package/dist/Editor/common/StyleBuilder/index.js +1 -1
  27. package/dist/Editor/commonStyle.js +38 -0
  28. package/dist/Editor/hooks/useMouseMove.js +17 -1
  29. package/dist/Editor/utils/formfield.js +1 -0
  30. package/dist/Editor/utils/pageSettings.js +18 -0
  31. package/package.json +1 -1
@@ -13,7 +13,7 @@ import { mentionsEvent, commands, indentation, escapeEvent, enterEvent } from ".
13
13
  import withCommon from "./hooks/withCommon";
14
14
  import DialogWrapper from "./DialogWrapper";
15
15
  import { serializeToText } from "./utils/serializeToText";
16
- import { findPageSettings, getPageSettings } from "./utils/pageSettings";
16
+ import { focusOnFirstParagraph, getPageSettings } from "./utils/pageSettings";
17
17
  import { getThumbnailImage, invertColor } from "./helper";
18
18
  import PopupTool from "./Toolbar/PopupTool";
19
19
  import "./font.css";
@@ -25,7 +25,6 @@ import { EditorProvider } from "./hooks/useMouseMove";
25
25
  import TopBanner from "./Elements/TopBanner/TopBanner";
26
26
  import editorStyles from "./Styles/EditorStyles";
27
27
  import DragAndDrop from "./common/DnD";
28
- import DragHandle from "./common/DnD/DragHandle";
29
28
  import Section from "./common/Section";
30
29
  import "animate.css";
31
30
  import decorators from "./utils/Decorators";
@@ -139,10 +138,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
139
138
  setValue(draftToSlate({
140
139
  data: content
141
140
  }));
142
- Transforms.select(editor, {
143
- path: [0, 0],
144
- offset: 0
145
- });
141
+ focusOnFirstParagraph(editor);
146
142
  }, [id, content]);
147
143
  useEffect(() => {
148
144
  if (editorWrapper && editorWrapper?.current && JSON.stringify(loadedValue) !== JSON.stringify(deboundedValue) && isInteracted && onSave) {
@@ -342,7 +338,9 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
342
338
  };
343
339
  return /*#__PURE__*/_jsx(EditorProvider, {
344
340
  theme: theme,
341
+ editor: editor,
345
342
  children: /*#__PURE__*/_jsx(DialogWrapper, {
343
+ classes: classes,
346
344
  ...props,
347
345
  fullScreen: fullScreen,
348
346
  footer: footer || "",
@@ -9,7 +9,8 @@ const DialogWrapper = props => {
9
9
  const {
10
10
  fullScreen,
11
11
  onClose,
12
- children
12
+ children,
13
+ classes
13
14
  } = props;
14
15
  return fullScreen ? /*#__PURE__*/_jsxs(Dialog, {
15
16
  className: `dialogComp`,
@@ -19,7 +20,11 @@ const DialogWrapper = props => {
19
20
  style: {
20
21
  zIndex: 1000
21
22
  },
23
+ sx: classes.fullScreenWrapper,
22
24
  children: [/*#__PURE__*/_jsx(DialogTitle, {
25
+ style: {
26
+ padding: "6px 8px"
27
+ },
23
28
  children: /*#__PURE__*/_jsx(Grid, {
24
29
  children: /*#__PURE__*/_jsx(Grid, {
25
30
  style: {
@@ -28,13 +33,16 @@ const DialogWrapper = props => {
28
33
  },
29
34
  children: /*#__PURE__*/_jsx(IconButton, {
30
35
  onClick: onClose,
36
+ style: {
37
+ background: "rgba(255,255,255,0.5)"
38
+ },
31
39
  children: /*#__PURE__*/_jsx(CloseIcon, {})
32
40
  })
33
41
  })
34
42
  })
35
43
  }), /*#__PURE__*/_jsx(DialogContent, {
36
44
  style: {
37
- padding: "0px"
45
+ paddingTop: "12px"
38
46
  },
39
47
  children: children
40
48
  })]
@@ -32,7 +32,6 @@ blockquote {
32
32
  margin-left: 0;
33
33
  margin-right: 0;
34
34
  padding-left: 10px;
35
- color: #000;
36
35
  margin: 0px;
37
36
  }
38
37
 
@@ -182,7 +181,7 @@ blockquote {
182
181
 
183
182
  .no-border-button button,
184
183
  .no-border-button button:hover {
185
- border: none
184
+ border: none;
186
185
  }
187
186
 
188
187
  .grid-item {
@@ -2,10 +2,11 @@ import React, { useState } from "react";
2
2
  import { Transforms } from "slate";
3
3
  import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
4
4
  import AccordionBtnPopup from "./AccordionBtnPopup";
5
- import { IconButton, Tooltip } from "@mui/material";
5
+ import { IconButton, Tooltip, Box } from "@mui/material";
6
6
  import DeleteIcon from "@mui/icons-material/Delete";
7
7
  import { GridSettingsIcon } from "../../common/iconslist";
8
8
  import Icon from "../../common/Icon";
9
+ import { useEditorSelection } from "../../hooks/useMouseMove";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
11
12
  const Accordion = props => {
@@ -21,6 +22,7 @@ const Accordion = props => {
21
22
  const [toggle, setToggle] = useState(false);
22
23
  const [openSetttings, setOpenSettings] = useState(false);
23
24
  const editor = useSlateStatic();
25
+ const [showTool] = useEditorSelection(editor);
24
26
  const selected = useSelected();
25
27
  const path = ReactEditor.findPath(editor, element);
26
28
  const {
@@ -31,7 +33,7 @@ const Accordion = props => {
31
33
  setToggle(!toggle);
32
34
  };
33
35
  const ToolBar = () => {
34
- return selected ? /*#__PURE__*/_jsxs("div", {
36
+ return selected && !showTool ? /*#__PURE__*/_jsxs("div", {
35
37
  className: "element-toolbar hr",
36
38
  contentEditable: false,
37
39
  style: {
@@ -93,14 +95,20 @@ const Accordion = props => {
93
95
  style: {
94
96
  backgroundColor: bgColor
95
97
  },
96
- children: [/*#__PURE__*/_jsx(IconButton, {
98
+ onClick: onToggle,
99
+ children: [/*#__PURE__*/_jsx(Box, {
100
+ role: "button",
97
101
  className: "accordion-summary-collapse-btn",
98
- onClick: onToggle,
99
102
  contentEditable: false,
100
103
  sx: {
104
+ display: "flex",
105
+ alignItems: "center",
106
+ justifyContent: "center",
107
+ userSelect: "none",
101
108
  "& svg": {
102
109
  fill: textColor
103
- }
110
+ },
111
+ cursor: "pointer"
104
112
  },
105
113
  children: !toggle ? /*#__PURE__*/_jsx(Icon, {
106
114
  icon: "accordionArrow"
@@ -4,6 +4,7 @@ import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
4
4
  import AccordionTitlePopup from "./AccordionTitlePopup";
5
5
  import { IconButton, Tooltip } from "@mui/material";
6
6
  import { GridSettingsIcon } from "../../common/iconslist";
7
+ import { useEditorSelection } 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 AccordionSummary = props => {
@@ -18,6 +19,7 @@ const AccordionSummary = props => {
18
19
  } = customProps;
19
20
  const [openSetttings, setOpenSettings] = useState(false);
20
21
  const editor = useSlateStatic();
22
+ const [showTool] = useEditorSelection(editor);
21
23
  const selected = useSelected();
22
24
  const path = ReactEditor.findPath(editor, element);
23
25
  const {
@@ -26,7 +28,7 @@ const AccordionSummary = props => {
26
28
  borderColor
27
29
  } = element;
28
30
  const ToolBar = () => {
29
- return selected ? /*#__PURE__*/_jsx("div", {
31
+ return selected && !showTool ? /*#__PURE__*/_jsx("div", {
30
32
  className: "element-toolbar hr",
31
33
  contentEditable: false,
32
34
  style: {
@@ -154,46 +154,51 @@ const EditorButton = props => {
154
154
  style: {
155
155
  display: "inline"
156
156
  },
157
- children: /*#__PURE__*/_jsxs(Box, {
158
- component: "button",
159
- sx: {
160
- background: bgColor || "rgb(30, 75, 122)",
161
- borderBlockStyle: "solid",
162
- borderColor: borderColor || "transparent",
163
- borderWidth: borderWidth || "1px",
164
- borderRadius: `${topLeft}px ${topRight}px ${bottomLeft}px ${bottomRight}px`,
165
- borderStyle: borderStyle || "solid",
166
- padding: {
167
- ...getTRBLBreakPoints(bannerSpacing)
168
- },
169
- color: `${textColor || "#FFFFFF"}`,
170
- fontSize: textSize || "inherit",
171
- fontFamily: fontFamily || "PoppinsRegular",
172
- display: "inline-flex",
173
- alignItems: "center",
174
- position: "relative",
175
- "& .element-toolbar": {
176
- display: "none"
177
- },
178
- "&:hover": {
179
- color: `${textColorHover || textColor || "#FFFFFF"}`,
180
- background: bgColorHover || bgColor || "rgb(30, 75, 122)",
157
+ children: /*#__PURE__*/_jsxs("span", {
158
+ style: {
159
+ position: "relative"
160
+ },
161
+ children: [/*#__PURE__*/_jsxs(Box, {
162
+ component: "button",
163
+ sx: {
164
+ background: bgColor || "rgb(30, 75, 122)",
165
+ borderBlockStyle: "solid",
166
+ borderColor: borderColor || "transparent",
167
+ borderWidth: borderWidth || "1px",
168
+ borderRadius: `${topLeft}px ${topRight}px ${bottomLeft}px ${bottomRight}px`,
169
+ borderStyle: borderStyle || "solid",
170
+ padding: {
171
+ ...getTRBLBreakPoints(bannerSpacing)
172
+ },
173
+ color: `${textColor || "#FFFFFF"}`,
174
+ fontSize: textSize || "inherit",
175
+ fontFamily: fontFamily || "PoppinsRegular",
176
+ display: "inline-flex",
177
+ alignItems: "center",
178
+ position: "relative",
181
179
  "& .element-toolbar": {
182
- display: "block"
180
+ display: "none"
181
+ },
182
+ "&:hover": {
183
+ color: `${textColorHover || textColor || "#FFFFFF"}`,
184
+ background: bgColorHover || bgColor || "rgb(30, 75, 122)",
185
+ "& .element-toolbar": {
186
+ display: "block"
187
+ }
183
188
  }
184
- }
185
- },
186
- onClick: onClick,
187
- children: [BtnIcon && iconPosition === "start" && /*#__PURE__*/_jsx(BtnIcon, {
188
- style: {
189
- paddingLeft: "4px",
190
- paddingRight: "4px"
191
- }
192
- }), label || "My Button", BtnIcon && iconPosition === "end" && /*#__PURE__*/_jsx(BtnIcon, {
193
- style: {
194
- paddingLeft: "4px",
195
- paddingRight: "4px"
196
- }
189
+ },
190
+ onClick: onClick,
191
+ children: [BtnIcon && iconPosition === "start" && /*#__PURE__*/_jsx(BtnIcon, {
192
+ style: {
193
+ paddingLeft: "4px",
194
+ paddingRight: "4px"
195
+ }
196
+ }), label || "My Button", BtnIcon && iconPosition === "end" && /*#__PURE__*/_jsx(BtnIcon, {
197
+ style: {
198
+ paddingLeft: "4px",
199
+ paddingRight: "4px"
200
+ }
201
+ })]
197
202
  }), !readOnly && isTrigger ? /*#__PURE__*/_jsx(IconButton, {
198
203
  className: "workflow-icon-btn",
199
204
  children: /*#__PURE__*/_jsx(WorkflowIcon, {})
@@ -6,7 +6,7 @@ import useResize from "../../utils/customHooks/useResize";
6
6
  import EmbedPopup from "./EmbedPopup";
7
7
  import { IconButton, Tooltip, Box } from "@mui/material";
8
8
  import { GridSettingsIcon } from "../../common/iconslist";
9
- import { useEditorContext } from "../../hooks/useMouseMove";
9
+ import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
10
10
  import { getTRBLBreakPoints, getBreakPointsValue } from "../../helper/theme";
11
11
  import Icon from "../../common/Icon";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -48,6 +48,7 @@ const Image = ({
48
48
  const [parentDOM, setParentDOM] = useState(null);
49
49
  const [openSetttings, setOpenSettings] = useState(false);
50
50
  const path = ReactEditor.findPath(editor, element);
51
+ const [showTool] = useEditorSelection(editor);
51
52
  const getSize = () => {
52
53
  if (element?.size === undefined) {
53
54
  return {
@@ -111,7 +112,7 @@ const Image = ({
111
112
  });
112
113
  };
113
114
  const ToolBar = () => {
114
- return selected ? /*#__PURE__*/_jsx("div", {
115
+ return selected && !showTool ? /*#__PURE__*/_jsx("div", {
115
116
  className: "element-toolbar visible-on-hover",
116
117
  contentEditable: false,
117
118
  children: /*#__PURE__*/_jsx(Tooltip, {
@@ -154,7 +155,7 @@ const Image = ({
154
155
  } else {
155
156
  return {
156
157
  width: url ? {
157
- ...getBreakPointsValue(element?.size, null, "overrideReSize", true)
158
+ ...getBreakPointsValue(getSize(), null, "overrideReSize", true)
158
159
  } : "100%"
159
160
  };
160
161
  }
@@ -12,6 +12,7 @@ import { formSubmit } from "../../service/formSubmit";
12
12
  import formButtonStyle from "../../common/StyleBuilder/formButtonStyle";
13
13
  import Workflow from "./Workflow";
14
14
  import { getTRBLBreakPoints } from "../../helper/theme";
15
+ import { validation } from "./FormElements/validations";
15
16
  import { jsx as _jsx } from "react/jsx-runtime";
16
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
18
  const Form = props => {
@@ -40,7 +41,6 @@ const Form = props => {
40
41
  fontFamily,
41
42
  textAlign
42
43
  } = element;
43
- const isEmail = element?.children[0].element === "email";
44
44
  const {
45
45
  topLeft,
46
46
  topRight,
@@ -66,6 +66,9 @@ const Form = props => {
66
66
  } : {
67
67
  borderColor: buttonProps?.borderColor || "none"
68
68
  };
69
+ const getFieldProps = (key = '', val = '') => {
70
+ return element?.children?.find(obj => obj && obj[key] === val);
71
+ };
69
72
  const handleSubmit = async (event, test = false) => {
70
73
  if (event) {
71
74
  event.preventDefault();
@@ -74,7 +77,29 @@ const Form = props => {
74
77
  const formData = new FormData(formEle?.current);
75
78
  setLoading(true);
76
79
  let response = {};
80
+ const emailObject = getFieldProps('field_type', 'email');
81
+ let user_email = '';
82
+ const validations = [];
77
83
  for (let pair of formData.entries()) {
84
+ if (emailObject?.name === pair[0]) {
85
+ user_email = pair[1];
86
+ }
87
+ const fieldData = getFieldProps('name', pair[0]);
88
+ let rule = [];
89
+ if (fieldData?.required) {
90
+ rule.push(`isRequired`);
91
+ }
92
+ if (fieldData?.field_type === "email") {
93
+ rule.push(`isEmail`);
94
+ }
95
+ if (fieldData?.required || fieldData?.field_type === 'email') {
96
+ validations.push({
97
+ name: pair[0],
98
+ value: pair[1],
99
+ field_type: fieldData?.field_type,
100
+ rules: rule && rule
101
+ });
102
+ }
78
103
  response = {
79
104
  ...response,
80
105
  [pair[0]]: pair[1]
@@ -83,14 +108,22 @@ const Form = props => {
83
108
  let params = {
84
109
  page_id: page_id,
85
110
  form_id: `${formName}`,
86
- response,
111
+ response: {
112
+ ...response
113
+ },
87
114
  form_data: {
115
+ user_email: user_email,
88
116
  email: element?.email,
89
117
  form_workflow: element?.workflow,
90
118
  save_response: element?.saveResponse
91
119
  }
92
120
  };
93
- await formSubmit(params, customProps);
121
+ const isValidForm = validations.length !== 0 && validation(validations);
122
+ if (isValidForm) {
123
+ alert(isValidForm[0]);
124
+ } else {
125
+ await formSubmit(params, customProps);
126
+ }
94
127
  setLoading(false);
95
128
  }
96
129
  };
@@ -0,0 +1,59 @@
1
+ import React from "react";
2
+ import { getTRBLBreakPoints } from "../../../helper/theme";
3
+ import { Box } from "@mui/material";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const FormEmail = props => {
6
+ const {
7
+ fieldProps
8
+ } = props;
9
+ const {
10
+ bannerSpacing,
11
+ height,
12
+ borderRadius,
13
+ borderStyle,
14
+ borderWidth,
15
+ borderColor,
16
+ textColor,
17
+ bgColor,
18
+ lockSpacing,
19
+ ...rest
20
+ } = fieldProps;
21
+ const {
22
+ topLeft,
23
+ topRight,
24
+ bottomLeft,
25
+ bottomRight
26
+ } = borderRadius || {};
27
+ const onChange = e => {
28
+ e.preventDefault();
29
+ };
30
+ return /*#__PURE__*/_jsx("div", {
31
+ style: {
32
+ width: "100%",
33
+ display: "flex"
34
+ },
35
+ contentEditable: false,
36
+ children: /*#__PURE__*/_jsx(Box, {
37
+ component: "input",
38
+ type: "email",
39
+ required: true,
40
+ ...rest,
41
+ onChange: onChange,
42
+ sx: {
43
+ width: "100%",
44
+ border: `1px solid ${borderColor || "#FFF"}`,
45
+ padding: {
46
+ ...getTRBLBreakPoints(bannerSpacing)
47
+ },
48
+ height: height || "auto",
49
+ borderColor: borderColor || "transparent",
50
+ borderWidth: borderWidth || "1px",
51
+ borderRadius: `${topLeft}px ${topRight}px ${bottomLeft}px ${bottomRight}px`,
52
+ borderStyle: borderStyle || "solid",
53
+ color: textColor || "#000",
54
+ background: bgColor || "transparent"
55
+ }
56
+ })
57
+ });
58
+ };
59
+ export default FormEmail;
@@ -1,8 +1,9 @@
1
+ import FormEmail from "./FormEmail";
1
2
  import FormText from "./FormText";
2
3
  import FormTextArea from "./FormTextArea";
3
4
  const FormElements = {
4
5
  text: FormText,
5
6
  textArea: FormTextArea,
6
- email: FormText
7
+ email: FormEmail
7
8
  };
8
9
  export default FormElements;
@@ -0,0 +1,35 @@
1
+ import { bool } from "prop-types";
2
+ export const validationMethods = {
3
+ isEmail: value => {
4
+ const regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
5
+ const result = regex.test(String(value).toLowerCase());
6
+ if (result) {
7
+ let domain = String(value).toLowerCase().split('@')[1];
8
+ let validExtensions = ['com', 'net', 'org', 'edu'];
9
+ let extension = domain.split('.').pop();
10
+ if (validExtensions.includes(extension)) {
11
+ return "";
12
+ } else {
13
+ return "Enter valid email address";
14
+ }
15
+ } else {
16
+ return "Enter valid email address";
17
+ }
18
+ },
19
+ isRequired: value => {
20
+ return value === '' ? "Required fields should not be empty" : "";
21
+ }
22
+ };
23
+ export const validation = fields => {
24
+ let validated = [];
25
+ let filedValue = [];
26
+ fields.map(field => {
27
+ let val = field.rules.map(vm => {
28
+ return validationMethods[vm](field["value"]);
29
+ });
30
+ return filedValue.push(...val);
31
+ });
32
+ validated.push(...filedValue);
33
+ validated = validated.filter(val => val !== "");
34
+ return validated.length === 0 ? false : validated;
35
+ };
@@ -11,7 +11,7 @@ import { GridAddGridIcon, GridAddSectionIcon, GridSettingsIcon } from "../../com
11
11
  import GridPopup from "./GridPopup";
12
12
  import SectionPopup from "./SectionPopup";
13
13
  import { gridItem } from "../../utils/gridItem";
14
- import { useEditorContext } from "../../hooks/useMouseMove";
14
+ import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
15
15
  import { getTRBLBreakPoints, getBreakPointsValue } from "../../helper/theme";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -62,6 +62,7 @@ const Grid = props => {
62
62
  hoverPath
63
63
  } = useEditorContext();
64
64
  const selected = hoverPath === path.join(",");
65
+ const [showTool] = useEditorSelection(editor);
65
66
  const onAddGridItem = () => {
66
67
  const currentPath = editor.selection?.anchor?.path;
67
68
  const ancestorsPath = Path.ancestors(currentPath, {
@@ -174,7 +175,7 @@ const Grid = props => {
174
175
  };
175
176
  const PoupComp = GridSettingsPoupComp[openSetttings];
176
177
  const NewLineButtons = () => {
177
- return !readOnly && selected && path.length === 2 ? /*#__PURE__*/_jsxs(_Fragment, {
178
+ return !readOnly && selected && path.length === 2 && !showTool ? /*#__PURE__*/_jsxs(_Fragment, {
178
179
  children: [/*#__PURE__*/_jsx("div", {
179
180
  className: "element-selector-ctrl tc",
180
181
  children: /*#__PURE__*/_jsx(Tooltip, {
@@ -199,7 +200,7 @@ const Grid = props => {
199
200
  }) : null;
200
201
  };
201
202
  const GridToolBar = () => {
202
- return selected ? /*#__PURE__*/_jsxs("div", {
203
+ return selected && !showTool ? /*#__PURE__*/_jsxs("div", {
203
204
  className: "grid-container-toolbar",
204
205
  contentEditable: false,
205
206
  children: [/*#__PURE__*/_jsx(Tooltip, {
@@ -5,7 +5,7 @@ import { useSlateStatic, ReactEditor } from "slate-react";
5
5
  import GridItemPopup from "./GridItemPopup";
6
6
  import { IconButton, Tooltip, Box, Grid as Item } from "@mui/material";
7
7
  import { GridSettingsIcon } from "../../common/iconslist";
8
- import { useEditorContext } from "../../hooks/useMouseMove";
8
+ import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
9
9
  import { getBreakPointsValue, getTRBLBreakPoints } from "../../helper/theme";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -53,8 +53,9 @@ const GridItem = props => {
53
53
  hoverPath
54
54
  } = useEditorContext();
55
55
  const selected = hoverPath === path.join(",");
56
+ const [showTool] = useEditorSelection(editor);
56
57
  const GridItemToolbar = () => {
57
- return selected ? /*#__PURE__*/_jsx("div", {
58
+ return selected && !showTool ? /*#__PURE__*/_jsx("div", {
58
59
  contentEditable: false,
59
60
  className: "grid-item-toolbar",
60
61
  style: {
@@ -6,13 +6,17 @@ import "react-datepicker/dist/react-datepicker.css";
6
6
  import SignatureOptions from "./SignatureOptions";
7
7
  import "./Signature.css";
8
8
  import { DrawSignature, PencilIcon, TypeSignature, UploadSignature } from "../../common/EditorIcons";
9
- import CommonStyle from "../../commonStyle";
10
- import { styled } from "@mui/material/styles";
9
+ import useCommonStyle from "../../commonStyle";
10
+ import { useEditorContext } from "../../hooks/useMouseMove";
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
14
14
  const BrushSizes = [1, 5, 7];
15
15
  const SignaturePopup = props => {
16
+ const {
17
+ theme
18
+ } = useEditorContext();
19
+ const classes = useCommonStyle(theme);
16
20
  const {
17
21
  onSave,
18
22
  onClear,
@@ -110,6 +114,7 @@ const SignaturePopup = props => {
110
114
  open: open,
111
115
  onClose: handleClose,
112
116
  fullWidth: true,
117
+ sx: classes.signaturePopup,
113
118
  children: /*#__PURE__*/_jsx(Grid, {
114
119
  container: true,
115
120
  children: /*#__PURE__*/_jsxs(Grid, {
@@ -370,4 +375,4 @@ const SignaturePopup = props => {
370
375
  };
371
376
 
372
377
  // export default SignaturePopup;
373
- export default styled(SignaturePopup)(CommonStyle);
378
+ export default SignaturePopup;
@@ -13,8 +13,9 @@ import DeleteCellIcon from "./DeleteCellIcon";
13
13
  import DeleteRowIcon from "./DeleteRowIcon";
14
14
  import { TableUtil } from "../../utils/table";
15
15
  import TablePopup from "./TablePopup";
16
- import "./table.css";
16
+ import { useEditorSelection } from "../../hooks/useMouseMove";
17
17
  import TableStyles from "./Styles";
18
+ import "./table.css";
18
19
  import { jsx as _jsx } from "react/jsx-runtime";
19
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
20
21
  const TABLE_MENUS = [{
@@ -91,6 +92,7 @@ const Table = props => {
91
92
  const selected = useSelected();
92
93
  const table = new TableUtil(editor);
93
94
  const tableProps = table.getTableProps();
95
+ const [showTool] = useEditorSelection(editor);
94
96
  const handleAction = ({
95
97
  type,
96
98
  position
@@ -125,7 +127,7 @@ const Table = props => {
125
127
  setExpandTools(!exandTools);
126
128
  };
127
129
  const ToolBar = () => {
128
- return selected ? /*#__PURE__*/_jsxs(Box, {
130
+ return selected && !showTool ? /*#__PURE__*/_jsxs(Box, {
129
131
  component: "div",
130
132
  contentEditable: false,
131
133
  className: `tableToolBar ${exandTools ? "active" : ""}`,
@@ -5,6 +5,7 @@ import { useSlateStatic, ReactEditor } from "slate-react";
5
5
  import useTableResize from "../../utils/customHooks/useTableResize";
6
6
  import { TableUtil } from "../../utils/table";
7
7
  import TableStyles from "./Styles";
8
+ import { useEditorSelection } from "../../hooks/useMouseMove";
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";
@@ -45,6 +46,7 @@ const TableCell = props => {
45
46
  } = element;
46
47
  const [parentDOM, setParentDOM] = useState(null);
47
48
  const editor = useSlateStatic();
49
+ const [showTool] = useEditorSelection(editor);
48
50
  const path = ReactEditor.findPath(editor, element);
49
51
  const isHeader = path.length >= 2 ? path[path.length - 2] === 0 : false;
50
52
  const [size, onMouseDown, resizing, onLoad] = useTableResize({
@@ -119,7 +121,7 @@ const TableCell = props => {
119
121
  border: `3px solid ${cellBorderColor}`,
120
122
  ...(sizeProps || {})
121
123
  },
122
- children: [children, isHeader && !readOnly && tableSize?.height ? /*#__PURE__*/_jsx(Resizer, {
124
+ children: [children, isHeader && !readOnly && tableSize?.height && !showTool ? /*#__PURE__*/_jsx(Resizer, {
123
125
  classes: classes,
124
126
  onMouseDown: onMouseDown,
125
127
  height: tableSize?.height
@@ -73,7 +73,7 @@ const TopBanner = props => {
73
73
  ...attributes,
74
74
  style: {
75
75
  position: "relative",
76
- height: "280px",
76
+ height: "296px",
77
77
  textAlign: "center"
78
78
  },
79
79
  contentEditable: false,
@@ -81,6 +81,7 @@ const TopBanner = props => {
81
81
  children: [/*#__PURE__*/_jsx("img", {
82
82
  src: url,
83
83
  alt: "Top Banner",
84
+ className: "top-banner-wrpr-ele",
84
85
  style: {
85
86
  width: "100%",
86
87
  height: "280px",
@@ -28,9 +28,19 @@ const editorStyles = ({
28
28
  flexDirection: "column",
29
29
  alignItems: "center",
30
30
  color: "#0f172a",
31
+ "& .has-topbanner": {
32
+ "& .doc-title-ele-wrpr": {
33
+ marginTop: "12px"
34
+ }
35
+ },
31
36
  "&.no-color": {
32
37
  backgroundColor: theme?.palette?.editor?.background,
33
- color: theme?.palette?.editor?.textColor
38
+ color: theme?.palette?.editor?.textColor,
39
+ "& .signed-btn": {
40
+ "& img": {
41
+ backgroundColor: "#FFF"
42
+ }
43
+ }
34
44
  },
35
45
  "& .max-content": {
36
46
  width: "100%",
@@ -201,6 +211,17 @@ const editorStyles = ({
201
211
  textAlign: "center",
202
212
  border: "1px solid #CFD8F5"
203
213
  }
214
+ },
215
+ fullScreenWrapper: {
216
+ "& .MuiPaper-root": {
217
+ borderRadius: "0px !important",
218
+ "& .MuiDialogTitle-root": {
219
+ position: "absolute",
220
+ top: 0,
221
+ right: "12px",
222
+ zIndex: 100
223
+ }
224
+ }
204
225
  }
205
226
  });
206
227
  export default editorStyles;
@@ -32,7 +32,7 @@ const miniToolbarStyles = theme => ({
32
32
  borderColor: theme?.palette?.editor?.borderColor,
33
33
  "& button": {
34
34
  "& svg": {
35
- stroke: theme?.palette?.editor?.textColor
35
+ stroke: theme?.palette?.editor?.svgStroke
36
36
  },
37
37
  "&.active": {
38
38
  "& svg": {
@@ -107,8 +107,8 @@ const AddTemplates = props => {
107
107
  case "Starter":
108
108
  case "Proposal":
109
109
  case "Page":
110
+ case "Brief":
110
111
  case "Contract":
111
- case "404 Page":
112
112
  return /*#__PURE__*/_jsx(TemplateCard, {
113
113
  classes: classes,
114
114
  onSelectTemplate: onSelectTemplate,
@@ -128,10 +128,19 @@ const AddTemplates = props => {
128
128
  classes: classes,
129
129
  onSelectTemplate: onSelectTemplate,
130
130
  m: mapData,
131
- fullScreen: fullScreen
131
+ fullScreen: fullScreen,
132
+ height: "smallCard"
133
+ }, `template_Card_${mapData.id}_popup`);
134
+ case "404 Page":
135
+ return /*#__PURE__*/_jsx(FullViewCard, {
136
+ classes: classes,
137
+ onSelectTemplate: onSelectTemplate,
138
+ m: mapData,
139
+ fullScreen: fullScreen,
140
+ height: "mediumCard"
132
141
  }, `template_Card_${mapData.id}_popup`);
133
142
  default:
134
- /*#__PURE__*/_jsx(TemplateCard, {
143
+ return /*#__PURE__*/_jsx(TemplateCard, {
135
144
  classes: classes,
136
145
  onSelectTemplate: onSelectTemplate,
137
146
  m: mapData,
@@ -26,7 +26,8 @@ const FullViewCard = props => {
26
26
  const {
27
27
  classes,
28
28
  m,
29
- onSelectTemplate
29
+ onSelectTemplate,
30
+ height = 'smallCard'
30
31
  } = props;
31
32
  return /*#__PURE__*/_jsx(Grid, {
32
33
  item: true,
@@ -40,7 +41,8 @@ const FullViewCard = props => {
40
41
  component: "div",
41
42
  image: m?.thumbnail,
42
43
  alt: m?.title,
43
- sx: classes.fullViewCardMedia
44
+ sx: classes.fullViewCardMedia,
45
+ className: height
44
46
  }), /*#__PURE__*/_jsx(Select, {
45
47
  classes: classes,
46
48
  onSelectTemplate: onSelectTemplate,
@@ -376,13 +376,19 @@ const usePopupStyle = theme => ({
376
376
  },
377
377
  fullViewCardMedia: {
378
378
  width: "100%",
379
- height: "130px",
380
379
  backgroundPosition: "left top",
381
380
  backgroundSize: "100% auto",
382
381
  zIndex: 1,
383
382
  position: "relative",
384
383
  "&.fullscreen": {
385
384
  height: "130px"
385
+ },
386
+ "&.smallCard": {
387
+ height: "130px"
388
+ },
389
+ "&.mediumCard": {
390
+ height: "250px",
391
+ boxShadow: "0px 1px 3px 3px rgba(0,0,0,0.12)"
386
392
  }
387
393
  },
388
394
  buttonCardMedia: {
@@ -6,8 +6,10 @@ import { FcAddRow, FcAddColumn } from "react-icons/fc";
6
6
  import { AiFillEdit, AiOutlineInsertRowBelow, AiOutlineInsertRowRight, AiOutlineDelete, AiFillTag, AiOutlineUpload, AiOutlineArrowsAlt, AiOutlineInsertRowAbove, AiOutlineInsertRowLeft, AiFillHtml5 } from "react-icons/ai";
7
7
  import { SiLatex } from "react-icons/si";
8
8
  import { RiDeleteColumn, RiDeleteRow } from "react-icons/ri";
9
- import { IoIosImage, IoMdArrowDroprightCircle, IoMdArrowDropdownCircle } from "react-icons/io";
9
+ import { IoIosImage } from "react-icons/io";
10
10
  import { GridIcon, AccordionIcon, SignatureIcon, ButtonIcon, Carousal, FormIcon, BoldIcon, FontFamilyIcon, FontSizeIcon, ImageIcon, ItalicIcon, LinkIcon, StrikethroughIcon, TableIcon, UnderLineIcon, VideoIcon, CheckboxIcon, AppHeader, MoreHorizontal, UploadImage, DocsUpload, LeftArrow, RightArrow, CheckListButton, CheckListButtonActive, ExcelIcon, CsvIcon, DividerIcon } from "./iconslist";
11
+ import ArrowRightIcon from '@mui/icons-material/ArrowRight';
12
+ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
11
13
  import { jsx as _jsx } from "react/jsx-runtime";
12
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
15
  const iconList = {
@@ -175,10 +177,10 @@ const iconList = {
175
177
  media: /*#__PURE__*/_jsx(MdOutlinePermMedia, {
176
178
  size: 20
177
179
  }),
178
- accordionArrow: /*#__PURE__*/_jsx(IoMdArrowDroprightCircle, {
180
+ accordionArrow: /*#__PURE__*/_jsx(ArrowRightIcon, {
179
181
  size: 20
180
182
  }),
181
- accordionArrowDown: /*#__PURE__*/_jsx(IoMdArrowDropdownCircle, {
183
+ accordionArrowDown: /*#__PURE__*/_jsx(ArrowDropDownIcon, {
182
184
  size: 20
183
185
  }),
184
186
  appHeader: /*#__PURE__*/_jsx(AppHeader, {}),
@@ -6,6 +6,7 @@ import TuneIcon from "@mui/icons-material/Tune";
6
6
  import SectionPopup from "../../Elements/Grid/SectionPopup";
7
7
  import { getBreakPointsValue, getTRBLBreakPoints } from "../../helper/theme";
8
8
  import DragHandle from "../DnD/DragHandleButton";
9
+ import { useEditorSelection } from "../../hooks/useMouseMove";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
11
12
  const SectionStyle = () => ({
@@ -33,6 +34,7 @@ const Section = props => {
33
34
  readOnly
34
35
  } = customProps;
35
36
  const editor = useSlateStatic();
37
+ const [showTool] = useEditorSelection(editor);
36
38
  const [openSetttings, setOpenSettings] = useState(false);
37
39
  const {
38
40
  sectionBgColor,
@@ -58,7 +60,7 @@ const Section = props => {
58
60
  setOpenSettings(true);
59
61
  };
60
62
  const Toolbar = () => {
61
- return !readOnly ? /*#__PURE__*/_jsx(Box, {
63
+ return !readOnly && !showTool ? /*#__PURE__*/_jsx(Box, {
62
64
  component: "div",
63
65
  className: "element-toolbar no-border-button ss hr section-tw",
64
66
  style: {
@@ -121,7 +123,7 @@ const Section = props => {
121
123
  ...getBreakPointsValue(sectionGridSize || 8, null, "overrideGridSize", true)
122
124
  }
123
125
  },
124
- children: [!readOnly ? /*#__PURE__*/_jsx(DragHandle, {
126
+ children: [!readOnly && !showTool ? /*#__PURE__*/_jsx(DragHandle, {
125
127
  ...props
126
128
  }) : null, children, /*#__PURE__*/_jsx(Toolbar, {})]
127
129
  }), openSetttings ? /*#__PURE__*/_jsx(SectionPopup, {
@@ -24,6 +24,11 @@ const fieldStyle = [{
24
24
  label: "Placeholder",
25
25
  key: "placeholder",
26
26
  type: "text"
27
+ }, {
28
+ label: "Is required",
29
+ key: "required",
30
+ type: "selectBox",
31
+ placeholder: "Is required"
27
32
  }]
28
33
  }, {
29
34
  tab: "Padding",
@@ -83,7 +83,7 @@ const StyleBuilder = props => {
83
83
  setElementProps({
84
84
  ...elementProps,
85
85
  ...data,
86
- name: data?.element === "email" ? "field_email" : data?.name
86
+ field_type: data?.element
87
87
  });
88
88
  };
89
89
  const handleSave = () => {
@@ -50,6 +50,44 @@ const useCommonStyle = theme => ({
50
50
  color: theme?.palette?.editor?.textColor
51
51
  }
52
52
  }
53
+ },
54
+ signaturePopup: {
55
+ "& .MuiPaper-root": {
56
+ backgroundColor: theme?.palette?.editor?.background,
57
+ "& .signature-canvas": {
58
+ backgroundColor: "#FFF"
59
+ },
60
+ "& label": {
61
+ color: theme?.palette?.editor?.textColor
62
+ },
63
+ "& input": {
64
+ color: theme?.palette?.editor?.textColor,
65
+ backgroundColor: theme?.palette?.editor?.background
66
+ },
67
+ "& .react-datepicker__input-container": {
68
+ "& svg": {
69
+ fill: theme?.palette?.editor?.textColor
70
+ }
71
+ },
72
+ "& fieldset": {
73
+ borderColor: theme?.palette?.editor?.textColor
74
+ },
75
+ "& .upload-wrapper-ui": {
76
+ "& .MuiTypography-root": {
77
+ color: theme?.palette?.editor?.textColor
78
+ }
79
+ },
80
+ "& .typesignature-fontfamily": {
81
+ "& button": {
82
+ color: theme?.palette?.editor?.textColor
83
+ }
84
+ }
85
+ }
86
+ },
87
+ textOptions: {
88
+ "& .MuiPopover-root": {
89
+ backgroundColor: theme?.palette?.editor?.background
90
+ }
53
91
  }
54
92
  });
55
93
  export default useCommonStyle;
@@ -1,7 +1,23 @@
1
1
  import { useEffect, useState, createContext, useContext, useMemo } from "react";
2
+ import { getSelectedText } from "../utils/helper";
2
3
  import { jsx as _jsx } from "react/jsx-runtime";
3
4
  const EditorContext = /*#__PURE__*/createContext();
5
+ export const useEditorSelection = editor => {
6
+ const [textSelected, setTextSelected] = useState(false);
7
+ useEffect(() => {
8
+ if (editor?.selection) {
9
+ const text = getSelectedText(editor);
10
+ if (text?.length > 0) {
11
+ setTextSelected(true);
12
+ } else {
13
+ setTextSelected(false);
14
+ }
15
+ }
16
+ }, [editor?.selection]);
17
+ return [textSelected];
18
+ };
4
19
  export const EditorProvider = ({
20
+ editor,
5
21
  theme,
6
22
  children
7
23
  }) => {
@@ -23,7 +39,7 @@ export const EditorProvider = ({
23
39
  hoverPath: previous
24
40
  };
25
41
  }
26
- }, [path]);
42
+ }, [path, editor?.selection]);
27
43
  return /*#__PURE__*/_jsx(EditorContext.Provider, {
28
44
  value: {
29
45
  ...(value || {}),
@@ -9,6 +9,7 @@ export const formField = () => {
9
9
  children: [{
10
10
  text: ""
11
11
  }],
12
+ field_type: 'text',
12
13
  bgColor: "rgba(255, 255, 255, 1)",
13
14
  borderColor: "#ccc",
14
15
  bannerSpacing: {
@@ -81,4 +81,22 @@ export const updatePageSettings = (editor, pageProps = {}) => {
81
81
  } catch (err) {
82
82
  console.log(err);
83
83
  }
84
+ };
85
+ export const focusOnFirstParagraph = editor => {
86
+ try {
87
+ const [paragraphNode] = Editor.nodes(editor, {
88
+ at: [],
89
+ match: n => {
90
+ return !Editor.isEditor(n) && Element.isElement(n) && n.text !== undefined && !n.type;
91
+ }
92
+ });
93
+ if (paragraphNode && paragraphNode[1] !== undefined) {
94
+ Transforms.select(editor, {
95
+ path: paragraphNode[1],
96
+ offset: 0
97
+ });
98
+ }
99
+ } catch (err) {
100
+ console.log(err);
101
+ }
84
102
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.9.8",
3
+ "version": "2.0.0",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"