@flozy/editor 1.1.5 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CollaborativeEditor.js +6 -1
- package/dist/Editor/CommonEditor.js +17 -3
- package/dist/Editor/Editor.css +15 -3
- package/dist/Editor/Elements/AppHeader/AppHeader.js +221 -0
- package/dist/Editor/Elements/AppHeader/AppHeaderButton.js +19 -0
- package/dist/Editor/Elements/AppHeader/AppHeaderPopup.js +20 -0
- package/dist/Editor/Elements/Button/EditorButton.js +3 -3
- package/dist/Editor/Elements/Carousel/Carousel.js +19 -5
- package/dist/Editor/Elements/Carousel/CarouselItem.js +5 -1
- package/dist/Editor/Elements/ChipText/ChipText.js +44 -0
- package/dist/Editor/Elements/ChipText/ChipTextButton.js +64 -0
- package/dist/Editor/Elements/ChipText/ChipTextPopup.js +24 -0
- package/dist/Editor/Elements/DrawerMenu/DrawerMenu.js +66 -0
- package/dist/Editor/Elements/DrawerMenu/DrawerMenuButton.js +21 -0
- package/dist/Editor/Elements/Link/Link.js +5 -5
- package/dist/Editor/Elements/Link/LinkButton.js +50 -37
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +27 -21
- package/dist/Editor/Elements/Table/Table.js +160 -10
- package/dist/Editor/Elements/Table/TableCell.js +55 -143
- package/dist/Editor/Elements/Table/table.css +13 -0
- package/dist/Editor/Toolbar/Toolbar.js +18 -0
- package/dist/Editor/Toolbar/toolbarGroups.js +9 -0
- package/dist/Editor/common/ColorPickerButton.js +65 -0
- package/dist/Editor/common/StyleBuilder/appHeaderStyle.js +63 -0
- package/dist/Editor/common/StyleBuilder/chipTextStyle.js +35 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +8 -14
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +114 -0
- package/dist/Editor/common/StyleBuilder/index.js +8 -3
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +20 -0
- package/dist/Editor/plugins/withLinks.js +40 -2
- package/dist/Editor/plugins/withTable.js +10 -1
- package/dist/Editor/utils/SlateUtilityFunctions.js +15 -0
- package/dist/Editor/utils/customHooks/useTableResize.js +46 -0
- package/dist/Editor/utils/insertAppHeader.js +55 -0
- package/dist/Editor/utils/insertChipText.js +49 -0
- package/dist/Editor/utils/insertDrawerMenu.js +52 -0
- package/dist/Editor/utils/serializer.js +26 -16
- package/dist/Editor/utils/table.js +26 -3
- package/package.json +2 -1
@@ -23,6 +23,9 @@ import SignatureButton from "../Elements/Signature/SignatureButton";
|
|
23
23
|
import ButtonToolIcon from "../Elements/Button/ButtonToolIcon";
|
24
24
|
import PageSettingsButton from "../Elements/PageSettings/PageSettingsButton";
|
25
25
|
import CarouselButton from "../Elements/Carousel/CarouselButton";
|
26
|
+
import ChipTextButton from "../Elements/ChipText/ChipTextButton";
|
27
|
+
import DrawerMenuButton from "../Elements/DrawerMenu/DrawerMenuButton";
|
28
|
+
import AppHeaderButton from "../Elements/AppHeader/AppHeaderButton";
|
26
29
|
import { jsx as _jsx } from "react/jsx-runtime";
|
27
30
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
28
31
|
const Toolbar = props => {
|
@@ -186,6 +189,21 @@ const Toolbar = props => {
|
|
186
189
|
return /*#__PURE__*/_jsx(CarouselButton, {
|
187
190
|
editor: editor
|
188
191
|
}, element.id);
|
192
|
+
case "chip-text":
|
193
|
+
return /*#__PURE__*/_jsx(ChipTextButton, {
|
194
|
+
editor: editor,
|
195
|
+
customProps: customProps
|
196
|
+
}, element.id);
|
197
|
+
case "drawer":
|
198
|
+
return /*#__PURE__*/_jsx(DrawerMenuButton, {
|
199
|
+
editor: editor,
|
200
|
+
customProps: customProps
|
201
|
+
}, element.id);
|
202
|
+
case "app-header":
|
203
|
+
return /*#__PURE__*/_jsx(AppHeaderButton, {
|
204
|
+
editor: editor,
|
205
|
+
customProps: customProps
|
206
|
+
}, element.id);
|
189
207
|
default:
|
190
208
|
return null;
|
191
209
|
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Grid, Button, Popover } from "@mui/material";
|
3
|
+
import ColorPicker from "react-best-gradient-color-picker";
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
6
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
7
|
+
const ColorPickerButton = props => {
|
8
|
+
const {
|
9
|
+
value,
|
10
|
+
onSave
|
11
|
+
} = props;
|
12
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
13
|
+
const [color, setColor] = useState(value);
|
14
|
+
const open = Boolean(anchorEl);
|
15
|
+
const handleColorPicker = e => {
|
16
|
+
setAnchorEl(e.currentTarget);
|
17
|
+
};
|
18
|
+
const handleSave = () => {
|
19
|
+
onSave(color);
|
20
|
+
handleClose();
|
21
|
+
};
|
22
|
+
const handleClose = () => {
|
23
|
+
setAnchorEl(null);
|
24
|
+
};
|
25
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
26
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
27
|
+
style: {
|
28
|
+
background: value,
|
29
|
+
height: "32px",
|
30
|
+
border: "1px solid #000"
|
31
|
+
},
|
32
|
+
onClick: handleColorPicker
|
33
|
+
}), /*#__PURE__*/_jsx(Popover, {
|
34
|
+
open: open,
|
35
|
+
anchorEl: anchorEl,
|
36
|
+
onClose: handleClose,
|
37
|
+
children: /*#__PURE__*/_jsx(Grid, {
|
38
|
+
container: true,
|
39
|
+
padding: 2,
|
40
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
41
|
+
item: true,
|
42
|
+
xs: 12,
|
43
|
+
children: [/*#__PURE__*/_jsx(ColorPicker, {
|
44
|
+
value: color,
|
45
|
+
onChange: setColor
|
46
|
+
}), /*#__PURE__*/_jsxs("div", {
|
47
|
+
style: {
|
48
|
+
display: "flex",
|
49
|
+
justifyContent: "end",
|
50
|
+
marginTop: "16px"
|
51
|
+
},
|
52
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
53
|
+
onClick: handleClose,
|
54
|
+
children: "Cancel"
|
55
|
+
}), /*#__PURE__*/_jsx(Button, {
|
56
|
+
onClick: handleSave,
|
57
|
+
children: "Save"
|
58
|
+
})]
|
59
|
+
})]
|
60
|
+
})
|
61
|
+
})
|
62
|
+
})]
|
63
|
+
});
|
64
|
+
};
|
65
|
+
export default ColorPickerButton;
|
@@ -0,0 +1,63 @@
|
|
1
|
+
const appHeaderStyle = [{
|
2
|
+
tab: "Logo",
|
3
|
+
value: "appLogo",
|
4
|
+
fields: [{
|
5
|
+
label: "App Logo URL",
|
6
|
+
key: "appLogo",
|
7
|
+
type: "text"
|
8
|
+
}, {
|
9
|
+
label: "App Logo",
|
10
|
+
key: "appLogo",
|
11
|
+
type: "backgroundImage"
|
12
|
+
}]
|
13
|
+
}, {
|
14
|
+
tab: "Title",
|
15
|
+
value: "appTitle",
|
16
|
+
fields: [{
|
17
|
+
label: "App Title",
|
18
|
+
key: "appTitle",
|
19
|
+
type: "text"
|
20
|
+
}]
|
21
|
+
}, {
|
22
|
+
tab: "Menus",
|
23
|
+
value: "menus",
|
24
|
+
fields: [{
|
25
|
+
label: "Menus",
|
26
|
+
key: "menus",
|
27
|
+
type: "menusArray"
|
28
|
+
}]
|
29
|
+
}, {
|
30
|
+
tab: "Banner Spacing",
|
31
|
+
value: "bannerSpacing",
|
32
|
+
fields: [{
|
33
|
+
label: "Banner Spacing",
|
34
|
+
key: "bannerSpacing",
|
35
|
+
type: "bannerSpacing"
|
36
|
+
}]
|
37
|
+
}, {
|
38
|
+
tab: "Border Radius",
|
39
|
+
value: "borderRadius",
|
40
|
+
fields: [{
|
41
|
+
label: "Border Radius",
|
42
|
+
key: "borderRadius",
|
43
|
+
type: "borderRadius"
|
44
|
+
}]
|
45
|
+
}, {
|
46
|
+
tab: "Colors",
|
47
|
+
value: "colors",
|
48
|
+
fields: [{
|
49
|
+
label: "Text",
|
50
|
+
key: "textColor",
|
51
|
+
type: "color",
|
52
|
+
needPreview: true
|
53
|
+
}, {
|
54
|
+
label: "Background",
|
55
|
+
key: "bgColor",
|
56
|
+
type: "color"
|
57
|
+
}, {
|
58
|
+
label: "Border",
|
59
|
+
key: "borderColor",
|
60
|
+
type: "color"
|
61
|
+
}]
|
62
|
+
}];
|
63
|
+
export default appHeaderStyle;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
const chipTextStyle = [{
|
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
|
+
export default chipTextStyle;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { Grid, TextField, InputAdornment } from "@mui/material";
|
3
|
+
import ColorPickerButton from "../../ColorPickerButton";
|
3
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
4
5
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
5
6
|
const Color = props => {
|
@@ -19,9 +20,9 @@ const Color = props => {
|
|
19
20
|
bgColor,
|
20
21
|
borderColor
|
21
22
|
} = elementProps;
|
22
|
-
const
|
23
|
+
const onSave = color => {
|
23
24
|
onChange({
|
24
|
-
[key]:
|
25
|
+
[key]: color
|
25
26
|
});
|
26
27
|
};
|
27
28
|
return /*#__PURE__*/_jsxs(Grid, {
|
@@ -35,7 +36,7 @@ const Color = props => {
|
|
35
36
|
style: {
|
36
37
|
padding: "8px",
|
37
38
|
color: textColor,
|
38
|
-
|
39
|
+
background: bgColor,
|
39
40
|
border: `1px solid ${borderColor}`
|
40
41
|
},
|
41
42
|
children: "Text Content"
|
@@ -66,19 +67,12 @@ const Color = props => {
|
|
66
67
|
shrink: true
|
67
68
|
},
|
68
69
|
InputProps: {
|
69
|
-
endAdornment: /*#__PURE__*/
|
70
|
+
endAdornment: /*#__PURE__*/_jsx(InputAdornment, {
|
70
71
|
position: "end",
|
71
|
-
children:
|
72
|
-
type: "color",
|
72
|
+
children: /*#__PURE__*/_jsx(ColorPickerButton, {
|
73
73
|
value: value,
|
74
|
-
|
75
|
-
|
76
|
-
}), /*#__PURE__*/_jsx("input", {
|
77
|
-
type: "checkbox",
|
78
|
-
onChange: handleChange,
|
79
|
-
value: "rgba(0,0,0,0)",
|
80
|
-
checked: value === "rgba(0,0,0,0)"
|
81
|
-
})]
|
74
|
+
onSave: onSave
|
75
|
+
})
|
82
76
|
})
|
83
77
|
}
|
84
78
|
})
|
@@ -7,6 +7,7 @@ import BackgroundImage from "./backgroundImage";
|
|
7
7
|
import GridSize from "./gridSize";
|
8
8
|
import ElementSize from "./elementSize";
|
9
9
|
import ImageTexts from "./imageTexts";
|
10
|
+
import MenusArray from "./menusArray";
|
10
11
|
const FieldMap = {
|
11
12
|
text: Text,
|
12
13
|
bannerSpacing: BannerSpacing,
|
@@ -16,6 +17,7 @@ const FieldMap = {
|
|
16
17
|
backgroundImage: BackgroundImage,
|
17
18
|
gridSize: GridSize,
|
18
19
|
elementSize: ElementSize,
|
19
|
-
imageTexts: ImageTexts
|
20
|
+
imageTexts: ImageTexts,
|
21
|
+
menusArray: MenusArray
|
20
22
|
};
|
21
23
|
export default FieldMap;
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Button, Grid, Radio, RadioGroup, TextField, FormControl, FormLabel, FormControlLabel } from "@mui/material";
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
4
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
5
|
+
const MenusArray = props => {
|
6
|
+
const {
|
7
|
+
value,
|
8
|
+
data,
|
9
|
+
elementProps,
|
10
|
+
onChange
|
11
|
+
} = props;
|
12
|
+
const {
|
13
|
+
key
|
14
|
+
} = data;
|
15
|
+
const {
|
16
|
+
menuStyle
|
17
|
+
} = elementProps || {
|
18
|
+
menuStyle: "stacked"
|
19
|
+
};
|
20
|
+
const handleChange = index => e => {
|
21
|
+
const upValue = [...(value || [])];
|
22
|
+
upValue[index] = {
|
23
|
+
...(upValue[index] || {}),
|
24
|
+
[e.target.name]: e.target.value
|
25
|
+
};
|
26
|
+
onChange({
|
27
|
+
[key]: upValue
|
28
|
+
});
|
29
|
+
};
|
30
|
+
const onAddMenu = () => {
|
31
|
+
onChange({
|
32
|
+
[key]: [...value, {
|
33
|
+
...value[0]
|
34
|
+
}]
|
35
|
+
});
|
36
|
+
};
|
37
|
+
const onDelete = index => () => {
|
38
|
+
const upValue = [...(value || [])];
|
39
|
+
upValue.splice(index, 1);
|
40
|
+
onChange({
|
41
|
+
[key]: upValue
|
42
|
+
});
|
43
|
+
};
|
44
|
+
const handleVariant = e => {
|
45
|
+
onChange({
|
46
|
+
[e.target.name]: e.target.value
|
47
|
+
});
|
48
|
+
};
|
49
|
+
return /*#__PURE__*/_jsxs(Grid, {
|
50
|
+
container: true,
|
51
|
+
padding: 1,
|
52
|
+
spacing: 2,
|
53
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
54
|
+
item: true,
|
55
|
+
xs: 12,
|
56
|
+
children: /*#__PURE__*/_jsxs(FormControl, {
|
57
|
+
children: [/*#__PURE__*/_jsx(FormLabel, {
|
58
|
+
id: "demo-radio-buttons-group-label",
|
59
|
+
children: "Menu Variant"
|
60
|
+
}), /*#__PURE__*/_jsxs(RadioGroup, {
|
61
|
+
row: true,
|
62
|
+
"aria-labelledby": "demo-radio-buttons-group-label",
|
63
|
+
defaultValue: menuStyle,
|
64
|
+
value: menuStyle,
|
65
|
+
name: "menuStyle",
|
66
|
+
onChange: handleVariant,
|
67
|
+
children: [/*#__PURE__*/_jsx(FormControlLabel, {
|
68
|
+
value: "stacked",
|
69
|
+
checked: menuStyle === "stacked",
|
70
|
+
control: /*#__PURE__*/_jsx(Radio, {}),
|
71
|
+
label: "Stacked"
|
72
|
+
}), /*#__PURE__*/_jsx(FormControlLabel, {
|
73
|
+
value: "drawer",
|
74
|
+
checked: menuStyle === "drawer",
|
75
|
+
control: /*#__PURE__*/_jsx(Radio, {}),
|
76
|
+
label: "Drawer"
|
77
|
+
})]
|
78
|
+
})]
|
79
|
+
})
|
80
|
+
}), (value || []).map((m, i) => {
|
81
|
+
return /*#__PURE__*/_jsxs(Grid, {
|
82
|
+
item: true,
|
83
|
+
xs: 12,
|
84
|
+
children: [/*#__PURE__*/_jsx(TextField, {
|
85
|
+
name: "text",
|
86
|
+
type: "text",
|
87
|
+
value: m.text,
|
88
|
+
onChange: handleChange(i),
|
89
|
+
size: "small",
|
90
|
+
fullWidth: true
|
91
|
+
}), /*#__PURE__*/_jsx(TextField, {
|
92
|
+
name: "url",
|
93
|
+
type: "text",
|
94
|
+
value: m.url,
|
95
|
+
onChange: handleChange(i),
|
96
|
+
size: "small",
|
97
|
+
fullWidth: true
|
98
|
+
}), /*#__PURE__*/_jsx(Button, {
|
99
|
+
onClick: onDelete(i),
|
100
|
+
color: "error",
|
101
|
+
children: "Delete"
|
102
|
+
})]
|
103
|
+
}, `add-m-${i}`);
|
104
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
105
|
+
item: true,
|
106
|
+
xs: 12,
|
107
|
+
children: /*#__PURE__*/_jsx(Button, {
|
108
|
+
onClick: onAddMenu,
|
109
|
+
children: "+ Add"
|
110
|
+
})
|
111
|
+
})]
|
112
|
+
});
|
113
|
+
};
|
114
|
+
export default MenusArray;
|
@@ -66,6 +66,7 @@ const StyleBuilder = props => {
|
|
66
66
|
element,
|
67
67
|
onSave,
|
68
68
|
onClose,
|
69
|
+
onDelete,
|
69
70
|
customProps
|
70
71
|
} = props;
|
71
72
|
const [elementProps, setElementProps] = useState(element);
|
@@ -86,8 +87,8 @@ const StyleBuilder = props => {
|
|
86
87
|
return /*#__PURE__*/_jsxs(Dialog, {
|
87
88
|
open: true,
|
88
89
|
fullWidth: true,
|
89
|
-
children: [/*#__PURE__*/
|
90
|
-
children: title
|
90
|
+
children: [/*#__PURE__*/_jsxs(DialogTitle, {
|
91
|
+
children: [title, " "]
|
91
92
|
}), /*#__PURE__*/_jsxs(DialogContent, {
|
92
93
|
children: [/*#__PURE__*/_jsx(StyleTabs, {
|
93
94
|
renderTabs: renderTabs,
|
@@ -101,7 +102,11 @@ const StyleBuilder = props => {
|
|
101
102
|
customProps: customProps
|
102
103
|
})]
|
103
104
|
}), /*#__PURE__*/_jsxs(DialogActions, {
|
104
|
-
children: [/*#__PURE__*/_jsx(Button, {
|
105
|
+
children: [onDelete ? /*#__PURE__*/_jsx(Button, {
|
106
|
+
onClick: onDelete,
|
107
|
+
color: "error",
|
108
|
+
children: "Delete"
|
109
|
+
}) : null, /*#__PURE__*/_jsx(Button, {
|
105
110
|
onClick: onClose,
|
106
111
|
children: "Cancel"
|
107
112
|
}), /*#__PURE__*/_jsx(Button, {
|
@@ -2,9 +2,29 @@ const pageSettingsStyle = [{
|
|
2
2
|
tab: "Colors",
|
3
3
|
value: "colors",
|
4
4
|
fields: [{
|
5
|
+
label: "Text",
|
6
|
+
key: "color",
|
7
|
+
type: "color"
|
8
|
+
}, {
|
9
|
+
label: "Background URL",
|
10
|
+
key: "pageColor",
|
11
|
+
type: "text"
|
12
|
+
}, {
|
13
|
+
label: "Background Image",
|
14
|
+
key: "pageColor",
|
15
|
+
type: "backgroundImage"
|
16
|
+
}, {
|
5
17
|
label: "Background",
|
6
18
|
key: "pageColor",
|
7
19
|
type: "color"
|
8
20
|
}]
|
21
|
+
}, {
|
22
|
+
tab: "Spacing",
|
23
|
+
value: "spacing",
|
24
|
+
fields: [{
|
25
|
+
label: "bannerSpacing",
|
26
|
+
key: "bannerSpacing",
|
27
|
+
type: "bannerSpacing"
|
28
|
+
}]
|
9
29
|
}];
|
10
30
|
export default pageSettingsStyle;
|
@@ -1,8 +1,46 @@
|
|
1
|
+
import { Transforms, Element, Node } from "slate";
|
2
|
+
const INLINE_ELLEMENTS = ["link", "chip-text", "drawer"];
|
1
3
|
const withLinks = editor => {
|
2
4
|
const {
|
3
|
-
isInline
|
5
|
+
isInline,
|
6
|
+
deleteBackward,
|
7
|
+
normalizeNode
|
4
8
|
} = editor;
|
5
|
-
editor.isInline = element => element.type
|
9
|
+
editor.isInline = element => INLINE_ELLEMENTS.indexOf(element.type) > -1 ? true : isInline(element);
|
10
|
+
|
11
|
+
// remove empty inline
|
12
|
+
editor.normalizeNode = entry => {
|
13
|
+
const [node, path] = entry;
|
14
|
+
if (Element.isElement(node) && node.type === "paragraph") {
|
15
|
+
const children = Array.from(Node.children(editor, path));
|
16
|
+
for (const [child, childPath] of children) {
|
17
|
+
// remove link nodes whose text value is empty string.
|
18
|
+
// empty text links happen when you move from link to next line or delete link line.
|
19
|
+
if (Element.isElement(child) && INLINE_ELLEMENTS.indexOf(child.type) > -1 && child.children[0].text === "") {
|
20
|
+
if (children.length === 1) {
|
21
|
+
Transforms.removeNodes(editor, {
|
22
|
+
at: path
|
23
|
+
});
|
24
|
+
Transforms.insertNodes(editor, {
|
25
|
+
type: "paragraph",
|
26
|
+
children: [{
|
27
|
+
text: ""
|
28
|
+
}]
|
29
|
+
});
|
30
|
+
} else {
|
31
|
+
Transforms.removeNodes(editor, {
|
32
|
+
at: childPath
|
33
|
+
});
|
34
|
+
}
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
normalizeNode(entry);
|
40
|
+
};
|
41
|
+
editor.deleteBackward = unit => {
|
42
|
+
deleteBackward(unit);
|
43
|
+
};
|
6
44
|
return editor;
|
7
45
|
};
|
8
46
|
export default withLinks;
|
@@ -1,10 +1,19 @@
|
|
1
|
-
import { Editor, Range, Point, Element } from "slate";
|
1
|
+
import { Editor, Range, Point, Element, Transforms } from "slate";
|
2
2
|
const NON_DELETABLE_BLOCKS = ["table-cell", "carousel-item"];
|
3
3
|
const withTable = editor => {
|
4
4
|
const {
|
5
5
|
deleteBackward,
|
6
6
|
deleteForward
|
7
7
|
} = editor;
|
8
|
+
editor.insertData = data => {
|
9
|
+
try {
|
10
|
+
const text = data.getData("text/plain");
|
11
|
+
Transforms.insertText(editor, text);
|
12
|
+
return;
|
13
|
+
} catch (err) {
|
14
|
+
console.log(err);
|
15
|
+
}
|
16
|
+
};
|
8
17
|
editor.deleteBackward = unit => {
|
9
18
|
const {
|
10
19
|
selection
|
@@ -21,6 +21,9 @@ import Carousel from "../Elements/Carousel/Carousel";
|
|
21
21
|
import CarouselItem from "../Elements/Carousel/CarouselItem";
|
22
22
|
import ImageTextWrapper from "../Elements/ImageText/ImageTextWrapper";
|
23
23
|
import ImageText from "../Elements/ImageText/ImageText";
|
24
|
+
import ChipText from "../Elements/ChipText/ChipText";
|
25
|
+
import DrawerMenu from "../Elements/DrawerMenu/DrawerMenu";
|
26
|
+
import AppHeader from "../Elements/AppHeader/AppHeader";
|
24
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
25
28
|
const alignment = ["alignLeft", "alignRight", "alignCenter"];
|
26
29
|
const list_types = ["orderedList", "unorderedList"];
|
@@ -343,6 +346,18 @@ export const getBlock = props => {
|
|
343
346
|
return /*#__PURE__*/_jsx(CarouselItem, {
|
344
347
|
...props
|
345
348
|
});
|
349
|
+
case "chip-text":
|
350
|
+
return /*#__PURE__*/_jsx(ChipText, {
|
351
|
+
...props
|
352
|
+
});
|
353
|
+
case "drawer":
|
354
|
+
return /*#__PURE__*/_jsx(DrawerMenu, {
|
355
|
+
...props
|
356
|
+
});
|
357
|
+
case "app-header":
|
358
|
+
return /*#__PURE__*/_jsx(AppHeader, {
|
359
|
+
...props
|
360
|
+
});
|
346
361
|
default:
|
347
362
|
return /*#__PURE__*/_jsx("div", {
|
348
363
|
...element.attr,
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { useState } from "react";
|
2
|
+
const useTableResize = ({
|
3
|
+
parentDOM,
|
4
|
+
size: defaultSize
|
5
|
+
}) => {
|
6
|
+
const {
|
7
|
+
width
|
8
|
+
} = parentDOM?.getBoundingClientRect() || {
|
9
|
+
...defaultSize
|
10
|
+
};
|
11
|
+
const [size, setSize] = useState({
|
12
|
+
height: 300,
|
13
|
+
widthInPercent: 100,
|
14
|
+
...defaultSize
|
15
|
+
});
|
16
|
+
const [resizing, setResizing] = useState(false);
|
17
|
+
const onLoad = defaultSize => {
|
18
|
+
setSize({
|
19
|
+
widthInPercent: 100,
|
20
|
+
height: 300,
|
21
|
+
...defaultSize
|
22
|
+
});
|
23
|
+
};
|
24
|
+
const onMouseDown = () => {
|
25
|
+
document.addEventListener("pointermove", onMouseMove);
|
26
|
+
document.addEventListener("pointerup", onMouseUp);
|
27
|
+
setResizing(true);
|
28
|
+
};
|
29
|
+
const onMouseUp = () => {
|
30
|
+
document.removeEventListener("pointermove", onMouseMove);
|
31
|
+
document.removeEventListener("pointerup", onMouseUp);
|
32
|
+
setResizing(false);
|
33
|
+
};
|
34
|
+
const onMouseMove = e => {
|
35
|
+
setSize(currentSize => {
|
36
|
+
const calcWidth = currentSize?.width + e.movementX;
|
37
|
+
return {
|
38
|
+
width: calcWidth,
|
39
|
+
height: currentSize.height + e.movementY,
|
40
|
+
widthInPercent: calcWidth / width * 100
|
41
|
+
};
|
42
|
+
});
|
43
|
+
};
|
44
|
+
return [size, onMouseDown, resizing, onLoad];
|
45
|
+
};
|
46
|
+
export default useTableResize;
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { Editor, Transforms, Path, Range, Element } from "slate";
|
2
|
+
export const createAppHeaderNode = ({
|
3
|
+
menus
|
4
|
+
}) => ({
|
5
|
+
type: "app-header",
|
6
|
+
appTitle: "Title",
|
7
|
+
appLogo: "https://upload.wikimedia.org/wikipedia/commons/thumb/0/08/Netflix_2015_logo.svg/1200px-Netflix_2015_logo.svg.png",
|
8
|
+
menus: !menus ? [{
|
9
|
+
type: "menu",
|
10
|
+
url: "https://www.google.com",
|
11
|
+
target: "_blank",
|
12
|
+
text: "Google"
|
13
|
+
}] : menus,
|
14
|
+
menuStyle: "drawer",
|
15
|
+
children: [{
|
16
|
+
text: ""
|
17
|
+
}]
|
18
|
+
});
|
19
|
+
export const insertAppHeader = (editor, props) => {
|
20
|
+
const {
|
21
|
+
selection
|
22
|
+
} = editor;
|
23
|
+
const appHeader = createAppHeaderNode(props || {});
|
24
|
+
if (!!selection) {
|
25
|
+
const [parent, parentPath] = Editor.parent(editor, selection.focus.path);
|
26
|
+
if (editor.isVoid(parent)) {
|
27
|
+
Transforms.insertNodes(editor, {
|
28
|
+
type: "paragraph",
|
29
|
+
children: [appHeader]
|
30
|
+
}, {
|
31
|
+
at: Path.next(parentPath),
|
32
|
+
select: true
|
33
|
+
});
|
34
|
+
} else if (Range.isCollapsed(selection)) {
|
35
|
+
Transforms.insertNodes(editor, appHeader, {
|
36
|
+
select: true
|
37
|
+
});
|
38
|
+
} else {
|
39
|
+
Transforms.wrapNodes(editor, appHeader, {
|
40
|
+
split: true
|
41
|
+
});
|
42
|
+
}
|
43
|
+
} else {
|
44
|
+
Transforms.insertNodes(editor, {
|
45
|
+
type: "paragraph",
|
46
|
+
children: [appHeader]
|
47
|
+
});
|
48
|
+
}
|
49
|
+
};
|
50
|
+
export const removeAppHeader = (editor, path) => {
|
51
|
+
Transforms.unwrapNodes(editor, {
|
52
|
+
at: path,
|
53
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "app-header"
|
54
|
+
});
|
55
|
+
};
|