@flozy/editor 5.8.1 → 5.8.2
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 +6 -4
- package/dist/Editor/Editor.css +14 -15
- package/dist/Editor/Elements/AI/PopoverAIInput.js +2 -12
- package/dist/Editor/Elements/Button/EditorButton.js +2 -1
- 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/Divider/Divider.js +3 -3
- package/dist/Editor/Elements/Search/SearchList.js +8 -1
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/Table.js +3 -3
- package/dist/Editor/Elements/Table/TableCell.js +14 -9
- package/dist/Editor/Elements/Title/title.js +13 -1
- package/dist/Editor/Elements/Variables/Style.js +21 -2
- package/dist/Editor/Elements/Variables/VariableButton.js +17 -4
- package/dist/Editor/MiniEditor.js +4 -2
- package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +24 -25
- 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 +1 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +9 -3
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +5 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +2 -0
- package/dist/Editor/common/FontLoader/FontList.js +3 -11
- package/dist/Editor/common/FontLoader/FontLoader.js +33 -7
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +1 -0
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +8 -2
- package/dist/Editor/common/Section/index.js +39 -29
- package/dist/Editor/common/Section/styles.js +15 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
- package/dist/Editor/common/Uploader.js +8 -0
- package/dist/Editor/commonStyle.js +13 -12
- package/dist/Editor/helper/ensureWrappedVariables.js +28 -0
- package/dist/Editor/helper/index.js +2 -2
- package/dist/Editor/plugins/withHTML.js +8 -8
- package/dist/Editor/plugins/withLayout.js +1 -1
- package/dist/Editor/utils/SlateUtilityFunctions.js +2 -3
- package/dist/Editor/utils/button.js +4 -4
- package/dist/Editor/utils/customHooks/useTableResize.js +2 -1
- package/dist/Editor/utils/draftToSlate.js +3 -2
- package/dist/Editor/utils/helper.js +60 -19
- package/dist/Editor/utils/table.js +21 -0
- package/package.json +1 -1
@@ -96,7 +96,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
96
96
|
const editorWrapper = useRef();
|
97
97
|
const mentionsRef = useRef();
|
98
98
|
const convertedContent = draftToSlate({
|
99
|
-
data: content
|
99
|
+
data: content,
|
100
|
+
needLayout: otherProps?.needLayout
|
100
101
|
});
|
101
102
|
const [value, setValue] = useState(convertedContent);
|
102
103
|
const [isInteracted, setIsInteracted] = useState(false);
|
@@ -167,11 +168,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
167
168
|
const debounced = useDebouncedCallback(
|
168
169
|
// function
|
169
170
|
value => {
|
171
|
+
debouncedValue.current = value;
|
170
172
|
const {
|
171
173
|
value: strVal,
|
172
174
|
...restVal
|
173
175
|
} = getOnSaveData(value);
|
174
|
-
debouncedValue.current = value;
|
175
176
|
onSave(strVal, restVal);
|
176
177
|
},
|
177
178
|
// delay in ms
|
@@ -182,7 +183,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
182
183
|
return {
|
183
184
|
value: JSON.stringify(val),
|
184
185
|
text: text,
|
185
|
-
title: serializeToText(title?.children) || "
|
186
|
+
title: serializeToText(title?.children) || ""
|
186
187
|
};
|
187
188
|
};
|
188
189
|
const getPreviewImage = async (needBackground = false, options = {}) => {
|
@@ -596,8 +597,9 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
596
597
|
setIsTextSelected: setIsTextSelected,
|
597
598
|
customProps: customProps,
|
598
599
|
editorWrapper: editorWrapper
|
599
|
-
}) : null, !readOnly
|
600
|
+
}) : null, !readOnly ? /*#__PURE__*/_jsx(SwitchViewport, {
|
600
601
|
breakpoint: breakpoint,
|
602
|
+
show: showViewport,
|
601
603
|
onChange: b => onSwitchBreakpoint(b)
|
602
604
|
}) : null]
|
603
605
|
})
|
package/dist/Editor/Editor.css
CHANGED
@@ -1258,11 +1258,24 @@ blockquote {
|
|
1258
1258
|
}
|
1259
1259
|
|
1260
1260
|
.dividerComponent:hover .divider-settings,
|
1261
|
-
.dividerComponent:hover .
|
1261
|
+
.dividerComponent:hover .sectionIcon button {
|
1262
1262
|
display: block;
|
1263
1263
|
pointer-events: auto;
|
1264
1264
|
}
|
1265
1265
|
|
1266
|
+
@media (max-width: 899px) {
|
1267
|
+
.MuiPopover-root {
|
1268
|
+
z-index: 1302 !important;
|
1269
|
+
}
|
1270
|
+
canvas {
|
1271
|
+
max-width: 100% !important;
|
1272
|
+
}
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
.settingsHeader {
|
1276
|
+
font-size: 14px !important;
|
1277
|
+
font-weight: 500 !important;
|
1278
|
+
}
|
1266
1279
|
.hideScroll {
|
1267
1280
|
overflow-anchor: none;
|
1268
1281
|
}
|
@@ -1278,20 +1291,6 @@ blockquote {
|
|
1278
1291
|
.hideScroll::-webkit-scrollbar-thumb:hover {
|
1279
1292
|
background: none !important;
|
1280
1293
|
}
|
1281
|
-
@media (max-width: 899px) {
|
1282
|
-
.MuiPopover-root {
|
1283
|
-
z-index: 1302 !important;
|
1284
|
-
}
|
1285
|
-
|
1286
|
-
canvas {
|
1287
|
-
max-width: 100% !important;
|
1288
|
-
}
|
1289
|
-
}
|
1290
|
-
|
1291
|
-
.settingsHeader {
|
1292
|
-
font-size: 14px !important;
|
1293
|
-
font-weight: 500 !important;
|
1294
|
-
}
|
1295
1294
|
|
1296
1295
|
.custom-scroll::-webkit-scrollbar {
|
1297
1296
|
height: .6rem;
|
@@ -6,7 +6,7 @@ import AIInput from "./AIInput";
|
|
6
6
|
import { ReactEditor, useSlate } from "slate-react";
|
7
7
|
import { Node, Range, Transforms } from "slate";
|
8
8
|
import { MODES } from "./helper";
|
9
|
-
import { getSelectedText, getSlateDom } from "../../utils/helper";
|
9
|
+
import { getSelectedText, getSlateDom, viewSlateSelection } from "../../utils/helper";
|
10
10
|
import { VoiceToText } from "./VoiceToText";
|
11
11
|
import deserialize from "../../helper/deserialize";
|
12
12
|
import useEditorScroll from "../../hooks/useEditorScroll";
|
@@ -286,17 +286,7 @@ function PopoverAIInput({
|
|
286
286
|
};
|
287
287
|
useEffect(() => {
|
288
288
|
if (openAI && getSelectedText(editor).trim()) {
|
289
|
-
|
290
|
-
const selectionBg = "rgba(35, 131, 226, 0.35)";
|
291
|
-
if (customSelection?.length) {
|
292
|
-
customSelection?.forEach(el => el.style.background = selectionBg);
|
293
|
-
|
294
|
-
// if ai is opened, remove the window selection class and open then slate selection, To resolve: focussing on the ai input removes window selection automatically
|
295
|
-
const selection = window.getSelection();
|
296
|
-
if (selection) {
|
297
|
-
selection.removeAllRanges(); // Clears the selection
|
298
|
-
}
|
299
|
-
}
|
289
|
+
viewSlateSelection();
|
300
290
|
}
|
301
291
|
}, [editor.selection, openAI]);
|
302
292
|
return /*#__PURE__*/_jsxs("div", {
|
@@ -162,6 +162,7 @@ const EditorButton = props => {
|
|
162
162
|
display: "inline-flex",
|
163
163
|
color: "rgba(0, 0, 0, 0.54)",
|
164
164
|
marginBottom: "0px !important",
|
165
|
+
...classes.buttonMoreOption,
|
165
166
|
...classes.buttonMoreOption3
|
166
167
|
},
|
167
168
|
...btnProps,
|
@@ -264,7 +265,7 @@ const EditorButton = props => {
|
|
264
265
|
...btnSp,
|
265
266
|
borderStyle: borderStyle || "solid",
|
266
267
|
color: `${textColor || "#FFFFFF"}`,
|
267
|
-
fontSize: textSize || "
|
268
|
+
fontSize: textSize || "12px",
|
268
269
|
fontFamily: fontFamily || "PoppinsRegular",
|
269
270
|
display: "inline-flex",
|
270
271
|
alignItems: "center",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { Node, Path, Transforms } from "slate";
|
3
|
-
import { ReactEditor,
|
3
|
+
import { ReactEditor, useSlate } from "slate-react";
|
4
4
|
import { Box, useTheme } from "@mui/material";
|
5
5
|
import { DataViewProvider } from "./Providers/DataViewProvider";
|
6
6
|
import useDataViewStyles from "./styles";
|
@@ -15,7 +15,7 @@ const DataView = props => {
|
|
15
15
|
theme: appTheme
|
16
16
|
} = useEditorContext();
|
17
17
|
const theme = useTheme();
|
18
|
-
const editor =
|
18
|
+
const editor = useSlate();
|
19
19
|
const {
|
20
20
|
attributes,
|
21
21
|
children,
|
@@ -113,7 +113,8 @@ const DataView = props => {
|
|
113
113
|
onDuplicate: onDuplicate,
|
114
114
|
readOnly: readOnly,
|
115
115
|
title: title,
|
116
|
-
onTitleChange: onTitleChange
|
116
|
+
onTitleChange: onTitleChange,
|
117
|
+
path: path
|
117
118
|
}), /*#__PURE__*/_jsx(LayoutView, {
|
118
119
|
readOnly: readOnly,
|
119
120
|
children: children
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { TextField } from "@mui/material";
|
3
3
|
import { useDataView } from "../../Providers/DataViewProvider";
|
4
|
+
import { focusDynamicTableInput } from "../../../../utils/helper";
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
5
6
|
const NumberType = props => {
|
6
7
|
const {
|
@@ -16,6 +17,7 @@ const NumberType = props => {
|
|
16
17
|
onChange(rowIndex, {
|
17
18
|
[property]: e?.target?.value
|
18
19
|
});
|
20
|
+
focusDynamicTableInput(e);
|
19
21
|
};
|
20
22
|
return /*#__PURE__*/_jsx(TextField, {
|
21
23
|
type: "number",
|
@@ -24,7 +26,9 @@ const NumberType = props => {
|
|
24
26
|
value: value,
|
25
27
|
size: "small",
|
26
28
|
onChange: handleChange,
|
27
|
-
disabled: readOnly
|
29
|
+
disabled: readOnly,
|
30
|
+
id: `tv-number-input-${rowIndex}-${property}` // * should be unique
|
28
31
|
});
|
29
32
|
};
|
33
|
+
|
30
34
|
export default NumberType;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { TextField } from "@mui/material";
|
3
3
|
import { useDataView } from "../../Providers/DataViewProvider";
|
4
|
+
import { focusDynamicTableInput } from "../../../../utils/helper";
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
5
6
|
const TextType = props => {
|
6
7
|
const {
|
@@ -16,6 +17,7 @@ const TextType = props => {
|
|
16
17
|
onChange(rowIndex, {
|
17
18
|
[property]: e?.target?.value
|
18
19
|
});
|
20
|
+
focusDynamicTableInput(e);
|
19
21
|
};
|
20
22
|
const formatValue = () => {
|
21
23
|
if (typeof value === "string") {
|
@@ -30,7 +32,9 @@ const TextType = props => {
|
|
30
32
|
value: formatValue(value),
|
31
33
|
size: "small",
|
32
34
|
onChange: handleChange,
|
33
|
-
disabled: readOnly
|
35
|
+
disabled: readOnly,
|
36
|
+
id: `tv-text-input-${rowIndex}-${property}` // * should be unique
|
34
37
|
});
|
35
38
|
};
|
39
|
+
|
36
40
|
export default TextType;
|
@@ -5,6 +5,7 @@ import FilterSort from "./FilterSort";
|
|
5
5
|
import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
|
6
6
|
import Icon from "../../../common/Icon";
|
7
7
|
import { useEditorContext } from "../../../hooks/useMouseMove";
|
8
|
+
import { focusDynamicTableInput } from "../../../utils/helper";
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
9
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
11
|
const FilterView = props => {
|
@@ -15,7 +16,8 @@ const FilterView = props => {
|
|
15
16
|
onEnter,
|
16
17
|
readOnly,
|
17
18
|
title,
|
18
|
-
onTitleChange
|
19
|
+
onTitleChange,
|
20
|
+
path
|
19
21
|
} = props;
|
20
22
|
const {
|
21
23
|
sort,
|
@@ -70,6 +72,7 @@ const FilterView = props => {
|
|
70
72
|
};
|
71
73
|
const handleTitleChange = e => {
|
72
74
|
onTitleChange(e?.target?.value);
|
75
|
+
focusDynamicTableInput(e);
|
73
76
|
};
|
74
77
|
const handleEnter = e => {
|
75
78
|
if (e?.key === "Enter") {
|
@@ -96,24 +99,25 @@ const FilterView = props => {
|
|
96
99
|
},
|
97
100
|
value: title,
|
98
101
|
onChange: handleTitleChange,
|
99
|
-
onKeyUp: handleEnter
|
102
|
+
onKeyUp: handleEnter,
|
103
|
+
id: `tv-title-input-${path.join("|")}`
|
100
104
|
}) : title || "Untitled"
|
101
105
|
}), /*#__PURE__*/_jsxs(Box, {
|
102
106
|
className: "tv-fi-wrpr",
|
103
107
|
sx: {
|
104
|
-
alignItems:
|
108
|
+
alignItems: "center"
|
105
109
|
},
|
106
110
|
children: [/*#__PURE__*/_jsxs(Box, {
|
107
111
|
className: `tv-sb mr ${toggle ? "open" : ""}`,
|
108
112
|
sx: {
|
109
|
-
minHeight:
|
113
|
+
minHeight: "32px"
|
110
114
|
},
|
111
115
|
children: [/*#__PURE__*/_jsx(IconButton, {
|
112
116
|
type: "button",
|
113
117
|
sx: {
|
114
|
-
|
115
|
-
width:
|
116
|
-
height:
|
118
|
+
"& svg": {
|
119
|
+
width: "14px",
|
120
|
+
height: "14px"
|
117
121
|
}
|
118
122
|
},
|
119
123
|
"aria-label": "search",
|
@@ -137,12 +141,12 @@ const FilterView = props => {
|
|
137
141
|
className: ` ${sort?.length > 0 ? "active" : ""}`,
|
138
142
|
onClick: handleSortClick,
|
139
143
|
sx: {
|
140
|
-
|
144
|
+
"& svg": {
|
141
145
|
strokeWidth: 1.2
|
142
146
|
}
|
143
147
|
},
|
144
148
|
children: /*#__PURE__*/_jsx(Icon, {
|
145
|
-
icon:
|
149
|
+
icon: "sortBy"
|
146
150
|
})
|
147
151
|
}), /*#__PURE__*/_jsx(FilterSort, {
|
148
152
|
open: open,
|
@@ -152,7 +156,7 @@ const FilterView = props => {
|
|
152
156
|
}), !readOnly ? /*#__PURE__*/_jsx(IconButton, {
|
153
157
|
className: "mr",
|
154
158
|
sx: {
|
155
|
-
|
159
|
+
"& svg": {
|
156
160
|
fill: theme?.palette?.editor?.tv_stroke
|
157
161
|
}
|
158
162
|
},
|
@@ -162,7 +166,7 @@ const FilterView = props => {
|
|
162
166
|
className: "mr",
|
163
167
|
onClick: handleDeleteRow,
|
164
168
|
children: /*#__PURE__*/_jsx(Icon, {
|
165
|
-
icon:
|
169
|
+
icon: "trashIcon"
|
166
170
|
})
|
167
171
|
}) : null, !readOnly ? /*#__PURE__*/_jsxs(Menu, {
|
168
172
|
sx: classes.basicMenu,
|
@@ -185,24 +189,24 @@ const FilterView = props => {
|
|
185
189
|
onClick: onMenuClick("Duplicate"),
|
186
190
|
children: [" ", /*#__PURE__*/_jsx(Box, {
|
187
191
|
sx: {
|
188
|
-
marginRight:
|
189
|
-
display:
|
190
|
-
alignItems:
|
192
|
+
marginRight: "5px",
|
193
|
+
display: " flex",
|
194
|
+
alignItems: "center"
|
191
195
|
},
|
192
196
|
children: /*#__PURE__*/_jsx(Icon, {
|
193
|
-
icon:
|
197
|
+
icon: "duplicateIcon"
|
194
198
|
})
|
195
199
|
}), "Duplicate"]
|
196
200
|
}), /*#__PURE__*/_jsxs(MenuItem, {
|
197
201
|
onClick: onMenuClick("Delete"),
|
198
202
|
children: [" ", /*#__PURE__*/_jsx(Box, {
|
199
203
|
sx: {
|
200
|
-
marginRight:
|
201
|
-
display:
|
202
|
-
alignItems:
|
204
|
+
marginRight: "5px",
|
205
|
+
display: " flex",
|
206
|
+
alignItems: "center"
|
203
207
|
},
|
204
208
|
children: /*#__PURE__*/_jsx(Icon, {
|
205
|
-
icon:
|
209
|
+
icon: "trashIcon"
|
206
210
|
})
|
207
211
|
}), "Delete"]
|
208
212
|
})]
|
@@ -57,9 +57,9 @@ const Divider = props => {
|
|
57
57
|
// : {};
|
58
58
|
return /*#__PURE__*/_jsx("div", {
|
59
59
|
contentEditable: false,
|
60
|
-
className: "
|
60
|
+
className: "element-toolbar dividerIcon",
|
61
61
|
style: {
|
62
|
-
top: "
|
62
|
+
top: "3px",
|
63
63
|
left: 0
|
64
64
|
},
|
65
65
|
children: /*#__PURE__*/_jsx(Tooltip, {
|
@@ -76,7 +76,7 @@ const Divider = props => {
|
|
76
76
|
// theme?.palette?.type === "dark"
|
77
77
|
// ? "1px solid #E4E8EB33"
|
78
78
|
// : "none",
|
79
|
-
boxShadow: "0px 0px 4px 0px #00000040",
|
79
|
+
boxShadow: "0px 0px 4px 0px #00000040 !important",
|
80
80
|
borderRadius: "50%",
|
81
81
|
"& svg": {
|
82
82
|
width: '16px',
|
@@ -185,6 +185,9 @@ const SearchAndDocList = ({
|
|
185
185
|
gap: 1,
|
186
186
|
children: [/*#__PURE__*/_jsx(Grid, {
|
187
187
|
item: true,
|
188
|
+
sx: {
|
189
|
+
maxWidth: 'calc(100% - 45px)'
|
190
|
+
},
|
188
191
|
children: /*#__PURE__*/_jsxs(Grid, {
|
189
192
|
container: true,
|
190
193
|
alignItems: "center",
|
@@ -207,6 +210,9 @@ const SearchAndDocList = ({
|
|
207
210
|
})
|
208
211
|
}), /*#__PURE__*/_jsx(Grid, {
|
209
212
|
item: true,
|
213
|
+
sx: {
|
214
|
+
maxWidth: '100%'
|
215
|
+
},
|
210
216
|
children: /*#__PURE__*/_jsx(Typography, {
|
211
217
|
sx: {
|
212
218
|
fontSize: "12px",
|
@@ -219,7 +225,8 @@ const SearchAndDocList = ({
|
|
219
225
|
maxWidth: '230px',
|
220
226
|
textAlign: 'left',
|
221
227
|
'@media only screen and (min-width: 350px) and (max-width: 899px)': {
|
222
|
-
maxWidth: '100%'
|
228
|
+
maxWidth: '100%',
|
229
|
+
width: '100%'
|
223
230
|
}
|
224
231
|
},
|
225
232
|
children: title
|
@@ -35,8 +35,8 @@ const SimpleTextStyle = ({
|
|
35
35
|
height: "24px",
|
36
36
|
overflow: "hidden",
|
37
37
|
fontSize: "14px",
|
38
|
-
display:
|
39
|
-
alignItems:
|
38
|
+
display: "inline-flex",
|
39
|
+
alignItems: "center",
|
40
40
|
"& .bg-pad-sl": {
|
41
41
|
padding: "2px 4px 2px 4px",
|
42
42
|
background: "transparent",
|
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
|
|
2
2
|
import { Editor, Transforms } from "slate";
|
3
3
|
import { ReactEditor, useSelected, useSlateStatic } from "slate-react";
|
4
4
|
import { Box, IconButton, Tooltip, Table as TableComp, TableBody, useTheme, Popper, ClickAwayListener } from "@mui/material";
|
5
|
-
import { TableUtil } from "../../utils/table";
|
5
|
+
import { TableUtil, getTableColumns, getTableRows } from "../../utils/table";
|
6
6
|
import TablePopup from "./TablePopup";
|
7
7
|
import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
|
8
8
|
import TableStyles from "./Styles";
|
@@ -206,7 +206,7 @@ const Table = props => {
|
|
206
206
|
}
|
207
207
|
}, theme);
|
208
208
|
const addRow = () => {
|
209
|
-
const lastRow = element
|
209
|
+
const lastRow = getTableRows(element) - 1;
|
210
210
|
const firstCol = 0;
|
211
211
|
const lastRowPath = [...path, lastRow, firstCol];
|
212
212
|
const position = Editor.start(editor, lastRowPath);
|
@@ -221,7 +221,7 @@ const Table = props => {
|
|
221
221
|
Transforms.deselect(editor);
|
222
222
|
};
|
223
223
|
const addCol = () => {
|
224
|
-
const lastCol = element
|
224
|
+
const lastCol = getTableColumns(element) - 1;
|
225
225
|
const firstRow = 0;
|
226
226
|
const lastColumnPath = [...path, firstRow, lastCol];
|
227
227
|
const position = Editor.start(editor, lastColumnPath);
|
@@ -50,6 +50,7 @@ const TableCell = props => {
|
|
50
50
|
const {
|
51
51
|
readOnly
|
52
52
|
} = customProps;
|
53
|
+
const isMobile = window.matchMedia("(max-width: 899px)")?.matches || false;
|
53
54
|
const {
|
54
55
|
bgColor,
|
55
56
|
borderColor,
|
@@ -247,20 +248,24 @@ const TableCell = props => {
|
|
247
248
|
isDragging: false
|
248
249
|
});
|
249
250
|
};
|
250
|
-
const
|
251
|
-
|
252
|
-
|
251
|
+
const eventProps = isMobile ? {
|
252
|
+
// mobile events for selection
|
253
|
+
onTouchStart: onMouseDownInCell,
|
254
|
+
onTouchMove: handleTouchMove,
|
255
|
+
onTouchEnd: handleTouchEnd
|
253
256
|
} : {
|
254
|
-
...commonTdProps,
|
255
257
|
onMouseEnter: () => onMouseEnter(path),
|
256
258
|
onMouseLeave,
|
257
259
|
onMouseDown: onMouseDownInCell,
|
258
260
|
onMouseUp,
|
259
|
-
onClick
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
261
|
+
onClick
|
262
|
+
};
|
263
|
+
const tbProps = tableResizing || resizing || over || readOnly ? {
|
264
|
+
...commonTdProps,
|
265
|
+
contentEditable: false
|
266
|
+
} : {
|
267
|
+
...commonTdProps,
|
268
|
+
...eventProps
|
264
269
|
};
|
265
270
|
const dndProps = {
|
266
271
|
id: cellId,
|
@@ -1,12 +1,24 @@
|
|
1
1
|
import React from "react";
|
2
|
+
import { Text } from "slate";
|
2
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
4
|
+
const isEmptyTextNode = node => {
|
5
|
+
if (Text.isText(node)) {
|
6
|
+
return !node.text.trim();
|
7
|
+
}
|
8
|
+
return false;
|
9
|
+
};
|
3
10
|
const Title = props => {
|
4
11
|
const {
|
12
|
+
element,
|
5
13
|
attributes,
|
6
|
-
children
|
14
|
+
children,
|
15
|
+
customProps
|
7
16
|
} = props;
|
17
|
+
const isEmpty = !customProps?.readOnly && isEmptyTextNode(element?.children[0]) ? "empty" : "";
|
8
18
|
return /*#__PURE__*/_jsx("div", {
|
9
19
|
...attributes,
|
20
|
+
placeholder: "Title",
|
21
|
+
className: `content-editable ${isEmpty}`,
|
10
22
|
style: {
|
11
23
|
fontWeight: "bold",
|
12
24
|
fontSize: "20px"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
const VariableStyles =
|
1
|
+
const VariableStyles = theme => ({
|
2
2
|
variablesItem: {
|
3
3
|
color: "#2563EB",
|
4
4
|
background: "#EEEEEE"
|
@@ -37,8 +37,27 @@ const VariableStyles = () => ({
|
|
37
37
|
"& .MuiMenuItem-root": {
|
38
38
|
color: "#64748B"
|
39
39
|
},
|
40
|
+
"& .MuiPaper-root": {
|
41
|
+
borderRadius: '8px',
|
42
|
+
backgroundColor: `${theme?.palette?.editor?.miniToolBarBackground} !important`,
|
43
|
+
marginTop: '5px'
|
44
|
+
},
|
45
|
+
"& .MuiList-root": {
|
46
|
+
padding: '0px'
|
47
|
+
},
|
48
|
+
"& .MuiButtonBase-root": {
|
49
|
+
margin: '6px',
|
50
|
+
borderRadius: '8px',
|
51
|
+
padding: '6px 14px',
|
52
|
+
fontSize: '14px',
|
53
|
+
fontWeight: '400',
|
54
|
+
color: theme?.palette?.editor?.deletePopUpButtonTextColor,
|
55
|
+
"&:hover": {
|
56
|
+
background: `${theme?.palette?.editor?.menuOptionHoverBackground} !important`
|
57
|
+
}
|
58
|
+
},
|
40
59
|
"& .Mui-selected": {
|
41
|
-
backgroundColor:
|
60
|
+
backgroundColor: 'unset !important'
|
42
61
|
}
|
43
62
|
}
|
44
63
|
});
|
@@ -3,11 +3,15 @@ import { useSlateStatic } from "slate-react";
|
|
3
3
|
import { MenuItem, Select } from "@mui/material";
|
4
4
|
import { insertVariables } from "../../utils/variables";
|
5
5
|
import VariableStyles from "./Style";
|
6
|
-
import
|
6
|
+
import KeyboardArrowDownRoundedIcon from '@mui/icons-material/KeyboardArrowDownRounded';
|
7
|
+
import { useEditorContext } from "../../hooks/useMouseMove";
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
9
10
|
const VariableButton = props => {
|
10
|
-
const
|
11
|
+
const {
|
12
|
+
theme
|
13
|
+
} = useEditorContext();
|
14
|
+
const classes = VariableStyles(theme);
|
11
15
|
const editor = useSlateStatic();
|
12
16
|
const {
|
13
17
|
options
|
@@ -24,13 +28,14 @@ const VariableButton = props => {
|
|
24
28
|
value: "",
|
25
29
|
sx: classes.variableBtn,
|
26
30
|
onChange: updateVariable,
|
27
|
-
IconComponent: () => /*#__PURE__*/_jsx(
|
31
|
+
IconComponent: () => /*#__PURE__*/_jsx(KeyboardArrowDownRoundedIcon, {}),
|
28
32
|
MenuProps: {
|
29
33
|
sx: classes.variableMenuItem,
|
30
34
|
PaperProps: {
|
31
35
|
style: {
|
32
36
|
maxHeight: 300,
|
33
|
-
overflowY: "auto"
|
37
|
+
overflowY: "auto",
|
38
|
+
transformOrigin: 'top left'
|
34
39
|
},
|
35
40
|
sx: {
|
36
41
|
"&::-webkit-scrollbar-track": {
|
@@ -40,6 +45,14 @@ const VariableButton = props => {
|
|
40
45
|
borderRadius: "16px"
|
41
46
|
}
|
42
47
|
}
|
48
|
+
},
|
49
|
+
anchorOrigin: {
|
50
|
+
vertical: 'bottom',
|
51
|
+
horizontal: 'right'
|
52
|
+
},
|
53
|
+
transformOrigin: {
|
54
|
+
vertical: 'top',
|
55
|
+
horizontal: 'right'
|
43
56
|
}
|
44
57
|
},
|
45
58
|
children: [/*#__PURE__*/_jsx(MenuItem, {
|
@@ -11,6 +11,7 @@ import withCommon from "./hooks/withCommon";
|
|
11
11
|
import { serializeToText } from "./utils/serializeToText";
|
12
12
|
import "./Editor.css";
|
13
13
|
import { EditorProvider } from "./hooks/useMouseMove";
|
14
|
+
import { ensureWrappedVariables } from "./helper/ensureWrappedVariables";
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
15
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
16
17
|
const MiniEditor = props => {
|
@@ -36,7 +37,8 @@ const MiniEditor = props => {
|
|
36
37
|
needLayout: false
|
37
38
|
}));
|
38
39
|
const [isInteracted, setIsInteracted] = useState(false);
|
39
|
-
const
|
40
|
+
const updatedContent = ensureWrappedVariables(content);
|
41
|
+
const [value, setValue] = useState(ensureWrappedVariables(updatedContent));
|
40
42
|
const [deboundedValue] = useDebounce(value, 500);
|
41
43
|
const isReadOnly = readOnly === "readonly";
|
42
44
|
const customProps = {
|
@@ -149,7 +151,7 @@ const MiniEditor = props => {
|
|
149
151
|
theme: theme,
|
150
152
|
children: /*#__PURE__*/_jsxs(Slate, {
|
151
153
|
editor: editor,
|
152
|
-
initialValue:
|
154
|
+
initialValue: updatedContent,
|
153
155
|
onChange: onChange,
|
154
156
|
children: [/*#__PURE__*/_jsx(BasicToolbar, {
|
155
157
|
...props,
|