@flozy/editor 5.3.9 → 5.4.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 +25 -34
- package/dist/Editor/CommonEditor.js +29 -15
- package/dist/Editor/Editor.css +100 -18
- package/dist/Editor/Elements/AI/AIInput.js +0 -1
- package/dist/Editor/Elements/AI/CustomSelect.js +19 -11
- package/dist/Editor/Elements/AI/PopoverAIInput.js +58 -52
- package/dist/Editor/Elements/AI/Styles.js +24 -6
- package/dist/Editor/Elements/Accordion/Accordion.js +8 -1
- package/dist/Editor/Elements/AppHeader/AppHeader.js +6 -6
- package/dist/Editor/Elements/Button/EditorButton.js +9 -2
- package/dist/Editor/Elements/Carousel/CarouselItem.js +11 -3
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +7 -5
- package/dist/Editor/Elements/Color Picker/Styles.js +7 -3
- package/dist/Editor/Elements/Color Picker/defaultColors.js +2 -2
- package/dist/Editor/Elements/DataView/DataView.js +124 -0
- package/dist/Editor/Elements/DataView/DataViewButton.js +23 -0
- package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +67 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +33 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +162 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +40 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +67 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +35 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +39 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +30 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +30 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +35 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +36 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +17 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +29 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +38 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +74 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +64 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +106 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterView.js +174 -0
- package/dist/Editor/Elements/DataView/Layouts/Formula.js +29 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +113 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +37 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +111 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +60 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +36 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +101 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +160 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +190 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +42 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +30 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/index.js +110 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +179 -0
- package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +112 -0
- package/dist/Editor/Elements/DataView/Layouts/TableView.js +227 -0
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +80 -0
- package/dist/Editor/Elements/DataView/Layouts/colStyles.js +10 -0
- package/dist/Editor/Elements/DataView/Layouts/index.js +25 -0
- package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +281 -0
- package/dist/Editor/Elements/DataView/Utils/globalSearch.js +15 -0
- package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +74 -0
- package/dist/Editor/Elements/DataView/styles.js +154 -0
- package/dist/Editor/Elements/Divider/Divider.js +36 -20
- package/dist/Editor/Elements/Embed/Image.js +51 -16
- package/dist/Editor/Elements/Embed/Video.js +26 -3
- package/dist/Editor/Elements/Form/Form.js +39 -2
- package/dist/Editor/Elements/Form/FormElements/FormCheckbox.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormDate.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormEmail.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormNumbers.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormRadioButton.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormText.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +6 -1
- package/dist/Editor/Elements/Form/FormPopup.js +12 -9
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +20 -1
- package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +4 -4
- package/dist/Editor/Elements/FreeGrid/styles.js +2 -1
- package/dist/Editor/Elements/Grid/GridButton.js +2 -2
- package/dist/Editor/Elements/Grid/GridItem.js +47 -36
- package/dist/Editor/Elements/Grid/Styles.js +50 -0
- package/dist/Editor/Elements/Link/LinkButton.js +1 -1
- package/dist/Editor/Elements/List/CheckList.js +2 -1
- package/dist/Editor/Elements/Search/SearchAttachment.js +1 -0
- package/dist/Editor/Elements/Search/SearchButton.js +1 -0
- package/dist/Editor/Elements/Signature/Signature.css +1 -1
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -2
- package/dist/Editor/Elements/Signature/SignaturePopup.js +17 -52
- package/dist/Editor/Elements/SimpleText/index.js +8 -1
- package/dist/Editor/Elements/SimpleText/style.js +20 -1
- package/dist/Editor/Elements/Table/AddRowCol.js +77 -0
- package/dist/Editor/Elements/Table/DragButton.js +142 -0
- package/dist/Editor/Elements/Table/DragStyles.js +70 -0
- package/dist/Editor/Elements/Table/Draggable.js +25 -0
- package/dist/Editor/Elements/Table/Droppable.js +53 -0
- package/dist/Editor/Elements/Table/Styles.js +82 -79
- package/dist/Editor/Elements/Table/Table.js +258 -140
- package/dist/Editor/Elements/Table/TableCell.js +365 -111
- package/dist/Editor/Elements/Table/TablePopup.js +9 -3
- package/dist/Editor/Elements/Table/TableRow.js +10 -2
- package/dist/Editor/Elements/Table/TableTool.js +101 -0
- package/dist/Editor/Elements/Table/tableHelper.js +71 -0
- package/dist/Editor/Elements/TopBanner/TopBanner.js +2 -1
- package/dist/Editor/MiniEditor.js +15 -1
- package/dist/Editor/Styles/EditorStyles.js +13 -4
- package/dist/Editor/Toolbar/FormatTools/BlockButton.js +10 -0
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +7 -12
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +26 -4
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +3 -0
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +5 -5
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +3 -6
- package/dist/Editor/Toolbar/Mini/Styles.js +4 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/InfinityAITool.js +7 -3
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +6 -4
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +19 -15
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +555 -57
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +73 -16
- package/dist/Editor/Toolbar/PopupTool/index.js +3 -5
- package/dist/Editor/Toolbar/Toolbar.js +6 -0
- package/dist/Editor/Toolbar/toolbarGroups.js +4 -0
- package/dist/Editor/assets/svg/BrainIcon.js +2 -2
- package/dist/Editor/assets/svg/SettingsIcon.js +4 -4
- package/dist/Editor/assets/svg/TableIcons.js +220 -0
- package/dist/Editor/common/ColorPickerButton.js +85 -45
- package/dist/Editor/common/DnD/Draggable.js +2 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +4 -4
- package/dist/Editor/common/Icon.js +23 -20
- package/dist/Editor/common/ImageSelector/Options/Upload.js +2 -1
- package/dist/Editor/common/ImageSelector/Styles.js +47 -6
- package/dist/Editor/common/ImageSelector/UploadStyles.js +18 -6
- package/dist/Editor/common/LinkSettings/NavComponents.js +2 -1
- package/dist/Editor/common/LinkSettings/index.js +2 -1
- package/dist/Editor/common/MentionsPopup/Styles.js +143 -8
- package/dist/Editor/common/MentionsPopup/index.js +1 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +108 -12
- 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 +14 -2
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +9 -6
- package/dist/Editor/common/RnD/VirtualElement/index.js +5 -1
- package/dist/Editor/common/RnD/index.js +3 -2
- package/dist/Editor/common/Section/index.js +3 -3
- package/dist/Editor/common/Section/styles.js +5 -1
- package/dist/Editor/common/Select/index.js +20 -0
- package/dist/Editor/common/Select/styles.js +17 -0
- package/dist/Editor/common/Shorthands/elements.js +13 -1
- package/dist/Editor/common/StyleBuilder/fieldStyle.js +2 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +9 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +35 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +2 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +1 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +2 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +79 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/radiusStyle.js +11 -11
- package/dist/Editor/common/StyleBuilder/fieldTypes/saveAsTemplate.js +22 -6
- package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +21 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +20 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +12 -2
- package/dist/Editor/common/StyleBuilder/formStyle.js +268 -149
- package/dist/Editor/common/StyleBuilder/index.js +101 -20
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +4 -0
- package/dist/Editor/common/StyleBuilder/tableStyle.js +69 -25
- package/dist/Editor/common/SwipeableDrawer/style.js +15 -4
- package/dist/Editor/common/ToolbarIcon.js +1 -1
- package/dist/Editor/common/Uploader.js +46 -36
- package/dist/Editor/common/iconListV2.js +616 -60
- package/dist/Editor/common/iconslist.js +23 -17
- package/dist/Editor/commonStyle.js +417 -11
- package/dist/Editor/helper/deserialize/index.js +4 -1
- package/dist/Editor/helper/enforceDateFormat.js +41 -0
- package/dist/Editor/helper/index.js +17 -4
- package/dist/Editor/helper/theme.js +24 -1
- package/dist/Editor/hooks/useMouseMove.js +5 -2
- package/dist/Editor/hooks/useTable.js +210 -0
- package/dist/Editor/plugins/withCustomDeleteBackward.js +36 -4
- package/dist/Editor/plugins/withEmbeds.js +30 -26
- package/dist/Editor/plugins/withHTML.js +61 -10
- package/dist/Editor/plugins/withLayout.js +1 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +39 -12
- package/dist/Editor/utils/brains.js +1 -1
- package/dist/Editor/utils/button.js +4 -4
- package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +26 -1
- package/dist/Editor/utils/customHooks/useResize.js +7 -4
- package/dist/Editor/utils/customHooks/useTableResize.js +6 -2
- package/dist/Editor/utils/dataView.js +43 -0
- package/dist/Editor/utils/embed.js +2 -1
- package/dist/Editor/utils/events.js +0 -1
- package/dist/Editor/utils/font.js +11 -4
- package/dist/Editor/utils/formfield.js +8 -4
- package/dist/Editor/utils/helper.js +103 -2
- package/dist/Editor/utils/insertNewLine.js +19 -1
- package/dist/Editor/utils/pageSettings.js +14 -2
- package/dist/Editor/utils/serializeToText.js +2 -0
- package/dist/Editor/utils/table.js +228 -24
- package/package.json +2 -2
@@ -308,7 +308,13 @@ export const getTextColor = (color = "") => {
|
|
308
308
|
color: "transparent !important",
|
309
309
|
caretColor: "black",
|
310
310
|
"& span": {
|
311
|
-
color: "transparent !important"
|
311
|
+
color: "transparent !important",
|
312
|
+
"& ::selection": {
|
313
|
+
color: "#000 !important"
|
314
|
+
}
|
315
|
+
},
|
316
|
+
"& ::selection": {
|
317
|
+
color: "#000 !important"
|
312
318
|
}
|
313
319
|
} : {
|
314
320
|
color
|
@@ -331,14 +337,14 @@ export const isCarouselSelected = editor => {
|
|
331
337
|
return false;
|
332
338
|
}
|
333
339
|
const [nodeEntry] = Editor.nodes(editor, {
|
334
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type ===
|
340
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "carousel"
|
335
341
|
});
|
336
342
|
if (!nodeEntry) {
|
337
343
|
return false;
|
338
344
|
}
|
339
345
|
const [node] = nodeEntry;
|
340
346
|
const carouselDom = ReactEditor.toDOMNode(editor, node);
|
341
|
-
const isEdit = carouselDom.classList.contains(
|
347
|
+
const isEdit = carouselDom.classList.contains("carousel_slider_edit");
|
342
348
|
return !isEdit;
|
343
349
|
} catch (err) {
|
344
350
|
console.log(err);
|
@@ -352,7 +358,7 @@ export const clearBrainText = editor => {
|
|
352
358
|
} = editor;
|
353
359
|
if (selection) {
|
354
360
|
const [currentNode, currentPath] = Editor.node(editor, selection);
|
355
|
-
const cleanedText = Node.string(currentNode).replace(/\/b(?:rain|rai|ra|r)?/g, "").trim();
|
361
|
+
const cleanedText = Node.string(currentNode).replace(/\/(?:b(?:rain|rai|ra|r)?)?/g, "").trim();
|
356
362
|
Transforms.insertText(editor, cleanedText, {
|
357
363
|
at: currentPath
|
358
364
|
});
|
@@ -360,4 +366,11 @@ export const clearBrainText = editor => {
|
|
360
366
|
} catch (err) {
|
361
367
|
console.log(err);
|
362
368
|
}
|
369
|
+
};
|
370
|
+
export const clearSelectionOnly = editor => {
|
371
|
+
try {
|
372
|
+
Transforms.deselect(editor);
|
373
|
+
} catch (err) {
|
374
|
+
console.log(err);
|
375
|
+
}
|
363
376
|
};
|
@@ -147,4 +147,27 @@ export const groupByBreakpoint = (styleProps, theme) => {
|
|
147
147
|
}
|
148
148
|
};
|
149
149
|
};
|
150
|
-
export const getCustomizationValue = value => isNaN(parseInt(value)) ? null : parseInt(value);
|
150
|
+
export const getCustomizationValue = value => isNaN(parseInt(value)) ? null : parseInt(value);
|
151
|
+
export const getBreakpointLineSpacing = (value, breakpoint) => {
|
152
|
+
try {
|
153
|
+
const values = getBreakPointsValue(value, breakpoint);
|
154
|
+
const cssVal = BREAKPOINTS_DEVICES.reduce((a, b) => {
|
155
|
+
if (values[b] || values["lg"]) {
|
156
|
+
const value = values[b] || values["lg"];
|
157
|
+
return {
|
158
|
+
...a,
|
159
|
+
[b]: value
|
160
|
+
};
|
161
|
+
} else {
|
162
|
+
return a;
|
163
|
+
}
|
164
|
+
}, {});
|
165
|
+
if (breakpoint) {
|
166
|
+
return value[breakpoint] || value["lg"] || value;
|
167
|
+
} else {
|
168
|
+
return cssVal["lg"];
|
169
|
+
}
|
170
|
+
} catch (err) {
|
171
|
+
// console.log(err);
|
172
|
+
}
|
173
|
+
};
|
@@ -35,6 +35,7 @@ export const EditorProvider = ({
|
|
35
35
|
path: null
|
36
36
|
});
|
37
37
|
const [fontFamilies, setFontFamilies] = useState({});
|
38
|
+
const [activeBreakPoint, setActiveBreakPoint] = useState("");
|
38
39
|
useEffect(() => {
|
39
40
|
window.updateSelectedItem = d => {
|
40
41
|
setSelectedElement(d);
|
@@ -97,8 +98,10 @@ export const EditorProvider = ({
|
|
97
98
|
setOpenAI,
|
98
99
|
updateDragging,
|
99
100
|
fontFamilies,
|
100
|
-
setFontFamilies
|
101
|
-
|
101
|
+
setFontFamilies,
|
102
|
+
activeBreakPoint,
|
103
|
+
setActiveBreakPoint
|
104
|
+
}), [path, editor?.selection, selectedPath, selectedElement, contextMenu, openAI, popupType, drop, activeBreakPoint]);
|
102
105
|
return /*#__PURE__*/_jsx(EditorContext.Provider, {
|
103
106
|
value: otherValues,
|
104
107
|
children: children
|
@@ -0,0 +1,210 @@
|
|
1
|
+
import { ClickAwayListener } from "@mui/material";
|
2
|
+
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
3
|
+
import { clearCellText } from "../utils/table";
|
4
|
+
import { Editor, Element, Transforms } from "slate";
|
5
|
+
import { DndContext, DragOverlay, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
|
6
|
+
import { encodeToBase64, isHavingSelection } from "../utils/helper";
|
7
|
+
import { serializeToText } from "../utils/serializeToText";
|
8
|
+
import { createCopiedTableStructure, getRectangleBounds, tableNodeToDom } from "../Elements/Table/tableHelper";
|
9
|
+
|
10
|
+
// const selectFirstCell = (tablePath, editor, updateTableSelection) => {
|
11
|
+
// const firstCell = [...tablePath, 0, 0];
|
12
|
+
|
13
|
+
// const end = Editor.end(editor, firstCell);
|
14
|
+
|
15
|
+
// Transforms.select(editor, {
|
16
|
+
// anchor: end,
|
17
|
+
// focus: end,
|
18
|
+
// });
|
19
|
+
|
20
|
+
// updateTableSelection({
|
21
|
+
// startCellPath: firstCell,
|
22
|
+
// endCellPath: [],
|
23
|
+
// isDragging: false,
|
24
|
+
// });
|
25
|
+
// };
|
26
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
27
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
28
|
+
const handleDragEnd = (dragData, editor, resetAll) => {
|
29
|
+
const {
|
30
|
+
active,
|
31
|
+
over
|
32
|
+
} = dragData;
|
33
|
+
if (over) {
|
34
|
+
const {
|
35
|
+
dragType,
|
36
|
+
path: startCellPath
|
37
|
+
} = active?.data?.current || {};
|
38
|
+
const {
|
39
|
+
path: overCellPath
|
40
|
+
} = over?.data?.current || {};
|
41
|
+
if (startCellPath?.length) {
|
42
|
+
if (dragType === "row") {
|
43
|
+
const startRowPath = startCellPath.slice(0, -1);
|
44
|
+
const overRowPath = overCellPath.slice(0, -1);
|
45
|
+
Transforms.moveNodes(editor, {
|
46
|
+
at: startRowPath,
|
47
|
+
to: overRowPath
|
48
|
+
});
|
49
|
+
} else {
|
50
|
+
const [startCol] = startCellPath.slice(-1);
|
51
|
+
const [overCol] = overCellPath.slice(-1);
|
52
|
+
const [tableData] = Editor.nodes(editor, {
|
53
|
+
at: startCellPath,
|
54
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
55
|
+
});
|
56
|
+
const [tableNode, tablePath] = tableData;
|
57
|
+
const rows = tableNode?.rows || 0;
|
58
|
+
for (let row = 0; row < rows; row++) {
|
59
|
+
const startColPath = [...tablePath, row, startCol];
|
60
|
+
const overColPath = [...tablePath, row, overCol];
|
61
|
+
Transforms.moveNodes(editor, {
|
62
|
+
at: startColPath,
|
63
|
+
to: overColPath
|
64
|
+
});
|
65
|
+
}
|
66
|
+
}
|
67
|
+
resetAll();
|
68
|
+
}
|
69
|
+
}
|
70
|
+
};
|
71
|
+
const TableContext = /*#__PURE__*/createContext();
|
72
|
+
export function getDefaultTableSelection() {
|
73
|
+
return {
|
74
|
+
startCellPath: [],
|
75
|
+
endCellPath: [],
|
76
|
+
isDragging: false
|
77
|
+
};
|
78
|
+
}
|
79
|
+
export const TableProvider = ({
|
80
|
+
editor,
|
81
|
+
children,
|
82
|
+
otherProps = {}
|
83
|
+
}) => {
|
84
|
+
const [hoverPath, setHoverPath] = useState(null);
|
85
|
+
const [tableSelection, setTableSelection] = useState(getDefaultTableSelection());
|
86
|
+
const [tableResizing, setTableResizing] = useState(null);
|
87
|
+
|
88
|
+
// for the button events (like onclick,...etc) inside draggable component to work correctly
|
89
|
+
const sensors = useSensors(useSensor(PointerSensor, {
|
90
|
+
activationConstraint: {
|
91
|
+
delay: 250,
|
92
|
+
distance: 0 // throws exceeded distance error
|
93
|
+
}
|
94
|
+
}));
|
95
|
+
|
96
|
+
const getSelectedCells = () => {
|
97
|
+
return getRectangleBounds(tableSelection);
|
98
|
+
};
|
99
|
+
const updateTableSelection = update => {
|
100
|
+
setTableSelection(prev => ({
|
101
|
+
...prev,
|
102
|
+
...update
|
103
|
+
}));
|
104
|
+
};
|
105
|
+
const resetAll = () => {
|
106
|
+
setTableSelection(getDefaultTableSelection());
|
107
|
+
Transforms.deselect(editor);
|
108
|
+
|
109
|
+
// hide drag icons after drag completion
|
110
|
+
setTimeout(() => setHoverPath(null), 200);
|
111
|
+
};
|
112
|
+
const values = useMemo(() => {
|
113
|
+
return {
|
114
|
+
hoverPath,
|
115
|
+
setHoverPath,
|
116
|
+
editor,
|
117
|
+
getSelectedCells,
|
118
|
+
updateTableSelection,
|
119
|
+
tableSelection,
|
120
|
+
tableResizing,
|
121
|
+
setTableResizing,
|
122
|
+
otherProps,
|
123
|
+
resetAll
|
124
|
+
};
|
125
|
+
}, [hoverPath, editor?.selection, tableSelection, tableResizing]);
|
126
|
+
useEffect(() => {
|
127
|
+
let isTextSelected;
|
128
|
+
const handleKeyDown = event => {
|
129
|
+
const isCutKey = (event.ctrlKey || event.metaKey) && event.key === "x";
|
130
|
+
if (isCutKey) {
|
131
|
+
isTextSelected = isHavingSelection(editor);
|
132
|
+
} else if (event.key === "Backspace") {
|
133
|
+
const selectedCells = getSelectedCells();
|
134
|
+
if (selectedCells?.length > 1) {
|
135
|
+
selectedCells.forEach(currentCellPath => {
|
136
|
+
clearCellText(editor, currentCellPath);
|
137
|
+
});
|
138
|
+
}
|
139
|
+
}
|
140
|
+
};
|
141
|
+
const handleCopy = (event, isCut) => {
|
142
|
+
try {
|
143
|
+
const isTextSelected = isHavingSelection(editor);
|
144
|
+
const {
|
145
|
+
startCellPath
|
146
|
+
} = tableSelection || {};
|
147
|
+
const customCopy = startCellPath?.length;
|
148
|
+
if (customCopy && !isTextSelected) {
|
149
|
+
event.preventDefault(); // Prevent default copy behavior
|
150
|
+
|
151
|
+
const {
|
152
|
+
tablePath
|
153
|
+
} = otherProps;
|
154
|
+
const [node] = Editor.node(editor, tablePath);
|
155
|
+
const copiedTableNode = createCopiedTableStructure(editor, tableSelection, node, tablePath);
|
156
|
+
const tableNode = [copiedTableNode];
|
157
|
+
const encodedTableNode = encodeToBase64(tableNode);
|
158
|
+
event.clipboardData.setData("application/x-slate-fragment", encodedTableNode);
|
159
|
+
const textData = serializeToText(tableNode);
|
160
|
+
event.clipboardData.setData("text/plain", textData);
|
161
|
+
const tableDom = tableNodeToDom(copiedTableNode);
|
162
|
+
event.clipboardData.setData("text/html", tableDom?.outerHTML);
|
163
|
+
if (isCut) {
|
164
|
+
clearCellText(editor, startCellPath);
|
165
|
+
}
|
166
|
+
}
|
167
|
+
} catch (err) {
|
168
|
+
console.log(err);
|
169
|
+
}
|
170
|
+
};
|
171
|
+
const handleCut = e => {
|
172
|
+
// unable to find the text selected or not here, that why handling it on handleKeyDown
|
173
|
+
|
174
|
+
if (!isTextSelected) {
|
175
|
+
e.preventDefault();
|
176
|
+
handleCopy(e, true);
|
177
|
+
}
|
178
|
+
};
|
179
|
+
window.addEventListener("keydown", handleKeyDown);
|
180
|
+
window.addEventListener("copy", handleCopy);
|
181
|
+
window.addEventListener("cut", handleCut);
|
182
|
+
return () => {
|
183
|
+
window.removeEventListener("keydown", handleKeyDown);
|
184
|
+
window.removeEventListener("copy", handleCopy);
|
185
|
+
window.removeEventListener("cut", handleCut);
|
186
|
+
};
|
187
|
+
}, [tableSelection, editor, tableSelection]);
|
188
|
+
|
189
|
+
// useEffect(() => {
|
190
|
+
// selectFirstCell(tablePath, editor, updateTableSelection);
|
191
|
+
// }, []);
|
192
|
+
|
193
|
+
return /*#__PURE__*/_jsx(TableContext.Provider, {
|
194
|
+
value: values,
|
195
|
+
children: /*#__PURE__*/_jsxs(DndContext, {
|
196
|
+
sensors: sensors,
|
197
|
+
onDragEnd: data => handleDragEnd(data, editor, resetAll),
|
198
|
+
children: [/*#__PURE__*/_jsx(ClickAwayListener, {
|
199
|
+
onClickAway: () => setTableSelection(getDefaultTableSelection()),
|
200
|
+
children: /*#__PURE__*/_jsx("div", {
|
201
|
+
children: children
|
202
|
+
})
|
203
|
+
}), /*#__PURE__*/_jsx(DragOverlay, {})]
|
204
|
+
})
|
205
|
+
});
|
206
|
+
};
|
207
|
+
function useTable() {
|
208
|
+
return useContext(TableContext);
|
209
|
+
}
|
210
|
+
export default useTable;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { Editor, Node, Path, Point, Transforms } from "slate";
|
2
|
-
import { getNextNode } from "../utils/helper";
|
1
|
+
import { Editor, Node, Path, Point, Range, Transforms } from "slate";
|
2
|
+
import { containsSurrogatePair, getNextNode } from "../utils/helper";
|
3
|
+
const BACKWARD_BLOCKS = ["list-item", "signature"];
|
3
4
|
const isNodeTextEmpty = node => {
|
4
5
|
const nodeText = Node.string(node);
|
5
6
|
return nodeText.trim() === "";
|
@@ -28,10 +29,41 @@ const withCustomDeleteBackward = editor => {
|
|
28
29
|
return;
|
29
30
|
}
|
30
31
|
}
|
32
|
+
if (selection && Range.isCollapsed(selection)) {
|
33
|
+
const [currentNode, path] = Editor.node(editor, selection);
|
34
|
+
if (currentNode && typeof currentNode.text === 'string') {
|
35
|
+
const text = currentNode.text;
|
36
|
+
if (containsSurrogatePair(text)) {
|
37
|
+
// Check if the cursor is at the end of a surrogate pair
|
38
|
+
const {
|
39
|
+
offset
|
40
|
+
} = selection.anchor;
|
41
|
+
const beforeCursor = text.slice(0, offset);
|
42
|
+
const afterCursor = text.slice(offset);
|
43
|
+
if (containsSurrogatePair(beforeCursor) || containsSurrogatePair(afterCursor)) {
|
44
|
+
// Delete the entire surrogate pair
|
45
|
+
Transforms.delete(editor, {
|
46
|
+
at: {
|
47
|
+
anchor: {
|
48
|
+
path,
|
49
|
+
offset: offset - 2
|
50
|
+
},
|
51
|
+
// Move back 2 for surrogate pair
|
52
|
+
focus: {
|
53
|
+
path,
|
54
|
+
offset
|
55
|
+
}
|
56
|
+
}
|
57
|
+
});
|
58
|
+
return;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
31
63
|
|
32
|
-
// Check if current node is a list item and is the last one
|
64
|
+
// Check if current node is a list item and is the last one, signature node
|
33
65
|
const [node] = Editor.nodes(editor, {
|
34
|
-
match: n => n.type
|
66
|
+
match: n => BACKWARD_BLOCKS.includes(n.type) // Adjust based on your list item type
|
35
67
|
});
|
36
68
|
|
37
69
|
if (node) {
|
@@ -40,32 +40,36 @@ 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
|
-
|
43
|
+
try {
|
44
|
+
const parentPath = Path.parent(editor.selection.focus.path);
|
45
|
+
const parentNode = Node.get(editor, parentPath);
|
46
|
+
if (editor.isVoid(parentNode)) {
|
47
|
+
const nextPath = Path.next(parentPath);
|
48
|
+
Transforms.insertNodes(editor, {
|
49
|
+
type: "paragraph",
|
50
|
+
children: [{
|
51
|
+
text: ""
|
52
|
+
}]
|
53
|
+
}, {
|
54
|
+
at: nextPath,
|
55
|
+
select: true // Focus on this node once inserted
|
56
|
+
});
|
57
|
+
} else if (AvoidCopying.indexOf(parentNode?.type) >= 0) {
|
58
|
+
const nextPath = Path.next(parentPath);
|
59
|
+
Transforms.insertNodes(editor, {
|
60
|
+
type: "paragraph",
|
61
|
+
children: [{
|
62
|
+
text: ""
|
63
|
+
}]
|
64
|
+
}, {
|
65
|
+
at: nextPath,
|
66
|
+
select: true // Focus on this node once inserted
|
67
|
+
});
|
68
|
+
} else {
|
69
|
+
insertBreak(...args);
|
70
|
+
}
|
71
|
+
} catch (err) {
|
72
|
+
console.log(err);
|
69
73
|
}
|
70
74
|
};
|
71
75
|
return editor;
|
@@ -2,6 +2,8 @@ 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 NON_TEXT_TAGS = ["ol", "ul", "img", "table", "video", "a", "button", "GOOGLE-SHEETS-HTML-ORIGIN"];
|
6
|
+
const ALLOWED_TEXT_NODES = ["paragraph", "title", "headingOne", "headingTwo", "headingThree"];
|
5
7
|
const loopChildren = (children = [], defaultInsert) => {
|
6
8
|
if (!children?.length) {
|
7
9
|
return defaultInsert;
|
@@ -61,12 +63,23 @@ const insertAtNextNode = (editor, formattedFragment) => {
|
|
61
63
|
console.log(err);
|
62
64
|
}
|
63
65
|
};
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
|
67
|
+
// const handleInsert = (editor, defaultInsert, fragment = []) => {
|
68
|
+
// if (
|
69
|
+
// getCurrentElementText(editor) &&
|
70
|
+
// fragment.some((f) => f.type === "table")
|
71
|
+
// ) {
|
72
|
+
// insertAtNextNode(editor, fragment);
|
73
|
+
// } else {
|
74
|
+
// defaultInsert();
|
75
|
+
// }
|
76
|
+
// };
|
77
|
+
|
78
|
+
const getTableCellChild = (fragment = []) => {
|
79
|
+
const table = fragment.find(node => node.type === "table");
|
80
|
+
const row = table?.children?.find(node => node.type === "table-row");
|
81
|
+
const cell = row?.children?.find(node => node.type === "table-cell");
|
82
|
+
return cell?.children || [];
|
70
83
|
};
|
71
84
|
const formatFragment = {
|
72
85
|
"list-item": fragment => {
|
@@ -115,8 +128,21 @@ const withHtml = editor => {
|
|
115
128
|
const html = data?.getData("text/html");
|
116
129
|
const currentEl = getCurrentElement(editor);
|
117
130
|
const eltype = currentEl?.type;
|
131
|
+
const firstNode = editor?.children?.[0];
|
132
|
+
const titlePath = firstNode?.type === "topbanner" ? 1 : 0;
|
133
|
+
const isTitlePath = editor.needLayout && editor?.selection?.anchor?.path[0] === titlePath;
|
118
134
|
if (slateHTML && !formatFragment[eltype]) {
|
135
|
+
const [tableCellNode] = Editor.nodes(editor, {
|
136
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
|
137
|
+
});
|
119
138
|
const decoded = decodeAndParseBase64(slateHTML);
|
139
|
+
if (tableCellNode) {
|
140
|
+
const tableCellChild = getTableCellChild(decoded);
|
141
|
+
if (tableCellChild?.length) {
|
142
|
+
Transforms.insertFragment(editor, tableCellChild);
|
143
|
+
return;
|
144
|
+
}
|
145
|
+
}
|
120
146
|
const tableNode = getFocusedNode(editor, "table");
|
121
147
|
const onlyTextNode = getFocusedNode(editor, "freegrid");
|
122
148
|
|
@@ -154,22 +180,38 @@ const withHtml = editor => {
|
|
154
180
|
Transforms.insertText(editor, text);
|
155
181
|
}
|
156
182
|
} else {
|
157
|
-
|
183
|
+
const isTextNode = ALLOWED_TEXT_NODES.includes(decoded?.[0]?.type);
|
184
|
+
if (isTitlePath && !isTextNode) {
|
185
|
+
insertAtNextNode(editor, decoded);
|
186
|
+
return;
|
187
|
+
}
|
188
|
+
const currentText = getCurrentElementText(editor);
|
189
|
+
if (currentText && !isTextNode) {
|
190
|
+
insertAtNextNode(editor, decoded);
|
191
|
+
return;
|
192
|
+
}
|
193
|
+
insertData(data);
|
158
194
|
}
|
159
195
|
} else if (html) {
|
160
196
|
const parsed = new DOMParser().parseFromString(html, "text/html");
|
197
|
+
const rootElement = parsed.body || parsed.documentElement;
|
198
|
+
const isNonText = rootElement ? rootElement?.querySelector(NON_TEXT_TAGS.toString()) : false;
|
161
199
|
const isGoogleSheet = parsed.body.querySelector("google-sheets-html-origin");
|
162
200
|
if (isGoogleSheet) {
|
163
201
|
if (editor.isChatEditor) {
|
164
202
|
return;
|
165
203
|
}
|
166
|
-
const table =
|
204
|
+
const table = rootElement.querySelector("table");
|
167
205
|
const colGrp = table.querySelector("colgroup");
|
168
206
|
if (colGrp) {
|
169
207
|
colGrp.remove();
|
170
208
|
}
|
171
209
|
const fragment = deserialize(table);
|
172
|
-
|
210
|
+
if (isTitlePath) {
|
211
|
+
insertAtNextNode(editor, [fragment]);
|
212
|
+
} else {
|
213
|
+
Transforms.insertFragment(editor, [fragment]);
|
214
|
+
}
|
173
215
|
return;
|
174
216
|
}
|
175
217
|
const fragment = deserialize(parsed.body);
|
@@ -183,7 +225,16 @@ const withHtml = editor => {
|
|
183
225
|
if (editor.isChatEditor && is_img_table) {
|
184
226
|
return;
|
185
227
|
}
|
186
|
-
|
228
|
+
if (isTitlePath && isNonText) {
|
229
|
+
insertAtNextNode(editor, formattedFragment);
|
230
|
+
return;
|
231
|
+
}
|
232
|
+
const currentText = getCurrentElementText(editor);
|
233
|
+
if (currentText && isNonText) {
|
234
|
+
insertAtNextNode(editor, formattedFragment);
|
235
|
+
return;
|
236
|
+
}
|
237
|
+
Transforms.insertFragment(editor, formattedFragment);
|
187
238
|
return;
|
188
239
|
} else {
|
189
240
|
insertData(data);
|
@@ -43,6 +43,9 @@ 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";
|
46
49
|
import SearchAttachment from "../Elements/Search/SearchAttachment";
|
47
50
|
// import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
|
48
51
|
import { jsx as _jsx } from "react/jsx-runtime";
|
@@ -152,7 +155,7 @@ export const activeMark = (editor, format) => {
|
|
152
155
|
const defaultMarkData = {
|
153
156
|
color: "#000000",
|
154
157
|
bgColor: "#FFFFFF",
|
155
|
-
fontSize: "
|
158
|
+
fontSize: "14px",
|
156
159
|
fontFamily: "PoppinsRegular",
|
157
160
|
fontWeight: "normal"
|
158
161
|
};
|
@@ -167,6 +170,16 @@ export const activeMark = (editor, format) => {
|
|
167
170
|
};
|
168
171
|
export const getMarked = (leaf, children, theme) => {
|
169
172
|
const className = leaf?.doublequote ? "doublequote" : "";
|
173
|
+
if (leaf.highlight) {
|
174
|
+
children = /*#__PURE__*/_jsx("span", {
|
175
|
+
style: {
|
176
|
+
color: "inherit"
|
177
|
+
},
|
178
|
+
className: "slate-highlight" // while opening AI, we will use this element to highlight the selection. (PopoverAIInput.js)
|
179
|
+
,
|
180
|
+
children: children
|
181
|
+
});
|
182
|
+
}
|
170
183
|
if (leaf.bold) {
|
171
184
|
children = /*#__PURE__*/_jsx("strong", {
|
172
185
|
children: children
|
@@ -237,21 +250,13 @@ export const getMarked = (leaf, children, theme) => {
|
|
237
250
|
// },
|
238
251
|
...textStyles,
|
239
252
|
fontFamily: family,
|
240
|
-
fontWeight: leaf.fontWeight
|
253
|
+
fontWeight: leaf.fontWeight,
|
254
|
+
WebkitTextFillColor: "unset !important"
|
241
255
|
},
|
242
256
|
children: children
|
243
257
|
})
|
244
258
|
});
|
245
259
|
}
|
246
|
-
if (leaf.highlight) {
|
247
|
-
children = /*#__PURE__*/_jsx("span", {
|
248
|
-
style: {
|
249
|
-
background: "#EAEBFE",
|
250
|
-
color: "inherit"
|
251
|
-
},
|
252
|
-
children: children
|
253
|
-
});
|
254
|
-
}
|
255
260
|
if (leaf.decoration === "link") {
|
256
261
|
children = /*#__PURE__*/_jsx("a", {
|
257
262
|
style: {
|
@@ -309,7 +314,8 @@ export const getBlock = props => {
|
|
309
314
|
borderRadius: `${element?.color ? "0px" : "12px"} 12px 12px ${element?.color ? "0px" : "12px"}`,
|
310
315
|
margin: `${element?.bgColor ? "16px" : "0px"} 0px`,
|
311
316
|
width: element?.bgColor ? "calc(100% - 16px)" : "100%",
|
312
|
-
borderWidth: element?.color ? "0px 0px 0px 3px" : "0px"
|
317
|
+
borderWidth: element?.color ? "0px 0px 0px 3px" : "0px",
|
318
|
+
lineHeight: 1.43
|
313
319
|
},
|
314
320
|
children: children
|
315
321
|
});
|
@@ -369,12 +375,20 @@ export const getBlock = props => {
|
|
369
375
|
});
|
370
376
|
case "orderedList":
|
371
377
|
return /*#__PURE__*/_jsx("ol", {
|
378
|
+
style: {
|
379
|
+
lineHeight: 1.43
|
380
|
+
},
|
381
|
+
className: "listItemMargin",
|
372
382
|
type: "1",
|
373
383
|
...attributes,
|
374
384
|
children: children
|
375
385
|
});
|
376
386
|
case "unorderedList":
|
377
387
|
return /*#__PURE__*/_jsx("ul", {
|
388
|
+
style: {
|
389
|
+
lineHeight: 1.43
|
390
|
+
},
|
391
|
+
className: "listItemMargin",
|
378
392
|
...attributes,
|
379
393
|
children: children
|
380
394
|
});
|
@@ -562,6 +576,19 @@ export const getBlock = props => {
|
|
562
576
|
contentEditable: false,
|
563
577
|
children: children
|
564
578
|
});
|
579
|
+
// Data View
|
580
|
+
case "dataView":
|
581
|
+
return /*#__PURE__*/_jsx(DataView, {
|
582
|
+
...props
|
583
|
+
});
|
584
|
+
case "viewData":
|
585
|
+
return /*#__PURE__*/_jsx(ViewData, {
|
586
|
+
...props
|
587
|
+
});
|
588
|
+
case "columnView":
|
589
|
+
return /*#__PURE__*/_jsx(ColumnView, {
|
590
|
+
...props
|
591
|
+
});
|
565
592
|
default:
|
566
593
|
return /*#__PURE__*/_jsx(SimpleText, {
|
567
594
|
...props,
|
@@ -18,7 +18,7 @@ export const insertBrain = (editor, data, position) => {
|
|
18
18
|
};
|
19
19
|
const [currentNode, currentPath] = Editor.node(editor, selection);
|
20
20
|
console.log('W1', Node.string(currentNode));
|
21
|
-
const cleanedText = Node.string(currentNode).replace(/\/b(?:rain|rai|ra|r)?/g, "").trim();
|
21
|
+
const cleanedText = Node.string(currentNode).replace(/\/(?:b(?:rain|rai|ra|r)?)?/g, "").trim();
|
22
22
|
if (cleanedText) {
|
23
23
|
Transforms.delete(editor, {
|
24
24
|
at: Editor.range(editor, currentPath)
|