@flozy/editor 5.5.9 → 5.6.1
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 +33 -16
- package/dist/Editor/Editor.css +105 -20
- package/dist/Editor/Elements/AI/AIInput.js +0 -1
- package/dist/Editor/Elements/AI/CustomSelect.js +17 -10
- package/dist/Editor/Elements/AI/PopoverAIInput.js +59 -53
- 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 +8 -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 +83 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +33 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +180 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +62 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +68 -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 +86 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +71 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +138 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterView.js +213 -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 +44 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +146 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +79 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +57 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +101 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +174 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +241 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +45 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +32 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/index.js +110 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +217 -0
- package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +131 -0
- package/dist/Editor/Elements/DataView/Layouts/TableView.js +253 -0
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +85 -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 +277 -0
- package/dist/Editor/Elements/DataView/Utils/globalSearch.js +15 -0
- package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +88 -0
- package/dist/Editor/Elements/DataView/styles.js +169 -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/Form/Workflow/Styles.js +2 -0
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +4 -2
- 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 +11 -3
- 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 +88 -78
- package/dist/Editor/Elements/Table/Table.js +263 -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 +21 -2
- 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 +8 -8
- package/dist/Editor/Toolbar/Mini/Styles.js +9 -1
- package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +13 -3
- 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 +557 -58
- package/dist/Editor/Toolbar/PopupTool/TemplateCard.js +1 -1
- 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/ArrowDownIcon.js +25 -0
- package/dist/Editor/assets/svg/ArrowUpIcon.js +25 -0
- package/dist/Editor/assets/svg/BrainIcon.js +2 -2
- package/dist/Editor/assets/svg/CalenderIconTick.js +64 -0
- package/dist/Editor/assets/svg/ChervDown.js +18 -0
- package/dist/Editor/assets/svg/ChervUp.js +18 -0
- package/dist/Editor/assets/svg/DataTableIcon.js +50 -0
- package/dist/Editor/assets/svg/DuplicateIcon.js +23 -0
- package/dist/Editor/assets/svg/EyeIcon.js +23 -0
- package/dist/Editor/assets/svg/EyeSlash.js +43 -0
- package/dist/Editor/assets/svg/HashtagIcon.js +33 -0
- package/dist/Editor/assets/svg/PlusIcon.js +23 -0
- package/dist/Editor/assets/svg/SelectRoundedIcon.js +24 -0
- package/dist/Editor/assets/svg/SettingsIcon.js +4 -4
- package/dist/Editor/assets/svg/SortByIcon.js +33 -0
- package/dist/Editor/assets/svg/TableIcons.js +220 -0
- package/dist/Editor/assets/svg/TickOutlined.js +23 -0
- package/dist/Editor/assets/svg/TrashCanIcon.js +38 -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 +6 -6
- package/dist/Editor/common/Icon.js +54 -21
- 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 +26 -7
- package/dist/Editor/common/RnD/VirtualElement/index.js +5 -1
- package/dist/Editor/common/RnD/index.js +4 -3
- 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 +598 -74
- package/dist/Editor/common/iconslist.js +25 -19
- package/dist/Editor/commonStyle.js +421 -15
- package/dist/Editor/helper/deserialize/index.js +31 -2
- package/dist/Editor/helper/enforceDateFormat.js +41 -0
- package/dist/Editor/helper/index.js +17 -4
- package/dist/Editor/helper/theme.js +39 -2
- package/dist/Editor/hooks/useBreakpoints.js +1 -1
- package/dist/Editor/hooks/useMouseMove.js +5 -2
- package/dist/Editor/hooks/useTable.js +210 -0
- package/dist/Editor/plugins/withCustomDeleteBackward.js +34 -3
- package/dist/Editor/plugins/withEmbeds.js +30 -26
- package/dist/Editor/plugins/withHTML.js +100 -12
- 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 +75 -6
- 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
@@ -1,4 +1,26 @@
|
|
1
1
|
import { jsx } from "slate-hyperscript";
|
2
|
+
const inlineStyles = [{
|
3
|
+
key: "bold",
|
4
|
+
getStyle: styles => styles.fontWeight === "bold" || parseInt(styles.fontWeight, 10) >= 700
|
5
|
+
}, {
|
6
|
+
key: "italic",
|
7
|
+
getStyle: styles => styles.fontStyle === "italic"
|
8
|
+
}, {
|
9
|
+
key: "underline",
|
10
|
+
getStyle: styles => styles.textDecoration.includes("underline")
|
11
|
+
}];
|
12
|
+
function getInlineTextStyles(element) {
|
13
|
+
if (!element || !element.style) return {};
|
14
|
+
const styles = element.style;
|
15
|
+
const elementStyles = inlineStyles.reduce((total, currVal) => {
|
16
|
+
const style = currVal.getStyle(styles);
|
17
|
+
if (style) {
|
18
|
+
total[currVal.key] = style;
|
19
|
+
}
|
20
|
+
return total;
|
21
|
+
}, {});
|
22
|
+
return elementStyles;
|
23
|
+
}
|
2
24
|
const handleTableCell = (el, children) => {
|
3
25
|
const wrapChild = children?.map(c => {
|
4
26
|
if (typeof c === "string") {
|
@@ -14,7 +36,10 @@ const handleTableCell = (el, children) => {
|
|
14
36
|
});
|
15
37
|
return {
|
16
38
|
type: "table-cell",
|
17
|
-
overwriteChild: wrapChild
|
39
|
+
overwriteChild: wrapChild,
|
40
|
+
size: {
|
41
|
+
width: 120
|
42
|
+
}
|
18
43
|
};
|
19
44
|
};
|
20
45
|
const INLINE_TAGS = ["A", "ABBR", "B", "BDO", "CITE", "CODE", "DATA", "DEL", "DFN", "IMG", "INS", "KBD", "LABEL", "MARK", "Q", "SAMP", "SMALL", "SPAN", "SUB", "SUP", "TIME", "VAR"];
|
@@ -135,9 +160,13 @@ const TEXT_TAGS = {
|
|
135
160
|
|
136
161
|
const deserialize = el => {
|
137
162
|
if (el.nodeType === 3) {
|
163
|
+
// if there is any line-breaks
|
138
164
|
const match = /\r|\n/.exec(el.textContent);
|
139
165
|
const text = el.textContent.replace(/\r|\n/g, "").trim();
|
140
|
-
return match && !text ? null :
|
166
|
+
return match && !text ? null : {
|
167
|
+
text,
|
168
|
+
...getInlineTextStyles(el.parentNode)
|
169
|
+
};
|
141
170
|
} else if (el.nodeType !== 1) {
|
142
171
|
return null;
|
143
172
|
} else if (el.nodeName === "BR") {
|
@@ -0,0 +1,41 @@
|
|
1
|
+
function enforceDateFormat(inputElement) {
|
2
|
+
inputElement.addEventListener("input", event => {
|
3
|
+
const input = event.target;
|
4
|
+
let value = input.value;
|
5
|
+
|
6
|
+
// Allow only numbers and forward slashes
|
7
|
+
value = value.replace(/[^\d/]/g, "");
|
8
|
+
|
9
|
+
// Enforce MM/DD/YYYY structure
|
10
|
+
if (value.length > 10) {
|
11
|
+
value = value.slice(0, 10);
|
12
|
+
}
|
13
|
+
const parts = value.split("/");
|
14
|
+
if (parts.length > 1) {
|
15
|
+
parts[0] = parts[0].slice(0, 2); // Limit MM to 2 digits
|
16
|
+
if (parts[0] > 12) parts[0] = "12"; // Max month value
|
17
|
+
}
|
18
|
+
|
19
|
+
if (parts.length > 2) {
|
20
|
+
parts[1] = parts[1].slice(0, 2); // Limit DD to 2 digits
|
21
|
+
if (parts[1] > 31) parts[1] = "31"; // Max day value
|
22
|
+
}
|
23
|
+
|
24
|
+
if (parts.length > 3) {
|
25
|
+
parts[2] = parts[2].slice(0, 4); // Limit YYYY to 4 digits
|
26
|
+
}
|
27
|
+
|
28
|
+
input.value = parts.join("/");
|
29
|
+
|
30
|
+
// Optionally, validate the full date
|
31
|
+
if (input.value.length === 10) {
|
32
|
+
const [month, day, year] = input.value.split("/").map(Number);
|
33
|
+
const isValidDate = !isNaN(Date.parse(`${year}-${month}-${day}`));
|
34
|
+
if (!isValidDate) {
|
35
|
+
input.value = ""; // Clear input if invalid
|
36
|
+
alert("Invalid date format. Please enter a valid MM/DD/YYYY date.");
|
37
|
+
}
|
38
|
+
}
|
39
|
+
});
|
40
|
+
}
|
41
|
+
export default enforceDateFormat;
|
@@ -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
|
};
|
@@ -54,6 +54,20 @@ const overrides = {
|
|
54
54
|
return `${val?.topLeft}px ${val?.topRight}px ${val?.bottomLeft}px ${val?.bottomRight}px`;
|
55
55
|
}
|
56
56
|
};
|
57
|
+
export const checkXS = (val = {}) => {
|
58
|
+
try {
|
59
|
+
if (typeof val === "object") {
|
60
|
+
if (val?.xs === undefined && val?.lg !== undefined) {
|
61
|
+
val.xs = val.lg;
|
62
|
+
}
|
63
|
+
return val;
|
64
|
+
}
|
65
|
+
return val;
|
66
|
+
} catch (err) {
|
67
|
+
console.log(err);
|
68
|
+
return val;
|
69
|
+
}
|
70
|
+
};
|
57
71
|
export const getBreakPointsValue = (value, breakpoint, ot = null, ov = false) => {
|
58
72
|
try {
|
59
73
|
if (breakpoint) {
|
@@ -67,7 +81,7 @@ export const getBreakPointsValue = (value, breakpoint, ot = null, ov = false) =>
|
|
67
81
|
return value ? value[breakpoint] || value["lg"] : value;
|
68
82
|
}
|
69
83
|
} else if (typeof value === "object") {
|
70
|
-
return !breakpoint && value["lg"] ? !ov ? value : overrideValues(value, ot) : value[breakpoint] || copyAllLg(value, ot);
|
84
|
+
return !breakpoint && value["lg"] ? !ov ? value : checkXS(overrideValues(value, ot)) : value[breakpoint] || copyAllLg(value, ot);
|
71
85
|
} else {
|
72
86
|
// consider without breakpoints
|
73
87
|
return copyAllLg(value, ot);
|
@@ -147,4 +161,27 @@ export const groupByBreakpoint = (styleProps, theme) => {
|
|
147
161
|
}
|
148
162
|
};
|
149
163
|
};
|
150
|
-
export const getCustomizationValue = value => isNaN(parseInt(value)) ? null : parseInt(value);
|
164
|
+
export const getCustomizationValue = value => isNaN(parseInt(value)) ? null : parseInt(value);
|
165
|
+
export const getBreakpointLineSpacing = (value, breakpoint) => {
|
166
|
+
try {
|
167
|
+
const values = getBreakPointsValue(value, breakpoint);
|
168
|
+
const cssVal = BREAKPOINTS_DEVICES.reduce((a, b) => {
|
169
|
+
if (values[b] || values["lg"]) {
|
170
|
+
const value = values[b] || values["lg"];
|
171
|
+
return {
|
172
|
+
...a,
|
173
|
+
[b]: value
|
174
|
+
};
|
175
|
+
} else {
|
176
|
+
return a;
|
177
|
+
}
|
178
|
+
}, {});
|
179
|
+
if (breakpoint) {
|
180
|
+
return value[breakpoint] || value["lg"] || value;
|
181
|
+
} else {
|
182
|
+
return cssVal["lg"];
|
183
|
+
}
|
184
|
+
} catch (err) {
|
185
|
+
// console.log(err);
|
186
|
+
}
|
187
|
+
};
|
@@ -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,5 @@
|
|
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
3
|
const BACKWARD_BLOCKS = ["list-item", "signature"];
|
4
4
|
const isNodeTextEmpty = node => {
|
5
5
|
const nodeText = Node.string(node);
|
@@ -30,10 +30,41 @@ const withCustomDeleteBackward = editor => {
|
|
30
30
|
return;
|
31
31
|
}
|
32
32
|
}
|
33
|
+
if (selection && Range.isCollapsed(selection)) {
|
34
|
+
const [currentNode, path] = Editor.node(editor, selection);
|
35
|
+
if (currentNode && typeof currentNode.text === 'string') {
|
36
|
+
const text = currentNode.text;
|
37
|
+
if (containsSurrogatePair(text)) {
|
38
|
+
// Check if the cursor is at the end of a surrogate pair
|
39
|
+
const {
|
40
|
+
offset
|
41
|
+
} = selection.anchor;
|
42
|
+
const beforeCursor = text.slice(0, offset);
|
43
|
+
const afterCursor = text.slice(offset);
|
44
|
+
if (containsSurrogatePair(beforeCursor) || containsSurrogatePair(afterCursor)) {
|
45
|
+
// Delete the entire surrogate pair
|
46
|
+
Transforms.delete(editor, {
|
47
|
+
at: {
|
48
|
+
anchor: {
|
49
|
+
path,
|
50
|
+
offset: offset - 2
|
51
|
+
},
|
52
|
+
// Move back 2 for surrogate pair
|
53
|
+
focus: {
|
54
|
+
path,
|
55
|
+
offset
|
56
|
+
}
|
57
|
+
}
|
58
|
+
});
|
59
|
+
return;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
33
64
|
|
34
65
|
// Check if current node is a list item and is the last one, signature node
|
35
66
|
const [node] = Editor.nodes(editor, {
|
36
|
-
match: n => BACKWARD_BLOCKS
|
67
|
+
match: n => BACKWARD_BLOCKS.includes(n.type) // Adjust based on your list item type
|
37
68
|
});
|
38
69
|
|
39
70
|
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;
|