@flozy/editor 4.0.6 → 4.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,10 +22,11 @@ const scrollToAIInput = editor => {
22
22
  selectionRect = ReactEditor.toDOMRange(editor, getNextLine(editor).at).getBoundingClientRect();
23
23
  }
24
24
  const wrapperTop = slateWrapper.getBoundingClientRect().top;
25
- const cursorViewPortPosition = selectionRect.top - wrapperTop;
25
+ const cursorViewPortPosition = selectionRect.bottom - wrapperTop; // here the slatewrapper is the viewport, not the whole screen. We are finding the position of the cursor/selection relative to the slate wrapper, that why we are subracting the slate wrapper top with selection bottom
26
+
26
27
  if (cursorViewPortPosition > 80) {
27
28
  // scroll to top of the slateWrapper
28
- slateWrapper.scrollBy(0, selectionRect.bottom - wrapperTop - 80);
29
+ slateWrapper.scrollBy(0, cursorViewPortPosition - 80);
29
30
  }
30
31
  }, 200);
31
32
  } catch (err) {
@@ -18,6 +18,7 @@ import { onPasteRnDNode } from "../../helper";
18
18
  import focusOnNewItem from "../../helper/RnD/focusOnNewItem";
19
19
  import { appHeaderNode } from "../../utils/insertAppHeader";
20
20
  import { FORM_NODE } from "../../utils/form";
21
+ import { DEFAULT_TABLE_NODE } from "../../utils/table";
21
22
  import itemOptions from "./Options/sectionItemOptions";
22
23
  import { jsx as _jsx } from "react/jsx-runtime";
23
24
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -158,7 +159,7 @@ const FreeGrid = props => {
158
159
  marginTop: 0,
159
160
  top: 0,
160
161
  width: 170,
161
- height: 80
162
+ height: 30
162
163
  }], {
163
164
  at: [...insertAt]
164
165
  });
@@ -189,14 +190,16 @@ const FreeGrid = props => {
189
190
  top: 12,
190
191
  right: 12,
191
192
  bottom: 12
192
- }
193
+ },
194
+ textAlign: "center",
195
+ label: "Get Started"
193
196
  }],
194
197
  gridArea: "3 / 1 / 4 / 2",
195
198
  left: 50,
196
199
  marginTop: 0,
197
200
  top: 0,
198
- width: 170,
199
- height: 80
201
+ width: 143,
202
+ height: 50
200
203
  }], {
201
204
  at: [...insertAt]
202
205
  });
@@ -237,6 +240,18 @@ const FreeGrid = props => {
237
240
  at: [...insertAt]
238
241
  });
239
242
  break;
243
+ case "addTable":
244
+ Transforms.insertNodes(editor, [{
245
+ ...insertFreeGridItem("table", {
246
+ ...DEFAULT_TABLE_NODE()
247
+ }, {
248
+ height: 130,
249
+ width: 400
250
+ })
251
+ }], {
252
+ at: [...insertAt]
253
+ });
254
+ break;
240
255
  case "addBox":
