@flozy/editor 7.0.3 → 7.0.5

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] : {};
@@ -312,7 +314,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
312
314
  updateTopBanner(newValue, setTopBanner);
313
315
  debounced(newValue);
314
316
  if (!isInteracted) {
315
- setIsInteracted(true);
317
+ // setIsInteracted(true);
316
318
  }
317
319
  }
318
320
  };
@@ -493,7 +495,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
493
495
  ...props,
494
496
  fullScreen: fullScreen,
495
497
  footer: footer || "",
496
- children: /*#__PURE__*/_jsx(Box, {
498
+ children: /*#__PURE__*/_jsxs(Box, {
497
499
  component: "div",
498
500
  className: `et-wrpr stimulate-${breakpoint} ${editorClass || ""} ${isIframe ? "iframe-editor" : ""}`,
499
501
  sx: classes.root,
@@ -503,7 +505,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
503
505
  "data-breakpoint": breakpoint
504
506
  // onContextMenu={handleContextMenu}
505
507
  ,
506
- children: /*#__PURE__*/_jsxs(Slate, {
508
+ children: [/*#__PURE__*/_jsxs(Slate, {
507
509
  editor: editor,
508
510
  initialValue: getInitialValue(debouncedValue?.current, readOnly),
509
511
  onChange: handleEditorChange,
@@ -604,10 +606,13 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
604
606
  }), htmlAction.showInput && /*#__PURE__*/_jsx(CodeToText, {
605
607
  ...htmlAction,
606
608
  handleCodeToText: handleCodeToText
607
- }), /*#__PURE__*/_jsx(FontLoader, {
608
- ...props
609
609
  })]
610
- }, id)
610
+ }, id), /*#__PURE__*/_jsx(FontLoader, {
611
+ otherProps: {
612
+ services: otherProps?.services
613
+ },
614
+ readOnly: readOnly
615
+ })]
611
616
  })
612
617
  })
613
618
  });
@@ -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,19 +27,15 @@ 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 || {};
30
+ // const { element: pageSt } = getPageSettings(editor) || {};
31
+ // const { pageColor } = pageSt?.pageProps || {};
37
32
  const {
38
33
  activeBreakPoint
39
34
  } = useEditorContext();
40
35
  const lineHeight = element?.children[0]?.lineHeight;
41
36
  const lineH = getBreakpointLineSpacing(lineHeight, activeBreakPoint);
42
37
  const classes = SimpleTextStyle({
43
- pageColor: pageColor || theme?.palette?.editor?.background || "#FFFFFF",
38
+ pageColor: "#FFFFFF",
44
39
  lineHeight: lineH
45
40
  });
46
41
  const selected = useSelected();
@@ -59,14 +54,14 @@ const SimpleText = props => {
59
54
  contentEditable: false,
60
55
  className: "placeholder-simple-text",
61
56
  children: isEmptyEditor ? editorPlaceholder || "Write Something..." : showPlaceHolder ? opacity && selected ? /*#__PURE__*/_jsxs(_Fragment, {
62
- children: ["Type ", /*#__PURE__*/_jsx("span", {
57
+ children: ["Type", " ", /*#__PURE__*/_jsx("span", {
63
58
  style: {
64
- backgroundColor: '#F2F6FA',
59
+ backgroundColor: "#F2F6FA",
65
60
  padding: "0px 2px",
66
61
  borderRadius: "2px"
67
62
  },
68
63
  children: "/"
69
- }), " to browse elements"]
64
+ }), " ", "to browse elements"]
70
65
  }) : "" : ""
71
66
  }));
72
67
  };
