@flozy/editor 9.0.1 → 9.0.3

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.
@@ -1280,8 +1280,8 @@ blockquote {
1280
1280
  }
1281
1281
  @media (max-width: 899px) {
1282
1282
  /* Qa validation required */
1283
- /* .MuiPopover-root {
1284
- z-index: 1302 !important;
1283
+ /* .MuiPopover-root {
1284
+ z-index: 1302 !important;
1285
1285
  } */
1286
1286
 
1287
1287
  canvas {
@@ -43,19 +43,21 @@ const ColorPicker = props => {
43
43
  };
44
44
  const handleFormSubmit = color => {
45
45
  if (!color) return;
46
- selection && Transforms.select(editor, selection);
46
+ // selection && Transforms.select(editor, selection);
47
47
  addMarkData(editor, {
48
48
  format,
49
49
  value: color
50
50
  });
51
- selection && ReactEditor.focus(editor);
52
- handleClose();
51
+ // selection && ReactEditor.focus(editor);
52
+ // handleClose();
53
53
  };
54
+
54
55
  const onSelect = color => {
55
56
  handleFormSubmit(color);
56
57
  };
57
58
  const handleClose = () => {
58
59
  setAnchorEl(null);
60
+ setSelection(null);
59
61
  };
60
62
  const activeColor = activeMark(editor, format) || DEFAULT_COLOR[format];
61
63
  return /*#__PURE__*/_jsxs(_Fragment, {
@@ -869,14 +869,19 @@ const usePopupStyle = theme => ({
869
869
  overflow: "auto",
870
870
  backgroundColor: theme?.palette?.editor?.background,
871
871
  borderRadius: "14px !important",
872
- border: `1px solid ${theme?.palette?.editor?.inputFieldBorder} !important`
872
+ border: `1px solid ${theme?.palette?.editor?.inputFieldBorder} !important`,
873
+ minWidth: "fit-content",
874
+ "@media only screen and (max-width: 599px)": {
875
+ left: "0px !important"
876
+ }
873
877
  },
874
878
  "& .popup_tabs": {
875
- backgroundColor: theme?.palette?.editor?.inputFieldBgColor,
876
- "@media only screen and (max-width: 899px)": {
877
- width: "100% !important"
878
- }
879
+ backgroundColor: theme?.palette?.editor?.inputFieldBgColor
880
+ // "@media only screen and (max-width: 599px)": {
881
+ // width: "100% !important",
882
+ // },
879
883
  },
884
+
880
885
  "& .popup_tabs-header": {
881
886
  fontFamily: "Inter, sans-serif",
882
887
  fontWeight: 700,
@@ -14,7 +14,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  const PopupTool = props => {
15
15
  const {
16
16
  theme,
17
- setIsTextSelected,
18
17
  customProps,
19
18
  editorWrapper
20
19
  } = props;
@@ -35,9 +34,14 @@ const PopupTool = props => {
35
34
  const {
36
35
  selectedElement
37
36
  } = useEditorContext();
37
+ console.log("Editor debug ====>", event, open, anchorEl, selection);
38
38
  const updateAnchorEl = useCallback(() => {
39
39
  try {
40
+ const {
41
+ selection
42
+ } = editor;
40
43
  const isHavingSelection = selection && !Range.isCollapsed(selection);
44
+ console.log("Editor isHavingSelection", isHavingSelection, selection);
41
45
  if (isHavingSelection) {
42
46
  const domRange = ReactEditor.toDOMRange(editor, editor.selection);
43
47
  const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
@@ -47,6 +51,7 @@ const PopupTool = props => {
47
51
  rect.y = -500; // hide the popper
48
52
  }
49
53
 
54
+ console.log("Editor setAnchorEl", rect, domRange, editorContainer);
50
55
  setAnchorEl({
51
56
  clientWidth: rect.width,
52
57
  clientHeight: rect.height,
@@ -56,7 +61,7 @@ const PopupTool = props => {
56
61
  } catch (err) {
57
62
  console.log(err);
58
63
  }
59
- }, [selection]);
64
+ }, [editor?.selection]);
60
65
  useEditorScroll(editorWrapper, updateAnchorEl);
61
66
  useEffect(() => {
62
67
  const userStoppedSelection = size?.device === "xs" ? true : event === "end"; // for mobile, when user starts the selection, we are gonna show the popup tool
@@ -71,34 +76,44 @@ const PopupTool = props => {
71
76
  if (!isCarouselEdit) {
72
77
  setOpen(true);
73
78
  setPopupType("textFormat");
74
- setIsTextSelected(true);
79
+ // setIsTextSelected(true);
75
80
  }
76
81
  } else if (!anchorEl) {
77
82
  setOpen(false);
78
83
  setPopupType("");
79
- setIsTextSelected(false);
84
+ // setIsTextSelected(false);
80
85
  }
81
86
  }, [event, anchorEl]);
82
87
  useEffect(() => {
88
+ console.log("Editor useEffect", selection);
83
89
  if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "") {
84
90
  setAnchorEl(null);
85
91
  } else {
92
+ console.log("Editor updateAnchorEl", selection);
86
93
  updateAnchorEl();
87
94
  hideSlateSelection(); // removes slate selection background, when there is no selection
88
95
  }
89
- }, [selection]);
96
+ }, [editor?.selection]);
90
97
  useEffect(() => {
91
- if (selectedElement?.enable === 1) {
98
+ const {
99
+ path,
100
+ enable
101
+ } = selectedElement || {};
102
+ const isFreeGridElement = path && path.split("|").length > 2;
103
+ if (enable === 1 && isFreeGridElement) {
104
+ console.log("Editor useEffect isFreeGridElement", selectedElement);
92
105
  setAnchorEl(null);
93
106
  }
94
107
  }, [selection, selectedElement?.path, selectedElement?.enable]);
95
108
  const handleClose = () => {
109
+ console.log("Editor closing");
96
110
  // setAnchorEl(null);
97
111
  setOpen(false);
98
112
  setPopupType("");
99
113
  };
100
114
  return open && !openAI ? /*#__PURE__*/_jsx(ClickAwayListener, {
101
115
  onClickAway: e => {
116
+ console.log("ClickAwayListener", e.target, document.body, e.target !== document.body);
102
117
  // close the mini toolbar, if user clicks outside the editor (in Flozy app.)
103
118
  if (e.target !== document.body) {
104
119
  // e.target returns body, if the user clicks material ui select popup inside the tool bar, on that time, we don't need to close
@@ -19,7 +19,7 @@ const Upload = props => {
19
19
  xs: 12,
20
20
  sx: {
21
21
  padding: "10px",
22
- height: '100%'
22
+ height: "100%"
23
23
  },
24
24
  className: "ims-right",
25
25
  children: /*#__PURE__*/_jsx(Uploader, {
@@ -5,9 +5,9 @@ const UploadStyles = theme => ({
5
5
  borderRadius: "11px",
6
6
  boxShadow: "0px 4px 10px rgba(0, 0, 0, 0.16)",
7
7
  background: theme?.palette?.editor?.uploadFileBg,
8
- height: '100%',
9
- minHeight: '150px',
10
- height: 'inherit'
8
+ height: "100%",
9
+ minHeight: "150px",
10
+ height: "inherit"
11
11
  },
12
12
  uploadField: {
13
13
  width: "100%",
@@ -19,21 +19,21 @@ const UploadStyles = theme => ({
19
19
  backgroundColor: theme?.palette?.editor?.uploadFileInnerBg,
20
20
  borderRadius: "9px",
21
21
  border: "1px dashed #2563EB",
22
- minHeight: '150px'
22
+ minHeight: "150px"
23
23
  },
24
24
  uploadIcon: {
25
25
  display: "grid !important",
26
26
  "& svg": {
27
- display: 'flex',
28
- width: '100%',
27
+ display: "flex",
28
+ width: "100%",
29
29
  "& path": {
30
30
  stroke: "#2563EB"
31
31
  }
32
32
  },
33
- '& span': {
34
- display: 'flex',
35
- width: '100%',
36
- marginTop: '5px'
33
+ "& span": {
34
+ display: "flex",
35
+ width: "100%",
36
+ marginTop: "5px"
37
37
  }
38
38
  }
39
39
  });
@@ -58,6 +58,7 @@ const useElementSettingsStyle = theme => ({
58
58
  maxHeight: "500px",
59
59
  overflowX: "hidden",
60
60
  overflowY: "auto",
61
+ paddingLeft: "4px",
61
62
  background: theme?.palette?.editor?.background,
62
63
  paddingLeft: "4px",
63
64
  "& .MuiTypography-root, .MuiInputBase-root, input": {
@@ -1,26 +1,20 @@
1
- import { useEffect, useState } from "react";
1
+ import { useCallback, useEffect, useState } from "react";
2
2
  const useDrag = () => {
3
3
  const [event, setEvent] = useState("");
4
- useEffect(() => {
5
- addListener();
6
- return () => {
7
- removeListener();
8
- };
9
- }, []);
10
- const onMouseDown = () => {
4
+ const onMouseDown = useCallback(() => {
11
5
  setEvent("start");
12
- };
13
- const onMouseUp = () => {
6
+ }, []);
7
+ const onMouseUp = useCallback(() => {
14
8
  setEvent("end");
15
- };
16
- const addListener = () => {
9
+ }, []);
10
+ useEffect(() => {
17
11
  document.addEventListener("pointerdown", onMouseDown);
18
12
  document.addEventListener("pointerup", onMouseUp);
19
- };
20
- const removeListener = () => {
21
- document.removeEventListener("pointerdown", onMouseDown);
22
- document.removeEventListener("pointerup", onMouseUp);
23
- };
13
+ return () => {
14
+ document.removeEventListener("pointerdown", onMouseDown);
15
+ document.removeEventListener("pointerup", onMouseUp);
16
+ };
17
+ }, []);
24
18
  return [event];
25
19
  };
26
20
  export default useDrag;
@@ -4,6 +4,7 @@ function useEditorScroll(editorWrapper = {
4
4
  }, callback) {
5
5
  useEffect(() => {
6
6
  const handleScroll = () => {
7
+ console.log("Editor debug useEditorScroll ====>", editorWrapper, callback);
7
8
  if (editorWrapper.current) {
8
9
  callback();
9
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "9.0.1",
3
+ "version": "9.0.3",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -61,7 +61,7 @@
61
61
  "scripts": {
62
62
  "prepare": "husky install .husky",
63
63
  "analyze": "source-map-explorer build/static/js/*.js",
64
- "lint": "./node_modules/.bin/eslint --ignore-path .gitignore .",
64
+ "lint": "./node_modules/. bin/eslint --ignore-path .gitignore .",
65
65
  "start": "craco start",
66
66
  "build": "NODE_OPTIONS='--max_old_space_size=4096' craco build",
67
67
  "test": "craco test --passWithNoTests",