@flozy/editor 9.0.2 → 9.0.4

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.
@@ -54,13 +54,14 @@ const Item = /*#__PURE__*/forwardRef(({
54
54
  });
55
55
  });
56
56
  Item.displayName = "Item";
57
- const Element = props => {
57
+ const Element = /*#__PURE__*/React.memo(props => {
58
58
  return /*#__PURE__*/_jsx(Section, {
59
59
  ...props,
60
60
  children: getBlock(props)
61
61
  });
62
- };
63
- const Leaf = ({
62
+ });
63
+ Element.displayName = "Element";
64
+ const Leaf = /*#__PURE__*/React.memo(({
64
65
  attributes,
65
66
  children,
66
67
  leaf
@@ -71,7 +72,8 @@ const Leaf = ({
71
72
  ...attributes,
72
73
  children: children
73
74
  });
74
- };
75
+ });
76
+ Leaf.displayName = "Leaf";
75
77
  const updateTopBanner = (content = [], setTopBanner) => {
76
78
  setTopBanner(() => {
77
79
  const firstNode = content ? content[0] : {};
@@ -314,7 +316,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
314
316
  updateTopBanner(newValue, setTopBanner);
315
317
  debounced(newValue);
316
318
  if (!isInteracted) {
317
- setIsInteracted(true);
319
+ // setIsInteracted(true);
318
320
  }
319
321
  }
320
322
  };
@@ -495,7 +497,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
495
497
  ...props,
496
498
  fullScreen: fullScreen,
497
499
  footer: footer || "",
498
- children: /*#__PURE__*/_jsx(Box, {
500
+ children: /*#__PURE__*/_jsxs(Box, {
499
501
  component: "div",
500
502
  className: `et-wrpr stimulate-${breakpoint} ${editorClass || ""} ${isIframe ? "iframe-editor" : ""}`,
501
503
  sx: classes.root,
@@ -505,7 +507,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
505
507
  "data-breakpoint": breakpoint
506
508
  // onContextMenu={handleContextMenu}
507
509
  ,
508
- children: /*#__PURE__*/_jsxs(Slate, {
510
+ children: [/*#__PURE__*/_jsxs(Slate, {
509
511
  editor: editor,
510
512
  initialValue: getInitialValue(debouncedValue?.current, readOnly),
511
513
  onChange: handleEditorChange,
@@ -606,10 +608,13 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
606
608
  }), htmlAction.showInput && /*#__PURE__*/_jsx(CodeToText, {
607
609
  ...htmlAction,
608
610
  handleCodeToText: handleCodeToText
609
- }), /*#__PURE__*/_jsx(FontLoader, {
610
- ...props
611
611
  })]
612
- }, id)
612
+ }, id), /*#__PURE__*/_jsx(FontLoader, {
613
+ otherProps: {
614
+ services: otherProps?.services
615
+ },
616
+ readOnly: readOnly
617
+ })]
613
618
  })
614
619
  })
615
620
  });
@@ -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,21 +43,19 @@ 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
-
55
54
  const onSelect = color => {
56
55
  handleFormSubmit(color);
57
56
  };
58
57
  const handleClose = () => {
59
58
  setAnchorEl(null);
60
- setSelection(null);
61
59
  };
62
60
  const activeColor = activeMark(editor, format) || DEFAULT_COLOR[format];
63
61
  return /*#__PURE__*/_jsxs(_Fragment, {
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { useSlateStatic, useSelected, ReactEditor } from "slate-react";
3
3
  import { Box } from "@mui/material";
4
- import { getPageSettings } from "../../utils/pageSettings";
4
+ // import { getPageSettings } from "../../utils/pageSettings";
5
5
  import { isTextSelected } from "../../utils/helper";
6
6
  import { useEditorContext } from "../../hooks/useMouseMove";
7
7
  import SimpleTextStyle from "./style";
@@ -12,7 +12,6 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
12
12
  import { createElement as _createElement } from "react";
13
13
  const SimpleText = props => {
14
14
  const {
15
- theme,
16
15
  openAI
17
16
  } = useEditorContext() || {};
18
17
  const editor = useSlateStatic();
@@ -28,20 +27,10 @@ const SimpleText = props => {
28
27
  readOnly,
29
28
  editorPlaceholder
30
29
  } = customProps;
31
- const {
32
- element: pageSt
33
- } = getPageSettings(editor) || {};
34
- const {
35
- pageColor
36
- } = pageSt?.pageProps || {};
37
- const {
38
- activeBreakPoint
39
- } = useEditorContext();
40
- const lineHeight = element?.children[0]?.lineHeight;
41
- const lineH = getBreakpointLineSpacing(lineHeight, activeBreakPoint);
30
+ // const { element: pageSt } = getPageSettings(editor) || {};
31
+ // const { pageColor } = pageSt?.pageProps || {};
42
32
  const classes = SimpleTextStyle({
43
- pageColor: pageColor || theme?.palette?.editor?.background || "#FFFFFF",
44
- lineHeight: lineH
33
+ pageColor: "#FFFFFF"
45
34
  });
46
35
  const selected = useSelected();
47
36
  const path = ReactEditor.findPath(editor, element);
@@ -59,14 +48,14 @@ const SimpleText = props => {
59
48
  contentEditable: false,
60
49
  className: "placeholder-simple-text",
61
50
  children: isEmptyEditor ? editorPlaceholder || "Write Something..." : showPlaceHolder ? opacity && selected ? /*#__PURE__*/_jsxs(_Fragment, {
62
- children: ["Type ", /*#__PURE__*/_jsx("span", {
51
+ children: ["Type", " ", /*#__PURE__*/_jsx("span", {
63
52
  style: {
64
- backgroundColor: '#F2F6FA',
53
+ backgroundColor: "#F2F6FA",
65
54
  padding: "0px 2px",
66
55
  borderRadius: "2px"
67
56
  },
68
57
  children: "/"
69
- }), " to browse elements"]
58
+ }), " ", "to browse elements"]
70
59
  }) : "" : ""
71
60
  }));
72
61
  };