241
256
  Transforms.insertNodes(editor, [{
242
257
  ...insertFreeGridItem("box", {
@@ -254,7 +269,7 @@ const FreeGrid = props => {
254
269
  ...insertFreeGridItem("form", {
255
270
  ...FORM_NODE()
256
271
  }, {
257
- height: 100,
272
+ height: 92,
258
273
  width: 400
259
274
  })
260
275
  }], {
@@ -24,7 +24,11 @@ const AddElement = props => {
24
24
  }), /*#__PURE__*/_jsx(ListItemButton, {
25
25
  className: "item-wrapper",
26
26
  onClick: handleClick("addVideo"),
27
- children: "Video"
27
+ children: "Embed or Video"
28
+ }), /*#__PURE__*/_jsx(ListItemButton, {
29
+ className: "item-wrapper",
30
+ onClick: handleClick("addTable"),
31
+ children: "Table"
28
32
  }), /*#__PURE__*/_jsx(ListItemButton, {
29
33
  className: "item-wrapper",
30
34
  onClick: handleClick("addBox"),
@@ -4,6 +4,7 @@ const buttonOptions = ["settings", "link", "saveAsTemplate", "close"];
4
4
  const imageOptions = ["settings", "link", "saveAsTemplate", "close"];
5
5
  const boxOptions = ["settings", "link", "saveAsTemplate", "close"];
6
6
  const appHeaderOptions = ["settings", "saveAsTemplate", "close"];
7
+ const tableOptions = ["drag", "edit", "settings", "saveAsTemplate", "close"];
7
8
  const sectionOptions = ["addElement", "settings", "moveUp", "moveDown", "saveAsTemplate", "more"];
8
9
  const formOptions = ["drag", "edit", "settings", "addFormField", "workFlow", "saveAsTemplate", "close"];
9
10
  const itemOptions = {
@@ -14,6 +15,7 @@ const itemOptions = {
14
15
  box: boxOptions,
15
16
  appHeader: appHeaderOptions,
16
17
  form: formOptions,
17
- section: sectionOptions
18
+ section: sectionOptions,
19
+ table: tableOptions
18
20
  };
19
21
  export default itemOptions;
@@ -150,6 +150,9 @@ const useFreeGridStyles = ({
150
150
  },
151
151
 
152
152
  "& .fgi_type_form": {
153
+ "& .form-wrapper": {
154
+ padding: "0px !important"
155
+ },
153
156
  "& legend": {
154
157
  paddingLeft: "16px",
155
158
  paddingTop: "16px",
@@ -170,6 +173,21 @@ const useFreeGridStyles = ({
170
173
  }
171
174
  }
172
175
  },
176
+ "& .fgi_type_table": {
177
+ "& .tableToolBar": {
178
+ right: "0px",
179
+ left: "auto",
180
+ top: "-34px",
181
+ display: "flex",
182
+ flexDirection: "row-reverse",
183
+ "& .toolbtn.settings": {
184
+ display: "none"
185
+ },
186
+ "& .toolbtn.remove": {
187
+ display: "none"
188
+ }
189
+ }
190
+ },
173
191
  /** element toolbar hide */
174
192
  "& .element-toolbar": {
175
193
  display: "none"
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from "react";
2
2
  import { Transforms } from "slate";
3
3
  import { useSelected, useSlateStatic } from "slate-react";
4
- import { Box, IconButton, Tooltip, Table as TableComp, TableBody, Popper, Typography } from "@mui/material";
4
+ import { Box, IconButton, Tooltip, Table as TableComp, TableBody } from "@mui/material";
5
5
  import AlignHorizontalLeftIcon from "@mui/icons-material/AlignHorizontalLeft";
6
6
  import AlignHorizontalRightIcon from "@mui/icons-material/AlignHorizontalRight";
7
7
  import AlignVerticalTopIcon from "@mui/icons-material/AlignVerticalTop";
@@ -15,7 +15,6 @@ import { TableUtil } from "../../utils/table";
15
15
  import TablePopup from "./TablePopup";
16
16
  import { useEditorSelection } from "../../hooks/useMouseMove";
17
17
  import TableStyles from "./Styles";
18
- import useClickOutside from "../../hooks/useClickOutside";
19
18
  import "./table.css";
20
19
  import { jsx as _jsx } from "react/jsx-runtime";
21
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -150,7 +149,7 @@ const Table = props => {
150
149
  title: text,
151
150
  arrow: true,
152
151
  children: /*#__PURE__*/_jsx(IconButton, {
153
- className: "toolbtn",
152
+ className: `toolbtn ${action?.type}`,
154
153
  onClick: handleAction(action),
155
154
  children: /*#__PURE__*/_jsx(Icon, {})
156
155
  })
@@ -0,0 +1,77 @@
1
+ import React from "react";
2
+ import { Node, Transforms } from "slate";
3
+ import { Box } from "@mui/material";
4
+ import { StyleContent } from "../../../StyleBuilder";
5
+ import tableStyle from "../../../StyleBuilder/tableStyle";
6
+ import { TableUtil } from "../../../../utils/table";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const TableSettings = props => {
9
+ const {
10
+ editor,
11
+ path,
12
+ customProps
13
+ } = props;
14
+ const item_path = path?.split("|").map(m => parseInt(m));
15
+ const element_path = [...item_path, 0];
16
+ const element = Node.get(editor, element_path);
17
+ const getTableProps = () => {
18
+ try {
19
+ const firstTCell = [...element_path, 0, 0, 0, 0];
20
+ const firstTCellTarget = {
21
+ anchor: {
22
+ path: [...firstTCell],
23
+ offset: 0
24
+ },
25
+ focus: {
26
+ path: [...firstTCell],
27
+ offset: 0
28
+ }
29
+ };
30
+ Transforms.select(editor, firstTCellTarget);
31
+ const table = new TableUtil(editor);
32
+ const tableProps = table.getTableProps();
33
+ return {
34
+ table,
35
+ tableProps
36
+ };
37
+ } catch (err) {
38
+ return element;
39
+ }
40
+ };
41
+ const onChange = data => {
42
+ try {
43
+ const {
44
+ table,
45
+ tableProps
46
+ } = getTableProps();
47
+ const updateData = {
48
+ ...data
49
+ };
50
+ delete updateData.children;
51
+ delete updateData.type;
52
+ table.updateTableStyle(updateData, {
53
+ ...tableProps
54
+ });
55
+ } catch (err) {
56
+ console.log(err);
57
+ }
58
+ };
59
+ const handleClose = () => {
60
+ console.log("close");
61
+ };
62
+ return /*#__PURE__*/_jsx(Box, {
63
+ component: "div",
64
+ className: "item-w",
65
+ children: tableStyle?.map((m, i) => {
66
+ return /*#__PURE__*/_jsx(StyleContent, {
67
+ renderTabs: tableStyle,
68
+ value: m.value,
69
+ element: getTableProps()?.tableProps?.styleProps || {},
70
+ onChange: onChange,
71
+ customProps: customProps,
72
+ handleClose: handleClose
73
+ }, `tab_${m.value}_$${i}`);
74
+ })
75
+ });
76
+ };
77
+ export default TableSettings;
@@ -5,6 +5,7 @@ import VideoSettings from "./VideoSettings";
5
5
  import BoxSettings from "./BoxSettings";
6
6
  import AppHeaderSettings from "./AppHeaderSettings";
7
7
  import FormSettings from "./FormSettings";
8
+ import TableSettings from "./TableSettings";
8
9
  const SettingsComponents = {
9
10
  text: TextSettings,
10
11
  button: ButtonSettings,
@@ -12,6 +13,7 @@ const SettingsComponents = {
12
13
  video: VideoSettings,
13
14
  box: BoxSettings,
14
15
  appHeader: AppHeaderSettings,
15
- form: FormSettings
16
+ form: FormSettings,
17
+ table: TableSettings
16
18
  };
17
19
  export default SettingsComponents;
@@ -2,17 +2,19 @@ export const settingsLabel = {
2
2
  text: "Text Settings",
3
3
  button: "Button Settings",
4
4
  image: "Image Settings",
5
- video: "Video Settings",
5
+ video: "Embed or Video Settings",
6
6
  box: "Box Settings",
7
7
  appHeader: "App Header Settings",
8
- form: "Form Settings"
8
+ form: "Form Settings",
9
+ table: "Table Settings"
9
10
  };
10
11
  export const ItemTypes = {
11
12
  text: "Text",
12
13
  button: "Button",
13
14
  image: "Image",
14
- video: "Video",
15
+ video: "Embed or Video",
15
16
  box: "Box",
16
17
  appHeader: "App Header",
17
- form: "Form"
18
+ form: "Form",
19
+ table: "Table"
18
20
  };
@@ -273,7 +273,6 @@ const RnD = props => {
273
273
  };
274
274
  const onDragStart = e => {
275
275
  e.preventDefault();
276
- console.log(e?.target?.dataset);
277
276
  if (e?.target?.dataset?.path?.split(",").join("|") === sp) {
278
277
  const {
279
278
  left,
@@ -4,7 +4,8 @@ const sectionStyle = [{
4
4
  fields: [{
5
5
  label: "Section Name",
6
6
  key: "sectionName",
7
- type: "text"
7
+ type: "text",
8
+ placeholder: "Welcome"
8
9
  }]
9
10
  }, {
10
11
  tab: "Colors",
@@ -208,7 +208,8 @@ export const onPasteRnDNode = (editor, {
208
208
  left: parsed_node?.left + 20,
209
209
  marginTop: parsed_node?.marginTop + 20,
210
210
  // to maintain unique drop location in different section also
211
- gridArea: "1 / 1 / 2 / 2"
211
+ gridArea: "1 / 1 / 2 / 2",
212
+ xs_updatedOn: null
212
213
  }], {
213
214
  at: new_path
214
215
  });
@@ -42,37 +42,150 @@ export const insertFreeGrid = (editor, path, extProps) => {
42
42
  children: [{
43
43
  type: "paragraph",
44
44
  children: [{
45
- text: "Heading One",
46
- fontSize: {
47
- xs: "38px",
48
- sm: "54px",
49
- md: "54px",
50
- lg: "54px"
45
+ type: "grid",
46
+ grid: "container",
47
+ children: [{
48
+ type: "grid-item",
49
+ grid: 12,
50
+ children: [{
51
+ type: "alignCenter",
52
+ children: [{
53
+ type: "paragraph",
54
+ children: [{
55
+ text: "Lorem ipsum sit ",
56
+ fontSize: {
57
+ xs: "80px",
58
+ sm: "80px",
59
+ md: "80px",
60
+ lg: "80px"
61
+ },
62
+ fontFamily: "PoppinsBold",
63
+ color: "rgb(132, 141, 151)"
64
+ }]
65
+ }]
66
+ }, {
67
+ type: "alignCenter",
68
+ children: [{
69
+ type: "paragraph",
70
+ children: [{
71
+ fontSize: {
72
+ xs: "80px",
73
+ sm: "80px",
74
+ md: "80px",
75
+ lg: "80px"
76
+ },
77
+ fontFamily: "PoppinsBold",
78
+ text: "amet.",
79
+ color: "rgb(132, 141, 151)"
80
+ }, {
81
+ fontSize: {
82
+ xs: "80px",
83
+ sm: "80px",
84
+ md: "80px",
85
+ lg: "80px"
86
+ },
87
+ fontFamily: "PoppinsBold",
88
+ text: " "
89
+ }, {
90
+ fontSize: {
91
+ xs: "80px",
92
+ sm: "80px",
93
+ md: "80px",
94
+ lg: "80px"
95
+ },
96
+ fontFamily: "PoppinsBold",
97
+ text: "Lorem",
98
+ color: "rgb(131, 96, 253)"
99
+ }]
100
+ }]
101
+ }],
102
+ bgColor: "rgba(255, 255, 255, 0)",
103
+ borderColor: "rgba(204, 204, 204, 0)",
104
+ lockSpacing: true,
105
+ bannerSpacing: {
106
+ top: "16",
107
+ left: "16",
108
+ right: "16",
109
+ bottom: "16"
110
+ }
111
+ }],
112
+ alignment: {
113
+ flexDirection: "column"
51
114
  },
52
- fontFamily: "PoppinsBold"
115
+ lockSpacing: false,
116
+ bannerSpacing: {
117
+ top: "32",
118
+ left: "16",
119
+ right: "16",
120
+ bottom: "16"
121
+ },
122
+ gridSize: 8
53
123
  }]
54
124
  }]
55
125
  }],
56
- gridArea: "2 / 1 / 3 / 2",
57
- height: 88,
126
+ gridArea: "1 / 1 / 2 / 2",
127
+ height: 323,
58
128
  width: 746,
59
- left: 129,
60
- marginTop: 23,
129
+ left: 127,
130
+ marginTop: 25,
61
131
  top_xs: 105.1875,
62
132
  left_xs: 22,
63
133
  marginTop_xs: 38,
64
134
  width_xs: 272,
65
135
  height_xs: 163.0078125,
66
136
  gridArea_xs: "2 / 1 / 3 / 2",
67
- updated_at: 1728554109479,
68
- lg_updatedOn: 1726290562773,
69
- xs_updatedOn: 1728554109478
137
+ updated_at: 1729055084817,
138
+ lg_updatedOn: 1729055010519,
139
+ xs_updatedOn: null
140
+ }, {
141
+ type: "freegridItem",
142
+ childType: "button",
143
+ children: [{
144
+ type: "button",
145
+ children: [{
146
+ text: ""
147
+ }],
148
+ buttonLink: {
149
+ linkType: "webAddress"
150
+ },
151
+ iconPosition: "start",
152
+ bgColor: "#2563EB",
153
+ textColor: "#FFF",
154
+ borderRadius: {
155
+ topLeft: 30,
156
+ topRight: 30,
157
+ bottomLeft: 30,
158
+ bottomRight: 30
159
+ },
160
+ bannerSpacing: {
161
+ left: 12,
162
+ top: 12,
163
+ right: 12,
164
+ bottom: 12
165
+ },
166
+ textAlign: "center",
167
+ label: "Get Started"
168
+ }],
169
+ gridArea: "7 / 1 / 8 / 2",
170
+ left: 428,
171
+ marginTop: 42,
172
+ top: 0,
173
+ width: 143,
174
+ height: 50,
175
+ lg_updatedOn: 1729055084816,
176
+ updated_at: 1729055084817,
177
+ top_xs: 366,
178
+ left_xs: 24,
179
+ marginTop_xs: 12,
180
+ width_xs: 272,
181
+ height_xs: 48,
182
+ gridArea_xs: "8 / 1 / 9 / 2"
70
183
  }],
71
184
  height_xs: 593.0625,
72
- updated_at: 1728554109479,
185
+ updated_at: 1729055084816,
73
186
  width: 0,
74
- sectionBgColor: "rgb(222, 99, 138)",
75
- xs_updatedOn: 1727921628092,
187
+ sectionBgColor: "rgb(255, 255, 255)",
188
+ xs_updatedOn: null,
76
189
  sectionName: "Home"
77
190
  }];
78
191
  const newPath = path ? path : editor?.selection?.anchor?.path;
@@ -1,6 +1,111 @@
1
1
  import { Transforms, Editor, Range, Element, Path, Node } from "slate";
2
2
  import { ReactEditor } from "slate-react";
3
3
  import { customInsertNode } from "./helper";
4
+ export const DEFAULT_TABLE_NODE = () => ({
5
+ type: "table",
6
+ children: [{
7
+ type: "table-row",
8
+ children: [{
9
+ type: "table-cell",
10
+ children: [{
11
+ type: "paragraph",
12
+ children: [{
13
+ text: ""
14
+ }],
15
+ cellBgColor: "#FFFFFF"
16
+ }]
17
+ }, {
18
+ type: "table-cell",
19
+ children: [{
20
+ type: "paragraph",
21
+ children: [{
22
+ text: ""
23
+ }],
24
+ cellBgColor: "#FFFFFF"
25
+ }]
26
+ }, {
27
+ type: "table-cell",
28
+ children: [{
29
+ type: "paragraph",
30
+ children: [{
31
+ text: ""
32
+ }],
33
+ cellBgColor: "#FFFFFF"
34
+ }]
35
+ }]
36
+ }, {
37
+ type: "table-row",
38
+ children: [{
39
+ type: "table-cell",
40
+ children: [{
41
+ type: "paragraph",
42
+ children: [{
43
+ text: ""
44
+ }],
45
+ cellBgColor: "#FFFFFF"
46
+ }]
47
+ }, {
48
+ type: "table-cell",
49
+ children: [{
50
+ type: "paragraph",
51
+ children: [{
52
+ text: ""
53
+ }],
54
+ cellBgColor: "#FFFFFF"
55
+ }]
56
+ }, {
57
+ type: "table-cell",
58
+ children: [{
59
+ type: "paragraph",
60
+ children: [{
61
+ text: ""
62
+ }],
63
+ cellBgColor: "#FFFFFF"
64
+ }],
65
+ size: {
66
+ widthInPercent: 100,
67
+ height: 100,
68
+ width: 365.3307291666667
69
+ }
70
+ }]
71
+ }, {
72
+ type: "table-row",
73
+ children: [{
74
+ type: "table-cell",
75
+ children: [{
76
+ type: "paragraph",
77
+ children: [{
78
+ text: ""
79
+ }],
80
+ cellBgColor: "#FFFFFF"
81
+ }]
82
+ }, {
83
+ type: "table-cell",
84
+ children: [{
85
+ type: "paragraph",
86
+ children: [{
87
+ text: ""
88
+ }],
89
+ cellBgColor: "#FFFFFF"
90
+ }]
91
+ }, {
92
+ type: "table-cell",
93
+ children: [{
94
+ type: "paragraph",
95
+ children: [{
96
+ text: ""
97
+ }],
98
+ cellBgColor: "#FFFFFF"
99
+ }],
100
+ size: {
101
+ height: 300,
102
+ widthInPercent: 100
103
+ }
104
+ }]
105
+ }],
106
+ rows: 3,
107
+ columns: 3
108
+ });
4
109
  const prefixKey = (obj, pk = "") => {
5
110
  return Object.keys(obj).reduce((a, b) => {
6
111
  a[`${pk}${b}`] = obj[b];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"