@flozy/editor 1.1.1 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CollaborativeEditor.js +7 -2
- package/dist/Editor/CommonEditor.js +59 -37
- package/dist/Editor/Editor.css +209 -12
- package/dist/Editor/Elements/Accordion/Accordion.js +100 -0
- package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +20 -0
- package/dist/Editor/Elements/Accordion/AccordionButton.js +22 -0
- package/dist/Editor/Elements/Accordion/AccordionDetails.js +18 -0
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +69 -0
- package/dist/Editor/Elements/Accordion/AccordionTitlePopup.js +20 -0
- package/dist/Editor/Elements/Button/ButtonPopup.js +20 -0
- package/dist/Editor/Elements/Button/ButtonToolIcon.js +19 -0
- package/dist/Editor/Elements/Button/EditorButton.js +124 -0
- package/dist/Editor/Elements/Carousel/Arrows.js +39 -0
- package/dist/Editor/Elements/Carousel/Carousel.js +82 -0
- package/dist/Editor/Elements/Carousel/CarouselButton.js +19 -0
- package/dist/Editor/Elements/Carousel/CarouselItem.js +13 -0
- package/dist/Editor/Elements/Carousel/slick-theme.min.css +143 -0
- package/dist/Editor/Elements/Carousel/slick.min.css +83 -0
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +1 -1
- package/dist/Editor/Elements/Embed/Embed.css +22 -2
- package/dist/Editor/Elements/Embed/Embed.js +89 -74
- package/dist/Editor/Elements/Embed/EmbedPopup.js +23 -0
- package/dist/Editor/Elements/Embed/Image.js +92 -10
- package/dist/Editor/Elements/Embed/Video.js +31 -5
- package/dist/Editor/Elements/Equation/EquationButton.js +12 -12
- package/dist/Editor/Elements/Grid/Grid.js +64 -8
- package/dist/Editor/Elements/Grid/GridButton.js +2 -4
- package/dist/Editor/Elements/Grid/GridItem.js +59 -5
- package/dist/Editor/Elements/Grid/GridItemPopup.js +20 -0
- package/dist/Editor/Elements/Grid/GridPopup.js +22 -0
- package/dist/Editor/Elements/ID/Id.js +1 -1
- package/dist/Editor/Elements/ImageText/ImageText.js +14 -0
- package/dist/Editor/Elements/ImageText/ImageTextWrapper.js +14 -0
- package/dist/Editor/Elements/Link/LinkButton.js +1 -1
- package/dist/Editor/Elements/NewLine/NewLineButton.js +2 -1
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +88 -0
- package/dist/Editor/Elements/PageSettings/PageSettingsPopup.js +22 -0
- package/dist/Editor/Elements/Signature/Signature.js +50 -0
- package/dist/Editor/Elements/Signature/SignatureButton.js +19 -0
- package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +39 -0
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +84 -0
- package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +50 -0
- package/dist/Editor/Elements/Signature/SignatureOptions/index.js +5 -0
- package/dist/Editor/Elements/Signature/SignaturePopup.js +243 -0
- package/dist/Editor/Elements/Signature/Signed.js +80 -0
- package/dist/Editor/Elements/Table/DeleteCellIcon.js +24 -0
- package/dist/Editor/Elements/Table/DeleteRowIcon.js +24 -0
- package/dist/Editor/Elements/Table/Table.js +9 -1
- package/dist/Editor/Elements/Table/TableCell.js +181 -0
- package/dist/Editor/Elements/Table/TablePopup.js +22 -0
- package/dist/Editor/Elements/Table/TableRow.js +31 -0
- package/dist/Editor/Elements/Table/TableSelector.js +62 -68
- package/dist/Editor/Toolbar/Toolbar.js +47 -10
- package/dist/Editor/Toolbar/styles.css +20 -11
- package/dist/Editor/Toolbar/toolbarGroups.js +17 -19
- package/dist/Editor/common/Button.js +4 -8
- package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +23 -0
- package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +35 -0
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +47 -0
- package/dist/Editor/common/StyleBuilder/embedImageStyle.js +63 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/alignment.js +88 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +87 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +136 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +126 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +89 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/elementSize.js +110 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/gridSize.js +42 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/imageTexts.js +75 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +21 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +46 -0
- package/dist/Editor/common/StyleBuilder/gridItemStyle.js +51 -0
- package/dist/Editor/common/StyleBuilder/gridStyle.js +51 -0
- package/dist/Editor/common/StyleBuilder/index.js +114 -0
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +10 -0
- package/dist/Editor/common/StyleBuilder/tableStyle.js +38 -0
- package/dist/Editor/common/Uploader.js +87 -0
- package/dist/Editor/plugins/withEmbeds.js +12 -5
- package/dist/Editor/plugins/withTable.js +5 -4
- package/dist/Editor/service/fileupload.js +17 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +72 -23
- package/dist/Editor/utils/accordion.js +25 -0
- package/dist/Editor/utils/button.js +11 -0
- package/dist/Editor/utils/carousel.js +13 -0
- package/dist/Editor/utils/carouselItem.js +19 -0
- package/dist/Editor/utils/customHooks/useContextMenu.js +8 -8
- package/dist/Editor/utils/customHooks/useResize.js +1 -1
- package/dist/Editor/utils/font.js +59 -0
- package/dist/Editor/utils/helper.js +32 -0
- package/dist/Editor/utils/imageText.js +19 -0
- package/dist/Editor/utils/signature.js +23 -0
- package/dist/Editor/utils/table.js +172 -0
- package/package.json +11 -3
@@ -1,103 +1,118 @@
|
|
1
|
-
import React, { useRef, useState } from
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import {
|
5
|
-
import
|
6
|
-
import {
|
7
|
-
import
|
8
|
-
import {
|
9
|
-
import
|
1
|
+
import React, { useRef, useState } from "react";
|
2
|
+
import { Transforms } from "slate";
|
3
|
+
import { ReactEditor } from "slate-react";
|
4
|
+
import { Grid, Dialog, DialogTitle, DialogContent, DialogActions, Button, TextField, IconButton } from "@mui/material";
|
5
|
+
import Icon from "../../common/Icon";
|
6
|
+
import { isBlockActive } from "../../utils/SlateUtilityFunctions";
|
7
|
+
import usePopup from "../../utils/customHooks/usePopup";
|
8
|
+
import { insertEmbed } from "../../utils/embed";
|
9
|
+
import Uploader from "../../common/Uploader";
|
10
|
+
import "./Embed.css";
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
11
12
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
14
|
+
const EMBED_LABEL = {
|
15
|
+
image: "Image",
|
16
|
+
video: "Video"
|
17
|
+
};
|
12
18
|
const Embed = ({
|
13
19
|
editor,
|
14
|
-
format
|
20
|
+
format,
|
21
|
+
customProps
|
15
22
|
}) => {
|
16
23
|
const urlInputRef = useRef();
|
24
|
+
const [open, setOpen] = useState(false);
|
17
25
|
const [showInput, setShowInput] = usePopup(urlInputRef);
|
18
26
|
const [formData, setFormData] = useState({
|
19
|
-
url:
|
20
|
-
alt:
|
27
|
+
url: "",
|
28
|
+
alt: ""
|
21
29
|
});
|
22
30
|
const [selection, setSelection] = useState();
|
23
|
-
const
|
31
|
+
const handleFormSubmit = () => {
|
32
|
+
if (formData?.url) {
|
33
|
+
selection && Transforms.select(editor, selection);
|
34
|
+
selection && ReactEditor.focus(editor);
|
35
|
+
insertEmbed(editor, {
|
36
|
+
...formData
|
37
|
+
}, format);
|
38
|
+
setShowInput(false);
|
39
|
+
setFormData({
|
40
|
+
url: "",
|
41
|
+
alt: ""
|
42
|
+
});
|
43
|
+
}
|
44
|
+
};
|
45
|
+
const onToggle = e => {
|
24
46
|
e.preventDefault();
|
25
47
|
setSelection(editor.selection);
|
26
48
|
selection && ReactEditor.focus(editor);
|
27
|
-
|
49
|
+
setOpen(true);
|
28
50
|
};
|
29
|
-
const
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
51
|
+
const onSave = () => {
|
52
|
+
handleFormSubmit();
|
53
|
+
setOpen(false);
|
54
|
+
};
|
55
|
+
const onClose = () => {
|
56
|
+
setOpen(false);
|
57
|
+
};
|
58
|
+
const onUploaded = uploadedData => {
|
37
59
|
setFormData({
|
38
|
-
|
39
|
-
|
60
|
+
...formData,
|
61
|
+
...uploadedData
|
40
62
|
});
|
41
63
|
};
|
42
|
-
const
|
43
|
-
|
64
|
+
const handleChange = e => {
|
65
|
+
setFormData({
|
66
|
+
...formData,
|
67
|
+
[e.target.name]: e.target.value
|
68
|
+
});
|
44
69
|
};
|
45
|
-
return /*#__PURE__*/_jsxs(
|
46
|
-
|
47
|
-
|
48
|
-
children: [/*#__PURE__*/_jsx(Button, {
|
49
|
-
active: isBlockActive(editor, format),
|
70
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
71
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
72
|
+
className: isBlockActive(editor, format) ? "active" : "",
|
50
73
|
style: {
|
51
|
-
border: showInput ?
|
52
|
-
borderBottom:
|
74
|
+
border: showInput ? "1px solid lightgray" : "",
|
75
|
+
borderBottom: "none"
|
53
76
|
},
|
54
77
|
format: format,
|
55
|
-
onClick:
|
78
|
+
onClick: onToggle,
|
56
79
|
children: /*#__PURE__*/_jsx(Icon, {
|
57
80
|
icon: format
|
58
81
|
})
|
59
|
-
}),
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
82
|
+
}), /*#__PURE__*/_jsxs(Dialog, {
|
83
|
+
open: open,
|
84
|
+
fullWidth: true,
|
85
|
+
children: [/*#__PURE__*/_jsx(DialogTitle, {
|
86
|
+
children: EMBED_LABEL[format] || "Embed"
|
87
|
+
}), /*#__PURE__*/_jsx(DialogContent, {
|
88
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
89
|
+
container: true,
|
90
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
91
|
+
item: true,
|
92
|
+
xs: 12,
|
93
|
+
children: /*#__PURE__*/_jsx(TextField, {
|
94
|
+
name: "url",
|
95
|
+
placeholder: "Enter URL",
|
96
|
+
size: "small",
|
97
|
+
fullWidth: true,
|
98
|
+
onChange: handleChange,
|
99
|
+
value: formData?.url || ""
|
100
|
+
})
|
101
|
+
}), /*#__PURE__*/_jsx(Uploader, {
|
102
|
+
value: formData,
|
103
|
+
data: {
|
104
|
+
key: "url"
|
105
|
+
},
|
106
|
+
customProps: customProps,
|
107
|
+
onUploaded: onUploaded
|
72
108
|
})]
|
73
|
-
})
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
},
|
79
|
-
children: "OR"
|
80
|
-
})]
|
81
|
-
}), /*#__PURE__*/_jsxs("form", {
|
82
|
-
onSubmit: handleFormSubmit,
|
83
|
-
children: [/*#__PURE__*/_jsx("input", {
|
84
|
-
type: "text",
|
85
|
-
placeholder: "Enter url",
|
86
|
-
value: formData.url,
|
87
|
-
onChange: e => setFormData(prev => ({
|
88
|
-
...prev,
|
89
|
-
url: e.target.value
|
90
|
-
}))
|
91
|
-
}), /*#__PURE__*/_jsx("input", {
|
92
|
-
type: "text",
|
93
|
-
placeholder: "Enter alt",
|
94
|
-
value: formData.alt,
|
95
|
-
onChange: e => setFormData(prev => ({
|
96
|
-
...prev,
|
97
|
-
alt: e.target.value
|
98
|
-
}))
|
109
|
+
})
|
110
|
+
}), /*#__PURE__*/_jsxs(DialogActions, {
|
111
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
112
|
+
onClick: onClose,
|
113
|
+
children: "Cancel"
|
99
114
|
}), /*#__PURE__*/_jsx(Button, {
|
100
|
-
|
115
|
+
onClick: onSave,
|
101
116
|
children: "Save"
|
102
117
|
})]
|
103
118
|
})]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import StyleBuilder from "../../common/StyleBuilder";
|
3
|
+
import embedImageStyle from "../../common/StyleBuilder/embedImageStyle";
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
const EmbedPopup = props => {
|
6
|
+
const {
|
7
|
+
element,
|
8
|
+
onSave,
|
9
|
+
onClose,
|
10
|
+
customProps,
|
11
|
+
format
|
12
|
+
} = props;
|
13
|
+
return /*#__PURE__*/_jsx(StyleBuilder, {
|
14
|
+
title: "Image",
|
15
|
+
type: format === "image" ? "embedImageStyle" : "embedImageStyle",
|
16
|
+
element: element,
|
17
|
+
onSave: onSave,
|
18
|
+
onClose: onClose,
|
19
|
+
renderTabs: format === "image" ? embedImageStyle : embedImageStyle,
|
20
|
+
customProps: customProps
|
21
|
+
});
|
22
|
+
};
|
23
|
+
export default EmbedPopup;
|
@@ -1,36 +1,59 @@
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
2
|
-
import { useSlateStatic, useSelected,
|
3
|
-
import { Node, Transforms } from "slate";
|
2
|
+
import { useSlateStatic, useSelected, ReactEditor } from "slate-react";
|
3
|
+
import { Node, Transforms, Editor, Element, Path } from "slate";
|
4
4
|
import Icon from "../../common/Icon";
|
5
5
|
import useResize from "../../utils/customHooks/useResize";
|
6
|
+
import { insertImageText } from "../../utils/imageText";
|
7
|
+
import EmbedPopup from "./EmbedPopup";
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
7
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
8
10
|
const Image = ({
|
9
11
|
attributes,
|
10
12
|
element,
|
11
|
-
children
|
13
|
+
children,
|
14
|
+
customProps
|
12
15
|
}) => {
|
13
16
|
const {
|
14
17
|
url,
|
15
|
-
alt
|
18
|
+
alt,
|
19
|
+
bannerSpacing,
|
20
|
+
alignment,
|
21
|
+
bgColor,
|
22
|
+
borderColor
|
16
23
|
} = element;
|
24
|
+
const {
|
25
|
+
left,
|
26
|
+
top,
|
27
|
+
right,
|
28
|
+
bottom
|
29
|
+
} = bannerSpacing || {};
|
30
|
+
const {
|
31
|
+
vertical,
|
32
|
+
horizantal
|
33
|
+
} = alignment || {};
|
17
34
|
const editor = useSlateStatic();
|
18
35
|
const selected = useSelected();
|
19
|
-
const focused = useFocused();
|
20
36
|
const [parentDOM, setParentDOM] = useState(null);
|
37
|
+
const [openSetttings, setOpenSettings] = useState(false);
|
21
38
|
const [size, onMouseDown, resizing, onLoad] = useResize({
|
22
39
|
parentDOM,
|
23
40
|
size: element?.size
|
24
41
|
});
|
25
42
|
const arr = Array.from(Node.elements(editor));
|
26
43
|
const ele = arr.find(([elem]) => element === elem);
|
44
|
+
const path = ReactEditor.findPath(editor, element);
|
27
45
|
useEffect(() => {
|
28
46
|
if (editor && ele[1] !== undefined) {
|
29
47
|
const dom = ReactEditor.toDOMNode(editor, Node.get(editor, ele[1]));
|
30
48
|
setParentDOM(dom);
|
31
|
-
onLoad(
|
49
|
+
onLoad(element?.size || {});
|
32
50
|
}
|
33
51
|
}, []);
|
52
|
+
useEffect(() => {
|
53
|
+
if (!resizing) {
|
54
|
+
onLoad(element?.size || {});
|
55
|
+
}
|
56
|
+
}, [element?.size]);
|
34
57
|
useEffect(() => {
|
35
58
|
if (!resizing) {
|
36
59
|
Transforms.setNodes(editor, {
|
@@ -38,17 +61,74 @@ const Image = ({
|
|
38
61
|
});
|
39
62
|
}
|
40
63
|
}, [resizing]);
|
64
|
+
const handleImageClick = () => {
|
65
|
+
Transforms.select(editor, {
|
66
|
+
anchor: Editor.start(editor, path),
|
67
|
+
focus: Editor.end(editor, path)
|
68
|
+
});
|
69
|
+
};
|
70
|
+
const onSettings = () => {
|
71
|
+
setOpenSettings(true);
|
72
|
+
};
|
73
|
+
const onSave = data => {
|
74
|
+
const updateData = {
|
75
|
+
...data
|
76
|
+
};
|
77
|
+
delete updateData.children;
|
78
|
+
Transforms.setNodes(editor, {
|
79
|
+
...updateData
|
80
|
+
}, {
|
81
|
+
at: path
|
82
|
+
});
|
83
|
+
onClose();
|
84
|
+
};
|
85
|
+
const onClose = () => {
|
86
|
+
setOpenSettings(false);
|
87
|
+
};
|
88
|
+
const onAddText = () => {
|
89
|
+
Transforms.wrapNodes(editor, {
|
90
|
+
type: "image-text-wrapper",
|
91
|
+
children: []
|
92
|
+
});
|
93
|
+
insertImageText(editor, [...path, 1]);
|
94
|
+
};
|
95
|
+
const ToolBar = () => {
|
96
|
+
return selected ? /*#__PURE__*/_jsxs("div", {
|
97
|
+
className: "element-toolbar",
|
98
|
+
contentEditable: false,
|
99
|
+
children: [/*#__PURE__*/_jsx("button", {
|
100
|
+
onClick: onAddText,
|
101
|
+
children: "Add Text"
|
102
|
+
}), /*#__PURE__*/_jsx("button", {
|
103
|
+
onClick: onSettings,
|
104
|
+
children: "Settings"
|
105
|
+
})]
|
106
|
+
}) : null;
|
107
|
+
};
|
108
|
+
const totalMinus = (parseInt(left) || 0) + (parseInt(right) || 0);
|
41
109
|
return /*#__PURE__*/_jsxs("div", {
|
42
110
|
...attributes,
|
43
111
|
className: "embed",
|
44
112
|
style: {
|
45
113
|
display: "flex",
|
46
|
-
width:
|
114
|
+
width: `calc(100% - ${totalMinus}px)`,
|
47
115
|
maxWidth: "100%",
|
48
|
-
|
116
|
+
paddingLeft: `${left}px`,
|
117
|
+
paddingRight: `${right}px`,
|
118
|
+
paddingTop: `${top}px`,
|
119
|
+
paddingBottom: `${bottom}px`,
|
120
|
+
backgroundColor: bgColor,
|
121
|
+
justifyContent: horizantal,
|
122
|
+
alignContent: vertical,
|
123
|
+
border: `1px solid ${borderColor}`
|
49
124
|
},
|
50
125
|
...element.attr,
|
51
|
-
children: [/*#__PURE__*/
|
126
|
+
children: [/*#__PURE__*/_jsx(ToolBar, {}), openSetttings ? /*#__PURE__*/_jsx(EmbedPopup, {
|
127
|
+
element: element,
|
128
|
+
onSave: onSave,
|
129
|
+
onClose: onClose,
|
130
|
+
customProps: customProps
|
131
|
+
}) : null, /*#__PURE__*/_jsxs("div", {
|
52
132
|
contentEditable: false,
|
53
133
|
style: {
|
54
134
|
position: "relative",
|
@@ -57,7 +137,8 @@ const Image = ({
|
|
57
137
|
},
|
58
138
|
children: [/*#__PURE__*/_jsx("img", {
|
59
139
|
alt: alt,
|
60
|
-
src: url
|
140
|
+
src: url,
|
141
|
+
onClick: handleImageClick
|
61
142
|
}), selected && /*#__PURE__*/_jsx("button", {
|
62
143
|
onPointerDown: onMouseDown,
|
63
144
|
style: {
|
@@ -66,6 +147,7 @@ const Image = ({
|
|
66
147
|
opacity: 1,
|
67
148
|
background: "transparent"
|
68
149
|
},
|
150
|
+
className: "resize",
|
69
151
|
children: /*#__PURE__*/_jsx(Icon, {
|
70
152
|
icon: "resize"
|
71
153
|
})
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { useSelected, useFocused } from "slate-react";
|
1
|
+
import React, { useState, useEffect } from "react";
|
2
|
+
import { useSelected, useFocused, useSlateStatic, ReactEditor } from "slate-react";
|
3
|
+
import { Node, Transforms } from "slate";
|
3
4
|
import Icon from "../../common/Icon";
|
4
5
|
import useResize from "../../utils/customHooks/useResize";
|
5
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
@@ -13,21 +14,45 @@ const Video = ({
|
|
13
14
|
url,
|
14
15
|
alt
|
15
16
|
} = element;
|
16
|
-
const
|
17
|
+
const editor = useSlateStatic();
|
17
18
|
const selected = useSelected();
|
18
19
|
const focused = useFocused();
|
20
|
+
const [parentDOM, setParentDOM] = useState(null);
|
21
|
+
const [size, onMouseDown, resizing, onLoad] = useResize({
|
22
|
+
parentDOM,
|
23
|
+
size: element?.size
|
24
|
+
});
|
25
|
+
const arr = Array.from(Node.elements(editor));
|
26
|
+
const ele = arr.find(([elem]) => element === elem);
|
27
|
+
useEffect(() => {
|
28
|
+
if (editor && ele[1] !== undefined) {
|
29
|
+
const dom = ReactEditor.toDOMNode(editor, Node.get(editor, ele[1]));
|
30
|
+
setParentDOM(dom);
|
31
|
+
onLoad(dom);
|
32
|
+
}
|
33
|
+
}, []);
|
34
|
+
useEffect(() => {
|
35
|
+
if (!resizing) {
|
36
|
+
Transforms.setNodes(editor, {
|
37
|
+
size: size
|
38
|
+
});
|
39
|
+
}
|
40
|
+
}, [resizing]);
|
19
41
|
return /*#__PURE__*/_jsxs("div", {
|
20
42
|
...attributes,
|
21
43
|
className: "embed",
|
22
44
|
style: {
|
23
45
|
display: "flex",
|
46
|
+
width: "100%",
|
47
|
+
maxWidth: "100%",
|
24
48
|
boxShadow: selected && focused && "0 0 3px 3px lightgray"
|
25
49
|
},
|
26
50
|
...element.attr,
|
27
51
|
children: [/*#__PURE__*/_jsxs("div", {
|
28
52
|
contentEditable: false,
|
29
53
|
style: {
|
30
|
-
|
54
|
+
position: "relative",
|
55
|
+
width: size.widthInPercent ? `${size.widthInPercent}%` : `${size.width}px`,
|
31
56
|
height: `${size.height}px`
|
32
57
|
},
|
33
58
|
children: [
|
@@ -50,13 +75,14 @@ const Video = ({
|
|
50
75
|
frameBorder: "0",
|
51
76
|
title: alt
|
52
77
|
}), selected && /*#__PURE__*/_jsx("button", {
|
53
|
-
|
78
|
+
onPointerDown: onMouseDown,
|
54
79
|
style: {
|
55
80
|
width: "15px",
|
56
81
|
height: "15px",
|
57
82
|
opacity: 1,
|
58
83
|
background: "transparent"
|
59
84
|
},
|
85
|
+
className: "resize",
|
60
86
|
children: /*#__PURE__*/_jsx(Icon, {
|
61
87
|
icon: "resize"
|
62
88
|
})
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { useRef, useState } from
|
2
|
-
import Button from
|
3
|
-
import Icon from
|
4
|
-
import usePopup from
|
5
|
-
import { insertEquation } from
|
6
|
-
import { Transforms } from
|
1
|
+
import { useRef, useState } from "react";
|
2
|
+
import Button from "../../common/Button";
|
3
|
+
import Icon from "../../common/Icon";
|
4
|
+
import usePopup from "../../utils/customHooks/usePopup";
|
5
|
+
import { insertEquation } from "../../utils/equation";
|
6
|
+
import { Transforms } from "slate";
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
9
9
|
const EquationButton = ({
|
@@ -11,7 +11,7 @@ const EquationButton = ({
|
|
11
11
|
}) => {
|
12
12
|
const equationInputRef = useRef(null);
|
13
13
|
const [showInput, setShowInput] = usePopup(equationInputRef);
|
14
|
-
const [math, setMath] = useState(
|
14
|
+
const [math, setMath] = useState("");
|
15
15
|
const [displayInline, setDisplayInline] = useState(false);
|
16
16
|
const [selection, setSelection] = useState();
|
17
17
|
const toggleButton = () => {
|
@@ -22,7 +22,7 @@ const EquationButton = ({
|
|
22
22
|
const handleInputChange = ({
|
23
23
|
target
|
24
24
|
}) => {
|
25
|
-
if (target.type ===
|
25
|
+
if (target.type === "checkbox") {
|
26
26
|
setDisplayInline(prev => !prev);
|
27
27
|
} else {
|
28
28
|
setMath(target.value);
|
@@ -32,12 +32,12 @@ const EquationButton = ({
|
|
32
32
|
if (!math) return;
|
33
33
|
selection && Transforms.select(editor, selection);
|
34
34
|
insertEquation(editor, math, displayInline);
|
35
|
-
console.log(
|
35
|
+
console.log("btn click");
|
36
36
|
setShowInput(false);
|
37
37
|
};
|
38
38
|
return /*#__PURE__*/_jsxs("div", {
|
39
39
|
ref: equationInputRef,
|
40
|
-
className: "popup-
|
40
|
+
className: "popup-wrapper1",
|
41
41
|
children: [/*#__PURE__*/_jsx(Button, {
|
42
42
|
format: "equation",
|
43
43
|
onClick: toggleButton,
|
@@ -48,8 +48,8 @@ const EquationButton = ({
|
|
48
48
|
className: "popup",
|
49
49
|
children: [/*#__PURE__*/_jsxs("div", {
|
50
50
|
style: {
|
51
|
-
display:
|
52
|
-
gap:
|
51
|
+
display: "flex",
|
52
|
+
gap: "5px"
|
53
53
|
},
|
54
54
|
children: [/*#__PURE__*/_jsx("input", {
|
55
55
|
type: "text",
|
@@ -1,20 +1,39 @@
|
|
1
|
-
import React from "react";
|
1
|
+
import React, { useState } from "react";
|
2
2
|
import { Transforms, Path } from "slate";
|
3
|
-
import { useSelected, useSlateStatic } from "slate-react";
|
3
|
+
import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
|
4
4
|
import { gridItem } from "../../utils/gridItem";
|
5
|
+
import GridPopup from "./GridPopup";
|
5
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
6
7
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
7
8
|
const Grid = props => {
|
8
9
|
const {
|
9
10
|
attributes,
|
10
11
|
children,
|
11
|
-
element
|
12
|
+
element,
|
13
|
+
customProps
|
12
14
|
} = props;
|
15
|
+
const [openSetttings, setOpenSettings] = useState(false);
|
13
16
|
const {
|
14
|
-
grid
|
17
|
+
grid,
|
18
|
+
bannerSpacing,
|
19
|
+
bgColor,
|
20
|
+
alignment,
|
21
|
+
backgroundImage,
|
22
|
+
borderColor
|
15
23
|
} = element;
|
24
|
+
const {
|
25
|
+
left,
|
26
|
+
top,
|
27
|
+
right,
|
28
|
+
bottom
|
29
|
+
} = bannerSpacing || {};
|
30
|
+
const {
|
31
|
+
vertical,
|
32
|
+
horizantal
|
33
|
+
} = alignment || {};
|
16
34
|
const editor = useSlateStatic();
|
17
35
|
const selected = useSelected();
|
36
|
+
const path = ReactEditor.findPath(editor, element);
|
18
37
|
const onAddGridItem = () => {
|
19
38
|
const currentPath = editor.selection?.anchor?.path;
|
20
39
|
const ancestorsPath = Path.ancestors(currentPath, {
|
@@ -39,20 +58,57 @@ const Grid = props => {
|
|
39
58
|
});
|
40
59
|
}
|
41
60
|
};
|
61
|
+
const onSettings = () => {
|
62
|
+
setOpenSettings(true);
|
63
|
+
};
|
64
|
+
const onSave = data => {
|
65
|
+
const updateData = {
|
66
|
+
...data
|
67
|
+
};
|
68
|
+
delete updateData.children;
|
69
|
+
Transforms.setNodes(editor, {
|
70
|
+
...updateData
|
71
|
+
}, {
|
72
|
+
at: path
|
73
|
+
});
|
74
|
+
onClose();
|
75
|
+
};
|
76
|
+
const onClose = () => {
|
77
|
+
setOpenSettings(false);
|
78
|
+
};
|
42
79
|
const GridToolBar = () => {
|
43
|
-
return selected ? /*#__PURE__*/
|
80
|
+
return selected ? /*#__PURE__*/_jsxs("div", {
|
44
81
|
className: "grid-container-toolbar",
|
45
82
|
contentEditable: false,
|
46
|
-
children: /*#__PURE__*/_jsx("button", {
|
83
|
+
children: [/*#__PURE__*/_jsx("button", {
|
84
|
+
onClick: onSettings,
|
85
|
+
children: "Settings"
|
86
|
+
}), /*#__PURE__*/_jsx("button", {
|
47
87
|
onClick: onAddGridItem,
|
48
88
|
children: "+ Add Item"
|
49
|
-
})
|
89
|
+
})]
|
50
90
|
}) : null;
|
51
91
|
};
|
52
92
|
return /*#__PURE__*/_jsxs("div", {
|
53
93
|
className: `grid-container ${grid}`,
|
54
94
|
...attributes,
|
55
|
-
|
95
|
+
style: {
|
96
|
+
paddingLeft: `${left}px`,
|
97
|
+
paddingRight: `${right}px`,
|
98
|
+
paddingTop: `${top}px`,
|
99
|
+
paddingBottom: `${bottom}px`,
|
100
|
+
backgroundColor: bgColor,
|
101
|
+
justifyContent: horizantal,
|
102
|
+
alignContent: vertical,
|
103
|
+
backgroundImage: backgroundImage ? `url(${backgroundImage})` : "none",
|
104
|
+
border: `1px solid ${borderColor}`
|
105
|
+
},
|
106
|
+
children: [/*#__PURE__*/_jsx(GridToolBar, {}), openSetttings ? /*#__PURE__*/_jsx(GridPopup, {
|
107
|
+
element: element,
|
108
|
+
onSave: onSave,
|
109
|
+
onClose: onClose,
|
110
|
+
customProps: customProps
|
111
|
+
}) : null, children]
|
56
112
|
});
|
57
113
|
};
|
58
114
|
export default Grid;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from "react";
|
2
|
+
import { IconButton } from "@mui/material";
|
2
3
|
import ViewComfyIcon from "@mui/icons-material/ViewComfy";
|
3
4
|
import { insertGrid } from "../../utils/grid";
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
@@ -9,12 +10,9 @@ const GridButton = props => {
|
|
9
10
|
const handleInsertGrid = () => {
|
10
11
|
insertGrid(editor);
|
11
12
|
};
|
12
|
-
return /*#__PURE__*/_jsx(
|
13
|
+
return /*#__PURE__*/_jsx(IconButton, {
|
13
14
|
onClick: handleInsertGrid,
|
14
15
|
title: "Layout",
|
15
|
-
style: {
|
16
|
-
marginLeft: "8px"
|
17
|
-
},
|
18
16
|
children: /*#__PURE__*/_jsx(ViewComfyIcon, {})
|
19
17
|
});
|
20
18
|
};
|