@flozy/editor 4.0.3 → 4.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CommonEditor.js +85 -13
- package/dist/Editor/DialogWrapper.js +4 -3
- package/dist/Editor/Editor.css +28 -2
- package/dist/Editor/Elements/AI/AIInput.js +31 -33
- package/dist/Editor/Elements/AI/CustomSelect.js +19 -12
- package/dist/Editor/Elements/AI/PopoverAIInput.js +119 -132
- package/dist/Editor/Elements/AI/Styles.js +2 -2
- package/dist/Editor/Elements/AI/VoiceToText/AudioWave.js +73 -0
- package/dist/Editor/Elements/AI/VoiceToText/index.js +184 -0
- package/dist/Editor/Elements/AI/VoiceToText/style.js +40 -0
- package/dist/Editor/Elements/AI/helper.js +5 -3
- package/dist/Editor/Elements/AppHeader/AppHeader.js +36 -23
- package/dist/Editor/Elements/Button/EditorButton.js +23 -16
- package/dist/Editor/Elements/Carousel/CarouselButton.js +2 -2
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +1 -1
- package/dist/Editor/Elements/Color Picker/Styles.js +1 -0
- 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/Form.js +43 -27
- package/dist/Editor/Elements/Form/FormField.js +21 -10
- package/dist/Editor/Elements/Form/Workflow/index.js +5 -2
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +437 -0
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +206 -0
- package/dist/Editor/Elements/FreeGrid/FreeGridButton.js +23 -0
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +236 -0
- package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +44 -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 +19 -0
- package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +75 -0
- package/dist/Editor/Elements/FreeGrid/styles.js +214 -0
- package/dist/Editor/Elements/Grid/Grid.js +12 -8
- package/dist/Editor/Elements/Grid/GridItem.js +31 -21
- package/dist/Editor/Elements/Link/LinkPopup.js +69 -13
- package/dist/Editor/Elements/Link/LinkPopupStyles.js +28 -0
- package/dist/Editor/Elements/NewLine/NewLineButton.js +2 -2
- package/dist/Editor/Elements/Signature/Signature.css +13 -6
- package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +2 -1
- package/dist/Editor/Elements/Signature/SignaturePopup.js +186 -31
- package/dist/Editor/Elements/SimpleText/index.js +19 -7
- package/dist/Editor/Elements/SimpleText/style.js +44 -1
- package/dist/Editor/ErrorBoundary.js +30 -0
- package/dist/Editor/Styles/EditorStyles.js +28 -0
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +1 -1
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +2 -2
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +33 -5
- package/dist/Editor/Toolbar/PopupTool/ButtonTemplatesCard.js +12 -13
- package/dist/Editor/Toolbar/PopupTool/FullViewCard.js +12 -13
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/CustomSelectTool.js +3 -0
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectSuperSubscript.js +59 -0
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +107 -40
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +57 -61
- package/dist/Editor/Toolbar/PopupTool/index.js +13 -3
- package/dist/Editor/Toolbar/Toolbar.js +7 -0
- package/dist/Editor/Toolbar/toolbarGroups.js +15 -5
- package/dist/Editor/assets/svg/AIIcons.js +153 -1
- package/dist/Editor/common/EditorCmds.js +0 -3
- package/dist/Editor/common/EditorIcons.js +7 -7
- package/dist/Editor/common/Icon.js +39 -30
- package/dist/Editor/common/ImageList.js +16 -3
- package/dist/Editor/common/ImageSelector/ImageSelector.js +30 -9
- package/dist/Editor/common/ImageSelector/Styles.js +2 -1
- package/dist/Editor/common/LinkSettings/index.js +2 -1
- package/dist/Editor/common/LinkSettings/style.js +11 -8
- package/dist/Editor/common/MentionsPopup/Styles.js +1 -1
- package/dist/Editor/common/MentionsPopup/index.js +12 -8
- package/dist/Editor/common/RnD/ContextMenu/CMenus.js +142 -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 +55 -0
- package/dist/Editor/common/RnD/DragOver/styles.js +23 -0
- package/dist/Editor/common/RnD/ElementOptions/Actions.js +102 -0
- package/dist/Editor/common/RnD/ElementOptions/Icons/LinkIcon.js +26 -0
- package/dist/Editor/common/RnD/ElementOptions/index.js +95 -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/SaveAsTemplate.js +36 -0
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +60 -0
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/index.js +9 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +47 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +47 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +47 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +48 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +47 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +30 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +47 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/index.js +17 -0
- package/dist/Editor/common/RnD/ElementSettings/index.js +17 -0
- package/dist/Editor/common/RnD/ElementSettings/settingsConstants.js +18 -0
- package/dist/Editor/common/RnD/ElementSettings/styles.js +94 -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 +62 -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 +20 -0
- package/dist/Editor/common/RnD/TransformHandles/index.js +67 -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 +181 -0
- package/dist/Editor/common/RnD/Utils/index.js +251 -0
- package/dist/Editor/common/RnD/VirtualElement/index.js +77 -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 +567 -0
- package/dist/Editor/common/RnD/styles.js +4 -0
- package/dist/Editor/common/Section/index.js +21 -12
- package/dist/Editor/common/Section/styles.js +7 -4
- package/dist/Editor/common/Shorthands/elements.js +21 -9
- package/dist/Editor/common/StyleBuilder/boxStyle.js +30 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +18 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/saveAsTemplate.js +18 -5
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +4 -2
- package/dist/Editor/common/StyleBuilder/index.js +6 -4
- package/dist/Editor/common/StyleBuilder/sectionStyle.js +13 -2
- package/dist/Editor/common/iconListV2.js +843 -0
- package/dist/Editor/commonStyle.js +6 -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 +50 -1
- package/dist/Editor/hooks/useBreakpoints.js +34 -0
- package/dist/Editor/hooks/useMouseMove.js +36 -8
- package/dist/Editor/hooks/useWindowMessage.js +10 -7
- package/dist/Editor/hooks/withCommon.js +2 -1
- package/dist/Editor/hooks/withErrorHandling.js +14 -0
- package/dist/Editor/utils/RnD/RnDCtrlCmds.js +197 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +36 -4
- package/dist/Editor/utils/events.js +5 -0
- package/dist/Editor/utils/form.js +7 -2
- package/dist/Editor/utils/formfield.js +1 -1
- package/dist/Editor/utils/freegrid.js +91 -0
- package/dist/Editor/utils/helper.js +43 -0
- package/dist/Editor/utils/insertAppHeader.js +47 -40
- package/package.json +6 -2
@@ -0,0 +1,251 @@
|
|
1
|
+
import { Transforms, Node } from "slate";
|
2
|
+
import { ReactEditor } from "slate-react";
|
3
|
+
import { getNearestItem } from "./calculateDropItem";
|
4
|
+
const GUIDE_LINE_THRESHOLD = 5;
|
5
|
+
const GUIDE_LINE_OVERLAP_THRESHOLD = 50;
|
6
|
+
const handleMoveNode = (editor, path, newPath, {
|
7
|
+
isEmpty
|
8
|
+
}) => {
|
9
|
+
try {
|
10
|
+
const replaceNode = Node.get(editor, path);
|
11
|
+
if (isEmpty) {
|
12
|
+
const toPath = [...newPath, 0];
|
13
|
+
Transforms.insertNodes(editor, [{
|
14
|
+
...replaceNode
|
15
|
+
}], {
|
16
|
+
at: toPath
|
17
|
+
});
|
18
|
+
Transforms.removeNodes(editor, {
|
19
|
+
at: path
|
20
|
+
});
|
21
|
+
return toPath;
|
22
|
+
} else {
|
23
|
+
Transforms.insertNodes(editor, [{
|
24
|
+
...replaceNode
|
25
|
+
}], {
|
26
|
+
at: newPath
|
27
|
+
});
|
28
|
+
Transforms.removeNodes(editor, {
|
29
|
+
at: path
|
30
|
+
});
|
31
|
+
return newPath;
|
32
|
+
}
|
33
|
+
} catch (err) {
|
34
|
+
console.log(err);
|
35
|
+
console.log("Drop Node error");
|
36
|
+
return null;
|
37
|
+
}
|
38
|
+
};
|
39
|
+
export function triggerClick(editor, path = []) {
|
40
|
+
try {
|
41
|
+
const triggerNode = Node.get(editor, path);
|
42
|
+
const triggerNodeDOM = ReactEditor.toDOMNode(editor, triggerNode);
|
43
|
+
triggerNodeDOM?.closest(".freegrid-item")?.click();
|
44
|
+
} catch (err) {
|
45
|
+
console.log(err);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
export function updatePositions(props, closestClass) {
|
49
|
+
try {
|
50
|
+
const {
|
51
|
+
editor,
|
52
|
+
path,
|
53
|
+
offsetY,
|
54
|
+
dragOver,
|
55
|
+
x,
|
56
|
+
y,
|
57
|
+
diffX,
|
58
|
+
parentPath
|
59
|
+
} = props;
|
60
|
+
const posY = y - offsetY;
|
61
|
+
const posX = parseInt(x - window.innerWidth / 2 + 490 - diffX);
|
62
|
+
let addToSectionDOMRect = null;
|
63
|
+
let newPath = [];
|
64
|
+
let toSectionNode = null;
|
65
|
+
const needMove = dragOver !== parentPath;
|
66
|
+
const moveTo = dragOver.split("|").map(m => parseInt(m));
|
67
|
+
const from = parentPath.split("|").map(m => parseInt(m));
|
68
|
+
newPath = moveTo;
|
69
|
+
toSectionNode = Node.get(editor, newPath);
|
70
|
+
const addToSectionDOM = ReactEditor.toDOMNode(editor, toSectionNode);
|
71
|
+
addToSectionDOMRect = addToSectionDOM?.getBoundingClientRect();
|
72
|
+
|
73
|
+
// update top and left properties
|
74
|
+
const newProperties = {};
|
75
|
+
newProperties.left = posX;
|
76
|
+
newProperties.marginTop = posY > addToSectionDOMRect.top ? posY - addToSectionDOMRect.top : addToSectionDOMRect.top - posY;
|
77
|
+
Transforms.setNodes(editor, newProperties, {
|
78
|
+
at: path
|
79
|
+
});
|
80
|
+
const returnData = {};
|
81
|
+
if (needMove) {
|
82
|
+
const isEmpty = toSectionNode?.children[0]?.type === undefined;
|
83
|
+
if (!isEmpty) {
|
84
|
+
newPath = [...newPath, toSectionNode?.children?.length];
|
85
|
+
}
|
86
|
+
newPath = newPath.map(m => parseInt(m));
|
87
|
+
const rPath = handleMoveNode(editor, path, newPath, {
|
88
|
+
isEmpty
|
89
|
+
});
|
90
|
+
// to update path index need to re-render items in parent sections
|
91
|
+
Transforms.setNodes(editor, {
|
92
|
+
updated_at: new Date().getTime
|
93
|
+
}, {
|
94
|
+
at: parentPath.split("|").map(m => parseInt(m))
|
95
|
+
});
|
96
|
+
returnData.updated_at = rPath;
|
97
|
+
}
|
98
|
+
returnData.updated_at = path;
|
99
|
+
if (needMove) {
|
100
|
+
getNearestItem(editor, moveTo, {
|
101
|
+
currentItem: path
|
102
|
+
});
|
103
|
+
} else {
|
104
|
+
getNearestItem(editor, from, {
|
105
|
+
currentItem: path
|
106
|
+
});
|
107
|
+
}
|
108
|
+
return returnData;
|
109
|
+
} catch (err) {
|
110
|
+
console.log(err);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
const isOverLapLine = ({
|
114
|
+
x,
|
115
|
+
y
|
116
|
+
}, lines) => {
|
117
|
+
return lines.find(f => Math.abs(f.x - x) <= GUIDE_LINE_OVERLAP_THRESHOLD || Math.abs(f.y - y) <= GUIDE_LINE_OVERLAP_THRESHOLD);
|
118
|
+
};
|
119
|
+
export function getClosestDraggable(x, y, className, activeClassName) {
|
120
|
+
const draggables = document.querySelectorAll(className);
|
121
|
+
const activeDragEle = document.querySelectorAll(activeClassName)[0];
|
122
|
+
const {
|
123
|
+
left: aLeft,
|
124
|
+
top: aTop,
|
125
|
+
width: aWidth,
|
126
|
+
height: aHeight
|
127
|
+
} = activeDragEle?.getBoundingClientRect() || {};
|
128
|
+
let lines = [];
|
129
|
+
draggables.forEach(draggable => {
|
130
|
+
const {
|
131
|
+
left,
|
132
|
+
top,
|
133
|
+
width,
|
134
|
+
height
|
135
|
+
} = draggable.getBoundingClientRect();
|
136
|
+
let xVal = 0;
|
137
|
+
let yVal = 0;
|
138
|
+
|
139
|
+
// top match
|
140
|
+
xVal = x < left ? aLeft : left;
|
141
|
+
yVal = top;
|
142
|
+
if (Math.abs(top - aTop) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
|
143
|
+
x: xVal,
|
144
|
+
y: yVal
|
145
|
+
}, lines)) {
|
146
|
+
lines.push({
|
147
|
+
y: top,
|
148
|
+
x: xVal,
|
149
|
+
width: x > left ? Math.abs(aLeft + aWidth - left) : Math.abs(aLeft - (left + width)),
|
150
|
+
height: 1
|
151
|
+
});
|
152
|
+
}
|
153
|
+
|
154
|
+
// bottom match
|
155
|
+
xVal = x < left ? aLeft : left;
|
156
|
+
yVal = top + height;
|
157
|
+
if (Math.abs(top + height - (aTop + aHeight)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
|
158
|
+
x: xVal,
|
159
|
+
y: yVal
|
160
|
+
}, lines)) {
|
161
|
+
lines.push({
|
162
|
+
y: yVal,
|
163
|
+
x: xVal,
|
164
|
+
width: x > left ? Math.abs(aLeft + aWidth - left) : Math.abs(aLeft - (left + width)),
|
165
|
+
height: 1
|
166
|
+
});
|
167
|
+
}
|
168
|
+
|
169
|
+
// center match
|
170
|
+
xVal = x < left ? aLeft : left;
|
171
|
+
yVal = top + height / 2;
|
172
|
+
if (Math.abs(top + height / 2 - (aTop + aHeight / 2)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
|
173
|
+
x: xVal,
|
174
|
+
y: yVal
|
175
|
+
}, lines, "y")) {
|
176
|
+
lines.push({
|
177
|
+
y: yVal,
|
178
|
+
x: xVal,
|
179
|
+
width: x > left ? Math.abs(aLeft + aWidth - left) : Math.abs(aLeft - (left + width)),
|
180
|
+
height: 1
|
181
|
+
});
|
182
|
+
}
|
183
|
+
|
184
|
+
// right match
|
185
|
+
xVal = left + width;
|
186
|
+
yVal = top < aTop ? top : aTop;
|
187
|
+
if ((Math.abs(left + width - aLeft) <= GUIDE_LINE_THRESHOLD || Math.abs(left - aLeft) <= GUIDE_LINE_THRESHOLD) && !isOverLapLine({
|
188
|
+
x: xVal,
|
189
|
+
y: yVal
|
190
|
+
}, lines)) {
|
191
|
+
lines.push({
|
192
|
+
y: yVal,
|
193
|
+
x: xVal,
|
194
|
+
width: 1,
|
195
|
+
height: Math.abs(aTop - top)
|
196
|
+
});
|
197
|
+
}
|
198
|
+
|
199
|
+
// left match
|
200
|
+
xVal = left;
|
201
|
+
yVal = top < aTop ? top : aTop;
|
202
|
+
if ((Math.abs(aLeft + aWidth - left) <= GUIDE_LINE_THRESHOLD || Math.abs(aLeft - left) <= GUIDE_LINE_THRESHOLD) && !isOverLapLine({
|
203
|
+
x: xVal,
|
204
|
+
y: yVal
|
205
|
+
}, lines)) {
|
206
|
+
lines.push({
|
207
|
+
y: yVal,
|
208
|
+
x: xVal,
|
209
|
+
width: 1,
|
210
|
+
height: Math.abs(aTop - top)
|
211
|
+
});
|
212
|
+
}
|
213
|
+
|
214
|
+
// middle match
|
215
|
+
xVal = left + width / 2;
|
216
|
+
yVal = top < aTop ? top : aTop;
|
217
|
+
if (Math.abs(aLeft + aWidth / 2 - (left + width / 2)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
|
218
|
+
x: xVal,
|
219
|
+
y: yVal
|
220
|
+
}, lines)) {
|
221
|
+
lines.push({
|
222
|
+
y: yVal,
|
223
|
+
x: xVal,
|
224
|
+
width: 1,
|
225
|
+
height: Math.abs(aTop - top)
|
226
|
+
});
|
227
|
+
}
|
228
|
+
});
|
229
|
+
return lines;
|
230
|
+
}
|
231
|
+
export function isDragOver(rect, mousePosition) {
|
232
|
+
const {
|
233
|
+
x,
|
234
|
+
y
|
235
|
+
} = mousePosition;
|
236
|
+
if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom) {
|
237
|
+
return true;
|
238
|
+
}
|
239
|
+
return false;
|
240
|
+
}
|
241
|
+
export function getParentSectionPath(props, closestClass) {
|
242
|
+
try {
|
243
|
+
const {
|
244
|
+
ref
|
245
|
+
} = props;
|
246
|
+
const parentDom = ref?.closest(closestClass);
|
247
|
+
return parentDom?.dataset?.path;
|
248
|
+
} catch (err) {
|
249
|
+
console.log(err);
|
250
|
+
}
|
251
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
2
|
+
import { Box } from "@mui/material";
|
3
|
+
import useVirtualElementStyles from "./styles";
|
4
|
+
import updateAutoProps from "./updateAutoProps";
|
5
|
+
import { calculateGridArea } from "../Utils/gridDropItem";
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
+
const ROOT_ITEM_CLASS = ".freegrid-item.path-3";
|
8
|
+
const VirtualElement = props => {
|
9
|
+
const classes = useVirtualElementStyles();
|
10
|
+
const {
|
11
|
+
editor,
|
12
|
+
path,
|
13
|
+
parentEle,
|
14
|
+
updated_at
|
15
|
+
} = props;
|
16
|
+
const cloneNode = parentEle?.cloneNode(true);
|
17
|
+
const virtualRef = useRef();
|
18
|
+
useEffect(() => {
|
19
|
+
if (virtualRef?.current) {
|
20
|
+
setTimeout(() => {
|
21
|
+
calculateProps();
|
22
|
+
}, 0);
|
23
|
+
}
|
24
|
+
}, [updated_at, virtualRef?.current]);
|
25
|
+
const calculateProps = () => {
|
26
|
+
const rect = virtualRef?.current?.getBoundingClientRect();
|
27
|
+
const sectionProps = {
|
28
|
+
path,
|
29
|
+
props: {
|
30
|
+
height: rect.height
|
31
|
+
}
|
32
|
+
};
|
33
|
+
const itemsData = [];
|
34
|
+
const items = virtualRef?.current?.querySelectorAll(ROOT_ITEM_CLASS);
|
35
|
+
let sectionHeight = 0;
|
36
|
+
for (let i = 0; i < items.length; i++) {
|
37
|
+
const itemRect = items[i]?.getBoundingClientRect();
|
38
|
+
const y = Math.abs(rect.top - itemRect?.top);
|
39
|
+
itemsData.push({
|
40
|
+
path: items[i]?.dataset.path,
|
41
|
+
props: {
|
42
|
+
top: y,
|
43
|
+
left: 24,
|
44
|
+
marginTop: 12,
|
45
|
+
width: itemRect?.width,
|
46
|
+
height: itemRect?.height,
|
47
|
+
gridArea: calculateGridArea(y)
|
48
|
+
}
|
49
|
+
});
|
50
|
+
sectionHeight += itemRect?.height;
|
51
|
+
}
|
52
|
+
if (sectionHeight > sectionProps?.props?.height) {
|
53
|
+
sectionProps.props.height = sectionHeight;
|
54
|
+
}
|
55
|
+
const allData = [sectionProps, itemsData]?.flat();
|
56
|
+
// it should trigger by auto alignment or on clicking mobile view change
|
57
|
+
updateAutoProps(editor, allData, "xs");
|
58
|
+
};
|
59
|
+
const getItems = () => {
|
60
|
+
const items = cloneNode?.querySelectorAll(ROOT_ITEM_CLASS) || [];
|
61
|
+
let itemsHTML = "";
|
62
|
+
for (let i = 0; i < items?.length; i++) {
|
63
|
+
items[i].classList.add("exclude-virtual");
|
64
|
+
itemsHTML += items[i].outerHTML;
|
65
|
+
}
|
66
|
+
return itemsHTML;
|
67
|
+
};
|
68
|
+
return /*#__PURE__*/_jsx(Box, {
|
69
|
+
className: "mobile-virtual-mode",
|
70
|
+
ref: virtualRef,
|
71
|
+
sx: classes.root,
|
72
|
+
dangerouslySetInnerHTML: {
|
73
|
+
__html: getItems()
|
74
|
+
}
|
75
|
+
});
|
76
|
+
};
|
77
|
+
export default VirtualElement;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
const useVirtualElementStyles = () => ({
|
2
|
+
root: {
|
3
|
+
width: "320px",
|
4
|
+
position: "fixed",
|
5
|
+
backgroundColor: "red",
|
6
|
+
height: "auto",
|
7
|
+
overflow: "visible",
|
8
|
+
pointerEvents: "none",
|
9
|
+
opacity: 0,
|
10
|
+
right: 0,
|
11
|
+
top: 0,
|
12
|
+
"& .freegrid-item": {
|
13
|
+
gridArea: "none !important",
|
14
|
+
width: "calc(100% - 48px) !important",
|
15
|
+
height: "auto !important",
|
16
|
+
left: "24px !important",
|
17
|
+
marginTop: "24px !important",
|
18
|
+
"& .debug-info, & .editor-blocker": {
|
19
|
+
display: "none"
|
20
|
+
},
|
21
|
+
"& .embed": {
|
22
|
+
minHeight: "300px"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
});
|
27
|
+
export default useVirtualElementStyles;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Node, Transforms } from "slate";
|
2
|
+
const updateAutoProps = (editor, datas = [], breakpoint = "") => {
|
3
|
+
try {
|
4
|
+
for (let i = 0; i < datas.length; i++) {
|
5
|
+
const {
|
6
|
+
path,
|
7
|
+
props
|
8
|
+
} = datas[i] || {};
|
9
|
+
const int_path = path.split("|").map(m => parseInt(m));
|
10
|
+
const updatedProps = Object.keys(props).reduce((a, b) => {
|
11
|
+
const key = breakpoint ? `${b}_${breakpoint}` : b;
|
12
|
+
a[key] = props[b];
|
13
|
+
return a;
|
14
|
+
}, {});
|
15
|
+
const oldProps = Node.get(editor, int_path);
|
16
|
+
if (!oldProps?.xs_updatedOn) {
|
17
|
+
Transforms.setNodes(editor, {
|
18
|
+
...updatedProps
|
19
|
+
}, {
|
20
|
+
at: int_path
|
21
|
+
});
|
22
|
+
}
|
23
|
+
}
|
24
|
+
} catch (err) {
|
25
|
+
console.log(err);
|
26
|
+
}
|
27
|
+
};
|
28
|
+
export default updateAutoProps;
|