@flozy/editor 10.1.5 → 10.1.6

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.
@@ -1391,6 +1391,10 @@ code.markcode {
1391
1391
  fill: #2563EB;
1392
1392
  }
1393
1393
 
1394
+ .themePaintIcon:hover .iconStroke {
1395
+ stroke: #2563EB;
1396
+ }
1397
+
1394
1398
  .hyperLink {
1395
1399
  word-break: break-all;
1396
1400
  }
@@ -21,6 +21,8 @@ import { FORM_NODE } from "../../utils/form";
21
21
  import { DEFAULT_TABLE_NODE } from "../../utils/table";
22
22
  import itemOptions from "./Options/sectionItemOptions";
23
23
  import { getBreakPointsValue, groupByBreakpoint } from "../../helper/theme";
24
+ import { useDebouncedCallback } from "use-debounce";
25
+ import { getNewElementXsValues } from "./helper";
24
26
  import { jsx as _jsx } from "react/jsx-runtime";
25
27
  import { jsxs as _jsxs } from "react/jsx-runtime";
26
28
  const MAX_DEVICE_WIDTH = {
@@ -79,6 +81,9 @@ const FreeGrid = props => {
79
81
  const count = useRef(2);
80
82
  const childrenCountRef = useRef(element?.children?.length);
81
83
  const [isInteracting, setIsInteracting] = useState(false);
84
+ const debouncedStopInteraction = useDebouncedCallback(() => {
85
+ setIsInteracting(false);
86
+ }, 500);
82
87
  const onChange = data => {
83
88
  const append = breakpoint === "lg" ? "" : `_${breakpoint}`;
84
89
  const updateData = {
@@ -176,6 +181,10 @@ const FreeGrid = props => {
176
181
  const handleAddElementClick = type => () => {
177
182
  const isEmpty = isEmptySection();
178
183
  const insertAt = isEmpty ? [...path, 0] : [...path, childrenCountRef.current];
184
+ const {
185
+ xsVal,
186
+ sectionHeightXs
187
+ } = getNewElementXsValues(type, element?.children);
179
188
  switch (type) {
180
189
  case "addText":
181
190
  Transforms.insertNodes(editor, [{
@@ -192,7 +201,8 @@ const FreeGrid = props => {
192
201
  marginTop: 0,
193
202
  top: 0,
194
203
  width: 170,
195
- height: 30
204
+ height: 30,
205
+ ...(xsVal || {})
196
206
  }], {
197
207
  at: [...insertAt]
198
208
  });
@@ -218,7 +228,8 @@ const FreeGrid = props => {
218
228
  marginTop: 0,
219
229
  top: 0,
220
230
  width: 143,
221
- height: 50
231
+ height: 50,
232
+ ...(xsVal || {})
222
233
  }], {
223
234
  at: [...insertAt]
224
235
  });
@@ -244,8 +255,9 @@ const FreeGrid = props => {
244
255
  top: 0,
245
256
  width: 217,
246
257
  height: 173,
247
- width_xs: 217,
248
- height_xs: 173
258
+ // width_xs: 217,
259
+ // height_xs: 173,
260
+ ...(xsVal || {})
249
261
  }], {
250
262
  at: [...insertAt]
251
263
  });
@@ -268,7 +280,8 @@ const FreeGrid = props => {
268
280
  marginTop: 0,
269
281
  top: 0,
270
282
  width: 170,
271
- height: 80
283
+ height: 80,
284
+ ...(xsVal || {})
272
285
  }], {
273
286
  at: [...insertAt]
274
287
  });
@@ -281,7 +294,8 @@ const FreeGrid = props => {
281
294
  images: []
282
295
  }), {
283
296
  height: 370,
284
- width: 650
297
+ width: 650,
298
+ ...(xsVal || {})
285
299
  })
286
300
  }], {
287
301
  at: [...insertAt]
@@ -293,7 +307,8 @@ const FreeGrid = props => {
293
307
  ...DEFAULT_TABLE_NODE()
294
308
  }, {
295
309
  height: 150,
296
- width: 400
310
+ width: 400,
311
+ ...(xsVal || {})
297
312
  })
298
313
  }], {
299
314
  at: [...insertAt]
@@ -317,7 +332,8 @@ const FreeGrid = props => {
317
332
  marginTop: 0,
318
333
  top: 0,
319
334
  width: 400,
320
- height: 300
335
+ height: 300,
336
+ ...(xsVal || {})
321
337
  }], {
322
338
  at: [...insertAt]
323
339
  });
@@ -329,7 +345,9 @@ const FreeGrid = props => {
329
345
  children: [{
330
346
  text: ""
331
347
  }]
332
- }, {}, "freegridBox")
348
+ }, {
349
+ ...(xsVal || {})
350
+ }, "freegridBox")
333
351
  }], {
334
352
  at: [...insertAt]
335
353
  });
@@ -340,7 +358,8 @@ const FreeGrid = props => {
340
358
  ...FORM_NODE()
341
359
  }, {
342
360
  height: 92,
343
- width: 400
361
+ width: 400,
362
+ ...(xsVal || {})
344
363
  })
345
364
  }], {
346
365
  at: [...insertAt]
@@ -354,7 +373,8 @@ const FreeGrid = props => {
354
373
  })
355
374
  }, {
356
375
  height: 60,
357
- width: 400
376
+ width: 400,
377
+ ...(xsVal || {})
358
378
  })
359
379
  }], {
360
380
  at: [...insertAt]
@@ -375,19 +395,18 @@ const FreeGrid = props => {
375
395
  marginTop: 0,
376
396
  top: 0,
377
397
  width: 170,
378
- height: 30
398
+ height: 30,
399
+ ...(xsVal || {})
379
400
  }], {
380
401
  at: [...insertAt]
381
402
  });
382
403
  break;
383
404
  default:
384
405
  }
