@flozy/editor 7.0.5 → 7.0.6
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.
- package/dist/Editor/CommonEditor.js +14 -17
- package/dist/Editor/Editor.css +3 -2
- package/dist/Editor/Elements/SimpleText/index.js +12 -7
- package/dist/Editor/Styles/EditorStyles.js +291 -287
- package/dist/Editor/Toolbar/PopupTool/index.js +55 -32
- package/dist/Editor/common/FontLoader/FontList.js +11 -11
- package/dist/Editor/common/FontLoader/FontLoader.js +45 -75
- package/dist/Editor/common/ImageSelector/Options/Upload.js +1 -1
- package/dist/Editor/common/ImageSelector/UploadStyles.js +1 -1
- package/dist/Editor/common/RnD/ElementSettings/styles.js +1 -1
- package/dist/Editor/common/Section/index.js +87 -58
- package/dist/Editor/helper/deserialize/index.js +1 -1
- package/dist/Editor/hooks/useDrag.js +11 -17
- package/dist/Editor/hooks/useEditorScroll.js +2 -1
- package/dist/Editor/hooks/useMouseMove.js +1 -2
- package/dist/Editor/utils/SlateUtilityFunctions.js +0 -5
- package/package.json +3 -3
@@ -1,5 +1,5 @@
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
2
|
-
import { Popper, Paper, ClickAwayListener } from "@mui/material";
|
1
|
+
import React, { useCallback, useEffect, useState } from "react";
|
2
|
+
import { Popper, Fade, 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,15 +14,13 @@ 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;
|
21
20
|
const classes = usePopupStyles(theme);
|
22
21
|
const {
|
23
22
|
setPopupType,
|
24
|
-
openAI
|
25
|
-
selectedElement
|
23
|
+
openAI
|
26
24
|
} = useEditorContext();
|
27
25
|
const [anchorEl, setAnchorEl] = useState(null);
|
28
26
|
const [open, setOpen] = useState(false);
|
@@ -33,10 +31,18 @@ const PopupTool = props => {
|
|
33
31
|
const [event] = useDrag(anchorEl);
|
34
32
|
const id = open ? "popup-edit-tool" : "";
|
35
33
|
const [size] = useWindowResize();
|
36
|
-
const
|
34
|
+
const {
|
35
|
+
selectedElement
|
36
|
+
} = useEditorContext();
|
37
|
+
console.log("Editor debug ====>", event, open, anchorEl, selection);
|
38
|
+
const updateAnchorEl = useCallback(() => {
|
37
39
|
try {
|
40
|
+
const {
|
41
|
+
selection
|
42
|
+
} = editor;
|
38
43
|
const isHavingSelection = selection && !Range.isCollapsed(selection);
|
39
|
-
|
44
|
+
console.log("Editor isHavingSelection", isHavingSelection, selection);
|
45
|
+
if (isHavingSelection) {
|
40
46
|
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
41
47
|
const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
|
42
48
|
const rect = domRange.getBoundingClientRect();
|
@@ -45,21 +51,17 @@ const PopupTool = props => {
|
|
45
51
|
rect.y = -500; // hide the popper
|
46
52
|
}
|
47
53
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
if (!anchorEl || isScroll === "scroll") {
|
55
|
-
setAnchorEl(anchor);
|
56
|
-
setOpen(true);
|
57
|
-
}
|
54
|
+
console.log("Editor setAnchorEl", rect, domRange, editorContainer);
|
55
|
+
setAnchorEl({
|
56
|
+
clientWidth: rect.width,
|
57
|
+
clientHeight: rect.height,
|
58
|
+
getBoundingClientRect: () => rect
|
59
|
+
});
|
58
60
|
}
|
59
61
|
} catch (err) {
|
60
62
|
console.log(err);
|
61
63
|
}
|
62
|
-
};
|
64
|
+
}, [editor?.selection]);
|
63
65
|
useEditorScroll(editorWrapper, updateAnchorEl);
|
64
66
|
useEffect(() => {
|
65
67
|
const userStoppedSelection = size?.device === "xs" ? true : event === "end"; // for mobile, when user starts the selection, we are gonna show the popup tool
|
@@ -74,29 +76,44 @@ const PopupTool = props => {
|
|
74
76
|
if (!isCarouselEdit) {
|
75
77
|
setOpen(true);
|
76
78
|
setPopupType("textFormat");
|
77
|
-
setIsTextSelected(true);
|
79
|
+
// setIsTextSelected(true);
|
78
80
|
}
|
79
81
|
} else if (!anchorEl) {
|
80
82
|
setOpen(false);
|
81
83
|
setPopupType("");
|
82
|
-
setIsTextSelected(false);
|
84
|
+
// setIsTextSelected(false);
|
83
85
|
}
|
84
86
|
}, [event, anchorEl]);
|
85
87
|
useEffect(() => {
|
86
|
-
|
88
|
+
console.log("Editor useEffect", selection);
|
89
|
+
if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "") {
|
87
90
|
setAnchorEl(null);
|
88
91
|
} else {
|
92
|
+
console.log("Editor updateAnchorEl", selection);
|
89
93
|
updateAnchorEl();
|
90
94
|
hideSlateSelection(); // removes slate selection background, when there is no selection
|
91
95
|
}
|
92
|
-
}, [selection
|
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]);
|
93
108
|
const handleClose = () => {
|
109
|
+
console.log("Editor closing");
|
94
110
|
// setAnchorEl(null);
|
95
111
|
setOpen(false);
|
96
112
|
setPopupType("");
|
97
113
|
};
|
98
114
|
return open && !openAI ? /*#__PURE__*/_jsx(ClickAwayListener, {
|
99
115
|
onClickAway: e => {
|
116
|
+
console.log("ClickAwayListener", e.target, document.body, e.target !== document.body);
|
100
117
|
// close the mini toolbar, if user clicks outside the editor (in Flozy app.)
|
101
118
|
if (e.target !== document.body) {
|
102
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
|
@@ -115,18 +132,24 @@ const PopupTool = props => {
|
|
115
132
|
id: id,
|
116
133
|
open: open,
|
117
134
|
anchorEl: anchorEl,
|
135
|
+
transition: true,
|
118
136
|
sx: classes.popupWrapper,
|
119
137
|
placement: "top-start",
|
120
|
-
children:
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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
|
+
})
|
130
153
|
})
|
131
154
|
})
|
132
155
|
})
|
@@ -1,11 +1,11 @@
|
|
1
|
-
const
|
2
|
-
|
3
|
-
|
4
|
-
export const
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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,11 +1,7 @@
|
|
1
|
-
import { useEffect
|
1
|
+
import { useEffect } from "react";
|
2
2
|
import WebFont from "webfontloader";
|
3
3
|
import { useEditorContext } from "../../hooks/useMouseMove";
|
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";
|
4
|
+
import { defaultFonts, googleFontList, otherFonts } from "./FontList";
|
9
5
|
const FontLoader = props => {
|
10
6
|
const {
|
11
7
|
otherProps,
|
@@ -14,74 +10,69 @@ const FontLoader = props => {
|
|
14
10
|
const {
|
15
11
|
setFontFamilies
|
16
12
|
} = useEditorContext();
|
17
|
-
const [loading, setLoading] = useState(true);
|
18
13
|
const loadFontsInBatches = (families, batchSize = 5, maxRetries = 3) => {
|
19
14
|
let currentIndex = 0;
|
20
15
|
let retryCount = 0;
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
+
// );
|
38
47
|
currentIndex += batchSize;
|
39
48
|
retryCount = 0; // Reset retry count for the next batch
|
40
49
|
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
|
-
}
|
57
50
|
}
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
}
|
62
|
-
};
|
51
|
+
}
|
52
|
+
});
|
53
|
+
}
|
63
54
|
loadNextBatch();
|
64
55
|
};
|
65
56
|
useEffect(() => {
|
66
|
-
let families = [...
|
57
|
+
let families = [...otherFonts, ...defaultFonts];
|
67
58
|
if (!readOnly) {
|
68
59
|
otherProps?.services("listGoogleFont", []).then(data => {
|
69
|
-
families = [...(data?.data || [])];
|
60
|
+
families = [...families, ...(data?.data || [])];
|
61
|
+
const filteredfamilies = families?.filter(font => !font?.includes("Material"));
|
70
62
|
setFontFamilies({
|
71
63
|
id: 1,
|
72
64
|
format: "fontFamily",
|
73
65
|
type: "fontfamilydropdown",
|
74
|
-
options:
|
66
|
+
options: filteredfamilies || []
|
75
67
|
});
|
76
68
|
loadFontsInBatches(families);
|
77
69
|
}).catch(err => {
|
78
70
|
// console.log(err);
|
79
|
-
setLoading(false);
|
80
71
|
});
|
81
72
|
} else {
|
82
73
|
function correctFontArray(fontString) {
|
83
|
-
let fontsArray = fontString
|
84
|
-
let cleanedFontsArray = [...new Set(fontsArray
|
74
|
+
let fontsArray = fontString.split(",");
|
75
|
+
let cleanedFontsArray = [...new Set(fontsArray.map(font => font.trim()))];
|
85
76
|
return cleanedFontsArray;
|
86
77
|
}
|
87
78
|
function sanitizeFontFamily(fontFamily) {
|
@@ -97,32 +88,11 @@ const FontLoader = props => {
|
|
97
88
|
let families = Array.from(fontSet);
|
98
89
|
families = correctFontArray(families.join(", "));
|
99
90
|
families = families?.map(font => font?.replace(/\"/g, ""));
|
100
|
-
families = families?.map(font => font?.replace(", sans-serif", ""));
|
101
|
-
families = families
|
91
|
+
families = families?.map(font => font?.replace(", sans-serif", "")); //This is temporary fix for patch
|
92
|
+
families = families.filter(font => googleFontList.includes(font));
|
102
93
|
loadFontsInBatches(families);
|
103
94
|
}
|
104
|
-
|
105
|
-
// Set timeout to hide loader after 5 seconds
|
106
|
-
const timeoutId = setTimeout(() => {
|
107
|
-
setLoading(false);
|
108
|
-
}, 5000);
|
109
|
-
return () => clearTimeout(timeoutId);
|
110
95
|
}, []);
|
111
|
-
return
|
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
|
-
});
|
96
|
+
return null;
|
127
97
|
};
|
128
98
|
export default FontLoader;
|
@@ -58,8 +58,8 @@ const useElementSettingsStyle = theme => ({
|
|
58
58
|
maxHeight: "500px",
|
59
59
|
overflowX: "hidden",
|
60
60
|
overflowY: "auto",
|
61
|
-
background: theme?.palette?.editor?.background,
|
62
61
|
paddingLeft: "4px",
|
62
|
+
background: theme?.palette?.editor?.background,
|
63
63
|
"& .MuiTypography-root, .MuiInputBase-root, input": {
|
64
64
|
color: theme?.palette?.editor?.textColor
|
65
65
|
},
|
@@ -2,33 +2,36 @@ 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, Tooltip } from "@mui/material";
|
5
|
+
import { Box, IconButton, Popper, Tooltip } from "@mui/material";
|
6
6
|
import SectionPopup from "../../Elements/Grid/SectionPopup";
|
7
7
|
import { getBreakPointsValue, getTRBLBreakPoints, groupByBreakpoint } from "../../helper/theme";
|
8
|
-
|
9
|
-
|
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";
|
15
16
|
const Toolbar = ({
|
16
17
|
fromPopper,
|
17
18
|
readOnly,
|
18
19
|
showTool,
|
19
|
-
onSettings
|
20
|
-
isSectionFullWidth
|
20
|
+
onSettings
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
"
|
30
|
-
|
31
|
-
|
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"
|
32
35
|
},
|
33
36
|
children: /*#__PURE__*/_jsx(Tooltip, {
|
34
37
|
title: "Section Settings",
|
@@ -53,8 +56,7 @@ const Section = props => {
|
|
53
56
|
readOnly
|
54
57
|
} = customProps;
|
55
58
|
const editor = useSlateStatic();
|
56
|
-
|
57
|
-
const [size] = useWindowResize();
|
59
|
+
const [showTool] = useEditorSelection(editor);
|
58
60
|
const [openSetttings, setOpenSettings] = useState(false);
|
59
61
|
const {
|
60
62
|
sectionBgColor,
|
@@ -71,43 +73,16 @@ const Section = props => {
|
|
71
73
|
} = sectionAlignment || {};
|
72
74
|
const path = ReactEditor.findPath(editor, element);
|
73
75
|
const anchorEl = useRef(null);
|
74
|
-
|
75
|
-
|
76
|
+
const popperEl = useRef(null);
|
77
|
+
const [size] = useWindowResize();
|
76
78
|
const isSectionFullWidth = sectionGridSize && sectionGridSize[size?.device] >= 12;
|
77
|
-
const
|
78
|
-
const
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
};
|
85
|
-
}
|
86
|
-
const sectionBgImage = sectionBackgroundImage && sectionBackgroundImage !== "none" ? {
|
87
|
-
backgroundImage: `url(${sectionBackgroundImage})`
|
88
|
-
} : {};
|
89
|
-
const edSectionSp = groupByBreakpoint({
|
90
|
-
padding: {
|
91
|
-
...getTRBLBreakPoints(sectionBannerSpacing)
|
92
|
-
},
|
93
|
-
borderRadius: {
|
94
|
-
...getBreakPointsValue(sectionBorderRadius || {}, null, "overrideBorderRadius", true)
|
95
|
-
}
|
96
|
-
}, themeReact);
|
97
|
-
const edInnerSp = groupByBreakpoint({
|
98
|
-
width: {
|
99
|
-
...getBreakPointsValue(sectionGridSize || 8, null, "overrideGridSize", true)
|
100
|
-
}
|
101
|
-
}, themeReact);
|
102
|
-
|
103
|
-
// const onMouseEnter = () => {
|
104
|
-
// setIsHovering(true);
|
105
|
-
// };
|
106
|
-
|
107
|
-
// const onMouseLeave = () => {
|
108
|
-
// setIsHovering(false);
|
109
|
-
// };
|
110
|
-
|
79
|
+
const [isHovering, setIsHovering] = useState(false);
|
80
|
+
const onMouseEnter = () => {
|
81
|
+
setIsHovering(true);
|
82
|
+
};
|
83
|
+
const onMouseLeave = () => {
|
84
|
+
setIsHovering(false);
|
85
|
+
};
|
111
86
|
const onSettings = () => {
|
112
87
|
setOpenSettings(true);
|
113
88
|
};
|
@@ -131,6 +106,31 @@ const Section = props => {
|
|
131
106
|
at: path
|
132
107
|
});
|
133
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)) ? "" : "";
|
111
|
+
let tempProps = {};
|
112
|
+
if (element?.type === "temp") {
|
113
|
+
tempProps = {
|
114
|
+
"--left": `${element?.left}px`,
|
115
|
+
"--top": `${element?.top}px`
|
116
|
+
};
|
117
|
+
}
|
118
|
+
const sectionBgImage = sectionBackgroundImage && sectionBackgroundImage !== "none" ? {
|
119
|
+
backgroundImage: `url(${sectionBackgroundImage})`
|
120
|
+
} : {};
|
121
|
+
const edSectionSp = groupByBreakpoint({
|
122
|
+
padding: {
|
123
|
+
...getTRBLBreakPoints(sectionBannerSpacing)
|
124
|
+
},
|
125
|
+
borderRadius: {
|
126
|
+
...getBreakPointsValue(sectionBorderRadius || {}, null, "overrideBorderRadius", true)
|
127
|
+
}
|
128
|
+
}, themeReact);
|
129
|
+
const edInnerSp = groupByBreakpoint({
|
130
|
+
width: {
|
131
|
+
...getBreakPointsValue(sectionGridSize || 8, null, "overrideGridSize", true)
|
132
|
+
}
|
133
|
+
}, themeReact);
|
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,10 +145,9 @@ const Section = props => {
|
|
145
145
|
flexDirection: flexDirection || "column",
|
146
146
|
alignItems: horizantal,
|
147
147
|
justifyContent: vertical
|
148
|
-
}
|
149
|
-
|
150
|
-
|
151
|
-
,
|
148
|
+
},
|
149
|
+
onMouseEnter: onMouseEnter,
|
150
|
+
onMouseLeave: onMouseLeave,
|
152
151
|
children: [/*#__PURE__*/_jsxs(Box, {
|
153
152
|
className: "ed-section-inner",
|
154
153
|
sx: {
|
@@ -156,11 +155,41 @@ const Section = props => {
|
|
156
155
|
...edInnerSp
|
157
156
|
},
|
158
157
|
ref: anchorEl,
|
159
|
-
children: [/*#__PURE__*/_jsx(
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
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
|
+
})]
|
164
193
|
}), children]
|
165
194
|
}), openSetttings ? /*#__PURE__*/_jsx(SectionPopup, {
|
166
195
|
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
|
178
|
+
const text = el.textContent.replace(/\r|\n/g, "").trim();
|
179
179
|
return match && !text ? null : {
|
180
180
|
text,
|
181
181
|
...getInlineTextStyles(el.parentNode)
|
@@ -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
|
-
|
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
|
-
|
9
|
+
}, []);
|
10
|
+
useEffect(() => {
|
17
11
|
document.addEventListener("pointerdown", onMouseDown);
|
18
12
|
document.addEventListener("pointerup", onMouseUp);
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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,8 +4,9 @@ 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
|
-
callback(
|
9
|
+
callback();
|
9
10
|
}
|
10
11
|
};
|
11
12
|
const currentEditorWrapper = editorWrapper.current;
|
@@ -1,7 +1,6 @@
|
|
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";
|
5
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
6
5
|
const EditorContext = /*#__PURE__*/createContext();
|
7
6
|
export const useEditorSelection = editor => {
|
@@ -35,7 +34,7 @@ export const EditorProvider = ({
|
|
35
34
|
const [contextMenu, setContextMenu] = useState({
|
36
35
|
path: null
|
37
36
|
});
|
38
|
-
const [fontFamilies, setFontFamilies] = useState(
|
37
|
+
const [fontFamilies, setFontFamilies] = useState({});
|
39
38
|
const [activeBreakPoint, setActiveBreakPoint] = useState("");
|
40
39
|
useEffect(() => {
|
41
40
|
window.updateSelectedItem = d => {
|