@@ -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";
@@ -21,7 +21,8 @@ const PopupTool = props => {
21
21
  const classes = usePopupStyles(theme);
22
22
  const {
23
23
  setPopupType,
24
- openAI
24
+ openAI,
25
+ selectedElement
25
26
  } = useEditorContext();
26
27
  const [anchorEl, setAnchorEl] = useState(null);
27
28
  const [open, setOpen] = useState(false);
@@ -32,13 +33,10 @@ const PopupTool = props => {
32
33
  const [event] = useDrag(anchorEl);
33
34
  const id = open ? "popup-edit-tool" : "";
34
35
  const [size] = useWindowResize();
35
- const {
36
- selectedElement
37
- } = useEditorContext();
38
- const updateAnchorEl = useCallback(() => {
36
+ const updateAnchorEl = isScroll => {
39
37
  try {
40
38
  const isHavingSelection = selection && !Range.isCollapsed(selection);
41
- if (isHavingSelection) {
39
+ if (isHavingSelection && event === "end") {
42
40
  const domRange = ReactEditor.toDOMRange(editor, editor.selection);
43
41
  const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
44
42
  const rect = domRange.getBoundingClientRect();
@@ -47,16 +45,21 @@ const PopupTool = props => {
47
45
  rect.y = -500; // hide the popper
48
46
  }
49
47
 
50
- setAnchorEl({
51
- clientWidth: rect.width,
52
- clientHeight: rect.height,
53
- getBoundingClientRect: () => rect
54
- });
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
+ }
55
58
  }
56
59
  } catch (err) {
57
60
  console.log(err);
58
61
  }
59
- }, [selection]);
62
+ };
60
63
  useEditorScroll(editorWrapper, updateAnchorEl);
61
64
  useEffect(() => {
62
65
  const userStoppedSelection = size?.device === "xs" ? true : event === "end"; // for mobile, when user starts the selection, we are gonna show the popup tool
@@ -80,18 +83,13 @@ const PopupTool = props => {
80
83
  }
81
84
  }, [event, anchorEl]);
82
85
  useEffect(() => {
83
- if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "") {
86
+ if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "" || selectedElement?.enable === 1) {
84
87
  setAnchorEl(null);
85
88
  } else {
86
89
  updateAnchorEl();
87
90
  hideSlateSelection(); // removes slate selection background, when there is no selection
88
91
  }
89
- }, [selection]);
90
- useEffect(() => {
91
- if (selectedElement?.enable === 1) {
92
- setAnchorEl(null);
93
- }
94
- }, [selection, selectedElement?.path, selectedElement?.enable]);
92
+ }, [selection, event, selectedElement?.enable]);
95
93
  const handleClose = () => {
96
94
  // setAnchorEl(null);
97
95
  setOpen(false);
@@ -117,24 +115,18 @@ const PopupTool = props => {
117
115
  id: id,
118
116
  open: open,
119
117
  anchorEl: anchorEl,
120
- transition: true,
121
118
  sx: classes.popupWrapper,
122
119
  placement: "top-start",
123
- children: ({
124
- TransitionProps
125
- }) => /*#__PURE__*/_jsx(Fade, {
126
- ...TransitionProps,
127
- children: /*#__PURE__*/_jsx(Paper, {
128
- style: {
129
- borderRadius: "6px",
130
- border: "1px solid #8360FD"
131
- },
132
- children: /*#__PURE__*/_jsx(MiniTextFormat, {
133
- editor: editor,
134
- classes: classes,
135
- closeMainPopup: handleClose,
136
- customProps: customProps
137
- })
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
138
130
  })
139
131
  })
140
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;
@@ -2,36 +2,33 @@ 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
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
- import { Fragment as _Fragment } from "react/jsx-runtime";
16
15
  const Toolbar = ({
17
16
  fromPopper,
18
17
  readOnly,
19
18
  showTool,
20
- onSettings
19
+ onSettings,
20
+ isSectionFullWidth
21
21
  }) => {
22
22
  return !readOnly && !showTool ? /*#__PURE__*/_jsx(Box, {
23
23
  component: "div",
24
24
  className: `element-toolbar no-border-button hr section-tw sectionIcon`,
25
25
  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"
26
+ sx: {
27
+ left: isSectionFullWidth ? "0px" : "-28px",
28
+ top: isSectionFullWidth ? "-28px" : "1px",
29
+ "&:hover": {
30
+ backgroundColor: "rgba(0,0,0,0.5)"
31
+ }
35
32
  },
36
33
  children: /*#__PURE__*/_jsx(Tooltip, {
37
34
  title: "Section Settings",
@@ -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)
@@ -5,7 +5,7 @@ function useEditorScroll(editorWrapper = {
5
5
  useEffect(() => {
6
6
  const handleScroll = () => {
7
7
  if (editorWrapper.current) {
8
- callback();
8
+ callback("scroll");
9
9
  }
10
10
  };
11
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": "7.0.3",
3
+ "version": "7.0.5",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -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": [