@flozy/editor 5.2.8 → 5.3.0
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/ChatEditor.js +34 -25
- package/dist/Editor/CommonEditor.js +11 -17
- package/dist/Editor/Editor.css +16 -14
- package/dist/Editor/Elements/AI/AIInput.js +3 -0
- package/dist/Editor/Elements/AppHeader/AppHeader.js +6 -6
- package/dist/Editor/Elements/Button/EditorButton.js +2 -8
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +2 -4
- package/dist/Editor/Elements/Form/Form.js +0 -1
- package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +4 -4
- package/dist/Editor/Elements/FreeGrid/styles.js +1 -2
- package/dist/Editor/Elements/List/CheckList.js +1 -2
- package/dist/Editor/Elements/Search/SearchAttachment.js +0 -1
- package/dist/Editor/Elements/SimpleText/index.js +1 -8
- package/dist/Editor/Elements/SimpleText/style.js +1 -10
- package/dist/Editor/Elements/Table/Table.js +1 -1
- package/dist/Editor/Elements/TopBanner/TopBanner.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +0 -10
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +0 -45
- package/dist/Editor/Toolbar/Toolbar.js +0 -6
- package/dist/Editor/Toolbar/toolbarGroups.js +0 -4
- package/dist/Editor/common/FontLoader/FontLoader.js +4 -4
- package/dist/Editor/common/Icon.js +0 -6
- package/dist/Editor/common/MentionsPopup/Styles.js +5 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +0 -1
- package/dist/Editor/common/RnD/GuideLines/styles.js +3 -3
- package/dist/Editor/common/RnD/ShadowElement.js +1 -1
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -14
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +6 -9
- package/dist/Editor/common/Shorthands/elements.js +1 -13
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +2 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +0 -4
- package/dist/Editor/common/Uploader.js +0 -8
- package/dist/Editor/common/iconListV2.js +53 -53
- package/dist/Editor/common/iconslist.js +3 -6
- package/dist/Editor/commonStyle.js +0 -9
- package/dist/Editor/helper/index.js +2 -2
- package/dist/Editor/helper/theme.js +1 -24
- package/dist/Editor/hooks/useMouseMove.js +2 -5
- package/dist/Editor/plugins/withEmbeds.js +26 -30
- package/dist/Editor/plugins/withHTML.js +2 -42
- package/dist/Editor/plugins/withLayout.js +0 -42
- package/dist/Editor/utils/SlateUtilityFunctions.js +1 -24
- package/dist/Editor/utils/button.js +4 -4
- package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +1 -26
- package/dist/Editor/utils/events.js +1 -0
- package/dist/Editor/utils/helper.js +1 -51
- package/dist/Editor/utils/pageSettings.js +2 -14
- package/dist/Editor/utils/serializeToText.js +0 -2
- package/package.json +1 -1
- package/dist/Editor/Elements/DataView/DataView.js +0 -124
- package/dist/Editor/Elements/DataView/DataViewButton.js +0 -23
- package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +0 -68
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +0 -33
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +0 -162
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +0 -40
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +0 -67
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +0 -35
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +0 -39
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +0 -30
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +0 -30
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +0 -35
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +0 -36
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +0 -17
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +0 -29
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +0 -38
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +0 -74
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +0 -64
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +0 -106
- package/dist/Editor/Elements/DataView/Layouts/FilterView.js +0 -174
- package/dist/Editor/Elements/DataView/Layouts/Formula.js +0 -29
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +0 -113
- package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +0 -37
- package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +0 -111
- package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +0 -60
- package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +0 -36
- package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +0 -101
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +0 -160
- package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +0 -190
- package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +0 -42
- package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +0 -30
- package/dist/Editor/Elements/DataView/Layouts/Options/index.js +0 -110
- package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +0 -179
- package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +0 -112
- package/dist/Editor/Elements/DataView/Layouts/TableView.js +0 -227
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +0 -81
- package/dist/Editor/Elements/DataView/Layouts/index.js +0 -25
- package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +0 -273
- package/dist/Editor/Elements/DataView/Utils/globalSearch.js +0 -15
- package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +0 -74
- package/dist/Editor/Elements/DataView/styles.js +0 -154
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +0 -79
- package/dist/Editor/helper/enforceDateFormat.js +0 -41
- package/dist/Editor/utils/dataView.js +0 -43
|
@@ -40,36 +40,32 @@ const withEmbeds = editor => {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
editor.insertBreak = (...args) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
insertBreak(...args);
|
|
70
|
-
}
|
|
71
|
-
} catch (err) {
|
|
72
|
-
console.log(err);
|
|
43
|
+
const parentPath = Path.parent(editor.selection.focus.path);
|
|
44
|
+
const parentNode = Node.get(editor, parentPath);
|
|
45
|
+
if (editor.isVoid(parentNode)) {
|
|
46
|
+
const nextPath = Path.next(parentPath);
|
|
47
|
+
Transforms.insertNodes(editor, {
|
|
48
|
+
type: "paragraph",
|
|
49
|
+
children: [{
|
|
50
|
+
text: ""
|
|
51
|
+
}]
|
|
52
|
+
}, {
|
|
53
|
+
at: nextPath,
|
|
54
|
+
select: true // Focus on this node once inserted
|
|
55
|
+
});
|
|
56
|
+
} else if (AvoidCopying.indexOf(parentNode?.type) >= 0) {
|
|
57
|
+
const nextPath = Path.next(parentPath);
|
|
58
|
+
Transforms.insertNodes(editor, {
|
|
59
|
+
type: "paragraph",
|
|
60
|
+
children: [{
|
|
61
|
+
text: ""
|
|
62
|
+
}]
|
|
63
|
+
}, {
|
|
64
|
+
at: nextPath,
|
|
65
|
+
select: true // Focus on this node once inserted
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
insertBreak(...args);
|
|
73
69
|
}
|
|
74
70
|
};
|
|
75
71
|
return editor;
|
|
@@ -2,7 +2,6 @@ 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"];
|
|
6
5
|
const loopChildren = (children = [], defaultInsert) => {
|
|
7
6
|
if (!children?.length) {
|
|
8
7
|
return defaultInsert;
|
|
@@ -121,21 +120,12 @@ const withHtml = editor => {
|
|
|
121
120
|
const slateHTML = data?.getData("application/x-slate-fragment");
|
|
122
121
|
const html = data?.getData("text/html");
|
|
123
122
|
const currentEl = getCurrentElement(editor);
|
|
124
|
-
|
|
125
|
-
const isTitlePath = editor?.selection?.anchor?.path[0] === 0;
|
|
123
|
+
let eltype = currentEl?.type;
|
|
126
124
|
if (slateHTML && !formatFragment[eltype]) {
|
|
127
125
|
const [tableCellNode] = Editor.nodes(editor, {
|
|
128
126
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
|
|
129
127
|
});
|
|
130
128
|
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
|
-
}
|
|
139
129
|
if (tableCellNode) {
|
|
140
130
|
const tableCellChild = getTableCellChild(decoded);
|
|
141
131
|
if (tableCellChild?.length) {
|
|
@@ -180,40 +170,10 @@ const withHtml = editor => {
|
|
|
180
170
|
Transforms.insertText(editor, text);
|
|
181
171
|
}
|
|
182
172
|
} else {
|
|
183
|
-
handleInsert(editor, () =>
|
|
184
|
-
if (isTitlePath) {
|
|
185
|
-
Transforms.insertNodes(editor, [{
|
|
186
|
-
type: "title",
|
|
187
|
-
children: [{
|
|
188
|
-
text: ""
|
|
189
|
-
}]
|
|
190
|
-
}], {
|
|
191
|
-
at: [0]
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
insertData(data);
|
|
195
|
-
}, decoded);
|
|
173
|
+
handleInsert(editor, () => insertData(data), decoded);
|
|
196
174
|
}
|
|
197
175
|
} else if (html) {
|
|
198
176
|
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
|
-
}
|
|
217
177
|
const isGoogleSheet = parsed.body.querySelector("google-sheets-html-origin");
|
|
218
178
|
if (isGoogleSheet) {
|
|
219
179
|
if (editor.isChatEditor) {
|
|
@@ -58,49 +58,7 @@ const withLayout = editor => {
|
|
|
58
58
|
Transforms.insertNodes(editor, paragraph, {
|
|
59
59
|
at: path.concat(1)
|
|
60
60
|
});
|
|
61
|
-
return;
|
|
62
61
|
}
|
|
63
|
-
|
|
64
|
-
// Transforms.insertNodes(editor, paragraph, { at: [0] });
|
|
65
|
-
// const extractFirstText = (node) => {
|
|
66
|
-
// if (node.text) {
|
|
67
|
-
// return node.text;
|
|
68
|
-
// }
|
|
69
|
-
// if (node.children) {
|
|
70
|
-
// for (const child of node.children) {
|
|
71
|
-
// const text = extractFirstText(child);
|
|
72
|
-
// if (text) {
|
|
73
|
-
// return text;
|
|
74
|
-
// }
|
|
75
|
-
// }
|
|
76
|
-
// }
|
|
77
|
-
// return "";
|
|
78
|
-
// };
|
|
79
|
-
|
|
80
|
-
// const extractRemainingNodes = (node) => {
|
|
81
|
-
// if (!node.children) {
|
|
82
|
-
// return [];
|
|
83
|
-
// }
|
|
84
|
-
// const [, ...remainingChildren] = node.children;
|
|
85
|
-
// return remainingChildren.map((child) => ({ ...child }));
|
|
86
|
-
// };
|
|
87
|
-
|
|
88
|
-
// const firstNode = editor.children[0];
|
|
89
|
-
// const firstContent = extractFirstText(firstNode);
|
|
90
|
-
|
|
91
|
-
// if (firstNode.type !== "title") {
|
|
92
|
-
// const titleNode = {
|
|
93
|
-
// type: "title",
|
|
94
|
-
// children: [{ text: firstContent }],
|
|
95
|
-
// };
|
|
96
|
-
// Transforms.removeNodes(editor, { at: [0] });
|
|
97
|
-
// Transforms.insertNodes(editor, titleNode, { at: [0], select: true });
|
|
98
|
-
// const remainingNodes = extractRemainingNodes(firstNode);
|
|
99
|
-
// if (remainingNodes.length > 0) {
|
|
100
|
-
// Transforms.insertNodes(editor, remainingNodes, { at: [1] });
|
|
101
|
-
// }
|
|
102
|
-
// }
|
|
103
|
-
|
|
104
62
|
ORDERS_LAYOUT.forEach((enforce, index) => {
|
|
105
63
|
if (index < editor.children.length) {
|
|
106
64
|
const existsNode = Node.get(editor, [index]);
|
|
@@ -43,9 +43,6 @@ import Code from "../Elements/EmbedScript/Code";
|
|
|
43
43
|
import FreeGrid from "../Elements/FreeGrid/FreeGrid";
|
|
44
44
|
import FreeGridItem from "../Elements/FreeGrid/FreeGridItem";
|
|
45
45
|
import FreeGridBox from "../Elements/FreeGrid/FreeGridBox";
|
|
46
|
-
import DataView from "../Elements/DataView/DataView";
|
|
47
|
-
import ViewData from "../Elements/DataView/Layouts/ViewData";
|
|
48
|
-
import ColumnView from "../Elements/DataView/Layouts/ColumnView";
|
|
49
46
|
import SearchAttachment from "../Elements/Search/SearchAttachment";
|
|
50
47
|
// import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
|
|
51
48
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -312,8 +309,7 @@ export const getBlock = props => {
|
|
|
312
309
|
borderRadius: `${element?.color ? "0px" : "12px"} 12px 12px ${element?.color ? "0px" : "12px"}`,
|
|
313
310
|
margin: `${element?.bgColor ? "16px" : "0px"} 0px`,
|
|
314
311
|
width: element?.bgColor ? "calc(100% - 16px)" : "100%",
|
|
315
|
-
borderWidth: element?.color ? "0px 0px 0px 3px" : "0px"
|
|
316
|
-
lineHeight: 1.43
|
|
312
|
+
borderWidth: element?.color ? "0px 0px 0px 3px" : "0px"
|
|
317
313
|
},
|
|
318
314
|
children: children
|
|
319
315
|
});
|
|
@@ -373,9 +369,6 @@ export const getBlock = props => {
|
|
|
373
369
|
});
|
|
374
370
|
case "orderedList":
|
|
375
371
|
return /*#__PURE__*/_jsx("ol", {
|
|
376
|
-
style: {
|
|
377
|
-
lineHeight: 1.43
|
|
378
|
-
},
|
|
379
372
|
className: "listItemMargin",
|
|
380
373
|
type: "1",
|
|
381
374
|
...attributes,
|
|
@@ -383,9 +376,6 @@ export const getBlock = props => {
|
|
|
383
376
|
});
|
|
384
377
|
case "unorderedList":
|
|
385
378
|
return /*#__PURE__*/_jsx("ul", {
|
|
386
|
-
style: {
|
|
387
|
-
lineHeight: 1.43
|
|
388
|
-
},
|
|
389
379
|
className: "listItemMargin",
|
|
390
380
|
...attributes,
|
|
391
381
|
children: children
|
|
@@ -574,19 +564,6 @@ export const getBlock = props => {
|
|
|
574
564
|
contentEditable: false,
|
|
575
565
|
children: children
|
|
576
566
|
});
|
|
577
|
-
// Data View
|
|
578
|
-
case "dataView":
|
|
579
|
-
return /*#__PURE__*/_jsx(DataView, {
|
|
580
|
-
...props
|
|
581
|
-
});
|
|
582
|
-
case "viewData":
|
|
583
|
-
return /*#__PURE__*/_jsx(ViewData, {
|
|
584
|
-
...props
|
|
585
|
-
});
|
|
586
|
-
case "columnView":
|
|
587
|
-
return /*#__PURE__*/_jsx(ColumnView, {
|
|
588
|
-
...props
|
|
589
|
-
});
|
|
590
567
|
default:
|
|
591
568
|
return /*#__PURE__*/_jsx(SimpleText, {
|
|
592
569
|
...props,
|
|
@@ -3,7 +3,6 @@ import { Box } from "@mui/material";
|
|
|
3
3
|
import { fontFamilyMap, sizeMap } from "../font";
|
|
4
4
|
import Mentions from "../../Elements/Mentions/Mentions";
|
|
5
5
|
import CheckList from "../../Elements/List/CheckList";
|
|
6
|
-
import SimpleText from "../../Elements/SimpleText";
|
|
7
6
|
import { isEmptyTextNode } from "../../helper";
|
|
8
7
|
import { getBreakPointsValue } from "../../helper/theme";
|
|
9
8
|
import insertNewLine from "../insertNewLine";
|
|
@@ -16,20 +15,6 @@ const LIST_FORMAT_TYPE = {
|
|
|
16
15
|
unorderedList: "list-item"
|
|
17
16
|
};
|
|
18
17
|
const NEWLINESAFTER = ["headingOne", "headingTwo", "headingThree"];
|
|
19
|
-
export const serializeMentions = node => {
|
|
20
|
-
try {
|
|
21
|
-
if (node?.type === 'mention') {
|
|
22
|
-
return [node.character];
|
|
23
|
-
}
|
|
24
|
-
let children = Array.isArray(node) ? node : node?.children;
|
|
25
|
-
children = children && Array.isArray(children) ? children : [];
|
|
26
|
-
let mentions = children.map(child => serializeMentions(child)).flat();
|
|
27
|
-
return mentions.filter(Boolean);
|
|
28
|
-
} catch (err) {
|
|
29
|
-
console.log(err);
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
18
|
export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
34
19
|
const isActive = isBlockActive(editor, format);
|
|
35
20
|
const isList = list_types.includes(format);
|
|
@@ -260,13 +245,6 @@ export const getBlock = props => {
|
|
|
260
245
|
,
|
|
261
246
|
children: children
|
|
262
247
|
});
|
|
263
|
-
case "title":
|
|
264
|
-
return /*#__PURE__*/_jsx("h3", {
|
|
265
|
-
...attributes,
|
|
266
|
-
...element.attr,
|
|
267
|
-
className: `content-editable ${isEmpty ? "empty" : ""}`,
|
|
268
|
-
children: children
|
|
269
|
-
});
|
|
270
248
|
case "headingThree":
|
|
271
249
|
return /*#__PURE__*/_jsx("h3", {
|
|
272
250
|
...attributes,
|
|
@@ -364,9 +342,6 @@ export const getBlock = props => {
|
|
|
364
342
|
...props
|
|
365
343
|
});
|
|
366
344
|
default:
|
|
367
|
-
return
|
|
368
|
-
...props,
|
|
369
|
-
isEmpty: isEmpty
|
|
370
|
-
});
|
|
345
|
+
return null;
|
|
371
346
|
}
|
|
372
347
|
};
|
|
@@ -5,6 +5,7 @@ import { insertAccordion } from "./accordion";
|
|
|
5
5
|
import { isListItem } from "./helper";
|
|
6
6
|
import RnDCtrlCmds from "./RnD/RnDCtrlCmds";
|
|
7
7
|
import EDITORCMDS from "../common/EditorCmds";
|
|
8
|
+
import { ReactEditor } from "slate-react";
|
|
8
9
|
const HOTKEYS = {
|
|
9
10
|
b: "bold",
|
|
10
11
|
i: "italic",
|
|
@@ -4,7 +4,6 @@ import insertNewLine from "./insertNewLine";
|
|
|
4
4
|
import { getDevice } from "../helper/theme";
|
|
5
5
|
export const windowVar = {};
|
|
6
6
|
let ST_TIMEOUT = null;
|
|
7
|
-
const BLOCKS = ["grid", "dataView"];
|
|
8
7
|
export const formatDate = (date, format = "MM/DD/YYYY") => {
|
|
9
8
|
if (!date) return "";
|
|
10
9
|
var d = new Date(date),
|
|
@@ -164,7 +163,7 @@ export const handleInsertLastElement = (event, editor) => {
|
|
|
164
163
|
if (isFreeGrid) {
|
|
165
164
|
return;
|
|
166
165
|
}
|
|
167
|
-
const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c =>
|
|
166
|
+
const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => c.type === "grid");
|
|
168
167
|
if (!ReactEditor.isFocused(editor)) {
|
|
169
168
|
if (isLastElementEmpty) {
|
|
170
169
|
if (hasPath) {
|
|
@@ -628,24 +627,6 @@ export function capitalizeFirstLetter(str) {
|
|
|
628
627
|
if (!str) return str;
|
|
629
628
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
630
629
|
}
|
|
631
|
-
export const insertLineBreakAtEndOfPath = (editor, path) => {
|
|
632
|
-
try {
|
|
633
|
-
const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
|
|
634
|
-
if (node) {
|
|
635
|
-
// Insert the line break
|
|
636
|
-
Transforms.insertNodes(editor, {
|
|
637
|
-
type: "paragraph",
|
|
638
|
-
children: [{
|
|
639
|
-
text: ""
|
|
640
|
-
}]
|
|
641
|
-
}, {
|
|
642
|
-
at: nodePath
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
} catch (err) {
|
|
646
|
-
console.log(err);
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
630
|
export function isHavingSelection(editor) {
|
|
650
631
|
try {
|
|
651
632
|
return editor?.selection && !Range.isCollapsed(editor.selection);
|
|
@@ -653,37 +634,6 @@ export function isHavingSelection(editor) {
|
|
|
653
634
|
console.log(err);
|
|
654
635
|
}
|
|
655
636
|
}
|
|
656
|
-
const omitNodes = ["site-settings", "page-settings"];
|
|
657
|
-
export function getInitialValue(value = [], readOnly) {
|
|
658
|
-
if (readOnly === "readonly" && value?.length) {
|
|
659
|
-
// remove last empty nodes on readonly mode, to remove empty spaces
|
|
660
|
-
|
|
661
|
-
let lastNonEmptyElementIndex;
|
|
662
|
-
for (let i = value?.length; i > 0; i--) {
|
|
663
|
-
const elementIndex = i - 1;
|
|
664
|
-
const node = value[elementIndex];
|
|
665
|
-
if (lastNonEmptyElementIndex) {
|
|
666
|
-
break;
|
|
667
|
-
}
|
|
668
|
-
if (node?.type === "paragraph") {
|
|
669
|
-
// Ensure all children of the paragraph node are text nodes
|
|
670
|
-
const hasOnlyTextChildren = node.children.every(child => Text.isText(child));
|
|
671
|
-
const text = node.children[node.children.length - 1]?.text;
|
|
672
|
-
lastNonEmptyElementIndex = hasOnlyTextChildren ? text ? elementIndex : null : elementIndex;
|
|
673
|
-
} else if (omitNodes.includes(node?.type)) {
|
|
674
|
-
continue;
|
|
675
|
-
} else {
|
|
676
|
-
lastNonEmptyElementIndex = elementIndex;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
const newValue = [...value].slice(0, lastNonEmptyElementIndex + 1);
|
|
680
|
-
return newValue;
|
|
681
|
-
}
|
|
682
|
-
return value;
|
|
683
|
-
}
|
|
684
637
|
export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
|
|
685
638
|
return `${defaultCls} ${selected ? selectedClsName : ""}`;
|
|
686
|
-
}
|
|
687
|
-
export function handleNegativeInteger(val) {
|
|
688
|
-
return val < 0 ? 0 : val;
|
|
689
639
|
}
|
|
@@ -9,13 +9,7 @@ export const findPageSettings = editor => {
|
|
|
9
9
|
path: null,
|
|
10
10
|
element: {
|
|
11
11
|
pageProps: {
|
|
12
|
-
pageWidth: "fixed"
|
|
13
|
-
"lineHeight": {
|
|
14
|
-
"xs": 1.43,
|
|
15
|
-
"sm": 1.43,
|
|
16
|
-
"md": 1.43,
|
|
17
|
-
"lg": 1.43
|
|
18
|
-
}
|
|
12
|
+
pageWidth: "fixed"
|
|
19
13
|
}
|
|
20
14
|
}
|
|
21
15
|
};
|
|
@@ -40,13 +34,7 @@ export const getPageSettings = editor => {
|
|
|
40
34
|
path: null,
|
|
41
35
|
element: {
|
|
42
36
|
pageProps: {
|
|
43
|
-
pageWidth: "fixed"
|
|
44
|
-
"lineHeight": {
|
|
45
|
-
"xs": 1.43,
|
|
46
|
-
"sm": 1.43,
|
|
47
|
-
"md": 1.43,
|
|
48
|
-
"lg": 1.43
|
|
49
|
-
}
|
|
37
|
+
pageWidth: "fixed"
|
|
50
38
|
}
|
|
51
39
|
}
|
|
52
40
|
};
|
|
@@ -2,8 +2,6 @@ export const serializeToText = node => {
|
|
|
2
2
|
try {
|
|
3
3
|
if (!node?.type && node?.text) {
|
|
4
4
|
return node?.text;
|
|
5
|
-
} else if (node?.type === 'mention') {
|
|
6
|
-
return '@' + node?.character?.name || '';
|
|
7
5
|
}
|
|
8
6
|
let n = Array.isArray(node) ? node : node?.children;
|
|
9
7
|
n = n && Array.isArray(n) ? n : n ? [n] : [];
|
package/package.json
CHANGED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Node, Path, Transforms } from "slate";
|
|
3
|
-
import { ReactEditor, useSlateStatic } from "slate-react";
|
|
4
|
-
import { Box, useTheme } from "@mui/material";
|
|
5
|
-
import { DataViewProvider } from "./Providers/DataViewProvider";
|
|
6
|
-
import useDataViewStyles from "./styles";
|
|
7
|
-
import LayoutView from "./Layouts";
|
|
8
|
-
import FilterView from "./Layouts/FilterView";
|
|
9
|
-
import { insertLineBreakAtEndOfPath } from "../../utils/helper";
|
|
10
|
-
import { useEditorContext } from "../../hooks/useMouseMove";
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
const DataView = props => {
|
|
14
|
-
const {
|
|
15
|
-
theme: appTheme
|
|
16
|
-
} = useEditorContext();
|
|
17
|
-
const theme = useTheme();
|
|
18
|
-
const editor = useSlateStatic();
|
|
19
|
-
const {
|
|
20
|
-
attributes,
|
|
21
|
-
children,
|
|
22
|
-
element,
|
|
23
|
-
customProps
|
|
24
|
-
} = props;
|
|
25
|
-
const {
|
|
26
|
-
CHARACTERS,
|
|
27
|
-
readOnly
|
|
28
|
-
} = customProps || {};
|
|
29
|
-
const {
|
|
30
|
-
properties,
|
|
31
|
-
layouts,
|
|
32
|
-
rows,
|
|
33
|
-
title
|
|
34
|
-
} = element;
|
|
35
|
-
const classes = useDataViewStyles(theme, appTheme);
|
|
36
|
-
const path = ReactEditor.findPath(editor, element);
|
|
37
|
-
const users = CHARACTERS?.map(m => {
|
|
38
|
-
const name = [m?.first_name || "", m?.last_name || ""]?.join(" ").trim();
|
|
39
|
-
return {
|
|
40
|
-
value: m?.email,
|
|
41
|
-
name: name || m?.username || m?.email,
|
|
42
|
-
avatar: m?.avatar || null
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
const onDuplicate = () => {
|
|
46
|
-
try {
|
|
47
|
-
const newPath = ReactEditor.findPath(editor, element);
|
|
48
|
-
const dataViewNode = Node.get(editor, newPath);
|
|
49
|
-
const cloneNode = JSON.parse(JSON.stringify(dataViewNode));
|
|
50
|
-
const toPath = Path.next(Path.parent(newPath));
|
|
51
|
-
Transforms.insertNodes(editor, [{
|
|
52
|
-
type: "paragraph",
|
|
53
|
-
children: [{
|
|
54
|
-
...cloneNode
|
|
55
|
-
}]
|
|
56
|
-
}], {
|
|
57
|
-
at: toPath
|
|
58
|
-
});
|
|
59
|
-
} catch (err) {
|
|
60
|
-
console.log(err);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const onDelete = () => {
|
|
64
|
-
try {
|
|
65
|
-
const newPath = ReactEditor.findPath(editor, element);
|
|
66
|
-
Transforms.removeNodes(editor, {
|
|
67
|
-
at: newPath
|
|
68
|
-
});
|
|
69
|
-
} catch (err) {
|
|
70
|
-
console.log(err);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const onEnter = () => {
|
|
74
|
-
try {
|
|
75
|
-
const newPath = ReactEditor.findPath(editor, element);
|
|
76
|
-
const toPath = Path.previous(Path.parent(newPath));
|
|
77
|
-
insertLineBreakAtEndOfPath(editor, toPath);
|
|
78
|
-
} catch (err) {
|
|
79
|
-
console.log(err);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const onTitleChange = value => {
|
|
83
|
-
try {
|
|
84
|
-
Transforms.setNodes(editor, {
|
|
85
|
-
title: value
|
|
86
|
-
}, {
|
|
87
|
-
at: path
|
|
88
|
-
});
|
|
89
|
-
} catch (err) {
|
|
90
|
-
console.log(err);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
return /*#__PURE__*/_jsx(Box, {
|
|
94
|
-
...attributes,
|
|
95
|
-
className: "fe-dataview",
|
|
96
|
-
sx: classes.root,
|
|
97
|
-
contentEditable: false,
|
|
98
|
-
"data-title": title,
|
|
99
|
-
children: /*#__PURE__*/_jsxs(DataViewProvider, {
|
|
100
|
-
initialData: {
|
|
101
|
-
properties,
|
|
102
|
-
layouts,
|
|
103
|
-
rows,
|
|
104
|
-
users: users
|
|
105
|
-
},
|
|
106
|
-
path: path,
|
|
107
|
-
editor: editor,
|
|
108
|
-
title: title,
|
|
109
|
-
children: [/*#__PURE__*/_jsx(FilterView, {
|
|
110
|
-
classes: classes,
|
|
111
|
-
onEnter: onEnter,
|
|
112
|
-
onDelete: onDelete,
|
|
113
|
-
onDuplicate: onDuplicate,
|
|
114
|
-
readOnly: readOnly,
|
|
115
|
-
title: title,
|
|
116
|
-
onTitleChange: onTitleChange
|
|
117
|
-
}), /*#__PURE__*/_jsx(LayoutView, {
|
|
118
|
-
readOnly: readOnly,
|
|
119
|
-
children: children
|
|
120
|
-
})]
|
|
121
|
-
})
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
export default DataView;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ToolbarIcon from "../../common/ToolbarIcon";
|
|
3
|
-
import Icon from "../../common/Icon";
|
|
4
|
-
import { insertDataView } from "../../utils/dataView";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const DataViewButton = props => {
|
|
7
|
-
const {
|
|
8
|
-
editor,
|
|
9
|
-
icoBtnType
|
|
10
|
-
} = props;
|
|
11
|
-
const onClick = () => {
|
|
12
|
-
insertDataView(editor);
|
|
13
|
-
};
|
|
14
|
-
return /*#__PURE__*/_jsx(ToolbarIcon, {
|
|
15
|
-
title: "Dynamic Table",
|
|
16
|
-
onClick: onClick,
|
|
17
|
-
icon: /*#__PURE__*/_jsx(Icon, {
|
|
18
|
-
icon: "dataView"
|
|
19
|
-
}),
|
|
20
|
-
icoBtnType: icoBtnType
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
export default DataViewButton;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { Box, Checkbox, Popper } from "@mui/material";
|
|
3
|
-
import CheckBoxTwoToneIcon from "@mui/icons-material/CheckBoxTwoTone";
|
|
4
|
-
import DataTypes from "./DataTypes";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
const ColumnView = props => {
|
|
8
|
-
const {
|
|
9
|
-
needAnchor,
|
|
10
|
-
rowIndex,
|
|
11
|
-
row,
|
|
12
|
-
property,
|
|
13
|
-
onSelect,
|
|
14
|
-
selected,
|
|
15
|
-
readOnly
|
|
16
|
-
} = props;
|
|
17
|
-
const DataType = DataTypes[property?.type] || DataTypes["text"];
|
|
18
|
-
const anchorRef = useRef(null);
|
|
19
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
20
|
-
const open = Boolean(anchorEl);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (anchorRef?.current) {
|
|
23
|
-
setAnchorEl(anchorRef?.current);
|
|
24
|
-
}
|
|
25
|
-
}, [anchorRef?.current]);
|
|
26
|
-
const handleSelect = id => e => {
|
|
27
|
-
onSelect(id, e.target.checked);
|
|
28
|
-
};
|
|
29
|
-
return /*#__PURE__*/_jsxs(Box, {
|
|
30
|
-
component: "td",
|
|
31
|
-
children: [needAnchor ? /*#__PURE__*/_jsx("span", {
|
|
32
|
-
ref: anchorRef,
|
|
33
|
-
style: {
|
|
34
|
-
position: "absolute",
|
|
35
|
-
width: "1px"
|
|
36
|
-
}
|
|
37
|
-
}) : null, /*#__PURE__*/_jsx(DataType, {
|
|
38
|
-
options: property?.options,
|
|
39
|
-
property: property?.key,
|
|
40
|
-
value: row[property?.key] || "",
|
|
41
|
-
rowIndex: rowIndex,
|
|
42
|
-
label: property?.label,
|
|
43
|
-
readOnly: readOnly
|
|
44
|
-
}), needAnchor && !readOnly ? /*#__PURE__*/_jsx(Popper, {
|
|
45
|
-
sx: {
|
|
46
|
-
zIndex: 1000,
|
|
47
|
-
marginTop: "20px !important"
|
|
48
|
-
},
|
|
49
|
-
open: open,
|
|
50
|
-
anchorEl: anchorEl,
|
|
51
|
-
placement: "left",
|
|
52
|
-
container: anchorRef?.current,
|
|
53
|
-
className: `tv-tr-pop ${selected ? "active" : ""}`,
|
|
54
|
-
disablePortal: true,
|
|
55
|
-
children: /*#__PURE__*/_jsx(Checkbox, {
|
|
56
|
-
onClick: handleSelect(row?.id),
|
|
57
|
-
size: "small",
|
|
58
|
-
className: "tv-ck-box",
|
|
59
|
-
sx: {
|
|
60
|
-
mr: 0
|
|
61
|
-
},
|
|
62
|
-
checked: selected,
|
|
63
|
-
checkedIcon: /*#__PURE__*/_jsx(CheckBoxTwoToneIcon, {})
|
|
64
|
-
})
|
|
65
|
-
}) : null]
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
export default ColumnView;
|