@flozy/editor 11.1.1 → 11.1.3

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 (143) hide show
  1. package/dist/Editor/ChatEditor.js +6 -6
  2. package/dist/Editor/CommonEditor.js +82 -21
  3. package/dist/Editor/DialogWrapper.js +31 -25
  4. package/dist/Editor/Editor.css +37 -4
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +11 -3
  6. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  7. package/dist/Editor/Elements/Attachments/AttachmentStyles.js +16 -0
  8. package/dist/Editor/Elements/Attachments/Attachments.js +154 -11
  9. package/dist/Editor/Elements/Attachments/AttachmentsButton.js +8 -3
  10. package/dist/Editor/Elements/Button/EditorButton.js +22 -7
  11. package/dist/Editor/Elements/Color Picker/ColorButtons.js +61 -14
  12. package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
  13. package/dist/Editor/Elements/Color Picker/ColorPicker.js +10 -7
  14. package/dist/Editor/Elements/Color Picker/Styles.js +15 -13
  15. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +134 -55
  16. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SelectV1.js +7 -8
  17. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +8 -3
  18. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +1 -1
  19. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +1 -1
  20. package/dist/Editor/Elements/Embed/Embed.css +5 -0
  21. package/dist/Editor/Elements/Embed/Embed.js +37 -43
  22. package/dist/Editor/Elements/Embed/Image.js +242 -22
  23. package/dist/Editor/Elements/Embed/Video.js +277 -32
  24. package/dist/Editor/Elements/Form/Form.js +10 -35
  25. package/dist/Editor/Elements/Form/FormField.js +1 -1
  26. package/dist/Editor/Elements/Form/Workflow/Styles.js +24 -22
  27. package/dist/Editor/Elements/Form/Workflow/constant.js +25 -1
  28. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +34 -75
  29. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +9 -5
  30. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +3 -1
  31. package/dist/Editor/Elements/FreeGrid/helper.js +194 -0
  32. package/dist/Editor/Elements/FreeGrid/styles.js +15 -0
  33. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  34. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +2 -1
  35. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -3
  36. package/dist/Editor/Elements/Signature/SignaturePopup.js +2 -13
  37. package/dist/Editor/Elements/SimpleText/index.js +4 -1
  38. package/dist/Editor/Elements/Table/Table.js +2 -1
  39. package/dist/Editor/Elements/Table/TableCell.js +10 -3
  40. package/dist/Editor/Elements/Title/title.js +4 -5
  41. package/dist/Editor/Elements/TopBanner/TopBanner.js +4 -2
  42. package/dist/Editor/Elements/TopBanner/TopBannerButton.js +5 -3
  43. package/dist/Editor/Styles/EditorStyles.js +16 -5
  44. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
  45. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
  46. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  47. package/dist/Editor/Toolbar/FormatTools/TextSize.js +33 -29
  48. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +2 -1
  49. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +3 -1
  50. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +25 -23
  51. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +167 -42
  52. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +15 -5
  53. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +2 -1
  54. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +65 -7
  55. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +66 -12
  56. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +439 -0
  57. package/dist/Editor/Toolbar/PopupTool/index.js +7 -4
  58. package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
  59. package/dist/Editor/assets/svg/BackIcon.js +18 -0
  60. package/dist/Editor/assets/svg/ThemeIcons.js +293 -0
  61. package/dist/Editor/common/ColorPickerButton.js +38 -19
  62. package/dist/Editor/common/CustomColorPicker/index.js +130 -0
  63. package/dist/Editor/common/CustomColorPicker/style.js +53 -0
  64. package/dist/Editor/common/CustomDialog2/index.js +94 -0
  65. package/dist/Editor/common/CustomDialog2/style.js +67 -0
  66. package/dist/Editor/common/CustomSelect.js +43 -0
  67. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  68. package/dist/Editor/common/FontLoader/FontLoader.js +1 -0
  69. package/dist/Editor/common/Icon.js +28 -0
  70. package/dist/Editor/common/ImageSelector/ImageSelector.js +45 -7
  71. package/dist/Editor/common/ImageSelector/Options/Upload.js +26 -11
  72. package/dist/Editor/common/ImageSelector/Styles.js +3 -9
  73. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +2 -1
  74. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
  75. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
  76. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
  77. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
  78. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +3 -2
  79. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +20 -7
  80. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
  81. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +2 -0
  82. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +20 -7
  83. package/dist/Editor/common/RnD/GuideLines/styles.js +1 -1
  84. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
  85. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
  86. package/dist/Editor/common/RnD/Utils/gridDropItem.js +28 -11
  87. package/dist/Editor/common/RnD/Utils/index.js +3 -1
  88. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +52 -63
  89. package/dist/Editor/common/RnD/VirtualElement/helper.js +248 -68
  90. package/dist/Editor/common/RnD/VirtualElement/styles.js +22 -0
  91. package/dist/Editor/common/RnD/index.js +61 -14
  92. package/dist/Editor/common/Shorthands/elements.js +54 -0
  93. package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
  94. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +4 -0
  95. package/dist/Editor/common/StyleBuilder/fieldStyle.js +1 -0
  96. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +18 -4
  97. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +12 -2
  98. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
  99. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +36 -10
  100. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +13 -4
  101. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +2 -0
  102. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +15 -4
  103. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
  104. package/dist/Editor/common/StyleBuilder/formStyle.js +19 -13
  105. package/dist/Editor/common/StyleBuilder/index.js +8 -4
  106. package/dist/Editor/common/Uploader.js +118 -17
  107. package/dist/Editor/common/UploaderWithProgress.js +183 -0
  108. package/dist/Editor/common/iconslist.js +21 -0
  109. package/dist/Editor/commonStyle.js +37 -3
  110. package/dist/Editor/helper/index.js +4 -1
  111. package/dist/Editor/helper/theme.js +203 -2
  112. package/dist/Editor/hooks/useEditorTheme.js +153 -0
  113. package/dist/Editor/hooks/useMouseMove.js +12 -3
  114. package/dist/Editor/hooks/useTable.js +62 -1
  115. package/dist/Editor/hooks/useThemeValues.js +63 -0
  116. package/dist/Editor/plugins/withEmbeds.js +1 -1
  117. package/dist/Editor/plugins/withHTML.js +56 -3
  118. package/dist/Editor/plugins/withTable.js +1 -1
  119. package/dist/Editor/service/fileupload.js +70 -0
  120. package/dist/Editor/theme/ThemeList.js +50 -173
  121. package/dist/Editor/theme/index.js +149 -0
  122. package/dist/Editor/themeSettings/ActiveTheme.js +82 -0
  123. package/dist/Editor/themeSettings/buttons/index.js +300 -0
  124. package/dist/Editor/themeSettings/buttons/style.js +23 -0
  125. package/dist/Editor/themeSettings/colorTheme/index.js +310 -0
  126. package/dist/Editor/themeSettings/colorTheme/style.js +81 -0
  127. package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
  128. package/dist/Editor/themeSettings/fonts/index.js +240 -0
  129. package/dist/Editor/themeSettings/fonts/style.js +62 -0
  130. package/dist/Editor/themeSettings/icons.js +60 -0
  131. package/dist/Editor/themeSettings/index.js +380 -0
  132. package/dist/Editor/themeSettings/style.js +299 -0
  133. package/dist/Editor/themeSettingsAI/icons.js +96 -0
  134. package/dist/Editor/themeSettingsAI/index.js +355 -0
  135. package/dist/Editor/themeSettingsAI/saveTheme.js +202 -0
  136. package/dist/Editor/themeSettingsAI/style.js +332 -0
  137. package/dist/Editor/utils/SlateUtilityFunctions.js +162 -38
  138. package/dist/Editor/utils/accordion.js +1 -1
  139. package/dist/Editor/utils/button.js +1 -17
  140. package/dist/Editor/utils/font.js +40 -37
  141. package/dist/Editor/utils/helper.js +76 -3
  142. package/dist/Editor/utils/insertAppHeader.js +8 -4
  143. package/package.json +1 -1
