@flozy/editor 1.5.9 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CommonEditor.js +195 -94
- package/dist/Editor/DialogWrapper.js +3 -0
- package/dist/Editor/Editor.css +211 -50
- package/dist/Editor/Elements/Accordion/Accordion.js +0 -1
- package/dist/Editor/Elements/Accordion/AccordionButton.js +13 -12
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +0 -1
- package/dist/Editor/Elements/AppHeader/AppHeader.js +136 -133
- package/dist/Editor/Elements/AppHeader/AppHeaderPopup.js +4 -2
- package/dist/Editor/Elements/Button/ButtonToolIcon.js +10 -9
- package/dist/Editor/Elements/Button/EditorButton.js +8 -24
- package/dist/Editor/Elements/Carousel/Carousel.js +47 -28
- package/dist/Editor/Elements/Carousel/CarouselButton.js +7 -8
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +133 -0
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +49 -58
- package/dist/Editor/Elements/Color Picker/Styles.js +51 -0
- package/dist/Editor/Elements/Color Picker/defaultColors.js +1 -1
- package/dist/Editor/Elements/Embed/Embed.js +35 -126
- package/dist/Editor/Elements/Embed/Image.js +24 -7
- package/dist/Editor/Elements/Embed/Video.js +21 -6
- package/dist/Editor/Elements/Emoji/EmojiButton.js +73 -0
- package/dist/Editor/Elements/Emoji/EmojiPicker.js +0 -0
- package/dist/Editor/Elements/Form/Form.js +24 -13
- package/dist/Editor/Elements/Form/FormButton.js +11 -9
- package/dist/Editor/Elements/Form/FormElements/FormText.js +4 -2
- package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +3 -2
- package/dist/Editor/Elements/Form/FormField.js +7 -1
- package/dist/Editor/Elements/Grid/Grid.js +143 -47
- package/dist/Editor/Elements/Grid/GridButton.js +52 -29
- package/dist/Editor/Elements/Grid/GridItem.js +32 -21
- package/dist/Editor/Elements/Grid/Styles.js +11 -0
- package/dist/Editor/Elements/InlineIcon/InlineIcon.js +0 -1
- package/dist/Editor/Elements/List/CheckList.js +57 -0
- package/dist/Editor/Elements/List/CheckListButton.js +24 -0
- package/dist/Editor/Elements/NewLine/NewLineButton.js +14 -14
- package/dist/Editor/Elements/PageSettings/PageSettings.js +4 -2
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +17 -62
- package/dist/Editor/Elements/PageSettings/PageSettingsPopup.js +1 -1
- package/dist/Editor/Elements/Signature/Signature.js +9 -3
- package/dist/Editor/Elements/Signature/SignatureButton.js +10 -9
- package/dist/Editor/Elements/Signature/SignaturePopup.js +42 -6
- package/dist/Editor/Elements/SimpleText.js +62 -0
- package/dist/Editor/Elements/Table/Styles.js +66 -0
- package/dist/Editor/Elements/Table/Table.js +33 -16
- package/dist/Editor/Elements/Table/TableCell.js +54 -24
- package/dist/Editor/Elements/Table/TableSelector.js +13 -15
- package/dist/Editor/Elements/Table/table.css +0 -10
- package/dist/Editor/Elements/TopBanner/Styles.js +33 -0
- package/dist/Editor/Elements/TopBanner/TopBanner.js +106 -0
- package/dist/Editor/Elements/TopBanner/TopBannerButton.js +47 -0
- package/dist/Editor/Styles/EditorStyles.js +50 -0
- package/dist/Editor/Toolbar/FormatTools/Autocomplete.js +0 -2
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +8 -3
- package/dist/Editor/Toolbar/FormatTools/FontFamilyDropdown.js +63 -0
- package/dist/Editor/Toolbar/FormatTools/FontSize.js +112 -0
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +13 -3
- package/dist/Editor/Toolbar/FormatTools/index.js +4 -1
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +101 -0
- package/dist/Editor/Toolbar/Mini/Options/Options.js +17 -0
- package/dist/Editor/Toolbar/Mini/Styles.js +30 -0
- package/dist/Editor/Toolbar/PopupTool/AddElements.js +32 -0
- package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +115 -0
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +65 -0
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +160 -6
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +263 -80
- package/dist/Editor/Toolbar/PopupTool/index.js +50 -85
- package/dist/Editor/Toolbar/Toolbar.js +189 -129
- package/dist/Editor/Toolbar/styles.css +136 -18
- package/dist/Editor/Toolbar/toolbarGroups.js +94 -34
- package/dist/Editor/assets/svg/AddElementIcon.js +29 -0
- package/dist/Editor/assets/svg/AddTemplateIcon.js +29 -0
- package/dist/Editor/assets/svg/TextIcon.js +29 -0
- package/dist/Editor/common/Icon.js +54 -5
- package/dist/Editor/common/ImageList.js +75 -0
- package/dist/Editor/common/ImageSelector/ImageSelector.js +117 -0
- package/dist/Editor/common/ImageSelector/Options/AddLink.js +44 -0
- package/dist/Editor/common/ImageSelector/Options/ChooseAssets.js +39 -0
- package/dist/Editor/common/ImageSelector/Options/Upload.js +30 -0
- package/dist/Editor/common/ImageSelector/Styles.js +41 -0
- package/dist/Editor/common/ImageUploader.js +94 -0
- package/dist/Editor/common/MentionsPopup/ElementsListCard.js +66 -0
- package/dist/Editor/common/MentionsPopup/MentionsListCard.js +70 -0
- package/dist/Editor/common/MentionsPopup/Styles.js +68 -0
- package/dist/Editor/common/MentionsPopup/index.js +129 -0
- package/dist/Editor/common/Shorthands/elements.js +191 -0
- package/dist/Editor/common/Shorthands/index.js +7 -0
- package/dist/Editor/common/Shorthands/mentions.js +8 -0
- package/dist/Editor/common/StyleBuilder/appHeaderStyle.js +5 -5
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +1 -1
- package/dist/Editor/common/StyleBuilder/embedImageStyle.js +15 -2
- package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +8 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/alignment.js +2 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +23 -35
- package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +3 -20
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +95 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +14 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +0 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +3 -2
- package/dist/Editor/common/StyleBuilder/index.js +0 -1
- package/dist/Editor/common/StyleBuilder/tableStyle.js +9 -5
- package/dist/Editor/common/ToolbarIcon.js +43 -0
- package/dist/Editor/common/Uploader.js +35 -61
- package/dist/Editor/common/iconslist.js +46 -1
- package/dist/Editor/helper/index.js +0 -1
- package/dist/Editor/hooks/useDrag.js +2 -2
- package/dist/Editor/hooks/useMentions.js +104 -17
- package/dist/Editor/hooks/useMouseMove.js +53 -0
- package/dist/Editor/hooks/useScroll.js +26 -0
- package/dist/Editor/plugins/withEmbeds.js +12 -0
- package/dist/Editor/service/fileupload.js +2 -2
- package/dist/Editor/utils/SlateUtilityFunctions.js +61 -9
- package/dist/Editor/utils/button.js +2 -1
- package/dist/Editor/utils/carousel.js +5 -2
- package/dist/Editor/utils/carouselItem.js +2 -2
- package/dist/Editor/utils/customHooks/useResize.js +2 -3
- package/dist/Editor/utils/customHooks/useTableResize.js +2 -1
- package/dist/Editor/utils/embed.js +25 -8
- package/dist/Editor/utils/emoji.js +8 -0
- package/dist/Editor/utils/events.js +49 -12
- package/dist/Editor/utils/form.js +3 -9
- package/dist/Editor/utils/formfield.js +2 -1
- package/dist/Editor/utils/grid.js +44 -8
- package/dist/Editor/utils/gridItem.js +4 -3
- package/dist/Editor/utils/insertNewLine.js +12 -0
- package/dist/Editor/utils/mentions.js +14 -10
- package/dist/Editor/utils/pageSettings.js +67 -0
- package/dist/Editor/utils/signature.js +6 -8
- package/dist/Editor/utils/table.js +79 -18
- package/dist/Editor/utils/topBanner.js +58 -0
- package/package.json +6 -2
- package/dist/Editor/common/MentionsPopup.js +0 -56
@@ -18,7 +18,9 @@ const Video = ({
|
|
18
18
|
}) => {
|
19
19
|
const {
|
20
20
|
url,
|
21
|
-
alt
|
21
|
+
alt,
|
22
|
+
alignment,
|
23
|
+
bannerSpacing
|
22
24
|
} = element;
|
23
25
|
const editor = useSlateStatic();
|
24
26
|
const selected = useSelected();
|
@@ -28,6 +30,14 @@ const Video = ({
|
|
28
30
|
const {
|
29
31
|
readOnly
|
30
32
|
} = customProps;
|
33
|
+
const {
|
34
|
+
vertical,
|
35
|
+
horizantal
|
36
|
+
} = alignment || {};
|
37
|
+
const {
|
38
|
+
left,
|
39
|
+
right
|
40
|
+
} = bannerSpacing || {};
|
31
41
|
const [size, onMouseDown, resizing, onLoad] = useResize({
|
32
42
|
parentDOM,
|
33
43
|
size: element?.size
|
@@ -93,14 +103,17 @@ const Video = ({
|
|
93
103
|
at: path
|
94
104
|
});
|
95
105
|
};
|
106
|
+
const totalMinus = parseInt(left || 0) + parseInt(right || 0);
|
107
|
+
const width = resizing ? `${size.width}px` : `${size.widthInPercent}%`;
|
96
108
|
return /*#__PURE__*/_jsxs("div", {
|
97
109
|
...attributes,
|
98
110
|
className: "embed has-hover",
|
99
111
|
style: {
|
100
112
|
display: "flex",
|
101
|
-
width:
|
102
|
-
|
103
|
-
|
113
|
+
width: `calc(100% - ${totalMinus}px)`,
|
114
|
+
boxShadow: selected && focused && "0 0 3px 3px lightgray",
|
115
|
+
justifyContent: horizantal,
|
116
|
+
alignContent: vertical
|
104
117
|
},
|
105
118
|
...element.attr,
|
106
119
|
children: [openSetttings ? /*#__PURE__*/_jsx(EmbedPopup, {
|
@@ -114,7 +127,7 @@ const Video = ({
|
|
114
127
|
contentEditable: false,
|
115
128
|
style: {
|
116
129
|
position: "relative",
|
117
|
-
width:
|
130
|
+
width: `${width}`,
|
118
131
|
height: `${size.height}px`
|
119
132
|
},
|
120
133
|
children: [!readOnly && /*#__PURE__*/_jsx(ToolBar, {}),
|
@@ -136,8 +149,10 @@ const Video = ({
|
|
136
149
|
className: "embedd-iframe",
|
137
150
|
style: {
|
138
151
|
border: "none",
|
152
|
+
position: "absolute",
|
139
153
|
width: "100%",
|
140
|
-
height: "100%"
|
154
|
+
height: "100%",
|
155
|
+
left: "0px"
|
141
156
|
},
|
142
157
|
src: url,
|
143
158
|
title: alt
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import React, { useState, forwardRef, useImperativeHandle } from "react";
|
2
|
+
import { useSlateStatic, ReactEditor } from "slate-react";
|
3
|
+
import { Paper, Popover } from "@mui/material";
|
4
|
+
import data from "@emoji-mart/data";
|
5
|
+
import Picker from "@emoji-mart/react";
|
6
|
+
import { insertEmoji } from "../../utils/emoji";
|
7
|
+
import ToolbarIcon from "../../common/ToolbarIcon";
|
8
|
+
import Icon from "../../common/Icon";
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
12
|
+
const EmojiButton = /*#__PURE__*/forwardRef((props, ref) => {
|
13
|
+
const {
|
14
|
+
icoBtnType,
|
15
|
+
selectionTarget
|
16
|
+
} = props;
|
17
|
+
const editor = useSlateStatic();
|
18
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
19
|
+
const [target, setTarget] = useState(selectionTarget);
|
20
|
+
const open = Boolean(anchorEl);
|
21
|
+
useImperativeHandle(ref, () => ({
|
22
|
+
triggerClick: target => {
|
23
|
+
setTarget(target);
|
24
|
+
onClick();
|
25
|
+
}
|
26
|
+
}));
|
27
|
+
const onClick = () => {
|
28
|
+
if (editor.selection) {
|
29
|
+
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
30
|
+
const rect = domRange.getBoundingClientRect();
|
31
|
+
setAnchorEl({
|
32
|
+
getBoundingClientRect: () => rect,
|
33
|
+
nodeType: 1
|
34
|
+
});
|
35
|
+
}
|
36
|
+
};
|
37
|
+
const onEmojiSelect = emoji => {
|
38
|
+
insertEmoji(editor, emoji?.native, target || editor.selection);
|
39
|
+
setAnchorEl(null);
|
40
|
+
};
|
41
|
+
const handleClose = () => {
|
42
|
+
setAnchorEl(null);
|
43
|
+
};
|
44
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
45
|
+
children: [/*#__PURE__*/_jsx(ToolbarIcon, {
|
46
|
+
title: "Emoji",
|
47
|
+
onClick: onClick,
|
48
|
+
icon: /*#__PURE__*/_jsx(Icon, {
|
49
|
+
icon: "emoji"
|
50
|
+
}),
|
51
|
+
icoBtnType: icoBtnType
|
52
|
+
}), /*#__PURE__*/_jsx(Popover, {
|
53
|
+
style: {
|
54
|
+
zIndex: 10001
|
55
|
+
},
|
56
|
+
open: open,
|
57
|
+
anchorEl: anchorEl,
|
58
|
+
anchorOrigin: {
|
59
|
+
vertical: "bottom",
|
60
|
+
horizontal: "left"
|
61
|
+
},
|
62
|
+
onClose: handleClose,
|
63
|
+
children: /*#__PURE__*/_jsx(Paper, {
|
64
|
+
children: /*#__PURE__*/_jsx(Picker, {
|
65
|
+
data: data,
|
66
|
+
onEmojiSelect: onEmojiSelect
|
67
|
+
})
|
68
|
+
})
|
69
|
+
})]
|
70
|
+
});
|
71
|
+
});
|
72
|
+
EmojiButton.displayName = "EmojiButton";
|
73
|
+
export default EmojiButton;
|
File without changes
|
@@ -3,9 +3,8 @@ import { Transforms } from "slate";
|
|
3
3
|
import { useSlateStatic, ReactEditor } from "slate-react";
|
4
4
|
import { IconButton, Tooltip, Grid, Menu, MenuItem, CircularProgress } from "@mui/material";
|
5
5
|
import DeleteIcon from "@mui/icons-material/Delete";
|
6
|
-
import SettingsIcon from "@mui/icons-material/Settings";
|
7
|
-
import AddIcon from "@mui/icons-material/Add";
|
8
6
|
import BackupIcon from "@mui/icons-material/Backup";
|
7
|
+
import { GridSettingsIcon, GridAddSectionIcon } from "../../common/iconslist";
|
9
8
|
import FormPopup from "./FormPopup";
|
10
9
|
import ButtonPopup from "../Button/ButtonPopup";
|
11
10
|
import { formField } from "../../utils/formfield";
|
@@ -61,6 +60,7 @@ const Form = props => {
|
|
61
60
|
const [editButton, setEditButton] = useState(false);
|
62
61
|
const [anchorEl, setAnchorEl] = useState(null);
|
63
62
|
const [loading, setLoading] = useState(false);
|
63
|
+
const [showOptions, setShowOptions] = useState(false);
|
64
64
|
const path = ReactEditor.findPath(editor, element);
|
65
65
|
const btnBorderStyle = buttonProps?.borderColor?.indexOf("linear") >= 0 ? {
|
66
66
|
borderImageSource: buttonProps?.borderColor,
|
@@ -170,33 +170,42 @@ const Form = props => {
|
|
170
170
|
setAnchorEl(e.currentTarget);
|
171
171
|
}
|
172
172
|
};
|
173
|
+
const onMouseOver = () => {
|
174
|
+
setShowOptions(true);
|
175
|
+
};
|
176
|
+
const onMouseLeave = () => {
|
177
|
+
setShowOptions(false);
|
178
|
+
};
|
173
179
|
const FormToolbar = () => {
|
174
180
|
return /*#__PURE__*/_jsxs("div", {
|
175
|
-
className: "",
|
181
|
+
className: "element-toolbar hr",
|
176
182
|
contentEditable: false,
|
177
183
|
style: {
|
178
|
-
|
179
|
-
|
184
|
+
top: "-42px",
|
185
|
+
left: "0px"
|
180
186
|
},
|
181
187
|
children: [/*#__PURE__*/_jsx(Tooltip, {
|
182
188
|
title: "Form Settings",
|
183
189
|
arrow: true,
|
184
190
|
children: /*#__PURE__*/_jsx(IconButton, {
|
185
191
|
onClick: onSettings,
|
186
|
-
|
192
|
+
className: "mr",
|
193
|
+
children: /*#__PURE__*/_jsx(GridSettingsIcon, {})
|
187
194
|
})
|
188
195
|
}), /*#__PURE__*/_jsx(Tooltip, {
|
189
196
|
title: "Add Form Field",
|
190
197
|
arrow: true,
|
191
198
|
children: /*#__PURE__*/_jsx(IconButton, {
|
192
199
|
onClick: onAddFormField,
|
193
|
-
|
200
|
+
className: "mr",
|
201
|
+
children: /*#__PURE__*/_jsx(GridAddSectionIcon, {})
|
194
202
|
})
|
195
203
|
}), /*#__PURE__*/_jsx(Tooltip, {
|
196
204
|
title: "Delete Form",
|
197
205
|
arrow: true,
|
198
206
|
children: /*#__PURE__*/_jsx(IconButton, {
|
199
207
|
onClick: onDelete,
|
208
|
+
className: "mr",
|
200
209
|
children: /*#__PURE__*/_jsx(DeleteIcon, {})
|
201
210
|
})
|
202
211
|
})]
|
@@ -206,10 +215,12 @@ const Form = props => {
|
|
206
215
|
...attributes,
|
207
216
|
className: "form-wrapper element-root",
|
208
217
|
style: {
|
209
|
-
border: !readOnly ? "
|
218
|
+
border: !readOnly ? "none" : "none",
|
210
219
|
padding: "10px"
|
211
220
|
},
|
212
|
-
|
221
|
+
onMouseOver: onMouseOver,
|
222
|
+
onMouseLeave: onMouseLeave,
|
223
|
+
children: [/*#__PURE__*/_jsxs("form", {
|
213
224
|
id: `${formName}`,
|
214
225
|
onSubmit: handleSubmit,
|
215
226
|
style: {
|
@@ -222,14 +233,14 @@ const Form = props => {
|
|
222
233
|
paddingLeft: `${left}px`,
|
223
234
|
paddingRight: `${right}px`,
|
224
235
|
paddingTop: `${top}px`,
|
225
|
-
paddingBottom: `${bottom}px
|
236
|
+
paddingBottom: `${bottom}px`,
|
237
|
+
position: "relative"
|
226
238
|
},
|
227
239
|
ref: formEle,
|
228
240
|
children: [/*#__PURE__*/_jsx(Grid, {
|
229
241
|
className: "form-grid",
|
230
242
|
item: true,
|
231
243
|
xs: 12,
|
232
|
-
spacing: 2,
|
233
244
|
children: /*#__PURE__*/_jsxs(Grid, {
|
234
245
|
container: true,
|
235
246
|
spacing: 2,
|
@@ -278,7 +289,7 @@ const Form = props => {
|
|
278
289
|
})
|
279
290
|
})]
|
280
291
|
})
|
281
|
-
}), loading && /*#__PURE__*/_jsx("div", {
|
292
|
+
}), !readOnly && showOptions && /*#__PURE__*/_jsx(FormToolbar, {}), loading && /*#__PURE__*/_jsx("div", {
|
282
293
|
style: {
|
283
294
|
position: "absolute",
|
284
295
|
top: 0,
|
@@ -314,7 +325,7 @@ const Form = props => {
|
|
314
325
|
title: "Button Settings",
|
315
326
|
arrow: true,
|
316
327
|
children: /*#__PURE__*/_jsx(IconButton, {
|
317
|
-
children: /*#__PURE__*/_jsx(
|
328
|
+
children: /*#__PURE__*/_jsx(GridSettingsIcon, {})
|
318
329
|
})
|
319
330
|
})
|
320
331
|
}), /*#__PURE__*/_jsx(MenuItem, {
|
@@ -1,21 +1,23 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { useSlateStatic } from "slate-react";
|
3
|
-
import { IconButton, Tooltip } from "@mui/material";
|
4
|
-
import { FormIcon } from "../../common/iconslist";
|
5
3
|
import { insertForm } from "../../utils/form";
|
4
|
+
import ToolbarIcon from "../../common/ToolbarIcon";
|
5
|
+
import Icon from "../../common/Icon";
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
-
const FormButton =
|
7
|
+
const FormButton = ({
|
8
|
+
icoBtnType
|
9
|
+
}) => {
|
8
10
|
const editor = useSlateStatic();
|
9
11
|
const onClick = () => {
|
10
12
|
insertForm(editor);
|
11
13
|
};
|
12
|
-
return /*#__PURE__*/_jsx(
|
14
|
+
return /*#__PURE__*/_jsx(ToolbarIcon, {
|
13
15
|
title: "Form",
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
onClick: onClick,
|
17
|
+
icon: /*#__PURE__*/_jsx(Icon, {
|
18
|
+
icon: "form"
|
19
|
+
}),
|
20
|
+
icoBtnType: icoBtnType
|
19
21
|
});
|
20
22
|
};
|
21
23
|
export default FormButton;
|
@@ -12,7 +12,9 @@ const FormText = props => {
|
|
12
12
|
borderWidth,
|
13
13
|
borderColor,
|
14
14
|
textColor,
|
15
|
-
bgColor
|
15
|
+
bgColor,
|
16
|
+
lockSpacing,
|
17
|
+
...rest
|
16
18
|
} = fieldProps;
|
17
19
|
const {
|
18
20
|
left,
|
@@ -36,7 +38,7 @@ const FormText = props => {
|
|
36
38
|
},
|
37
39
|
contentEditable: false,
|
38
40
|
children: /*#__PURE__*/_jsx("input", {
|
39
|
-
...
|
41
|
+
...rest,
|
40
42
|
onChange: onChange,
|
41
43
|
style: {
|
42
44
|
width: "100%",
|
@@ -12,7 +12,8 @@ const FormTextArea = props => {
|
|
12
12
|
borderWidth,
|
13
13
|
borderColor,
|
14
14
|
textColor,
|
15
|
-
bgColor
|
15
|
+
bgColor,
|
16
|
+
...rest
|
16
17
|
} = fieldProps;
|
17
18
|
const {
|
18
19
|
left,
|
@@ -36,7 +37,7 @@ const FormTextArea = props => {
|
|
36
37
|
},
|
37
38
|
contentEditable: false,
|
38
39
|
children: /*#__PURE__*/_jsx("textarea", {
|
39
|
-
...
|
40
|
+
...rest,
|
40
41
|
onChange: onChange,
|
41
42
|
style: {
|
42
43
|
width: "100%",
|
@@ -12,6 +12,7 @@ const FormField = props => {
|
|
12
12
|
const {
|
13
13
|
attributes,
|
14
14
|
element,
|
15
|
+
children: rootChildren,
|
15
16
|
customProps
|
16
17
|
} = props;
|
17
18
|
const {
|
@@ -94,7 +95,12 @@ const FormField = props => {
|
|
94
95
|
element: element,
|
95
96
|
onSave: onSave,
|
96
97
|
onClose: onClose
|
97
|
-
}) : null
|
98
|
+
}) : null, /*#__PURE__*/_jsx("span", {
|
99
|
+
style: {
|
100
|
+
display: "none"
|
101
|
+
},
|
102
|
+
children: rootChildren
|
103
|
+
})]
|
98
104
|
});
|
99
105
|
};
|
100
106
|
export default FormField;
|
@@ -1,15 +1,20 @@
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
1
2
|
import React, { useState, useEffect } from "react";
|
2
3
|
import { Transforms, Path, Node } from "slate";
|
3
4
|
import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
|
4
5
|
import { gridItem } from "../../utils/gridItem";
|
5
6
|
import GridPopup from "./GridPopup";
|
6
|
-
import { IconButton, Tooltip } from "@mui/material";
|
7
|
-
// import CompressIcon from "@mui/icons-material/Compress";
|
7
|
+
import { IconButton, Tooltip, Grid as GridContainer } from "@mui/material";
|
8
8
|
import { insertGrid } from "../../utils/grid";
|
9
|
-
import useDragAndDrop from "../../common/useDragAndDrop";
|
9
|
+
// import useDragAndDrop from "../../common/useDragAndDrop";
|
10
10
|
import useResize from "../../utils/customHooks/useResize";
|
11
11
|
import { GridAddGridIcon, GridAddSectionIcon, GridSettingsIcon } from "../../common/iconslist";
|
12
|
+
import ArrowUpwardIcon from "@mui/icons-material/ArrowUpward";
|
13
|
+
import ArrowDownwardIcon from "@mui/icons-material/ArrowDownward";
|
14
|
+
import KeyboardReturnIcon from "@mui/icons-material/KeyboardReturn";
|
15
|
+
import { useEditorContext } from "../../hooks/useMouseMove";
|
12
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
17
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
13
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
14
19
|
const Grid = props => {
|
15
20
|
const {
|
@@ -29,7 +34,7 @@ const Grid = props => {
|
|
29
34
|
bgColor,
|
30
35
|
alignment,
|
31
36
|
backgroundImage,
|
32
|
-
size: elSize,
|
37
|
+
// size: elSize,
|
33
38
|
fgColor,
|
34
39
|
borderWidth,
|
35
40
|
borderColor,
|
@@ -53,23 +58,24 @@ const Grid = props => {
|
|
53
58
|
bottomLeft,
|
54
59
|
bottomRight
|
55
60
|
} = borderRadius || {};
|
56
|
-
const {
|
57
|
-
height: elHeight
|
58
|
-
} = elSize || {};
|
61
|
+
// const { height: elHeight } = elSize || {};
|
59
62
|
const editor = useSlateStatic();
|
60
|
-
const selected = useSelected();
|
63
|
+
// const selected = useSelected();
|
61
64
|
// const [selected, setSelected] = useState(false);
|
62
65
|
const path = ReactEditor.findPath(editor, element);
|
63
66
|
const [parentDOM, setParentDOM] = useState(null);
|
64
|
-
|
65
67
|
// resize
|
66
|
-
const [size
|
68
|
+
const [size,, resizing, onLoad] = useResize({
|
67
69
|
parentDOM,
|
68
70
|
size: element?.size,
|
69
71
|
isGrid: true
|
70
72
|
});
|
71
73
|
const arr = Array.from(Node.elements(editor));
|
72
74
|
const ele = arr.find(([elem]) => element === elem);
|
75
|
+
const {
|
76
|
+
hoverPath
|
77
|
+
} = useEditorContext();
|
78
|
+
const selected = hoverPath === path.join(",");
|
73
79
|
useEffect(() => {
|
74
80
|
if (editor && ele[1] !== undefined) {
|
75
81
|
const dom = ReactEditor.toDOMNode(editor, Node.get(editor, ele[1]));
|
@@ -154,49 +160,115 @@ const Grid = props => {
|
|
154
160
|
console.log(err);
|
155
161
|
}
|
156
162
|
};
|
157
|
-
const
|
163
|
+
const onMoveSection = direction => e => {
|
158
164
|
try {
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
165
|
+
e.preventDefault();
|
166
|
+
e.stopPropagation();
|
167
|
+
if (direction) {
|
168
|
+
let moveTo = direction === "up" ? path[0] - 1 : path[0] + 1;
|
169
|
+
if (moveTo < 0) {
|
170
|
+
moveTo = 0;
|
171
|
+
} else if (moveTo > editor.children.length - 1) {
|
172
|
+
moveTo = editor.children.length - 1;
|
173
|
+
}
|
174
|
+
Transforms.moveNodes(editor, {
|
175
|
+
at: [path[0]],
|
176
|
+
to: [moveTo]
|
177
|
+
});
|
178
|
+
}
|
163
179
|
} catch (err) {
|
164
180
|
console.log(err);
|
165
181
|
}
|
166
182
|
};
|
167
|
-
const
|
183
|
+
const onNewLine = direction => () => {
|
168
184
|
try {
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
185
|
+
if (direction) {
|
186
|
+
let moveTo = direction === "up" ? path[0] - 1 : path[0] + 1;
|
187
|
+
let lastLine = false;
|
188
|
+
if (moveTo < 0) {
|
189
|
+
moveTo = 0;
|
190
|
+
} else if (moveTo > editor.children.length - 1) {
|
191
|
+
moveTo = editor.children.length;
|
192
|
+
lastLine = true;
|
193
|
+
}
|
194
|
+
Transforms.insertNodes(editor, {
|
195
|
+
type: "paragraph",
|
196
|
+
children: [{
|
197
|
+
text: ""
|
198
|
+
}]
|
199
|
+
}, {
|
200
|
+
at: [moveTo]
|
173
201
|
});
|
202
|
+
if (lastLine) {
|
203
|
+
Transforms.move(editor, {
|
204
|
+
at: [moveTo]
|
205
|
+
});
|
206
|
+
}
|
174
207
|
}
|
175
208
|
} catch (err) {
|
176
209
|
console.log(err);
|
177
210
|
}
|
178
211
|
};
|
179
|
-
const grid_drag_id = `grid_drag_${path.join("_")}`;
|
180
|
-
const [dndElements, isDragging, isActiveDrag] = useDragAndDrop({
|
181
|
-
editor,
|
182
|
-
id: grid_drag_id,
|
183
|
-
selected,
|
184
|
-
path,
|
185
|
-
element,
|
186
|
-
onDragEnd,
|
187
|
-
onDrop
|
188
|
-
});
|
189
212
|
|
190
|
-
// const
|
191
|
-
//
|
192
|
-
//
|
213
|
+
// const onDrop = (dropElement) => {
|
214
|
+
// try {
|
215
|
+
// Transforms.insertNodes(editor, JSON.parse(dropElement), {
|
216
|
+
// at: path,
|
217
|
+
// select: true,
|
218
|
+
// });
|
219
|
+
// } catch (err) {
|
220
|
+
// console.log(err);
|
221
|
+
// }
|
193
222
|
// };
|
194
223
|
|
195
|
-
// const
|
196
|
-
//
|
197
|
-
//
|
224
|
+
// const onDragEnd = () => {
|
225
|
+
// try {
|
226
|
+
// const currentDelpath = ReactEditor.findPath(editor, element);
|
227
|
+
// if (currentDelpath) {
|
228
|
+
// Transforms.removeNodes(editor, { at: currentDelpath });
|
229
|
+
// }
|
230
|
+
// } catch (err) {
|
231
|
+
// console.log(err);
|
232
|
+
// }
|
198
233
|
// };
|
199
234
|
|
235
|
+
// const grid_drag_id = `grid_drag_${path.join("_")}`;
|
236
|
+
|
237
|
+
// const [dndElements, isDragging, isActiveDrag] = useDragAndDrop({
|
238
|
+
// editor,
|
239
|
+
// id: grid_drag_id,
|
240
|
+
// selected,
|
241
|
+
// path,
|
242
|
+
// element,
|
243
|
+
// onDragEnd,
|
244
|
+
// onDrop,
|
245
|
+
// });
|
246
|
+
|
247
|
+
const NewLineButtons = () => {
|
248
|
+
return !readOnly && selected && path.length === 2 ? /*#__PURE__*/_jsxs(_Fragment, {
|
249
|
+
children: [/*#__PURE__*/_jsx("div", {
|
250
|
+
className: "element-selector-ctrl tc",
|
251
|
+
children: /*#__PURE__*/_jsx(Tooltip, {
|
252
|
+
title: "Add Space above",
|
253
|
+
arrow: true,
|
254
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
255
|
+
onClick: onNewLine("up"),
|
256
|
+
children: /*#__PURE__*/_jsx(KeyboardReturnIcon, {})
|
257
|
+
})
|
258
|
+
})
|
259
|
+
}), /*#__PURE__*/_jsx("div", {
|
260
|
+
className: "element-selector-ctrl bc",
|
261
|
+
children: /*#__PURE__*/_jsx(Tooltip, {
|
262
|
+
title: "Add Space below",
|
263
|
+
arrow: true,
|
264
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
265
|
+
onClick: onNewLine("down"),
|
266
|
+
children: /*#__PURE__*/_jsx(KeyboardReturnIcon, {})
|
267
|
+
})
|
268
|
+
})
|
269
|
+
})]
|
270
|
+
}) : null;
|
271
|
+
};
|
200
272
|
const GridToolBar = () => {
|
201
273
|
return selected ? /*#__PURE__*/_jsxs("div", {
|
202
274
|
className: "grid-container-toolbar",
|
@@ -222,7 +294,23 @@ const Grid = props => {
|
|
222
294
|
onClick: onAddSection(null, true),
|
223
295
|
children: /*#__PURE__*/_jsx(GridAddSectionIcon, {})
|
224
296
|
})
|
225
|
-
})
|
297
|
+
}), path.length === 2 ? /*#__PURE__*/_jsxs(_Fragment, {
|
298
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
299
|
+
title: "Move Up",
|
300
|
+
arrow: true,
|
301
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
302
|
+
onClick: onMoveSection("up"),
|
303
|
+
children: /*#__PURE__*/_jsx(ArrowUpwardIcon, {})
|
304
|
+
})
|
305
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
306
|
+
title: "Move Down",
|
307
|
+
arrow: true,
|
308
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
309
|
+
onClick: onMoveSection("down"),
|
310
|
+
children: /*#__PURE__*/_jsx(ArrowDownwardIcon, {})
|
311
|
+
})
|
312
|
+
})]
|
313
|
+
}) : null]
|
226
314
|
}) : null;
|
227
315
|
};
|
228
316
|
const sectionId = id ? {
|
@@ -231,8 +319,9 @@ const Grid = props => {
|
|
231
319
|
const bgImage = backgroundImage && backgroundImage !== "none" ? {
|
232
320
|
backgroundImage: `url(${backgroundImage})`
|
233
321
|
} : {};
|
234
|
-
return /*#__PURE__*/_jsxs(
|
235
|
-
|
322
|
+
return /*#__PURE__*/_jsxs(GridContainer, {
|
323
|
+
container: true,
|
324
|
+
className: `grid-container ${grid} has-hover element-root`,
|
236
325
|
...attributes,
|
237
326
|
...sectionId,
|
238
327
|
style: {
|
@@ -243,10 +332,8 @@ const Grid = props => {
|
|
243
332
|
borderWidth: borderWidth || "1px",
|
244
333
|
borderRadius: `${topLeft}px ${topRight}px ${bottomLeft}px ${bottomRight}px`,
|
245
334
|
borderStyle: borderStyle || "solid"
|
246
|
-
}
|
247
|
-
|
248
|
-
// onMouseLeave={onMouseLeave}
|
249
|
-
,
|
335
|
+
},
|
336
|
+
"data-path": path.join(","),
|
250
337
|
children: [fgColor && /*#__PURE__*/_jsx("div", {
|
251
338
|
style: {
|
252
339
|
position: "absolute",
|
@@ -279,7 +366,9 @@ const Grid = props => {
|
|
279
366
|
onClose: onClose,
|
280
367
|
onDelete: onDelete,
|
281
368
|
customProps: customProps
|
282
|
-
}) : null, /*#__PURE__*/_jsx(
|
369
|
+
}) : null, /*#__PURE__*/_jsx(GridContainer, {
|
370
|
+
item: true,
|
371
|
+
xs: 12,
|
283
372
|
className: "grid-c-wrpr",
|
284
373
|
style: {
|
285
374
|
display: "flex",
|
@@ -290,11 +379,18 @@ const Grid = props => {
|
|
290
379
|
alignItems: vertical || "start",
|
291
380
|
justifyContent: horizantal || "start",
|
292
381
|
flexDirection: flexDirection || "row",
|
293
|
-
width: "100%"
|
294
|
-
|
382
|
+
width: "100%"
|
383
|
+
// height cause overlap issues TBD
|
384
|
+
// height: resizing
|
385
|
+
// ? `${size?.height}px`
|
386
|
+
// : elHeight
|
387
|
+
// ? `${elHeight}px`
|
388
|
+
// : "fit-content",
|
295
389
|
},
|
390
|
+
|
391
|
+
"data-path": path.join(","),
|
296
392
|
children: children
|
297
|
-
})]
|
393
|
+
}), /*#__PURE__*/_jsx(NewLineButtons, {})]
|
298
394
|
});
|
299
395
|
};
|
300
396
|
export default Grid;
|