@flozy/editor 1.3.5 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -184,7 +184,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
184
184
  const isReadOnly = readOnly === "readonly";
185
185
  const customProps = {
186
186
  ...(otherProps || {}),
187
- readOnly: isReadOnly
187
+ readOnly: isReadOnly,
188
+ page_id: id
188
189
  };
189
190
  const renderElement = useCallback(props => {
190
191
  return /*#__PURE__*/_jsx(Element, {
@@ -396,6 +396,15 @@ blockquote {
396
396
  width: auto !important;
397
397
  }
398
398
  @media (max-width: 480px) {
399
+ body {
400
+ padding: 0px !important;
401
+ }
402
+ .app-logo {
403
+ justify-content: end;
404
+ }
405
+ .editor-t-wrapper {
406
+ padding: 0px 0px !important;
407
+ }
399
408
  .toolbar {
400
409
  display: flex;
401
410
  flex-wrap: nowrap;
@@ -405,9 +414,32 @@ blockquote {
405
414
  .toolbar-grp1 > div {
406
415
  display: flex;
407
416
  }
417
+ .grid-container > div {
418
+ flex-direction: column !important;
419
+ }
408
420
  .grid-item {
409
421
  width: 100% !important;
410
422
  }
423
+ .grid-item > div {
424
+ text-align: center;
425
+ }
426
+ .page-builder .editor-wrapper {
427
+ max-width: 100% !important;
428
+ margin-top: 0px !important;
429
+ padding: 0px !important;
430
+ }
431
+ .embed {
432
+ justify-content: center;
433
+ }
434
+ .embed img {
435
+ object-fit: contain;
436
+ }
437
+ form .form-field {
438
+ width: 100% !important;
439
+ }
440
+ .form-btn-wrpr {
441
+ justify-content: center !important;
442
+ }
411
443
  }
412
444
 
413
445
  .editorTabs {
@@ -476,11 +508,11 @@ blockquote {
476
508
  position: absolute;
477
509
  width: calc(100% + 16px);
478
510
  height: calc(100% + 16px);
479
- border: 4px solid #2684ff;
511
+ border: 4px dotted #2684ff;
480
512
  display: none;
481
513
  pointer-events: none;
482
- top: -12px;
483
- left: -12px;
514
+ top: -8px;
515
+ left: -8px;
484
516
  z-index: 100;
485
517
  }
486
518
 
@@ -502,4 +534,4 @@ blockquote {
502
534
 
503
535
  .empty-carousel-wrapper .grid-item-toolbar {
504
536
  left: 0px;
505
- }
537
+ }
@@ -160,6 +160,7 @@ function AppHeader(props) {
160
160
  sm: "block"
161
161
  }
162
162
  },
163
+ className: "app-logo",
163
164
  children: [appLogo && appLogo !== "none" ? /*#__PURE__*/_jsx("img", {
164
165
  alt: `${appTitle} Logo`,
165
166
  style: {
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import StyleBuilder from "../../common/StyleBuilder";
3
+ import fieldStyle from "../../common/StyleBuilder/fieldStyle";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const FieldPopup = props => {
6
+ const {
7
+ element,
8
+ onSave,
9
+ onClose
10
+ } = props;
11
+ return /*#__PURE__*/_jsx(StyleBuilder, {
12
+ title: "Form Field",
13
+ type: "fieldStyle",
14
+ element: element,
15
+ onSave: onSave,
16
+ onClose: onClose,
17
+ renderTabs: fieldStyle
18
+ });
19
+ };
20
+ export default FieldPopup;
@@ -0,0 +1,268 @@
1
+ import React, { useState, useRef } from "react";
2
+ import { Transforms } from "slate";
3
+ import { useSlateStatic, ReactEditor } from "slate-react";
4
+ import { IconButton, Tooltip, Grid, Menu, MenuItem, CircularProgress } from "@mui/material";
5
+ import DeleteIcon from "@mui/icons-material/Delete";
6
+ import SettingsIcon from "@mui/icons-material/Settings";
7
+ import AddIcon from "@mui/icons-material/Add";
8
+ import FormPopup from "./FormPopup";
9
+ import ButtonPopup from "../Button/ButtonPopup";
10
+ import { formField } from "../../utils/formfield";
11
+ import { formSubmit } from "../../service/formSubmit";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ const Form = props => {
15
+ const {
16
+ attributes,
17
+ children,
18
+ element,
19
+ customProps
20
+ } = props;
21
+ const {
22
+ readOnly,
23
+ page_id
24
+ } = customProps;
25
+ const {
26
+ buttonProps,
27
+ textColor,
28
+ formName
29
+ } = element;
30
+ const btnR = buttonProps?.borderRadius || {};
31
+ const btnSpacing = buttonProps?.bannerSpacing || {};
32
+ const btnAlign = buttonProps?.alignment || {};
33
+ const btnM = buttonProps?.marginSpacing || {};
34
+ const editor = useSlateStatic();
35
+ const formEle = useRef();
36
+ const [openSetttings, setOpenSettings] = useState(false);
37
+ const [editButton, setEditButton] = useState(false);
38
+ const [anchorEl, setAnchorEl] = useState(null);
39
+ const [loading, setLoading] = useState(false);
40
+ const path = ReactEditor.findPath(editor, element);
41
+ const btnBorderStyle = buttonProps?.borderColor?.indexOf("linear") >= 0 ? {
42
+ borderImageSource: buttonProps?.borderColor,
43
+ borderImageSlice: 1
44
+ } : {
45
+ borderColor: buttonProps?.borderColor || "none"
46
+ };
47
+ const handleSubmit = async (event, test = false) => {
48
+ if (event) {
49
+ event.preventDefault();
50
+ }
51
+ if ((readOnly || test) && formEle && formEle?.current) {
52
+ const formData = new FormData(formEle?.current);
53
+ setLoading(true);
54
+ let params = {
55
+ page_id: page_id
56
+ };
57
+ for (let pair of formData.entries()) {
58
+ params = {
59
+ ...params,
60
+ [pair[0]]: pair[1]
61
+ };
62
+ }
63
+ const result = await formSubmit(params);
64
+ console.log(result);
65
+ setLoading(false);
66
+ }
67
+ };
68
+ const onSettings = () => {
69
+ setOpenSettings(true);
70
+ };
71
+ const onSave = data => {
72
+ const path = ReactEditor.findPath(editor, element);
73
+ const updateData = {
74
+ ...data
75
+ };
76
+ delete updateData.children;
77
+ Transforms.setNodes(editor, {
78
+ ...updateData
79
+ }, {
80
+ at: path
81
+ });
82
+ onClose();
83
+ };
84
+ const onClose = () => {
85
+ setOpenSettings(false);
86
+ };
87
+ const onAddFormField = () => {
88
+ try {
89
+ Transforms.insertNodes(editor, {
90
+ ...formField()
91
+ }, {
92
+ at: [...path, children.length]
93
+ });
94
+ } catch (err) {
95
+ console.log(err, "Add Field Error in Form Builder");
96
+ }
97
+ };
98
+ const onDelete = () => {
99
+ if (path) {
100
+ Transforms.removeNodes(editor, {
101
+ at: path
102
+ });
103
+ }
104
+ };
105
+ const onSaveButtonSettings = data => {
106
+ onSave({
107
+ buttonProps: {
108
+ ...data
109
+ }
110
+ });
111
+ onCloseButtonSettings();
112
+ };
113
+ const onCloseButtonSettings = () => {
114
+ setAnchorEl(null);
115
+ setEditButton(false);
116
+ };
117
+ const handleClose = () => {
118
+ setAnchorEl(null);
119
+ };
120
+ const onMenuClick = menuName => () => {
121
+ switch (menuName) {
122
+ case "edit":
123
+ setEditButton(true);
124
+ break;
125
+ case "close":
126
+ setEditButton(false);
127
+ break;
128
+ case "test":
129
+ // test submit form
130
+ handleSubmit(null, true);
131
+ break;
132
+ default:
133
+ return;
134
+ }
135
+ };
136
+ const onSubmitClick = e => {
137
+ if (readOnly) {
138
+ // submit the form
139
+ } else {
140
+ setAnchorEl(e.currentTarget);
141
+ }
142
+ };
143
+ const FormToolbar = () => {
144
+ return /*#__PURE__*/_jsxs("div", {
145
+ className: "",
146
+ contentEditable: false,
147
+ children: [/*#__PURE__*/_jsx(Tooltip, {
148
+ title: "Form Settings",
149
+ arrow: true,
150
+ children: /*#__PURE__*/_jsx(IconButton, {
151
+ onClick: onSettings,
152
+ children: /*#__PURE__*/_jsx(SettingsIcon, {})
153
+ })
154
+ }), /*#__PURE__*/_jsx(Tooltip, {
155
+ title: "Add Form Field",
156
+ arrow: true,
157
+ children: /*#__PURE__*/_jsx(IconButton, {
158
+ onClick: onAddFormField,
159
+ children: /*#__PURE__*/_jsx(AddIcon, {})
160
+ })
161
+ }), /*#__PURE__*/_jsx(Tooltip, {
162
+ title: "Delete Form",
163
+ arrow: true,
164
+ children: /*#__PURE__*/_jsx(IconButton, {
165
+ onClick: onDelete,
166
+ children: /*#__PURE__*/_jsx(DeleteIcon, {})
167
+ })
168
+ })]
169
+ });
170
+ };
171
+ console.log(element);
172
+ return /*#__PURE__*/_jsxs("div", {
173
+ ...attributes,
174
+ className: "form-wrapper element-root",
175
+ style: {
176
+ border: !readOnly ? "1px dotted red" : "none",
177
+ padding: "10px"
178
+ },
179
+ children: [!readOnly && /*#__PURE__*/_jsx(FormToolbar, {}), /*#__PURE__*/_jsxs("form", {
180
+ id: `form_${formName}`,
181
+ onSubmit: handleSubmit,
182
+ style: {
183
+ color: textColor || "#FFF"
184
+ },
185
+ ref: formEle,
186
+ children: [/*#__PURE__*/_jsxs(Grid, {
187
+ container: true,
188
+ spacing: 2,
189
+ children: [children, /*#__PURE__*/_jsx(Grid, {
190
+ item: true,
191
+ className: "form-btn-wrpr",
192
+ contentEditable: false,
193
+ style: {
194
+ display: "flex",
195
+ flex: 1,
196
+ justifyContent: btnAlign?.horizantal || "start",
197
+ alignItems: btnAlign?.vertical || "start",
198
+ marginLeft: "0px"
199
+ },
200
+ children: /*#__PURE__*/_jsx("button", {
201
+ onClick: onSubmitClick,
202
+ disabled: loading,
203
+ style: {
204
+ background: buttonProps?.bgColor || "rgb(30, 75, 122)",
205
+ borderWidth: "1px",
206
+ borderBlockStyle: "solid",
207
+ ...btnBorderStyle,
208
+ borderRadius: `${btnR?.topLeft}px ${btnR?.topRight}px ${btnR?.bottomLeft}px ${btnR?.bottomRight}px`,
209
+ paddingLeft: `${btnSpacing?.left || 8}px`,
210
+ paddingRight: `${btnSpacing?.right || 8}px`,
211
+ paddingTop: `${btnSpacing?.top || 8}px`,
212
+ paddingBottom: `${btnSpacing?.bottom || 8}px`,
213
+ marginLeft: `${btnM?.left || 0}px`,
214
+ marginRight: `${btnM?.right || 0}px`,
215
+ marginTop: `${btnM?.top || 0}px`,
216
+ marginBottom: `${btnM?.bottom || 0}px`,
217
+ color: `${buttonProps?.textColor || "#FFFFFF"}`,
218
+ fontSize: buttonProps?.textSize || "inherit",
219
+ height: "fit-content"
220
+ },
221
+ children: buttonProps?.label || "Submit"
222
+ })
223
+ })]
224
+ }), loading && /*#__PURE__*/_jsx("div", {
225
+ style: {
226
+ position: "absolute",
227
+ top: 0,
228
+ left: 0,
229
+ width: "100%",
230
+ height: "100%",
231
+ background: "rgba(255,255,255,0.5)"
232
+ },
233
+ children: /*#__PURE__*/_jsx(CircularProgress, {
234
+ style: {
235
+ position: "absolute",
236
+ left: 0,
237
+ right: 0,
238
+ top: 0,
239
+ bottom: 0,
240
+ margin: "auto"
241
+ }
242
+ })
243
+ })]
244
+ }), openSetttings ? /*#__PURE__*/_jsx(FormPopup, {
245
+ element: element,
246
+ onSave: onSave,
247
+ onClose: onClose
248
+ }) : null, /*#__PURE__*/_jsxs(Menu, {
249
+ className: "editor-btn-options",
250
+ open: anchorEl !== null,
251
+ anchorEl: anchorEl,
252
+ onClose: handleClose,
253
+ children: [!readOnly && /*#__PURE__*/_jsx(MenuItem, {
254
+ onClick: onMenuClick("edit"),
255
+ children: "Settings"
256
+ }), /*#__PURE__*/_jsx(MenuItem, {
257
+ onClick: onMenuClick("test"),
258
+ children: "Test Submit Form"
259
+ })]
260
+ }), editButton && /*#__PURE__*/_jsx(ButtonPopup, {
261
+ element: buttonProps || {},
262
+ onSave: onSaveButtonSettings,
263
+ onClose: onCloseButtonSettings,
264
+ customProps: customProps
265
+ })]
266
+ });
267
+ };
268
+ export default Form;
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { useSlateStatic } from "slate-react";
3
+ import { IconButton, Tooltip } from "@mui/material";
4
+ import FeedIcon from "@mui/icons-material/Feed";
5
+ import { insertForm } from "../../utils/form";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const FormButton = props => {
8
+ const editor = useSlateStatic();
9
+ const onClick = () => {
10
+ insertForm(editor);
11
+ };
12
+ return /*#__PURE__*/_jsx(Tooltip, {
13
+ title: "Form",
14
+ arrow: true,
15
+ children: /*#__PURE__*/_jsx(IconButton, {
16
+ onClick: onClick,
17
+ children: /*#__PURE__*/_jsx(FeedIcon, {})
18
+ })
19
+ });
20
+ };
21
+ export default FormButton;
@@ -0,0 +1,48 @@
1
+ import React from "react";
2
+ import { Grid } from "@mui/material";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const FormText = props => {
5
+ const {
6
+ fieldProps
7
+ } = props;
8
+ const {
9
+ borderColor,
10
+ bannerSpacing,
11
+ borderRadius
12
+ } = fieldProps;
13
+ const {
14
+ left,
15
+ top,
16
+ right,
17
+ bottom
18
+ } = bannerSpacing || {};
19
+ const {
20
+ topLeft,
21
+ topRight,
22
+ bottomLeft,
23
+ bottomRight
24
+ } = borderRadius || {};
25
+ console.log(fieldProps);
26
+ const onChange = e => {
27
+ e.preventDefault();
28
+ };
29
+ return /*#__PURE__*/_jsx(Grid, {
30
+ item: true,
31
+ xs: 12,
32
+ contentEditable: false,
33
+ children: /*#__PURE__*/_jsx("input", {
34
+ ...fieldProps,
35
+ onChange: onChange,
36
+ style: {
37
+ width: "100%",
38
+ border: `1px solid ${borderColor || "#FFF"}`,
39
+ borderRadius: `${topLeft}px ${topRight}px ${bottomLeft}px ${bottomRight}px`,
40
+ paddingLeft: `${left || 8}px`,
41
+ paddingRight: `${right || 8}px`,
42
+ paddingTop: `${top || 8}px`,
43
+ paddingBottom: `${bottom || 8}px`
44
+ }
45
+ })
46
+ });
47
+ };
48
+ export default FormText;
@@ -0,0 +1,5 @@
1
+ import FormText from "./FormText";
2
+ const FormElements = {
3
+ text: FormText
4
+ };
5
+ export default FormElements;
@@ -0,0 +1,101 @@
1
+ import React, { useState } from "react";
2
+ import { Transforms } from "slate";
3
+ import { useSlateStatic, ReactEditor } from "slate-react";
4
+ import { IconButton, Tooltip, Grid } from "@mui/material";
5
+ import DeleteIcon from "@mui/icons-material/Delete";
6
+ import SettingsIcon from "@mui/icons-material/Settings";
7
+ import FormElements from "./FormElements";
8
+ import FieldPopup from "./FieldPopup";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ const FormField = props => {
12
+ const {
13
+ attributes,
14
+ element,
15
+ customProps
16
+ } = props;
17
+ const {
18
+ readOnly
19
+ } = customProps;
20
+ const {
21
+ element: elementType,
22
+ grid,
23
+ children,
24
+ ...elementProps
25
+ } = element;
26
+ const FormElement = FormElements[elementType];
27
+ const editor = useSlateStatic();
28
+ const path = ReactEditor.findPath(editor, element);
29
+ const [openSetttings, setOpenSettings] = useState(false);
30
+ const itemWidth = (grid || 6) / 12 * 100;
31
+ const onSettings = () => {
32
+ setOpenSettings(true);
33
+ };
34
+ const onSave = data => {
35
+ const updateData = {
36
+ ...data
37
+ };
38
+ delete updateData.children;
39
+ Transforms.setNodes(editor, {
40
+ ...updateData
41
+ }, {
42
+ at: path
43
+ });
44
+ onClose();
45
+ };
46
+ const onDelete = () => {
47
+ Transforms.removeNodes(editor, {
48
+ at: path
49
+ });
50
+ };
51
+ const onClose = () => {
52
+ setOpenSettings(false);
53
+ };
54
+ const FieldToolbar = () => {
55
+ return /*#__PURE__*/_jsxs("div", {
56
+ className: "",
57
+ contentEditable: false,
58
+ style: {
59
+ position: "absolute",
60
+ right: "0px",
61
+ top: "16px",
62
+ bottom: 0,
63
+ margin: "auto",
64
+ height: "42px",
65
+ zIndex: 101
66
+ },
67
+ children: [/*#__PURE__*/_jsx(Tooltip, {
68
+ title: "Field Settings",
69
+ arrow: true,
70
+ children: /*#__PURE__*/_jsx(IconButton, {
71
+ onClick: onSettings,
72
+ children: /*#__PURE__*/_jsx(SettingsIcon, {})
73
+ })
74
+ }), /*#__PURE__*/_jsx(Tooltip, {
75
+ title: "Delete Field",
76
+ arrow: true,
77
+ children: /*#__PURE__*/_jsx(IconButton, {
78
+ onClick: onDelete,
79
+ children: /*#__PURE__*/_jsx(DeleteIcon, {})
80
+ })
81
+ })]
82
+ });
83
+ };
84
+ return /*#__PURE__*/_jsxs(Grid, {
85
+ item: true,
86
+ ...attributes,
87
+ className: "form-field",
88
+ style: {
89
+ position: "relative",
90
+ width: `${itemWidth}%`
91
+ },
92
+ children: [!readOnly && /*#__PURE__*/_jsx(FieldToolbar, {}), /*#__PURE__*/_jsx(FormElement, {
93
+ fieldProps: elementProps
94
+ }), openSetttings ? /*#__PURE__*/_jsx(FieldPopup, {
95
+ element: element,
96
+ onSave: onSave,
97
+ onClose: onClose
98
+ }) : null]
99
+ });
100
+ };
101
+ export default FormField;
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import StyleBuilder from "../../common/StyleBuilder";
3
+ import formStyle from "../../common/StyleBuilder/formStyle";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const FormPopup = props => {
6
+ const {
7
+ element,
8
+ onSave,
9
+ onClose
10
+ } = props;
11
+ return /*#__PURE__*/_jsx(StyleBuilder, {
12
+ title: "Form",
13
+ type: "formStyle",
14
+ element: element,
15
+ onSave: onSave,
16
+ onClose: onClose,
17
+ renderTabs: formStyle
18
+ });
19
+ };
20
+ export default FormPopup;
@@ -21,6 +21,7 @@ import PageSettingsButton from "../Elements/PageSettings/PageSettingsButton";
21
21
  import CarouselButton from "../Elements/Carousel/CarouselButton";
22
22
  import AppHeaderButton from "../Elements/AppHeader/AppHeaderButton";
23
23
  import "./styles.css";
24
+ import FormButton from "../Elements/Form/FormButton.js";
24
25
  import { jsx as _jsx } from "react/jsx-runtime";
25
26
  import { jsxs as _jsxs } from "react/jsx-runtime";
26
27
  const Toolbar = props => {
@@ -148,6 +149,11 @@ const Toolbar = props => {
148
149
  editor: editor,
149
150
  customProps: customProps
150
151
  }, element.id);
152
+ case "form":
153
+ return /*#__PURE__*/_jsx(FormButton, {
154
+ editor: editor,
155
+ customProps: customProps
156
+ }, element.id);
151
157
  default:
152
158
  return null;
153
159
  }
@@ -151,5 +151,8 @@ const toolbarGroups = [[{
151
151
  }, {
152
152
  id: 37,
153
153
  type: "app-header"
154
+ }, {
155
+ id: 38,
156
+ type: "form"
154
157
  }]];
155
158
  export default toolbarGroups;
@@ -1,15 +1,11 @@
1
1
  const buttonStyle = [{
2
- tab: "Content",
3
- value: "content",
2
+ tab: "General",
3
+ value: "size",
4
4
  fields: [{
5
5
  label: "Button Text",
6
6
  key: "label",
7
7
  type: "text"
8
- }]
9
- }, {
10
- tab: "Size & Alignment",
11
- value: "size",
12
- fields: [{
8
+ }, {
13
9
  label: "Text Size",
14
10
  key: "textSize",
15
11
  type: "text",
@@ -28,6 +24,22 @@ const buttonStyle = [{
28
24
  key: "buttonLink",
29
25
  type: "buttonLink"
30
26
  }]
27
+ }, {
28
+ tab: "Position",
29
+ value: "position",
30
+ fields: [{
31
+ label: "Set Postion (Vertical & Horizantal)",
32
+ key: "alignment",
33
+ type: "alignment"
34
+ }]
35
+ }, {
36
+ tab: "Margin Spacing",
37
+ value: "marginSpacing",
38
+ fields: [{
39
+ label: "Margin Spacing",
40
+ key: "marginSpacing",
41
+ type: "bannerSpacing"
42
+ }]
31
43
  }, {
32
44
  tab: "Banner Spacing",
33
45
  value: "bannerSpacing",
@@ -0,0 +1,71 @@
1
+ const fieldStyle = [{
2
+ tab: "General",
3
+ value: "general",
4
+ fields: [{
5
+ label: "Field Name",
6
+ key: "name",
7
+ type: "text"
8
+ }, {
9
+ label: "Field Type",
10
+ key: "element",
11
+ type: "textOptions",
12
+ options: [{
13
+ label: "Textbox",
14
+ value: "text"
15
+ }]
16
+ }, {
17
+ label: "Placeholder",
18
+ key: "placeholder",
19
+ type: "text"
20
+ }]
21
+ }, {
22
+ tab: "Banner Spacing",
23
+ value: "bannerSpacing",
24
+ fields: [{
25
+ label: "Banner Spacing",
26
+ key: "bannerSpacing",
27
+ type: "bannerSpacing"
28
+ }]
29
+ }, {
30
+ tab: "Border Radius",
31
+ value: "borderRadius",
32
+ fields: [{
33
+ label: "Border Radius",
34
+ key: "borderRadius",
35
+ type: "borderRadius"
36
+ }]
37
+ }, {
38
+ tab: "Colors",
39
+ value: "colors",
40
+ fields: [{
41
+ label: "Text",
42
+ key: "textColor",
43
+ type: "color",
44
+ needPreview: true
45
+ }, {
46
+ label: "Background",
47
+ key: "bgColor",
48
+ type: "color"
49
+ }, {
50
+ label: "Border",
51
+ key: "borderColor",
52
+ type: "color"
53
+ }]
54
+ }, {
55
+ tab: "Position",
56
+ value: "position",
57
+ fields: [{
58
+ label: "Set Postion (Vertical & Horizantal)",
59
+ key: "alignment",
60
+ type: "alignment"
61
+ }]
62
+ }, {
63
+ tab: "Size",
64
+ value: "gridSize",
65
+ fields: [{
66
+ label: "Grid Size",
67
+ key: "grid",
68
+ type: "gridSize"
69
+ }]
70
+ }];
71
+ export default fieldStyle;
@@ -11,6 +11,8 @@ import MenusArray from "./menusArray";
11
11
  import ButtonLink from "./buttonLink";
12
12
  import SaveAsTemplate from "./saveAsTemplate";
13
13
  import TextAlign from "./textAlign";
14
+ import TextOptions from "./textOptions";
15
+ import SelectBox from "./selectBox";
14
16
  const FieldMap = {
15
17
  text: Text,
16
18
  bannerSpacing: BannerSpacing,
@@ -24,6 +26,8 @@ const FieldMap = {
24
26
  menusArray: MenusArray,
25
27
  buttonLink: ButtonLink,
26
28
  saveAsTemplate: SaveAsTemplate,
27
- textAlign: TextAlign
29
+ textAlign: TextAlign,
30
+ textOptions: TextOptions,
31
+ selectBox: SelectBox
28
32
  };
29
33
  export default FieldMap;
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ import { Grid, Checkbox, FormControlLabel } from "@mui/material";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const SelectBox = props => {
5
+ const {
6
+ value,
7
+ data,
8
+ onChange
9
+ } = props;
10
+ const {
11
+ key,
12
+ placeholder
13
+ } = data;
14
+ const handleChange = e => {
15
+ onChange({
16
+ [key]: e.target.checked
17
+ });
18
+ };
19
+ return /*#__PURE__*/_jsx(Grid, {
20
+ container: true,
21
+ padding: 1,
22
+ children: /*#__PURE__*/_jsx(Grid, {
23
+ item: true,
24
+ xs: 12,
25
+ children: /*#__PURE__*/_jsx(FormControlLabel, {
26
+ control: /*#__PURE__*/_jsx(Checkbox, {
27
+ value: value,
28
+ onChange: handleChange
29
+ }),
30
+ label: placeholder
31
+ })
32
+ })
33
+ });
34
+ };
35
+ export default SelectBox;
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+ import { Grid, MenuItem, Select } from "@mui/material";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const TextOptions = props => {
5
+ const {
6
+ data,
7
+ onChange,
8
+ elementProps
9
+ } = props;
10
+ const {
11
+ key,
12
+ options
13
+ } = data;
14
+ const {
15
+ element: elementType
16
+ } = elementProps;
17
+ const handleChange = e => {
18
+ onChange({
19
+ [key]: e.target.value
20
+ });
21
+ };
22
+ return /*#__PURE__*/_jsx(Grid, {
23
+ container: true,
24
+ children: /*#__PURE__*/_jsx(Grid, {
25
+ item: true,
26
+ xs: 12,
27
+ style: {
28
+ padding: "10px"
29
+ },
30
+ children: /*#__PURE__*/_jsx(Select, {
31
+ onChange: handleChange,
32
+ value: elementType,
33
+ placeholder: data?.label,
34
+ fullWidth: true,
35
+ size: "small",
36
+ children: options.map(m => {
37
+ return /*#__PURE__*/_jsx(MenuItem, {
38
+ value: m.value,
39
+ children: m.label
40
+ }, `${key}_${m.value}`);
41
+ })
42
+ })
43
+ })
44
+ });
45
+ };
46
+ export default TextOptions;
@@ -0,0 +1,82 @@
1
+ const formStyle = [{
2
+ tab: "General",
3
+ value: "general",
4
+ fields: [{
5
+ label: "Form Name",
6
+ key: "formName",
7
+ type: "text"
8
+ }, {
9
+ label: "Send Form to Email",
10
+ key: "email",
11
+ type: "text",
12
+ placeholder: "Enter Email to send the response..."
13
+ }, {
14
+ label: "Save Response",
15
+ key: "saveResponse",
16
+ type: "selectBox",
17
+ placeholder: "Save Response"
18
+ }]
19
+ }, {
20
+ tab: "Banner Spacing",
21
+ value: "bannerSpacing",
22
+ fields: [{
23
+ label: "Banner Spacing",
24
+ key: "bannerSpacing",
25
+ type: "bannerSpacing"
26
+ }]
27
+ }, {
28
+ tab: "Border Radius",
29
+ value: "borderRadius",
30
+ fields: [{
31
+ label: "Border Radius",
32
+ key: "borderRadius",
33
+ type: "borderRadius"
34
+ }]
35
+ }, {
36
+ tab: "Colors",
37
+ value: "colors",
38
+ fields: [{
39
+ label: "Text",
40
+ key: "textColor",
41
+ type: "color",
42
+ needPreview: true
43
+ }, {
44
+ label: "Background",
45
+ key: "bgColor",
46
+ type: "color"
47
+ }, {
48
+ label: "Border",
49
+ key: "borderColor",
50
+ type: "color"
51
+ }]
52
+ }, {
53
+ tab: "Position",
54
+ value: "position",
55
+ fields: [{
56
+ label: "Set Postion (Vertical & Horizantal)",
57
+ key: "alignment",
58
+ type: "alignment"
59
+ }]
60
+ }, {
61
+ tab: "Background",
62
+ value: "backgroundImage",
63
+ fields: [{
64
+ label: "URL",
65
+ key: "backgroundImage",
66
+ type: "text"
67
+ }, {
68
+ label: "Background Image",
69
+ key: "backgroundImage",
70
+ type: "backgroundImage"
71
+ }]
72
+ }, {
73
+ tab: "Save As Template",
74
+ value: "saveAsTemplate",
75
+ needActions: false,
76
+ fields: [{
77
+ label: "Template Image",
78
+ key: "saveAsTemplate",
79
+ type: "saveAsTemplate"
80
+ }]
81
+ }];
82
+ export default formStyle;
@@ -0,0 +1,16 @@
1
+ export const formSubmit = async formData => {
2
+ try {
3
+ const response = await fetch(`/form/submit`, {
4
+ method: "POST",
5
+ headers: {
6
+ "Content-Type": "application/json"
7
+ },
8
+ body: JSON.stringify(formData)
9
+ });
10
+ const result = await response.json();
11
+ return result.data;
12
+ } catch (err) {
13
+ console.log(err);
14
+ return err;
15
+ }
16
+ };
@@ -26,6 +26,8 @@ import DrawerMenu from "../Elements/DrawerMenu/DrawerMenu";
26
26
  import AppHeader from "../Elements/AppHeader/AppHeader";
27
27
  import PageSettings from "../Elements/PageSettings/PageSettings";
28
28
  import Title from "../Elements/Title/title";
29
+ import Form from "../Elements/Form/Form";
30
+ import FormField from "../Elements/Form/FormField";
29
31
  import { jsx as _jsx } from "react/jsx-runtime";
30
32
  const alignment = ["alignLeft", "alignRight", "alignCenter"];
31
33
  const list_types = ["orderedList", "unorderedList"];
@@ -369,6 +371,14 @@ export const getBlock = props => {
369
371
  return /*#__PURE__*/_jsx(Title, {
370
372
  ...props
371
373
  });
374
+ case "form":
375
+ return /*#__PURE__*/_jsx(Form, {
376
+ ...props
377
+ });
378
+ case "form-field":
379
+ return /*#__PURE__*/_jsx(FormField, {
380
+ ...props
381
+ });
372
382
  default:
373
383
  return /*#__PURE__*/_jsx("div", {
374
384
  ...element.attr,
@@ -0,0 +1,24 @@
1
+ import { Transforms } from "slate";
2
+ import { formField } from "./formfield";
3
+ export const insertForm = (editor, item) => {
4
+ const grid = !item ? {
5
+ type: "form",
6
+ grid: "container",
7
+ formName: `form_${new Date().getTime()}`,
8
+ props: {
9
+ onSubmit: null
10
+ },
11
+ children: [{
12
+ ...formField()
13
+ }, {
14
+ text: ""
15
+ }]
16
+ } : item;
17
+ const {
18
+ selection
19
+ } = editor;
20
+ Transforms.insertNodes(editor, grid, {
21
+ at: selection.focus.path
22
+ });
23
+ Transforms.move(editor);
24
+ };
@@ -0,0 +1,20 @@
1
+ import { Transforms } from "slate";
2
+ export const formField = () => {
3
+ return {
4
+ type: "form-field",
5
+ grid: 6,
6
+ element: "text",
7
+ name: `field_${new Date().getTime()}`,
8
+ placeholder: "Placeholder...",
9
+ children: [{
10
+ text: ""
11
+ }],
12
+ bgColor: "rgba(255, 255, 255, 0)"
13
+ };
14
+ };
15
+ export const insertGridItem = editor => {
16
+ Transforms.insertNodes(editor, {
17
+ ...formField()
18
+ });
19
+ Transforms.move(editor);
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"