@flozy/editor 11.0.5 → 11.0.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.
- package/dist/Editor/ChatEditor.js +16 -17
- package/dist/Editor/CommonEditor.js +28 -141
- package/dist/Editor/DialogWrapper.js +25 -31
- package/dist/Editor/Editor.css +11 -39
- package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
- package/dist/Editor/Elements/AI/Styles.js +0 -1
- package/dist/Editor/Elements/Accordion/Accordion.js +22 -28
- package/dist/Editor/Elements/Accordion/AccordionButton.js +3 -12
- package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
- package/dist/Editor/Elements/Attachments/Attachments.js +11 -153
- package/dist/Editor/Elements/Attachments/AttachmentsButton.js +3 -8
- package/dist/Editor/Elements/Button/EditorButton.js +7 -23
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
- package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +454 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +55 -134
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SelectV1.js +8 -7
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +3 -8
- package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +1 -1
- package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +1 -1
- package/dist/Editor/Elements/Embed/Embed.js +43 -36
- package/dist/Editor/Elements/Embed/Image.js +23 -236
- package/dist/Editor/Elements/Embed/Video.js +15 -245
- package/dist/Editor/Elements/Form/Form.js +10 -16
- package/dist/Editor/Elements/Form/FormField.js +1 -1
- package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
- package/dist/Editor/Elements/Form/Workflow/constant.js +1 -25
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +74 -31
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +5 -9
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -3
- package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
- package/dist/Editor/Elements/FreeGrid/styles.js +0 -15
- package/dist/Editor/Elements/Grid/GridItem.js +1 -1
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +1 -2
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -3
- package/dist/Editor/Elements/Signature/SignaturePopup.js +6 -24
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/Table.js +4 -5
- package/dist/Editor/Elements/Table/TableCell.js +3 -10
- package/dist/Editor/Elements/Title/title.js +11 -10
- package/dist/Editor/Elements/TopBanner/TopBanner.js +2 -4
- package/dist/Editor/Elements/TopBanner/TopBannerButton.js +3 -5
- package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
- package/dist/Editor/MiniEditor.js +1 -2
- package/dist/Editor/Styles/EditorStyles.js +5 -23
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +29 -33
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +23 -25
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +7 -25
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +8 -24
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +10 -70
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +14 -73
- package/dist/Editor/Toolbar/PopupTool/index.js +4 -7
- package/dist/Editor/Toolbar/toolbarGroups.js +10 -56
- package/dist/Editor/common/ColorPickerButton.js +16 -38
- package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +0 -4
- package/dist/Editor/common/Icon.js +0 -28
- package/dist/Editor/common/ImageSelector/ImageSelector.js +7 -45
- package/dist/Editor/common/ImageSelector/Options/Upload.js +11 -26
- package/dist/Editor/common/ImageSelector/Styles.js +9 -3
- package/dist/Editor/common/LinkSettings/NavComponents.js +2 -6
- package/dist/Editor/common/MentionsPopup/index.js +1 -9
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +7 -20
- package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -9
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +7 -20
- package/dist/Editor/common/RnD/GuideLines/styles.js +1 -1
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +11 -28
- package/dist/Editor/common/RnD/Utils/index.js +1 -3
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +63 -52
- package/dist/Editor/common/RnD/VirtualElement/helper.js +130 -320
- package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -22
- package/dist/Editor/common/RnD/index.js +14 -61
- package/dist/Editor/common/Shorthands/elements.js +4 -62
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
- package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
- package/dist/Editor/common/StyleBuilder/fieldStyle.js +0 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +2 -15
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +0 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +0 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
- package/dist/Editor/common/StyleBuilder/formStyle.js +13 -19
- package/dist/Editor/common/StyleBuilder/index.js +4 -8
- package/dist/Editor/common/Uploader.js +17 -125
- package/dist/Editor/common/iconslist.js +0 -21
- package/dist/Editor/commonStyle.js +63 -136
- package/dist/Editor/helper/index.js +2 -10
- package/dist/Editor/helper/theme.js +2 -203
- package/dist/Editor/hooks/useMouseMove.js +3 -9
- package/dist/Editor/hooks/useTable.js +1 -62
- package/dist/Editor/plugins/withEmbeds.js +1 -12
- package/dist/Editor/plugins/withHTML.js +3 -58
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/service/fileupload.js +0 -70
- package/dist/Editor/theme/ThemeList.js +173 -50
- package/dist/Editor/utils/SlateUtilityFunctions.js +40 -192
- package/dist/Editor/utils/accordion.js +39 -67
- package/dist/Editor/utils/button.js +17 -1
- package/dist/Editor/utils/draftToSlate.js +2 -3
- package/dist/Editor/utils/events.js +89 -94
- package/dist/Editor/utils/font.js +37 -40
- package/dist/Editor/utils/formfield.js +2 -2
- package/dist/Editor/utils/helper.js +23 -100
- package/dist/Editor/utils/insertAppHeader.js +4 -8
- package/package.json +4 -4
- package/dist/Editor/Elements/Attachments/AttachmentStyles.js +0 -16
- package/dist/Editor/Elements/FreeGrid/helper.js +0 -194
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
- package/dist/Editor/assets/svg/BackIcon.js +0 -18
- package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
- package/dist/Editor/common/CustomColorPicker/index.js +0 -130
- package/dist/Editor/common/CustomColorPicker/style.js +0 -53
- package/dist/Editor/common/CustomDialog2/index.js +0 -94
- package/dist/Editor/common/CustomDialog2/style.js +0 -67
- package/dist/Editor/common/CustomSelect.js +0 -43
- package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
- package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
- package/dist/Editor/common/UploaderWithProgress.js +0 -183
- package/dist/Editor/helper/textIndeces.js +0 -58
- package/dist/Editor/hooks/useEditorTheme.js +0 -153
- package/dist/Editor/hooks/useThemeValues.js +0 -63
- package/dist/Editor/theme/index.js +0 -149
- package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
- package/dist/Editor/themeSettings/buttons/index.js +0 -300
- package/dist/Editor/themeSettings/buttons/style.js +0 -23
- package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
- package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
- package/dist/Editor/themeSettings/fonts/index.js +0 -240
- package/dist/Editor/themeSettings/fonts/style.js +0 -62
- package/dist/Editor/themeSettings/icons.js +0 -60
- package/dist/Editor/themeSettings/index.js +0 -380
- package/dist/Editor/themeSettings/style.js +0 -299
- package/dist/Editor/themeSettingsAI/icons.js +0 -96
- package/dist/Editor/themeSettingsAI/index.js +0 -355
- package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
- package/dist/Editor/themeSettingsAI/style.js +0 -332
@@ -1,45 +1,69 @@
|
|
1
1
|
import { useEffect, useRef } from "react";
|
2
|
+
import { Path, Transforms } from "slate";
|
2
3
|
import { getNode } from "../../../utils/helper";
|
3
4
|
import { ROW_HEIGHT } from "../Utils/gridDropItem";
|
4
|
-
import { getGridArea,
|
5
|
+
import { findFirstRowOverlap, getGridArea, handleContainers, moveOverlappedItems } from "./helper";
|
5
6
|
import { Box } from "@mui/material";
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
-
|
8
|
-
|
9
|
-
height,
|
10
|
-
gridArea,
|
11
|
-
marginTop
|
12
|
-
} = getNodeValues(element, breakpoint);
|
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
|
-
};
|
21
|
-
export const updateTextHeight = (editor, path, currHeight, updateBreakpoint) => {
|
22
|
-
if (!currHeight) {
|
8
|
+
const updateTextHeight = (editor, path, height) => {
|
9
|
+
if (!height) {
|
23
10
|
return;
|
24
11
|
}
|
25
|
-
const
|
26
|
-
|
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) {
|
27
17
|
return;
|
28
18
|
}
|
19
|
+
const textItemIndex = path[parentPath.length];
|
20
|
+
const textItem = gridItems.find((_, index) => textItemIndex === index);
|
29
21
|
const {
|
30
|
-
|
31
|
-
gridArea,
|
32
|
-
|
33
|
-
} =
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
const
|
42
|
-
|
22
|
+
marginTop_xs: marginTop,
|
23
|
+
gridArea_xs: gridArea,
|
24
|
+
height_xs
|
25
|
+
} = 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
|
+
});
|
43
67
|
}
|
44
68
|
};
|
45
69
|
function VirtualTextElement(props) {
|
@@ -47,8 +71,7 @@ function VirtualTextElement(props) {
|
|
47
71
|
dataSets,
|
48
72
|
getCurrentEle,
|
49
73
|
path,
|
50
|
-
editor
|
51
|
-
breakpoint
|
74
|
+
editor
|
52
75
|
} = props;
|
53
76
|
const currElement = getCurrentEle();
|
54
77
|
const textRef = useRef(null);
|
@@ -60,9 +83,9 @@ function VirtualTextElement(props) {
|
|
60
83
|
height
|
61
84
|
} = entry.contentRect;
|
62
85
|
const currentText = currElement?.innerText;
|
63
|
-
const prevText = prevTextRef
|
86
|
+
const prevText = prevTextRef.current;
|
64
87
|
if (currentText && currentText !== prevText) {
|
65
|
-
updateTextHeight(editor, path, height
|
88
|
+
updateTextHeight(editor, path, height);
|
66
89
|
}
|
67
90
|
prevTextRef.current = currentText;
|
68
91
|
}
|
@@ -78,12 +101,11 @@ function VirtualTextElement(props) {
|
|
78
101
|
}
|
79
102
|
observer.disconnect();
|
80
103
|
};
|
81
|
-
}, [currElement?.innerText
|
82
|
-
const fontSize = `var(--fontSize_${breakpoint}) !important`;
|
104
|
+
}, [currElement?.innerText]);
|
83
105
|
return /*#__PURE__*/_jsx(Box, {
|
84
106
|
style: {
|
85
107
|
position: "fixed",
|
86
|
-
width: dataSets[
|
108
|
+
width: dataSets["data-width-xs"],
|
87
109
|
minHeight: "fit-content",
|
88
110
|
visibility: "hidden",
|
89
111
|
pointerEvents: "none",
|
@@ -93,24 +115,13 @@ function VirtualTextElement(props) {
|
|
93
115
|
ref: textRef,
|
94
116
|
sx: {
|
95
117
|
"& .leaf-item": {
|
96
|
-
fontSize:
|
118
|
+
fontSize: "var(--fontSize_xs) !important",
|
97
119
|
"& span": {
|
98
|
-
fontSize:
|
120
|
+
fontSize: "var(--fontSize_xs) !important"
|
99
121
|
}
|
100
122
|
},
|
101
123
|
"& .editor-blocker": {
|
102
124
|
display: "none"
|
103
|
-
},
|
104
|
-
"& .fgi_type_text": {
|
105
|
-
"& .edt-headings": {
|
106
|
-
margin: "0px"
|
107
|
-
},
|
108
|
-
"& .edt-paragraphs": {
|
109
|
-
margin: "0px"
|
110
|
-
},
|
111
|
-
"& blockquote": {
|
112
|
-
margin: "0px !important"
|
113
|
-
}
|
114
125
|
}
|
115
126
|
},
|
116
127
|
dangerouslySetInnerHTML: {
|
@@ -1,9 +1,5 @@
|
|
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";
|
7
3
|
const isBulletOrTickIcon = (width, itemStartRow, startRow) => {
|
8
4
|
return width <= 40 && itemStartRow === startRow;
|
9
5
|
};
|
@@ -43,83 +39,106 @@ export const getGridArea = gridArea => {
|
|
43
39
|
const getBoxToAutoAlign = (editor, sectionPath) => {
|
44
40
|
const [boxData] = Editor.nodes(editor, {
|
45
41
|
at: sectionPath,
|
46
|
-
match: node =>
|
42
|
+
match: node => node.type === "freegridBox" && node.autoAlign
|
47
43
|
});
|
48
44
|
return boxData || [];
|
49
45
|
};
|
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;
|
50
73
|
|
51
|
-
//
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
//
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
// newlyAddedHeight,
|
120
|
-
// };
|
121
|
-
// };
|
122
|
-
|
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
|
+
};
|
123
142
|
const getAncestorFreeGridContainers = (editor, path) => {
|
124
143
|
const containers = [...Editor.nodes(editor, {
|
125
144
|
at: path,
|
@@ -132,37 +151,6 @@ const getAncestorFreeGridContainers = (editor, path) => {
|
|
132
151
|
})].filter(([node, nodePath]) => nodePath.length <= path.length);
|
133
152
|
return containers;
|
134
153
|
};
|
135
|
-
export const handleTextAlignment = (editor, textNode, heightDiff, updateBreakpoint) => {
|
136
|
-
const [textEle, textPath] = textNode;
|
137
|
-
let containers = getAncestorFreeGridContainers(editor, textPath);
|
138
|
-
for (let i = containers.length - 1; i >= 0; i--) {
|
139
|
-
const container = containers[i];
|
140
|
-
const childContainer = containers[i + 1];
|
141
|
-
if (!heightDiff) {
|
142
|
-
break;
|
143
|
-
}
|
144
|
-
|
145
|
-
// get the data of elements to align inside container
|
146
|
-
const alignElements = alignElementsInsideContainer(container, childContainer || textNode, heightDiff, updateBreakpoint);
|
147
|
-
if (!childContainer) {
|
148
|
-
const {
|
149
|
-
height
|
150
|
-
} = getNodeValues(textEle, updateBreakpoint);
|
151
|
-
const appendBp = updateBreakpoint === "lg" ? "" : "_xs";
|
152
|
-
|
153
|
-
// update the height of the current text element, before updating the container
|
154
|
-
Transforms.setNodes(editor, {
|
155
|
-
[`height${appendBp}`]: height + heightDiff
|
156
|
-
}, {
|
157
|
-
at: textPath
|
158
|
-
});
|
159
|
-
}
|
160
|
-
const containerHeightDiff = updateContainer(editor, alignElements, container, updateBreakpoint, heightDiff);
|
161
|
-
|
162
|
-
// if container height incresed/decresed, need to auto align the parent container based on height differed
|
163
|
-
heightDiff = containerHeightDiff;
|
164
|
-
}
|
165
|
-
};
|
166
154
|
export const handleContainers = (editor, boxPath, extraHeight) => {
|
167
155
|
const containers = getAncestorFreeGridContainers(editor, boxPath);
|
168
156
|
let lastChildStartRow;
|
@@ -224,7 +212,7 @@ export const moveOverlappedItems = (editor, moveRows, containerItems, containerP
|
|
224
212
|
if (isChildEle) {
|
225
213
|
return;
|
226
214
|
}
|
227
|
-
if (
|
215
|
+
if (gridItem.type === "paragraph") {
|
228
216
|
return;
|
229
217
|
}
|
230
218
|
const {
|
@@ -247,196 +235,7 @@ export const moveOverlappedItems = (editor, moveRows, containerItems, containerP
|
|
247
235
|
}
|
248
236
|
});
|
249
237
|
};
|
250
|
-
export const
|
251
|
-
const [containerNode, containerPath] = container;
|
252
|
-
let isOverlapped = false;
|
253
|
-
containerNode.children.forEach((item, index) => {
|
254
|
-
if (!RND_ITEMS.includes(item.type)) {
|
255
|
-
return;
|
256
|
-
}
|
257
|
-
const currPath = [...containerPath, index];
|
258
|
-
if (currPath.toString() === currElementPath.toString()) {
|
259
|
-
return;
|
260
|
-
}
|
261
|
-
const {
|
262
|
-
top,
|
263
|
-
bottom
|
264
|
-
} = getElementOffset(item, updateBreakpoint);
|
265
|
-
if (firstNextElement === top) {
|
266
|
-
return;
|
267
|
-
}
|
268
|
-
if (newTopPosition > top && newTopPosition <= bottom) {
|
269
|
-
isOverlapped = true;
|
270
|
-
}
|
271
|
-
});
|
272
|
-
return isOverlapped;
|
273
|
-
};
|
274
|
-
export const alignElementsInsideContainer = (container, currentElement, heightDiff, updateBreakpoint) => {
|
275
|
-
const [containerNode, containerPath] = container;
|
276
|
-
const [currentElementNode, currElementPath] = currentElement || [];
|
277
|
-
const {
|
278
|
-
bottom: currElementBottom
|
279
|
-
} = getElementOffset(currentElementNode, updateBreakpoint);
|
280
|
-
const newCurrElementBottom = currElementBottom + heightDiff;
|
281
|
-
const bufferSpace = 12;
|
282
|
-
const nextElements = []; // Elements after the current element
|
283
|
-
let firstNextElement = 0; // first element position which is after the current element
|
284
|
-
|
285
|
-
const alignElements = {};
|
286
|
-
|
287
|
-
// find the elements present after the current element
|
288
|
-
containerNode.children.forEach((item, index) => {
|
289
|
-
if (!RND_ITEMS.includes(item.type)) {
|
290
|
-
return;
|
291
|
-
}
|
292
|
-
const currPath = [...containerPath, index];
|
293
|
-
const {
|
294
|
-
top: itemTop
|
295
|
-
} = getElementOffset(item, updateBreakpoint);
|
296
|
-
if (currPath.toString() === currElementPath.toString()) {
|
297
|
-
return;
|
298
|
-
}
|
299
|
-
const bufferPosition = 15;
|
300
|
-
if (itemTop + bufferPosition >= currElementBottom) {
|
301
|
-
const element = {
|
302
|
-
path: currPath,
|
303
|
-
node: item
|
304
|
-
};
|
305
|
-
nextElements.push(element);
|
306
|
-
firstNextElement = firstNextElement > 0 ? Math.min(firstNextElement, itemTop) : itemTop;
|
307
|
-
}
|
308
|
-
});
|
309
|
-
|
310
|
-
// check whether the new height is overlapping the next element
|
311
|
-
const isOverlapped = firstNextElement && newCurrElementBottom >= firstNextElement;
|
312
|
-
let moveElements = isOverlapped || heightDiff < 0; // if heightDiff is negative, move elements up
|
313
|
-
|
314
|
-
if (heightDiff < 0) {
|
315
|
-
// does flex elements cause overlap
|
316
|
-
const isCausingOverlap = causeOverlap(container, currElementPath, updateBreakpoint, firstNextElement + heightDiff, firstNextElement);
|
317
|
-
moveElements = !isCausingOverlap;
|
318
|
-
}
|
319
|
-
if (moveElements) {
|
320
|
-
const topPos = newCurrElementBottom - firstNextElement + bufferSpace; // position the element after the current element
|
321
|
-
alignElements.topPos = heightDiff < 0 ? heightDiff : topPos;
|
322
|
-
alignElements.nextElements = nextElements;
|
323
|
-
alignElements.moveElements = moveElements;
|
324
|
-
}
|
325
|
-
return alignElements;
|
326
|
-
};
|
327
|
-
export const updateContainer = (editor, alignElements, container, updateBreakpoint, heightDiff) => {
|
328
|
-
const [containerNode, containerPath] = container;
|
329
|
-
const {
|
330
|
-
moveElements,
|
331
|
-
topPos,
|
332
|
-
nextElements
|
333
|
-
} = alignElements || {};
|
334
|
-
const appendBp = updateBreakpoint === "lg" ? "" : "_xs";
|
335
|
-
|
336
|
-
// update the aligned data inside container
|
337
|
-
if (moveElements && topPos !== 0) {
|
338
|
-
nextElements.forEach(ele => {
|
339
|
-
const {
|
340
|
-
path,
|
341
|
-
node
|
342
|
-
} = ele;
|
343
|
-
const {
|
344
|
-
top
|
345
|
-
} = getElementOffset(node, updateBreakpoint);
|
346
|
-
const y = top + topPos;
|
347
|
-
|
348
|
-
// Calculate grid position
|
349
|
-
const row = Math.floor(y / ROW_HEIGHT) + 1;
|
350
|
-
|
351
|
-
// to calculate difference inside the grid
|
352
|
-
const marginTop = Math.abs((row - 1) * ROW_HEIGHT - y);
|
353
|
-
|
354
|
-
// Update grid area
|
355
|
-
const gridArea = `${row} / 1 / ${row + 1} / 2`;
|
356
|
-
Transforms.setNodes(editor, {
|
357
|
-
[`gridArea${appendBp}`]: gridArea,
|
358
|
-
[`marginTop${appendBp}`]: marginTop
|
359
|
-
}, {
|
360
|
-
at: path
|
361
|
-
});
|
362
|
-
});
|
363
|
-
}
|
364
|
-
|
365
|
-
// update the new height of the container
|
366
|
-
const newContainerNode = getNode(editor, containerPath);
|
367
|
-
const newHeight = findMaxYValue(newContainerNode?.children, updateBreakpoint) + 12;
|
368
|
-
const {
|
369
|
-
height: containerOldHeight
|
370
|
-
} = getNodeValues(containerNode, updateBreakpoint);
|
371
|
-
let currHeightDiff = newHeight - containerOldHeight;
|
372
|
-
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
|
373
|
-
if (noUpdate) {
|
374
|
-
currHeightDiff = 0;
|
375
|
-
} else {
|
376
|
-
Transforms.setNodes(editor, {
|
377
|
-
[`height${appendBp}`]: newHeight + 12
|
378
|
-
}, {
|
379
|
-
at: containerPath
|
380
|
-
});
|
381
|
-
currHeightDiff += 12;
|
382
|
-
}
|
383
|
-
return currHeightDiff;
|
384
|
-
};
|
385
|
-
export const handleContainersAlignment = (editor, containers, heightDiff, bufferSpace = 0) => {
|
386
|
-
for (let i = containers.length - 1; i >= 0; i--) {
|
387
|
-
const container = containers[i];
|
388
|
-
const childContainer = containers[i + 1];
|
389
|
-
const [containerNode, containerPath] = container;
|
390
|
-
const [childContainerNode, childContainerPath] = childContainer || [];
|
391
|
-
if (childContainer) {
|
392
|
-
const {
|
393
|
-
bottom
|
394
|
-
} = getElementOffset(childContainerNode);
|
395
|
-
containerNode.children.forEach((item, index) => {
|
396
|
-
const currPath = [...containerPath, index];
|
397
|
-
if (currPath.toString() === childContainerPath.toString()) {
|
398
|
-
return;
|
399
|
-
}
|
400
|
-
if (!RND_ITEMS.includes(item.type)) {
|
401
|
-
return;
|
402
|
-
}
|
403
|
-
const {
|
404
|
-
top: itemTop
|
405
|
-
} = getElementOffset(item);
|
406
|
-
if (itemTop >= bottom) {
|
407
|
-
const {
|
408
|
-
gridArea_xs,
|
409
|
-
marginTop_xs
|
410
|
-
} = item;
|
411
|
-
const [startRow] = getGridArea(gridArea_xs);
|
412
|
-
const y = (startRow - 1) * ROW_HEIGHT + marginTop_xs + heightDiff;
|
413
|
-
|
414
|
-
// Calculate grid position
|
415
|
-
const row = Math.floor(y / ROW_HEIGHT) + 1;
|
416
|
-
|
417
|
-
// to calculate difference inside the grid
|
418
|
-
const marginTop = Math.abs((row - 1) * ROW_HEIGHT - y);
|
419
|
-
|
420
|
-
// Update grid area
|
421
|
-
const gridArea = `${row} / 1 / ${row + 1} / 2`;
|
422
|
-
Transforms.setNodes(editor, {
|
423
|
-
gridArea_xs: gridArea,
|
424
|
-
marginTop_xs: marginTop + bufferSpace
|
425
|
-
}, {
|
426
|
-
at: currPath
|
427
|
-
});
|
428
|
-
}
|
429
|
-
});
|
430
|
-
}
|
431
|
-
Transforms.setNodes(editor, {
|
432
|
-
height_xs: containerNode?.height_xs + heightDiff + bufferSpace,
|
433
|
-
xs_updatedOn: new Date().getTime()
|
434
|
-
}, {
|
435
|
-
at: containerPath
|
436
|
-
});
|
437
|
-
}
|
438
|
-
};
|
439
|
-
export const handleBoxAlignment = (editor, sectionPath, heightDiff) => {
|
238
|
+
export const handleBoxAlignment = (editor, sectionNode, sectionPath) => {
|
440
239
|
const [boxNode, boxPath] = getBoxToAutoAlign(editor, sectionPath);
|
441
240
|
Transforms.setNodes(editor, {
|
442
241
|
autoAlign: false
|
@@ -446,11 +245,39 @@ export const handleBoxAlignment = (editor, sectionPath, heightDiff) => {
|
|
446
245
|
if (!boxNode) {
|
447
246
|
return;
|
448
247
|
}
|
449
|
-
|
450
|
-
|
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
|
+
});
|
451
280
|
}
|
452
|
-
let containers = getAncestorFreeGridContainers(editor, boxPath);
|
453
|
-
handleContainersAlignment(editor, containers, heightDiff, 12);
|
454
281
|
};
|
455
282
|
export const getMarginTop = y => {
|
456
283
|
const calcMargin = y % ROW_HEIGHT;
|
@@ -553,21 +380,4 @@ export const sortElements = (items, container) => {
|
|
553
380
|
}
|
554
381
|
}
|
555
382
|
});
|
556
|
-
};
|
557
|
-
const nodeKeys = ["height", "width", "gridArea", "marginTop", "left"];
|
558
|
-
export const getNodeValues = (node, breakpoint = "xs") => {
|
559
|
-
// defaulty return xs breakpoint values, if breakpoint is not given
|
560
|
-
const appendBp = breakpoint === "lg" ? "" : "_xs";
|
561
|
-
const nodeVals = nodeKeys.reduce((a, b) => {
|
562
|
-
const key = b + appendBp;
|
563
|
-
a[b] = node[key];
|
564
|
-
if (b === "height" && !a[b]) {
|
565
|
-
a[b] = node.height;
|
566
|
-
}
|
567
|
-
return a;
|
568
|
-
}, {});
|
569
|
-
return {
|
570
|
-
...node,
|
571
|
-
...nodeVals
|
572
|
-
};
|
573
383
|
};
|