@flozy/editor 4.8.1 → 4.8.3
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.
|
@@ -320,9 +320,10 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
320
320
|
const renderElement = useCallback(props => {
|
|
321
321
|
return /*#__PURE__*/_jsx(Element, {
|
|
322
322
|
...props,
|
|
323
|
-
customProps: customProps
|
|
323
|
+
customProps: customProps,
|
|
324
|
+
theme: theme
|
|
324
325
|
});
|
|
325
|
-
}, []);
|
|
326
|
+
}, [theme]);
|
|
326
327
|
const renderLeaf = useCallback(props => {
|
|
327
328
|
return /*#__PURE__*/_jsx(Leaf, {
|
|
328
329
|
...props,
|
|
@@ -45,10 +45,9 @@ const useFreeGridStyles = ({
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"&.type_text": {
|
|
48
|
-
minHeight: "fit-content !important"
|
|
48
|
+
// minHeight: "fit-content !important",
|
|
49
49
|
// wordBreak: "break-all",
|
|
50
50
|
},
|
|
51
|
-
|
|
52
51
|
"&.enable-1, &.enable-2": {
|
|
53
52
|
"&.type_text": {
|
|
54
53
|
// for dark theme
|
|
@@ -7,7 +7,7 @@ import TuneIcon from "@mui/icons-material/Tune";
|
|
|
7
7
|
import SectionPopup from "../../Elements/Grid/SectionPopup";
|
|
8
8
|
import { getBreakPointsValue, getTRBLBreakPoints, groupByBreakpoint } from "../../helper/theme";
|
|
9
9
|
import DragHandle from "../DnD/DragHandleButton";
|
|
10
|
-
import {
|
|
10
|
+
import { useEditorSelection } from "../../hooks/useMouseMove";
|
|
11
11
|
import SectionStyle from "./styles";
|
|
12
12
|
import useWindowResize from "../../hooks/useWindowResize";
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -16,9 +16,7 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
16
16
|
const list_types = ["orderedList", "unorderedList"];
|
|
17
17
|
const Section = props => {
|
|
18
18
|
const themeReact = useTheme();
|
|
19
|
-
const
|
|
20
|
-
theme
|
|
21
|
-
} = useEditorContext();
|
|
19
|
+
const theme = props?.theme;
|
|
22
20
|
const classes = SectionStyle(themeReact, theme);
|
|
23
21
|
const {
|
|
24
22
|
children,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Editor, Node, Path, Transforms } from "slate";
|
|
1
|
+
import { Editor, Node, Path, Point, Transforms } from "slate";
|
|
2
|
+
import { getNextNode } from "../utils/helper";
|
|
2
3
|
const isNodeTextEmpty = node => {
|
|
3
4
|
const nodeText = Node.string(node);
|
|
4
5
|
return nodeText.trim() === "";
|
|
5
6
|
};
|
|
6
7
|
const withCustomDeleteBackward = editor => {
|
|
7
8
|
const {
|
|
8
|
-
deleteBackward
|
|
9
|
+
deleteBackward,
|
|
10
|
+
deleteForward
|
|
9
11
|
} = editor;
|
|
10
12
|
|
|
11
13
|
// Override deleteBackward
|
|
@@ -54,6 +56,42 @@ const withCustomDeleteBackward = editor => {
|
|
|
54
56
|
// Fall back to default delete behavior if conditions are not met
|
|
55
57
|
deleteBackward(...args);
|
|
56
58
|
};
|
|
59
|
+
editor.deleteForward = (...args) => {
|
|
60
|
+
const {
|
|
61
|
+
selection
|
|
62
|
+
} = editor;
|
|
63
|
+
if (selection) {
|
|
64
|
+
const {
|
|
65
|
+
nextPath,
|
|
66
|
+
nextNode
|
|
67
|
+
} = getNextNode(editor) || {};
|
|
68
|
+
|
|
69
|
+
// Restrict deletion of page-settings
|
|
70
|
+
if (nextNode?.type === "page-settings") {
|
|
71
|
+
const isEndLine = Point.equals(selection.focus, Editor.end(editor, selection.focus.path));
|
|
72
|
+
if (isEndLine) {
|
|
73
|
+
const lastEditorChild = editor?.children?.length;
|
|
74
|
+
const isLastNode = lastEditorChild - 1 === nextPath[0];
|
|
75
|
+
if (isLastNode) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// move the page-settings node to last
|
|
80
|
+
Transforms.moveNodes(editor, {
|
|
81
|
+
at: nextPath,
|
|
82
|
+
to: [lastEditorChild]
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Node present after page-settings, will now merged to current node
|
|
86
|
+
Transforms.mergeNodes(editor, {
|
|
87
|
+
at: nextPath
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
deleteForward(...args);
|
|
94
|
+
};
|
|
57
95
|
return editor;
|
|
58
96
|
};
|
|
59
97
|
export default withCustomDeleteBackward;
|
|
@@ -500,6 +500,19 @@ export const isFreeGrid = (nodes, types = ["freegrid", "freegridItem", "freegrid
|
|
|
500
500
|
return false;
|
|
501
501
|
}
|
|
502
502
|
};
|
|
503
|
+
export const getNextNode = editor => {
|
|
504
|
+
try {
|
|
505
|
+
const parentPath = [editor?.selection?.focus?.path[0]];
|
|
506
|
+
const nextPath = Path.next(parentPath);
|
|
507
|
+
const nextNode = Node.get(editor, nextPath);
|
|
508
|
+
return {
|
|
509
|
+
nextPath,
|
|
510
|
+
nextNode
|
|
511
|
+
};
|
|
512
|
+
} catch (err) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
};
|
|
503
516
|
export const getPreviousNode = editor => {
|
|
504
517
|
try {
|
|
505
518
|
const parentPath = Path.parent(editor?.selection?.anchor?.path);
|
|
@@ -526,7 +539,7 @@ export const isPageSettings = (event, editor) => {
|
|
|
526
539
|
const {
|
|
527
540
|
previousNode,
|
|
528
541
|
previousPath
|
|
529
|
-
} = getPreviousNode(editor);
|
|
542
|
+
} = getPreviousNode(editor) || {};
|
|
530
543
|
if (previousNode?.type === "page-settings") {
|
|
531
544
|
event.preventDefault(); // stops deleting backward
|
|
532
545
|
|