@@ -1,5 +1,5 @@
1
- import React, { useCallback, useEffect, useState } from "react";
2
- import { Popper, Fade, Paper, ClickAwayListener } from "@mui/material";
1
+ import React, { useEffect, useState } from "react";
2
+ import { Popper, Paper, ClickAwayListener } from "@mui/material";
3
3
  import { Editor, Range, Transforms } from "slate";
4
4
  import { ReactEditor, useSlate } from "slate-react";
5
5
  import useDrag from "../../hooks/useDrag";
@@ -14,13 +14,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  const PopupTool = props => {
15
15
  const {
16
16
  theme,
17
+ setIsTextSelected,
17
18
  customProps,
18
19
  editorWrapper
19
20
  } = props;
20
21
  const classes = usePopupStyles(theme);
21
22
  const {
22
23
  setPopupType,
23
- openAI
24
+ openAI,
25
+ selectedElement
24
26
  } = useEditorContext();
25
27
  const [anchorEl, setAnchorEl] = useState(null);
26
28
  const [open, setOpen] = useState(false);
@@ -31,18 +33,10 @@ const PopupTool = props => {
31
33
  const [event] = useDrag(anchorEl);
32
34
  const id = open ? "popup-edit-tool" : "";
33
35
  const [size] = useWindowResize();
34
- const {
35
- selectedElement
36
- } = useEditorContext();
37
- console.log("Editor debug ====>", event, open, anchorEl, selection);
38
- const updateAnchorEl = useCallback(() => {
36
+ const updateAnchorEl = isScroll => {
39
37
  try {
40
- const {
41
- selection
42
- } = editor;
43
38
  const isHavingSelection = selection && !Range.isCollapsed(selection);
44
- console.log("Editor isHavingSelection", isHavingSelection, selection);
45
- if (isHavingSelection) {
39
+ if (isHavingSelection && event === "end") {
46
40
  const domRange = ReactEditor.toDOMRange(editor, editor.selection);
47
41
  const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
48
42
  const rect = domRange.getBoundingClientRect();
@@ -51,17 +45,21 @@ const PopupTool = props => {
51
45
  rect.y = -500; // hide the popper
52
46
  }
53
47
 
54
- console.log("Editor setAnchorEl", rect, domRange, editorContainer);
55
- setAnchorEl({
56
- clientWidth: rect.width,
57
- clientHeight: rect.height,
58
- getBoundingClientRect: () => rect
59
- });
48
+ // Create a dummy anchor element to match Popper's requirements
49
+ const anchor = document.createElement("div");
50
+ anchor.style.position = "absolute";
51
+ anchor.style.top = `${rect.top + window.scrollY}px`;
52
+ anchor.style.left = `${rect.left + window.scrollX}px`;
53
+ document.body.appendChild(anchor);
54
+ if (!anchorEl || isScroll === "scroll") {
55
+ setAnchorEl(anchor);
56
+ setOpen(true);
57
+ }
60
58
  }
61
59
  } catch (err) {
62
60
  console.log(err);
63
61
  }
64
- }, [editor?.selection]);
62
+ };
65
63
  useEditorScroll(editorWrapper, updateAnchorEl);
66
64
  useEffect(() => {
67
65
  const userStoppedSelection = size?.device === "xs" ? true : event === "end"; // for mobile, when user starts the selection, we are gonna show the popup tool
@@ -76,44 +74,29 @@ const PopupTool = props => {
76
74
  if (!isCarouselEdit) {
77
75
  setOpen(true);
78
76
  setPopupType("textFormat");
79
- // setIsTextSelected(true);
77
+ setIsTextSelected(true);
80
78
  }
81
79
  } else if (!anchorEl) {
82
80
  setOpen(false);
83
81
  setPopupType("");
84
- // setIsTextSelected(false);
82
+ setIsTextSelected(false);
85
83
  }
86
84
  }, [event, anchorEl]);
87
85
  useEffect(() => {
88
- console.log("Editor useEffect", selection);
89
- if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "") {
86
+ if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "" || selectedElement?.enable === 1) {
90
87
  setAnchorEl(null);
91
88
  } else {
92
- console.log("Editor updateAnchorEl", selection);
93
89
  updateAnchorEl();
94
90
  hideSlateSelection(); // removes slate selection background, when there is no selection
95
91
  }
96
- }, [editor?.selection]);
97
- useEffect(() => {
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);
105
- setAnchorEl(null);
106
- }
107
- }, [selection, selectedElement?.path, selectedElement?.enable]);
92
+ }, [selection, event, selectedElement?.enable]);
108
93
  const handleClose = () => {
109
- console.log("Editor closing");
110
94
  // setAnchorEl(null);
111
95
  setOpen(false);
112
96
  setPopupType("");
113
97
  };
