@flozy/editor 9.4.7 → 9.4.8

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.
@@ -502,7 +502,7 @@ blockquote {
502
502
  color: #ffffff !important;
503
503
  border: 1px solid #2563eb !important;
504
504
  width: auto !important;
505
- padding: 2px 0px 0px 0px !important;
505
+ /* padding: 2px 0px 0px 0px !important; */
506
506
  min-width: 89px !important;
507
507
  font-family: Inter, sans-serif;
508
508
  text-transform: none;
@@ -534,7 +534,7 @@ blockquote {
534
534
  margin-right: 15px !important;
535
535
  color: #2563eb;
536
536
  width: auto !important;
537
- padding: 2px 0px 0px 0px !important;
537
+ /* padding: 2px 0px 0px 0px !important; */
538
538
  min-width: 89px !important;
539
539
  font-family: Inter, sans-serif;
540
540
  text-transform: none;
@@ -91,12 +91,19 @@ const DataView = props => {
91
91
  console.log(err);
92
92
  }
93
93
  };
94
+ const handleClick = () => {
95
+ // for the bug FS-9557, scenario mentioned in comment
96
+ if (editor.selection !== null) {
97
+ Transforms.deselect(editor);
98
+ }
99
+ };
94
100
  return /*#__PURE__*/_jsx(Box, {
95
101
  ...attributes,
96
102
  className: "fe-dataview",
97
103
  sx: classes.root,
98
104
  contentEditable: false,
99
105
  "data-title": title,
106
+ onClick: handleClick,
100
107
  children: /*#__PURE__*/_jsxs(DataViewProvider, {
101
108
  data: {
102
109
  properties,
@@ -15,6 +15,11 @@ import { useEditorContext } from "../../hooks/useMouseMove";
15
15
  import useCommonStyle from "../../commonStyle";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
+ const TYPE_LABELS = {
19
+ calendly: "Embed Calendly or Other",
20
+ video: "Embed Video or Other",
21
+ image: "Embed Image or Other"
22
+ };
18
23
  const VideoContent = props => {
19
24
  const {
20
25
  resizing,
@@ -72,7 +77,8 @@ const VideoPlaceholder = props => {
72
77
  readOnly,
73
78
  onSettings,
74
79
  classes,
75
- translation
80
+ translation,
81
+ type
76
82
  } = props;
77
83
  return !url ? !readOnly ? /*#__PURE__*/_jsxs(Box, {
78
84
  component: "button",
@@ -83,7 +89,7 @@ const VideoPlaceholder = props => {
83
89
  },
84
90
  children: [/*#__PURE__*/_jsx(Icon, {
85
91
  icon: "video"
86
- }), translation("Embed Video or Other")]
92
+ }), translation(TYPE_LABELS[type] || "Embed Video or Other")]
87
93
  }) : /*#__PURE__*/_jsxs(Box, {
88
94
  sx: {
89
95
  color: "#64748B !important",
@@ -139,6 +139,13 @@ const FreeGrid = props => {
139
139
  setAutoAlign(true);
140
140
  setSelectedElement({});
141
141
  break;
142
+ case "deleteSection":
143
+ if (Node.has(editor, cur_root_path)) {
144
+ Transforms.removeNodes(editor, {
145
+ at: cur_root_path
146
+ });
147
+ }
148
+ break;
142
149
  default:
143
150
  }
144
151
  } catch (err) {
@@ -23,7 +23,11 @@ const More = props => {
23
23
  className: "item-wrapper",
24
24
  onClick: handleClick("forceAutoAlignment"),
25
25
  children: "Force Auto Alignment"
26
- }) : null]
26
+ }) : null, /*#__PURE__*/_jsx(ListItemButton, {
27
+ className: "item-wrapper",
28
+ onClick: handleClick("deleteSection"),
29
+ children: "Delete Section"
30
+ })]
27
31
  })
28
32
  });
29
33
  };
