@flozy/editor 6.0.5 → 6.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 +15 -17
- package/dist/Editor/Editor.css +4 -3
- package/dist/Editor/Elements/AI/PopoverAIInput.js +2 -12
- package/dist/Editor/Elements/Button/EditorButton.js +1 -0
- package/dist/Editor/Elements/DataView/DataView.js +4 -3
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +5 -1
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +5 -1
- package/dist/Editor/Elements/DataView/Layouts/FilterView.js +23 -19
- package/dist/Editor/Elements/Form/Form.js +1 -0
- package/dist/Editor/Elements/FreeGrid/styles.js +1 -0
- package/dist/Editor/Elements/List/CheckList.js +2 -1
- package/dist/Editor/Elements/Search/SearchAttachment.js +1 -0
- package/dist/Editor/Elements/Search/SearchList.js +8 -1
- package/dist/Editor/Elements/SimpleText/index.js +19 -7
- package/dist/Editor/Elements/SimpleText/style.js +5 -1
- package/dist/Editor/Elements/Table/Table.js +15 -15
- package/dist/Editor/Elements/Table/TableCell.js +14 -9
- package/dist/Editor/MiniEditor.js +4 -2
- package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +37 -28
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectAlignment.js +3 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +1 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +3 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +3 -8
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +9 -3
- package/dist/Editor/Toolbar/PopupTool/TemplateCard.js +1 -1
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +45 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +45 -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 +2 -1
- package/dist/Editor/common/RnD/ElementSettings/styles.js +1 -0
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +6 -0
- package/dist/Editor/common/Section/index.js +89 -60
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +79 -0
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +4 -0
- package/dist/Editor/commonStyle.js +5 -0
- package/dist/Editor/helper/deserialize/index.js +1 -1
- package/dist/Editor/helper/ensureWrappedVariables.js +28 -0
- package/dist/Editor/helper/theme.js +24 -1
- package/dist/Editor/hooks/useDrag.js +11 -17
- package/dist/Editor/hooks/useEditorScroll.js +2 -1
- package/dist/Editor/hooks/useMouseMove.js +6 -4
- package/dist/Editor/plugins/withHTML.js +7 -1
- package/dist/Editor/utils/SlateUtilityFunctions.js +23 -12
- package/dist/Editor/utils/customHooks/useTableResize.js +2 -1
- package/dist/Editor/utils/helper.js +41 -0
- package/dist/Editor/utils/pageSettings.js +14 -2
- package/dist/Editor/utils/table.js +21 -0
- package/package.json +3 -3
@@ -58,6 +58,7 @@ const useElementSettingsStyle = theme => ({
|
|
58
58
|
maxHeight: "500px",
|
59
59
|
overflowX: "hidden",
|
60
60
|
overflowY: "auto",
|
61
|
+
paddingLeft: "4px",
|
61
62
|
background: theme?.palette?.editor?.background,
|
62
63
|
"& .MuiTypography-root, .MuiInputBase-root, input": {
|
63
64
|
color: theme?.palette?.editor?.textColor
|
@@ -3,6 +3,7 @@ import PersonalVideoIcon from "@mui/icons-material/PersonalVideo";
|
|
3
3
|
import PhoneIphoneIcon from "@mui/icons-material/PhoneIphone";
|
4
4
|
import useSwitchViewport from "./styles";
|
5
5
|
import { useEffect } from "react";
|
6
|
+
import { useEditorContext } from "../../../hooks/useMouseMove";
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
7
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
8
9
|
const SwitchViewport = props => {
|
@@ -11,6 +12,9 @@ const SwitchViewport = props => {
|
|
11
12
|
onChange
|
12
13
|
} = props;
|
13
14
|
const classes = useSwitchViewport();
|
15
|
+
const {
|
16
|
+
setActiveBreakPoint
|
17
|
+
} = useEditorContext();
|
14
18
|
useEffect(() => {
|
15
19
|
console.log(breakpoint);
|
16
20
|
}, [breakpoint]);
|
@@ -21,6 +25,7 @@ const SwitchViewport = props => {
|
|
21
25
|
children: /*#__PURE__*/_jsx(IconButton, {
|
22
26
|
className: `${!breakpoint || breakpoint === "lg" ? "active" : ""}`,
|
23
27
|
onClick: () => {
|
28
|
+
setActiveBreakPoint("");
|
24
29
|
onChange("");
|
25
30
|
},
|
26
31
|
children: /*#__PURE__*/_jsx(PersonalVideoIcon, {})
|
@@ -30,6 +35,7 @@ const SwitchViewport = props => {
|
|
30
35
|
children: /*#__PURE__*/_jsx(IconButton, {
|
31
36
|
className: `${breakpoint === "xs" ? "active" : ""}`,
|
32
37
|
onClick: () => {
|
38
|
+
setActiveBreakPoint("xs");
|
33
39
|
onChange("xs");
|
34
40
|
},
|
35
41
|
children: /*#__PURE__*/_jsx(PhoneIphoneIcon, {})
|
@@ -2,34 +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
|
-
|
14
|
-
// const list_types = ["orderedList", "unorderedList"];
|
15
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
16
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
15
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
17
16
|
const Toolbar = ({
|
17
|
+
fromPopper,
|
18
18
|
readOnly,
|
19
19
|
showTool,
|
20
|
-
onSettings
|
21
|
-
isSectionFullWidth
|
20
|
+
onSettings
|
22
21
|
}) => {
|
23
22
|
return !readOnly && !showTool ? /*#__PURE__*/_jsx(Box, {
|
24
23
|
component: "div",
|
25
24
|
className: `element-toolbar no-border-button hr section-tw sectionIcon`,
|
26
25
|
contentEditable: false,
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
"
|
31
|
-
|
32
|
-
|
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"
|
33
35
|
},
|
34
36
|
children: /*#__PURE__*/_jsx(Tooltip, {
|
35
37
|
title: "Section Settings",
|
@@ -40,6 +42,7 @@ const Toolbar = ({
|
|
40
42
|
})
|
41
43
|
}) : null;
|
42
44
|
};
|
45
|
+
const list_types = ["orderedList", "unorderedList"];
|
43
46
|
const Section = props => {
|
44
47
|
const themeReact = useTheme();
|
45
48
|
const theme = props?.theme;
|
@@ -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: {
|
@@ -18,6 +18,7 @@ import FontSize from "./fontSize";
|
|
18
18
|
import SelectSwitch from "./selectSwitch";
|
19
19
|
import CardsMapping from "./card";
|
20
20
|
import MetaDataMapping from "./metaDataMapping";
|
21
|
+
import LineSpacing from "./lineSpacing";
|
21
22
|
const FieldMap = {
|
22
23
|
text: Text,
|
23
24
|
bannerSpacing: BannerSpacing,
|
@@ -38,6 +39,7 @@ const FieldMap = {
|
|
38
39
|
fontSize: FontSize,
|
39
40
|
selectSwitch: SelectSwitch,
|
40
41
|
card: CardsMapping,
|
41
|
-
metadatamapping: MetaDataMapping
|
42
|
+
metadatamapping: MetaDataMapping,
|
43
|
+
lineSpacing: LineSpacing
|
42
44
|
};
|
43
45
|
export default FieldMap;
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Grid, Slider, Typography, Box } from "@mui/material";
|
3
|
+
import { getBreakPointsValue } from "../../../helper/theme";
|
4
|
+
import useWindowResize from "../../../hooks/useWindowResize";
|
5
|
+
import { useEditorContext } from "../../../hooks/useMouseMove";
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
8
|
+
const LineSpacing = props => {
|
9
|
+
const {
|
10
|
+
value: val,
|
11
|
+
data,
|
12
|
+
onChange
|
13
|
+
} = props;
|
14
|
+
const {
|
15
|
+
theme
|
16
|
+
} = useEditorContext();
|
17
|
+
const {
|
18
|
+
key
|
19
|
+
} = data;
|
20
|
+
const [size] = useWindowResize();
|
21
|
+
const pro_value = getBreakPointsValue(val, size?.device);
|
22
|
+
const [value, setValue] = useState(pro_value);
|
23
|
+
let breakpointValue = getBreakPointsValue(val, null);
|
24
|
+
breakpointValue = typeof breakpointValue['lg'] === 'object' ? breakpointValue['lg'] : breakpointValue;
|
25
|
+
useState(() => {
|
26
|
+
setValue(pro_value);
|
27
|
+
}, [pro_value]);
|
28
|
+
const handleChange = e => {
|
29
|
+
onChange({
|
30
|
+
[key]: {
|
31
|
+
...breakpointValue,
|
32
|
+
[size?.device]: e.target.value
|
33
|
+
}
|
34
|
+
});
|
35
|
+
};
|
36
|
+
return /*#__PURE__*/_jsxs(Grid, {
|
37
|
+
item: true,
|
38
|
+
xs: 12,
|
39
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
40
|
+
variant: "body1",
|
41
|
+
color: "primary",
|
42
|
+
style: {
|
43
|
+
fontSize: "14px",
|
44
|
+
fontWeight: 500
|
45
|
+
},
|
46
|
+
children: data?.label
|
47
|
+
}), /*#__PURE__*/_jsxs(Grid, {
|
48
|
+
container: true,
|
49
|
+
wrap: "nowrap",
|
50
|
+
className: "sld-wrpr",
|
51
|
+
children: [/*#__PURE__*/_jsx(Slider, {
|
52
|
+
className: "spacingSlider",
|
53
|
+
defaultValue: value || 1.43,
|
54
|
+
"aria-label": "Default",
|
55
|
+
valueLabelDisplay: "auto",
|
56
|
+
min: 0.5,
|
57
|
+
max: 3.0,
|
58
|
+
step: 0.1,
|
59
|
+
name: "lineHeight",
|
60
|
+
onChange: handleChange
|
61
|
+
}), /*#__PURE__*/_jsx(Box, {
|
62
|
+
component: "input",
|
63
|
+
sx: {
|
64
|
+
background: theme?.palette?.editor?.background,
|
65
|
+
color: theme?.palette?.editor?.textColor
|
66
|
+
},
|
67
|
+
name: "lineHeight",
|
68
|
+
value: pro_value,
|
69
|
+
className: "sliderInput",
|
70
|
+
onChange: handleChange,
|
71
|
+
type: "number",
|
72
|
+
placeholder: "0",
|
73
|
+
disabled: true,
|
74
|
+
defaultValue: pro_value || 1.43
|
75
|
+
})]
|
76
|
+
})]
|
77
|
+
});
|
78
|
+
};
|
79
|
+
export default LineSpacing;
|
@@ -49,6 +49,11 @@ const useCommonStyle = theme => ({
|
|
49
49
|
fontWeight: "500",
|
50
50
|
fontFamily: "Inter, sans-serif"
|
51
51
|
},
|
52
|
+
"& .MuiPaper-root": {
|
53
|
+
border: `unset !important`,
|
54
|
+
borderRadius: '0px',
|
55
|
+
height: 'fit-content'
|
56
|
+
},
|
52
57
|
"& p": {
|
53
58
|
marginBottom: "7px",
|
54
59
|
marginTop: "4px"
|
@@ -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)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
export const ensureWrappedVariables = content => {
|
2
|
+
return content.map(node => {
|
3
|
+
if (node.children) {
|
4
|
+
return {
|
5
|
+
...node,
|
6
|
+
children: node.children.reduce((result, child, index, arr) => {
|
7
|
+
if (child.type === "variables") {
|
8
|
+
if (index === 0 || !arr[index - 1].text || arr[index - 1].text.trim() === "") {
|
9
|
+
result.push({
|
10
|
+
text: ""
|
11
|
+
});
|
12
|
+
}
|
13
|
+
result.push(child);
|
14
|
+
if (index === arr.length - 1 || !arr[index + 1]?.text || arr[index + 1]?.text.trim() === "") {
|
15
|
+
result.push({
|
16
|
+
text: ""
|
17
|
+
});
|
18
|
+
}
|
19
|
+
} else {
|
20
|
+
result.push(child);
|
21
|
+
}
|
22
|
+
return result;
|
23
|
+
}, [])
|
24
|
+
};
|
25
|
+
}
|
26
|
+
return node;
|
27
|
+
});
|
28
|
+
};
|
@@ -161,4 +161,27 @@ export const groupByBreakpoint = (styleProps, theme) => {
|
|
161
161
|
}
|
162
162
|
};
|
163
163
|
};
|
164
|
-
export const getCustomizationValue = value => isNaN(parseInt(value)) ? null : parseInt(value);
|
164
|
+
export const getCustomizationValue = value => isNaN(parseInt(value)) ? null : parseInt(value);
|
165
|
+
export const getBreakpointLineSpacing = (value, breakpoint) => {
|
166
|
+
try {
|
167
|
+
const values = getBreakPointsValue(value, breakpoint);
|
168
|
+
const cssVal = BREAKPOINTS_DEVICES.reduce((a, b) => {
|
169
|
+
if (values[b] || values["lg"]) {
|
170
|
+
const value = values[b] || values["lg"];
|
171
|
+
return {
|
172
|
+
...a,
|
173
|
+
[b]: value
|
174
|
+
};
|
175
|
+
} else {
|
176
|
+
return a;
|
177
|
+
}
|
178
|
+
}, {});
|
179
|
+
if (breakpoint) {
|
180
|
+
return value[breakpoint] || value["lg"] || value;
|
181
|
+
} else {
|
182
|
+
return cssVal["lg"];
|
183
|
+
}
|
184
|
+
} catch (err) {
|
185
|
+
// console.log(err);
|
186
|
+
}
|
187
|
+
};
|
@@ -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,8 @@ 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({});
|
38
|
+
const [activeBreakPoint, setActiveBreakPoint] = useState("");
|
39
39
|
useEffect(() => {
|
40
40
|
window.updateSelectedItem = d => {
|
41
41
|
setSelectedElement(d);
|
@@ -98,8 +98,10 @@ export const EditorProvider = ({
|
|
98
98
|
setOpenAI,
|
99
99
|
updateDragging,
|
100
100
|
fontFamilies,
|
101
|
-
setFontFamilies
|
102
|
-
|
101
|
+
setFontFamilies,
|
102
|
+
activeBreakPoint,
|
103
|
+
setActiveBreakPoint
|
104
|
+
}), [path, editor?.selection, selectedPath, selectedElement, contextMenu, openAI, popupType, drop, activeBreakPoint]);
|
103
105
|
return /*#__PURE__*/_jsx(EditorContext.Provider, {
|
104
106
|
value: otherValues,
|
105
107
|
children: children
|
@@ -253,7 +253,13 @@ const withHtml = editor => {
|
|
253
253
|
return;
|
254
254
|
}
|
255
255
|
const fragment = deserialize(parsed.body);
|
256
|
-
const
|
256
|
+
const normalizeFragment = formatFragment[eltype];
|
257
|
+
if (normalizeFragment && isNonText) {
|
258
|
+
// When a non-text node is pasted into a list item, insert it into the next node.
|
259
|
+
insertAtNextNode(editor, fragment);
|
260
|
+
return;
|
261
|
+
}
|
262
|
+
const formattedFragment = normalizeFragment ? normalizeFragment(fragment) : fragment;
|
257
263
|
let is_img_table = false;
|
258
264
|
formattedFragment.map(f => {
|
259
265
|
if (f.type === "image" || f?.type?.includes("table")) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Editor, Transforms, Element as SlateElement } from "slate";
|
1
|
+
import { Editor, Transforms, Element as SlateElement, Range } from "slate";
|
2
2
|
import { Box } from "@mui/material";
|
3
3
|
import { sizeMap } from "./font";
|
4
4
|
import Link from "../Elements/Link/Link";
|
@@ -38,7 +38,7 @@ import { getBreakPointsValue, groupByBreakpoint } from "../helper/theme";
|
|
38
38
|
import Variables from "../Elements/Variables/Variable";
|
39
39
|
import insertNewLine from "./insertNewLine";
|
40
40
|
import Divider from "../Elements/Divider/Divider";
|
41
|
-
import { getBorderColor } from "./helper";
|
41
|
+
import { getBorderColor, getSlateDom } from "./helper";
|
42
42
|
import Code from "../Elements/EmbedScript/Code";
|
43
43
|
import FreeGrid from "../Elements/FreeGrid/FreeGrid";
|
44
44
|
import FreeGridItem from "../Elements/FreeGrid/FreeGridItem";
|
@@ -161,7 +161,17 @@ export const activeMark = (editor, format) => {
|
|
161
161
|
};
|
162
162
|
try {
|
163
163
|
const marks = Editor.marks(editor);
|
164
|
-
|
164
|
+
let defaultValue = defaultMarkData[format];
|
165
|
+
const {
|
166
|
+
selection
|
167
|
+
} = editor || {};
|
168
|
+
if (format === "fontSize" && selection && !Range.isCollapsed(selection)) {
|
169
|
+
const slateDom = getSlateDom(editor, editor?.selection);
|
170
|
+
if (slateDom) {
|
171
|
+
const parentElement = slateDom.commonAncestorContainer.parentElement;
|
172
|
+
defaultValue = window.getComputedStyle(parentElement).fontSize;
|
173
|
+
}
|
174
|
+
}
|
165
175
|
return marks?.[format] ?? defaultValue;
|
166
176
|
} catch (err) {
|
167
177
|
console.log(err);
|
@@ -173,10 +183,9 @@ export const getMarked = (leaf, children, theme) => {
|
|
173
183
|
if (leaf.highlight) {
|
174
184
|
children = /*#__PURE__*/_jsx("span", {
|
175
185
|
style: {
|
176
|
-
color: "inherit"
|
186
|
+
color: "inherit",
|
187
|
+
background: "var(--slate-highlight-bg)"
|
177
188
|
},
|
178
|
-
className: "slate-highlight" // while opening AI, we will use this element to highlight the selection. (PopoverAIInput.js)
|
179
|
-
,
|
180
189
|
children: children
|
181
190
|
});
|
182
191
|
}
|
@@ -338,7 +347,8 @@ export const getBlock = props => {
|
|
338
347
|
borderRadius: `${element?.color ? "0px" : "12px"} 12px 12px ${element?.color ? "0px" : "12px"}`,
|
339
348
|
margin: `${element?.bgColor ? "16px" : "0px"} 0px`,
|
340
349
|
width: element?.bgColor ? "calc(100% - 16px)" : "100%",
|
341
|
-
borderWidth: element?.color ? "0px 0px 0px 3px" : "0px"
|
350
|
+
borderWidth: element?.color ? "0px 0px 0px 3px" : "0px",
|
351
|
+
lineHeight: 1.43
|
342
352
|
},
|
343
353
|
children: children
|
344
354
|
});
|
@@ -398,6 +408,9 @@ export const getBlock = props => {
|
|
398
408
|
});
|
399
409
|
case "orderedList":
|
400
410
|
return /*#__PURE__*/_jsx("ol", {
|
411
|
+
style: {
|
412
|
+
lineHeight: 1.43
|
413
|
+
},
|
401
414
|
className: "listItemMargin",
|
402
415
|
type: "1",
|
403
416
|
...attributes,
|
@@ -405,6 +418,9 @@ export const getBlock = props => {
|
|
405
418
|
});
|
406
419
|
case "unorderedList":
|
407
420
|
return /*#__PURE__*/_jsx("ul", {
|
421
|
+
style: {
|
422
|
+
lineHeight: 1.43
|
423
|
+
},
|
408
424
|
className: "listItemMargin",
|
409
425
|
...attributes,
|
410
426
|
children: children
|
@@ -614,11 +630,6 @@ export const getBlock = props => {
|
|
614
630
|
children: children
|
615
631
|
});
|
616
632
|
default:
|
617
|
-
// return (
|
618
|
-
// <span {...attributes} {...element.attr}>
|
619
|
-
// {children}
|
620
|
-
// </span>
|
621
|
-
// );
|
622
633
|
return /*#__PURE__*/_jsx(SimpleText, {
|
623
634
|
...props,
|
624
635
|
isEmpty: isEmpty
|
@@ -43,7 +43,8 @@ const useTableResize = ({
|
|
43
43
|
minWidth
|
44
44
|
} = minMaxProps || {};
|
45
45
|
setSize(currentSize => {
|
46
|
-
const
|
46
|
+
const width = currentSize?.width || parentDOM?.clientWidth;
|
47
|
+
const calcWidth = width + e.movementX;
|
47
48
|
return {
|
48
49
|
width: minWidth && calcWidth < minWidth ? minWidth : calcWidth,
|
49
50
|
height: currentSize.height + e.movementY,
|