@flozy/editor 3.8.8 → 3.8.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/ChatEditor.js +31 -57
- package/dist/Editor/CommonEditor.js +69 -8
- package/dist/Editor/DialogWrapper.js +4 -3
- package/dist/Editor/Editor.css +5 -12
- package/dist/Editor/Elements/AI/PopoverAIInput.js +47 -36
- package/dist/Editor/Elements/Accordion/Accordion.js +1 -1
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +6 -20
- package/dist/Editor/Elements/AppHeader/AppHeader.js +36 -23
- package/dist/Editor/Elements/Button/EditorButton.js +23 -16
- package/dist/Editor/Elements/Embed/Image.js +15 -14
- package/dist/Editor/Elements/Embed/Video.js +12 -8
- package/dist/Editor/Elements/Emoji/EmojiButton.js +11 -7
- package/dist/Editor/Elements/Emoji/EmojiPicker.js +2 -4
- package/dist/Editor/Elements/Form/Form.js +1 -1
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +391 -0
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +193 -0
- package/dist/Editor/Elements/FreeGrid/FreeGridButton.js +23 -0
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +184 -0
- package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +36 -0
- package/dist/Editor/Elements/FreeGrid/Options/More.js +24 -0
- package/dist/Editor/Elements/FreeGrid/Options/SectionSettings.js +47 -0
- package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +11 -0
- package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +75 -0
- package/dist/Editor/Elements/FreeGrid/styles.js +159 -0
- package/dist/Editor/Elements/Grid/Grid.js +12 -8
- package/dist/Editor/Elements/Grid/GridItem.js +31 -21
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +1 -5
- package/dist/Editor/Elements/SimpleText/index.js +9 -8
- package/dist/Editor/Elements/SimpleText/style.js +37 -0
- package/dist/Editor/ErrorBoundary.js +30 -0
- package/dist/Editor/Styles/EditorStyles.js +23 -0
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -25
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +1 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +8 -0
- package/dist/Editor/Toolbar/Toolbar.js +7 -0
- package/dist/Editor/Toolbar/toolbarGroups.js +5 -0
- package/dist/Editor/common/Icon.js +9 -2
- package/dist/Editor/common/MentionsPopup/MentionsListCard.js +1 -6
- package/dist/Editor/common/MentionsPopup/index.js +12 -8
- package/dist/Editor/common/RnD/ContextMenu/CMenus.js +105 -0
- package/dist/Editor/common/RnD/ContextMenu/index.js +38 -0
- package/dist/Editor/common/RnD/ContextMenu/styles.js +21 -0
- package/dist/Editor/common/RnD/DragInfo/index.js +31 -0
- package/dist/Editor/common/RnD/DragInfo/styles.js +15 -0
- package/dist/Editor/common/RnD/DragOver/index.js +46 -0
- package/dist/Editor/common/RnD/DragOver/styles.js +23 -0
- package/dist/Editor/common/RnD/ElementOptions/Actions.js +82 -0
- package/dist/Editor/common/RnD/ElementOptions/Icons/LinkIcon.js +26 -0
- package/dist/Editor/common/RnD/ElementOptions/index.js +93 -0
- package/dist/Editor/common/RnD/ElementOptions/styles.js +41 -0
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Link.js +153 -0
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +58 -0
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/index.js +7 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +46 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +46 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +46 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +30 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +46 -0
- package/dist/Editor/common/RnD/ElementSettings/Settings/index.js +13 -0
- package/dist/Editor/common/RnD/ElementSettings/index.js +17 -0
- package/dist/Editor/common/RnD/ElementSettings/settingsConstants.js +14 -0
- package/dist/Editor/common/RnD/ElementSettings/styles.js +76 -0
- package/dist/Editor/common/RnD/GuideLines/BoundaryLine.js +52 -0
- package/dist/Editor/common/RnD/GuideLines/index.js +33 -0
- package/dist/Editor/common/RnD/GuideLines/styles.js +60 -0
- package/dist/Editor/common/RnD/OptionsPopup/index.js +50 -0
- package/dist/Editor/common/RnD/OptionsPopup/style.js +36 -0
- package/dist/Editor/common/RnD/RnDCopy.js +23 -0
- package/dist/Editor/common/RnD/ShadowElement.js +34 -0
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +40 -0
- package/dist/Editor/common/RnD/SwitchViewport/styles.js +24 -0
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +63 -0
- package/dist/Editor/common/RnD/TransformHandles/CornerHandle.js +19 -0
- package/dist/Editor/common/RnD/TransformHandles/Icons/BottomRightIcon.js +13 -0
- package/dist/Editor/common/RnD/TransformHandles/SizeHandle.js +18 -0
- package/dist/Editor/common/RnD/TransformHandles/index.js +62 -0
- package/dist/Editor/common/RnD/Utils/alignmentDetection.js +26 -0
- package/dist/Editor/common/RnD/Utils/calculateDropItem.js +98 -0
- package/dist/Editor/common/RnD/Utils/collisionDetection.js +52 -0
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +148 -0
- package/dist/Editor/common/RnD/Utils/index.js +251 -0
- package/dist/Editor/common/RnD/VirtualElement/index.js +76 -0
- package/dist/Editor/common/RnD/VirtualElement/styles.js +27 -0
- package/dist/Editor/common/RnD/VirtualElement/updateAutoProps.js +28 -0
- package/dist/Editor/common/RnD/index.js +503 -0
- package/dist/Editor/common/RnD/styles.js +4 -0
- package/dist/Editor/common/Section/index.js +21 -12
- package/dist/Editor/common/Section/styles.js +6 -1
- package/dist/Editor/common/Shorthands/elements.js +12 -0
- package/dist/Editor/common/StyleBuilder/boxStyle.js +30 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +32 -31
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +16 -18
- package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +3 -14
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +4 -2
- package/dist/Editor/common/StyleBuilder/index.js +2 -2
- package/dist/Editor/common/StyleBuilder/sectionStyle.js +13 -2
- package/dist/Editor/helper/RnD/focusOnNewItem.js +39 -0
- package/dist/Editor/helper/RnD/scrollToNewSection.js +24 -0
- package/dist/Editor/helper/breakpoint.js +5 -0
- package/dist/Editor/helper/index.js +139 -22
- package/dist/Editor/helper/theme.js +50 -2
- package/dist/Editor/hooks/useBreakpoints.js +34 -0
- package/dist/Editor/hooks/useMouseMove.js +36 -8
- package/dist/Editor/hooks/withCommon.js +2 -1
- package/dist/Editor/hooks/withErrorHandling.js +14 -0
- package/dist/Editor/utils/RnD/RnDCtrlCmds.js +168 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +31 -5
- package/dist/Editor/utils/draftToSlate.js +1 -1
- package/dist/Editor/utils/events.js +5 -0
- package/dist/Editor/utils/freegrid.js +49 -0
- package/dist/Editor/utils/helper.js +29 -0
- package/package.json +5 -2
@@ -22,16 +22,36 @@ export const EditorProvider = ({
|
|
22
22
|
theme,
|
23
23
|
children
|
24
24
|
}) => {
|
25
|
-
const [event] = useMouseMove();
|
26
25
|
const [previous, setPrevious] = useState("");
|
27
26
|
const [drop, setDrop] = useState(0);
|
28
27
|
const [selectedPath, setSelectedPath] = useState(null);
|
28
|
+
const [selectedElement, setSelectedElement] = useState({});
|
29
|
+
const [dragging, setDragging] = useState({});
|
30
|
+
const [event] = useMouseMove(dragging);
|
29
31
|
const path = event?.target?.getAttribute("data-path");
|
30
32
|
const [popupType, setPopupType] = useState(""); // opened popup name in the editor will be stored
|
31
33
|
const [openAI, setOpenAI] = useState("");
|
34
|
+
const [contextMenu, setContextMenu] = useState({
|
35
|
+
path: null
|
36
|
+
});
|
37
|
+
useEffect(() => {
|
38
|
+
window.updateSelectedItem = d => {
|
39
|
+
setSelectedElement(d);
|
40
|
+
};
|
41
|
+
}, []);
|
32
42
|
const onDrop = () => {
|
33
43
|
setDrop(drop + 1);
|
34
44
|
};
|
45
|
+
const isSelectedElement = path => {
|
46
|
+
const cu_path = path.split("|");
|
47
|
+
const se_path = selectedElement?.path?.split("|");
|
48
|
+
const isParentSelected = se_path?.slice(0, cu_path.length).join("|") === path;
|
49
|
+
// check if child or parent is selected
|
50
|
+
if (selectedElement?.path === path || isParentSelected) {
|
51
|
+
return selectedElement;
|
52
|
+
}
|
53
|
+
return {};
|
54
|
+
};
|
35
55
|
const value = useMemo(() => {
|
36
56
|
if (path) {
|
37
57
|
setPrevious(path);
|
@@ -52,8 +72,15 @@ export const EditorProvider = ({
|
|
52
72
|
theme: theme,
|
53
73
|
selectedPath: selectedPath,
|
54
74
|
setSelectedPath: setSelectedPath,
|
75
|
+
selectedElement: selectedElement,
|
76
|
+
setSelectedElement: setSelectedElement,
|
77
|
+
isSelectedElement: isSelectedElement,
|
78
|
+
setDragging: setDragging,
|
79
|
+
dragging: dragging,
|
55
80
|
popupType,
|
56
81
|
setPopupType,
|
82
|
+
setContextMenu,
|
83
|
+
contextMenu,
|
57
84
|
openAI,
|
58
85
|
setOpenAI
|
59
86
|
},
|
@@ -63,7 +90,7 @@ export const EditorProvider = ({
|
|
63
90
|
export const useEditorContext = () => {
|
64
91
|
return useContext(EditorContext);
|
65
92
|
};
|
66
|
-
const useMouseMove =
|
93
|
+
const useMouseMove = dragging => {
|
67
94
|
const [event, setEvent] = useState({
|
68
95
|
target: null
|
69
96
|
});
|
@@ -74,12 +101,13 @@ const useMouseMove = () => {
|
|
74
101
|
};
|
75
102
|
}, []);
|
76
103
|
const onMouseMove = e => {
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
104
|
+
if (!dragging?.id) {
|
105
|
+
const dpath = e?.target?.closest(".dpath");
|
106
|
+
if (dpath) {
|
107
|
+
setEvent({
|
108
|
+
target: dpath
|
109
|
+
});
|
110
|
+
}
|
83
111
|
}
|
84
112
|
};
|
85
113
|
const debounceMouseMove = debounce(onMouseMove, 100);
|
@@ -7,8 +7,9 @@ import withEquation from "../plugins/withEquation";
|
|
7
7
|
import withMentions from "../plugins/withMentions";
|
8
8
|
import withLayout from "../plugins/withLayout";
|
9
9
|
import withHtml from "../plugins/withHTML";
|
10
|
+
import withErrorHandling from "./withErrorHandling";
|
10
11
|
import withCustomDeleteBackward from "../plugins/withCustomDeleteBackward";
|
11
12
|
const withCommon = (props, rest = {}) => {
|
12
|
-
return rest.needLayout ? withHtml(withEquation(withLayout(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props)))))))))) : withHtml(withEquation(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props)))))))));
|
13
|
+
return rest.needLayout ? withErrorHandling(withHtml(withEquation(withLayout(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props))))))))))) : withErrorHandling(withHtml(withEquation(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props))))))))));
|
13
14
|
};
|
14
15
|
export default withCommon;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
const withErrorHandling = editor => {
|
2
|
+
const {
|
3
|
+
apply
|
4
|
+
} = editor;
|
5
|
+
editor.apply = operation => {
|
6
|
+
try {
|
7
|
+
apply(operation);
|
8
|
+
} catch (error) {
|
9
|
+
console.error("Error applying Slate operation:", error);
|
10
|
+
}
|
11
|
+
};
|
12
|
+
return editor;
|
13
|
+
};
|
14
|
+
export default withErrorHandling;
|
@@ -0,0 +1,168 @@
|
|
1
|
+
import { Editor, Transforms, Node, Path } from "slate";
|
2
|
+
import { isSelectionInNodeType, getCaretPosition, onPasteRnDNode, bringItemToFB } from "../../helper";
|
3
|
+
import focusOnNewItem from "../../helper/RnD/focusOnNewItem";
|
4
|
+
const RND_ITEM_TYPES = ["freegrid", "freegridItem", "freegridBox"];
|
5
|
+
const parsePath = path => path?.split("|").map(m => parseInt(m));
|
6
|
+
const selectAll = (event, {
|
7
|
+
editor
|
8
|
+
}) => {
|
9
|
+
try {
|
10
|
+
const {
|
11
|
+
selected,
|
12
|
+
match
|
13
|
+
} = isSelectionInNodeType(editor, "freegridItem");
|
14
|
+
const sel = getCaretPosition(editor);
|
15
|
+
|
16
|
+
// if not selection prevent the events
|
17
|
+
if (!sel) {
|
18
|
+
event.preventDefault();
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
|
22
|
+
// only prevent default for freegrid item
|
23
|
+
if (selected) {
|
24
|
+
event.preventDefault();
|
25
|
+
const [item, path] = match;
|
26
|
+
switch (item?.childType) {
|
27
|
+
case "text":
|
28
|
+
const range = Editor.range(editor, path);
|
29
|
+
Transforms.select(editor, range);
|
30
|
+
break;
|
31
|
+
default:
|
32
|
+
return null;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
} catch (err) {
|
36
|
+
console.log(err);
|
37
|
+
}
|
38
|
+
};
|
39
|
+
const onCopy = async (event, {
|
40
|
+
editor
|
41
|
+
}) => {
|
42
|
+
try {
|
43
|
+
const {
|
44
|
+
path,
|
45
|
+
enable
|
46
|
+
} = window?.selectedRnDElement || {};
|
47
|
+
// only copy RnD items in Srag enable mode not in edit mode
|
48
|
+
if (path && enable === 1) {
|
49
|
+
let pPath = parsePath(path);
|
50
|
+
let node = Node.get(editor, pPath);
|
51
|
+
const isRnD = RND_ITEM_TYPES.indexOf(node?.type) > -1;
|
52
|
+
if (isRnD) {
|
53
|
+
event.preventDefault();
|
54
|
+
if (node?.type === "freegrid") {
|
55
|
+
node = Node.get(editor, Path.parent(pPath));
|
56
|
+
}
|
57
|
+
const jsonFragment = JSON.stringify(node);
|
58
|
+
window.copiedNode = jsonFragment;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
} catch (err) {
|
62
|
+
console.log(err);
|
63
|
+
}
|
64
|
+
};
|
65
|
+
const onCut = (event, {
|
66
|
+
editor
|
67
|
+
}) => {
|
68
|
+
try {
|
69
|
+
const {
|
70
|
+
path,
|
71
|
+
enable
|
72
|
+
} = window?.selectedRnDElement || {};
|
73
|
+
onCopy(event, {
|
74
|
+
editor
|
75
|
+
});
|
76
|
+
// remove the node
|
77
|
+
if (path && enable === 1) {
|
78
|
+
const pPath = parsePath(path);
|
79
|
+
Transforms.removeNodes(editor, {
|
80
|
+
at: pPath
|
81
|
+
});
|
82
|
+
// change / remove the focus to parent
|
83
|
+
const currentSelectedNode = Node.get(editor, pPath);
|
84
|
+
const sPath = currentSelectedNode?.type !== "freegrid" ? Path.parent(pPath) : pPath;
|
85
|
+
focusOnNewItem(editor, sPath, {
|
86
|
+
setSelectedElement: window.updateSelectedItem
|
87
|
+
});
|
88
|
+
}
|
89
|
+
} catch (err) {
|
90
|
+
console.log(err);
|
91
|
+
}
|
92
|
+
};
|
93
|
+
const onPaste = async (event, {
|
94
|
+
editor
|
95
|
+
}) => {
|
96
|
+
try {
|
97
|
+
const {
|
98
|
+
path,
|
99
|
+
enable
|
100
|
+
} = window?.selectedRnDElement || {};
|
101
|
+
if (path && enable === 1) {
|
102
|
+
event.preventDefault();
|
103
|
+
const pPath = parsePath(path);
|
104
|
+
const currentSelectedNode = Node.get(editor, pPath);
|
105
|
+
let sPath = currentSelectedNode?.type !== "freegrid" ? Path.parent(pPath) : pPath;
|
106
|
+
const sectionNode = Node.get(editor, sPath);
|
107
|
+
const np = onPasteRnDNode(editor, {
|
108
|
+
path: sPath,
|
109
|
+
children: sectionNode?.children,
|
110
|
+
slateNodes: null
|
111
|
+
});
|
112
|
+
if (np && window.updateSelectedItem) {
|
113
|
+
focusOnNewItem(editor, np, {
|
114
|
+
setSelectedElement: window.updateSelectedItem
|
115
|
+
});
|
116
|
+
}
|
117
|
+
}
|
118
|
+
} catch (err) {
|
119
|
+
console.log(err);
|
120
|
+
}
|
121
|
+
};
|
122
|
+
const onBringFront = (event, {
|
123
|
+
editor
|
124
|
+
}) => {
|
125
|
+
try {
|
126
|
+
const {
|
127
|
+
path,
|
128
|
+
enable
|
129
|
+
} = window?.selectedRnDElement || {};
|
130
|
+
if (path && enable === 1) {
|
131
|
+
event.preventDefault();
|
132
|
+
bringItemToFB(editor, {
|
133
|
+
path: parsePath(path),
|
134
|
+
moveFront: true
|
135
|
+
});
|
136
|
+
}
|
137
|
+
} catch (err) {
|
138
|
+
console.log(err);
|
139
|
+
}
|
140
|
+
};
|
141
|
+
const onBringBack = (event, {
|
142
|
+
editor
|
143
|
+
}) => {
|
144
|
+
try {
|
145
|
+
const {
|
146
|
+
path,
|
147
|
+
enable
|
148
|
+
} = window?.selectedRnDElement || {};
|
149
|
+
if (path && enable === 1) {
|
150
|
+
event.preventDefault();
|
151
|
+
bringItemToFB(editor, {
|
152
|
+
path: parsePath(path),
|
153
|
+
moveFront: false
|
154
|
+
});
|
155
|
+
}
|
156
|
+
} catch (err) {
|
157
|
+
console.log(err);
|
158
|
+
}
|
159
|
+
};
|
160
|
+
const RnDCtrlCmds = {
|
161
|
+
ArrowUp: onBringFront,
|
162
|
+
ArrowDown: onBringBack,
|
163
|
+
a: selectAll,
|
164
|
+
c: onCopy,
|
165
|
+
v: onPaste,
|
166
|
+
x: onCut
|
167
|
+
};
|
168
|
+
export default RnDCtrlCmds;
|
@@ -32,7 +32,7 @@ import FormField from "../Elements/Form/FormField";
|
|
32
32
|
import InlineIcon from "../Elements/InlineIcon/InlineIcon";
|
33
33
|
import SimpleText from "../Elements/SimpleText";
|
34
34
|
import CheckList from "../Elements/List/CheckList";
|
35
|
-
import {
|
35
|
+
import { isEmptyTextNode } from "../helper";
|
36
36
|
import Attachments from "../Elements/Attachments/Attachments";
|
37
37
|
import { getBreakPointsValue } from "../helper/theme";
|
38
38
|
import Variables from "../Elements/Variables/Variable";
|
@@ -40,6 +40,10 @@ import insertNewLine from "./insertNewLine";
|
|
40
40
|
import Divider from "../Elements/Divider/Divider";
|
41
41
|
import { getBorderColor } from "./helper";
|
42
42
|
import Code from "../Elements/EmbedScript/Code";
|
43
|
+
import FreeGrid from "../Elements/FreeGrid/FreeGrid";
|
44
|
+
import FreeGridItem from "../Elements/FreeGrid/FreeGridItem";
|
45
|
+
import FreeGridBox from "../Elements/FreeGrid/FreeGridBox";
|
46
|
+
import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
|
43
47
|
import { jsx as _jsx } from "react/jsx-runtime";
|
44
48
|
const alignment = ["alignLeft", "alignRight", "alignCenter"];
|
45
49
|
const list_types = ["orderedList", "unorderedList"];
|
@@ -160,7 +164,7 @@ export const activeMark = (editor, format) => {
|
|
160
164
|
return null;
|
161
165
|
}
|
162
166
|
};
|
163
|
-
export const getMarked = (leaf, children) => {
|
167
|
+
export const getMarked = (leaf, children, theme) => {
|
164
168
|
const className = leaf?.doublequote ? "doublequote" : "";
|
165
169
|
if (leaf.bold) {
|
166
170
|
children = /*#__PURE__*/_jsx("strong", {
|
@@ -203,7 +207,13 @@ export const getMarked = (leaf, children) => {
|
|
203
207
|
// cover under single span
|
204
208
|
if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || className) {
|
205
209
|
const family = fontFamilyMap[leaf?.fontFamily];
|
206
|
-
const textStyles =
|
210
|
+
const textStyles = leaf?.color?.indexOf("gradient") >= 0 ? {
|
211
|
+
background: leaf?.color?.concat("text"),
|
212
|
+
WebkitBackgroundClip: "text",
|
213
|
+
WebkitTextFillColor: "transparent"
|
214
|
+
} : {
|
215
|
+
color: leaf.color
|
216
|
+
};
|
207
217
|
children = /*#__PURE__*/_jsx("span", {
|
208
218
|
style: {
|
209
219
|
background: leaf.bgColor
|
@@ -212,10 +222,14 @@ export const getMarked = (leaf, children) => {
|
|
212
222
|
className: className,
|
213
223
|
component: "span",
|
214
224
|
sx: {
|
215
|
-
|
225
|
+
...wrapThemeBreakpoints({
|
216
226
|
lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
217
227
|
...getBreakPointsValue(leaf.fontSize, null, "overrideText")
|
218
|
-
},
|
228
|
+
}, "fontSize", theme),
|
229
|
+
// fontSize: {
|
230
|
+
// lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
231
|
+
// ...getBreakPointsValue(leaf.fontSize, null, "overrideText"),
|
232
|
+
// },
|
219
233
|
...textStyles,
|
220
234
|
fontFamily: family,
|
221
235
|
fontWeight: leaf.fontWeight
|
@@ -401,6 +415,18 @@ export const getBlock = props => {
|
|
401
415
|
return /*#__PURE__*/_jsx(Grid, {
|
402
416
|
...props
|
403
417
|
});
|
418
|
+
case "freegrid":
|
419
|
+
return /*#__PURE__*/_jsx(FreeGrid, {
|
420
|
+
...props
|
421
|
+
});
|
422
|
+
case "freegridItem":
|
423
|
+
return /*#__PURE__*/_jsx(FreeGridItem, {
|
424
|
+
...props
|
425
|
+
});
|
426
|
+
case "freegridBox":
|
427
|
+
return /*#__PURE__*/_jsx(FreeGridBox, {
|
428
|
+
...props
|
429
|
+
});
|
404
430
|
case "grid-item":
|
405
431
|
return /*#__PURE__*/_jsx(GridItem, {
|
406
432
|
...props,
|
@@ -3,6 +3,7 @@ import { toggleBlock } from "./SlateUtilityFunctions";
|
|
3
3
|
import insertNewLine from "./insertNewLine";
|
4
4
|
import { insertAccordion } from "./accordion";
|
5
5
|
import { isListItem } from "./helper";
|
6
|
+
import RnDCtrlCmds from "./RnD/RnDCtrlCmds";
|
6
7
|
import EDITORCMDS from "../common/EditorCmds";
|
7
8
|
const HOTKEYS = {
|
8
9
|
b: "bold",
|
@@ -75,6 +76,10 @@ export const commands = props => {
|
|
75
76
|
} else {
|
76
77
|
Editor.addMark(editor, HOTKEYS[event.key], true);
|
77
78
|
}
|
79
|
+
} else if (RnDCtrlCmds[event.key]) {
|
80
|
+
RnDCtrlCmds[event.key](event, {
|
81
|
+
editor
|
82
|
+
});
|
78
83
|
} else if (EDITORCMDS[event.key]) {
|
79
84
|
EDITORCMDS[event.key](event, {
|
80
85
|
editor,
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { Transforms } from "slate";
|
2
|
+
import insertNewLine from "./insertNewLine";
|
3
|
+
import scrollToNewSection from "../helper/RnD/scrollToNewSection";
|
4
|
+
const Default_text_Node = {
|
5
|
+
type: "paragraph",
|
6
|
+
children: [{
|
7
|
+
text: "Effortless Business Growth"
|
8
|
+
}]
|
9
|
+
};
|
10
|
+
export const insertFreeGridItem = (childType, childTypeNode, extProps = {}, type = "freegridItem") => {
|
11
|
+
return {
|
12
|
+
type: type || "freegridItem",
|
13
|
+
childType: childType || "text",
|
14
|
+
children: [childTypeNode || Default_text_Node],
|
15
|
+
gridArea: "1 / 1 / 2 / 2",
|
16
|
+
height: 300,
|
17
|
+
width: 250,
|
18
|
+
left: 401,
|
19
|
+
top: 0,
|
20
|
+
marginTop: 47,
|
21
|
+
left_xs: 24,
|
22
|
+
top_xs: 24,
|
23
|
+
marginTop_xs: 12,
|
24
|
+
width_xs: 250,
|
25
|
+
height_xs: 300,
|
26
|
+
gridArea_xs: "1 / 1 / 2 / 2",
|
27
|
+
sectionBgColor: "rgb(240, 108, 131)",
|
28
|
+
...(extProps || {})
|
29
|
+
};
|
30
|
+
};
|
31
|
+
export const insertFreeGrid = (editor, path, extProps) => {
|
32
|
+
const items = Array.from(Array(1).keys()).map(() => insertFreeGridItem());
|
33
|
+
const freegridData = [{
|
34
|
+
type: "paragraph",
|
35
|
+
children: [{
|
36
|
+
type: "freegrid",
|
37
|
+
height: 500,
|
38
|
+
gridTemplateRows: "var(--rows)",
|
39
|
+
gridTemplateColumns: "var(--cols)",
|
40
|
+
children: [...items]
|
41
|
+
}]
|
42
|
+
}];
|
43
|
+
const newPath = path ? path : editor?.selection?.anchor?.path;
|
44
|
+
Transforms.insertNodes(editor, freegridData, {
|
45
|
+
at: newPath
|
46
|
+
});
|
47
|
+
scrollToNewSection(editor, newPath, extProps);
|
48
|
+
insertNewLine(editor);
|
49
|
+
};
|
@@ -398,4 +398,33 @@ export const onDeleteKey = (event, {
|
|
398
398
|
} catch (err) {
|
399
399
|
console.log(err);
|
400
400
|
}
|
401
|
+
};
|
402
|
+
export const selectText = (editor, {
|
403
|
+
path,
|
404
|
+
cursorOnly
|
405
|
+
}) => {
|
406
|
+
try {
|
407
|
+
ReactEditor.focus(editor);
|
408
|
+
const range = Editor.range(editor, path);
|
409
|
+
const textNode = Node.get(editor, path);
|
410
|
+
if (!cursorOnly) {
|
411
|
+
Transforms.select(editor, range);
|
412
|
+
}
|
413
|
+
if (cursorOnly && textNode) {
|
414
|
+
const textLength = Node.string(textNode).length;
|
415
|
+
editor.selection = {
|
416
|
+
anchor: {
|
417
|
+
path: path,
|
418
|
+
offset: textLength
|
419
|
+
},
|
420
|
+
focus: {
|
421
|
+
path: path,
|
422
|
+
offset: textLength
|
423
|
+
}
|
424
|
+
};
|
425
|
+
}
|
426
|
+
ReactEditor.focus(editor);
|
427
|
+
} catch (err) {
|
428
|
+
console.log(err);
|
429
|
+
}
|
401
430
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "3.8.
|
3
|
+
"version": "3.8.9",
|
4
4
|
"description": "An Editor for flozy app brain",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -36,6 +36,7 @@
|
|
36
36
|
"react-gcolor-picker": "^1.3.1",
|
37
37
|
"react-icons": "^4.10.1",
|
38
38
|
"react-katex": "^3.0.1",
|
39
|
+
"react-rnd": "^10.4.11",
|
39
40
|
"react-scripts": "5.0.1",
|
40
41
|
"react-signature-canvas": "^1.0.6",
|
41
42
|
"react-slick": "^0.29.0",
|
@@ -56,6 +57,7 @@
|
|
56
57
|
},
|
57
58
|
"scripts": {
|
58
59
|
"prepare": "husky install .husky",
|
60
|
+
"analyze": "source-map-explorer build/static/js/*.js",
|
59
61
|
"lint": "./node_modules/.bin/eslint --ignore-path .gitignore .",
|
60
62
|
"start": "craco start",
|
61
63
|
"build": "NODE_OPTIONS='--max_old_space_size=4096' craco build",
|
@@ -64,7 +66,7 @@
|
|
64
66
|
"storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook dev -p 6006",
|
65
67
|
"build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
|
66
68
|
"publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
|
67
|
-
"publish:local": "rm -rf /Users/
|
69
|
+
"publish:local": "rm -rf /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist --copy-files"
|
68
70
|
},
|
69
71
|
"eslintConfig": {
|
70
72
|
"extends": [
|
@@ -112,6 +114,7 @@
|
|
112
114
|
"babel-plugin-named-exports-order": "^0.0.2",
|
113
115
|
"eslint-plugin-storybook": "^0.6.13",
|
114
116
|
"prop-types": "^15.8.1",
|
117
|
+
"source-map-explorer": "^2.5.3",
|
115
118
|
"storybook": "^7.4.0",
|
116
119
|
"webpack": "^5.88.2"
|
117
120
|
},
|