@@ -168,6 +168,12 @@ const RnD = props => {
168
168
  if (readOnly) {
169
169
  return;
170
170
  }
171
+
172
+ // for section click
173
+ if (e?.target?.dataset?.dragovertype === "parent") {
174
+ // consider as section click and de-select focused / edited item
175
+ setSelectedElement({});
176
+ }
171
177
  if (e?.target?.dataset?.event === "rnd-click") {
172
178
  // for context menu
173
179
  setContextMenu({
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from "react";
2
- import { CircularProgress, Drawer, Grid, IconButton, Tab, Tabs, Typography, styled } from "@mui/material";
2
+ import { Box, CircularProgress, Drawer, Grid, IconButton, Tab, Tabs, Typography, styled } from "@mui/material";
3
3
 
4
4
  // Style
5
5
  import Style from "./style";
@@ -53,8 +53,7 @@ const ThemeSettings = props => {
53
53
  const {
54
54
  id,
55
55
  name,
56
- mood_name,
57
- template_tags
56
+ mood_name
58
57
  } = userSelectedTheme || {};
59
58
  const onClose = () => setOpen(false);
60
59
  const getThemesList = async themeTabType => {
@@ -92,10 +91,10 @@ const ThemeSettings = props => {
92
91
  getThemesList(newValue);
93
92
  };
94
93
  const isUpdateTheme = Number(userSelectedTheme?.type) === 2;
95
- const onSaveTheme = async (formData = {}) => {
94
+ const onSaveTheme = async (formData = {}, addNewTheme) => {
96
95
  setSavingTheme(true);
97
96
  try {
98
- const type = isUpdateTheme ? "update" : "create";
97
+ let type = isUpdateTheme && !addNewTheme ? "update" : "create";
99
98
  const result = await services("saveTheme", {
100
99
  type,
101
100
  id,
@@ -189,14 +188,15 @@ const ThemeSettings = props => {
189
188
  })]
190
189
  });
191
190
  };
191
+ const showThemeSettings = id && !themeMoodboard;
192
192
  return /*#__PURE__*/_jsx(Grid, {
193
193
  className: className,
194
- children: /*#__PURE__*/_jsx(Drawer, {
194
+ children: /*#__PURE__*/_jsxs(Drawer, {
195
195
  className: className,
196
196
  open: open,
197
197
  onClose: onClose,
198
198
  anchor: "right",
199
- children: /*#__PURE__*/_jsxs(Grid, {
199
+ children: [/*#__PURE__*/_jsxs(Grid, {
200
200
  className: "settingsContainer",
201
201
  children: [/*#__PURE__*/_jsxs(Grid, {
202
202
  container: true,
@@ -271,7 +271,7 @@ const ThemeSettings = props => {
271
271
  }, i);
272
272
  })]
273
273
  })
274
- }), id && !themeMoodboard ? /*#__PURE__*/_jsxs(_Fragment, {
274
+ }), showThemeSettings ? /*#__PURE__*/_jsxs(_Fragment, {
275
275
  children: [/*#__PURE__*/_jsx(Grid, {
276
276
  sx: {
277
277
  px: 1,
@@ -301,27 +301,30 @@ const ThemeSettings = props => {
301
301
  appTheme: appTheme,
302
302
  customProps: customProps
303
303
  })
304
- }), /*#__PURE__*/_jsx("div", {
305
- style: {
306
- width: "100%",
307
- display: "flex",
308
- justifyContent: "center",
309
- alignItems: "center",
310
- marginTop: "10px"
311
- },
312
- children: /*#__PURE__*/_jsx(SaveTheme, {
313
- saveBtnLabel: isUpdateTheme ? "Update theme" : "Save Theme",
314
- loading: savingTheme,
315
- onSave: onSaveTheme,
316
- defaultFormData: {
317
- name,
318
- mood_name,
319
- template_tags
320
- }
321
- })
322
304
  })]
323
305
  }) : null]
324
- })
306
+ }), showThemeSettings ? /*#__PURE__*/_jsxs(Box, {
307
+ className: "saveThemeBtnsWrapper",
308
+ component: "div",
309
+ children: [isUpdateTheme ? /*#__PURE__*/_jsx(SaveTheme, {
310
+ saveBtnLabel: "Add new theme",
311
+ loading: savingTheme,
312
+ onSave: onSaveTheme,
313
+ defaultFormData: {
314
+ name,
315
+ mood_name
316
+ },
317
+ addNewTheme: true
318
+ }) : null, /*#__PURE__*/_jsx(SaveTheme, {
319
+ saveBtnLabel: isUpdateTheme ? "Update theme" : "Save to my theme",
320
+ loading: savingTheme,
321
+ onSave: onSaveTheme,
322
+ defaultFormData: {
323
+ name,
324
+ mood_name
325
+ }
326
+ })]
327
+ }) : null]
325
328
  })
326
329
  });
327
330
  };
@@ -32,7 +32,9 @@ const Style = ({
32
32
  },
33
33
  "& .MuiDrawer-paper": {
34
34
  background: background,
35
- color: textColor
35
+ color: textColor,
36
+ display: "flex",
37
+ flexDirection: "column"
36
38
  },
37
39
  "& .textSecondary": {
38
40
  color: tv_text
@@ -40,6 +42,9 @@ const Style = ({
40
42
  ".settingsContainer": {
41
43
  width: "340px",
42
44
  padding: "16px 5px",
45
+ position: "relative",
46
+ overflowY: "auto",
47
+ flexGrow: 1,
43
48
  ".header": {
44
49
  borderBottom: `1px solid ${deviderBgColor}`,
45
50
  paddingBottom: "16px",
@@ -182,11 +187,24 @@ const Style = ({
182
187
  fontWeight: "600"
183
188
  },
184
189
  ".MuiAccordionDetails-root ": {
185
- padding: "12px 0px"
190
+ padding: "12px 0px !important"
186
191
  }
187
192
  },
188
193
  ".MuiTab-root": {
189
194
  color: textColor
195
+ },
196
+ ".saveThemeBtnsWrapper": {
197
+ position: "sticky",
198
+ bottom: "0px",
199
+ right: "0px",
200
+ boxShadow: "0px -3px 12px 0px #00000017",
201
+ padding: "10px",
202
+ borderRadius: "8px",
203
+ display: "flex",
204
+ justifyContent: "end",
205
+ alignItems: "center",
206
+ gap: "8px",
207
+ background: background
190
208
  }
191
209
  };
192
210
  };
@@ -16,7 +16,8 @@ const SaveTheme = props => {
16
16
  saveBtnLabel,
17
17
  loading,
18
18
  onSave,
19
- defaultFormData = {}
19
+ defaultFormData = {},
20
+ addNewTheme
20
21
  } = props;
21
22
 
22
23
  // State
@@ -25,8 +26,7 @@ const SaveTheme = props => {
25
26
  const [form, setForm] = useState(defaultFormData);
26
27
  const {
27
28
  name,
28
- mood_name,
29
- template_tags
29
+ mood_name
30
30
  } = form;
31
31
  const updateForm = update => {
32
32
  setForm(prev => ({
@@ -60,7 +60,7 @@ const SaveTheme = props => {
60
60
  // className={`blueBtn ${enableGenerateTheme ? "eanbled" : "disabled"}`}
61
61
  // disabled={!enableGenerateTheme}
62
62
  ,
63
- className: `blueBtn`,
63
+ className: addNewTheme ? `outlineBtn` : `blueBtn`,
64
64
  onClick: () => setSaveTheme(true),
65
65
  children: saveBtnLabel
66
66
  }), /*#__PURE__*/_jsx(Dialog, {
@@ -88,7 +88,7 @@ const SaveTheme = props => {
88
88
  fontSize: "18px"
89
89
  },
90
90
  className: "fw-600",
91
- children: "Save Your theme"
91
+ children: saveBtnLabel
92
92
  }), /*#__PURE__*/_jsx(IconButton, {
93
93
  onClick: onClose,
94
94
  className: "closeBtn",
@@ -136,24 +136,20 @@ const SaveTheme = props => {
136
136
  value: mood_name
137
137
  }), /*#__PURE__*/_jsx(Error, {
138
138
  error: error?.mood_name
139
- }), /*#__PURE__*/_jsx(Typography, {
140
- variant: "body1",
141
- className: "fw-500",
139
+ }), loading ? /*#__PURE__*/_jsx(Box, {
142
140
  sx: {
143
- pt: 2,
144
- pb: 1
141
+ position: "absolute",
142
+ top: 0,
143
+ left: 0,
144
+ right: 0,
145
+ bottom: 0,
146
+ zIndex: 99999,
147
+ display: "flex",
148
+ justifyContent: "center",
149
+ alignItems: "center"
145
150
  },
146
- children: "Template Tags"
147
- }), /*#__PURE__*/_jsx(TextField, {
148
- variant: "outlined",
149
- size: "small",
150
- placeholder: "template_tags",
151
- fullWidth: true,
152
- onChange: e => updateForm({
153
- template_tags: e.target.value
154
- }),
155
- value: template_tags
156
- }), /*#__PURE__*/_jsxs(Grid, {
151
+ children: /*#__PURE__*/_jsx(CircularProgress, {})
152
+ }) : null, /*#__PURE__*/_jsxs(Grid, {
157
153
  container: true,
158
154
  justifyContent: "flex-end",
159
155
  sx: {
@@ -165,14 +161,13 @@ const SaveTheme = props => {
165
161
  color: "secondary",
166
162
  onClick: onClose,
167
163
  children: "Cancel"
168
- }), /*#__PURE__*/_jsxs(Button, {
164
+ }), /*#__PURE__*/_jsx(Button, {
169
165
  variant: "contained",
170
166
  color: "primary",
171
167
  className: "blueBtn",
172
168
  sx: {
173
169
  ml: 1
174
170
  },
175
- disabled: loading,
176
171
  onClick: async () => {
177
172
  const err = validate();
178
173
  setError(err);
@@ -181,15 +176,10 @@ const SaveTheme = props => {
181
176
  }
182
177
  await onSave({
183
178
  ...form
184
- });
179
+ }, addNewTheme);
185
180
  onClose();
186
181
  },
187
- children: [loading ? /*#__PURE__*/_jsx(CircularProgress, {
188
- size: 14,
189
- style: {
190
- marginRight: "10px"
191
- }
192
- }) : null, saveBtnLabel]
182
+ children: saveBtnLabel
193
183
  })]
194
184
  })]
195
185
  })
@@ -144,7 +144,11 @@ const style = () => ({
144
144
  border: "1px solid #2563EB",
145
145
  background: "#EBF1F9",
146
146
  height: "34px",
147
- textTransform: "unset"
147
+ textTransform: "unset",
148
+ fontWeight: "bold",
149
+ "&:hover": {
150
+ background: "#EBF1F9"
151
+ }
148
152
  },
149
153
  ".seondaryOutlineBtn": {
150
154
  border: "1px solid #D8DDE1",
@@ -152,8 +156,12 @@ const style = () => ({
152
156
  // boxShadow: "0px 4px 10px 0px #00000026",
153
157
  height: "34px",
154
158
  textTransform: "unset",
155
- background: "#eceef3",
156
- color: "#64748B"
159
+ background: "#f5f6f9 !important",
160
+ color: "#64748B !important",
161
+ "&:hover": {
162
+ border: "1px solid #D8DDE1",
163
+ background: "#f5f6f9 !important"
164
+ }
157
165
  },
158
166
  ".blueBtn": {
159
167
  boxShadow: "0px 4px 10px 0px #00000026",
@@ -162,6 +170,7 @@ const style = () => ({
162
170
  textTransform: "unset",
163
171
  height: "34px",
164
172
  color: "#fff",
173
+ fontWeight: "bold",
165
174
  "&.disabled": {
166
175
  background: "#D9D9DD !important",
167
176
  color: "#fff !important"
@@ -1,4 +1,4 @@
1
- import { Editor, Transforms, Element as SlateElement, Range } from "slate";
1
+ import { Editor, Transforms, Element as SlateElement, Range, Text, Element } from "slate";
2
2
  import { Box } from "@mui/material";
3
3
  import { sizeMap } from "./font";
4
4
  import Link from "../Elements/Link/Link";
@@ -55,22 +55,14 @@ const LIST_FORMAT_TYPE = {
55
55
  orderedList: "list-item",
56
56
  unorderedList: "list-item"
57
57
  };
58
-
59
- // const NEWLINESAFTER = [
60
- // "headingOne",
61
- // "headingTwo",
62
- // "headingThree",
63
- // "headingFour",
64
- // "headingFive",
65
- // "headingSix",
66
- // ];
67
-
58
+ const NEWLINESAFTER = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix"];
68
59
  const THEME_BLOCK_FIELDS = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
69
60
  export const toggleBlock = (editor, format, selection = true, attr = {}) => {
70
61
  const isActive = isBlockActive(editor, format);
71
62
  const isList = list_types.includes(format);
72
63
  const isIndent = alignment.includes(format);
73
64
  const isAligned = alignment.some(alignmentType => isBlockActive(editor, alignmentType));
65
+ console.log(isAligned, isIndent);
74
66
 
75
67
  /*If the node is already aligned and change in indent is called we should unwrap it first and split the node to prevent
76
68
  messy, nested DOM structure and bugs due to that.*/
@@ -83,10 +75,29 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
83
75
 
84
76
  /* Wraping the nodes for alignment, to allow it to co-exist with other block level operations*/
85
77
  if (isIndent) {
86
- Transforms.wrapNodes(editor, {
87
- type: format,
88
- children: []
78
+ const [nodeEntry] = Editor.nodes(editor, {
79
+ at: editor.selection,
80
+ match: n => Element.isElement(n) && NEWLINESAFTER.indexOf(n.type) > -1
89
81
  });
82
+ // for heading background preserve while alignment change
83
+ if (nodeEntry) {
84
+ // for headings alone
85
+ Transforms.wrapNodes(editor, {
86
+ type: format,
87
+ children: []
88
+ }, {
89
+ at: editor.selection,
90
+ match: n => {
91
+ return Text.isText(n);
92
+ }
93
+ });
94
+ } else {
95
+ // follow old logic
96
+ Transforms.wrapNodes(editor, {
97
+ type: format,
98
+ children: []
99
+ });
100
+ }
90
101
  return;
91
102
  }
92
103
  Transforms.unwrapNodes(editor, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "9.4.7",
3
+ "version": "9.4.8",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"