385
- if (breakpoint === "lg") {
406
+ if (xsVal) {
386
407
  setSelectedElement({});
387
-
388
- // auto align in mobile
389
408
  Transforms.setNodes(editor, {
390
- xs_updatedOn: null,
409
+ height_xs: sectionHeightXs,
391
410
  updated_at: new Date().getTime()
392
411
  }, {
393
412
  at: path
@@ -480,7 +499,11 @@ const FreeGrid = props => {
480
499
  return /*#__PURE__*/_jsx(FreeGridContext.Provider, {
481
500
  value: {
482
501
  isInteracting,
483
- setIsInteracting
502
+ handleStart: () => {
503
+ setIsInteracting(true);
504
+ debouncedStopInteraction.cancel();
505
+ },
506
+ handleStop: debouncedStopInteraction
484
507
  },
485
508
  children: /*#__PURE__*/_jsx(RnD, {
486
509
  id: `freegrid_container_${path.join("|")}_${updated_at}_${breakpoint}`,
@@ -0,0 +1,113 @@
1
+ import { ROW_HEIGHT } from "../../common/RnD/Utils/gridDropItem";
2
+ import { getElementOffset } from "../../common/RnD/VirtualElement/VirtualTextElement";
3
+ export const ELEMENT_CASE = {
4
+ ADD_TEXT: "addText",
5
+ ADD_BUTTON: "addButton",
6
+ ADD_SIGNATURE: "addSignature",
7
+ ADD_IMAGE: "addImage",
8
+ ADD_VIDEO: "addVideo",
9
+ ADD_TABLE: "addTable",
10
+ ADD_CODE: "addCode",
11
+ ADD_BOX: "addBox",
12
+ ADD_FORM: "addForm",
13
+ ADD_APP_HEADER: "addAppHeader",
14
+ ADD_DIVIDER: "addDivider"
15
+ };
16
+ const commonXsValues = {
17
+ top_xs: 0,
18
+ marginTop_xs: 12,
19
+ left_xs: 24,
20
+ width_xs: 272,
21
+ xs_updatedOn: new Date().getTime()
22
+ };
23
+ const elementXsValues = {
24
+ [ELEMENT_CASE.ADD_TEXT]: {
25
+ ...commonXsValues,
26
+ height_xs: 50
27
+ },
28
+ [ELEMENT_CASE.ADD_BUTTON]: {
29
+ ...commonXsValues,
30
+ height_xs: 50
31
+ },
32
+ [ELEMENT_CASE.ADD_SIGNATURE]: {
33
+ ...commonXsValues,
34
+ height_xs: 173
35
+ },
36
+ [ELEMENT_CASE.ADD_IMAGE]: {
37
+ ...commonXsValues,
38
+ height_xs: 80
39
+ },
40
+ [ELEMENT_CASE.ADD_VIDEO]: {
41
+ ...commonXsValues,
42
+ height_xs: 300
43
+ },
44
+ [ELEMENT_CASE.ADD_TABLE]: {
45
+ ...commonXsValues,
46
+ height_xs: 165
47
+ },
48
+ [ELEMENT_CASE.ADD_CODE]: {
49
+ ...commonXsValues,
50
+ height: 300
51
+ },
52
+ [ELEMENT_CASE.ADD_BOX]: {
53
+ ...commonXsValues,
54
+ height_xs: 300
55
+ },
56
+ [ELEMENT_CASE.ADD_FORM]: {
57
+ ...commonXsValues,
58
+ height_xs: 80
59
+ },
60
+ [ELEMENT_CASE.ADD_APP_HEADER]: {
61
+ ...commonXsValues,
62
+ height_xs: 80
63
+ },
64
+ [ELEMENT_CASE.ADD_DIVIDER]: {
65
+ ...commonXsValues,
66
+ height_xs: 24
67
+ }
68
+ };
69
+ export const findMaxYValue = sectionItems => {
70
+ let maxY = 0;
71
+ sectionItems.forEach(item => {
72
+ if (item?.type && item?.type !== "paragraph") {
73
+ const {
74
+ bottom
75
+ } = getElementOffset(item);
76
+ maxY = Math.max(maxY, bottom);
77
+ }
78
+ });
79
+ return maxY;
80
+ };
81
+ export const convertToGridArea = y => {
82
+ // Calculate grid position
83
+ const row = Math.floor(y / ROW_HEIGHT) + 1;
84
+
85
+ // to calculate difference inside the grid
86
+ const marginTop = Math.abs((row - 1) * ROW_HEIGHT - y);
87
+
88
+ // Update grid area
89
+ const gridArea = `${row} / 1 / ${row + 1} / 2`;
90
+ return {
91
+ gridArea,
92
+ marginTop
93
+ };
94
+ };
95
+ export const getNewElementXsValues = (type, sectionItems) => {
96
+ const values = elementXsValues[type] || {};
97
+ const y = sectionItems?.length ? findMaxYValue(sectionItems) : 0;
98
+ const {
99
+ gridArea,
100
+ marginTop
101
+ } = convertToGridArea(y);
102
+ const BUFFER_MARGIN_TOP = 12;
103
+ const xsVal = {
104
+ ...values,
105
+ gridArea_xs: gridArea,
106
+ marginTop_xs: marginTop + BUFFER_MARGIN_TOP
107
+ };
108
+ const sectionHeightXs = y + values?.height_xs + BUFFER_MARGIN_TOP + 12;
109
+ return {
110
+ xsVal,
111
+ sectionHeightXs
112
+ };
113
+ };
@@ -11,7 +11,7 @@ export const ThemePaintIcon = () => /*#__PURE__*/_jsxs("svg", {
11
11
  fill: "#64748B",
12
12
  stroke: "#64748B",
13
13
  strokeWidth: "0.5",
14
- className: "iconBorder"
14
+ className: "iconBorder iconStroke"
15
15
  }), /*#__PURE__*/_jsx("path", {
16
16
  fillRule: "evenodd",
17
17
  clipRule: "evenodd",
@@ -2,6 +2,7 @@ import { Transforms, Node, Path, Editor } from "slate";
2
2
  import { ReactEditor } from "slate-react";
3
3
  import { getNode, handleNegativeInteger } from "../../../utils/helper";
4
4
  import { handleBoxAlignment } from "../VirtualElement/helper";
5
+ import { convertToGridArea, findMaxYValue } from "../../../Elements/FreeGrid/helper";
5
6
  export const ROW_HEIGHT = 50;
6
7
 
7
8
  // const MARGIN_OF = {
@@ -22,18 +23,27 @@ export function updateRows() {}
22
23
  export function updateCols() {}
23
24
  const handleMoveNode = (editor, path, newPath, {
24
25
  isEmpty
25
- }, autoAlign) => {
26
+ }, autoAlign, moveToNode) => {
26
27
  try {
27
28
  let replaceNode = Node.get(editor, path);
29
+ let heightDiff = 0;
28
30
  if (autoAlign) {
29
- // reset node for auto alignment in mobile
31
+ const y = findMaxYValue(moveToNode?.children);
32
+ const {
33
+ gridArea,
34
+ marginTop
35
+ } = convertToGridArea(y);
30
36
  replaceNode = {
31
37
  ...replaceNode,
32
- gridArea_xs: null,
33
- xs_updatedOn: null,
34
- marginTop_xs: null
38
+ gridArea_xs: gridArea,
39
+ marginTop_xs: marginTop + 12,
40
+ xs_updatedOn: new Date().getTime()
35
41
  };
42
+ const newHeight = y + replaceNode?.height_xs + 12;
43
+ const diffH = newHeight - moveToNode?.height_xs;
44
+ heightDiff = diffH >= 0 ? diffH : 0;
36
45
  }
46
+ let rPath;
37
47
  if (isEmpty) {
38
48
  const toPath = [...newPath, 0];
39
49
  Transforms.insertNodes(editor, [{
@@ -44,7 +54,7 @@ const handleMoveNode = (editor, path, newPath, {
44
54
  Transforms.removeNodes(editor, {
45
55
  at: path
46
56
  });
47
- return toPath;
57
+ rPath = toPath;
48
58
  } else {
49
59
  Transforms.insertNodes(editor, [{
50
60
  ...replaceNode
@@ -54,8 +64,12 @@ const handleMoveNode = (editor, path, newPath, {
54
64
  Transforms.removeNodes(editor, {
55
65
  at: path
56
66
  });
57
- return newPath;
67
+ rPath = newPath;
58
68
  }
69
+ return {
70
+ rPath,
71
+ heightDiff
72
+ };
59
73
  } catch (err) {
60
74
  console.log(err);
61
75
  console.log("Drop Node error");
@@ -210,7 +224,7 @@ export function onDropItem(props, parentClass) {
210
224
  at: moveTo,
211
225
  match: n => n.type === "freegrid"
212
226
  });
213
- const [sectionNode, sectionPath] = sectionData || [];
227
+ const [, sectionPath] = sectionData || [];
214
228
  if (needMove && isInsidePath(from, moveTo)) {
215
229
  reRenderSectionPath = sectionPath;
216
230
  } else {
@@ -229,13 +243,6 @@ export function onDropItem(props, parentClass) {
229
243
  const isBoxHeader = currentNode?.childType === "appHeader" && moveTo?.length > 2;
230
244
  if (isBoxHeader) {
231
245
  // will handle on <BoxHeaderAutoAlignment />
232
- } else if (moveTo?.length === 2 && autoAlign) {
233
- // auto align in mobile
234
- Transforms.setNodes(editor, {
235
- xs_updatedOn: null
236
- }, {
237
- at: moveTo
238
- });
239
246
  } else if (autoAlign) {
240
247
  Transforms.setNodes(editor, {
241
248
  autoAlign: true,
@@ -244,12 +251,15 @@ export function onDropItem(props, parentClass) {
244
251
  at: moveTo
245
252
  });
246
253
  }
247
- const rPath = handleMoveNode(editor, path, newPath, {
254
+ const {
255
+ rPath,
256
+ heightDiff
257
+ } = handleMoveNode(editor, path, newPath, {
248
258
  isEmpty
249
- }, autoAlign);
259
+ }, autoAlign, toSectionNode) || {};
250
260
  reRenderChildNodes(editor, reRenderSectionPath || moveTo);
251
261
  if (autoAlign && !isBoxHeader) {
252
- handleBoxAlignment(editor, sectionNode, sectionPath);
262
+ handleBoxAlignment(editor, sectionPath, heightDiff);
253
263
  }
254
264
  return {
255
265
  updated_at: rPath
@@ -87,7 +87,9 @@ export function updatePositions(props, closestClass) {
87
87
  newPath = [...newPath, toSectionNode?.children?.length];
88
88
  }
89
89
  newPath = newPath.map(m => parseInt(m));
90
- const rPath = handleMoveNode(editor, path, newPath, {
90
+ const {
91
+ rPath
92
+ } = handleMoveNode(editor, path, newPath, {
91
93
  isEmpty
92
94
  });
93
95
  // to update path index need to re-render items in parent sections
@@ -1,71 +1,57 @@
1
1
  import { useEffect, useRef } from "react";
2
- import { Path, Transforms } from "slate";
3
2
  import { getNode } from "../../../utils/helper";
4
3
  import { ROW_HEIGHT } from "../Utils/gridDropItem";
5
- import { findFirstRowOverlap, getGridArea, handleContainers, moveOverlappedItems } from "./helper";
4
+ import { getGridArea, handleTextAlignment } from "./helper";
6
5
  import { Box } from "@mui/material";
7
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
+ export const getElementOffset = element => {
8
+ const {
9
+ marginTop_xs: marginTop,
10
+ gridArea_xs: gridArea,
11
+ height_xs: height
12
+ } = element;
13
+ const [startRow] = getGridArea(gridArea);
14
+ const top = (startRow - 1) * ROW_HEIGHT + marginTop;
15
+ const bottom = top + height;
16
+ return {
17
+ top,
18
+ bottom
19
+ };
20
+ };
8
21
  const updateTextHeight = (editor, path, height) => {
9
22
  if (!height) {
10
23
  return;
11
24
  }
12
- const parentPath = Path.parent(path);
13
- const currentNode = getNode(editor, parentPath);
14
- const gridItems = currentNode?.children || [];
15
- const isNewlyAddedElement = gridItems.some(gridItem => !gridItem.gridArea_xs && gridItem.type !== "paragraph");
16
- if (isNewlyAddedElement) {
25
+ const textItem = getNode(editor, path);
26
+ if (!textItem) {
17
27
  return;
18
28
  }
19
- const textItemIndex = path[parentPath.length];
20
- const textItem = gridItems.find((_, index) => textItemIndex === index);
21
29
  const {
22
- marginTop_xs: marginTop,
23
- gridArea_xs: gridArea,
24
- height_xs
30
+ height_xs,
31
+ gridArea_xs,
32
+ type
25
33
  } = textItem;
26
- const oldHeight = height_xs + marginTop;
27
- const newHeight = height + marginTop;
28
- const extraHeight = newHeight - oldHeight;
29
- let containerExtraHeight = extraHeight;
30
- if (extraHeight > 0) {
31
- const [startRow] = getGridArea(gridArea);
32
- const newRows = Math.floor(newHeight / ROW_HEIGHT) + 1;
33
- const endRow = startRow + newRows;
34
- const firstOverlappedRow = findFirstRowOverlap(gridItems, startRow, endRow, textItemIndex);
35
- if (firstOverlappedRow) {
36
- const moveRows = endRow - firstOverlappedRow;
37
- moveOverlappedItems(editor, moveRows, gridItems, parentPath, textItemIndex, startRow);
38
- containerExtraHeight += moveRows * ROW_HEIGHT;
39
- }
40
-
41
- // handle containers (box and section)
42
- const containerData = handleContainers(editor, parentPath, containerExtraHeight);
43
- containerData.forEach(container => {
44
- const {
45
- moveRows,
46
- containerNode,
47
- containerPath,
48
- newHeight,
49
- childIndex,
50
- lastChildStartRow
51
- } = container;
52
- if (moveRows) {
53
- moveOverlappedItems(editor, moveRows, containerNode?.children, containerPath, childIndex, lastChildStartRow);
54
- }
55
- Transforms.setNodes(editor, {
56
- height_xs: newHeight,
57
- xs_updatedOn: new Date().getTime()
58
- }, {
59
- at: containerPath
60
- });
61
- });
62
- Transforms.setNodes(editor, {
63
- height_xs: height
64
- }, {
65
- at: path
66
- });
34
+ if (!gridArea_xs && type !== "paragraph") {
35
+ return;
67
36
  }
37
+ const oldHeight = height_xs;
38
+ const newHeight = height;
39
+ const heightDiff = newHeight - oldHeight;
40
+ if (heightDiff !== 0) {
41
+ const textNode = [textItem, path];
42
+ handleTextAlignment(editor, textNode, heightDiff);
43
+ }
44
+ // else if (heightDiff < 0) {
45
+ // Transforms.setNodes(
46
+ // editor,
47
+ // {
48
+ // height_xs: newHeight,
49
+ // },
50
+ // { at: path }
51
+ // );
52
+ // }
68
53
  };
54
+
69
55
  function VirtualTextElement(props) {
70
56
  const {
71
57
  dataSets,
@@ -75,7 +61,6 @@ function VirtualTextElement(props) {
75
61
  } = props;
76
62
  const currElement = getCurrentEle();
77
63
  const textRef = useRef(null);
78
- const prevTextRef = useRef(currElement?.innerText);
79
64
  useEffect(() => {
80
65
  const observer = new ResizeObserver(([entry]) => {
81
66
  if (entry) {
@@ -83,11 +68,9 @@ function VirtualTextElement(props) {
83
68
  height
84
69
  } = entry.contentRect;
85
70
  const currentText = currElement?.innerText;
86
- const prevText = prevTextRef.current;
87
- if (currentText && currentText !== prevText) {
71
+ if (currentText && height) {
88
72
  updateTextHeight(editor, path, height);
89
73
  }
90
- prevTextRef.current = currentText;
91
74
  }
92
75
  });
93
76
  const elementRef = textRef?.current;
@@ -122,6 +105,14 @@ function VirtualTextElement(props) {
122
105
  },
123
106
  "& .editor-blocker": {
124
107
  display: "none"
108
+ },
109
+ "& .fgi_type_text": {
110
+ "& .edt-headings": {
111
+ margin: "0px"
112
+ },
113
+ "& .edt-paragraphs": {
114
+ margin: "0px"
115
+ }
125
116
  }
126
117
  },
127
118
  dangerouslySetInnerHTML: {
@@ -1,5 +1,6 @@
1
1
  import { ROW_HEIGHT, calculateGridArea } from "../Utils/gridDropItem";
2
2
  import { Transforms, Editor } from "slate";
3
+ import { getElementOffset } from "./VirtualTextElement";
3
4
  const isBulletOrTickIcon = (width, itemStartRow, startRow) => {
4
5
  return width <= 40 && itemStartRow === startRow;
5
6
  };
@@ -39,106 +40,83 @@ export const getGridArea = gridArea => {
39
40
  const getBoxToAutoAlign = (editor, sectionPath) => {
40
41
  const [boxData] = Editor.nodes(editor, {
41
42
  at: sectionPath,
42
- match: node => node.type === "freegridBox" && node.autoAlign
43
+ match: node => ["freegridBox", "freegrid"].includes(node.type) && node.autoAlign
43
44
  });
44
45
  return boxData || [];
45
46
  };
46
- const handleGridItems = (gridItems, lastRow) => {
47
- // to find the previously occupied rows
48
- gridItems.forEach(item => {
49
- const {
50
- gridArea_xs: gridArea,
51
- marginTop_xs,
52
- height_xs,
53
- type
54
- } = item;
55
- if (type === "paragraph") {
56
- // non-freegridItem,
57
- // some "paragraph" node is defaulty coming inside in box's children
58
- return;
59
- }
60
- const [startRow] = getGridArea(gridArea);
61
- const marginTop = marginTop_xs ? Number(marginTop_xs) : 0;
62
- const fullHeight = Number(height_xs) + marginTop;
63
- const endRow = startRow + Math.floor(fullHeight / ROW_HEIGHT) + 1;
64
- lastRow = Math.max(endRow, lastRow);
65
- });
66
- return {
67
- lastRow
68
- };
69
- };
70
- const handleNonGridItems = (nonGridItems, lastRow, editor, boxPath) => {
71
- let containerHeight = (lastRow - 1) * ROW_HEIGHT;
72
- let newlyAddedHeight = 0;
73
47
 
74
- //place it on the next rows that are available
75
- nonGridItems.forEach((item, index) => {
76
- const {
77
- height_xs,
78
- type,
79
- itemIndex
80
- } = item;
81
- if (type === "paragraph") {
82
- // non-freegridItem
83
- return;
84
- }
85
- const startRow = lastRow || 1;
86
- const DEFAULT_NEW_ELEMENT_MARGIN_TOP = 12;
87
- let fullHeight = height_xs + DEFAULT_NEW_ELEMENT_MARGIN_TOP;
88
- const endRow = startRow + Math.floor(fullHeight / ROW_HEIGHT) + 1;
89
- const newGridArea = `${startRow} / 1 / ${startRow + 1} / 2`;
90
- const currentElementPath = [...boxPath, itemIndex];
91
- Transforms.setNodes(editor, {
92
- gridArea_xs: newGridArea,
93
- marginTop_xs: 12,
94
- left_xs: 12,
95
- xs_updatedOn: new Date().getTime()
96
- }, {
97
- at: currentElementPath
98
- });
99
- lastRow = Math.max(endRow, lastRow);
100
- containerHeight += fullHeight;
101
- newlyAddedHeight += fullHeight;
102
- });
103
- return {
104
- lastRow,
105
- containerHeight,
106
- newlyAddedHeight
107
- };
108
- };
109
- const alignNewElementInContainer = (editor, boxPath, containerItems) => {
110
- let lastRow = 1;
111
- const gridItems = [];
112
- const nonGridItems = [];
113
- containerItems.forEach((item, index) => {
114
- if (item?.gridArea_xs) {
115
- gridItems.push({
116
- ...item,
117
- itemIndex: index
118
- });
119
- } else {
120
- nonGridItems.push({
121
- ...item,
122
- itemIndex: index
123
- });
124
- }
125
- });
126
- const {
127
- lastRow: lastRowOccupied
128
- } = handleGridItems(gridItems, lastRow);
129
- lastRow = lastRowOccupied;
130
- const {
131
- lastRow: lastRowTaken,
132
- containerHeight,
133
- newlyAddedHeight
134
- } = handleNonGridItems(nonGridItems, lastRow, editor, boxPath);
135
- lastRow = lastRowTaken;
136
- return {
137
- lastRow,
138
- containerHeight,
139
- newlyAddedHeight
140
- };
141
- };
48
+ // const handleGridItems = (gridItems, lastRow) => {
49
+ // // to find the previously occupied rows
50
+ // gridItems.forEach((item) => {
51
+ // const { gridArea_xs: gridArea, marginTop_xs, height_xs, type } = item;
52
+
53
+ // if (type === "paragraph") {
54
+ // // non-freegridItem,
55
+ // // some "paragraph" node is defaulty coming inside in box's children
56
+ // return;
57
+ // }
58
+
59
+ // const [startRow] = getGridArea(gridArea);
60
+ // const marginTop = marginTop_xs ? Number(marginTop_xs) : 0;
61
+ // const fullHeight = Number(height_xs) + marginTop;
62
+
63
+ // const endRow = startRow + Math.floor(fullHeight / ROW_HEIGHT) + 1;
64
+
65
+ // lastRow = Math.max(endRow, lastRow);
66
+ // });
67
+
68
+ // return { lastRow };
69
+ // };
70
+
71
+ // const handleNonGridItems = (nonGridItems, lastRow, editor, boxPath) => {
72
+ // let containerHeight = (lastRow - 1) * ROW_HEIGHT;
73
+
74
+ // let newlyAddedHeight = 0;
75
+
76
+ // //place it on the next rows that are available
77
+ // nonGridItems.forEach((item, index) => {
78
+ // const { height_xs, type, itemIndex } = item;
79
+
80
+ // if (type === "paragraph") {
81
+ // // non-freegridItem
82
+ // return;
83
+ // }
84
+
85
+ // const startRow = lastRow || 1;
86
+
87
+ // const DEFAULT_NEW_ELEMENT_MARGIN_TOP = 12;
88
+ // let fullHeight = height_xs + DEFAULT_NEW_ELEMENT_MARGIN_TOP;
89
+
90
+ // const endRow = startRow + Math.floor(fullHeight / ROW_HEIGHT) + 1;
91
+
92
+ // const newGridArea = `${startRow} / 1 / ${startRow + 1} / 2`;
93
+
94
+ // const currentElementPath = [...boxPath, itemIndex];
95
+
96
+ // Transforms.setNodes(
97
+ // editor,
98
+ // {
99
+ // gridArea_xs: newGridArea,
100
+ // marginTop_xs: 12,
101
+ // left_xs: 12,
102
+ // xs_updatedOn: new Date().getTime(),
103
+ // },
104
+ // { at: currentElementPath }
105
+ // );
106
+
107
+ // lastRow = Math.max(endRow, lastRow);
108
+
109
+ // containerHeight += fullHeight;
110
+ // newlyAddedHeight += fullHeight;
111
+ // });
112
+
113
+ // return {
114
+ // lastRow,
115
+ // containerHeight,
116
+ // newlyAddedHeight,
117
+ // };
118
+ // };
119
+
142
120
  const getAncestorFreeGridContainers = (editor, path) => {
143
121
  const containers = [...Editor.nodes(editor, {
144
122
  at: path,
@@ -151,6 +129,12 @@ const getAncestorFreeGridContainers = (editor, path) => {
151
129
  })].filter(([node, nodePath]) => nodePath.length <= path.length);
152
130
  return containers;
153
131
  };
132
+ export const handleTextAlignment = (editor, textNode, heightDiff) => {
133
+ const [, textPath] = textNode;
134
+ let containers = getAncestorFreeGridContainers(editor, textPath);
135
+ containers = [...containers, textNode];
136
+ handleContainersAlignment(editor, containers, heightDiff, 0);
137
+ };
154
138
  export const handleContainers = (editor, boxPath, extraHeight) => {
155
139
  const containers = getAncestorFreeGridContainers(editor, boxPath);
156
140
  let lastChildStartRow;
@@ -213,6 +197,7 @@ export const moveOverlappedItems = (editor, moveRows, containerItems, containerP
213
197
  return;
214
198
  }
215
199
  if (gridItem.type === "paragraph") {
200
+ // some empty paragraph node is inserted default'ly inside box, to avoid that
216
201
  return;
217
202
  }
218
203
  const {
@@ -235,7 +220,61 @@ export const moveOverlappedItems = (editor, moveRows, containerItems, containerP
235
220
  }
236
221
  });
237
222
  };
238
- export const handleBoxAlignment = (editor, sectionNode, sectionPath) => {
223
+ export const handleContainersAlignment = (editor, containers, heightDiff, bufferSpace = 0) => {
224
+ for (let i = containers.length - 1; i >= 0; i--) {
225
+ const container = containers[i];
226
+ const childContainer = containers[i + 1];
227
+ const [containerNode, containerPath] = container;
228
+ const [childContainerNode, childContainerPath] = childContainer || [];
229
+ if (childContainer) {
230
+ const {
231
+ bottom
232
+ } = getElementOffset(childContainerNode);
233
+ containerNode.children.forEach((item, index) => {
234
+ const currPath = [...containerPath, index];
235
+ if (currPath.toString() === childContainerPath.toString()) {
236
+ return;
237
+ }
238
+ if (item.type === "paragraph") {
239
+ return;
240
+ }
241
+ const {
242
+ top: itemTop
243
+ } = getElementOffset(item);
244
+ if (itemTop >= bottom) {
245
+ const {
246
+ gridArea_xs,
247
+ marginTop_xs
248
+ } = item;
249
+ const [startRow] = getGridArea(gridArea_xs);
250
+ const y = (startRow - 1) * ROW_HEIGHT + marginTop_xs + heightDiff;
251
+
252
+ // Calculate grid position
253
+ const row = Math.floor(y / ROW_HEIGHT) + 1;
254
+
255
+ // to calculate difference inside the grid
256
+ const marginTop = Math.abs((row - 1) * ROW_HEIGHT - y);
257
+
258
+ // Update grid area
259
+ const gridArea = `${row} / 1 / ${row + 1} / 2`;
260
+ Transforms.setNodes(editor, {
261
+ gridArea_xs: gridArea,
262
+ marginTop_xs: marginTop + bufferSpace
263
+ }, {
264
+ at: currPath
265
+ });
266
+ }
267
+ });
268
+ }
269
+ Transforms.setNodes(editor, {
270
+ height_xs: containerNode?.height_xs + heightDiff + bufferSpace,
271
+ xs_updatedOn: new Date().getTime()
272
+ }, {
273
+ at: containerPath
274
+ });
275
+ }
276
+ };
277
+ export const handleBoxAlignment = (editor, sectionPath, heightDiff) => {
239
278
  const [boxNode, boxPath] = getBoxToAutoAlign(editor, sectionPath);
240
279
  Transforms.setNodes(editor, {
241
280
  autoAlign: false
@@ -245,39 +284,11 @@ export const handleBoxAlignment = (editor, sectionNode, sectionPath) => {
245
284
  if (!boxNode) {
246
285
  return;
247
286
  }
248
- const containerItems = boxNode?.children || [];
249
- const {
250
- containerHeight
251
- } = alignNewElementInContainer(editor, boxPath, containerItems);
252
- const bufferHeight = 12;
253
- const newHeight = containerHeight + bufferHeight;
254
- const {
255
- height_xs
256
- } = boxNode;
257
- const oldHeight = Number(height_xs);
258
- const extraHeight = newHeight - oldHeight;
259
- if (extraHeight > 0) {
260
- const containerData = handleContainers(editor, boxPath, extraHeight);
261
- containerData.forEach(container => {
262
- const {
263
- moveRows,
264
- containerNode,
265
- containerPath,
266
- newHeight,
267
- childIndex,
268
- lastChildStartRow
269
- } = container;
270
- if (moveRows) {
271
- moveOverlappedItems(editor, moveRows, containerNode?.children, containerPath, childIndex, lastChildStartRow);
272
- }
273
- Transforms.setNodes(editor, {
274
- height_xs: newHeight,
275
- xs_updatedOn: new Date().getTime()
276
- }, {
277
- at: containerPath
278
- });
279
- });
287
+ if (heightDiff <= 0) {
288
+ return;
280
289
  }
290
+ let containers = getAncestorFreeGridContainers(editor, boxPath);
291
+ handleContainersAlignment(editor, containers, heightDiff, 12);
281
292
  };
282
293
  export const getMarginTop = y => {
283
294
  const calcMargin = y % ROW_HEIGHT;
@@ -18,6 +18,14 @@ const useVirtualElementStyles = () => ({
18
18
  "& .editor-blocker": {
19
19
  display: "none"
20
20
  },
21
+ "& .fgi_type_text": {
22
+ "& .edt-headings": {
23
+ margin: "0px"
24
+ },
25
+ "& .edt-paragraphs": {
26
+ margin: "0px"
27
+ }
28
+ },
21
29
  "& .freegrid-item": {
22
30
  position: "relative !important",
23
31
  top: "0 !important",
@@ -97,6 +105,14 @@ export const useAutoAlignStyles = () => ({
97
105
  "&.type_text": {
98
106
  height: "auto !important"
99
107
  },
108
+ "& .fgi_type_text": {
109
+ "& .edt-headings": {
110
+ margin: "0px"
111
+ },
112
+ "& .edt-paragraphs": {
113
+ margin: "0px"
114
+ }
115
+ },
100
116
  // start - default signature classes on free-grid
101
117
  "& .fgi_type_signature": {
102
118
  height: "100%",
@@ -12,7 +12,7 @@ import GuideLines from "./GuideLines";
12
12
  import ShadowElement from "./ShadowElement";
13
13
  import BoundaryLine from "./GuideLines/BoundaryLine";
14
14
  import ContextMenu from "./ContextMenu";
15
- import VirtualElement from "./VirtualElement";
15
+ // import VirtualElement from "./VirtualElement";
16
16
  import { ItemTypes } from "./ElementSettings/settingsConstants";
17
17
  import { selectText } from "../../utils/helper";
18
18
  import { removeSign } from "./ElementSettings/OtherSettings";
@@ -125,7 +125,8 @@ const RnD = props => {
125
125
  } = useAutoScroll(10, "slate-wrapper-scroll-container");
126
126
  const {
127
127
  isInteracting,
128
- setIsInteracting
128
+ handleStart,
129
+ handleStop
129
130
  } = useFreeGrid();
130
131
  const {
131
132
  translation
@@ -323,7 +324,7 @@ const RnD = props => {
323
324
  };
324
325
  const onDragStart = e => {
325
326
  e.preventDefault();
326
- setIsInteracting(true);
327
+ handleStart();
327
328
  if (e?.target?.dataset?.path?.split(",").join("|") === sp) {
328
329
  const {
329
330
  left,
@@ -425,7 +426,7 @@ const RnD = props => {
425
426
  e.preventDefault();
426
427
  e.stopPropagation();
427
428
  stopAutoScroll();
428
- setIsInteracting(false);
429
+ handleStop();
429
430
  if (dragging?.isDragging === 2 && dragging?.position?.strXY && dragging?.dragOver) {
430
431
  d.x = e.x;
431
432
  d.y = e.y;
@@ -468,7 +469,7 @@ const RnD = props => {
468
469
  };
469
470
  const onResizeStop = (e, direction, ref, d, position) => {
470
471
  e.preventDefault();
471
- setIsInteracting(false);
472
+ handleStop();
472
473
  let updatedPosition = {};
473
474
  if (type !== "parent") {
474
475
  // update element position while resizing, (for free grid box and item)
@@ -498,7 +499,9 @@ const RnD = props => {
498
499
  ref
499
500
  }, ".freegrid-container-parent");
500
501
  const formatParentPath = parentPath?.split("|")?.map(m => parseInt(m));
501
- reRenderChildNodes(editor, formatParentPath);
502
+ if (formatParentPath) {
503
+ reRenderChildNodes(editor, formatParentPath);
504
+ }
502
505
  };
503
506
  const onCloseSettings = () => {
504
507
  setSelectedElement({
@@ -557,7 +560,7 @@ const RnD = props => {
557
560
  return {
558
561
  onResizeStart: e => {
559
562
  e.preventDefault();
560
- setIsInteracting(true);
563
+ handleStart();
561
564
  },
562
565
  onDragStart: onDragStart,
563
566
  onDrag: onDrag,
@@ -680,14 +683,7 @@ const RnD = props => {
680
683
  handleClose: handleClose,
681
684
  theme: theme,
682
685
  translation: translation
683
- }), type === "parent" && breakpoint === "lg" && !readOnly ? /*#__PURE__*/_jsx(VirtualElement, {
684
- updated_at: updated_at,
685
- path: str_path,
686
- editor: editor,
687
- sectionElement: sectionElement,
688
- sectionCls: `.freegrid-section_${path.join("_")}`,
689
- dataSets: dataSets
690
- }) : null, childType === "text" && breakpoint === "lg" && !readOnly && enable ? /*#__PURE__*/_jsx(VirtualTextElement, {
686
+ }), childType === "text" && breakpoint === "lg" && !readOnly && enable ? /*#__PURE__*/_jsx(VirtualTextElement, {
691
687
  editor: editor,
692
688
  dataSets: dataSets,
693
689
  getCurrentEle: getCurrentEle,
@@ -182,7 +182,7 @@ export function getElementProperty(element, styleProperty) {
182
182
 
183
183
  return style || "";
184
184
  }
185
- export const textThemeFields = ["fontFamily", "fontSize", "color", "bold", "italic"
185
+ export const textThemeFields = ["fontFamily", "fontSize", "color", "bold", "italic", "fontWeight"
186
186
  // "underline",
187
187
  // "strikethrough",
188
188
  ];
@@ -25,20 +25,30 @@ function ActiveTheme(props) {
25
25
  variant: "body1",
26
26
  className: "title activeThemeTitle",
27
27
  children: id ? "Active Theme" : "No theme activated"
28
- }), /*#__PURE__*/_jsxs(Grid, {
28
+ }), /*#__PURE__*/_jsx(Grid, {
29
29
  className: "flexAlign",
30
- children: [/*#__PURE__*/_jsx(Typography, {
31
- variant: "body1",
32
- className: "fs-14",
33
- children: name
34
- }), /*#__PURE__*/_jsxs(Typography, {
30
+ children: id ? /*#__PURE__*/_jsxs(_Fragment, {
31
+ children: [/*#__PURE__*/_jsx(Typography, {
32
+ variant: "body1",
33
+ className: "fs-14 flexItem",
34
+ title: name,
35
+ children: name
36
+ }), /*#__PURE__*/_jsxs(Typography, {
37
+ variant: "body2",
38
+ className: "fs-12 textSecondary flexItem",
39
+ style: {
40
+ marginLeft: id ? "4px" : "0px"
41
+ },
42
+ children: ["- ", mood_name]
43
+ })]
44
+ }) : /*#__PURE__*/_jsx(Typography, {
35
45
  variant: "body2",
36
46
  className: "fs-12 textSecondary",
37
47
  style: {
38
48
  marginLeft: id ? "4px" : "0px"
39
49
  },
40
- children: [id ? ` - ` : null, id ? mood_name : "Select 'Explore More' to activate a theme and customize your design."]
41
- })]
50
+ children: `Select 'Explore More' to activate a theme and customize your design.`
51
+ })
42
52
  }), /*#__PURE__*/_jsxs(Grid, {
43
53
  container: true,
44
54
  justifyContent: "space-between",
@@ -84,16 +84,17 @@ function getBtnSxProps(buttonStyle = {}, theme) {
84
84
  let newStyle = {
85
85
  ...buttonStyle
86
86
  };
87
- if (newStyle?.bannerSpacing) {
88
- newStyle.padding = newStyle?.bannerSpacing;
89
- }
87
+ // if (newStyle?.bannerSpacing) {
88
+ // newStyle.padding = newStyle?.bannerSpacing;
89
+ // }
90
+
90
91
  const btnSp = groupByBreakpoint({
91
92
  borderRadius: {
92
93
  ...getBreakPointsValue(newStyle?.borderRadius || {}, null, "overrideBorderRadius", true)
93
- },
94
- padding: {
95
- ...getTRBLBreakPoints(newStyle?.bannerSpacing)
96
94
  }
95
+ // padding: {
96
+ // ...getTRBLBreakPoints(newStyle?.bannerSpacing),
97
+ // },
97
98
  }, theme);
98
99
  newStyle = {
99
100
  ...newStyle,
@@ -232,19 +233,26 @@ const Buttons = props => {
232
233
  onClick: e => setAnchorEl(e.currentTarget),
233
234
  children: [/*#__PURE__*/_jsxs(Grid, {
234
235
  item: true,
235
- size: 12,
236
+ size: 8,
236
237
  children: [/*#__PURE__*/_jsx(Typography, {
237
238
  variant: "body1",
238
239
  className: "fw-600 fs-14",
240
+ style: {
241
+ marginBottom: "10px"
242
+ },
239
243
  children: "Theme Button"
240
244
  }), /*#__PURE__*/_jsx(Button, {
241
245
  sx: getBtnSxProps(button, theme),
242
246
  ref: buttonEl,
243
247
  children: "Button"
244
248
  })]
245
- }), /*#__PURE__*/_jsx(IconButton, {
246
- className: "editIcon",
247
- children: /*#__PURE__*/_jsx(PenIcon, {})
249
+ }), /*#__PURE__*/_jsx(Grid, {
250
+ item: true,
251
+ size: 4,
252
+ children: /*#__PURE__*/_jsx(IconButton, {
253
+ className: "editIcon",
254
+ children: /*#__PURE__*/_jsx(PenIcon, {})
255
+ })
248
256
  })]
249
257
  })
250
258
  })]
@@ -135,6 +135,7 @@ const ColorTheme = props => {
135
135
  style: {
136
136
  color: textColor
137
137
  },
138
+ title: color,
138
139
  children: color
139
140
  })]
140
141
  })
@@ -1,9 +1,9 @@
1
1
  const Style = () => ({
2
2
  ".primaryColorBoxes": {
3
3
  ".pmBox": {
4
- border: "1px solid #D1D1D1",
4
+ border: "1.5px solid #D1D1D1",
5
5
  height: "65px",
6
- borderRadius: "4px",
6
+ borderRadius: "6px",
7
7
  position: "relative",
8
8
  flexShrink: 0,
9
9
  "&:hover": {
@@ -17,9 +17,9 @@ const Style = () => ({
17
17
  ".secondaryColorBoxes": {
18
18
  gap: "10px",
19
19
  ".sdBox": {
20
- border: "1px solid #D1D1D1",
20
+ border: "1.5px solid #D1D1D1",
21
21
  height: "60px",
22
- borderRadius: "4px",
22
+ borderRadius: "6px",
23
23
  width: "100%",
24
24
  flexShrink: 0,
25
25
  position: "relative",
@@ -117,6 +117,12 @@ const Style = ({
117
117
  display: "flex",
118
118
  alignItems: "center"
119
119
  },
120
+ ".flexItem": {
121
+ maxWidth: "50%",
122
+ whiteSpace: "nowrap",
123
+ overflow: "hidden",
124
+ textOverflow: "ellipsis"
125
+ },
120
126
  ".activeColorBox, .xsColorBox": {
121
127
  width: "24px",
122
128
  height: "24px",
@@ -135,7 +141,7 @@ const Style = ({
135
141
  alignItems: "center"
136
142
  },
137
143
  ".themeCardWrapper": {
138
- padding: "6px 10px",
144
+ padding: "6px 14px",
139
145
  cursor: "pointer",
140
146
  "&.active": {
141
147
  background: "#ECF2FF"
@@ -166,8 +172,8 @@ const Style = ({
166
172
  borderBottom: `1px solid ${deviderBgColor}`,
167
173
  fontWeight: "600",
168
174
  fontSize: "14px",
169
- padding: "10px 0px",
170
- width: "calc(100% - 20px)",
175
+ padding: "14px 0px",
176
+ width: "calc(100% - 30px)",
171
177
  margin: "auto",
172
178
  gap: "8px"
173
179
  },
@@ -202,8 +208,8 @@ const Style = ({
202
208
  marginTop: "10px",
203
209
  marginBottom: "10px",
204
210
  padding: "0px 12px",
205
- "&.Mui-expanded": {
206
- border: `1px solid #2563EB`,
211
+ "&&.Mui-expanded": {
212
+ border: `1.5px solid #2563EB`,
207
213
  boxShadow: "1px 2px 14px 0px #2563EB47",
208
214
  "& .MuiAccordionSummary-expandIconWrapper": {
209
215
  color: "#2563EB !important"
@@ -262,6 +268,7 @@ const Style = ({
262
268
  padding: "4px 20px",
263
269
  height: "fit-content",
264
270
  minWidth: "90px",
271
+ lineHeight: "1.75 !important",
265
272
  "@media only screen and (max-width: 899px)": {
266
273
  width: "50%"
267
274
  },
@@ -60,8 +60,15 @@ const style = ({
60
60
  },
61
61
  ".flexAlign": {
62
62
  display: "flex",
63
- alignItems: "center"
63
+ alignItems: "center",
64
+ flexWrap: "wrap"
64
65
  },
66
+ ".flexItem": {
67
+ maxWidth: "50%",
68
+ flex: "1 1 50%" /* allow shrink and grow but cap at 50% */,
69
+ minWidth: 0 /* important for flex children */
70
+ },
71
+
65
72
  ".activeColorBox, .xsColorBox": {
66
73
  width: "24px",
67
74
  height: "24px",
@@ -305,6 +312,7 @@ const style = ({
305
312
  padding: "4px 20px",
306
313
  height: "fit-content",
307
314
  minWidth: "90px",
315
+ lineHeight: "1.75 !important",
308
316
  "@media only screen and (max-width: 899px)": {
309
317
  width: "50%"
310
318
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "10.1.5",
3
+ "version": "10.1.6",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"