@flozy/editor 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/Editor/CollaborativeEditor.js +6 -1
  2. package/dist/Editor/CommonEditor.js +17 -3
  3. package/dist/Editor/Editor.css +15 -3
  4. package/dist/Editor/Elements/AppHeader/AppHeader.js +221 -0
  5. package/dist/Editor/Elements/AppHeader/AppHeaderButton.js +19 -0
  6. package/dist/Editor/Elements/AppHeader/AppHeaderPopup.js +20 -0
  7. package/dist/Editor/Elements/Button/EditorButton.js +3 -3
  8. package/dist/Editor/Elements/Carousel/Carousel.js +19 -5
  9. package/dist/Editor/Elements/Carousel/CarouselItem.js +5 -1
  10. package/dist/Editor/Elements/ChipText/ChipText.js +44 -0
  11. package/dist/Editor/Elements/ChipText/ChipTextButton.js +64 -0
  12. package/dist/Editor/Elements/ChipText/ChipTextPopup.js +24 -0
  13. package/dist/Editor/Elements/DrawerMenu/DrawerMenu.js +66 -0
  14. package/dist/Editor/Elements/DrawerMenu/DrawerMenuButton.js +21 -0
  15. package/dist/Editor/Elements/Link/Link.js +5 -5
  16. package/dist/Editor/Elements/Link/LinkButton.js +50 -37
  17. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +27 -21
  18. package/dist/Editor/Elements/Table/Table.js +160 -10
  19. package/dist/Editor/Elements/Table/TableCell.js +55 -143
  20. package/dist/Editor/Elements/Table/table.css +13 -0
  21. package/dist/Editor/Toolbar/Toolbar.js +18 -0
  22. package/dist/Editor/Toolbar/toolbarGroups.js +9 -0
  23. package/dist/Editor/common/ColorPickerButton.js +65 -0
  24. package/dist/Editor/common/StyleBuilder/appHeaderStyle.js +63 -0
  25. package/dist/Editor/common/StyleBuilder/chipTextStyle.js +35 -0
  26. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +8 -14
  27. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
  28. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +114 -0
  29. package/dist/Editor/common/StyleBuilder/index.js +8 -3
  30. package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +20 -0
  31. package/dist/Editor/plugins/withLinks.js +40 -2
  32. package/dist/Editor/plugins/withTable.js +10 -1
  33. package/dist/Editor/utils/SlateUtilityFunctions.js +15 -0
  34. package/dist/Editor/utils/customHooks/useTableResize.js +46 -0
  35. package/dist/Editor/utils/insertAppHeader.js +55 -0
  36. package/dist/Editor/utils/insertChipText.js +49 -0
  37. package/dist/Editor/utils/insertDrawerMenu.js +52 -0
  38. package/dist/Editor/utils/serializer.js +26 -16
  39. package/dist/Editor/utils/table.js +26 -3
  40. package/package.json +2 -1
@@ -23,6 +23,7 @@ const CollaborativeEditor = props => {
23
23
  });
24
24
  const [value] = useState(convertedContent);
25
25
  const [connected, setConnected] = useState(null);
