@flozy/editor 1.8.4 → 1.8.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ import { mentionsEvent, commands, indentation, escapeEvent, enterEvent } from ".
13
13
  import withCommon from "./hooks/withCommon";
14
14
  import DialogWrapper from "./DialogWrapper";
15
15
  import { serializeToText } from "./utils/serializeToText";
16
- import { getPageSettings } from "./utils/pageSettings";
16
+ import { findPageSettings, getPageSettings } from "./utils/pageSettings";
17
17
  import { getThumbnailImage, invertColor } from "./helper";
18
18
  import PopupTool from "./Toolbar/PopupTool";
19
19
  import "./font.css";
@@ -100,7 +100,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
100
100
  CHARACTERS = [],
101
101
  editorClass,
102
102
  fixedWidth = "60%",
103
- fullWidth = "80%"
103
+ fullWidth = "80%",
104
+ hideTools
104
105
  } = otherProps || {};
105
106
  const [drag, setDrag] = useState(null);
106
107
  const editor = useMemo(() => {
@@ -243,7 +244,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
243
244
  } = mentions;
244
245
  const chars = type ? Shorthands[type]({
245
246
  ...mentions,
246
- CHARACTERS
247
+ CHARACTERS,
248
+ hideTools: hideTools || []
247
249
  }) : [];
248
250
  const handleEditorChange = newValue => {
249
251
  setValue(newValue);
@@ -330,6 +330,10 @@ blockquote {
330
330
  border-radius: 12px;
331
331
  }
332
332
 
333
+ .activeBrush svg {
334
+ stroke: #2563eb;
335
+ }
336
+
333
337
  .react-datepicker__input-container {
334
338
  display: flex !important;
335
339
  align-items: center;
@@ -17,6 +17,11 @@ export const PrevArrow = props => {
17
17
  zIndex: 3
18
18
  },
19
19
  onClick: onClick,
20
+ sx: {
21
+ '&.MuiButtonBase-root': {
22
+ lineHeight: "0px !important"
23
+ }
24
+ },
20
25
  contentEditable: false,
21
26
  children: /*#__PURE__*/_jsx(Icon, {
22
27
  icon: "leftArrow"
@@ -37,6 +42,11 @@ export const NextArrow = props => {
37
42
  right: '5px',
38
43
  zIndex: 3
39
44
  },
45
+ sx: {
46
+ '&.MuiButtonBase-root': {
47
+ lineHeight: "0px !important"
48
+ }
49
+ },
40
50
  onClick: onClick,
41
51
  contentEditable: false,
42
52
  children: /*#__PURE__*/_jsx(Icon, {
@@ -11,6 +11,7 @@
11
11
  font-family: slick;
12
12
  -webkit-font-smoothing: antialiased;
13
13
  -moz-osx-font-smoothing: grayscale;
14
+ content: none;
14
15
  }
15
16
  .slick-loading .slick-list {
16
17
  background: #fff;
@@ -58,7 +58,7 @@ const Video = ({
58
58
  bottomRight
59
59
  } = borderRadius || {};
60
60
  useEffect(() => {
61
- if (editor && ele[1] !== undefined) {
61
+ if (editor && ele && ele[1] !== undefined) {
62
62
  const dom = ReactEditor.toDOMNode(editor, Node.get(editor, ele[1]));
63
63
  setParentDOM(dom);
64
64
  onLoad(element?.size || {});
@@ -12,7 +12,7 @@ import GridPopup from "./GridPopup";
12
12
  import SectionPopup from "./SectionPopup";
13
13
  import { gridItem } from "../../utils/gridItem";
14
14
  import { useEditorContext } from "../../hooks/useMouseMove";
15
- import { getTRBLBreakPoints } from "../../helper/theme";
15
+ import { getTRBLBreakPoints, getBreakPointsValue } from "../../helper/theme";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
18
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -42,7 +42,8 @@ const Grid = props => {
42
42
  borderWidth,
43
43
  borderColor,
44
44
  borderStyle,
45
- borderRadius
45
+ borderRadius,
46
+ flexWrap
46
47
  } = element;
47
48
  const {
48
49
  vertical,
@@ -305,7 +306,10 @@ const Grid = props => {
305
306
  alignItems: vertical || "start",
306
307
  justifyContent: horizantal || "start",
307
308
  flexDirection: flexDirection || "row",
308
- width: "100%"
309
+ width: "100%",
310
+ flexWrap: {
311
+ ...getBreakPointsValue(flexWrap || "wrap")
312
+ }
309
313
  },
310
314
  "data-path": path.join(","),
311
315
  children: children
@@ -33,7 +33,8 @@ const GridItem = props => {
33
33
  bgColorHover,
34
34
  borderColorHover,
35
35
  textColor,
36
- animation
36
+ animation,
37
+ cellGHeight
37
38
  } = element;
38
39
  const {
39
40
  vertical,
@@ -104,6 +105,9 @@ const GridItem = props => {
104
105
  width: {
105
106
  ...getBreakPointsValue(grid, null, "overrideGridSize", true)
106
107
  },
108
+ height: {
109
+ ...getBreakPointsValue(cellGHeight || "auto")
110
+ },
107
111
  display: "flex",
108
112
  flexDirection: flexDirection || "column",
109
113
  background: bgColor || "transparent",
@@ -333,7 +333,7 @@ const SignaturePopup = props => {
333
333
  return /*#__PURE__*/_jsx(IconButton, {
334
334
  onClick: onBrushSize(m),
335
335
  disableRipple: true,
336
- className: brush.size === m ? "active" : "",
336
+ className: brush.size === m ? "activeBrush" : "",
337
337
  children: /*#__PURE__*/_jsx("span", {
338
338
  style: {
339
339
  width: 20 + m,
@@ -6,11 +6,6 @@ const IframeEditor = () => {
6
6
  const [message, sendMessage] = useWindowMessage({
7
7
  type: "editorProps"
8
8
  });
9
- const device = {
10
- label: "Mobile",
11
- breakpoint: "sm",
12
- width: 425
13
- };
14
9
  const onSave = (a, b) => {
15
10
  sendMessage({
16
11
  type: "Editor:onSave",
@@ -24,8 +19,7 @@ const IframeEditor = () => {
24
19
  return /*#__PURE__*/_jsx(CommonEditor, {
25
20
  ...message,
26
21
  isIframe: true,
27
- onSave: onSave,
28
- device: device
22
+ onSave: onSave
29
23
  });
30
24
  } else {
31
25
  return /*#__PURE__*/_jsx("div", {
@@ -41,7 +41,6 @@ const editorStyles = ({
41
41
  "& .editor-wrapper": {
42
42
  maxWidth: "100%",
43
43
  height: "100%",
44
- backgroundColor: "#FFF",
45
44
  overflow: "visible",
46
45
  "& .section-wrapper-fluid": {
47
46
  "& .grid-container": {
@@ -37,6 +37,10 @@ const MiniToolbar = props => {
37
37
  const PopupComponent = POPUP_TYPES[popper] || null;
38
38
  const open = Boolean(PopupComponent);
39
39
  const DialogComp = !fullScreen ? Popper : Dialog;
40
+ const {
41
+ hideTools
42
+ } = customProps;
43
+ const UPDATED_MENU_OPTIONS = MENU_OPTIONS.filter(f => (hideTools || [])?.indexOf(f.type) === -1);
40
44
  useEffect(() => {
41
45
  if (popper) {
42
46
  setPopper(null);
@@ -58,7 +62,7 @@ const MiniToolbar = props => {
58
62
  component: "div",
59
63
  className: "mini-tool-wrpr-ei",
60
64
  sx: classes.root,
61
- children: MENU_OPTIONS.map(({
65
+ children: UPDATED_MENU_OPTIONS.map(({
62
66
  type,
63
67
  label,
64
68
  icon: Icon
@@ -11,6 +11,10 @@ const AddElements = props => {
11
11
  editor,
12
12
  customProps
13
13
  } = props;
14
+ const {
15
+ hideTools
16
+ } = customProps;
17
+ const filteredElements = elements.filter(f => hideTools.indexOf(f.type) === -1);
14
18
  return /*#__PURE__*/_jsx(Grid, {
15
19
  container: true,
16
20
  sx: classes.textFormatWrapper,
@@ -18,7 +22,7 @@ const AddElements = props => {
18
22
  style: {
19
23
  margin: 0
20
24
  },
21
- children: elements.map(m => {
25
+ children: filteredElements.map(m => {
22
26
  return /*#__PURE__*/_jsx(Grid, {
23
27
  item: true,
24
28
  xs: 6,
@@ -10,6 +10,9 @@ const usePopupStyle = () => ({
10
10
  "& .papper-wrpr": {
11
11
  boxShadow: "none"
12
12
  }
13
+ },
14
+ "&.xs": {
15
+ transform: "none !important"
13
16
  }
14
17
  },
15
18
  textFormatWrapper: {
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from "react";
2
- import { Popper, Fade, Paper } from "@mui/material";
2
+ import { Popper, Fade, Paper, Popover } from "@mui/material";
3
3
  import { Editor, Range } from "slate";
4
4
  import { useSlate, useFocused } from "slate-react";
5
5
  import TextFormat from "./TextFormat";
@@ -7,6 +7,7 @@ import usePopupStyle from "./PopupToolStyle";
7
7
  import useDrag from "../../hooks/useDrag";
8
8
  import PopperHeader from "./PopperHeader";
9
9
  import { TableUtil } from "../../utils/table";
10
+ import useWindowResize from "../../hooks/useWindowResize";
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
12
13
  const PopupTool = props => {
@@ -21,6 +22,7 @@ const PopupTool = props => {
21
22
  const [event] = useDrag(anchorEl);
22
23
  const id = open ? "popup-edit-tool" : "";
23
24
  const table = new TableUtil(editor);
25
+ const [size] = useWindowResize();
24
26
  useEffect(() => {
25
27
  if (event === "end" && anchorEl && !open) {
26
28
  // for table cell selection
@@ -66,7 +68,7 @@ const PopupTool = props => {
66
68
  transition: true,
67
69
  placement: "auto-end",
68
70
  sx: classes.popupWrapper,
69
- className: "tools-drawer",
71
+ className: `tools-drawer ${size?.device}`,
70
72
  children: ({
71
73
  TransitionProps
72
74
  }) => /*#__PURE__*/_jsx(Fade, {
@@ -157,14 +157,6 @@ export const RenderToolbarIcon = props => {
157
157
  editor: editor,
158
158
  customProps: customProps
159
159
  }, element.id);
160
- // case "drawer":
161
- // return (
162
- // <DrawerMenuButton
163
- // key={element.id}
164
- // editor={editor}
165
- // customProps={customProps}
166
- // />
167
- // );
168
160
  case "app-header":
169
161
  return /*#__PURE__*/_jsx(AppHeaderButton, {
170
162
  editor: editor,
@@ -14,6 +14,7 @@ const ELEMENTS_LIST = [{
14
14
  name: "Heading 1",
15
15
  desc: "",
16
16
  group: "Text",
17
+ type: "headingOne",
17
18
  icon: /*#__PURE__*/_jsx(Icon, {
18
19
  icon: "headingOne"
19
20
  }),
@@ -22,6 +23,7 @@ const ELEMENTS_LIST = [{
22
23
  name: "Heading 2",
23
24
  desc: "",
24
25
  group: "Text",
26
+ type: "headingTwo",
25
27
  icon: /*#__PURE__*/_jsx(Icon, {
26
28
  icon: "headingTwo"
27
29
  }),
@@ -30,6 +32,7 @@ const ELEMENTS_LIST = [{
30
32
  name: "Heading 3",
31
33
  desc: "",
32
34
  group: "Text",
35
+ type: "headingThree",
33
36
  icon: /*#__PURE__*/_jsx(Icon, {
34
37
  icon: "headingThree"
35
38
  }),
@@ -38,6 +41,7 @@ const ELEMENTS_LIST = [{
38
41
  name: "Quote",
39
42
  desc: "",
40
43
  group: "Text",
44
+ type: "blockquote",
41
45
  icon: /*#__PURE__*/_jsx(Icon, {
42
46
  icon: "blockquote"
43
47
  }),
@@ -48,6 +52,7 @@ const ELEMENTS_LIST = [{
48
52
  name: "Colorbox",
49
53
  desc: "",
50
54
  group: "Text",
55
+ type: "colorbox",
51
56
  icon: /*#__PURE__*/_jsx(Icon, {
52
57
  icon: "colorbox"
53
58
  }),
@@ -58,6 +63,7 @@ const ELEMENTS_LIST = [{
58
63
  name: "Ordered List",
59
64
  desc: "",
60
65
  group: "List",
66
+ type: "orderedList",
61
67
  icon: /*#__PURE__*/_jsx(Icon, {
62
68
  icon: "orderedList"
63
69
  }),
@@ -66,6 +72,7 @@ const ELEMENTS_LIST = [{
66
72
  name: "Bulleted List",
67
73
  desc: "",
68
74
  group: "List",
75
+ type: "unorderedList",
69
76
  icon: /*#__PURE__*/_jsx(Icon, {
70
77
  icon: "unorderedList"
71
78
  }),
@@ -74,6 +81,7 @@ const ELEMENTS_LIST = [{
74
81
  name: "Check List",
75
82
  desc: "",
76
83
  group: "List",
84
+ type: "check-list-item",
77
85
  icon: /*#__PURE__*/_jsx(Icon, {
78
86
  icon: "check-list-item"
79
87
  }),
@@ -82,6 +90,7 @@ const ELEMENTS_LIST = [{
82
90
  name: "Image",
83
91
  desc: "",
84
92
  group: "Media",
93
+ type: "embed",
85
94
  icon: /*#__PURE__*/_jsx(Icon, {
86
95
  icon: "image"
87
96
  }),
@@ -90,6 +99,7 @@ const ELEMENTS_LIST = [{
90
99
  name: "Video",
91
100
  desc: "",
92
101
  group: "Media",
102
+ type: "embed",
93
103
  icon: /*#__PURE__*/_jsx(Icon, {
94
104
  icon: "video"
95
105
  }),
@@ -98,6 +108,7 @@ const ELEMENTS_LIST = [{
98
108
  name: "Embed",
99
109
  desc: "",
100
110
  group: "Media",
111
+ type: "embed",
101
112
  icon: /*#__PURE__*/_jsx(Icon, {
102
113
  icon: "embed"
103
114
  }),
@@ -106,6 +117,7 @@ const ELEMENTS_LIST = [{
106
117
  name: "Emoji",
107
118
  group: "Elements",
108
119
  desc: "",
120
+ type: "emoji",
109
121
  renderComponent: rest => /*#__PURE__*/_jsx(EmojiButton, {
110
122
  ...rest,
111
123
  icoBtnType: "cmd"
@@ -114,6 +126,7 @@ const ELEMENTS_LIST = [{
114
126
  name: "Table",
115
127
  group: "Elements",
116
128
  desc: "",
129
+ type: "table",
117
130
  icon: /*#__PURE__*/_jsx(Icon, {
118
131
  icon: "table"
119
132
  }),
@@ -125,6 +138,7 @@ const ELEMENTS_LIST = [{
125
138
  name: "Grid",
126
139
  group: "Elements",
127
140
  desc: "",
141
+ type: "grid",
128
142
  icon: /*#__PURE__*/_jsx(Icon, {
129
143
  icon: "grid"
130
144
  }),
@@ -135,6 +149,7 @@ const ELEMENTS_LIST = [{
135
149
  name: "Accordion",
136
150
  group: "Elements",
137
151
  desc: "",
152
+ type: "accordion",
138
153
  icon: /*#__PURE__*/_jsx(Icon, {
139
154
  icon: "accordion"
140
155
  }),
@@ -145,6 +160,7 @@ const ELEMENTS_LIST = [{
145
160
  name: "Button",
146
161
  group: "Elements",
147
162
  desc: "",
163
+ type: "button",
148
164
  icon: /*#__PURE__*/_jsx(Icon, {
149
165
  icon: "button"
150
166
  }),
@@ -155,6 +171,7 @@ const ELEMENTS_LIST = [{
155
171
  name: "Signature",
156
172
  group: "Elements",
157
173
  desc: "",
174
+ type: "signature",
158
175
  icon: /*#__PURE__*/_jsx(Icon, {
159
176
  icon: "signature"
160
177
  }),
@@ -165,6 +182,7 @@ const ELEMENTS_LIST = [{
165
182
  name: "Carousel",
166
183
  group: "Elements",
167
184
  desc: "",
185
+ type: "carousel",
168
186
  icon: /*#__PURE__*/_jsx(Icon, {
169
187
  icon: "carousel"
170
188
  }),
@@ -175,6 +193,7 @@ const ELEMENTS_LIST = [{
175
193
  name: "Form",
176
194
  group: "Elements",
177
195
  desc: "",
196
+ type: "form",
178
197
  icon: /*#__PURE__*/_jsx(Icon, {
179
198
  icon: "form"
180
199
  }),
@@ -184,8 +203,10 @@ const ELEMENTS_LIST = [{
184
203
  }];
185
204
  const elements = props => {
186
205
  const {
187
- search
206
+ search,
207
+ hideTools
188
208
  } = props;
189
- return ELEMENTS_LIST.filter(c => c.name.toLowerCase().includes(search?.toLowerCase()));
209
+ const filteredElements = ELEMENTS_LIST.filter(f => hideTools.indexOf(f.type) === -1);
210
+ return filteredElements.filter(c => c.name.toLowerCase().includes(search?.toLowerCase()));
190
211
  };
191
212
  export default elements;
@@ -1,25 +1,39 @@
1
1
  import React from "react";
2
2
  import { Grid, MenuItem, Select, Typography } from "@mui/material";
3
+ import { getBreakPointsValue } from "../../../helper/theme";
4
+ import useWindowResize from "../../../hooks/useWindowResize";
3
5
  import { jsx as _jsx } from "react/jsx-runtime";
4
6
  import { jsxs as _jsxs } from "react/jsx-runtime";
5
7
  import { Fragment as _Fragment } from "react/jsx-runtime";
6
8
  const TextOptions = props => {
7
9
  const {
8
- value,
10
+ value: val,
9
11
  data,
10
12
  onChange,
11
13
  elementProps
12
14
  } = props;
13
15
  const {
14
16
  key,
17
+ isBreakpoint,
15
18
  options,
16
19
  renderOption,
17
20
  width
18
21
  } = data;
22
+ const [size] = useWindowResize();
23
+ const value = isBreakpoint ? getBreakPointsValue(val, size?.device) : val;
19
24
  const handleChange = e => {
20
- onChange({
21
- [key]: e.target.value
22
- });
25
+ if (isBreakpoint) {
26
+ onChange({
27
+ [key]: {
28
+ ...getBreakPointsValue(val),
29
+ [size?.device]: e.target.value
30
+ }
31
+ });
32
+ } else {
33
+ onChange({
34
+ [key]: e.target.value
35
+ });
36
+ }
23
37
  };
24
38
  return /*#__PURE__*/_jsx(_Fragment, {
25
39
  children: /*#__PURE__*/_jsxs(Grid, {
@@ -71,9 +71,26 @@ const gridItemStyle = [{
71
71
  tab: "Size",
72
72
  value: "gridSize",
73
73
  fields: [{
74
- label: "Grid Size",
74
+ label: "Width Size",
75
75
  key: "grid",
76
76
  type: "gridSize"
77
+ }, {
78
+ label: "Height",
79
+ key: "cellGHeight",
80
+ type: "textOptions",
81
+ isBreakpoint: true,
82
+ options: [{
83
+ text: "Auto",
84
+ value: "auto"
85
+ }, {
86
+ text: "Full",
87
+ value: "100%"
88
+ }],
89
+ renderOption: option => {
90
+ return /*#__PURE__*/_jsx("span", {
91
+ children: option.text
92
+ });
93
+ }
77
94
  }]
78
95
  }, {
79
96
  tab: "Animation",
@@ -90,9 +90,27 @@ const gridStyle = [{
90
90
  tab: "Size",
91
91
  value: "gridSize",
92
92
  fields: [{
93
- label: "Grid Size",
93
+ label: "Width Size",
94
94
  key: "gridSize",
95
95
  type: "gridSize"
96
+ }, {
97
+ label: "Wrap",
98
+ key: "flexWrap",
99
+ type: "textOptions",
100
+ width: 12,
101
+ isBreakpoint: true,
102
+ options: [{
103
+ text: "Wrap",
104
+ value: "wrap"
105
+ }, {
106
+ text: "No Wrap",
107
+ value: "nowrap"
108
+ }],
109
+ renderOption: option => {
110
+ return /*#__PURE__*/_jsx("span", {
111
+ children: option.text
112
+ });
113
+ }
96
114
  }]
97
115
  }, {
98
116
  tab: "Save As Template",
@@ -15,17 +15,21 @@ const StyleContent = props => {
15
15
  customProps,
16
16
  handleClose
17
17
  } = props;
18
+ const {
19
+ hideTools
20
+ } = customProps;
18
21
  const tabContent = renderTabs.find(f => f.value === value);
19
22
  const {
20
23
  fields
21
24
  } = tabContent || {
22
25
  fields: []
23
26
  };
27
+ const filteredFields = hideTools?.length > 0 ? fields.filter(f => hideTools.indexOf(f.key) === -1) : fields;
24
28
  return /*#__PURE__*/_jsx(Grid, {
25
29
  container: true,
26
30
  spacing: 2,
27
31
  className: "sidebar-wrpr-eds",
28
- children: [...fields].map((m, i) => {
32
+ children: [...filteredFields].map((m, i) => {
29
33
  const FieldComponent = FieldMap[m.type];
30
34
  return FieldComponent ? /*#__PURE__*/_jsx(FieldComponent, {
31
35
  data: m,
@@ -27,7 +27,7 @@ const useWindowMessage = props => {
27
27
  if (window.parent) {
28
28
  window.parent.postMessage({
29
29
  ...action
30
- }, "http://localhost:3000");
30
+ }, "*");
31
31
  }
32
32
  };
33
33
  return [message, sendMessage];
@@ -1,4 +1,21 @@
1
1
  import { Editor, Transforms, Element } from "slate";
2
+ export const findPageSettings = editor => {
3
+ try {
4
+ console.log(editor?.children);
5
+ return {
6
+ element: editor?.children?.find(f => f.type === "page-settings")
7
+ };
8
+ } catch (err) {
9
+ return {
10
+ path: null,
11
+ element: {
12
+ pageProps: {
13
+ pageWidth: "fixed"
14
+ }
15
+ }
16
+ };
17
+ }
18
+ };
2
19
  export const getPageSettings = editor => {
3
20
  try {
4
21
  const [pageSettingsNode] = Editor.nodes(editor, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"