114
98
  return open && !openAI ? /*#__PURE__*/_jsx(ClickAwayListener, {
115
99
  onClickAway: e => {
116
- console.log("ClickAwayListener", e.target, document.body, e.target !== document.body);
117
100
  // close the mini toolbar, if user clicks outside the editor (in Flozy app.)
118
101
  if (e.target !== document.body) {
119
102
  // 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
@@ -132,24 +115,18 @@ const PopupTool = props => {
132
115
  id: id,
133
116
  open: open,
134
117
  anchorEl: anchorEl,
135
- transition: true,
136
118
  sx: classes.popupWrapper,
137
119
  placement: "top-start",
138
- children: ({
139
- TransitionProps
140
- }) => /*#__PURE__*/_jsx(Fade, {
141
- ...TransitionProps,
142
- children: /*#__PURE__*/_jsx(Paper, {
143
- style: {
144
- borderRadius: "6px",
145
- border: "1px solid #8360FD"
146
- },
147
- children: /*#__PURE__*/_jsx(MiniTextFormat, {
148
- editor: editor,
149
- classes: classes,
150
- closeMainPopup: handleClose,
151
- customProps: customProps
152
- })
120
+ children: /*#__PURE__*/_jsx(Paper, {
121
+ style: {
122
+ borderRadius: "6px",
123
+ border: "1px solid #8360FD"
124
+ },
125
+ children: /*#__PURE__*/_jsx(MiniTextFormat, {
126
+ editor: editor,
127
+ classes: classes,
128
+ closeMainPopup: handleClose,
129
+ customProps: customProps
153
130
  })
154
131
  })
155
132
  })
@@ -1,11 +1,11 @@
1
- export const defaultFonts = [
2
- // "EB Garamond",
3
- "Anton", "DM Serif Text", "Libre Baskerville", "Montserrat", "Open Sans", "Public Sans", "Raleway", "Space Mono", "Great Vibes", "Zeyada", "Allura", "Pinyon Script", "Dancing Script", "Gaegu", "Kite One", "Merriweather"];
4
- export const otherFonts = ["PoppinsRegular", "PoppinsBold", "Monaco", "Qwitcher Grypen", "Bulgarian Garamond", "Redacted Script", "Herr Von Muellerhoff", "Dawning of a New Day", "Coming Soon", "Engagement", "Ingrid Darling", "La Belle Aurore", "Mea Culpa", "The Girl Next Door", "Helvetica", "Georgia", "Times New Roman", "Courier New", "Impact"];
5
- export const googleFontList = ["Roboto", "Noto Sans JP", "Poppins", "Lato", "Inter", "Roboto Condensed", "Roboto Mono", "Oswald", "Noto Sans", "Nunito", "Nunito Sans", "Ubuntu", "Rubik", "Playfair Display", "Noto Sans KR", "Roboto Slab", "PT Sans", "Kanit", "Work Sans", "Lora", "DM Sans", "Mulish", "Quicksand", "Fira Sans", "Noto Sans TC", "Inconsolata", "Barlow", "Manrope", "IBM Plex Sans", "PT Serif", "Karla", "Titillium Web", "Heebo", "Noto Serif", "Nanum Gothic", "Noto Color Emoji", "Agdasima", "Bebas Neue", "Libre Franklin", "Mukta", "Outfit", "Josefin Sans", "Source Code Pro", "Jost", "Space Grotesk", "Hind Siliguri", "Arimo", "Cabin", "Barlow Condensed", "Dosis", "Fira Sans Condensed", "Bitter", "Archivo", "Figtree", "Noto Serif JP", "PT Sans Narrow", "Abel", "Noto Sans SC",
6
- // "Source Sans 3",
7
- "Hind",
8
- // "Exo 2",
9
- "Teko", "Oxygen", "Cairo", "Crimson Text", "Plus Jakarta Sans", "Overpass", "Pacifico", "Prompt", "Red Hat Display", "Varela Round", "Cormorant Garamond", "Assistant", "Comfortaa", "Lexend", "Signika Negative",
10
- // "M PLUS Rounded 1c",
11
- "Fjalla One", "Caveat", "IBM Plex Mono", "Arvo", "Lobster", "Schibsted Grotesk", "Chakra Petch", "Maven Pro", "Sora", "Kalam", "Onest", "Space Grotesk", "Outfit", 'Titillium Web', ...defaultFonts];
1
+ const otherFonts = ["PoppinsRegular", "PoppinsBold", "Qwitcher Grypen", "Bulgarian Garamond", "Redacted Script", "Herr Von Muellerhoff", "Dawning of a New Day", "Coming Soon", "Engagement", "Ingrid Darling", "La Belle Aurore", "Mea Culpa", "The Girl Next Door"];
2
+ const mostUsedGoogleFonts = ["Roboto", "Poppins", "Lato", "Inter", "Nunito", "Ubuntu", "Oswald", "Rubik", "Roboto Slab", "PT Sans", "Work Sans", "Lora", "Mulish", "DM Sans", "Fira Sans", "Quicksand", "Barlow", "Manrope", "IBM Plex Sans", "PT Serif", "Libre Franklin", "Bebas Neue", "Cabin", "Titillium Web", "Heebo", "Noto Serif", "Jost", "Source Code Pro", "Josefin Sans", "Dosis", "Fira Sans Condensed", "Archivo", "Noto Serif JP", "Crimson Text", "Cairo", "Pacifico", "Red Hat Display", "Assistant", "Comfortaa", "Lexend", "Fjalla One", "Caveat", "Arvo", "Lobster", "Schibsted Grotesk", "EB Garamond", "Sora", "Kalam", "Onest", "Space Grotesk", "Outfit", "Plus Jakarta Sans"];
3
+ const systemFonts = ["Monaco", "Helvetica", "Georgia", "Times New Roman", "Courier New", "Impact"];
4
+ export const googleFontList = [...mostUsedGoogleFonts, ...otherFonts];
5
+ const fontList = [...mostUsedGoogleFonts, ...otherFonts, ...systemFonts];
6
+ export const defaultFontFamilies = {
7
+ id: 1,
8
+ format: "fontFamily",
9
+ type: "fontfamilydropdown",
10
+ options: fontList || []
11
+ };
@@ -1,7 +1,11 @@
1
- import { useEffect } from "react";
1
+ import { useEffect, useState } from "react";
2
2
  import WebFont from "webfontloader";
3
3
  import { useEditorContext } from "../../hooks/useMouseMove";
4
- import { defaultFonts, googleFontList, otherFonts } from "./FontList";
4
+ import { googleFontList } from "./FontList";
5
+ import CircularProgress from "@mui/material/CircularProgress";
6
+ import Box from "@mui/material/Box";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { Fragment as _Fragment } from "react/jsx-runtime";
5
9
  const FontLoader = props => {
6
10
  const {
7
11
  otherProps,
@@ -10,69 +14,74 @@ const FontLoader = props => {
10
14
  const {
11
15
  setFontFamilies
12
16
  } = useEditorContext();
17
+ const [loading, setLoading] = useState(true);
13
18
  const loadFontsInBatches = (families, batchSize = 5, maxRetries = 3) => {
14
19
  let currentIndex = 0;
15
20
  let retryCount = 0;
16
- function loadNextBatch() {
17
- if (currentIndex >= families?.length) {
18
- // console.log("All fonts have been loaded");
19
- return;
20
- }
21
- const batch = families?.slice(currentIndex, currentIndex + batchSize);
22
- const batchWithWeights = batch.map(font => `${font}:300,400,600,700`);
23
- WebFont.load({
24
- google: {
25
- families: [...batchWithWeights]
26
- },
27
- classes: false,
28
- timeout: 2000,
29
- active: () => {
30
- // console.log(`Fonts loaded successfully: ${batch}`);
31
- currentIndex += batchSize;
32
- retryCount = 0; // Reset retry count for the next batch
33
- loadNextBatch();
34
- },
35
- inactive: () => {
36
- // console.log(`Font loading failed for: ${batch}`);
37
-
38
- if (retryCount < maxRetries) {
39
- retryCount++;
40
- // console.log(`Retrying batch (${retryCount}/${maxRetries})...`);
41
- // Retry loading the same batch
42
- loadNextBatch();
43
- } else {
44
- // console.log(
45
- // `Max retries reached for batch: ${batch}. Moving to the next batch.`
46
- // );
21
+ const loadNextBatch = () => {
22
+ try {
23
+ if (currentIndex >= families?.length) {
24
+ // console.log("All fonts have been loaded");
25
+ setLoading(false);
26
+ return;
27
+ }
28
+ const batch = families?.slice(currentIndex, currentIndex + batchSize);
29
+ const batchWithWeights = batch?.map(font => `${font}:300,400,600,700`);
30
+ WebFont.load({
31
+ google: {
32
+ families: [...batchWithWeights]
33
+ },
34
+ classes: false,
35
+ timeout: 2000,
36
+ active: () => {
37
+ // console.log(`Fonts loaded successfully: ${batch}`);
47
38
  currentIndex += batchSize;
48
39
  retryCount = 0; // Reset retry count for the next batch
49
40
  loadNextBatch();
41
+ },
42
+ inactive: () => {
43
+ // console.log(`Font loading failed for: ${batch}`);
44
+ if (retryCount < maxRetries) {
45
+ retryCount++;
46
+ // console.log(`Retrying batch (${retryCount}/${maxRetries})...`);
47
+ // Retry loading the same batch
48
+ loadNextBatch();
49
+ } else {
50
+ // console.log(
51
+ // `Max retries reached for batch: ${batch}. Moving to the next batch.`
52
+ // );
53
+ currentIndex += batchSize;
54
+ retryCount = 0;
55
+ loadNextBatch();
56
+ }
50
57
  }
51
- }
52
- });
53
- }
58
+ });
59
+ } catch (err) {
60
+ setLoading(false);
61
+ }
62
+ };
54
63
  loadNextBatch();
55
64
  };
56
65
  useEffect(() => {
57
- let families = [...otherFonts, ...defaultFonts];
66
+ let families = [...googleFontList];
58
67
  if (!readOnly) {
59
68
  otherProps?.services("listGoogleFont", []).then(data => {
60
- families = [...families, ...(data?.data || [])];
61
- const filteredfamilies = families?.filter(font => !font?.includes("Material"));
69
+ families = [...(data?.data || [])];
62
70
  setFontFamilies({
63
71
  id: 1,
64
72
  format: "fontFamily",
65
73
  type: "fontfamilydropdown",
66
- options: filteredfamilies || []
74
+ options: families || []
67
75
  });
68
76
  loadFontsInBatches(families);
69
77
  }).catch(err => {
70
78
  // console.log(err);
79
+ setLoading(false);
71
80
  });
72
81
  } else {
73
82
  function correctFontArray(fontString) {
74
- let fontsArray = fontString.split(",");
75
- let cleanedFontsArray = [...new Set(fontsArray.map(font => font.trim()))];
83
+ let fontsArray = fontString?.split(",");
84
+ let cleanedFontsArray = [...new Set(fontsArray?.map(font => font.trim()))];
76
85
  return cleanedFontsArray;
77
86
  }
78
87
  function sanitizeFontFamily(fontFamily) {
@@ -88,11 +97,32 @@ const FontLoader = props => {
88
97
  let families = Array.from(fontSet);
89
98
  families = correctFontArray(families.join(", "));
90
99
  families = families?.map(font => font?.replace(/\"/g, ""));
91
- families = families?.map(font => font?.replace(", sans-serif", "")); //This is temporary fix for patch
92
- families = families.filter(font => googleFontList.includes(font));
100
+ families = families?.map(font => font?.replace(", sans-serif", ""));
101
+ families = families?.filter(font => googleFontList?.includes(font));
93
102
  loadFontsInBatches(families);
94
103
  }
104
+
105
+ // Set timeout to hide loader after 5 seconds
106
+ const timeoutId = setTimeout(() => {
107
+ setLoading(false);
108
+ }, 5000);
109
+ return () => clearTimeout(timeoutId);
95
110
  }, []);
96
- return null;
111
+ return /*#__PURE__*/_jsx(_Fragment, {
112
+ children: loading ? /*#__PURE__*/_jsx(Box, {
113
+ sx: {
114
+ position: "absolute",
115
+ top: 0,
116
+ left: 0,
117
+ right: 0,
118
+ bottom: 0,
119
+ zIndex: 99999,
120
+ display: "flex",
121
+ justifyContent: "center",
122
+ alignItems: "center"
123
+ },
124
+ children: /*#__PURE__*/_jsx(CircularProgress, {})
125
+ }) : null
126
+ });
97
127
  };
98
128
  export default FontLoader;
@@ -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
  });
@@ -131,6 +131,7 @@ const MentionsPopup = /*#__PURE__*/forwardRef((props, ref) => {
131
131
  setOpenAI("fromElements");
132
132
  }
133
133
  insertMention(editor, char, type);
134
+ Transforms.insertText(editor, " "); //Added to insert space after inserting mention node
134
135
  setMentions({
135
136
  ...mentions,
136
137
  target: null
@@ -58,7 +58,6 @@ const useElementSettingsStyle = theme => ({
58
58
  maxHeight: "500px",
59
59
  overflowX: "hidden",
60
60
  overflowY: "auto",
61
- paddingLeft: "4px",
62
61
  background: theme?.palette?.editor?.background,
63
62
  paddingLeft: "4px",
64
63
  "& .MuiTypography-root, .MuiInputBase-root, input": {
@@ -2,36 +2,34 @@ import React, { useRef, useState } from "react";
2
2
  import { useTheme } from "@mui/material";
3
3
  import { Transforms } from "slate";
4
4
  import { ReactEditor, useSlateStatic } from "slate-react";
5
- import { Box, IconButton, Popper, Tooltip } from "@mui/material";
5
+ import { Box, IconButton, Tooltip } from "@mui/material";
6
6
  import SectionPopup from "../../Elements/Grid/SectionPopup";
7
7
  import { getBreakPointsValue, getTRBLBreakPoints, groupByBreakpoint } from "../../helper/theme";
8
- import DragHandle from "../DnD/DragHandleButton";
9
- import { useEditorSelection } from "../../hooks/useMouseMove";
8
+ // import DragHandle from "../DnD/DragHandleButton";
9
+ // import { useEditorSelection } from "../../hooks/useMouseMove";
10
10
  import SectionStyle from "./styles";
11
11
  import useWindowResize from "../../hooks/useWindowResize";
12
12
  import { SectionSettingIcon } from "../iconListV2";
13
+
14
+ // const list_types = ["orderedList", "unorderedList"];
13
15
  import { jsx as _jsx } from "react/jsx-runtime";
14
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
- import { Fragment as _Fragment } from "react/jsx-runtime";
16
17
  const Toolbar = ({
17
- fromPopper,
18
18
  readOnly,
19
19
  showTool,
20
- onSettings
20
+ onSettings,
21
+ isSectionFullWidth
21
22
  }) => {
22
23
  return !readOnly && !showTool ? /*#__PURE__*/_jsx(Box, {
23
24
  component: "div",
24
25
  className: `element-toolbar no-border-button hr section-tw sectionIcon`,
25
26
  contentEditable: false,
26
- style: fromPopper ? {
27
- position: "unset",
28
- marginLeft: "28px",
29
- paddingTop: "4px",
30
- marginRight: "10px",
31
- height: "100%"
32
- } : {
33
- left: "-28px",
34
- top: "1px"
27
+ sx: {
28
+ left: isSectionFullWidth ? "0px" : "-28px",
29
+ top: isSectionFullWidth ? "-28px" : "1px",
30
+ "&:hover": {
31
+ backgroundColor: "rgba(0,0,0,0.5)"
32
+ }
35
33
  },
36
34
  children: /*#__PURE__*/_jsx(Tooltip, {
37
35
  title: "Section Settings",
@@ -42,7 +40,6 @@ const Toolbar = ({
42
40
  })
43
41
  }) : null;
44
42
  };
45
- const list_types = ["orderedList", "unorderedList"];
46
43
  const Section = props => {
47
44
  const themeReact = useTheme();
48
45
  const theme = props?.theme;
@@ -56,7 +53,8 @@ const Section = props => {
56
53
  readOnly
57
54
  } = customProps;
58
55
  const editor = useSlateStatic();
59
- const [showTool] = useEditorSelection(editor);
56
+ // const [isHovering, setIsHovering] = useState(false);
57
+ const [size] = useWindowResize();
60
58
  const [openSetttings, setOpenSettings] = useState(false);
61
59
  const {
62
60
  sectionBgColor,
@@ -73,41 +71,11 @@ const Section = props => {
73
71
  } = sectionAlignment || {};
74
72
  const path = ReactEditor.findPath(editor, element);
75
73
  const anchorEl = useRef(null);
76
- const popperEl = useRef(null);
77
- const [size] = useWindowResize();
74
+ // const popperEl = useRef(null);
75
+ // const [showTool] = useEditorSelection(editor);
78
76
  const isSectionFullWidth = sectionGridSize && sectionGridSize[size?.device] >= 12;
79
- const [isHovering, setIsHovering] = useState(false);
80
- const onMouseEnter = () => {
81
- setIsHovering(true);
82
- };
83
- const onMouseLeave = () => {
84
- setIsHovering(false);
85
- };
86
- const onSettings = () => {
87
- setOpenSettings(true);
88
- };
89
- const onSave = data => {
90
- const updateData = {
91
- ...data
92
- };
93
- delete updateData.children;
94
- Transforms.setNodes(editor, {
95
- ...updateData
96
- }, {
97
- at: path
98
- });
99
- onClose();
100
- };
101
- const onClose = () => {
102
- setOpenSettings(false);
103
- };
104
- const onDelete = () => {
105
- Transforms.removeNodes(editor, {
106
- at: path
107
- });
108
- };
109
- const isFreeGrid = element?.children?.find(f => f.type === "freegrid");
110
- const needHover = element?.children?.find(f => f.type === "grid" && !list_types.includes(element.type)) ? "" : "";
77
+ const isFreeGrid = element?.children[0]?.type === "freegrid";
78
+ const needHover = false;
111
79
  let tempProps = {};
112
80
  if (element?.type === "temp") {
113
81
  tempProps = {
@@ -131,6 +99,38 @@ const Section = props => {
131
99
  ...getBreakPointsValue(sectionGridSize || 8, null, "overrideGridSize", true)
132
100
  }
133
101
  }, themeReact);
102
+
103
+ // const onMouseEnter = () => {
104
+ // setIsHovering(true);
105
+ // };
106
+
107
+ // const onMouseLeave = () => {
108
+ // setIsHovering(false);
109
+ // };
110
+
111
+ const onSettings = () => {
112
+ setOpenSettings(true);
113
+ };
114
+ const onSave = data => {
115
+ const updateData = {
116
+ ...data
117
+ };
118
+ delete updateData.children;
119
+ Transforms.setNodes(editor, {
120
+ ...updateData
121
+ }, {
122
+ at: path
123
+ });
124
+ onClose();
125
+ };
126
+ const onClose = () => {
127
+ setOpenSettings(false);
128
+ };
129
+ const onDelete = () => {
130
+ Transforms.removeNodes(editor, {
131
+ at: path
132
+ });
133
+ };
134
134
  return path.length === 1 && !isFreeGrid ? /*#__PURE__*/_jsxs(Box, {
135
135
  component: "div",
136
136
  className: `ed-section-wrapper ${readOnly ? "" : "hselect"} ${needHover} is-${element?.type}`,
@@ -145,9 +145,10 @@ const Section = props => {
145
145
  flexDirection: flexDirection || "column",
146
146
  alignItems: horizantal,
147
147
  justifyContent: vertical
148
- },
149
- onMouseEnter: onMouseEnter,
150
- onMouseLeave: onMouseLeave,
148
+ }
149
+ // onMouseEnter={onMouseEnter}
150
+ // onMouseLeave={onMouseLeave}
151
+ ,
151
152
  children: [/*#__PURE__*/_jsxs(Box, {
152
153
  className: "ed-section-inner",
153
154
  sx: {
@@ -155,41 +156,11 @@ const Section = props => {
155
156
  ...edInnerSp
156
157
  },
157
158
  ref: anchorEl,
158
- children: [isHovering && isSectionFullWidth ? /*#__PURE__*/_jsx(Popper, {
159
- open: isHovering && isSectionFullWidth,
160
- anchorEl: anchorEl?.current,
161
- placement: "top-start",
162
- sx: {
163
- zIndex: 9999
164
- },
165
- disablePortal: true,
166
- ref: popperEl,
167
- className: "sectionPopper",
168
- children: /*#__PURE__*/_jsxs(Box, {
169
- sx: {
170
- bgcolor: "background.paper",
171
- height: "30px",
172
- position: "relative",
173
- background: theme?.palette?.type === "dark" ? theme?.palette?.editor?.miniToolBarBackground : "#F6F6F6"
174
- },
175
- children: [!readOnly && !showTool ? /*#__PURE__*/_jsx(DragHandle, {
176
- ...props,
177
- fromPopper: true
178
- }) : null, /*#__PURE__*/_jsx(Toolbar, {
179
- fromPopper: true,
180
- readOnly: readOnly,
181
- showTool: showTool,
182
- onSettings: onSettings
183
- })]
184
- })
185
- }) : /*#__PURE__*/_jsxs(_Fragment, {
186
- children: [!readOnly && !showTool ? /*#__PURE__*/_jsx(DragHandle, {
187
- ...props
188
- }) : null, /*#__PURE__*/_jsx(Toolbar, {
189
- readOnly: readOnly,
190
- showTool: showTool,
191
- onSettings: onSettings
192
- })]
159
+ children: [/*#__PURE__*/_jsx(Toolbar, {
160
+ isSectionFullWidth: isSectionFullWidth,
161
+ readOnly: readOnly,
162
+ showTool: false,
163
+ onSettings: onSettings
193
164
  }), children]
194
165
  }), openSetttings ? /*#__PURE__*/_jsx(SectionPopup, {
195
166
  element: {
@@ -175,7 +175,7 @@ const deserialize = el => {
175
175
  if (el.nodeType === 3) {
176
176
  // if there is any line-breaks
177
177
  const match = /\r|\n/.exec(el.textContent);
178
- const text = el.textContent.replace(/\r|\n/g, "").trim();
178
+ const text = el.textContent?.trim()?.length === 0 ? el.textContent.replace(/\r|\n/g, "").trim() : el.textContent;
179
179
  return match && !text ? null : {
180
180
  text,
181
181
  ...getInlineTextStyles(el.parentNode)
@@ -1,20 +1,26 @@
1
- import { useCallback, useEffect, useState } from "react";
1
+ import { useEffect, useState } from "react";
2
2
  const useDrag = () => {
3
3
  const [event, setEvent] = useState("");
4
- const onMouseDown = useCallback(() => {
5
- setEvent("start");
6
- }, []);
7
- const onMouseUp = useCallback(() => {
8
- setEvent("end");
9
- }, []);
10
4
  useEffect(() => {
11
- document.addEventListener("pointerdown", onMouseDown);
12
- document.addEventListener("pointerup", onMouseUp);
5
+ addListener();
13
6
  return () => {
14
- document.removeEventListener("pointerdown", onMouseDown);
15
- document.removeEventListener("pointerup", onMouseUp);
7
+ removeListener();
16
8
  };
17
9
  }, []);
10
+ const onMouseDown = () => {
11
+ setEvent("start");
12
+ };
13
+ const onMouseUp = () => {
14
+ setEvent("end");
15
+ };
16
+ const addListener = () => {
17
+ document.addEventListener("pointerdown", onMouseDown);
18
+ document.addEventListener("pointerup", onMouseUp);
19
+ };
20
+ const removeListener = () => {
21
+ document.removeEventListener("pointerdown", onMouseDown);
22
+ document.removeEventListener("pointerup", onMouseUp);
23
+ };
18
24
  return [event];
19
25
  };
20
26
  export default useDrag;
@@ -4,9 +4,8 @@ function useEditorScroll(editorWrapper = {
4
4
  }, callback) {
5
5
  useEffect(() => {
6
6
  const handleScroll = () => {
7
- console.log("Editor debug useEditorScroll ====>", editorWrapper, callback);
8
7
  if (editorWrapper.current) {
9
- callback();
8
+ callback("scroll");
10
9
  }
11
10
  };
12
11
  const currentEditorWrapper = editorWrapper.current;
@@ -1,6 +1,7 @@
1
1
  import { useEffect, useState, createContext, useContext, useMemo } from "react";
2
2
  import { getSelectedText } from "../utils/helper";
3
3
  import { debounce } from "../helper";
4
+ import { defaultFontFamilies } from "../common/FontLoader/FontList";
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  const EditorContext = /*#__PURE__*/createContext();
6
7
  export const useEditorSelection = editor => {
@@ -34,7 +35,7 @@ export const EditorProvider = ({
34
35
  const [contextMenu, setContextMenu] = useState({
35
36
  path: null
36
37
  });
37
- const [fontFamilies, setFontFamilies] = useState({});
38
+ const [fontFamilies, setFontFamilies] = useState(defaultFontFamilies);
38
39
  const [activeBreakPoint, setActiveBreakPoint] = useState("");
39
40
  useEffect(() => {
40
41
  window.updateSelectedItem = d => {
@@ -630,6 +630,11 @@ export const getBlock = props => {
630
630
  children: children
631
631
  });
632
632
  default:
633
+ // return (
634
+ // <span {...attributes} {...element.attr}>
635
+ // {children}
636
+ // </span>
637
+ // );
633
638
  return /*#__PURE__*/_jsx(SimpleText, {
634
639
  ...props,
635
640
  isEmpty: isEmpty
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "9.0.2",
3
+ "version": "9.0.4",
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",
@@ -69,7 +69,7 @@
69
69
  "storybook": "storybook dev -p 6006",
70
70
  "build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
71
71
  "publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
72
- "publish:local": "rm -rf /Users/agmac30/Documents/CODE_BASE/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac30/Documents/CODE_BASE/flozy/client/node_modules/@flozy/editor/dist --copy-files"
72
+ "publish:local": "rm -rf /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist --copy-files"
73
73
  },
74
74
  "eslintConfig": {
75
75
  "extends": [