26
+ const [message, setMessage] = useState("");
26
27
  const [authenticated, setAuthenticated] = useState({
27
28
  status: null,
28
29
  scope: null
@@ -100,12 +101,16 @@ const CollaborativeEditor = props => {
100
101
  setConnected(false);
101
102
  });
102
103
  provider.on("close", () => {
104
+ provider.disconnect();
105
+ provider.destroy();
103
106
  setConnected(false);
107
+ setMessage("Seems your connection is lost... Reload the page to edit the document...");
108
+ console.log("closed", provider);
104
109
  });
105
110
  if (authenticated.status === null || !connected === null || !editor) {
106
111
  return /*#__PURE__*/_jsx("h1", {
107
112
  "data-status": connected,
108
- children: "Loading..."
113
+ children: message || "Loading..."
109
114
  });
110
115
  }
111
116
  return /*#__PURE__*/_jsx(CommonEditor, {
@@ -48,6 +48,16 @@ const CommonEditor = props => {
48
48
  const {
49
49
  pageProps
50
50
  } = pageSettings || {};
51
+ const {
52
+ bannerSpacing
53
+ } = pageProps || {
54
+ bannerSpacing: {
55
+ left: 8,
56
+ right: 8,
57
+ top: 8,
58
+ bottom: 8
59
+ }
60
+ };
51
61
  useEffect(() => {
52
62
  setValue(draftToSlate({
53
63
  data: content
@@ -74,7 +84,7 @@ const CommonEditor = props => {
74
84
  const isAstChange = editor.operations.some(op => "set_selection" !== op.type);
75
85
  if (isAstChange && onSave) {
76
86
  // send the value to onSave api
77
- onSave(JSON.stringify(value));
87
+ onSave(JSON.stringify(newValue));
78
88
  }
79
89
  };
80
90
  const customProps = {
@@ -137,8 +147,12 @@ const CommonEditor = props => {
137
147
  className: "editor-wrapper",
138
148
  style: {
139
149
  border: "1px solid #f3f3f3",
140
- backgroundColor: pageProps?.pageColor || "#FFF",
141
- padding: "8px 8px"
150
+ background: pageProps?.pageColor || "#FFF",
151
+ color: pageProps?.color || "#000",
152
+ paddingLeft: `${bannerSpacing?.left}px`,
153
+ paddingRight: `${bannerSpacing?.right}px`,
154
+ paddingTop: `${bannerSpacing?.top}px`,
155
+ paddingBottom: `${bannerSpacing?.bottom}px`
142
156
  },
143
157
  children: [/*#__PURE__*/_jsx(Editable, {
144
158
  readOnly: isReadOnly,
@@ -29,7 +29,7 @@ button{
29
29
  }
30
30
 
31
31
  table{
32
- width:100%;
32
+ /* width:100%; */
33
33
  }
34
34
  td{
35
35
  height: 50px;
@@ -286,14 +286,26 @@ html{
286
286
 
287
287
  .empty-carousel-wrapper {
288
288
  display: flex;
289
- flex-direction: row;
289
+ flex-direction: column;
290
290
  overflow-x: auto;
291
291
  }
292
292
  .empty-carousel-wrapper > div{
293
293
  display: flex;
294
294
  flex-direction: column;
295
- width: 100%;
296
295
  flex-shrink: 0;
296
+ border: 1px solid #000;
297
+ }
298
+ .empty-carousel-wrapper .carousel-item-inner {
299
+ width: 100%;
300
+ }
301
+
302
+ .editor-chip-text {
303
+ padding: 4px;
304
+ background-color: #CCC;
305
+ }
306
+
307
+ .drawer-menu {
308
+ display: inline-flex;
297
309
  }
298
310
 
299
311
  @media (max-width: 480px) {
@@ -0,0 +1,221 @@
1
+ import React, { useState } from "react";
2
+ import { useSlateStatic, ReactEditor } from "slate-react";
3
+ import { Transforms } from "slate";
4
+ import AppBar from "@mui/material/AppBar";
5
+ import Box from "@mui/material/Box";
6
+ import CssBaseline from "@mui/material/CssBaseline";
7
+ import Divider from "@mui/material/Divider";
8
+ import Drawer from "@mui/material/Drawer";
9
+ import IconButton from "@mui/material/IconButton";
10
+ import List from "@mui/material/List";
11
+ import ListItem from "@mui/material/ListItem";
12
+ import ListItemButton from "@mui/material/ListItemButton";
13
+ import ListItemText from "@mui/material/ListItemText";
14
+ import MenuIcon from "@mui/icons-material/Menu";
15
+ import Toolbar from "@mui/material/Toolbar";
16
+ import Typography from "@mui/material/Typography";
17
+ import Button from "@mui/material/Button";
18
+ import SettingsIcon from "@mui/icons-material/Settings";
19
+ import DeleteIcon from "@mui/icons-material/Delete";
20
+ import AppHeaderPopup from "./AppHeaderPopup";
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { jsxs as _jsxs } from "react/jsx-runtime";
23
+ const drawerWidth = 240;
24
+ function AppHeader(props) {
25
+ const [openSetttings, setOpenSettings] = useState(false);
26
+ const {
27
+ attributes,
28
+ element,
29
+ customProps
30
+ } = props;
31
+ const {
32
+ appTitle,
33
+ appLogo,
34
+ menus,
35
+ bgColor,
36
+ menuStyle
37
+ } = element;
38
+ const {
39
+ window
40
+ } = props;
41
+ const [mobileOpen, setMobileOpen] = React.useState(false);
42
+ const editor = useSlateStatic();
43
+ const path = ReactEditor.findPath(editor, element);
44
+ const isDrawer = menuStyle === "drawer";
45
+ const handleDrawerToggle = () => {
46
+ setMobileOpen(prevState => !prevState);
47
+ };
48
+ const onSettings = () => {
49
+ setOpenSettings(true);
50
+ };
51
+ const ToolBar = () => {
52
+ return customProps?.readOnly !== true ? /*#__PURE__*/_jsxs("div", {
53
+ className: "element-toolbar",
54
+ contentEditable: false,
55
+ style: {
56
+ top: "-38px"
57
+ },
58
+ children: [/*#__PURE__*/_jsx(IconButton, {
59
+ size: "small",
60
+ onClick: onSettings,
61
+ children: /*#__PURE__*/_jsx(SettingsIcon, {})
62
+ }), /*#__PURE__*/_jsx(IconButton, {
63
+ size: "small",
64
+ onClick: onDelete,
65
+ children: /*#__PURE__*/_jsx(DeleteIcon, {})
66
+ })]
67
+ }) : null;
68
+ };
69
+ const onSave = data => {
70
+ const updateData = {
71
+ ...data
72
+ };
73
+ delete updateData.children;
74
+ Transforms.setNodes(editor, updateData, {
75
+ at: path
76
+ });
77
+ onClose();
78
+ };
79
+ const onDelete = () => {
80
+ Transforms.removeNodes(editor, {
81
+ at: path
82
+ });
83
+ };
84
+ const onClose = () => {
85
+ setOpenSettings(false);
86
+ };
87
+ const drawer = /*#__PURE__*/_jsxs(Box, {
88
+ onClick: handleDrawerToggle,
89
+ sx: {
90
+ textAlign: "center"
91
+ },
92
+ children: [/*#__PURE__*/_jsx(Typography, {
93
+ variant: "h6",
94
+ sx: {
95
+ my: 2
96
+ },
97
+ children: appLogo && appLogo !== "none" ? /*#__PURE__*/_jsx("img", {
98
+ alt: `${appTitle} Logo`,
99
+ style: {
100
+ height: "40px",
101
+ width: "auto"
102
+ },
103
+ src: appLogo
104
+ }) : appTitle
105
+ }), /*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsx(List, {
106
+ children: menus.map(item => /*#__PURE__*/_jsx(ListItem, {
107
+ disablePadding: true,
108
+ children: /*#__PURE__*/_jsx(ListItemButton, {
109
+ sx: {
110
+ textAlign: "center"
111
+ },
112
+ children: /*#__PURE__*/_jsx(ListItemText, {
113
+ primary: item.text
114
+ })
115
+ })
116
+ }, item.text))
117
+ })]
118
+ });
119
+ const container = window !== undefined ? () => window().document.body : undefined;
120
+ return /*#__PURE__*/_jsxs(Box, {
121
+ sx: {
122
+ display: "flex",
123
+ position: "relative"
124
+ },
125
+ ...attributes,
126
+ contentEditable: false,
127
+ children: [/*#__PURE__*/_jsx(CssBaseline, {}), /*#__PURE__*/_jsx(AppBar, {
128
+ component: "nav",
129
+ style: {
130
+ position: "relative",
131
+ background: bgColor
132
+ },
133
+ children: /*#__PURE__*/_jsxs(Toolbar, {
134
+ children: [/*#__PURE__*/_jsx(IconButton, {
135
+ color: "inherit",
136
+ "aria-label": "open drawer",
137
+ edge: "start",
138
+ onClick: handleDrawerToggle,
139
+ sx: {
140
+ mr: 2,
141
+ display: {
142
+ sm: "none"
143
+ }
144
+ },
145
+ children: /*#__PURE__*/_jsx(MenuIcon, {})
146
+ }), /*#__PURE__*/_jsxs(Typography, {
147
+ variant: "h6",
148
+ component: "div",
149
+ style: {
150
+ display: "inline-flex",
151
+ alignItems: "center"
152
+ },
153
+ sx: {
154
+ flexGrow: 1,
155
+ display: {
156
+ xs: "none",
157
+ sm: "block"
158
+ }
159
+ },
160
+ children: [appLogo && appLogo !== "none" ? /*#__PURE__*/_jsx("img", {
161
+ alt: `${appTitle} Logo`,
162
+ style: {
163
+ height: "40px",
164
+ width: "auto"
165
+ },
166
+ src: appLogo
167
+ }) : null, "\xA0", appTitle]
168
+ }), /*#__PURE__*/_jsxs(Box, {
169
+ sx: {
170
+ display: {
171
+ xs: "none",
172
+ sm: "block"
173
+ }
174
+ },
175
+ children: [isDrawer ? /*#__PURE__*/_jsx(IconButton, {
176
+ color: "inherit",
177
+ "aria-label": "open drawer",
178
+ edge: "start",
179
+ onClick: handleDrawerToggle,
180
+ children: /*#__PURE__*/_jsx(MenuIcon, {})
181
+ }) : null, !isDrawer ? menus.map(item => /*#__PURE__*/_jsx(Button, {
182
+ component: "a",
183
+ href: item.href,
184
+ sx: {
185
+ color: "#fff"
186
+ },
187
+ children: item.text
188
+ }, item)) : null]
189
+ })]
190
+ })
191
+ }), /*#__PURE__*/_jsx("nav", {
192
+ children: /*#__PURE__*/_jsx(Drawer, {
193
+ container: container,
194
+ variant: "temporary",
195
+ open: mobileOpen,
196
+ onClose: handleDrawerToggle,
197
+ ModalProps: {
198
+ keepMounted: true // Better open performance on mobile.
199
+ },
200
+
201
+ sx: {
202
+ display: {
203
+ xs: "block",
204
+ sm: isDrawer ? "block" : "none"
205
+ },
206
+ "& .MuiDrawer-paper": {
207
+ boxSizing: "border-box",
208
+ width: drawerWidth
209
+ }
210
+ },
211
+ children: drawer
212
+ })
213
+ }), /*#__PURE__*/_jsx(ToolBar, {}), openSetttings ? /*#__PURE__*/_jsx(AppHeaderPopup, {
214
+ element: element,
215
+ onSave: onSave,
216
+ onClose: onClose,
217
+ customProps: customProps
218
+ }) : null]
219
+ });
220
+ }
221
+ export default AppHeader;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import { IconButton } from "@mui/material";
3
+ import ViewDayIcon from "@mui/icons-material/ViewDay";
4
+ import { insertAppHeader } from "../../utils/insertAppHeader";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const AppHeaderButton = props => {
7
+ const {
8
+ editor
9
+ } = props;
10
+ const handleClick = () => {
11
+ insertAppHeader(editor, {});
12
+ };
13
+ return /*#__PURE__*/_jsx(IconButton, {
14
+ title: "App Header",
15
+ onClick: handleClick,
16
+ children: /*#__PURE__*/_jsx(ViewDayIcon, {})
17
+ });
18
+ };
19
+ export default AppHeaderButton;
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import StyleBuilder from "../../common/StyleBuilder";
3
+ import appHeaderStyle from "../../common/StyleBuilder/appHeaderStyle";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const AppHeaderPopup = props => {
6
+ const {
7
+ element,
8
+ onSave,
9
+ onClose
10
+ } = props;
11
+ return /*#__PURE__*/_jsx(StyleBuilder, {
12
+ title: "App Header",
13
+ type: "gridItemStyle",
14
+ element: element,
15
+ onSave: onSave,
16
+ onClose: onClose,
17
+ renderTabs: appHeaderStyle
18
+ });
19
+ };
20
+ export default AppHeaderPopup;
@@ -56,7 +56,7 @@ const EditorButton = props => {
56
56
  return;
57
57
  case "delete":
58
58
  Transforms.removeNodes(editor, {
59
- at: [path]
59
+ at: [...path]
60
60
  });
61
61
  return;
62
62
  default:
@@ -71,7 +71,7 @@ const EditorButton = props => {
71
71
  Transforms.setNodes(editor, {
72
72
  ...updateData
73
73
  }, {
74
- at: [path]
74
+ at: [...path]
75
75
  });
76
76
  setEdit(false);
77
77
  };
@@ -87,7 +87,7 @@ const EditorButton = props => {
87
87
  contentEditable: false,
88
88
  className: "editor-btn",
89
89
  style: {
90
- backgroundColor: bgColor || "rgb(30, 75, 122)",
90
+ background: bgColor || "rgb(30, 75, 122)",
91
91
  border: borderColor ? `1px solid ${borderColor}` : "none",
92
92
  borderRadius: `${topLeft}px ${topRight}px ${bottomLeft}px ${bottomRight}px`,
93
93
  paddingLeft: `${left || 8}px`,
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from "react";
2
2
  import { Transforms, Path } from "slate";
3
- import { useSelected, useSlateStatic } from "slate-react";
3
+ import { ReactEditor, useSelected, useSlateStatic } from "slate-react";
4
4
  import Slider from "react-slick";
5
5
  import "./slick-theme.min.css";
6
6
  import "./slick.min.css";
@@ -25,6 +25,7 @@ const Carousel = props => {
25
25
  const editor = useSlateStatic();
26
26
  const selected = useSelected();
27
27
  const [edit, setEdit] = useState(false);
28
+ const [reload, setReload] = useState(new Date().getTime());
28
29
  const settings = {
29
30
  dots: true,
30
31
  infinite: true,
@@ -51,6 +52,15 @@ const Carousel = props => {
51
52
  };
52
53
  const onEdit = () => {
53
54
  setEdit(!edit);
55
+ if (edit) {
56
+ setReload(new Date().getTime());
57
+ }
58
+ };
59
+ const onDelete = () => {
60
+ const path = ReactEditor.findPath(editor, element);
61
+ Transforms.removeNodes(editor, {
62
+ at: [...path]
63
+ });
54
64
  };
55
65
  const ToolBar = () => {
56
66
  return selected ? /*#__PURE__*/_jsxs("div", {
@@ -58,14 +68,16 @@ const Carousel = props => {
58
68
  contentEditable: false,
59
69
  children: [/*#__PURE__*/_jsx("button", {
60
70
  onClick: onEdit,
61
- children: "Edit"
71
+ children: edit ? "Save" : "Edit"
62
72
  }), /*#__PURE__*/_jsx("button", {
63
73
  onClick: onAddSlide,
64
74
  children: "Add Slide"
75
+ }), /*#__PURE__*/_jsx("button", {
76
+ onClick: onDelete,
77
+ children: "Delete"
65
78
  })]
66
79
  }) : null;
67
80
  };
68
- const CarouselWrapper = edit ? Slider : Empty;
69
81
  return /*#__PURE__*/_jsxs("div", {
70
82
  ...attributes,
71
83
  style: {
@@ -73,10 +85,12 @@ const Carousel = props => {
73
85
  backgroundColor: "#CCC",
74
86
  position: "relative"
75
87
  },
76
- children: [/*#__PURE__*/_jsx(CarouselWrapper, {
88
+ children: [edit ? /*#__PURE__*/_jsx(Empty, {
89
+ children: children
90
+ }) : /*#__PURE__*/_jsx(Slider, {
77
91
  ...settings,
78
92
  children: children
79
- }), /*#__PURE__*/_jsx(ToolBar, {})]
93
+ }, reload), /*#__PURE__*/_jsx(ToolBar, {})]
80
94
  });
81
95
  };
82
96
  export default Carousel;
@@ -7,7 +7,11 @@ const CarouselItem = props => {
7
7
  } = props;
8
8
  return /*#__PURE__*/_jsx("div", {
9
9
  ...attributes,
10
- children: children
10
+ className: "carousel-item",
11
+ children: /*#__PURE__*/_jsx("div", {
12
+ className: "carousel-item-inner",
13
+ children: children
14
+ })
11
15
  });
12
16
  };
13
17
  export default CarouselItem;
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ const ChipText = props => {
4
+ const {
5
+ attributes,
6
+ children,
7
+ element
8
+ } = props;
9
+ const {
10
+ bgColor,
11
+ textColor,
12
+ bannerSpacing,
13
+ borderRadius,
14
+ borderColor
15
+ } = element;
16
+ const {
17
+ left,
18
+ top,
19
+ right,
20
+ bottom
21
+ } = bannerSpacing || {};
22
+ const {
23
+ topLeft,
24
+ topRight,
25
+ bottomLeft,
26
+ bottomRight
27
+ } = borderRadius || {};
28
+ return /*#__PURE__*/_jsx("span", {
29
+ ...attributes,
30
+ className: "editor-chip-text",
31
+ style: {
32
+ paddingLeft: `${left}px`,
33
+ paddingRight: `${right}px`,
34
+ paddingTop: `${top}px`,
35
+ paddingBottom: `${bottom}px`,
36
+ border: borderColor ? `1px solid ${borderColor}` : "none",
37
+ borderRadius: `${topLeft}px ${topRight}px ${bottomLeft}px ${bottomRight}px`,
38
+ background: bgColor || "#CCC",
39
+ color: textColor
40
+ },
41
+ children: children
42
+ });
43
+ };
44
+ export default ChipText;
@@ -0,0 +1,64 @@
1
+ import React, { useState } from "react";
2
+ import { Editor, Transforms } from "slate";
3
+ import { IconButton } from "@mui/material";
4
+ import SmartButtonIcon from "@mui/icons-material/SmartButton";
5
+ import { insertChipText, removeChipText } from "../../utils/insertChipText";
6
+ import ChipTextPopup from "./ChipTextPopup";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { Fragment as _Fragment } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ const ChipTextButton = props => {
11
+ const {
12
+ editor,
13
+ customProps
14
+ } = props;
15
+ const [openSetttings, setOpenSettings] = useState(false);
16
+ const handleClick = () => {
17
+ const [parent, parentPath] = Editor.parent(editor, editor.selection.focus.path);
18
+ if (parent && parent?.type === "chip-text") {
19
+ setOpenSettings({
20
+ element: parent,
21
+ path: parentPath
22
+ });
23
+ // removeChipText(editor, parentPath);
24
+ } else {
25
+ insertChipText(editor, {
26
+ url: "",
27
+ showInNewTab: false
28
+ });
29
+ }
30
+ };
31
+ const onSave = data => {
32
+ const updateData = {
33
+ ...data
34
+ };
35
+ delete updateData.children;
36
+ Transforms.setNodes(editor, {
37
+ ...updateData
38
+ }, {
39
+ at: openSetttings?.path
40
+ });
41
+ onClose();
42
+ };
43
+ const onClose = () => {
44
+ setOpenSettings(false);
45
+ };
46
+ const onDelete = () => {
47
+ removeChipText(editor, openSetttings?.path);
48
+ onClose();
49
+ };
50
+ return /*#__PURE__*/_jsxs(_Fragment, {
51
+ children: [/*#__PURE__*/_jsx(IconButton, {
52
+ title: "Chip Text",
53
+ onClick: handleClick,
54
+ children: /*#__PURE__*/_jsx(SmartButtonIcon, {})
55
+ }), openSetttings !== false ? /*#__PURE__*/_jsx(ChipTextPopup, {
56
+ element: openSetttings?.element || {},
57
+ onSave: onSave,
58
+ onClose: onClose,
59
+ onDelete: onDelete,
60
+ customProps: customProps
61
+ }) : null]
62
+ });
63
+ };
64
+ export default ChipTextButton;
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import StyleBuilder from "../../common/StyleBuilder";
3
+ import chipTextStyle from "../../common/StyleBuilder/chipTextStyle";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const ChipTextPopup = props => {
6
+ const {
7
+ element,
8
+ onSave,
9
+ onClose,
10
+ onDelete,
11
+ customProps
12
+ } = props;
13
+ return /*#__PURE__*/_jsx(StyleBuilder, {
14
+ title: "Chip Text",
15
+ type: "ChipTextPopup",
16
+ element: element,
17
+ onSave: onSave,
18
+ onClose: onClose,
19
+ onDelete: onDelete,
20
+ renderTabs: chipTextStyle,
21
+ customProps: customProps
22
+ });
23
+ };
24
+ export default ChipTextPopup;
@@ -0,0 +1,66 @@
1
+ import React, { useState } from "react";
2
+ import { ReactEditor, useSlateStatic } from "slate-react";
3
+ import { Grid, Drawer, IconButton, List, ListItem, ListItemButton, ListItemText, Box, Button } from "@mui/material";
4
+ import MenuIcon from "@mui/icons-material/Menu";
5
+ import { removeDrawerMenu } from "../../utils/insertDrawerMenu";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ const DrawerMenu = props => {
9
+ const {
10
+ attributes,
11
+ element
12
+ } = props;
13
+ const {
14
+ menus,
15
+ anchor
16
+ } = element;
17
+ const [open, setOpen] = useState(false);
18
+ const editor = useSlateStatic();
19
+ const path = ReactEditor.findPath(editor, element);
20
+ const handleClick = () => {
21
+ setOpen(!open);
22
+ };
23
+ const handleDelete = () => {
24
+ removeDrawerMenu(editor, path);
25
+ };
26
+ return /*#__PURE__*/_jsxs("span", {
27
+ ...attributes,
28
+ className: "drawer-menu",
29
+ contentEditable: false,
30
+ children: [/*#__PURE__*/_jsx(IconButton, {
31
+ onClick: handleClick,
32
+ children: /*#__PURE__*/_jsx(MenuIcon, {})
33
+ }), /*#__PURE__*/_jsx(Drawer, {
34
+ anchor: anchor || "left",
35
+ open: open,
36
+ onClose: handleClick,
37
+ children: /*#__PURE__*/_jsxs(Box, {
38
+ sx: {
39
+ width: anchor === "top" || anchor === "bottom" ? "auto" : 250
40
+ },
41
+ children: [/*#__PURE__*/_jsx(List, {
42
+ children: menus.map((m, i) => {
43
+ return /*#__PURE__*/_jsx(ListItem, {
44
+ children: /*#__PURE__*/_jsx(ListItemButton, {
45
+ children: /*#__PURE__*/_jsx(ListItemText, {
46
+ children: m.text
47
+ })
48
+ })
49
+ }, `em-d-${i}-${m.title}`);
50
+ })
51
+ }), /*#__PURE__*/_jsx(Grid, {
52
+ style: {
53
+ display: "flex",
54
+ justifyContent: "center"
55
+ },
56
+ children: /*#__PURE__*/_jsx(Button, {
57
+ color: "error",
58
+ onClick: handleDelete,
59
+ children: "Delete"
60
+ })
61
+ })]
62
+ })
63
+ })]
64
+ });
65
+ };
66
+ export default DrawerMenu;
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { IconButton } from "@mui/material";
3
+ import ViewSidebarIcon from "@mui/icons-material/ViewSidebar";
4
+ import { insertDrawerMenu } from "../../utils/insertDrawerMenu";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const DrawerButton = props => {
7
+ const {
8
+ editor
9
+ } = props;
10
+ const handleClick = () => {
11
+ insertDrawerMenu(editor, {
12
+ text: ""
13
+ });
14
+ };
15
+ return /*#__PURE__*/_jsx(IconButton, {
16
+ title: "Drawer Menu",
17
+ onClick: handleClick,
18
+ children: /*#__PURE__*/_jsx(ViewSidebarIcon, {})
19
+ });
20
+ };
21
+ export default DrawerButton;