@flozy/editor 5.1.5 → 5.1.6
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 +15 -9
- package/dist/Editor/Editor.css +56 -12
- package/dist/Editor/Elements/AI/AIInput.js +0 -1
- package/dist/Editor/Elements/AI/CustomSelect.js +17 -10
- package/dist/Editor/Elements/AI/Styles.js +7 -1
- package/dist/Editor/Elements/Button/EditorButton.js +1 -1
- package/dist/Editor/Elements/Carousel/CarouselItem.js +1 -1
- 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 +101 -0
- package/dist/Editor/Elements/DataView/DataViewButton.js +23 -0
- package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +59 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +30 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +140 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +40 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +59 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +26 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +38 -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 +62 -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 +100 -0
- package/dist/Editor/Elements/DataView/Layouts/TableView.js +227 -0
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +70 -0
- package/dist/Editor/Elements/DataView/Layouts/index.js +25 -0
- package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +288 -0
- package/dist/Editor/Elements/DataView/Utils/globalSearch.js +15 -0
- package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +72 -0
- package/dist/Editor/Elements/DataView/styles.js +143 -0
- package/dist/Editor/Elements/Divider/Divider.js +15 -14
- package/dist/Editor/Elements/Form/Form.js +38 -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/Grid/GridButton.js +2 -1
- package/dist/Editor/Elements/Grid/GridItem.js +12 -0
- package/dist/Editor/Elements/Link/LinkButton.js +1 -1
- 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 +13 -48
- package/dist/Editor/Elements/SimpleText/index.js +8 -1
- package/dist/Editor/Elements/SimpleText/style.js +8 -1
- package/dist/Editor/Elements/Table/AddRowCol.js +77 -0
- package/dist/Editor/Elements/Table/DragButton.js +141 -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 +25 -43
- package/dist/Editor/Elements/Table/Table.js +205 -138
- package/dist/Editor/Elements/Table/TableCell.js +355 -102
- 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/Styles/EditorStyles.js +3 -1
- package/dist/Editor/Toolbar/FormatTools/BlockButton.js +10 -0
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +7 -11
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +10 -4
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +3 -0
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +0 -2
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +3 -6
- package/dist/Editor/Toolbar/Mini/Styles.js +4 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +3 -3
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +16 -11
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +416 -49
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +62 -8
- package/dist/Editor/Toolbar/PopupTool/index.js +5 -6
- 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/TableIcons.js +220 -0
- package/dist/Editor/common/ColorPickerButton.js +3 -2
- package/dist/Editor/common/FontLoader/FontLoader.js +4 -4
- package/dist/Editor/common/Icon.js +24 -23
- 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 +152 -7
- 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/SwitchViewport/SwitchViewport.js +14 -2
- 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/fieldTypes/backgroundImage.js +5 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +8 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
- 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 +7 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +5 -2
- package/dist/Editor/common/StyleBuilder/formStyle.js +268 -149
- package/dist/Editor/common/StyleBuilder/index.js +84 -11
- 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/Uploader.js +8 -0
- package/dist/Editor/common/iconListV2.js +378 -40
- package/dist/Editor/common/iconslist.js +23 -17
- package/dist/Editor/commonStyle.js +126 -9
- package/dist/Editor/helper/deserialize/index.js +4 -1
- package/dist/Editor/helper/index.js +2 -2
- package/dist/Editor/helper/theme.js +24 -1
- package/dist/Editor/hooks/useMouseMove.js +5 -2
- package/dist/Editor/hooks/useTable.js +195 -0
- package/dist/Editor/plugins/withCustomDeleteBackward.js +3 -2
- package/dist/Editor/plugins/withHTML.js +17 -1
- package/dist/Editor/plugins/withLayout.js +48 -1
- package/dist/Editor/utils/SlateUtilityFunctions.js +18 -0
- package/dist/Editor/utils/button.js +4 -4
- package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +21 -0
- 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 +67 -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 +1 -1
|
@@ -56,8 +56,55 @@ const withLayout = editor => {
|
|
|
56
56
|
}]
|
|
57
57
|
};
|
|
58
58
|
Transforms.insertNodes(editor, paragraph, {
|
|
59
|
-
at:
|
|
59
|
+
at: [0]
|
|
60
60
|
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const extractFirstText = node => {
|
|
64
|
+
if (node.text) {
|
|
65
|
+
return node.text;
|
|
66
|
+
}
|
|
67
|
+
if (node.children) {
|
|
68
|
+
for (const child of node.children) {
|
|
69
|
+
const text = extractFirstText(child);
|
|
70
|
+
if (text) {
|
|
71
|
+
return text;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return "";
|
|
76
|
+
};
|
|
77
|
+
const extractRemainingNodes = node => {
|
|
78
|
+
if (!node.children) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
const [, ...remainingChildren] = node.children;
|
|
82
|
+
return remainingChildren.map(child => ({
|
|
83
|
+
...child
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
const firstNode = editor.children[0];
|
|
87
|
+
const firstContent = extractFirstText(firstNode);
|
|
88
|
+
if (firstNode.type !== "title") {
|
|
89
|
+
const titleNode = {
|
|
90
|
+
type: "title",
|
|
91
|
+
children: [{
|
|
92
|
+
text: firstContent
|
|
93
|
+
}]
|
|
94
|
+
};
|
|
95
|
+
Transforms.removeNodes(editor, {
|
|
96
|
+
at: [0]
|
|
97
|
+
});
|
|
98
|
+
Transforms.insertNodes(editor, titleNode, {
|
|
99
|
+
at: [0],
|
|
100
|
+
select: true
|
|
101
|
+
});
|
|
102
|
+
const remainingNodes = extractRemainingNodes(firstNode);
|
|
103
|
+
if (remainingNodes.length > 0) {
|
|
104
|
+
Transforms.insertNodes(editor, remainingNodes, {
|
|
105
|
+
at: [1]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
61
108
|
}
|
|
62
109
|
ORDERS_LAYOUT.forEach((enforce, index) => {
|
|
63
110
|
if (index < editor.children.length) {
|
|
@@ -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";
|
|
@@ -369,12 +372,14 @@ export const getBlock = props => {
|
|
|
369
372
|
});
|
|
370
373
|
case "orderedList":
|
|
371
374
|
return /*#__PURE__*/_jsx("ol", {
|
|
375
|
+
className: "listItemMargin",
|
|
372
376
|
type: "1",
|
|
373
377
|
...attributes,
|
|
374
378
|
children: children
|
|
375
379
|
});
|
|
376
380
|
case "unorderedList":
|
|
377
381
|
return /*#__PURE__*/_jsx("ul", {
|
|
382
|
+
className: "listItemMargin",
|
|
378
383
|
...attributes,
|
|
379
384
|
children: children
|
|
380
385
|
});
|
|
@@ -562,6 +567,19 @@ export const getBlock = props => {
|
|
|
562
567
|
contentEditable: false,
|
|
563
568
|
children: children
|
|
564
569
|
});
|
|
570
|
+
// Data View
|
|
571
|
+
case "dataView":
|
|
572
|
+
return /*#__PURE__*/_jsx(DataView, {
|
|
573
|
+
...props
|
|
574
|
+
});
|
|
575
|
+
case "viewData":
|
|
576
|
+
return /*#__PURE__*/_jsx(ViewData, {
|
|
577
|
+
...props
|
|
578
|
+
});
|
|
579
|
+
case "columnView":
|
|
580
|
+
return /*#__PURE__*/_jsx(ColumnView, {
|
|
581
|
+
...props
|
|
582
|
+
});
|
|
565
583
|
default:
|
|
566
584
|
return /*#__PURE__*/_jsx(SimpleText, {
|
|
567
585
|
...props,
|
|
@@ -15,6 +15,20 @@ const LIST_FORMAT_TYPE = {
|
|
|
15
15
|
unorderedList: "list-item"
|
|
16
16
|
};
|
|
17
17
|
const NEWLINESAFTER = ["headingOne", "headingTwo", "headingThree"];
|
|
18
|
+
export const serializeMentions = node => {
|
|
19
|
+
try {
|
|
20
|
+
if (node?.type === 'mention') {
|
|
21
|
+
return [node.character];
|
|
22
|
+
}
|
|
23
|
+
let children = Array.isArray(node) ? node : node?.children;
|
|
24
|
+
children = children && Array.isArray(children) ? children : [];
|
|
25
|
+
let mentions = children.map(child => serializeMentions(child)).flat();
|
|
26
|
+
return mentions.filter(Boolean);
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.log(err);
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
18
32
|
export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
19
33
|
const isActive = isBlockActive(editor, format);
|
|
20
34
|
const isList = list_types.includes(format);
|
|
@@ -245,6 +259,13 @@ export const getBlock = props => {
|
|
|
245
259
|
,
|
|
246
260
|
children: children
|
|
247
261
|
});
|
|
262
|
+
case "title":
|
|
263
|
+
return /*#__PURE__*/_jsx("h3", {
|
|
264
|
+
...attributes,
|
|
265
|
+
...element.attr,
|
|
266
|
+
className: `content-editable ${isEmpty ? "empty" : ""}`,
|
|
267
|
+
children: children
|
|
268
|
+
});
|
|
248
269
|
case "headingThree":
|
|
249
270
|
return /*#__PURE__*/_jsx("h3", {
|
|
250
271
|
...attributes,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Transforms } from "slate";
|
|
2
|
+
const getDefaultDatView = () => ({
|
|
3
|
+
type: "paragraph",
|
|
4
|
+
children: [{
|
|
5
|
+
type: "dataView",
|
|
6
|
+
title: "",
|
|
7
|
+
layouts: [{
|
|
8
|
+
key: "view1",
|
|
9
|
+
type: "table",
|
|
10
|
+
label: "Table 1 View",
|
|
11
|
+
value: "table1",
|
|
12
|
+
filter: [],
|
|
13
|
+
sort: []
|
|
14
|
+
}],
|
|
15
|
+
properties: [{
|
|
16
|
+
key: "column1",
|
|
17
|
+
label: "Task",
|
|
18
|
+
type: "text",
|
|
19
|
+
visible: true,
|
|
20
|
+
default: true
|
|
21
|
+
}],
|
|
22
|
+
rows: [{
|
|
23
|
+
id: new Date().getTime(),
|
|
24
|
+
column1: ""
|
|
25
|
+
}],
|
|
26
|
+
children: [{
|
|
27
|
+
type: "viewData",
|
|
28
|
+
children: [{
|
|
29
|
+
text: ""
|
|
30
|
+
}]
|
|
31
|
+
}]
|
|
32
|
+
}]
|
|
33
|
+
});
|
|
34
|
+
export const insertDataView = editor => {
|
|
35
|
+
try {
|
|
36
|
+
Transforms.insertNodes(editor, {
|
|
37
|
+
...getDefaultDatView()
|
|
38
|
+
});
|
|
39
|
+
Transforms.move(editor);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.log(err);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transforms } from "slate";
|
|
2
|
-
import insertNewLine from "./insertNewLine";
|
|
2
|
+
import insertNewLine, { insertNewLineAfterCurrentPath } from "./insertNewLine";
|
|
3
3
|
export const insertDefaultEmbed = (editor, type, defaultURL = "", extProps = {}) => {
|
|
4
4
|
try {
|
|
5
5
|
const url = defaultURL ? defaultURL : type === "image" ? "" : "";
|
|
@@ -56,6 +56,7 @@ export const insertEmbed = (editor, embedData, format) => {
|
|
|
56
56
|
at: editor.selection.anchor.path
|
|
57
57
|
});
|
|
58
58
|
insertNewLine(editor);
|
|
59
|
+
insertNewLineAfterCurrentPath(editor);
|
|
59
60
|
} catch (err) {
|
|
60
61
|
console.log(err);
|
|
61
62
|
}
|
|
@@ -5,7 +5,6 @@ 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";
|
|
9
8
|
const HOTKEYS = {
|
|
10
9
|
b: "bold",
|
|
11
10
|
i: "italic",
|
|
@@ -60,7 +60,14 @@ export const signedTextFonts = Object.keys(fontFamilyMap).slice(-12).map(m => {
|
|
|
60
60
|
};
|
|
61
61
|
});
|
|
62
62
|
export const headingMap = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
63
|
+
headingOne: "32px",
|
|
64
|
+
headingTwo: "24px",
|
|
65
|
+
headingThree: "19px"
|
|
66
|
+
};
|
|
67
|
+
export const fontWeightOptions = [{
|
|
68
|
+
text: "Bold",
|
|
69
|
+
value: "500"
|
|
70
|
+
}, {
|
|
71
|
+
text: "Bolder",
|
|
72
|
+
value: "600"
|
|
73
|
+
}];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transforms } from "slate";
|
|
2
|
-
export const formField =
|
|
2
|
+
export const formField = data => {
|
|
3
3
|
return {
|
|
4
4
|
type: "form-field",
|
|
5
5
|
grid: 6,
|
|
@@ -12,14 +12,18 @@ export const formField = () => {
|
|
|
12
12
|
text: ""
|
|
13
13
|
}],
|
|
14
14
|
field_type: "text",
|
|
15
|
-
bgColor: "rgba(255, 255, 255, 1)",
|
|
16
|
-
borderColor: "#ccc",
|
|
15
|
+
bgColor: data?.bgColor ? data?.bgColor : "rgba(255, 255, 255, 1)",
|
|
16
|
+
borderColor: data?.borderColor ? data?.borderColor : "#ccc",
|
|
17
17
|
bannerSpacing: {
|
|
18
18
|
left: 16,
|
|
19
19
|
right: 16,
|
|
20
20
|
top: 16,
|
|
21
21
|
bottom: 16
|
|
22
|
-
}
|
|
22
|
+
},
|
|
23
|
+
fontFamily: data?.fontFamily ? data?.fontFamily : "",
|
|
24
|
+
textSize: data?.textSize ? data?.textSize : "",
|
|
25
|
+
textColor: data?.textColor ? data?.textColor : "",
|
|
26
|
+
fontWeight: data?.fontWeight ? data?.fontWeight : "500"
|
|
23
27
|
};
|
|
24
28
|
};
|
|
25
29
|
export const insertGridItem = editor => {
|
|
@@ -212,7 +212,7 @@ export const isListItem = editor => {
|
|
|
212
212
|
});
|
|
213
213
|
return node;
|
|
214
214
|
};
|
|
215
|
-
const getNode = (editor, path) => {
|
|
215
|
+
export const getNode = (editor, path) => {
|
|
216
216
|
try {
|
|
217
217
|
return Node.get(editor, path);
|
|
218
218
|
} catch (err) {
|
|
@@ -264,6 +264,17 @@ export const decodeAndParseBase64 = encodedString => {
|
|
|
264
264
|
const jsonData = JSON.parse(decodedURLString);
|
|
265
265
|
return jsonData;
|
|
266
266
|
};
|
|
267
|
+
export const encodeToBase64 = data => {
|
|
268
|
+
// Convert the data to a JSON string
|
|
269
|
+
const jsonString = JSON.stringify(data);
|
|
270
|
+
|
|
271
|
+
// URL-encode the JSON string
|
|
272
|
+
const encodedURLString = encodeURIComponent(jsonString);
|
|
273
|
+
|
|
274
|
+
// Base64-encode the URL-encoded string
|
|
275
|
+
const base64EncodedString = btoa(encodedURLString);
|
|
276
|
+
return base64EncodedString;
|
|
277
|
+
};
|
|
267
278
|
export const hasVerticalScrollbar = (element = {}) => {
|
|
268
279
|
return element.scrollHeight > element.clientHeight;
|
|
269
280
|
};
|
|
@@ -611,4 +622,58 @@ export const isPageSettings = (event, editor) => {
|
|
|
611
622
|
isPageSettingsNode = true;
|
|
612
623
|
return isPageSettingsNode;
|
|
613
624
|
}
|
|
614
|
-
};
|
|
625
|
+
};
|
|
626
|
+
export function capitalizeFirstLetter(str) {
|
|
627
|
+
if (!str) return str;
|
|
628
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
629
|
+
}
|
|
630
|
+
export const insertLineBreakAtEndOfPath = (editor, path) => {
|
|
631
|
+
try {
|
|
632
|
+
const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
|
|
633
|
+
if (node) {
|
|
634
|
+
// Insert the line break
|
|
635
|
+
Transforms.insertNodes(editor, {
|
|
636
|
+
type: "paragraph",
|
|
637
|
+
children: [{
|
|
638
|
+
text: ""
|
|
639
|
+
}]
|
|
640
|
+
}, {
|
|
641
|
+
at: nodePath
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
} catch (err) {
|
|
645
|
+
console.log(err);
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
export function isHavingSelection(editor) {
|
|
649
|
+
try {
|
|
650
|
+
return editor?.selection && !Range.isCollapsed(editor.selection);
|
|
651
|
+
} catch (err) {
|
|
652
|
+
console.log(err);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
export function getInitialValue(value = [], readOnly) {
|
|
656
|
+
if (readOnly === "readonly" && value?.length) {
|
|
657
|
+
// remove last empty nodes on readonly mode, to remove empty spaces
|
|
658
|
+
|
|
659
|
+
let lastNonEmptyElementIndex;
|
|
660
|
+
for (let i = value?.length; i > 0; i--) {
|
|
661
|
+
const elementIndex = i - 1;
|
|
662
|
+
const node = value[elementIndex];
|
|
663
|
+
if (lastNonEmptyElementIndex) {
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
if (node?.type === "paragraph") {
|
|
667
|
+
// Ensure all children of the paragraph node are text nodes
|
|
668
|
+
const hasOnlyTextChildren = node.children.every(child => Text.isText(child));
|
|
669
|
+
const text = node.children[node.children.length - 1]?.text;
|
|
670
|
+
lastNonEmptyElementIndex = hasOnlyTextChildren ? text ? elementIndex : null : elementIndex;
|
|
671
|
+
} else {
|
|
672
|
+
lastNonEmptyElementIndex = elementIndex;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
const newValue = [...value].slice(0, lastNonEmptyElementIndex + 1);
|
|
676
|
+
return newValue;
|
|
677
|
+
}
|
|
678
|
+
return value;
|
|
679
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transforms } from "slate";
|
|
1
|
+
import { Editor, Element, Path, Transforms } from "slate";
|
|
2
2
|
const insertNewLine = editor => {
|
|
3
3
|
Transforms.insertNodes(editor, {
|
|
4
4
|
type: "paragraph",
|
|
@@ -9,4 +9,22 @@ const insertNewLine = editor => {
|
|
|
9
9
|
at: [editor.children.length]
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
|
+
export const insertNewLineAfterCurrentPath = editor => {
|
|
13
|
+
const currentPath = editor?.selection?.anchor?.path;
|
|
14
|
+
const [tableNode] = Editor.nodes(editor, {
|
|
15
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
|
16
|
+
});
|
|
17
|
+
if (currentPath && tableNode) {
|
|
18
|
+
const currentParentPath = Path.parent(currentPath);
|
|
19
|
+
const nextPath = Path.next(currentParentPath);
|
|
20
|
+
Transforms.insertNodes(editor, {
|
|
21
|
+
type: "paragraph",
|
|
22
|
+
children: [{
|
|
23
|
+
text: ""
|
|
24
|
+
}]
|
|
25
|
+
}, {
|
|
26
|
+
at: nextPath
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
12
30
|
export default insertNewLine;
|
|
@@ -9,7 +9,13 @@ export const findPageSettings = editor => {
|
|
|
9
9
|
path: null,
|
|
10
10
|
element: {
|
|
11
11
|
pageProps: {
|
|
12
|
-
pageWidth: "fixed"
|
|
12
|
+
pageWidth: "fixed",
|
|
13
|
+
"lineHeight": {
|
|
14
|
+
"xs": 1.43,
|
|
15
|
+
"sm": 1.43,
|
|
16
|
+
"md": 1.43,
|
|
17
|
+
"lg": 1.43
|
|
18
|
+
}
|
|
13
19
|
}
|
|
14
20
|
}
|
|
15
21
|
};
|
|
@@ -34,7 +40,13 @@ export const getPageSettings = editor => {
|
|
|
34
40
|
path: null,
|
|
35
41
|
element: {
|
|
36
42
|
pageProps: {
|
|
37
|
-
pageWidth: "fixed"
|
|
43
|
+
pageWidth: "fixed",
|
|
44
|
+
"lineHeight": {
|
|
45
|
+
"xs": 1.43,
|
|
46
|
+
"sm": 1.43,
|
|
47
|
+
"md": 1.43,
|
|
48
|
+
"lg": 1.43
|
|
49
|
+
}
|
|
38
50
|
}
|
|
39
51
|
}
|
|
40
52
|
};
|
|
@@ -2,6 +2,8 @@ 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 || '';
|
|
5
7
|
}
|
|
6
8
|
let n = Array.isArray(node) ? node : node?.children;
|
|
7
9
|
n = n && Array.isArray(n) ? n : n ? [n] : [];
|