@flozy/editor 3.8.7 → 3.8.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/ChatEditor.js +2 -2
- package/dist/Editor/CommonEditor.js +170 -166
- package/dist/Editor/DialogWrapper.js +4 -3
- package/dist/Editor/Editor.css +4 -7
- package/dist/Editor/Elements/AI/AIInput.js +5 -16
- package/dist/Editor/Elements/AI/PopoverAIInput.js +64 -67
- package/dist/Editor/Elements/AI/Styles.js +1 -2
- package/dist/Editor/Elements/AppHeader/AppHeader.js +40 -49
- package/dist/Editor/Elements/Button/EditorButton.js +33 -38
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +17 -60
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
- package/dist/Editor/Elements/Color Picker/Styles.js +1 -2
- package/dist/Editor/Elements/Embed/Image.js +15 -14
- package/dist/Editor/Elements/Embed/Video.js +12 -8
- package/dist/Editor/Elements/Emoji/EmojiButton.js +11 -7
- package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +3 -12
- package/dist/Editor/Elements/Form/Workflow/UserInputs.js +1 -2
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +391 -0
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +193 -0
- package/dist/Editor/Elements/FreeGrid/FreeGridButton.js +23 -0
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +184 -0
- package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +36 -0
- package/dist/Editor/Elements/FreeGrid/Options/More.js +24 -0
- package/dist/Editor/Elements/FreeGrid/Options/SectionSettings.js +47 -0
- package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +11 -0
- package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +75 -0
- package/dist/Editor/Elements/FreeGrid/styles.js +159 -0
- package/dist/Editor/Elements/Grid/Grid.js +14 -34
- package/dist/Editor/Elements/Grid/GridItem.js +31 -23
- package/dist/Editor/Elements/Link/Link.js +1 -6
- package/dist/Editor/Elements/Link/LinkButton.js +2 -4
- package/dist/Editor/Elements/Link/LinkPopup.js +3 -10
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +3 -3
- package/dist/Editor/Elements/Signature/SignaturePopup.js +3 -14
- package/dist/Editor/Elements/SimpleText/index.js +9 -8
- package/dist/Editor/Elements/SimpleText/style.js +37 -0
- package/dist/Editor/Elements/Table/Styles.js +1 -23
- package/dist/Editor/Elements/Table/Table.js +1 -2
- package/dist/Editor/Elements/Table/TableCell.js +7 -69
- package/dist/Editor/Elements/TableContextMenu/TableContextMenu.js +0 -1
- package/dist/Editor/ErrorBoundary.js +30 -0
- package/dist/Editor/MiniEditor.js +1 -3
- package/dist/Editor/Styles/EditorStyles.js +23 -0
- package/dist/Editor/Toolbar/Basic/index.js +2 -4
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +2 -26
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +18 -29
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +2 -4
- package/dist/Editor/Toolbar/Mini/Options/Options.js +0 -10
- package/dist/Editor/Toolbar/Mini/Styles.js +0 -7
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +11 -4
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +86 -213
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +13 -20
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +8 -52
- package/dist/Editor/Toolbar/PopupTool/index.js +13 -6
- package/dist/Editor/Toolbar/Toolbar.js +7 -0
- package/dist/Editor/Toolbar/toolbarGroups.js +11 -48
- package/dist/Editor/assets/svg/AIIcons.js +1 -153
- package/dist/Editor/assets/svg/AddTemplateIcon.js +10 -13
- package/dist/Editor/assets/svg/TextIcon.js +5 -8
- package/dist/Editor/common/ColorPickerButton.js +9 -25
- package/dist/Editor/common/DnD/DragHandleButton.js +47 -56
- package/dist/Editor/common/Icon.js +8 -41
- package/dist/Editor/common/LinkSettings/NavComponents.js +2 -5
- package/dist/Editor/common/LinkSettings/index.js +2 -4
- package/dist/Editor/common/LinkSettings/navOptions.js +2 -7
- package/dist/Editor/common/LinkSettings/style.js +8 -11
- package/dist/Editor/common/MentionsPopup/index.js +12 -8
- package/dist/Editor/common/RnD/ContextMenu/CMenus.js +105 -0
- package/dist/Editor/common/RnD/ContextMenu/index.js +38 -0
- package/dist/Editor/common/RnD/ContextMenu/styles.js +21 -0
- package/dist/Editor/common/RnD/DragInfo/index.js +31 -0
- package/dist/Editor/common/RnD/DragInfo/styles.js +15 -0
- package/dist/Editor/common/RnD/DragOver/index.js +46 -0
- package/dist/Editor/common/RnD/DragOver/styles.js +23 -0
- package/dist/Editor/common/RnD/ElementOptions/Actions.js +82 -0
- package/dist/Editor/common/RnD/ElementOptions/Icons/LinkIcon.js +26 -0
- package/dist/Editor/common/RnD/ElementOptions/index.js +93 -0
- package/dist/Editor/common/RnD/ElementOptions/styles.js +41 -0
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Link.js +153 -0
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +58 -0
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/index.js +7 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +46 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +46 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +46 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +30 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +46 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/index.js +13 -0
- package/dist/Editor/common/RnD/ElementSettings/index.js +17 -0
- package/dist/Editor/common/RnD/ElementSettings/settingsConstants.js +14 -0
- package/dist/Editor/common/RnD/ElementSettings/styles.js +76 -0
- package/dist/Editor/common/RnD/GuideLines/BoundaryLine.js +52 -0
- package/dist/Editor/common/RnD/GuideLines/index.js +33 -0
- package/dist/Editor/common/RnD/GuideLines/styles.js +60 -0
- package/dist/Editor/common/RnD/OptionsPopup/index.js +50 -0
- package/dist/Editor/common/RnD/OptionsPopup/style.js +36 -0
- package/dist/Editor/common/RnD/RnDCopy.js +23 -0
- package/dist/Editor/common/RnD/ShadowElement.js +34 -0
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +40 -0
- package/dist/Editor/common/RnD/SwitchViewport/styles.js +24 -0
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +63 -0
- package/dist/Editor/common/RnD/TransformHandles/CornerHandle.js +19 -0
- package/dist/Editor/common/RnD/TransformHandles/Icons/BottomRightIcon.js +13 -0
- package/dist/Editor/common/RnD/TransformHandles/SizeHandle.js +18 -0
- package/dist/Editor/common/RnD/TransformHandles/index.js +62 -0
- package/dist/Editor/common/RnD/Utils/alignmentDetection.js +26 -0
- package/dist/Editor/common/RnD/Utils/calculateDropItem.js +98 -0
- package/dist/Editor/common/RnD/Utils/collisionDetection.js +52 -0
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +148 -0
- package/dist/Editor/common/RnD/Utils/index.js +251 -0
- package/dist/Editor/common/RnD/VirtualElement/index.js +76 -0
- package/dist/Editor/common/RnD/VirtualElement/styles.js +27 -0
- package/dist/Editor/common/RnD/VirtualElement/updateAutoProps.js +28 -0
- package/dist/Editor/common/RnD/index.js +503 -0
- package/dist/Editor/common/RnD/styles.js +4 -0
- package/dist/Editor/common/Section/index.js +28 -69
- package/dist/Editor/common/Section/styles.js +6 -12
- package/dist/Editor/common/Shorthands/elements.js +12 -54
- package/dist/Editor/common/StyleBuilder/boxStyle.js +30 -0
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +16 -19
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
- package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +1 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +7 -31
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +4 -13
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +4 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +4 -14
- package/dist/Editor/common/StyleBuilder/index.js +1 -1
- package/dist/Editor/common/StyleBuilder/sectionStyle.js +13 -2
- package/dist/Editor/common/iconslist.js +31 -0
- package/dist/Editor/helper/RnD/focusOnNewItem.js +39 -0
- package/dist/Editor/helper/RnD/scrollToNewSection.js +24 -0
- package/dist/Editor/helper/breakpoint.js +5 -0
- package/dist/Editor/helper/index.js +139 -0
- package/dist/Editor/helper/theme.js +48 -185
- package/dist/Editor/hooks/useBreakpoints.js +34 -0
- package/dist/Editor/hooks/useMouseMove.js +37 -12
- package/dist/Editor/hooks/useWindowMessage.js +7 -10
- package/dist/Editor/hooks/withCommon.js +2 -1
- package/dist/Editor/hooks/withErrorHandling.js +14 -0
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +1 -1
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/theme/ThemeList.js +173 -50
- package/dist/Editor/utils/RnD/RnDCtrlCmds.js +168 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +47 -163
- package/dist/Editor/utils/button.js +17 -1
- package/dist/Editor/utils/events.js +7 -54
- package/dist/Editor/utils/font.js +37 -40
- package/dist/Editor/utils/freegrid.js +49 -0
- package/dist/Editor/utils/helper.js +31 -31
- package/dist/Editor/utils/table.js +43 -51
- package/package.json +6 -4
- package/dist/Editor/Elements/AI/VoiceToText/AudioWave.js +0 -73
- package/dist/Editor/Elements/AI/VoiceToText/index.js +0 -167
- package/dist/Editor/Elements/AI/VoiceToText/style.js +0 -40
- package/dist/Editor/Elements/Link/LinkPopupStyles.js +0 -28
- package/dist/Editor/Elements/Redo/RedoButton.js +0 -14
- package/dist/Editor/Elements/Undo/UndoButton.js +0 -14
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -438
- package/dist/Editor/assets/svg/RedoIcon.js +0 -27
- package/dist/Editor/assets/svg/SettingsIcon.js +0 -28
- package/dist/Editor/assets/svg/ThemeIcons.js +0 -291
- package/dist/Editor/assets/svg/UndoIcon.js +0 -27
- package/dist/Editor/common/CustomColorPicker/index.js +0 -106
- package/dist/Editor/common/CustomColorPicker/style.js +0 -53
- package/dist/Editor/common/CustomDialog/index.js +0 -94
- package/dist/Editor/common/CustomDialog/style.js +0 -67
- package/dist/Editor/common/CustomSelect.js +0 -33
- package/dist/Editor/hooks/useEditorTheme.js +0 -139
- package/dist/Editor/theme/index.js +0 -144
- package/dist/Editor/themeSettings/ActiveTheme.js +0 -72
- package/dist/Editor/themeSettings/buttons/index.js +0 -290
- package/dist/Editor/themeSettings/buttons/style.js +0 -21
- package/dist/Editor/themeSettings/colorTheme/index.js +0 -290
- package/dist/Editor/themeSettings/colorTheme/style.js +0 -77
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -123
- package/dist/Editor/themeSettings/fonts/index.js +0 -213
- package/dist/Editor/themeSettings/fonts/style.js +0 -44
- package/dist/Editor/themeSettings/icons.js +0 -60
- package/dist/Editor/themeSettings/index.js +0 -320
- package/dist/Editor/themeSettings/style.js +0 -152
- package/dist/Editor/themeSettingsAI/icons.js +0 -96
- package/dist/Editor/themeSettingsAI/index.js +0 -356
- package/dist/Editor/themeSettingsAI/saveTheme.js +0 -190
- package/dist/Editor/themeSettingsAI/style.js +0 -247
@@ -0,0 +1,193 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Transforms, Node, Path } from "slate";
|
3
|
+
import { useSlateStatic } from "slate-react";
|
4
|
+
import { ReactEditor } from "slate-react";
|
5
|
+
import { Box, useTheme } from "@mui/material";
|
6
|
+
import RnD from "../../common/RnD";
|
7
|
+
import { onDropItem } from "../../common/RnD/Utils/gridDropItem";
|
8
|
+
import useBreakpoints from "../../hooks/useBreakpoints";
|
9
|
+
import { breakpointValues, formatBreakpointValues } from "./breakpointConstants";
|
10
|
+
import { useEditorContext } from "../../hooks/useMouseMove";
|
11
|
+
import { getBreakPointsValue } from "../../helper/theme";
|
12
|
+
import focusOnNewItem from "../../helper/RnD/focusOnNewItem";
|
13
|
+
import { bringItemToFB } from "../../helper";
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
15
|
+
const FreeGridBox = props => {
|
16
|
+
const theme = useTheme();
|
17
|
+
const breakpoint = useBreakpoints(theme);
|
18
|
+
const {
|
19
|
+
element,
|
20
|
+
attributes,
|
21
|
+
children,
|
22
|
+
customProps
|
23
|
+
} = props;
|
24
|
+
const editor = useSlateStatic();
|
25
|
+
const path = ReactEditor.findPath(editor, element);
|
26
|
+
const {
|
27
|
+
readOnly
|
28
|
+
} = customProps;
|
29
|
+
const {
|
30
|
+
updated_at,
|
31
|
+
zIndex,
|
32
|
+
sectionBgColor,
|
33
|
+
sectionBackgroundImage,
|
34
|
+
sectionBorderRadius
|
35
|
+
} = element;
|
36
|
+
// get values based on breakpoint size
|
37
|
+
const {
|
38
|
+
gridArea,
|
39
|
+
width,
|
40
|
+
height,
|
41
|
+
left,
|
42
|
+
top,
|
43
|
+
marginTop
|
44
|
+
} = breakpointValues(element.type, breakpoint, element);
|
45
|
+
const {
|
46
|
+
setSelectedElement
|
47
|
+
} = useEditorContext();
|
48
|
+
const arrangeIndex = zIndex === undefined ? path[path.length - 1] : zIndex;
|
49
|
+
const onChangeSettings = () => {};
|
50
|
+
const onChange = data => {
|
51
|
+
let updateData = {
|
52
|
+
...data
|
53
|
+
};
|
54
|
+
delete updateData.children;
|
55
|
+
updateData = formatBreakpointValues(element.type, breakpoint, updateData);
|
56
|
+
Transforms.setNodes(editor, {
|
57
|
+
...updateData
|
58
|
+
}, {
|
59
|
+
at: path
|
60
|
+
});
|
61
|
+
};
|
62
|
+
const handleDragEvent = (type, data, cb) => {
|
63
|
+
const toPosition = {
|
64
|
+
left: left + data.lastX,
|
65
|
+
top: top + data.lastY
|
66
|
+
};
|
67
|
+
const {
|
68
|
+
node,
|
69
|
+
...rest
|
70
|
+
} = data;
|
71
|
+
switch (type) {
|
72
|
+
case "stop":
|
73
|
+
const updated_data = onDropItem({
|
74
|
+
editor,
|
75
|
+
fromPosition: {
|
76
|
+
left,
|
77
|
+
top
|
78
|
+
},
|
79
|
+
toPosition,
|
80
|
+
path,
|
81
|
+
ref: node,
|
82
|
+
breakpoint,
|
83
|
+
...rest
|
84
|
+
}, ".freegrid-container");
|
85
|
+
if (cb) {
|
86
|
+
cb(updated_data);
|
87
|
+
}
|
88
|
+
break;
|
89
|
+
default:
|
90
|
+
}
|
91
|
+
};
|
92
|
+
const handleResizeEvent = (type, data, cb) => {
|
93
|
+
switch (type) {
|
94
|
+
case "stop":
|
95
|
+
return;
|
96
|
+
default:
|
97
|
+
}
|
98
|
+
};
|
99
|
+
const onDelete = () => {
|
100
|
+
try {
|
101
|
+
Transforms.removeNodes(editor, {
|
102
|
+
at: path
|
103
|
+
});
|
104
|
+
} catch (err) {
|
105
|
+
console.log(err);
|
106
|
+
}
|
107
|
+
};
|
108
|
+
const handleContextMenuClick = d => {
|
109
|
+
switch (d?.name) {
|
110
|
+
case "bringForward":
|
111
|
+
bringItemToFB(editor, {
|
112
|
+
path,
|
113
|
+
moveFront: true
|
114
|
+
});
|
115
|
+
Transforms.setNodes(editor, {
|
116
|
+
zIndex: Math.min(arrangeIndex + 1, editor.children.length)
|
117
|
+
}, {
|
118
|
+
at: path
|
119
|
+
});
|
120
|
+
break;
|
121
|
+
case "bringBackward":
|
122
|
+
bringItemToFB(editor, {
|
123
|
+
path,
|
124
|
+
moveFront: false
|
125
|
+
});
|
126
|
+
break;
|
127
|
+
case "cut":
|
128
|
+
window.copiedNode = JSON.stringify(Node.get(editor, path));
|
129
|
+
onDelete();
|
130
|
+
focusOnNewItem(editor, Path.parent(path), {
|
131
|
+
setSelectedElement
|
132
|
+
});
|
133
|
+
break;
|
134
|
+
case "copy":
|
135
|
+
window.copiedNode = JSON.stringify(Node.get(editor, path));
|
136
|
+
break;
|
137
|
+
case "delete":
|
138
|
+
onDelete();
|
139
|
+
setSelectedElement({});
|
140
|
+
break;
|
141
|
+
default:
|
142
|
+
return;
|
143
|
+
}
|
144
|
+
};
|
145
|
+
return /*#__PURE__*/_jsx(RnD, {
|
146
|
+
id: `freegrid_box_item_${path.join("|")}_${updated_at}_${breakpoint}`,
|
147
|
+
className: `freegrid-item breakpoint-${breakpoint}`,
|
148
|
+
editor: editor,
|
149
|
+
path: path,
|
150
|
+
actions: ["ai", "drag", "settings", "close"],
|
151
|
+
settingsProps: {
|
152
|
+
settings: "freegridBoxItem",
|
153
|
+
onChange: onChangeSettings
|
154
|
+
},
|
155
|
+
style: {
|
156
|
+
"--left": `${left || 0}px`,
|
157
|
+
"--marginTop": `${marginTop || 0}px`,
|
158
|
+
"--gridArea": `${gridArea}`,
|
159
|
+
"--width": `${width}px`,
|
160
|
+
"--height": `${height}px`,
|
161
|
+
"--zIndex": 100 + arrangeIndex
|
162
|
+
},
|
163
|
+
defaultStyle: {
|
164
|
+
height: `${height}px`,
|
165
|
+
width: `${width}px`
|
166
|
+
},
|
167
|
+
gridArea: gridArea,
|
168
|
+
onChange: onChange,
|
169
|
+
delta: {
|
170
|
+
width,
|
171
|
+
height
|
172
|
+
},
|
173
|
+
handleDragEvent: handleDragEvent,
|
174
|
+
handleResizeEvent: handleResizeEvent,
|
175
|
+
readOnly: readOnly,
|
176
|
+
childType: "box",
|
177
|
+
handleContextMenuClick: handleContextMenuClick,
|
178
|
+
children: /*#__PURE__*/_jsx(Box, {
|
179
|
+
component: "div",
|
180
|
+
...attributes,
|
181
|
+
className: `fgi_type_box`,
|
182
|
+
sx: {
|
183
|
+
borderRadius: {
|
184
|
+
...getBreakPointsValue(sectionBorderRadius || {}, null, "overrideBorderRadius", true)
|
185
|
+
},
|
186
|
+
background: sectionBgColor,
|
187
|
+
backgroundImage: `url(${sectionBackgroundImage})`
|
188
|
+
},
|
189
|
+
children: children
|
190
|
+
})
|
191
|
+
});
|
192
|
+
};
|
193
|
+
export default FreeGridBox;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import ToolbarIcon from "../../common/ToolbarIcon";
|
3
|
+
import Icon from "../../common/Icon";
|
4
|
+
import { insertFreeGrid } from "../../utils/freegrid";
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
6
|
+
const FreeGridButton = props => {
|
7
|
+
const {
|
8
|
+
editor,
|
9
|
+
icoBtnType
|
10
|
+
} = props;
|
11
|
+
const onButtonClick = () => {
|
12
|
+
insertFreeGrid(editor);
|
13
|
+
};
|
14
|
+
return /*#__PURE__*/_jsx(ToolbarIcon, {
|
15
|
+
title: "Free Grid",
|
16
|
+
onClick: onButtonClick,
|
17
|
+
icon: /*#__PURE__*/_jsx(Icon, {
|
18
|
+
icon: "freegrid"
|
19
|
+
}),
|
20
|
+
icoBtnType: icoBtnType
|
21
|
+
});
|
22
|
+
};
|
23
|
+
export default FreeGridButton;
|
@@ -0,0 +1,184 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Transforms, Node, Path } from "slate";
|
3
|
+
import { useSlateStatic } from "slate-react";
|
4
|
+
import { ReactEditor } from "slate-react";
|
5
|
+
import { Box, useTheme } from "@mui/material";
|
6
|
+
import RnD from "../../common/RnD";
|
7
|
+
import { onDropItem } from "../../common/RnD/Utils/gridDropItem";
|
8
|
+
import useBreakpoints from "../../hooks/useBreakpoints";
|
9
|
+
import { breakpointValues, formatBreakpointValues } from "./breakpointConstants";
|
10
|
+
import { useEditorContext } from "../../hooks/useMouseMove";
|
11
|
+
import focusOnNewItem from "../../helper/RnD/focusOnNewItem";
|
12
|
+
import { bringItemToFB } from "../../helper";
|
13
|
+
import itemOptions from "./Options/sectionItemOptions";
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
15
|
+
const FreeGridItem = props => {
|
16
|
+
const theme = useTheme();
|
17
|
+
const breakpoint = useBreakpoints(theme);
|
18
|
+
const {
|
19
|
+
element,
|
20
|
+
attributes,
|
21
|
+
children,
|
22
|
+
customProps
|
23
|
+
} = props;
|
24
|
+
const editor = useSlateStatic();
|
25
|
+
const path = ReactEditor.findPath(editor, element);
|
26
|
+
const {
|
27
|
+
readOnly
|
28
|
+
} = customProps;
|
29
|
+
const {
|
30
|
+
updated_at,
|
31
|
+
childType,
|
32
|
+
zIndex
|
33
|
+
} = element;
|
34
|
+
// get values based on breakpoint size
|
35
|
+
const {
|
36
|
+
gridArea,
|
37
|
+
width,
|
38
|
+
height,
|
39
|
+
left,
|
40
|
+
top,
|
41
|
+
marginTop
|
42
|
+
} = breakpointValues(element.type, breakpoint, element);
|
43
|
+
const {
|
44
|
+
setSelectedElement
|
45
|
+
} = useEditorContext();
|
46
|
+
const arrangeIndex = zIndex === undefined ? path[path.length - 1] : zIndex;
|
47
|
+
const onChangeSettings = () => {};
|
48
|
+
const onChange = data => {
|
49
|
+
let updateData = {
|
50
|
+
...data
|
51
|
+
};
|
52
|
+
delete updateData.children;
|
53
|
+
updateData = formatBreakpointValues(element.type, breakpoint, updateData);
|
54
|
+
Transforms.setNodes(editor, {
|
55
|
+
...updateData
|
56
|
+
}, {
|
57
|
+
at: path
|
58
|
+
});
|
59
|
+
};
|
60
|
+
const handleDragEvent = (type, data, cb) => {
|
61
|
+
const toPosition = {
|
62
|
+
left: left + data.lastX,
|
63
|
+
top: top + data.lastY
|
64
|
+
};
|
65
|
+
const {
|
66
|
+
node,
|
67
|
+
...rest
|
68
|
+
} = data;
|
69
|
+
switch (type) {
|
70
|
+
case "stop":
|
71
|
+
const updated_data = onDropItem({
|
72
|
+
editor,
|
73
|
+
fromPosition: {
|
74
|
+
left,
|
75
|
+
top
|
76
|
+
},
|
77
|
+
toPosition,
|
78
|
+
path,
|
79
|
+
ref: node,
|
80
|
+
breakpoint,
|
81
|
+
...rest
|
82
|
+
}, ".freegrid-container");
|
83
|
+
if (cb) {
|
84
|
+
cb(updated_data);
|
85
|
+
}
|
86
|
+
break;
|
87
|
+
default:
|
88
|
+
}
|
89
|
+
};
|
90
|
+
const handleResizeEvent = (type, data, cb) => {
|
91
|
+
switch (type) {
|
92
|
+
case "stop":
|
93
|
+
return;
|
94
|
+
default:
|
95
|
+
}
|
96
|
+
};
|
97
|
+
const onDelete = () => {
|
98
|
+
try {
|
99
|
+
Transforms.removeNodes(editor, {
|
100
|
+
at: path
|
101
|
+
});
|
102
|
+
} catch (err) {
|
103
|
+
console.log(err);
|
104
|
+
}
|
105
|
+
};
|
106
|
+
const handleContextMenuClick = d => {
|
107
|
+
switch (d?.name) {
|
108
|
+
case "bringForward":
|
109
|
+
bringItemToFB(editor, {
|
110
|
+
path,
|
111
|
+
moveFront: true
|
112
|
+
});
|
113
|
+
break;
|
114
|
+
case "bringBackward":
|
115
|
+
bringItemToFB(editor, {
|
116
|
+
path,
|
117
|
+
moveFront: false
|
118
|
+
});
|
119
|
+
break;
|
120
|
+
case "cut":
|
121
|
+
window.copiedNode = JSON.stringify(Node.get(editor, path));
|
122
|
+
onDelete();
|
123
|
+
focusOnNewItem(editor, Path.parent(path), {
|
124
|
+
setSelectedElement
|
125
|
+
});
|
126
|
+
break;
|
127
|
+
case "copy":
|
128
|
+
window.copiedNode = JSON.stringify(Node.get(editor, path));
|
129
|
+
break;
|
130
|
+
case "delete":
|
131
|
+
onDelete();
|
132
|
+
setSelectedElement({});
|
133
|
+
break;
|
134
|
+
default:
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
};
|
138
|
+
const handleActionClick = type => {
|
139
|
+
console.log(type);
|
140
|
+
};
|
141
|
+
return /*#__PURE__*/_jsx(RnD, {
|
142
|
+
id: `freegrid_item_${path.join("|")}_${updated_at}_${breakpoint}`,
|
143
|
+
className: `freegrid-item breakpoint-${breakpoint}`,
|
144
|
+
editor: editor,
|
145
|
+
path: path,
|
146
|
+
actions: itemOptions[childType] || itemOptions?.default,
|
147
|
+
settingsProps: {
|
148
|
+
settings: "freegridItem",
|
149
|
+
onChange: onChangeSettings,
|
150
|
+
customProps
|
151
|
+
},
|
152
|
+
style: {
|
153
|
+
"--left": `${left || 0}px`,
|
154
|
+
"--marginTop": `${marginTop || 0}px`,
|
155
|
+
"--gridArea": `${gridArea}`,
|
156
|
+
"--width": `${width}px`,
|
157
|
+
"--height": `${height}px`,
|
158
|
+
"--zIndex": 100 + arrangeIndex
|
159
|
+
},
|
160
|
+
defaultStyle: {
|
161
|
+
height: `${height}px`,
|
162
|
+
width: `${width}px`
|
163
|
+
},
|
164
|
+
gridArea: gridArea,
|
165
|
+
onChange: onChange,
|
166
|
+
delta: {
|
167
|
+
width,
|
168
|
+
height
|
169
|
+
},
|
170
|
+
handleDragEvent: handleDragEvent,
|
171
|
+
handleResizeEvent: handleResizeEvent,
|
172
|
+
readOnly: readOnly,
|
173
|
+
childType: childType || "",
|
174
|
+
handleContextMenuClick: handleContextMenuClick,
|
175
|
+
handleActionClick: handleActionClick,
|
176
|
+
children: /*#__PURE__*/_jsx(Box, {
|
177
|
+
component: "div",
|
178
|
+
...attributes,
|
179
|
+
className: `fgi_type_${childType}`,
|
180
|
+
children: children
|
181
|
+
})
|
182
|
+
});
|
183
|
+
};
|
184
|
+
export default FreeGridItem;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Box, List, ListItemButton } from "@mui/material";
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
4
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
5
|
+
const AddElement = props => {
|
6
|
+
const {
|
7
|
+
handleClick
|
8
|
+
} = props;
|
9
|
+
return /*#__PURE__*/_jsx(Box, {
|
10
|
+
children: /*#__PURE__*/_jsxs(List, {
|
11
|
+
className: "item-list-wrpr",
|
12
|
+
children: [/*#__PURE__*/_jsx(ListItemButton, {
|
13
|
+
className: "item-wrapper",
|
14
|
+
onClick: handleClick("addText"),
|
15
|
+
children: "Text"
|
16
|
+
}), /*#__PURE__*/_jsx(ListItemButton, {
|
17
|
+
className: "item-wrapper",
|
18
|
+
onClick: handleClick("addButton"),
|
19
|
+
children: "Button"
|
20
|
+
}), /*#__PURE__*/_jsx(ListItemButton, {
|
21
|
+
className: "item-wrapper",
|
22
|
+
onClick: handleClick("addImage"),
|
23
|
+
children: "Image"
|
24
|
+
}), /*#__PURE__*/_jsx(ListItemButton, {
|
25
|
+
className: "item-wrapper",
|
26
|
+
onClick: handleClick("addVideo"),
|
27
|
+
children: "Video"
|
28
|
+
}), /*#__PURE__*/_jsx(ListItemButton, {
|
29
|
+
className: "item-wrapper",
|
30
|
+
onClick: handleClick("addBox"),
|
31
|
+
children: "Box"
|
32
|
+
})]
|
33
|
+
})
|
34
|
+
});
|
35
|
+
};
|
36
|
+
export default AddElement;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Box, List, ListItemButton } from "@mui/material";
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
4
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
5
|
+
const More = props => {
|
6
|
+
const {
|
7
|
+
handleClick
|
8
|
+
} = props;
|
9
|
+
return /*#__PURE__*/_jsx(Box, {
|
10
|
+
children: /*#__PURE__*/_jsxs(List, {
|
11
|
+
className: "item-list-wrpr",
|
12
|
+
children: [/*#__PURE__*/_jsx(ListItemButton, {
|
13
|
+
className: "item-wrapper",
|
14
|
+
onClick: handleClick("addSection"),
|
15
|
+
children: "Add Section"
|
16
|
+
}), /*#__PURE__*/_jsx(ListItemButton, {
|
17
|
+
className: "item-wrapper",
|
18
|
+
onClick: handleClick("duplicateSection"),
|
19
|
+
children: "Duplicate Section"
|
20
|
+
})]
|
21
|
+
})
|
22
|
+
});
|
23
|
+
};
|
24
|
+
export default More;
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Transforms, Node } from "slate";
|
3
|
+
import { Box } from "@mui/material";
|
4
|
+
import { StyleContent } from "../../../common/StyleBuilder";
|
5
|
+
import sectionStyle from "../../../common/StyleBuilder/sectionStyle";
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
+
const SectionSettings = props => {
|
8
|
+
const {
|
9
|
+
editor,
|
10
|
+
path,
|
11
|
+
classes
|
12
|
+
} = props;
|
13
|
+
const element = Node.get(editor, path);
|
14
|
+
const styleMaps = sectionStyle?.filter(f => !f?.hideOnFGS);
|
15
|
+
const onChange = data => {
|
16
|
+
const updated_props = {
|
17
|
+
...element,
|
18
|
+
...data,
|
19
|
+
field_type: data?.element
|
20
|
+
};
|
21
|
+
delete updated_props.children;
|
22
|
+
Transforms.setNodes(editor, {
|
23
|
+
...updated_props
|
24
|
+
}, {
|
25
|
+
at: path
|
26
|
+
});
|
27
|
+
};
|
28
|
+
const handleClose = () => {
|
29
|
+
console.log("close");
|
30
|
+
};
|
31
|
+
return /*#__PURE__*/_jsx(Box, {
|
32
|
+
component: "div",
|
33
|
+
className: "style-settings-wrpr",
|
34
|
+
sx: classes.sectionSettingsPopper,
|
35
|
+
children: styleMaps?.map((m, i) => {
|
36
|
+
return /*#__PURE__*/_jsx(StyleContent, {
|
37
|
+
renderTabs: sectionStyle,
|
38
|
+
value: m.value,
|
39
|
+
element: element,
|
40
|
+
onChange: onChange,
|
41
|
+
customProps: {},
|
42
|
+
handleClose: handleClose
|
43
|
+
}, `tab_${m.value}_$${i}`);
|
44
|
+
})
|
45
|
+
});
|
46
|
+
};
|
47
|
+
export default SectionSettings;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
const commonOptions = ["drag", "edit", "settings", "close"];
|
2
|
+
const textOptions = ["drag", "edit", "settings", "link", "close"];
|
3
|
+
const buttonOptions = ["drag", "edit", "settings", "link", "close"];
|
4
|
+
const imageOptions = ["drag", "edit", "settings", "link", "close"];
|
5
|
+
const itemOptions = {
|
6
|
+
default: commonOptions,
|
7
|
+
text: textOptions,
|
8
|
+
button: buttonOptions,
|
9
|
+
image: imageOptions
|
10
|
+
};
|
11
|
+
export default itemOptions;
|
@@ -0,0 +1,75 @@
|
|
1
|
+
const breakpointConstants = {
|
2
|
+
freegrid: ["height"],
|
3
|
+
freegridItem: ["left", "top", "marginTop", "width", "height", "gridArea"],
|
4
|
+
freegridBox: ["left", "top", "marginTop", "width", "height", "gridArea"]
|
5
|
+
};
|
6
|
+
export function CssVar(device = "lg", key, props) {
|
7
|
+
const keyTo = `${key}_${device}`;
|
8
|
+
const value = props[keyTo] === undefined ? props[key] : props[keyTo];
|
9
|
+
return value;
|
10
|
+
}
|
11
|
+
export function breakpointValues(type, breakpoint = "lg", props) {
|
12
|
+
try {
|
13
|
+
const breakpointDatas = breakpointConstants[type]?.reduce((a, b) => {
|
14
|
+
const bpKey = `${b}_${breakpoint}`;
|
15
|
+
a[b] = props[bpKey] === undefined ? props[b] : props[bpKey];
|
16
|
+
return a;
|
17
|
+
}, {});
|
18
|
+
return breakpointDatas;
|
19
|
+
} catch (err) {
|
20
|
+
console.log(err);
|
21
|
+
return {};
|
22
|
+
}
|
23
|
+
}
|
24
|
+
export function formatBreakpointValues(type, breakpoint = "lg", data) {
|
25
|
+
try {
|
26
|
+
const bpValues = breakpointConstants[type];
|
27
|
+
if (breakpoint === "lg") {
|
28
|
+
return data;
|
29
|
+
} else {
|
30
|
+
let rtData = {};
|
31
|
+
Object.keys(data).forEach(key => {
|
32
|
+
if (bpValues.indexOf(key) > -1) {
|
33
|
+
rtData[`${key}_${breakpoint}`] = data[key];
|
34
|
+
} else {
|
35
|
+
rtData[key] = data[key];
|
36
|
+
}
|
37
|
+
});
|
38
|
+
return rtData;
|
39
|
+
}
|
40
|
+
} catch (err) {
|
41
|
+
console.log(err);
|
42
|
+
return {};
|
43
|
+
}
|
44
|
+
}
|
45
|
+
export function wrapThemeBreakpoints(sxProp, prop, theme) {
|
46
|
+
try {
|
47
|
+
const formatedSxProp = Object.keys(sxProp).reduce((a, b) => {
|
48
|
+
switch (b) {
|
49
|
+
case "md":
|
50
|
+
a[theme.breakpoints.up("lg")] = {
|
51
|
+
[prop]: sxProp["md"] || sxProp["lg"]
|
52
|
+
};
|
53
|
+
break;
|
54
|
+
case "sm":
|
55
|
+
a[theme.breakpoints.up("lg")] = {
|
56
|
+
[prop]: sxProp["sm"] || sxProp["lg"]
|
57
|
+
};
|
58
|
+
break;
|
59
|
+
case "xs":
|
60
|
+
a[theme.breakpoints.between("xs", "md")] = {
|
61
|
+
[prop]: sxProp["xs"] || sxProp["lg"]
|
62
|
+
};
|
63
|
+
break;
|
64
|
+
default:
|
65
|
+
a[theme.breakpoints.up("lg")] = {
|
66
|
+
[prop]: sxProp["lg"]
|
67
|
+
};
|
68
|
+
}
|
69
|
+
return a;
|
70
|
+
}, {});
|
71
|
+
return formatedSxProp;
|
72
|
+
} catch (err) {
|
73
|
+
console.log(err);
|
74
|
+
}
|
75
|
+
}
|