@flozy/editor 5.1.8 → 5.1.9
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/Elements/Divider/Divider.js +1 -1
- package/dist/Editor/Elements/Embed/Image.js +11 -7
- package/dist/Editor/Elements/Grid/GridItem.js +3 -0
- package/dist/Editor/Elements/Grid/Styles.js +6 -0
- package/dist/Editor/plugins/withHTML.js +42 -2
- package/dist/Editor/utils/customHooks/useResize.js +7 -4
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { Node, Transforms, Editor } from "slate";
|
|
|
4
4
|
import AspectRatioIcon from "@mui/icons-material/AspectRatio";
|
|
5
5
|
import useResize from "../../utils/customHooks/useResize";
|
|
6
6
|
import EmbedPopup from "./EmbedPopup";
|
|
7
|
-
import { IconButton, Tooltip, Box, useTheme } from "@mui/material";
|
|
7
|
+
import { IconButton, Tooltip, Box, useTheme, Popper } from "@mui/material";
|
|
8
8
|
import { GridSettingsIcon, LinkIcon } from "../../common/iconslist";
|
|
9
9
|
import { useEditorContext } from "../../hooks/useMouseMove";
|
|
10
10
|
import { getTRBLBreakPoints, getBreakPointsValue, groupByBreakpoint } from "../../helper/theme";
|
|
@@ -19,15 +19,15 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
19
19
|
const ToolBar = ({
|
|
20
20
|
isEmpty,
|
|
21
21
|
onSettings,
|
|
22
|
-
setOpenNav
|
|
22
|
+
setOpenNav,
|
|
23
|
+
topM
|
|
23
24
|
}) => {
|
|
24
25
|
return !isEmpty ? /*#__PURE__*/_jsxs("div", {
|
|
25
26
|
className: "element-toolbar visible-on-hover",
|
|
26
27
|
contentEditable: false,
|
|
27
28
|
style: {
|
|
28
|
-
top: "
|
|
29
|
-
|
|
30
|
-
left: "auto",
|
|
29
|
+
top: "-5px",
|
|
30
|
+
left: topM ? "35px" : "0px",
|
|
31
31
|
margin: "0px"
|
|
32
32
|
},
|
|
33
33
|
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
@@ -155,7 +155,10 @@ const Image = props => {
|
|
|
155
155
|
}, {
|
|
156
156
|
at: path
|
|
157
157
|
});
|
|
158
|
-
}
|
|
158
|
+
},
|
|
159
|
+
MW: 32,
|
|
160
|
+
MH: 32,
|
|
161
|
+
MP: 2
|
|
159
162
|
});
|
|
160
163
|
const arr = Array.from(Node.elements(editor));
|
|
161
164
|
const ele = arr.find(([elem]) => element === elem);
|
|
@@ -277,7 +280,8 @@ const Image = props => {
|
|
|
277
280
|
children: [!readOnly && /*#__PURE__*/_jsx(ToolBar, {
|
|
278
281
|
isEmpty: isEmpty,
|
|
279
282
|
onSettings: onSettings,
|
|
280
|
-
setOpenNav: setOpenNav
|
|
283
|
+
setOpenNav: setOpenNav,
|
|
284
|
+
topM: size.width < 100
|
|
281
285
|
}), /*#__PURE__*/_jsx(ImageContent, {
|
|
282
286
|
...element,
|
|
283
287
|
readOnly: readOnly,
|
|
@@ -52,6 +52,7 @@ const GridItemToolbar = props => {
|
|
|
52
52
|
sx: classes.popTools,
|
|
53
53
|
className: "gi-tool-pp",
|
|
54
54
|
disablePortal: true,
|
|
55
|
+
contentEditable: false,
|
|
55
56
|
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
56
57
|
title: "Column Settings",
|
|
57
58
|
arrow: true,
|
|
@@ -354,12 +355,14 @@ const GridItem = props => {
|
|
|
354
355
|
onMouseDown: onMouseDown,
|
|
355
356
|
height: "auto"
|
|
356
357
|
}) : null, /*#__PURE__*/_jsxs(Dialog, {
|
|
358
|
+
sx: classes.dialog,
|
|
357
359
|
open: Boolean(alert),
|
|
358
360
|
onClose: handleClose,
|
|
359
361
|
children: [/*#__PURE__*/_jsx(DialogContent, {
|
|
360
362
|
children: alert
|
|
361
363
|
}), /*#__PURE__*/_jsx(DialogActions, {
|
|
362
364
|
children: /*#__PURE__*/_jsx(Button, {
|
|
365
|
+
variant: "contained",
|
|
363
366
|
onClick: handleClose,
|
|
364
367
|
children: "Close"
|
|
365
368
|
})
|
|
@@ -106,6 +106,12 @@ const GridStyles = (theme, appTheme) => ({
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
+
},
|
|
110
|
+
dialog: {
|
|
111
|
+
"& .MuiPaper-root": {
|
|
112
|
+
background: appTheme?.palette?.editor?.background,
|
|
113
|
+
color: appTheme?.palette?.editor?.textColor
|
|
114
|
+
}
|
|
109
115
|
}
|
|
110
116
|
});
|
|
111
117
|
export default GridStyles;
|
|
@@ -2,6 +2,7 @@ import { Transforms, Editor, Element, Node, Path } from "slate";
|
|
|
2
2
|
import deserialize from "../helper/deserialize";
|
|
3
3
|
import { decodeAndParseBase64 } from "../utils/helper";
|
|
4
4
|
const avoidDefaultInsert = ["table", "grid"];
|
|
5
|
+
const LIST_TAGS = ["ol", "ul", "img", "table"];
|
|
5
6
|
const loopChildren = (children = [], defaultInsert) => {
|
|
6
7
|
if (!children?.length) {
|
|
7
8
|
return defaultInsert;
|
|
@@ -120,12 +121,21 @@ const withHtml = editor => {
|
|
|
120
121
|
const slateHTML = data?.getData("application/x-slate-fragment");
|
|
121
122
|
const html = data?.getData("text/html");
|
|
122
123
|
const currentEl = getCurrentElement(editor);
|
|
123
|
-
|
|
124
|
+
const eltype = currentEl?.type;
|
|
125
|
+
const isTitlePath = editor?.selection?.anchor?.path[0] === 0;
|
|
124
126
|
if (slateHTML && !formatFragment[eltype]) {
|
|
125
127
|
const [tableCellNode] = Editor.nodes(editor, {
|
|
126
128
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
|
|
127
129
|
});
|
|
128
130
|
const decoded = decodeAndParseBase64(slateHTML);
|
|
131
|
+
if (decoded && decoded[0] && decoded[0]?.type !== "paragraph" && isTitlePath) {
|
|
132
|
+
decoded.unshift({
|
|
133
|
+
type: "title",
|
|
134
|
+
children: [{
|
|
135
|
+
text: ""
|
|
136
|
+
}]
|
|
137
|
+
});
|
|
138
|
+
}
|
|
129
139
|
if (tableCellNode) {
|
|
130
140
|
const tableCellChild = getTableCellChild(decoded);
|
|
131
141
|
if (tableCellChild?.length) {
|
|
@@ -170,10 +180,40 @@ const withHtml = editor => {
|
|
|
170
180
|
Transforms.insertText(editor, text);
|
|
171
181
|
}
|
|
172
182
|
} else {
|
|
173
|
-
handleInsert(editor, () =>
|
|
183
|
+
handleInsert(editor, () => {
|
|
184
|
+
if (isTitlePath) {
|
|
185
|
+
Transforms.insertNodes(editor, [{
|
|
186
|
+
type: "title",
|
|
187
|
+
children: [{
|
|
188
|
+
text: ""
|
|
189
|
+
}]
|
|
190
|
+
}], {
|
|
191
|
+
at: [0]
|
|
192
|
+
});
|
|
193
|
+
insertData(data);
|
|
194
|
+
}
|
|
195
|
+
}, decoded);
|
|
174
196
|
}
|
|
175
197
|
} else if (html) {
|
|
176
198
|
const parsed = new DOMParser().parseFromString(html, "text/html");
|
|
199
|
+
const rootElement = parsed.body || parsed.documentElement;
|
|
200
|
+
const isList = LIST_TAGS.includes(rootElement.firstChild.tagName.toLowerCase());
|
|
201
|
+
|
|
202
|
+
// if selection is in title add the empty paragraph
|
|
203
|
+
if (isTitlePath && isList) {
|
|
204
|
+
// Check if the first child exists and is not a paragraph
|
|
205
|
+
if (!rootElement.firstChild || rootElement.firstChild.tagName.toLowerCase() !== "p") {
|
|
206
|
+
// Create a new empty paragraph element
|
|
207
|
+
const emptyParagraph = parsed.createElement("p");
|
|
208
|
+
|
|
209
|
+
// Insert the empty paragraph at the beginning
|
|
210
|
+
if (rootElement.firstChild) {
|
|
211
|
+
rootElement.insertBefore(emptyParagraph, rootElement.firstChild);
|
|
212
|
+
} else {
|
|
213
|
+
rootElement.appendChild(emptyParagraph);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
177
217
|
const isGoogleSheet = parsed.body.querySelector("google-sheets-html-origin");
|
|
178
218
|
if (isGoogleSheet) {
|
|
179
219
|
if (editor.isChatEditor) {
|
|
@@ -4,7 +4,10 @@ const useResize = ({
|
|
|
4
4
|
parentDOM,
|
|
5
5
|
size: allSize,
|
|
6
6
|
isGrid,
|
|
7
|
-
onChange
|
|
7
|
+
onChange,
|
|
8
|
+
MH,
|
|
9
|
+
MW,
|
|
10
|
+
MP
|
|
8
11
|
}) => {
|
|
9
12
|
const device = getDevice(window.innerWidth);
|
|
10
13
|
const defaultSize = getBreakPointsValue(allSize);
|
|
@@ -52,9 +55,9 @@ const useResize = ({
|
|
|
52
55
|
const cWP = calcWidth / width * 100;
|
|
53
56
|
const calcHeight = (parseInt(currentSize.height) || height) + e.movementY;
|
|
54
57
|
const calc = {
|
|
55
|
-
width: Math.max(calcWidth, 140),
|
|
56
|
-
height: Math.max(calcHeight, 50),
|
|
57
|
-
widthInPercent: cWP > 100 ? 100 : Math.max(cWP, 15)
|
|
58
|
+
width: Math.max(calcWidth, MW || 140),
|
|
59
|
+
height: Math.max(calcHeight, MH || 50),
|
|
60
|
+
widthInPercent: cWP > 100 ? 100 : Math.max(cWP, MP || 15)
|
|
58
61
|
};
|
|
59
62
|
latest = calc;
|
|
60
63
|
return calc;
|