@flozy/editor 9.8.3 → 9.8.4
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 +26 -19
- package/dist/Editor/CommonEditor.js +141 -26
- package/dist/Editor/DialogWrapper.js +31 -25
- package/dist/Editor/Editor.css +11 -7
- package/dist/Editor/Elements/AI/AIInput.js +5 -3
- package/dist/Editor/Elements/AI/CustomSelect.js +9 -5
- package/dist/Editor/Elements/AI/PopoverAIInput.js +15 -5
- package/dist/Editor/Elements/Accordion/Accordion.js +4 -3
- package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +4 -1
- package/dist/Editor/Elements/Accordion/AccordionButton.js +6 -2
- package/dist/Editor/Elements/Accordion/AccordionTitlePopup.js +4 -1
- package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
- package/dist/Editor/Elements/AppHeader/AppHeaderButton.js +6 -2
- package/dist/Editor/Elements/AppHeader/AppHeaderPopup.js +4 -1
- package/dist/Editor/Elements/Attachments/AttachmentsButton.js +4 -1
- package/dist/Editor/Elements/Button/ButtonPopup.js +4 -1
- package/dist/Editor/Elements/Button/ButtonToolIcon.js +6 -2
- package/dist/Editor/Elements/Button/EditorButton.js +43 -30
- package/dist/Editor/Elements/Carousel/Carousel.js +5 -4
- package/dist/Editor/Elements/Carousel/CarouselButton.js +6 -2
- package/dist/Editor/Elements/Carousel/CarouselItem.js +3 -2
- package/dist/Editor/Elements/ChipText/ChipTextPopup.js +4 -1
- package/dist/Editor/Elements/CodeToText/CodeToText.js +5 -4
- package/dist/Editor/Elements/CodeToText/HtmlContextMenu.js +6 -2
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +60 -14
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +10 -7
- package/dist/Editor/Elements/Color Picker/Styles.js +15 -13
- package/dist/Editor/Elements/Colorbox/ColorboxButton.js +6 -2
- package/dist/Editor/Elements/DataView/DataView.js +5 -2
- package/dist/Editor/Elements/DataView/DataViewButton.js +6 -2
- package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +4 -2
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +448 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +21 -6
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +13 -12
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +7 -4
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +7 -5
- package/dist/Editor/Elements/DataView/Layouts/FilterView.js +9 -7
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +8 -3
- package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +5 -3
- package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +6 -5
- package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +5 -3
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +9 -7
- package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +15 -12
- package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +3 -2
- package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +3 -2
- package/dist/Editor/Elements/DataView/Layouts/Options/index.js +23 -6
- package/dist/Editor/Elements/DataView/Layouts/TableView.js +6 -4
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +8 -4
- package/dist/Editor/Elements/DataView/Layouts/index.js +3 -1
- package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +5 -2
- package/dist/Editor/Elements/Divider/Divider.js +5 -3
- package/dist/Editor/Elements/Divider/DividerButton.js +6 -2
- package/dist/Editor/Elements/Divider/DividerPopup.js +3 -2
- package/dist/Editor/Elements/Embed/Embed.js +4 -1
- package/dist/Editor/Elements/Embed/EmbedPopup.js +4 -1
- package/dist/Editor/Elements/Embed/Image.js +16 -11
- package/dist/Editor/Elements/Embed/Video.js +10 -7
- package/dist/Editor/Elements/EmbedScript/Code.js +7 -4
- package/dist/Editor/Elements/EmbedScript/EmbedScript.js +6 -2
- package/dist/Editor/Elements/EmbedScript/EmbedScriptPopup.js +8 -5
- package/dist/Editor/Elements/Emoji/EmojiButton.js +6 -2
- package/dist/Editor/Elements/Form/FieldPopup.js +4 -1
- package/dist/Editor/Elements/Form/Form.js +12 -9
- package/dist/Editor/Elements/Form/FormButton.js +6 -2
- package/dist/Editor/Elements/Form/FormPopup.js +3 -2
- package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +18 -12
- package/dist/Editor/Elements/Form/Workflow/ListWorkflow.js +13 -8
- package/dist/Editor/Elements/Form/Workflow/MoreOptions.js +3 -2
- package/dist/Editor/Elements/Form/Workflow/Styles.js +24 -22
- package/dist/Editor/Elements/Form/Workflow/UserInputs.js +4 -2
- package/dist/Editor/Elements/Form/Workflow/index.js +15 -9
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +67 -23
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +31 -6
- package/dist/Editor/Elements/FreeGrid/FreeGridButton.js +6 -2
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +54 -6
- package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +3 -2
- package/dist/Editor/Elements/FreeGrid/Options/More.js +10 -4
- package/dist/Editor/Elements/FreeGrid/styles.js +3 -0
- package/dist/Editor/Elements/Grid/Grid.js +13 -10
- package/dist/Editor/Elements/Grid/GridButton.js +9 -5
- package/dist/Editor/Elements/Grid/GridItem.js +14 -8
- package/dist/Editor/Elements/Grid/GridItemPopup.js +4 -1
- package/dist/Editor/Elements/Grid/GridPopup.js +4 -1
- package/dist/Editor/Elements/Grid/SectionPopup.js +4 -1
- package/dist/Editor/Elements/Link/Link.js +8 -5
- package/dist/Editor/Elements/Link/LinkButton.js +4 -1
- package/dist/Editor/Elements/List/CheckList.js +18 -10
- package/dist/Editor/Elements/NewLine/NewLineButton.js +6 -2
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +4 -1
- package/dist/Editor/Elements/PageSettings/PageSettingsPopup.js +4 -1
- package/dist/Editor/Elements/Search/SearchButton.js +7 -4
- package/dist/Editor/Elements/Search/SearchList.js +10 -5
- package/dist/Editor/Elements/Signature/SignatureButton.js +6 -2
- package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +2 -8
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +6 -2
- package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +4 -1
- package/dist/Editor/Elements/Signature/SignaturePopup.js +17 -16
- package/dist/Editor/Elements/SimpleText/index.js +14 -5
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/DragButton.js +4 -2
- package/dist/Editor/Elements/Table/Table.js +23 -11
- package/dist/Editor/Elements/Table/TablePopup.js +4 -1
- package/dist/Editor/Elements/Table/TableSelector.js +10 -6
- package/dist/Editor/Elements/Table/TableTool.js +8 -4
- package/dist/Editor/Elements/Title/title.js +9 -8
- package/dist/Editor/Elements/TopBanner/TopBannerButton.js +4 -1
- package/dist/Editor/Elements/Variables/VariableButton.js +10 -1
- package/dist/Editor/MiniEditor.js +10 -3
- package/dist/Editor/Styles/EditorStyles.js +5 -5
- package/dist/Editor/Toolbar/Basic/index.js +2 -1
- package/dist/Editor/Toolbar/FormatTools/BlockButton.js +6 -2
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +8 -4
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +10 -13
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +17 -5
- package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +10 -5
- package/dist/Editor/Toolbar/PopupTool/ButtonTemplatesCard.js +10 -4
- package/dist/Editor/Toolbar/PopupTool/FullViewCard.js +10 -4
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +9 -3
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectAlignment.js +42 -35
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +6 -13
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +58 -51
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectSuperSubscript.js +29 -22
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +226 -87
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +20 -10
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +10 -5
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +71 -11
- package/dist/Editor/Toolbar/PopupTool/TemplateCard.js +11 -5
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +122 -42
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +436 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +18 -2
- package/dist/Editor/Toolbar/Toolbar.js +20 -10
- package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
- package/dist/Editor/assets/svg/ClearAllRounded.js +31 -0
- package/dist/Editor/assets/svg/ResetIconNew.js +23 -0
- package/dist/Editor/assets/svg/ThemeIcons.js +291 -0
- package/dist/Editor/common/ColorPickerButton.js +39 -14
- package/dist/Editor/common/CustomColorPicker/index.js +131 -0
- package/dist/Editor/common/CustomColorPicker/style.js +53 -0
- package/dist/Editor/common/CustomDialog/index.js +8 -10
- package/dist/Editor/common/CustomDialog2/index.js +94 -0
- package/dist/Editor/common/CustomDialog2/style.js +67 -0
- package/dist/Editor/common/CustomSelect.js +43 -0
- package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +3 -0
- package/dist/Editor/common/Icon.js +31 -1
- package/dist/Editor/common/ImageSelector/ImageSelector.js +10 -8
- package/dist/Editor/common/ImageSelector/Options/AddLink.js +6 -4
- package/dist/Editor/common/ImageSelector/Styles.js +3 -9
- package/dist/Editor/common/LinkSettings/NavComponents.js +14 -10
- package/dist/Editor/common/LinkSettings/index.js +20 -14
- package/dist/Editor/common/LinkSettings/navOptions.js +1 -1
- package/dist/Editor/common/MUIIcon/index.js +0 -3
- package/dist/Editor/common/MentionsPopup/index.js +6 -2
- package/dist/Editor/common/RnD/ContextMenu/CMenus.js +46 -22
- package/dist/Editor/common/RnD/ContextMenu/index.js +3 -2
- package/dist/Editor/common/RnD/ElementOptions/index.js +7 -2
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/SaveAsTemplate.js +8 -3
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +7 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +7 -4
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +6 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +3 -2
- package/dist/Editor/common/RnD/OptionsPopup/index.js +4 -3
- package/dist/Editor/common/RnD/ShadowElement.js +2 -1
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +11 -4
- package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +73 -9
- package/dist/Editor/common/RnD/Utils/index.js +3 -0
- package/dist/Editor/common/RnD/VirtualElement/BoxHeaderAutoAlignment.js +43 -0
- package/dist/Editor/common/RnD/VirtualElement/ForceAutoAlignment.js +44 -0
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +134 -0
- package/dist/Editor/common/RnD/VirtualElement/helper.js +382 -0
- package/dist/Editor/common/RnD/VirtualElement/index.js +187 -103
- package/dist/Editor/common/RnD/VirtualElement/styles.js +155 -7
- package/dist/Editor/common/RnD/VirtualElement/updateAutoProps.js +5 -3
- package/dist/Editor/common/RnD/index.js +69 -13
- package/dist/Editor/common/Section/index.js +7 -4
- package/dist/Editor/common/Shorthands/elements.js +72 -3
- package/dist/Editor/common/SnackBar/index.js +43 -0
- package/dist/Editor/common/StyleBuilder/appHeaderStyle.js +4 -4
- package/dist/Editor/common/StyleBuilder/boxStyle.js +2 -2
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +6 -4
- package/dist/Editor/common/StyleBuilder/dividerStyles.js +2 -2
- package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +6 -6
- package/dist/Editor/common/StyleBuilder/fieldStyle.js +2 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/alignment.js +13 -9
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +11 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +19 -5
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +22 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +6 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +27 -13
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +43 -14
- package/dist/Editor/common/StyleBuilder/fieldTypes/elementSize.js +10 -6
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +19 -6
- package/dist/Editor/common/StyleBuilder/fieldTypes/gridSize.js +6 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +5 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +7 -6
- package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +9 -6
- package/dist/Editor/common/StyleBuilder/fieldTypes/metaDataMapping.js +8 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/saveAsTemplate.js +12 -11
- package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +6 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +8 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/textAlign.js +6 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +21 -12
- package/dist/Editor/common/StyleBuilder/formStyle.js +7 -7
- package/dist/Editor/common/StyleBuilder/gridItemStyle.js +6 -6
- package/dist/Editor/common/StyleBuilder/gridStyle.js +5 -5
- package/dist/Editor/common/StyleBuilder/index.js +8 -5
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +5 -7
- package/dist/Editor/common/SwipeableDrawer/index.js +1 -1
- package/dist/Editor/common/Uploader.js +16 -5
- package/dist/Editor/commonStyle.js +68 -57
- package/dist/Editor/helper/index.js +27 -3
- package/dist/Editor/helper/textIndeces.js +58 -0
- package/dist/Editor/helper/theme.js +202 -2
- package/dist/Editor/hooks/useAutoScroll.js +38 -0
- package/dist/Editor/hooks/useEditorTheme.js +153 -0
- package/dist/Editor/hooks/useMouseMove.js +9 -3
- package/dist/Editor/hooks/useThemeValues.js +63 -0
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +11 -9
- package/dist/Editor/plugins/withLayout.js +3 -2
- package/dist/Editor/plugins/withLinks.js +10 -0
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/theme/ThemeList.js +50 -173
- package/dist/Editor/theme/index.js +149 -0
- package/dist/Editor/themeSettings/ActiveTheme.js +72 -0
- package/dist/Editor/themeSettings/buttons/index.js +290 -0
- package/dist/Editor/themeSettings/buttons/style.js +23 -0
- package/dist/Editor/themeSettings/colorTheme/index.js +310 -0
- package/dist/Editor/themeSettings/colorTheme/style.js +81 -0
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
- package/dist/Editor/themeSettings/fonts/index.js +240 -0
- package/dist/Editor/themeSettings/fonts/style.js +61 -0
- package/dist/Editor/themeSettings/icons.js +60 -0
- package/dist/Editor/themeSettings/index.js +351 -0
- package/dist/Editor/themeSettings/style.js +220 -0
- package/dist/Editor/themeSettingsAI/icons.js +96 -0
- package/dist/Editor/themeSettingsAI/index.js +355 -0
- package/dist/Editor/themeSettingsAI/saveTheme.js +205 -0
- package/dist/Editor/themeSettingsAI/style.js +259 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +186 -54
- package/dist/Editor/utils/brains.js +1 -2
- package/dist/Editor/utils/draftToSlate.js +3 -2
- package/dist/Editor/utils/font.js +40 -37
- package/dist/Editor/utils/freegrid.js +3 -3
- package/dist/Editor/utils/helper.js +92 -21
- package/package.json +4 -4
@@ -0,0 +1,382 @@
|
|
1
|
+
import { ROW_HEIGHT, calculateGridArea } from "../Utils/gridDropItem";
|
2
|
+
import { Transforms, Editor } from "slate";
|
3
|
+
const isBulletOrTickIcon = (width, itemStartRow, startRow) => {
|
4
|
+
return width <= 40 && itemStartRow === startRow;
|
5
|
+
};
|
6
|
+
export const findFirstRowOverlap = (gridItems, startRow, endRow, textItemIndex) => {
|
7
|
+
let firstOverlapRow;
|
8
|
+
gridItems.forEach((gridItem, index) => {
|
9
|
+
const {
|
10
|
+
gridArea_xs: gridArea,
|
11
|
+
width_xs
|
12
|
+
} = gridItem;
|
13
|
+
if (!gridArea) {
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
const [itemStartRow] = getGridArea(gridArea);
|
17
|
+
const isItemOverlap = itemStartRow >= startRow && itemStartRow <= endRow;
|
18
|
+
if (isBulletOrTickIcon(width_xs, itemStartRow, startRow)) {
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
const isCurrentEle = textItemIndex === index;
|
22
|
+
if (isItemOverlap && !isCurrentEle && gridArea) {
|
23
|
+
firstOverlapRow = firstOverlapRow ? Math.min(firstOverlapRow, itemStartRow) : itemStartRow;
|
24
|
+
}
|
25
|
+
});
|
26
|
+
return firstOverlapRow;
|
27
|
+
};
|
28
|
+
export const getHeight = (oldHeight, newHeight) => {
|
29
|
+
const changeHeight = oldHeight && oldHeight < newHeight;
|
30
|
+
const height = changeHeight ? newHeight : oldHeight;
|
31
|
+
return {
|
32
|
+
height,
|
33
|
+
changeHeight
|
34
|
+
};
|
35
|
+
};
|
36
|
+
export const getGridArea = gridArea => {
|
37
|
+
return gridArea.split("/").map(num => parseInt(num));
|
38
|
+
};
|
39
|
+
const getBoxToAutoAlign = (editor, sectionPath) => {
|
40
|
+
const [boxData] = Editor.nodes(editor, {
|
41
|
+
at: sectionPath,
|
42
|
+
match: node => node.type === "freegridBox" && node.autoAlign
|
43
|
+
});
|
44
|
+
return boxData || [];
|
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;
|
73
|
+
|
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
|
+
};
|
142
|
+
const getAncestorFreeGridContainers = (editor, path) => {
|
143
|
+
const containers = [...Editor.nodes(editor, {
|
144
|
+
at: path,
|
145
|
+
// Start from the current path
|
146
|
+
match: (node, nodePath) => {
|
147
|
+
const container = ["freegridBox", "freegrid"].includes(node.type);
|
148
|
+
return container;
|
149
|
+
},
|
150
|
+
reverse: true // Go upwards in the document tree
|
151
|
+
})].filter(([node, nodePath]) => nodePath.length <= path.length);
|
152
|
+
return containers;
|
153
|
+
};
|
154
|
+
export const handleContainers = (editor, boxPath, extraHeight) => {
|
155
|
+
const containers = getAncestorFreeGridContainers(editor, boxPath);
|
156
|
+
let lastChildStartRow;
|
157
|
+
let lastChildEndRow;
|
158
|
+
let lastChildPath;
|
159
|
+
const containerData = [];
|
160
|
+
for (let i = containers.length - 1; i >= 0; i--) {
|
161
|
+
const container = containers[i];
|
162
|
+
const childContainer = containers[i + 1];
|
163
|
+
const [containerNode, containerPath] = container;
|
164
|
+
const {
|
165
|
+
gridArea_xs,
|
166
|
+
height_xs,
|
167
|
+
marginTop_xs
|
168
|
+
} = containerNode;
|
169
|
+
const [startRow] = gridArea_xs ? getGridArea(gridArea_xs) : [0]; // there is no grid area for section nodes
|
170
|
+
|
171
|
+
let newHeight = Number(height_xs) + extraHeight;
|
172
|
+
let fullHeight = newHeight + Number(marginTop_xs); // to find end row
|
173
|
+
|
174
|
+
if (!childContainer) {
|
175
|
+
const endRow = startRow + Math.floor(fullHeight / ROW_HEIGHT) + 1;
|
176
|
+
containerData.push({
|
177
|
+
moveRows: 0,
|
178
|
+
extraHeight,
|
179
|
+
containerPath,
|
180
|
+
newHeight,
|
181
|
+
containerNode,
|
182
|
+
lastChildStartRow
|
183
|
+
});
|
184
|
+
lastChildStartRow = startRow;
|
185
|
+
lastChildEndRow = endRow;
|
186
|
+
} else {
|
187
|
+
const lastChildIndex = lastChildPath[containerPath.length];
|
188
|
+
const firstOverlappedRow = findFirstRowOverlap(containerNode?.children, lastChildStartRow, lastChildEndRow, lastChildIndex);
|
189
|
+
const moveRows = firstOverlappedRow ? lastChildEndRow - firstOverlappedRow : 0;
|
190
|
+
newHeight = newHeight + moveRows * ROW_HEIGHT;
|
191
|
+
fullHeight = newHeight + Number(marginTop_xs);
|
192
|
+
const newEndRow = startRow + Math.floor(fullHeight / ROW_HEIGHT) + 1;
|
193
|
+
containerData.push({
|
194
|
+
moveRows,
|
195
|
+
extraHeight,
|
196
|
+
childIndex: lastChildIndex,
|
197
|
+
newHeight,
|
198
|
+
containerPath,
|
199
|
+
containerNode,
|
200
|
+
lastChildStartRow
|
201
|
+
});
|
202
|
+
lastChildStartRow = startRow;
|
203
|
+
lastChildEndRow = newEndRow;
|
204
|
+
}
|
205
|
+
lastChildPath = containerPath;
|
206
|
+
}
|
207
|
+
return containerData;
|
208
|
+
};
|
209
|
+
export const moveOverlappedItems = (editor, moveRows, containerItems, containerPath, childIndex, lastChildStartRow) => {
|
210
|
+
containerItems?.forEach((gridItem, index) => {
|
211
|
+
const isChildEle = childIndex === index;
|
212
|
+
if (isChildEle) {
|
213
|
+
return;
|
214
|
+
}
|
215
|
+
if (gridItem.type === "paragraph") {
|
216
|
+
return;
|
217
|
+
}
|
218
|
+
const {
|
219
|
+
gridArea_xs: gridArea,
|
220
|
+
width_xs
|
221
|
+
} = gridItem;
|
222
|
+
const [itemStartRow] = getGridArea(gridArea);
|
223
|
+
if (isBulletOrTickIcon(width_xs, itemStartRow, lastChildStartRow)) {
|
224
|
+
return;
|
225
|
+
}
|
226
|
+
if (itemStartRow >= lastChildStartRow) {
|
227
|
+
const row = itemStartRow + moveRows;
|
228
|
+
const newGridArea = `${row} / 1 / ${row + 1} / 2`;
|
229
|
+
const currentElementPath = [...containerPath, index];
|
230
|
+
Transforms.setNodes(editor, {
|
231
|
+
gridArea_xs: newGridArea
|
232
|
+
}, {
|
233
|
+
at: currentElementPath
|
234
|
+
});
|
235
|
+
}
|
236
|
+
});
|
237
|
+
};
|
238
|
+
export const handleBoxAlignment = (editor, sectionNode, sectionPath) => {
|
239
|
+
const [boxNode, boxPath] = getBoxToAutoAlign(editor, sectionPath);
|
240
|
+
Transforms.setNodes(editor, {
|
241
|
+
autoAlign: false
|
242
|
+
}, {
|
243
|
+
at: boxPath
|
244
|
+
});
|
245
|
+
if (!boxNode) {
|
246
|
+
return;
|
247
|
+
}
|
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
|
+
});
|
280
|
+
}
|
281
|
+
};
|
282
|
+
export const getMarginTop = y => {
|
283
|
+
const calcMargin = y % ROW_HEIGHT;
|
284
|
+
return calcMargin <= 0 ? 0 : calcMargin;
|
285
|
+
};
|
286
|
+
export const calculateProps = (curPath, dom, domClass, allData, parentDom, isBoxHeader) => {
|
287
|
+
const rect = dom?.getBoundingClientRect();
|
288
|
+
const bufferHeight = parentDom ? 0 : 12;
|
289
|
+
const sectionProps = {
|
290
|
+
path: curPath,
|
291
|
+
props: {
|
292
|
+
height: rect?.height + bufferHeight
|
293
|
+
}
|
294
|
+
};
|
295
|
+
const itemsData = [];
|
296
|
+
const items = dom.querySelectorAll(domClass);
|
297
|
+
const nextItemPathLength = curPath?.split("|").length + 2;
|
298
|
+
let sectionHeight = 12;
|
299
|
+
for (let i = 0; i < items.length; i++) {
|
300
|
+
const itemRect = items[i]?.getBoundingClientRect();
|
301
|
+
if (items[i]?.classList.contains("type_box")) {
|
302
|
+
allData = calculateProps(items[i]?.dataset.path, items[i], `.freegrid-item.path-${nextItemPathLength}`, allData, dom);
|
303
|
+
} else {
|
304
|
+
const y = Math.abs(rect.top - itemRect?.top);
|
305
|
+
const left = Math.abs(rect.left - itemRect?.left);
|
306
|
+
const isAppHeader = isBoxHeader || dom?.classList?.contains("appHeaderBox");
|
307
|
+
itemsData.push({
|
308
|
+
path: items[i]?.dataset.path,
|
309
|
+
props: {
|
310
|
+
top: y,
|
311
|
+
left: isAppHeader ? left : 24,
|
312
|
+
marginTop: getMarginTop(y),
|
313
|
+
width: itemRect?.width,
|
314
|
+
height: itemRect?.height,
|
315
|
+
gridArea: calculateGridArea(y)
|
316
|
+
}
|
317
|
+
});
|
318
|
+
sectionHeight += itemRect?.height;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
if (dom?.classList.contains("type_box") && parentDom) {
|
322
|
+
const parentDomRect = parentDom?.getBoundingClientRect();
|
323
|
+
const isAppHeader = isBoxHeader || dom?.classList.contains("appHeaderBox");
|
324
|
+
const y = Math.abs(parentDomRect.top - rect?.top);
|
325
|
+
sectionProps.props.gridArea = calculateGridArea(y);
|
326
|
+
sectionProps.props.left = isAppHeader ? 6 : 24;
|
327
|
+
sectionProps.props.marginTop = getMarginTop(y);
|
328
|
+
sectionProps.props.width = rect?.width;
|
329
|
+
}
|
330
|
+
allData = [sectionProps, [...allData, ...itemsData]]?.flat();
|
331
|
+
return allData;
|
332
|
+
};
|
333
|
+
export const sortElements = (items, container) => {
|
334
|
+
const elementsArray = Array.from(items);
|
335
|
+
elementsArray.sort((a, b) => {
|
336
|
+
const aGridArea = a.dataset.gridAreaXs;
|
337
|
+
const bGridArea = b.dataset.gridAreaXs;
|
338
|
+
|
339
|
+
// If either element has no gridArea, push it to the end
|
340
|
+
if (!aGridArea) return 1;
|
341
|
+
if (!bGridArea) return -1;
|
342
|
+
const [aRow] = aGridArea.split("/").map(Number);
|
343
|
+
const [bRow] = bGridArea.split("/").map(Number);
|
344
|
+
if (aRow !== bRow) {
|
345
|
+
return aRow - bRow; // Sort by start row first
|
346
|
+
}
|
347
|
+
|
348
|
+
// Compare marginTopXs
|
349
|
+
const aMarginTop = parseFloat(a.dataset.marginTopXs) || 0;
|
350
|
+
const bMarginTop = parseFloat(b.dataset.marginTopXs) || 0;
|
351
|
+
const BUFFER_DIFF = 5;
|
352
|
+
if (Math.abs(aMarginTop - bMarginTop) > BUFFER_DIFF) {
|
353
|
+
return aMarginTop - bMarginTop;
|
354
|
+
}
|
355
|
+
const aLeft = parseFloat(a.dataset.leftXs) || 0;
|
356
|
+
const bLeft = parseFloat(b.dataset.leftXs) || 0;
|
357
|
+
return aLeft - bLeft;
|
358
|
+
});
|
359
|
+
|
360
|
+
// Append sorted elements to container
|
361
|
+
elementsArray.forEach(item => {
|
362
|
+
container.appendChild(item);
|
363
|
+
|
364
|
+
// If item is a box, recursively sort its children
|
365
|
+
if (item.classList.contains("type_box")) {
|
366
|
+
const nestedContainer = item.querySelector(":scope > .fgi_type_box");
|
367
|
+
const isAppHeader = item.querySelector(".type_appHeader");
|
368
|
+
if (isAppHeader) {
|
369
|
+
item.classList.add("appHeaderBox");
|
370
|
+
}
|
371
|
+
if (nestedContainer) {
|
372
|
+
const childToRemove = nestedContainer.querySelector(":scope > .simple-text");
|
373
|
+
if (childToRemove) {
|
374
|
+
nestedContainer.removeChild(childToRemove);
|
375
|
+
}
|
376
|
+
const children = nestedContainer.children;
|
377
|
+
sortElements(children, nestedContainer);
|
378
|
+
item.appendChild(nestedContainer);
|
379
|
+
}
|
380
|
+
}
|
381
|
+
});
|
382
|
+
};
|