@flozy/editor 10.8.6 → 10.8.8
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/Toolbar/FormatTools/TextSize.js +23 -16
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +17 -10
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +9 -2
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +1 -1
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +8 -2
- package/dist/Editor/hooks/useEditorTheme.js +2 -4
- package/dist/Editor/theme/ThemeList.js +2 -3
- package/dist/Editor/theme/index.js +3 -3
- package/package.json +1 -1
@@ -8,13 +8,19 @@ import { TextSizeDownArrow, TextSizeUpArrow } from "../../common/iconListV2.js";
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
9
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
10
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
11
|
-
const TextSize =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
const TextSize = props => {
|
12
|
+
const {
|
13
|
+
classes,
|
14
|
+
editor,
|
15
|
+
format,
|
16
|
+
fullWidth,
|
17
|
+
fromMiniTextFormat,
|
18
|
+
setResizedSize,
|
19
|
+
resizedSize
|
20
|
+
} = props;
|
17
21
|
const [fontSize, setFontSize] = useState();
|
22
|
+
const sizeValue = fromMiniTextFormat ? resizedSize : fontSize;
|
23
|
+
const setSizeValue = fromMiniTextFormat ? setResizedSize : setFontSize;
|
18
24
|
const timerRef = useRef();
|
19
25
|
const [size] = useWindowResize();
|
20
26
|
const val = activeMark(editor, format);
|
@@ -24,7 +30,7 @@ const TextSize = ({
|
|
24
30
|
|
25
31
|
const value = getTextSizeVal(editor);
|
26
32
|
useEffect(() => {
|
27
|
-
|
33
|
+
setSizeValue(getSizeVal());
|
28
34
|
}, [value]);
|
29
35
|
const updateMarkData = newVal => {
|
30
36
|
let upData = {
|
@@ -51,9 +57,10 @@ const TextSize = ({
|
|
51
57
|
if (value) {
|
52
58
|
let inc = parseInt(value);
|
53
59
|
inc = inc > 200 ? 200 : inc;
|
60
|
+
setSizeValue(inc);
|
54
61
|
updateMarkData(inc);
|
55
62
|
} else {
|
56
|
-
|
63
|
+
setSizeValue(null);
|
57
64
|
}
|
58
65
|
};
|
59
66
|
const getSizeVal = () => {
|
@@ -63,20 +70,20 @@ const TextSize = ({
|
|
63
70
|
return "";
|
64
71
|
}
|
65
72
|
};
|
66
|
-
const combinedOldVal = getSizeVal();
|
67
73
|
const onIncreaseSize = () => {
|
68
|
-
|
69
|
-
|
70
|
-
updateMarkData(
|
74
|
+
const newValue = Math.min((sizeValue || 16) + 1, 200);
|
75
|
+
setSizeValue(newValue);
|
76
|
+
updateMarkData(newValue);
|
71
77
|
};
|
72
78
|
const onDecreaseSize = () => {
|
73
|
-
const
|
74
|
-
|
79
|
+
const newValue = sizeValue ? Math.max(sizeValue - 1, 1) : 16;
|
80
|
+
setSizeValue(newValue);
|
81
|
+
updateMarkData(newValue);
|
75
82
|
};
|
76
83
|
const onChange = e => {
|
77
84
|
clearTimeout(timerRef.current);
|
78
85
|
const value = e.target.value;
|
79
|
-
|
86
|
+
setSizeValue(value);
|
80
87
|
timerRef.current = setTimeout(() => {
|
81
88
|
onChangeSize(value);
|
82
89
|
}, 500);
|
@@ -84,7 +91,7 @@ const TextSize = ({
|
|
84
91
|
return /*#__PURE__*/_jsx(_Fragment, {
|
85
92
|
children: /*#__PURE__*/_jsx(TextField, {
|
86
93
|
sx: classes?.textSize,
|
87
|
-
value:
|
94
|
+
value: sizeValue || 16,
|
88
95
|
onChange: onChange,
|
89
96
|
size: "small",
|
90
97
|
inputProps: {
|
@@ -7,12 +7,18 @@ import { BREAKPOINTS_DEVICES, getBreakPointsValue, getTextSizeVal } from "../../
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
9
9
|
const fontSizeOptions = [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 26, 32, 36, 40, 48, 64, 96, 128];
|
10
|
-
function SelectFontSize({
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
function SelectFontSize(props) {
|
11
|
+
const {
|
12
|
+
editor,
|
13
|
+
classes,
|
14
|
+
fromMiniTextFormat,
|
15
|
+
setResizedSize,
|
16
|
+
resizedSize
|
17
|
+
} = props;
|
14
18
|
const format = "fontSize";
|
15
19
|
const [fontSize, setFontSize] = useState();
|
20
|
+
const sizeValue = fromMiniTextFormat ? resizedSize : fontSize;
|
21
|
+
const setSizeValue = fromMiniTextFormat ? setResizedSize : setFontSize;
|
16
22
|
const [anchorEl, setAnchorEl] = useState(null);
|
17
23
|
const open = Boolean(anchorEl);
|
18
24
|
const containerRef = useRef();
|
@@ -45,9 +51,10 @@ function SelectFontSize({
|
|
45
51
|
if (value) {
|
46
52
|
let inc = parseInt(value);
|
47
53
|
inc = inc > 200 ? 200 : inc;
|
54
|
+
setSizeValue(inc);
|
48
55
|
updateMarkData(inc);
|
49
56
|
} else {
|
50
|
-
|
57
|
+
setSizeValue(null);
|
51
58
|
}
|
52
59
|
};
|
53
60
|
const getSizeVal = () => {
|
@@ -58,12 +65,12 @@ function SelectFontSize({
|
|
58
65
|
}
|
59
66
|
};
|
60
67
|
useEffect(() => {
|
61
|
-
|
68
|
+
setSizeValue(getSizeVal());
|
62
69
|
}, [value]);
|
63
70
|
const onChange = e => {
|
64
71
|
clearTimeout(timerRef.current);
|
65
72
|
const value = e.target.value;
|
66
|
-
|
73
|
+
setSizeValue(value);
|
67
74
|
timerRef.current = setTimeout(() => {
|
68
75
|
onChangeSize(value);
|
69
76
|
}, 500);
|
@@ -76,7 +83,7 @@ function SelectFontSize({
|
|
76
83
|
},
|
77
84
|
children: [/*#__PURE__*/_jsx(TextField, {
|
78
85
|
sx: classes?.miniFontSizeInput,
|
79
|
-
value:
|
86
|
+
value: sizeValue,
|
80
87
|
onChange: onChange,
|
81
88
|
size: "small"
|
82
89
|
}), /*#__PURE__*/_jsx(IconButton, {
|
@@ -97,9 +104,9 @@ function SelectFontSize({
|
|
97
104
|
children: fontSizeOptions.map((s, i) => {
|
98
105
|
return /*#__PURE__*/_jsx("div", {
|
99
106
|
children: /*#__PURE__*/_jsx(Button, {
|
100
|
-
className: `customSelectOptionLabel ${
|
107
|
+
className: `customSelectOptionLabel ${sizeValue === s ? "selected" : ""}`,
|
101
108
|
onClick: () => {
|
102
|
-
|
109
|
+
setSizeValue(s);
|
103
110
|
onChangeSize(s);
|
104
111
|
},
|
105
112
|
children: s
|
@@ -34,6 +34,7 @@ const MiniTextFormat = props => {
|
|
34
34
|
const [anchorEl, setAnchorEl] = useState(null);
|
35
35
|
const open = Boolean(anchorEl);
|
36
36
|
const id = open ? "popup-edit-tool" : "";
|
37
|
+
const [resizedSize, setResizedSize] = useState();
|
37
38
|
const [size] = useWindowResize();
|
38
39
|
const theme = useTheme();
|
39
40
|
const listType = getListType(editor);
|
@@ -84,7 +85,10 @@ const MiniTextFormat = props => {
|
|
84
85
|
className: "verticalLine mr-1"
|
85
86
|
}), /*#__PURE__*/_jsx(SelectFontSize, {
|
86
87
|
classes: classes,
|
87
|
-
editor: editor
|
88
|
+
editor: editor,
|
89
|
+
fromMiniTextFormat: true,
|
90
|
+
setResizedSize: setResizedSize,
|
91
|
+
resizedSize: resizedSize
|
88
92
|
}), /*#__PURE__*/_jsx("div", {
|
89
93
|
className: "verticalLine mr-1"
|
90
94
|
}), fontStyle?.map((m, i) => {
|
@@ -147,7 +151,10 @@ const MiniTextFormat = props => {
|
|
147
151
|
classes: classes,
|
148
152
|
closeMainPopup: closeMainPopup,
|
149
153
|
customProps: customProps,
|
150
|
-
commonProps: commonProps
|
154
|
+
commonProps: commonProps,
|
155
|
+
fromMiniTextFormat: true,
|
156
|
+
setResizedSize: setResizedSize,
|
157
|
+
resizedSize: resizedSize
|
151
158
|
})]
|
152
159
|
})
|
153
160
|
})
|
@@ -32,7 +32,10 @@ const TextFormat = props => {
|
|
32
32
|
onClose,
|
33
33
|
closeMainPopup,
|
34
34
|
customProps,
|
35
|
-
commonProps
|
35
|
+
commonProps,
|
36
|
+
setResizedSize,
|
37
|
+
resizedSize,
|
38
|
+
fromMiniTextFormat
|
36
39
|
} = props;
|
37
40
|
const [anchorEl, setAnchorEl] = useState(null);
|
38
41
|
const [type, setType] = useState(null);
|
@@ -252,7 +255,10 @@ const TextFormat = props => {
|
|
252
255
|
format: "fontSize",
|
253
256
|
activeMark: activeMark,
|
254
257
|
editor: editor,
|
255
|
-
fullWidth: true
|
258
|
+
fullWidth: true,
|
259
|
+
fromMiniTextFormat: fromMiniTextFormat,
|
260
|
+
setResizedSize: setResizedSize,
|
261
|
+
resizedSize: resizedSize
|
256
262
|
})
|
257
263
|
})]
|
258
264
|
})]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useSlate } from "slate-react";
|
2
|
-
import {
|
2
|
+
import { defaultTheme } from "../theme";
|
3
3
|
import { getPageSettings, updatePageSettings } from "../utils/pageSettings";
|
4
4
|
import { HEADING_THEME_FIELDS, PARAGRAPH_THEME_FIELDS } from "../helper/theme";
|
5
5
|
import { useEditorContext } from "./useMouseMove";
|
@@ -145,10 +145,8 @@ export const useEditorTheme = () => {
|
|
145
145
|
const {
|
146
146
|
theme
|
147
147
|
} = pageProps || {};
|
148
|
-
const fallbackTheme = baseTheme?.theme || {};
|
149
|
-
console.log("fallbackTheme", fallbackTheme, baseTheme);
|
150
148
|
return {
|
151
|
-
selectedTheme: theme?.theme ||
|
149
|
+
selectedTheme: theme?.theme || defaultTheme()?.theme,
|
152
150
|
updateTheme: (update, actionData) => updateTheme(editor, pageSt, update, actionData, triggerRender),
|
153
151
|
theme
|
154
152
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Box, MenuItem, Select } from "@mui/material";
|
2
|
-
import {
|
2
|
+
import { defaultTheme } from ".";
|
3
3
|
import { useEditorTheme } from "../hooks/useEditorTheme";
|
4
4
|
import { useEffect, useState } from "react";
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
@@ -31,8 +31,7 @@ function ThemeList({
|
|
31
31
|
const {
|
32
32
|
value
|
33
33
|
} = e.target;
|
34
|
-
const
|
35
|
-
const selectedTheme = themes.find(t => t.id === value) || fallbackTheme;
|
34
|
+
const selectedTheme = themes.find(t => t.id === value) || defaultTheme();
|
36
35
|
updateTheme(selectedTheme, "THEME_CHANGE");
|
37
36
|
};
|
38
37
|
return /*#__PURE__*/_jsx(Box, {
|
@@ -117,7 +117,7 @@ export const transformTheme = (selectedTheme = {}) => {
|
|
117
117
|
...others
|
118
118
|
};
|
119
119
|
};
|
120
|
-
export const
|
120
|
+
export const defaultTheme = () => ({
|
121
121
|
theme: {
|
122
122
|
cssVars: {},
|
123
123
|
elementProps: {
|
@@ -143,7 +143,7 @@ export const baseTheme = {
|
|
143
143
|
}
|
144
144
|
}
|
145
145
|
}
|
146
|
-
};
|
146
|
+
});
|
147
147
|
export function getTheme(selectedTheme) {
|
148
|
-
return transformTheme(selectedTheme?.theme ||
|
148
|
+
return transformTheme(selectedTheme?.theme || defaultTheme().theme);
|
149
149
|
}
|