@flozy/editor 7.0.4 → 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.
@@ -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,17 +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
- if (isHavingSelection) {
39
+ if (isHavingSelection && event === "end") {
45
40
  const domRange = ReactEditor.toDOMRange(editor, editor.selection);
46
41
  const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
47
42
  const rect = domRange.getBoundingClientRect();
@@ -50,16 +45,21 @@ const PopupTool = props => {
50
45
  rect.y = -500; // hide the popper
51
46
  }
52
47
 
53
- setAnchorEl({
54
- clientWidth: rect.width,
55
- clientHeight: rect.height,
56
- getBoundingClientRect: () => rect
57
- });
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
+ }
58
58
  }
59
59
  } catch (err) {
60
60
  console.log(err);
61
61
  }
62
- }, [editor?.selection]);
62
+ };
63
63
  useEditorScroll(editorWrapper, updateAnchorEl);
64
64
  useEffect(() => {
65
65
  const userStoppedSelection = size?.device === "xs" ? true : event === "end"; // for mobile, when user starts the selection, we are gonna show the popup tool
@@ -74,32 +74,22 @@ const PopupTool = props => {
74
74
  if (!isCarouselEdit) {
75
75
  setOpen(true);
76
76
  setPopupType("textFormat");
77
- // setIsTextSelected(true);
77
+ setIsTextSelected(true);
78
78
  }
79
79
  } else if (!anchorEl) {
80
80
  setOpen(false);
81
81
  setPopupType("");
82
- // setIsTextSelected(false);
82
+ setIsTextSelected(false);
83
83
  }
84
84
  }, [event, anchorEl]);
85
85
  useEffect(() => {
86
- if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "") {
86
+ if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "" || selectedElement?.enable === 1) {
87
87
  setAnchorEl(null);
88
88
  } else {
89
89
  updateAnchorEl();
90
90
  hideSlateSelection(); // removes slate selection background, when there is no selection
91
91
  }
92
- }, [selection]);
93
- useEffect(() => {
94
- const {
95
- path,
96
- enable
97
- } = selectedElement || {};
98
- const isFreeGridElement = path && path.split("|").length > 2;
99
- if (enable === 1 && isFreeGridElement) {
100
- setAnchorEl(null);
101
- }
102
- }, [selection, selectedElement?.path, selectedElement?.enable]);
92
+ }, [selection, event, selectedElement?.enable]);
103
93
  const handleClose = () => {
104
94
  // setAnchorEl(null);
105
95
  setOpen(false);
@@ -125,24 +115,18 @@ const PopupTool = props => {
125
115
  id: id,
126
116
  open: open,
127
117
  anchorEl: anchorEl,
128
- transition: true,
129
118
  sx: classes.popupWrapper,
130
119
  placement: "top-start",
131
- children: ({
132
- TransitionProps
133
- }) => /*#__PURE__*/_jsx(Fade, {
134
- ...TransitionProps,
135
- children: /*#__PURE__*/_jsx(Paper, {
136
- style: {
137
- borderRadius: "6px",
138
- border: "1px solid #8360FD"
139
- },
140
- children: /*#__PURE__*/_jsx(MiniTextFormat, {
141
- editor: editor,
142
- classes: classes,
143
- closeMainPopup: handleClose,
144
- customProps: customProps
145
- })
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
146
130
  })
147
131
  })
148
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;
@@ -18,7 +18,7 @@ const Upload = props => {
18
18
  item: true,
19
19
  xs: 12,
20
20
  sx: {
21
- padding: '10px',
21
+ padding: "10px",
22
22
  height: '100%'
23
23
  },
24
24
  className: "ims-right",
@@ -7,7 +7,7 @@ const UploadStyles = theme => ({
7
7
  background: theme?.palette?.editor?.uploadFileBg,
8
8
  height: '100%',
9
9
  minHeight: '150px',
10
- height: "inherit"
10
+ height: 'inherit'
11
11
  },
12
12
  uploadField: {
13
13
  width: "100%",
@@ -58,8 +58,8 @@ 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,
62
+ paddingLeft: "4px",
63
63
  "& .MuiTypography-root, .MuiInputBase-root, input": {
64
64
  color: theme?.palette?.editor?.textColor
65
65
  },
@@ -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)
@@ -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