@@ -1,5 +1,9 @@
1
1
  import { ROW_HEIGHT, calculateGridArea } from "../Utils/gridDropItem";
2
2
  import { Transforms, Editor } from "slate";
3
+ import { getElementOffset } from "./VirtualTextElement";
4
+ import { getNode } from "../../../utils/helper";
5
+ import { findMaxYValue } from "../../../Elements/FreeGrid/helper";
6
+ import { RND_ITEMS } from "../../../helper";
3
7
  const isBulletOrTickIcon = (width, itemStartRow, startRow) => {
4
8
  return width <= 40 && itemStartRow === startRow;
5
9
  };
@@ -39,7 +43,7 @@ export const getGridArea = gridArea => {
39
43
  const getBoxToAutoAlign = (editor, sectionPath) => {
40
44
  const [boxData] = Editor.nodes(editor, {
41
45
  at: sectionPath,
42
- match: node => node.type === "freegridBox" && node.autoAlign
46
+ match: node => ["freegridBox", "freegrid"].includes(node.type) && node.autoAlign
43
47
  });
44
48
  return boxData || [];
45
49
  };
@@ -106,39 +110,6 @@ const handleNonGridItems = (nonGridItems, lastRow, editor, boxPath) => {
106
110
  newlyAddedHeight
107
111
  };
108
112
  };
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
- };
142
113
  const getAncestorFreeGridContainers = (editor, path) => {
143
114
  const containers = [...Editor.nodes(editor, {
144
115
  at: path,
@@ -151,6 +122,37 @@ const getAncestorFreeGridContainers = (editor, path) => {
151
122
  })].filter(([node, nodePath]) => nodePath.length <= path.length);
152
123
  return containers;
153
124
  };
125
+ export const handleTextAlignment = (editor, textNode, heightDiff, updateBreakpoint) => {
126
+ const [textEle, textPath] = textNode;
127
+ let containers = getAncestorFreeGridContainers(editor, textPath);
128
+ for (let i = containers.length - 1; i >= 0; i--) {
129
+ const container = containers[i];
130
+ const childContainer = containers[i + 1];
131
+ if (!heightDiff) {
132
+ break;
133
+ }
134
+
135
+ // get the data of elements to align inside container
136
+ const alignElements = alignElementsInsideContainer(container, childContainer || textNode, heightDiff, updateBreakpoint);
137
+ if (!childContainer) {
138
+ const {
139
+ height
140
+ } = getNodeValues(textEle, updateBreakpoint);
141
+ const appendBp = updateBreakpoint === "lg" ? "" : "_xs";
142
+
143
+ // update the height of the current text element, before updating the container
144
+ Transforms.setNodes(editor, {
145
+ [`height${appendBp}`]: height + heightDiff
146
+ }, {
147
+ at: textPath
148
+ });
149
+ }
150
+ const containerHeightDiff = updateContainer(editor, alignElements, container, updateBreakpoint, heightDiff);
151
+
152
+ // if container height incresed/decresed, need to auto align the parent container based on height differed
153
+ heightDiff = containerHeightDiff;
154
+ }
155
+ };
154
156
  export const handleContainers = (editor, boxPath, extraHeight) => {
155
157
  const containers = getAncestorFreeGridContainers(editor, boxPath);
156
158
  let lastChildStartRow;
@@ -212,7 +214,7 @@ export const moveOverlappedItems = (editor, moveRows, containerItems, containerP
212
214
  if (isChildEle) {
213
215
  return;
214
216
  }
215
- if (gridItem.type === "paragraph") {
217
+ if (!RND_ITEMS.includes(gridItem.type)) {
216
218
  return;
217
219
  }
218
220
  const {
@@ -235,7 +237,196 @@ export const moveOverlappedItems = (editor, moveRows, containerItems, containerP
235
237
  }
236
238
  });
237
239
  };
238
- export const handleBoxAlignment = (editor, sectionNode, sectionPath) => {
240
+ export const causeOverlap = (container, currElementPath, updateBreakpoint, newTopPosition, firstNextElement) => {
241
+ const [containerNode, containerPath] = container;
242
+ let isOverlapped = false;
243
+ containerNode.children.forEach((item, index) => {
244
+ if (!RND_ITEMS.includes(item.type)) {
245
+ return;
246
+ }
247
+ const currPath = [...containerPath, index];
248
+ if (currPath.toString() === currElementPath.toString()) {
249
+ return;
250
+ }
251
+ const {
252
+ top,
253
+ bottom
254
+ } = getElementOffset(item, updateBreakpoint);
255
+ if (firstNextElement === top) {
256
+ return;
257
+ }
258
+ if (newTopPosition > top && newTopPosition <= bottom) {
259
+ isOverlapped = true;
260
+ }
261
+ });
262
+ return isOverlapped;
263
+ };
264
+ export const alignElementsInsideContainer = (container, currentElement, heightDiff, updateBreakpoint) => {
265
+ const [containerNode, containerPath] = container;
266
+ const [currentElementNode, currElementPath] = currentElement || [];
267
+ const {
268
+ bottom: currElementBottom
269
+ } = getElementOffset(currentElementNode, updateBreakpoint);
270
+ const newCurrElementBottom = currElementBottom + heightDiff;
271
+ const bufferSpace = 12;
272
+ const nextElements = []; // Elements after the current element
273
+ let firstNextElement = 0; // first element position which is after the current element
274
+
275
+ const alignElements = {};
276
+
277
+ // find the elements present after the current element
278
+ containerNode.children.forEach((item, index) => {
279
+ if (!RND_ITEMS.includes(item.type)) {
280
+ return;
281
+ }
282
+ const currPath = [...containerPath, index];
283
+ const {
284
+ top: itemTop
285
+ } = getElementOffset(item, updateBreakpoint);
286
+ if (currPath.toString() === currElementPath.toString()) {
287
+ return;
288
+ }
289
+ const bufferPosition = 15;
290
+ if (itemTop + bufferPosition >= currElementBottom) {
291
+ const element = {
292
+ path: currPath,
293
+ node: item
294
+ };
295
+ nextElements.push(element);
296
+ firstNextElement = firstNextElement > 0 ? Math.min(firstNextElement, itemTop) : itemTop;
297
+ }
298
+ });
299
+
300
+ // check whether the new height is overlapping the next element
301
+ const isOverlapped = firstNextElement && newCurrElementBottom >= firstNextElement;
302
+ let moveElements = isOverlapped || heightDiff < 0; // if heightDiff is negative, move elements up
303
+
304
+ if (heightDiff < 0) {
305
+ // does flex elements cause overlap
306
+ const isCausingOverlap = causeOverlap(container, currElementPath, updateBreakpoint, firstNextElement + heightDiff, firstNextElement);
307
+ moveElements = !isCausingOverlap;
308
+ }
309
+ if (moveElements) {
310
+ const topPos = newCurrElementBottom - firstNextElement + bufferSpace; // position the element after the current element
311
+ alignElements.topPos = heightDiff < 0 ? heightDiff : topPos;
312
+ alignElements.nextElements = nextElements;
313
+ alignElements.moveElements = moveElements;
314
+ }
315
+ return alignElements;
316
+ };
317
+ export const updateContainer = (editor, alignElements, container, updateBreakpoint, heightDiff) => {
318
+ const [containerNode, containerPath] = container;
319
+ const {
320
+ moveElements,
321
+ topPos,
322
+ nextElements
323
+ } = alignElements || {};
324
+ const appendBp = updateBreakpoint === "lg" ? "" : "_xs";
325
+
326
+ // update the aligned data inside container
327
+ if (moveElements && topPos !== 0) {
328
+ nextElements.forEach(ele => {
329
+ const {
330
+ path,
331
+ node
332
+ } = ele;
333
+ const {
334
+ top
335
+ } = getElementOffset(node, updateBreakpoint);
336
+ const y = top + topPos;
337
+
338
+ // Calculate grid position
339
+ const row = Math.floor(y / ROW_HEIGHT) + 1;
340
+
341
+ // to calculate difference inside the grid
342
+ const marginTop = Math.abs((row - 1) * ROW_HEIGHT - y);
343
+
344
+ // Update grid area
345
+ const gridArea = `${row} / 1 / ${row + 1} / 2`;
346
+ Transforms.setNodes(editor, {
347
+ [`gridArea${appendBp}`]: gridArea,
348
+ [`marginTop${appendBp}`]: marginTop
349
+ }, {
350
+ at: path
351
+ });
352
+ });
353
+ }
354
+
355
+ // update the new height of the container
356
+ const newContainerNode = getNode(editor, containerPath);
357
+ const newHeight = findMaxYValue(newContainerNode?.children, updateBreakpoint) + 12;
358
+ const {
359
+ height: containerOldHeight
360
+ } = getNodeValues(containerNode, updateBreakpoint);
361
+ let currHeightDiff = newHeight - containerOldHeight;
362
+ const noUpdate = currHeightDiff < 0 && heightDiff > 0; // if current text height is increased, but container height is getting reduced, we don't want to reduce the height of the container
363
+ if (noUpdate) {
364
+ currHeightDiff = 0;
365
+ } else {
366
+ Transforms.setNodes(editor, {
367
+ [`height${appendBp}`]: newHeight + 12
368
+ }, {
369
+ at: containerPath
370
+ });
371
+ currHeightDiff += 12;
372
+ }
373
+ return currHeightDiff;
374
+ };
375
+ export const handleContainersAlignment = (editor, containers, heightDiff, bufferSpace = 0) => {
376
+ for (let i = containers.length - 1; i >= 0; i--) {
377
+ const container = containers[i];
378
+ const childContainer = containers[i + 1];
379
+ const [containerNode, containerPath] = container;
380
+ const [childContainerNode, childContainerPath] = childContainer || [];
381
+ if (childContainer) {
382
+ const {
383
+ bottom
384
+ } = getElementOffset(childContainerNode);
385
+ containerNode.children.forEach((item, index) => {
386
+ const currPath = [...containerPath, index];
387
+ if (currPath.toString() === childContainerPath.toString()) {
388
+ return;
389
+ }
390
+ if (!RND_ITEMS.includes(item.type)) {
391
+ return;
392
+ }
393
+ const {
394
+ top: itemTop
395
+ } = getElementOffset(item);
396
+ if (itemTop >= bottom) {
397
+ const {
398
+ gridArea_xs,
399
+ marginTop_xs
400
+ } = item;
401
+ const [startRow] = getGridArea(gridArea_xs);
402
+ const y = (startRow - 1) * ROW_HEIGHT + marginTop_xs + heightDiff;
403
+
404
+ // Calculate grid position
405
+ const row = Math.floor(y / ROW_HEIGHT) + 1;
406
+
407
+ // to calculate difference inside the grid
408
+ const marginTop = Math.abs((row - 1) * ROW_HEIGHT - y);
409
+
410
+ // Update grid area
411
+ const gridArea = `${row} / 1 / ${row + 1} / 2`;
412
+ Transforms.setNodes(editor, {
413
+ gridArea_xs: gridArea,
414
+ marginTop_xs: marginTop + bufferSpace
415
+ }, {
416
+ at: currPath
417
+ });
418
+ }
419
+ });
420
+ }
421
+ Transforms.setNodes(editor, {
422
+ height_xs: containerNode?.height_xs + heightDiff + bufferSpace,
423
+ xs_updatedOn: new Date().getTime()
424
+ }, {
425
+ at: containerPath
426
+ });
427
+ }
428
+ };
429
+ export const handleBoxAlignment = (editor, sectionPath, heightDiff) => {
239
430
  const [boxNode, boxPath] = getBoxToAutoAlign(editor, sectionPath);
240
431
  Transforms.setNodes(editor, {
241
432
  autoAlign: false
@@ -245,39 +436,11 @@ export const handleBoxAlignment = (editor, sectionNode, sectionPath) => {
245
436
  if (!boxNode) {
246
437
  return;
247
438
  }
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
- });
439
+ if (heightDiff <= 0) {
440
+ return;
280
441
  }
442
+ let containers = getAncestorFreeGridContainers(editor, boxPath);
443
+ handleContainersAlignment(editor, containers, heightDiff, 12);
281
444
  };
282
445
  export const getMarginTop = y => {
283
446
  const calcMargin = y % ROW_HEIGHT;
@@ -380,4 +543,21 @@ export const sortElements = (items, container) => {
380
543
  }
381
544
  }
382
545
  });
546
+ };
547
+ const nodeKeys = ["height", "width", "gridArea", "marginTop", "left"];
548
+ export const getNodeValues = (node, breakpoint = "xs") => {
549
+ // defaulty return xs breakpoint values, if breakpoint is not given
550
+ const appendBp = breakpoint === "lg" ? "" : "_xs";
551
+ const nodeVals = nodeKeys.reduce((a, b) => {
552
+ const key = b + appendBp;
553
+ a[b] = node[key];
554
+ if (b === "height" && !a[b]) {
555
+ a[b] = node.height;
556
+ }
557
+ return a;
558
+ }, {});
559
+ return {
560
+ ...node,
561
+ ...nodeVals
562
+ };
383
563
  };
@@ -18,6 +18,17 @@ 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
+ "& blockquote": {
29
+ margin: "0px !important"
30
+ }
31
+ },
21
32
  "& .freegrid-item": {
22
33
  position: "relative !important",
23
34
  top: "0 !important",
@@ -97,6 +108,17 @@ export const useAutoAlignStyles = () => ({
97
108
  "&.type_text": {
98
109
  height: "auto !important"
99
110
  },
111
+ "& .fgi_type_text": {
112
+ "& .edt-headings": {
113
+ margin: "0px"
114
+ },
115
+ "& .edt-paragraphs": {
116
+ margin: "0px"
117
+ },
118
+ "& blockquote": {
119
+ margin: "0px !important"
120
+ }
121
+ },
100
122
  // start - default signature classes on free-grid
101
123
  "& .fgi_type_signature": {
102
124
  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";
@@ -20,7 +20,7 @@ import useDragging from "../../hooks/useDragging";
20
20
  import { dragOverOn } from "../../helper/RnD/focusNode";
21
21
  import { focusSelection, clearSelection, clearSelectionOnly } from "../../helper";
22
22
  // import { reRenderChildNodes } from "./Utils/gridDropItem";
23
- import VirtualTextElement from "./VirtualElement/VirtualTextElement";
23
+ import VirtualTextElement, { updateTextHeight } from "./VirtualElement/VirtualTextElement";
24
24
  import useAutoScroll from "../../hooks/useAutoScroll";
25
25
  import ForceAutoAlignment from "./VirtualElement/ForceAutoAlignment";
26
26
  import BoxHeaderAutoAlignment from "./VirtualElement/BoxHeaderAutoAlignment";
@@ -29,6 +29,38 @@ import { useFreeGrid } from "../../Elements/FreeGrid/FreeGrid";
29
29
  import { jsx as _jsx } from "react/jsx-runtime";
30
30
  import { jsxs as _jsxs } from "react/jsx-runtime";
31
31
  import { Fragment as _Fragment } from "react/jsx-runtime";
32
+ function getTextElementHeight(textElement) {
33
+ let totalHeight = 0;
34
+ if (textElement) {
35
+ const {
36
+ childNodes
37
+ } = textElement || {};
38
+ for (let i = childNodes.length - 1; i >= 0; i--) {
39
+ const el = childNodes[i];
40
+ const text = el.textContent?.replace(/\n/g, "")?.trim();
41
+ if (text || totalHeight) {
42
+ // remove last empty spaces
43
+ totalHeight += el.offsetHeight || el.getBoundingClientRect().height;
44
+ }
45
+ }
46
+ }
47
+ return totalHeight;
48
+ }
49
+ function textAutoAlign(editor, path, getCurrentEle, delta, breakpoint, onLoad) {
50
+ const currElement = getCurrentEle();
51
+ const textElement = currElement?.querySelector(".fgi_type_text");
52
+ const clientHeight = getTextElementHeight(textElement);
53
+ const {
54
+ height
55
+ } = delta || {};
56
+ const heightDiff = Math.abs(clientHeight - height);
57
+ const autoAlign = onLoad ? clientHeight > height : heightDiff >= 5;
58
+ if (clientHeight && height && autoAlign) {
59
+ updateTextHeight(editor, path, clientHeight, breakpoint);
60
+ const parentSectionPath = path.slice(0, 2);
61
+ reRenderChildNodes(editor, parentSectionPath);
62
+ }
63
+ }
32
64
  const ITEM_TYPES = ["child", "parent-container"];
33
65
  const EDIT_MODES = ["text", "form", "table"];
34
66
  const DISABLE_RESIZING = {
@@ -78,7 +110,8 @@ const RnD = props => {
78
110
  setAutoAlign,
79
111
  isBoxHeader,
80
112
  customProps,
81
- xsHidden
113
+ xsHidden,
114
+ disableClick = false
82
115
  } = props;
83
116
  const {
84
117
  isSelectedElement,
@@ -132,6 +165,8 @@ const RnD = props => {
132
165
  const {
133
166
  translation
134
167
  } = customProps;
168
+ const timerId = useRef(0);
169
+ const isFirstRender = useRef(true);
135
170
  useEffect(() => {
136
171
  if (ITEM_TYPES.includes(type)) {
137
172
  if (enable === 1) {
@@ -141,6 +176,19 @@ const RnD = props => {
141
176
  setAbsPosition({});
142
177
  }
143
178
  }
179
+ if (childType === "text" && !enable && !readOnly) {
180
+ if (isFirstRender.current) {
181
+ isFirstRender.current = false;
182
+ timerId.current = setTimeout(() => {
183
+ // auto align on load
184
+ textAutoAlign(editor, path, getCurrentEle, delta, breakpoint, true);
185
+ }, 200);
186
+ } else {
187
+ // auto align when the text is changed
188
+ textAutoAlign(editor, path, getCurrentEle, delta, breakpoint);
189
+ }
190
+ }
191
+ return () => clearTimeout(timerId?.current);
144
192
  }, [enable]);
145
193
  const getCurrentEle = () => {
146
194
  return positionRef.current?.resizableElement?.current;
@@ -500,7 +548,9 @@ const RnD = props => {
500
548
  ref
501
549
  }, ".freegrid-container-parent");
502
550
  const formatParentPath = parentPath?.split("|")?.map(m => parseInt(m));
503
- reRenderChildNodes(editor, formatParentPath);
551
+ if (formatParentPath) {
552
+ reRenderChildNodes(editor, formatParentPath);
553
+ }
504
554
  };
505
555
  const onCloseSettings = () => {
506
556
  setSelectedElement({
@@ -631,7 +681,10 @@ const RnD = props => {
631
681
  "data-path": path,
632
682
  contentEditable: false,
633
683
  "data-dragoverid": str_path,
634
- "data-dragovertype": type
684
+ "data-dragovertype": type,
685
+ style: {
686
+ pointerEvents: disableClick && "none"
687
+ }
635
688
  }) : null]
636
689
  }, eId), xsHidden && breakpoint === "xs" ? null : /*#__PURE__*/_jsxs(_Fragment, {
637
690
  children: [/*#__PURE__*/_jsx(ElementSettings, {
@@ -684,18 +737,12 @@ const RnD = props => {
684
737
  handleClose: handleClose,
685
738
  theme: theme,
686
739
  translation: translation
687
- }), type === "parent" && breakpoint === "lg" && !readOnly ? /*#__PURE__*/_jsx(VirtualElement, {
688
- updated_at: updated_at,
689
- path: str_path,
690
- editor: editor,
691
- sectionElement: sectionElement,
692
- sectionCls: `.freegrid-section_${path.join("_")}`,
693
- dataSets: dataSets
694
- }) : null, childType === "text" && breakpoint === "lg" && !readOnly && enable ? /*#__PURE__*/_jsx(VirtualTextElement, {
740
+ }), childType === "text" && !readOnly && enable ? /*#__PURE__*/_jsx(VirtualTextElement, {
695
741
  editor: editor,
696
742
  dataSets: dataSets,
697
743
  getCurrentEle: getCurrentEle,
698
- path: path
744
+ path: path,
745
+ breakpoint: breakpoint === "xs" ? "lg" : "xs" // auto-align for this passed breakpoint
699
746
  }) : null, type === "parent" && breakpoint === "xs" && !readOnly && autoAlign ? /*#__PURE__*/_jsx(ForceAutoAlignment, {
700
747
  updated_at: updated_at,
701
748
  path: str_path,
@@ -55,6 +55,60 @@ const ELEMENTS_LIST = [{
55
55
  icon: "headingThree"
56
56
  }),
57
57
  onInsert: editor => toggleBlock(editor, "headingThree", false)
58
+ }, {
59
+ name: "Heading 4",
60
+ desc: "",
61
+ group: "Text",
62
+ type: "headingFour",
63
+ icon: /*#__PURE__*/_jsx(Icon, {
64
+ icon: "headingFour"
65
+ }),
66
+ onInsert: editor => toggleBlock(editor, "headingFour", false)
67
+ }, {
68
+ name: "Heading 5",
69
+ desc: "",
70
+ group: "Text",
71
+ type: "headingFive",
72
+ icon: /*#__PURE__*/_jsx(Icon, {
73
+ icon: "headingFive"
74
+ }),
75
+ onInsert: editor => toggleBlock(editor, "headingFive", false)
76
+ }, {
77
+ name: "Heading 6",
78
+ desc: "",
79
+ group: "Text",
80
+ type: "headingSix",
81
+ icon: /*#__PURE__*/_jsx(Icon, {
82
+ icon: "headingSix"
83
+ }),
84
+ onInsert: editor => toggleBlock(editor, "headingSix", false)
85
+ }, {
86
+ name: "Paragraph 1",
87
+ desc: "",
88
+ group: "Text",
89
+ type: "paragraphOne",
90
+ icon: /*#__PURE__*/_jsx(Icon, {
91
+ icon: "paragraphOne"
92
+ }),
93
+ onInsert: editor => toggleBlock(editor, "paragraphOne", false)
94
+ }, {
95
+ name: "Paragraph 2",
96
+ desc: "",
97
+ group: "Text",
98
+ type: "paragraphTwo",
99
+ icon: /*#__PURE__*/_jsx(Icon, {
100
+ icon: "paragraphTwo"
101
+ }),
102
+ onInsert: editor => toggleBlock(editor, "paragraphTwo", false)
103
+ }, {
104
+ name: "Paragraph 3",
105
+ desc: "",
106
+ group: "Text",
107
+ type: "paragraphThree",
108
+ icon: /*#__PURE__*/_jsx(Icon, {
109
+ icon: "paragraphThree"
110
+ }),
111
+ onInsert: editor => toggleBlock(editor, "paragraphThree", false)
58
112
  }, {
59
113
  name: "Quote",
60
114
  desc: "",
@@ -21,7 +21,8 @@ const buttonStyle = [{
21
21
  },
22
22
  children: option.text
23
23
  });
24
- }
24
+ },
25
+ themeEnabled: true
25
26
  }, {
26
27
  label: "Font Size",
27
28
  key: "textSize",
@@ -45,7 +46,8 @@ const buttonStyle = [{
45
46
  }, {
46
47
  label: "Button Color",
47
48
  key: "bgColor",
48
- type: "color"
49
+ type: "color",
50
+ themeEnabled: true
49
51
  }, {
50
52
  label: "Border Color",
51
53
  key: "borderColor",
@@ -6,6 +6,10 @@ const embedVideoStyle = [{
6
6
  label: "URL",
7
7
  key: "url",
8
8
  type: "text"
9
+ }, {
10
+ label: "File",
11
+ key: "url",
12
+ type: "backgroundImage"
9
13
  }]
10
14
  }, {
11
15
  tab: "Aspect Ratio",
@@ -47,6 +47,7 @@ const fieldStyle = [{
47
47
  label: "Border Style",
48
48
  key: "borderStyle",
49
49
  type: "textOptions",
50
+ hideMetaDataOptions: true,
50
51
  options: [{
51
52
  text: "Solid",
52
53
  value: "solid"
@@ -11,7 +11,9 @@ const BackgroundImage = props => {
11
11
  value,
12
12
  data,
13
13
  customProps,
14
- onChange
14
+ onChange,
15
+ elementProps,
16
+ title
15
17
  } = props;
16
18
  const {
17
19
  translation
@@ -25,6 +27,7 @@ const BackgroundImage = props => {
25
27
  theme
26
28
  } = useEditorContext();
27
29
  const classes = UploadStyles(theme);
30
+ const disableProgress = title === "Page Settings" || elementProps?.type === "freegridBox" || elementProps?.type === "freegrid";
28
31
  const onRemoveBG = () => {
29
32
  setBase64(null);
30
33
  onChange({
@@ -38,12 +41,21 @@ const BackgroundImage = props => {
38
41
  setOpen(false);
39
42
  };
40
43
  const onSelectImage = img => {
41
- setBase64(img);
44
+ let imgUrl = "";
45
+ if (typeof img === "object") {
46
+ imgUrl = img?.embedURL;
47
+ } else {
48
+ imgUrl = img;
49
+ }
50
+ setBase64(imgUrl);
42
51
  onChange({
43
- [key]: img
52
+ [key]: imgUrl
44
53
  });
45
54
  handleClose();
46
55
  };
56
+ const getTitle = () => {
57
+ return elementProps?.type === "image" ? "Image" : elementProps?.type === "video" ? "Video" : null;
58
+ };
47
59
  return /*#__PURE__*/_jsxs(Grid, {
48
60
  item: true,
49
61
  xs: 12,
@@ -100,7 +112,9 @@ const BackgroundImage = props => {
100
112
  open: open,
101
113
  onClose: handleClose,
102
114
  customProps: customProps,
103
- onSelectImage: onSelectImage
115
+ onSelectImage: onSelectImage,
116
+ title: getTitle(),
117
+ disableProgress: disableProgress
104
118
  })]
105
119
  });
106
120
  };