@flozy/editor 1.1.2 → 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 +53 -34
- package/dist/Editor/Editor.css +93 -17
- package/dist/Editor/Elements/Accordion/Accordion.js +67 -2
- package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +20 -0
- package/dist/Editor/Elements/Accordion/AccordionButton.js +2 -1
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +59 -4
- 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 +1 -0
- 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 +4 -2
- package/dist/Editor/Elements/Signature/SignatureButton.js +2 -1
- package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +7 -2
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -1
- package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +50 -0
- package/dist/Editor/Elements/Signature/SignatureOptions/index.js +2 -1
- package/dist/Editor/Elements/Signature/SignaturePopup.js +79 -10
- 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 +22 -7
- package/dist/Editor/Toolbar/styles.css +20 -11
- package/dist/Editor/Toolbar/toolbarGroups.js +9 -9
- 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 +46 -12
- 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 +4 -4
- package/dist/Editor/utils/helper.js +16 -0
- package/dist/Editor/utils/imageText.js +19 -0
- package/dist/Editor/utils/table.js +172 -0
- package/package.json +2 -1
@@ -0,0 +1,42 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Grid, Slider } from "@mui/material";
|
3
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
const GridSize = props => {
|
6
|
+
const {
|
7
|
+
value,
|
8
|
+
data,
|
9
|
+
onChange
|
10
|
+
} = props;
|
11
|
+
const {
|
12
|
+
key
|
13
|
+
} = data;
|
14
|
+
const handleChange = e => {
|
15
|
+
onChange({
|
16
|
+
[key]: e.target.value
|
17
|
+
});
|
18
|
+
};
|
19
|
+
return /*#__PURE__*/_jsx(Grid, {
|
20
|
+
container: true,
|
21
|
+
padding: 3,
|
22
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
23
|
+
item: true,
|
24
|
+
xs: 12,
|
25
|
+
children: [/*#__PURE__*/_jsxs("label", {
|
26
|
+
style: {
|
27
|
+
marginBottom: "12px",
|
28
|
+
fontWeight: "bold"
|
29
|
+
},
|
30
|
+
children: ["Grid Size: ", value || 12, " "]
|
31
|
+
}), /*#__PURE__*/_jsx(Slider, {
|
32
|
+
defaultValue: 12,
|
33
|
+
value: value || 12,
|
34
|
+
step: 1,
|
35
|
+
min: 1,
|
36
|
+
max: 12,
|
37
|
+
onChange: handleChange
|
38
|
+
})]
|
39
|
+
})
|
40
|
+
});
|
41
|
+
};
|
42
|
+
export default GridSize;
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Button, Grid, IconButton, InputAdornment, TextField } from "@mui/material";
|
3
|
+
import DeleteIcon from "@mui/icons-material/Delete";
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
6
|
+
const ImageTexts = props => {
|
7
|
+
const {
|
8
|
+
value,
|
9
|
+
data,
|
10
|
+
onChange
|
11
|
+
} = props;
|
12
|
+
const texts = value || [""];
|
13
|
+
const {
|
14
|
+
key
|
15
|
+
} = data;
|
16
|
+
const handleChange = e => {
|
17
|
+
const updatedTexts = texts?.map((m, i) => {
|
18
|
+
if (`text-${i}` === e.target.name) {
|
19
|
+
return e.target.value;
|
20
|
+
}
|
21
|
+
return m;
|
22
|
+
});
|
23
|
+
onChange({
|
24
|
+
[key]: updatedTexts
|
25
|
+
});
|
26
|
+
};
|
27
|
+
const onAddText = () => {
|
28
|
+
onChange({
|
29
|
+
[key]: [...texts, ""]
|
30
|
+
});
|
31
|
+
};
|
32
|
+
const handleDelete = deleteIndex => () => {
|
33
|
+
const updatedTexts = texts?.filter((m, i) => {
|
34
|
+
return `text=${deleteIndex}` !== i;
|
35
|
+
});
|
36
|
+
onChange({
|
37
|
+
[key]: updatedTexts
|
38
|
+
});
|
39
|
+
};
|
40
|
+
return /*#__PURE__*/_jsxs(Grid, {
|
41
|
+
container: true,
|
42
|
+
padding: 3,
|
43
|
+
spacing: 2,
|
44
|
+
className: "input-adorn",
|
45
|
+
children: [texts?.map((m, i) => {
|
46
|
+
return /*#__PURE__*/_jsx(Grid, {
|
47
|
+
item: true,
|
48
|
+
xs: 12,
|
49
|
+
children: /*#__PURE__*/_jsx(TextField, {
|
50
|
+
fullWidth: true,
|
51
|
+
name: `text-${i}`,
|
52
|
+
placeholder: "Enter Image Text",
|
53
|
+
onChange: handleChange,
|
54
|
+
InputProps: {
|
55
|
+
endAdornment: /*#__PURE__*/_jsx(InputAdornment, {
|
56
|
+
position: "end",
|
57
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
58
|
+
onClick: handleDelete(i),
|
59
|
+
children: /*#__PURE__*/_jsx(DeleteIcon, {})
|
60
|
+
})
|
61
|
+
})
|
62
|
+
}
|
63
|
+
})
|
64
|
+
}, `imt_${i}`);
|
65
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
66
|
+
item: true,
|
67
|
+
xs: 12,
|
68
|
+
children: /*#__PURE__*/_jsx(Button, {
|
69
|
+
onClick: onAddText,
|
70
|
+
children: "Add Text"
|
71
|
+
})
|
72
|
+
})]
|
73
|
+
});
|
74
|
+
};
|
75
|
+
export default ImageTexts;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import Text from "./text";
|
2
|
+
import BannerSpacing from "./bannerSpacing";
|
3
|
+
import BorderRadius from "./borderRadius";
|
4
|
+
import Color from "./color";
|
5
|
+
import Alignment from "./alignment";
|
6
|
+
import BackgroundImage from "./backgroundImage";
|
7
|
+
import GridSize from "./gridSize";
|
8
|
+
import ElementSize from "./elementSize";
|
9
|
+
import ImageTexts from "./imageTexts";
|
10
|
+
const FieldMap = {
|
11
|
+
text: Text,
|
12
|
+
bannerSpacing: BannerSpacing,
|
13
|
+
borderRadius: BorderRadius,
|
14
|
+
color: Color,
|
15
|
+
alignment: Alignment,
|
16
|
+
backgroundImage: BackgroundImage,
|
17
|
+
gridSize: GridSize,
|
18
|
+
elementSize: ElementSize,
|
19
|
+
imageTexts: ImageTexts
|
20
|
+
};
|
21
|
+
export default FieldMap;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Grid, TextField } from "@mui/material";
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
4
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
5
|
+
const Text = props => {
|
6
|
+
const {
|
7
|
+
value,
|
8
|
+
data,
|
9
|
+
onChange
|
10
|
+
} = props;
|
11
|
+
const {
|
12
|
+
key
|
13
|
+
} = data;
|
14
|
+
const handleChange = e => {
|
15
|
+
onChange({
|
16
|
+
[key]: e.target.value
|
17
|
+
});
|
18
|
+
};
|
19
|
+
return /*#__PURE__*/_jsxs(Grid, {
|
20
|
+
container: true,
|
21
|
+
padding: 1,
|
22
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
23
|
+
item: true,
|
24
|
+
xs: 12,
|
25
|
+
style: {
|
26
|
+
fontWeight: "bold",
|
27
|
+
marginBottom: "8px"
|
28
|
+
},
|
29
|
+
children: /*#__PURE__*/_jsx("label", {
|
30
|
+
children: data?.label
|
31
|
+
})
|
32
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
33
|
+
item: true,
|
34
|
+
xs: 12,
|
35
|
+
children: /*#__PURE__*/_jsx(TextField, {
|
36
|
+
name: key,
|
37
|
+
type: "text",
|
38
|
+
value: value,
|
39
|
+
onChange: handleChange,
|
40
|
+
size: "small",
|
41
|
+
fullWidth: true
|
42
|
+
})
|
43
|
+
})]
|
44
|
+
});
|
45
|
+
};
|
46
|
+
export default Text;
|
@@ -0,0 +1,51 @@
|
|
1
|
+
const gridItemStyle = [{
|
2
|
+
tab: "Banner Spacing",
|
3
|
+
value: "bannerSpacing",
|
4
|
+
fields: [{
|
5
|
+
label: "Banner Spacing",
|
6
|
+
key: "bannerSpacing",
|
7
|
+
type: "bannerSpacing"
|
8
|
+
}]
|
9
|
+
}, {
|
10
|
+
tab: "Border Radius",
|
11
|
+
value: "borderRadius",
|
12
|
+
fields: [{
|
13
|
+
label: "Border Radius",
|
14
|
+
key: "borderRadius",
|
15
|
+
type: "borderRadius"
|
16
|
+
}]
|
17
|
+
}, {
|
18
|
+
tab: "Colors",
|
19
|
+
value: "colors",
|
20
|
+
fields: [{
|
21
|
+
label: "Text",
|
22
|
+
key: "textColor",
|
23
|
+
type: "color",
|
24
|
+
needPreview: true
|
25
|
+
}, {
|
26
|
+
label: "Background",
|
27
|
+
key: "bgColor",
|
28
|
+
type: "color"
|
29
|
+
}, {
|
30
|
+
label: "Border",
|
31
|
+
key: "borderColor",
|
32
|
+
type: "color"
|
33
|
+
}]
|
34
|
+
}, {
|
35
|
+
tab: "Position",
|
36
|
+
value: "position",
|
37
|
+
fields: [{
|
38
|
+
label: "Set Postion (Vertical & Horizantal)",
|
39
|
+
key: "alignment",
|
40
|
+
type: "alignment"
|
41
|
+
}]
|
42
|
+
}, {
|
43
|
+
tab: "Size",
|
44
|
+
value: "gridSize",
|
45
|
+
fields: [{
|
46
|
+
label: "Grid Size",
|
47
|
+
key: "grid",
|
48
|
+
type: "gridSize"
|
49
|
+
}]
|
50
|
+
}];
|
51
|
+
export default gridItemStyle;
|
@@ -0,0 +1,51 @@
|
|
1
|
+
const gridStyle = [{
|
2
|
+
tab: "Banner Spacing",
|
3
|
+
value: "bannerSpacing",
|
4
|
+
fields: [{
|
5
|
+
label: "Banner Spacing",
|
6
|
+
key: "bannerSpacing",
|
7
|
+
type: "bannerSpacing"
|
8
|
+
}]
|
9
|
+
}, {
|
10
|
+
tab: "Border Radius",
|
11
|
+
value: "borderRadius",
|
12
|
+
fields: [{
|
13
|
+
label: "Border Radius",
|
14
|
+
key: "borderRadius",
|
15
|
+
type: "borderRadius"
|
16
|
+
}]
|
17
|
+
}, {
|
18
|
+
tab: "Colors",
|
19
|
+
value: "colors",
|
20
|
+
fields: [{
|
21
|
+
label: "Text",
|
22
|
+
key: "textColor",
|
23
|
+
type: "color",
|
24
|
+
needPreview: true
|
25
|
+
}, {
|
26
|
+
label: "Background",
|
27
|
+
key: "bgColor",
|
28
|
+
type: "color"
|
29
|
+
}, {
|
30
|
+
label: "Border",
|
31
|
+
key: "borderColor",
|
32
|
+
type: "color"
|
33
|
+
}]
|
34
|
+
}, {
|
35
|
+
tab: "Position",
|
36
|
+
value: "position",
|
37
|
+
fields: [{
|
38
|
+
label: "Set Postion (Vertical & Horizantal)",
|
39
|
+
key: "alignment",
|
40
|
+
type: "alignment"
|
41
|
+
}]
|
42
|
+
}, {
|
43
|
+
tab: "Background",
|
44
|
+
value: "backgroundImage",
|
45
|
+
fields: [{
|
46
|
+
label: "Background Image",
|
47
|
+
key: "backgroundImage",
|
48
|
+
type: "backgroundImage"
|
49
|
+
}]
|
50
|
+
}];
|
51
|
+
export default gridStyle;
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Tabs, Tab, Grid } from "@mui/material";
|
3
|
+
import FieldMap from "./fieldTypes";
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
6
|
+
const StyleContent = props => {
|
7
|
+
const {
|
8
|
+
value,
|
9
|
+
renderTabs,
|
10
|
+
onChange,
|
11
|
+
element,
|
12
|
+
customProps
|
13
|
+
} = props;
|
14
|
+
const tabContent = renderTabs.find(f => f.value === value);
|
15
|
+
const {
|
16
|
+
fields
|
17
|
+
} = tabContent || {
|
18
|
+
fields: []
|
19
|
+
};
|
20
|
+
return /*#__PURE__*/_jsx(Grid, {
|
21
|
+
container: true,
|
22
|
+
spacing: 2,
|
23
|
+
children: /*#__PURE__*/_jsx(Grid, {
|
24
|
+
item: true,
|
25
|
+
xs: 12,
|
26
|
+
style: {
|
27
|
+
marginTop: "12px"
|
28
|
+
},
|
29
|
+
children: [...fields].map(m => {
|
30
|
+
const FieldComponent = FieldMap[m.type];
|
31
|
+
return FieldComponent ? /*#__PURE__*/_jsx(FieldComponent, {
|
32
|
+
data: m,
|
33
|
+
value: element[m.key],
|
34
|
+
onChange: onChange,
|
35
|
+
elementProps: element,
|
36
|
+
customProps: customProps
|
37
|
+
}, `ei_stt_tab_${value}_${m.key}`) : null;
|
38
|
+
})
|
39
|
+
})
|
40
|
+
}, value);
|
41
|
+
};
|
42
|
+
const StyleTabs = props => {
|
43
|
+
const {
|
44
|
+
value,
|
45
|
+
handleChange,
|
46
|
+
renderTabs
|
47
|
+
} = props;
|
48
|
+
return /*#__PURE__*/_jsx(Tabs, {
|
49
|
+
value: value,
|
50
|
+
onChange: handleChange,
|
51
|
+
variant: "scrollable",
|
52
|
+
scrollButtons: "auto",
|
53
|
+
"aria-label": "scrollable auto tabs example",
|
54
|
+
children: renderTabs.map((m, i) => {
|
55
|
+
return /*#__PURE__*/_jsx(Tab, {
|
56
|
+
value: m.value,
|
57
|
+
label: m.tab
|
58
|
+
}, `editor-stt-tab-${m.value}`);
|
59
|
+
})
|
60
|
+
});
|
61
|
+
};
|
62
|
+
const StyleBuilder = props => {
|
63
|
+
const {
|
64
|
+
title,
|
65
|
+
renderTabs,
|
66
|
+
element,
|
67
|
+
onSave,
|
68
|
+
onClose,
|
69
|
+
customProps
|
70
|
+
} = props;
|
71
|
+
const [elementProps, setElementProps] = useState(element);
|
72
|
+
const [tab, setTab] = useState(renderTabs[0]?.value);
|
73
|
+
const handleChange = (e, newValue) => {
|
74
|
+
setTab(newValue);
|
75
|
+
};
|
76
|
+
const onElementPropsChange = data => {
|
77
|
+
console.log(data);
|
78
|
+
setElementProps({
|
79
|
+
...elementProps,
|
80
|
+
...data
|
81
|
+
});
|
82
|
+
};
|
83
|
+
const handleSave = () => {
|
84
|
+
onSave(elementProps);
|
85
|
+
};
|
86
|
+
return /*#__PURE__*/_jsxs(Dialog, {
|
87
|
+
open: true,
|
88
|
+
fullWidth: true,
|
89
|
+
children: [/*#__PURE__*/_jsx(DialogTitle, {
|
90
|
+
children: title
|
91
|
+
}), /*#__PURE__*/_jsxs(DialogContent, {
|
92
|
+
children: [/*#__PURE__*/_jsx(StyleTabs, {
|
93
|
+
renderTabs: renderTabs,
|
94
|
+
value: tab,
|
95
|
+
handleChange: handleChange
|
96
|
+
}), /*#__PURE__*/_jsx(StyleContent, {
|
97
|
+
renderTabs: renderTabs,
|
98
|
+
value: tab,
|
99
|
+
element: elementProps,
|
100
|
+
onChange: onElementPropsChange,
|
101
|
+
customProps: customProps
|
102
|
+
})]
|
103
|
+
}), /*#__PURE__*/_jsxs(DialogActions, {
|
104
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
105
|
+
onClick: onClose,
|
106
|
+
children: "Cancel"
|
107
|
+
}), /*#__PURE__*/_jsx(Button, {
|
108
|
+
onClick: handleSave,
|
109
|
+
children: "Save"
|
110
|
+
})]
|
111
|
+
})]
|
112
|
+
});
|
113
|
+
};
|
114
|
+
export default StyleBuilder;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
const tableStyle = [{
|
2
|
+
tab: "Table",
|
3
|
+
value: "tableSettings",
|
4
|
+
fields: [{
|
5
|
+
label: "Table Background",
|
6
|
+
key: "table.bgColor",
|
7
|
+
type: "color"
|
8
|
+
}, {
|
9
|
+
label: "Border",
|
10
|
+
key: "table.borderColor",
|
11
|
+
type: "color"
|
12
|
+
}]
|
13
|
+
}, {
|
14
|
+
tab: "Row",
|
15
|
+
value: "rowSettings",
|
16
|
+
fields: [{
|
17
|
+
label: "Background",
|
18
|
+
key: "row.bgColor",
|
19
|
+
type: "color"
|
20
|
+
}, {
|
21
|
+
label: "Border",
|
22
|
+
key: "row.borderColor",
|
23
|
+
type: "color"
|
24
|
+
}]
|
25
|
+
}, {
|
26
|
+
tab: "Column",
|
27
|
+
value: "columnSettings",
|
28
|
+
fields: [{
|
29
|
+
label: "Background",
|
30
|
+
key: "col.bgColor",
|
31
|
+
type: "color"
|
32
|
+
}, {
|
33
|
+
label: "Border",
|
34
|
+
key: "col.borderColor",
|
35
|
+
type: "color"
|
36
|
+
}]
|
37
|
+
}];
|
38
|
+
export default tableStyle;
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Grid, Button } from "@mui/material";
|
3
|
+
import CloudUploadIcon from "@mui/icons-material/CloudUpload";
|
4
|
+
import { convertBase64 } from "../utils/helper";
|
5
|
+
import { uploadFile } from "../service/fileupload";
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
8
|
+
const Uploader = props => {
|
9
|
+
const {
|
10
|
+
value,
|
11
|
+
data,
|
12
|
+
onUploaded,
|
13
|
+
customProps
|
14
|
+
} = props;
|
15
|
+
const {
|
16
|
+
key
|
17
|
+
} = data;
|
18
|
+
const [base64, setBase64] = useState(value);
|
19
|
+
const [uploading, setUploading] = useState(false);
|
20
|
+
const handleChange = async e => {
|
21
|
+
const file = e.target.files[0];
|
22
|
+
const strImage = await convertBase64(file);
|
23
|
+
setBase64(strImage);
|
24
|
+
doUpload(strImage);
|
25
|
+
};
|
26
|
+
const doUpload = async strImage => {
|
27
|
+
setUploading(true);
|
28
|
+
const result = await uploadFile({
|
29
|
+
image: strImage
|
30
|
+
}, customProps);
|
31
|
+
setUploading(false);
|
32
|
+
if (result && result?.imageURL) {
|
33
|
+
onUploaded({
|
34
|
+
[key]: result?.imageURL
|
35
|
+
});
|
36
|
+
}
|
37
|
+
};
|
38
|
+
const onRemoveBG = () => {
|
39
|
+
setBase64(null);
|
40
|
+
onUploaded({
|
41
|
+
[key]: "none"
|
42
|
+
});
|
43
|
+
};
|
44
|
+
return /*#__PURE__*/_jsxs(Grid, {
|
45
|
+
container: true,
|
46
|
+
padding: 3,
|
47
|
+
children: [/*#__PURE__*/_jsxs(Grid, {
|
48
|
+
item: true,
|
49
|
+
xs: 12,
|
50
|
+
style: {
|
51
|
+
display: "flex"
|
52
|
+
},
|
53
|
+
justifyContent: "center",
|
54
|
+
alignItems: "center",
|
55
|
+
children: [/*#__PURE__*/_jsxs(Button, {
|
56
|
+
component: "label",
|
57
|
+
variant: "contained",
|
58
|
+
startIcon: /*#__PURE__*/_jsx(CloudUploadIcon, {}),
|
59
|
+
children: ["Upload file", /*#__PURE__*/_jsx("input", {
|
60
|
+
type: "file",
|
61
|
+
style: {
|
62
|
+
opacity: 0
|
63
|
+
},
|
64
|
+
onChange: handleChange
|
65
|
+
})]
|
66
|
+
}), /*#__PURE__*/_jsx("input", {
|
67
|
+
type: "checkbox",
|
68
|
+
value: "none",
|
69
|
+
checked: value === "none",
|
70
|
+
onChange: onRemoveBG
|
71
|
+
}), " ", "None"]
|
72
|
+
}), uploading ? "Uploading..." : "", /*#__PURE__*/_jsx(Grid, {
|
73
|
+
item: true,
|
74
|
+
xs: 12,
|
75
|
+
style: {
|
76
|
+
marginTop: "12px",
|
77
|
+
width: "100%",
|
78
|
+
backgroundImage: base64 ? `url(${base64})` : "none",
|
79
|
+
backgroundSize: "contain",
|
80
|
+
backgroundRepeat: "no-repeat",
|
81
|
+
backgroundPosition: "center",
|
82
|
+
height: "100px"
|
83
|
+
}
|
84
|
+
})]
|
85
|
+
});
|
86
|
+
};
|
87
|
+
export default Uploader;
|
@@ -1,20 +1,27 @@
|
|
1
|
-
import { Transforms, Path, Node } from
|
1
|
+
import { Transforms, Path, Node } from "slate";
|
2
2
|
const withEmbeds = editor => {
|
3
3
|
const {
|
4
4
|
isVoid,
|
5
5
|
insertBreak
|
6
6
|
} = editor;
|
7
|
-
editor.isVoid = element =>
|
7
|
+
editor.isVoid = element => {
|
8
|
+
if (["video", "htmlCode"].includes(element.type)) {
|
9
|
+
return true;
|
10
|
+
} else if (element.type === "image") {
|
11
|
+
return true;
|
12
|
+
} else {
|
13
|
+
return isVoid(element);
|
14
|
+
}
|
15
|
+
};
|
8
16
|
editor.insertBreak = (...args) => {
|
9
17
|
const parentPath = Path.parent(editor.selection.focus.path);
|
10
18
|
const parentNode = Node.get(editor, parentPath);
|
11
|
-
// console.log(parentNode);
|
12
19
|
if (editor.isVoid(parentNode)) {
|
13
20
|
const nextPath = Path.next(parentPath);
|
14
21
|
Transforms.insertNodes(editor, {
|
15
|
-
type:
|
22
|
+
type: "paragraph",
|
16
23
|
children: [{
|
17
|
-
text:
|
24
|
+
text: ""
|
18
25
|
}]
|
19
26
|
}, {
|
20
27
|
at: nextPath,
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Editor, Range, Point, Element } from "slate";
|
2
|
+
const NON_DELETABLE_BLOCKS = ["table-cell", "carousel-item"];
|
2
3
|
const withTable = editor => {
|
3
4
|
const {
|
4
5
|
deleteBackward,
|
@@ -10,12 +11,12 @@ const withTable = editor => {
|
|
10
11
|
} = editor;
|
11
12
|
if (selection) {
|
12
13
|
const [cell] = Editor.nodes(editor, {
|
13
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type
|
14
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && NON_DELETABLE_BLOCKS.indexOf(n.type) > -1
|
14
15
|
});
|
15
16
|
const prevNodePath = Editor.before(editor, selection);
|
16
17
|
const [tableNode] = Editor.nodes(editor, {
|
17
18
|
at: prevNodePath,
|
18
|
-
match: n => !Editor.isEditor(n) && Element.isElement && n.type
|
19
|
+
match: n => !Editor.isEditor(n) && Element.isElement && NON_DELETABLE_BLOCKS.indexOf(n.type) > -1
|
19
20
|
});
|
20
21
|
if (cell) {
|
21
22
|
const [, cellPath] = cell;
|
@@ -36,12 +37,12 @@ const withTable = editor => {
|
|
36
37
|
} = editor;
|
37
38
|
if (selection && Range.isCollapsed(selection)) {
|
38
39
|
const [cell] = Editor.nodes(editor, {
|
39
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type
|
40
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && NON_DELETABLE_BLOCKS.indexOf(n.type) > -1
|
40
41
|
});
|
41
42
|
const prevNodePath = Editor.after(editor, selection);
|
42
43
|
const [tableNode] = Editor.nodes(editor, {
|
43
44
|
at: prevNodePath,
|
44
|
-
match: n => !Editor.isEditor(n) && Element.isElement && n.type
|
45
|
+
match: n => !Editor.isEditor(n) && Element.isElement && NON_DELETABLE_BLOCKS.indexOf(n.type) > -1
|
45
46
|
});
|
46
47
|
if (cell) {
|
47
48
|
const [, cellPath] = cell;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export const uploadFile = async (formData, props) => {
|
2
|
+
try {
|
3
|
+
const response = await fetch(`${props.API_HOST}/api/v1/general/notes/file_upload`, {
|
4
|
+
method: "POST",
|
5
|
+
headers: {
|
6
|
+
"Content-Type": "application/json",
|
7
|
+
Authorization: `Bearer ${props.token}`
|
8
|
+
},
|
9
|
+
body: JSON.stringify(formData)
|
10
|
+
});
|
11
|
+
const result = await response.json();
|
12
|
+
return result.data;
|
13
|
+
} catch (err) {
|
14
|
+
console.log(err);
|
15
|
+
return err;
|
16
|
+
}
|
17
|
+
};
|