@flozy/editor 4.9.3 → 4.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1214,14 +1214,6 @@ blockquote {
1214
1214
  position: absolute;
1215
1215
  }
1216
1216
 
1217
- .dividerComponent:hover {
1218
- padding: 10px 0;
1219
- }
1220
-
1221
- .dividerComponent.readonlyDivider:hover {
1222
- padding: 0;
1223
- }
1224
-
1225
1217
  .dividerComponent:hover .divider-settings {
1226
1218
  display: block;
1227
1219
  }
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef, useState } from "react";
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
2
  import { useEditorContext } from "../../hooks/useMouseMove";
3
3
  import Styles from "./Styles";
4
4
  import { Fade, Paper, Popper } from "@mui/material";
@@ -178,9 +178,9 @@ function PopoverAIInput({
178
178
  const selectedEleRef = useRef({});
179
179
  const classes = Styles();
180
180
  const editor = useSlate();
181
- const updateAnchor = () => {
181
+ const updateAnchor = useCallback(() => {
182
182
  updateAnchorEl(setAnchorEl, editor, openAI, selectedEleRef.current);
183
- };
183
+ }, [setAnchorEl, editor, openAI, selectedEleRef.current]);
184
184
  useEditorScroll(editorWrapper, updateAnchor);
185
185
  const onClickOutside = () => {
186
186
  setAnchorEl(null);
@@ -52,10 +52,13 @@ const Carousel = props => {
52
52
  useEffect(() => {
53
53
  setRefresh(new Date().getTime());
54
54
  }, []);
55
+
56
+ //comment this for carosul selection on insert
55
57
  useEffect(() => {
56
58
  if (!edit) {
57
59
  ReactEditor.focus(editor);
58
60
  Transforms.select(editor, ReactEditor.findPath(editor, element));
61
+ Transforms.deselect(editor);
59
62
  }
60
63
  }, [edit]);
61
64
  const onAddSlide = () => {
@@ -100,11 +100,12 @@ const Divider = props => {
100
100
  };
101
101
  return /*#__PURE__*/_jsxs("div", {
102
102
  ...attributes,
103
- className: `dividerComponent ${readOnly ? 'readonlyDivider' : ''}`,
103
+ className: `dividerComponent`,
104
104
  style: {
105
105
  userSelect: "none",
106
106
  position: 'relative'
107
107
  },
108
+ contentEditable: false,
108
109
  children: [!readOnly && /*#__PURE__*/_jsx("div", {
109
110
  className: `element-root element-selector`,
110
111
  contentEditable: false,
@@ -124,7 +125,8 @@ const Divider = props => {
124
125
  userSelect: "none",
125
126
  borderTop: !borderColor?.includes("linear") ? `${width} ${borderStyle} ${borderColor}` : `transparent`,
126
127
  backgroundImage: borderColor?.includes("linear") ? borderColor : "none",
127
- height: borderColor?.includes("linear") ? borderWidth : undefined
128
+ height: borderColor?.includes("linear") ? borderWidth : undefined,
129
+ marginTop: '15px'
128
130
  }
129
131
  }), /*#__PURE__*/_jsx("span", {
130
132
  style: {
@@ -27,7 +27,7 @@ const SearchAttachment = props => {
27
27
  metadata?.actionHandler(type, element);
28
28
  }
29
29
  };
30
- return /*#__PURE__*/_jsxs(Box, {
30
+ return /*#__PURE__*/_jsx(Box, {
31
31
  component: "div",
32
32
  className: "attachment-wrpr-ev2",
33
33
  ...attributes,
@@ -35,7 +35,7 @@ const SearchAttachment = props => {
35
35
  style: {
36
36
  display: "block"
37
37
  },
38
- children: [/*#__PURE__*/_jsxs(Card, {
38
+ children: /*#__PURE__*/_jsxs(Card, {
39
39
  style: {
40
40
  display: "flex",
41
41
  justifyContent: "flex-start",
@@ -45,7 +45,7 @@ const SearchAttachment = props => {
45
45
  padding: "0px 10px",
46
46
  boxShadow: "none",
47
47
  border: `1px solid ${theme?.palette?.primary?.slashBrainBorder}`,
48
- borderRadius: "7px",
48
+ borderRadius: "7px !important",
49
49
  background: theme?.palette?.containers?.slashBrainCardBg,
50
50
  cursor: 'pointer',
51
51
  "& *::selection": {
@@ -76,7 +76,7 @@ const SearchAttachment = props => {
76
76
  paddingBottom: '3px'
77
77
  }
78
78
  },
79
- children: /*#__PURE__*/_jsx(Typography, {
79
+ children: /*#__PURE__*/_jsxs(Typography, {
80
80
  sx: {
81
81
  fontWeight: "500",
82
82
  background: theme?.palette?.text?.slashBrainText,
@@ -95,13 +95,10 @@ const SearchAttachment = props => {
95
95
  },
96
96
  component: "div",
97
97
  variant: "subtitle1",
98
- children: label
98
+ children: [label, children]
99
99
  })
100
100
  })]
101
- }), /*#__PURE__*/_jsx("span", {
102
- contentEditable: false,
103
- children: children
104
- })]
101
+ })
105
102
  });
106
103
  };
107
104
  export default SearchAttachment;
@@ -19,8 +19,7 @@ const usePopupStyle = theme => ({
19
19
  },
20
20
  "& .MuiPaper-root": {
21
21
  backgroundColor: `${theme?.palette?.editor?.textFormatBgColor} !important`,
22
- borderRadius: "19px !important",
23
- paddingBottom: "10px !important"
22
+ borderRadius: "19px !important"
24
23
  },
25
24
  "& .MuiDialog-paperFullScreen": {
26
25
  borderRadius: "0px !important"
@@ -1,7 +1,7 @@
1
- import React, { useEffect, useState } from "react";
1
+ import React, { useCallback, useEffect, useState } from "react";
2
2
  import { Popper, Fade, Paper, ClickAwayListener } from "@mui/material";
3
3
  import { Editor, Range } from "slate";
4
- import { useSlate } from "slate-react";
4
+ import { ReactEditor, useSlate } from "slate-react";
5
5
  import useDrag from "../../hooks/useDrag";
6
6
  import useWindowResize from "../../hooks/useWindowResize";
7
7
  import MiniTextFormat from "./MiniTextFormat";
@@ -33,16 +33,18 @@ const PopupTool = props => {
33
33
  const {
34
34
  selectedElement
35
35
  } = useEditorContext();
36
- const updateAnchorEl = () => {
36
+ const updateAnchorEl = useCallback(() => {
37
37
  try {
38
- const domSelection = window.getSelection();
39
- const domRange = domSelection?.getRangeAt(0);
40
- const {
41
- startOffset,
42
- endOffset
43
- } = domRange || {};
44
- if (startOffset !== endOffset) {
38
+ const isHavingSelection = selection && !Range.isCollapsed(selection);
39
+ if (isHavingSelection) {
40
+ const domRange = ReactEditor.toDOMRange(editor, editor.selection);
41
+ const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
45
42
  const rect = domRange.getBoundingClientRect();
43
+ const isOutside = rect.bottom < editorContainer.top || rect.top > editorContainer.bottom;
44
+ if (isOutside) {
45
+ rect.y = -500; // hide the popper
46
+ }
47
+
46
48
  setAnchorEl({
47
49
  clientWidth: rect.width,
48
50
  clientHeight: rect.height,
@@ -52,7 +54,7 @@ const PopupTool = props => {
52
54
  } catch (err) {
53
55
  console.log(err);
54
56
  }
55
- };
57
+ }, [selection]);
56
58
  useEditorScroll(editorWrapper, updateAnchorEl);
57
59
  useEffect(() => {
58
60
  const userStoppedSelection = size?.device === "xs" ? true : event === "end"; // for mobile, when user starts the selection, we are gonna show the popup tool
@@ -12,7 +12,7 @@ const usePopupStyles = theme => ({
12
12
  background: `${theme?.palette?.editor?.miniToolBarBackground} !important`,
13
13
  "& .MuiBox-root": {
14
14
  "& .renderComp": {
15
- padding: "2px 0px",
15
+ padding: "2px 0px 2px 1px",
16
16
  background: "transparent !important"
17
17
  },
18
18
  "& button": {
@@ -128,41 +128,15 @@ const FormSettings = props => {
128
128
  }, `accordion_${i}`)
129
129
  }, i);
130
130
  } else {
131
- return /*#__PURE__*/_jsx(ThemeProvider, {
132
- theme: muiTheme,
133
- children: /*#__PURE__*/_jsxs(Accordion, {
134
- defaultExpanded: true,
135
- children: [/*#__PURE__*/_jsx(AccordionSummary, {
136
- expandIcon: /*#__PURE__*/_jsx(ExpandMoreOutlined, {}),
137
- sx: {
138
- padding: "5px"
139
- },
140
- children: /*#__PURE__*/_jsx(Typography, {
141
- variant: "body1",
142
- className: "settingsHeader",
143
- color: "primary",
144
- style: {
145
- fontSize: "14px !important",
146
- fontWeight: "400"
147
- },
148
- children: m?.tab
149
- })
150
- }), /*#__PURE__*/_jsx(AccordionDetails, {
151
- sx: {
152
- padding: "0px"
153
- },
154
- children: /*#__PURE__*/_jsx(StyleContent, {
155
- renderTabs: styleMaps,
156
- value: m.value,
157
- element: element,
158
- customElement: element?.children?.[0] || null,
159
- onChange: onChange,
160
- customProps: customProps,
161
- handleClose: handleClose
162
- }, `tab_${m.value}_$${i}`)
163
- })]
164
- }, `accordion_${i}`)
165
- }, i);
131
+ return /*#__PURE__*/_jsx(StyleContent, {
132
+ renderTabs: styleMaps,
133
+ value: m.value,
134
+ element: element,
135
+ customElement: element?.children?.[0] || null,
136
+ onChange: onChange,
137
+ customProps: customProps,
138
+ handleClose: handleClose
139
+ }, `tab_${m.value}_$${i}`);
166
140
  }
167
141
  })
168
142
  });
@@ -174,82 +174,114 @@ export const formStyle = [{
174
174
  }, {
175
175
  tab: "Field Settings",
176
176
  value: "FieldSetting",
177
- hasChildrenTabs: false,
177
+ hasChildrenTabs: true,
178
178
  fields: [{
179
- label: "Font Family",
180
- key: "fieldFontFamily",
181
- type: "textOptions",
182
- hideMetaDataOptions: true,
183
- options: fontOptions,
184
- webFont: true,
185
- renderOption: option => {
186
- return /*#__PURE__*/_jsx("span", {
187
- style: {
188
- fontFamily: option.value
189
- },
190
- children: option.text
191
- });
192
- }
179
+ tab: "Font Family",
180
+ value: "FontFamily",
181
+ fields: [{
182
+ label: "Font Family",
183
+ key: "fieldFontFamily",
184
+ type: "textOptions",
185
+ hideMetaDataOptions: true,
186
+ options: fontOptions,
187
+ webFont: true,
188
+ renderOption: option => {
189
+ return /*#__PURE__*/_jsx("span", {
190
+ style: {
191
+ fontFamily: option.value
192
+ },
193
+ children: option.text
194
+ });
195
+ }
196
+ }]
193
197
  }, {
194
- label: "Font Weight",
195
- key: "fieldFontWeight",
196
- type: "textOptions",
197
- width: 5,
198
- options: fontWeightOptions,
199
- hideMetaDataOptions: true,
200
- renderOption: option => {
201
- return /*#__PURE__*/_jsx("span", {
202
- style: {
203
- fontWeight: option.value
204
- },
205
- children: option.text
206
- });
207
- }
198
+ tab: "Font Weight",
199
+ value: "FontWeight",
200
+ fields: [{
201
+ label: "Font Weight",
202
+ key: "fieldFontWeight",
203
+ type: "textOptions",
204
+ width: 5,
205
+ options: fontWeightOptions,
206
+ hideMetaDataOptions: true,
207
+ renderOption: option => {
208
+ return /*#__PURE__*/_jsx("span", {
209
+ style: {
210
+ fontWeight: option.value
211
+ },
212
+ children: option.text
213
+ });
214
+ }
215
+ }]
208
216
  }, {
209
- label: "Font Size",
210
- key: "fieldTextSize",
211
- type: "fontSize",
212
- width: 5,
213
- placeholder: "16px"
217
+ tab: "Font Size",
218
+ value: "FontSize",
219
+ fields: [{
220
+ label: "Font Size",
221
+ key: "fieldTextSize",
222
+ type: "fontSize",
223
+ width: 5,
224
+ placeholder: "16px"
225
+ }]
214
226
  }, {
215
- label: "Text Color",
216
- key: "fieldTextColor",
217
- type: "color",
218
- needPreview: true
227
+ tab: "Text Color",
228
+ value: "TextColor",
229
+ fields: [{
230
+ label: "Text Color",
231
+ key: "fieldTextColor",
232
+ type: "color",
233
+ needPreview: true
234
+ }]
219
235
  }, {
220
- label: "Background Color",
221
- key: "fieldBgColor",
222
- type: "color"
236
+ tab: "Background Color",
237
+ value: "BackgroundColor",
238
+ fields: [{
239
+ label: "Background Color",
240
+ key: "fieldBgColor",
241
+ type: "color"
242
+ }]
223
243
  }, {
224
- label: "Border Color",
225
- key: "fieldBorderColor",
226
- type: "color"
244
+ tab: "Border Color",
245
+ value: "BorderColor",
246
+ fields: [{
247
+ label: "Border Color",
248
+ key: "fieldBorderColor",
249
+ type: "color"
250
+ }]
227
251
  }, {
228
- label: "Border Width",
229
- key: "fieldBorderWidth",
230
- type: "text",
231
- width: 5,
232
- placeholder: "1px"
252
+ tab: "Border Width",
253
+ value: "BorderWidth",
254
+ fields: [{
255
+ label: "Border Width",
256
+ key: "fieldBorderWidth",
257
+ type: "text",
258
+ width: 5,
259
+ placeholder: "1px"
260
+ }]
233
261
  }, {
234
- label: "Border Style",
235
- key: "fieldBorderStyle",
236
- type: "textOptions",
237
- hideMetaDataOptions: true,
238
- width: 5,
239
- options: [{
240
- text: "Solid",
241
- value: "solid"
242
- }, {
243
- text: "Dotted",
244
- value: "dotted"
245
- }, {
246
- text: "Dashed",
247
- value: "dashed"
248
- }],
249
- renderOption: option => {
250
- return /*#__PURE__*/_jsx("span", {
251
- children: option.text
252
- });
253
- }
262
+ tab: "Border Style",
263
+ value: "BorderStyle",
264
+ fields: [{
265
+ label: "Border Style",
266
+ key: "fieldBorderStyle",
267
+ type: "textOptions",
268
+ hideMetaDataOptions: true,
269
+ width: 5,
270
+ options: [{
271
+ text: "Solid",
272
+ value: "solid"
273
+ }, {
274
+ text: "Dotted",
275
+ value: "dotted"
276
+ }, {
277
+ text: "Dashed",
278
+ value: "dashed"
279
+ }],
280
+ renderOption: option => {
281
+ return /*#__PURE__*/_jsx("span", {
282
+ children: option.text
283
+ });
284
+ }
285
+ }]
254
286
  }]
255
287
  }];
@@ -214,40 +214,14 @@ const StyleBuilder = props => {
214
214
  }, `accordion_${i}`)
215
215
  }, i);
216
216
  } else {
217
- return /*#__PURE__*/_jsx(ThemeProvider, {
218
- theme: muiTheme,
219
- children: /*#__PURE__*/_jsxs(Accordion, {
220
- defaultExpanded: true,
221
- children: [/*#__PURE__*/_jsx(AccordionSummary, {
222
- expandIcon: /*#__PURE__*/_jsx(ExpandMoreOutlined, {}),
223
- sx: {
224
- padding: "0px"
225
- },
226
- children: /*#__PURE__*/_jsx(Typography, {
227
- variant: "body1",
228
- className: "settingsHeader",
229
- color: "primary",
230
- style: {
231
- fontSize: "14px !important",
232
- fontWeight: "400"
233
- },
234
- children: m?.tab
235
- })
236
- }), /*#__PURE__*/_jsx(AccordionDetails, {
237
- sx: {
238
- padding: "5px"
239
- },
240
- children: /*#__PURE__*/_jsx(StyleContent, {
241
- renderTabs: renderTabs,
242
- value: m.value,
243
- element: elementProps,
244
- onChange: onElementPropsChange,
245
- customProps: customProps,
246
- handleClose: handleClose
247
- }, `tab_${m.value}_$${i}`)
248
- })]
249
- }, `accordion_${i}`)
250
- }, i);
217
+ return /*#__PURE__*/_jsx(StyleContent, {
218
+ renderTabs: renderTabs,
219
+ value: m.value,
220
+ element: elementProps,
221
+ onChange: onElementPropsChange,
222
+ customProps: customProps,
223
+ handleClose: handleClose
224
+ }, `tab_${m.value}_$${i}`);
251
225
  }
252
226
  })
253
227
  }), needActions ? /*#__PURE__*/_jsxs(DialogActions, {
@@ -19,6 +19,6 @@ function useEditorScroll(editorWrapper = {
19
19
  currentEditorWrapper.removeEventListener("scroll", handleScroll);
20
20
  }
21
21
  };
22
- }, [editorWrapper.current]);
22
+ }, [editorWrapper.current, callback]);
23
23
  }
24
24
  export default useEditorScroll;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "4.9.3",
3
+ "version": "4.9.4",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"