@flozy/editor 5.4.0 → 5.4.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 +34 -25
- package/dist/Editor/CommonEditor.js +15 -29
- package/dist/Editor/Editor.css +18 -100
- package/dist/Editor/Elements/AI/AIInput.js +1 -0
- package/dist/Editor/Elements/AI/CustomSelect.js +11 -19
- package/dist/Editor/Elements/AI/PopoverAIInput.js +52 -58
- package/dist/Editor/Elements/AI/Styles.js +6 -24
- package/dist/Editor/Elements/Accordion/Accordion.js +1 -8
- package/dist/Editor/Elements/AppHeader/AppHeader.js +6 -6
- package/dist/Editor/Elements/Button/EditorButton.js +2 -9
- package/dist/Editor/Elements/Carousel/CarouselItem.js +3 -11
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +5 -7
- package/dist/Editor/Elements/Color Picker/Styles.js +3 -7
- package/dist/Editor/Elements/Color Picker/defaultColors.js +2 -2
- package/dist/Editor/Elements/Divider/Divider.js +20 -36
- package/dist/Editor/Elements/Embed/Image.js +16 -51
- package/dist/Editor/Elements/Embed/Video.js +3 -26
- package/dist/Editor/Elements/Form/Form.js +2 -39
- package/dist/Editor/Elements/Form/FormElements/FormCheckbox.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormDate.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormEmail.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormNumbers.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormRadioButton.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormText.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +1 -6
- package/dist/Editor/Elements/Form/FormPopup.js +9 -12
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -20
- package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +4 -4
- package/dist/Editor/Elements/FreeGrid/styles.js +1 -2
- package/dist/Editor/Elements/Grid/GridButton.js +2 -2
- package/dist/Editor/Elements/Grid/GridItem.js +36 -47
- package/dist/Editor/Elements/Grid/Styles.js +0 -50
- package/dist/Editor/Elements/Link/LinkButton.js +1 -1
- package/dist/Editor/Elements/List/CheckList.js +1 -2
- package/dist/Editor/Elements/Search/SearchAttachment.js +0 -1
- package/dist/Editor/Elements/Search/SearchButton.js +0 -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 +52 -17
- package/dist/Editor/Elements/SimpleText/index.js +1 -8
- package/dist/Editor/Elements/SimpleText/style.js +1 -20
- package/dist/Editor/Elements/Table/Styles.js +79 -82
- package/dist/Editor/Elements/Table/Table.js +140 -258
- package/dist/Editor/Elements/Table/TableCell.js +111 -365
- package/dist/Editor/Elements/Table/TablePopup.js +3 -9
- package/dist/Editor/Elements/Table/TableRow.js +2 -10
- package/dist/Editor/Elements/TopBanner/TopBanner.js +1 -2
- package/dist/Editor/MiniEditor.js +1 -15
- package/dist/Editor/Styles/EditorStyles.js +4 -13
- package/dist/Editor/Toolbar/FormatTools/BlockButton.js +0 -10
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +12 -7
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -26
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +0 -3
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +5 -5
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +6 -3
- package/dist/Editor/Toolbar/Mini/Styles.js +1 -4
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/InfinityAITool.js +3 -7
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -6
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +15 -19
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +57 -555
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +16 -73
- package/dist/Editor/Toolbar/PopupTool/index.js +5 -3
- package/dist/Editor/Toolbar/Toolbar.js +0 -6
- package/dist/Editor/Toolbar/toolbarGroups.js +0 -4
- package/dist/Editor/assets/svg/BrainIcon.js +2 -2
- package/dist/Editor/assets/svg/SettingsIcon.js +4 -4
- package/dist/Editor/common/ColorPickerButton.js +45 -85
- package/dist/Editor/common/DnD/Draggable.js +1 -2
- package/dist/Editor/common/FontLoader/FontLoader.js +4 -4
- package/dist/Editor/common/Icon.js +20 -23
- package/dist/Editor/common/ImageSelector/Options/Upload.js +1 -2
- package/dist/Editor/common/ImageSelector/Styles.js +6 -47
- package/dist/Editor/common/ImageSelector/UploadStyles.js +6 -18
- package/dist/Editor/common/LinkSettings/NavComponents.js +1 -2
- package/dist/Editor/common/LinkSettings/index.js +1 -2
- package/dist/Editor/common/MentionsPopup/Styles.js +8 -143
- package/dist/Editor/common/MentionsPopup/index.js +1 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +12 -108
- package/dist/Editor/common/RnD/GuideLines/styles.js +3 -3
- package/dist/Editor/common/RnD/ShadowElement.js +1 -1
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -14
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +6 -9
- package/dist/Editor/common/RnD/VirtualElement/index.js +1 -5
- package/dist/Editor/common/RnD/index.js +2 -3
- package/dist/Editor/common/Section/index.js +3 -3
- package/dist/Editor/common/Section/styles.js +1 -5
- package/dist/Editor/common/Shorthands/elements.js +1 -13
- package/dist/Editor/common/StyleBuilder/fieldStyle.js +1 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +3 -9
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +7 -35
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +2 -15
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +2 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +1 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +1 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +0 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/radiusStyle.js +11 -11
- package/dist/Editor/common/StyleBuilder/fieldTypes/saveAsTemplate.js +6 -22
- package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +2 -21
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +4 -20
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +2 -12
- package/dist/Editor/common/StyleBuilder/formStyle.js +149 -268
- package/dist/Editor/common/StyleBuilder/index.js +20 -101
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +0 -4
- package/dist/Editor/common/StyleBuilder/tableStyle.js +25 -69
- package/dist/Editor/common/SwipeableDrawer/style.js +4 -15
- package/dist/Editor/common/ToolbarIcon.js +1 -1
- package/dist/Editor/common/Uploader.js +36 -46
- package/dist/Editor/common/iconListV2.js +60 -616
- package/dist/Editor/common/iconslist.js +17 -23
- package/dist/Editor/commonStyle.js +11 -417
- package/dist/Editor/helper/deserialize/index.js +1 -4
- package/dist/Editor/helper/index.js +4 -17
- package/dist/Editor/helper/theme.js +1 -24
- package/dist/Editor/hooks/useMouseMove.js +2 -5
- package/dist/Editor/plugins/withCustomDeleteBackward.js +4 -36
- package/dist/Editor/plugins/withEmbeds.js +26 -30
- package/dist/Editor/plugins/withHTML.js +10 -61
- package/dist/Editor/plugins/withLayout.js +0 -1
- package/dist/Editor/utils/SlateUtilityFunctions.js +12 -39
- package/dist/Editor/utils/brains.js +1 -1
- package/dist/Editor/utils/button.js +4 -4
- package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +1 -26
- package/dist/Editor/utils/customHooks/useResize.js +4 -7
- package/dist/Editor/utils/customHooks/useTableResize.js +2 -6
- package/dist/Editor/utils/embed.js +1 -2
- package/dist/Editor/utils/events.js +1 -0
- package/dist/Editor/utils/font.js +4 -11
- package/dist/Editor/utils/formfield.js +4 -8
- package/dist/Editor/utils/helper.js +2 -103
- package/dist/Editor/utils/insertNewLine.js +1 -19
- package/dist/Editor/utils/pageSettings.js +2 -14
- package/dist/Editor/utils/serializeToText.js +0 -2
- package/dist/Editor/utils/table.js +24 -228
- package/package.json +2 -2
- package/dist/Editor/Elements/DataView/DataView.js +0 -124
- package/dist/Editor/Elements/DataView/DataViewButton.js +0 -23
- package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +0 -67
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +0 -33
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +0 -162
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +0 -40
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +0 -67
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +0 -35
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +0 -39
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +0 -30
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +0 -30
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +0 -35
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +0 -36
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +0 -17
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +0 -29
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +0 -38
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +0 -74
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +0 -64
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +0 -106
- package/dist/Editor/Elements/DataView/Layouts/FilterView.js +0 -174
- package/dist/Editor/Elements/DataView/Layouts/Formula.js +0 -29
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +0 -113
- package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +0 -37
- package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +0 -111
- package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +0 -60
- package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +0 -36
- package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +0 -101
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +0 -160
- package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +0 -190
- package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +0 -42
- package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +0 -30
- package/dist/Editor/Elements/DataView/Layouts/Options/index.js +0 -110
- package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +0 -179
- package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +0 -112
- package/dist/Editor/Elements/DataView/Layouts/TableView.js +0 -227
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +0 -80
- package/dist/Editor/Elements/DataView/Layouts/colStyles.js +0 -10
- package/dist/Editor/Elements/DataView/Layouts/index.js +0 -25
- package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +0 -281
- package/dist/Editor/Elements/DataView/Utils/globalSearch.js +0 -15
- package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +0 -74
- package/dist/Editor/Elements/DataView/styles.js +0 -154
- package/dist/Editor/Elements/Table/AddRowCol.js +0 -77
- package/dist/Editor/Elements/Table/DragButton.js +0 -142
- package/dist/Editor/Elements/Table/DragStyles.js +0 -70
- package/dist/Editor/Elements/Table/Draggable.js +0 -25
- package/dist/Editor/Elements/Table/Droppable.js +0 -53
- package/dist/Editor/Elements/Table/TableTool.js +0 -101
- package/dist/Editor/Elements/Table/tableHelper.js +0 -71
- package/dist/Editor/assets/svg/TableIcons.js +0 -220
- package/dist/Editor/common/Select/index.js +0 -20
- package/dist/Editor/common/Select/styles.js +0 -17
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +0 -79
- package/dist/Editor/helper/enforceDateFormat.js +0 -41
- package/dist/Editor/hooks/useTable.js +0 -210
- package/dist/Editor/utils/dataView.js +0 -43
@@ -4,7 +4,6 @@ import insertNewLine from "./insertNewLine";
|
|
4
4
|
import { getDevice } from "../helper/theme";
|
5
5
|
export const windowVar = {};
|
6
6
|
let ST_TIMEOUT = null;
|
7
|
-
const BLOCKS = ["grid", "dataView"];
|
8
7
|
export const formatDate = (date, format = "MM/DD/YYYY") => {
|
9
8
|
if (!date) return "";
|
10
9
|
var d = new Date(date),
|
@@ -164,7 +163,7 @@ export const handleInsertLastElement = (event, editor) => {
|
|
164
163
|
if (isFreeGrid) {
|
165
164
|
return;
|
166
165
|
}
|
167
|
-
const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c =>
|
166
|
+
const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => c.type === "grid");
|
168
167
|
if (!ReactEditor.isFocused(editor)) {
|
169
168
|
if (isLastElementEmpty) {
|
170
169
|
if (hasPath) {
|
@@ -213,7 +212,7 @@ export const isListItem = editor => {
|
|
213
212
|
});
|
214
213
|
return node;
|
215
214
|
};
|
216
|
-
|
215
|
+
const getNode = (editor, path) => {
|
217
216
|
try {
|
218
217
|
return Node.get(editor, path);
|
219
218
|
} catch (err) {
|
@@ -265,17 +264,6 @@ export const decodeAndParseBase64 = encodedString => {
|
|
265
264
|
const jsonData = JSON.parse(decodedURLString);
|
266
265
|
return jsonData;
|
267
266
|
};
|
268
|
-
export const encodeToBase64 = data => {
|
269
|
-
// Convert the data to a JSON string
|
270
|
-
const jsonString = JSON.stringify(data);
|
271
|
-
|
272
|
-
// URL-encode the JSON string
|
273
|
-
const encodedURLString = encodeURIComponent(jsonString);
|
274
|
-
|
275
|
-
// Base64-encode the URL-encoded string
|
276
|
-
const base64EncodedString = btoa(encodedURLString);
|
277
|
-
return base64EncodedString;
|
278
|
-
};
|
279
267
|
export const hasVerticalScrollbar = (element = {}) => {
|
280
268
|
return element.scrollHeight > element.clientHeight;
|
281
269
|
};
|
@@ -623,93 +611,4 @@ export const isPageSettings = (event, editor) => {
|
|
623
611
|
isPageSettingsNode = true;
|
624
612
|
return isPageSettingsNode;
|
625
613
|
}
|
626
|
-
};
|
627
|
-
export function capitalizeFirstLetter(str) {
|
628
|
-
if (!str) return str;
|
629
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
630
|
-
}
|
631
|
-
export const insertLineBreakAtEndOfPath = (editor, path) => {
|
632
|
-
try {
|
633
|
-
const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
|
634
|
-
if (node) {
|
635
|
-
// Insert the line break
|
636
|
-
Transforms.insertNodes(editor, {
|
637
|
-
type: "paragraph",
|
638
|
-
children: [{
|
639
|
-
text: ""
|
640
|
-
}]
|
641
|
-
}, {
|
642
|
-
at: nodePath
|
643
|
-
});
|
644
|
-
}
|
645
|
-
} catch (err) {
|
646
|
-
console.log(err);
|
647
|
-
}
|
648
|
-
};
|
649
|
-
export function isHavingSelection(editor) {
|
650
|
-
try {
|
651
|
-
return editor?.selection && !Range.isCollapsed(editor.selection);
|
652
|
-
} catch (err) {
|
653
|
-
console.log(err);
|
654
|
-
}
|
655
|
-
}
|
656
|
-
const omitNodes = ["site-settings", "page-settings"];
|
657
|
-
export function getInitialValue(value = [], readOnly) {
|
658
|
-
if (readOnly === "readonly" && value?.length) {
|
659
|
-
// remove last empty nodes on readonly mode, to remove empty spaces
|
660
|
-
|
661
|
-
let lastNonEmptyElementIndex;
|
662
|
-
for (let i = value?.length; i > 0; i--) {
|
663
|
-
const elementIndex = i - 1;
|
664
|
-
const node = value[elementIndex];
|
665
|
-
if (lastNonEmptyElementIndex) {
|
666
|
-
break;
|
667
|
-
}
|
668
|
-
if (node?.type === "paragraph") {
|
669
|
-
// Ensure all children of the paragraph node are text nodes
|
670
|
-
const hasOnlyTextChildren = node.children.every(child => Text.isText(child));
|
671
|
-
const text = node.children[node.children.length - 1]?.text;
|
672
|
-
lastNonEmptyElementIndex = hasOnlyTextChildren ? text ? elementIndex : null : elementIndex;
|
673
|
-
} else if (omitNodes.includes(node?.type)) {
|
674
|
-
continue;
|
675
|
-
} else {
|
676
|
-
lastNonEmptyElementIndex = elementIndex;
|
677
|
-
}
|
678
|
-
}
|
679
|
-
const newValue = [...value].slice(0, lastNonEmptyElementIndex + 1);
|
680
|
-
return newValue;
|
681
|
-
}
|
682
|
-
return value;
|
683
|
-
}
|
684
|
-
export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
|
685
|
-
return `${defaultCls} ${selected ? selectedClsName : ""}`;
|
686
|
-
}
|
687
|
-
export function handleNegativeInteger(val) {
|
688
|
-
return val < 0 ? 0 : val;
|
689
|
-
}
|
690
|
-
export const containsSurrogatePair = text => {
|
691
|
-
// Match surrogate pairs (high and low surrogate)
|
692
|
-
const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
693
|
-
return surrogatePairRegex.test(text);
|
694
|
-
};
|
695
|
-
export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
696
|
-
try {
|
697
|
-
const options = {
|
698
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === nodeType,
|
699
|
-
...(otherOptions || {})
|
700
|
-
};
|
701
|
-
const [node, nodePath] = Editor.nodes(editor, options);
|
702
|
-
return node ? [node, nodePath] : [];
|
703
|
-
} catch (err) {
|
704
|
-
console.log(err);
|
705
|
-
return [];
|
706
|
-
}
|
707
|
-
};
|
708
|
-
export const getSlateDom = (editor, range) => {
|
709
|
-
try {
|
710
|
-
const slateDom = ReactEditor.toDOMRange(editor, range);
|
711
|
-
return slateDom;
|
712
|
-
} catch (err) {
|
713
|
-
console.log(err);
|
714
|
-
}
|
715
614
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { Transforms } from "slate";
|
2
2
|
const insertNewLine = editor => {
|
3
3
|
Transforms.insertNodes(editor, {
|
4
4
|
type: "paragraph",
|
@@ -9,22 +9,4 @@ 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
|
-
};
|
30
12
|
export default insertNewLine;
|
@@ -9,13 +9,7 @@ export const findPageSettings = editor => {
|
|
9
9
|
path: null,
|
10
10
|
element: {
|
11
11
|
pageProps: {
|
12
|
-
pageWidth: "fixed"
|
13
|
-
"lineHeight": {
|
14
|
-
"xs": 1.43,
|
15
|
-
"sm": 1.43,
|
16
|
-
"md": 1.43,
|
17
|
-
"lg": 1.43
|
18
|
-
}
|
12
|
+
pageWidth: "fixed"
|
19
13
|
}
|
20
14
|
}
|
21
15
|
};
|
@@ -40,13 +34,7 @@ export const getPageSettings = editor => {
|
|
40
34
|
path: null,
|
41
35
|
element: {
|
42
36
|
pageProps: {
|
43
|
-
pageWidth: "fixed"
|
44
|
-
"lineHeight": {
|
45
|
-
"xs": 1.43,
|
46
|
-
"sm": 1.43,
|
47
|
-
"md": 1.43,
|
48
|
-
"lg": 1.43
|
49
|
-
}
|
37
|
+
pageWidth: "fixed"
|
50
38
|
}
|
51
39
|
}
|
52
40
|
};
|
@@ -2,8 +2,6 @@ export const serializeToText = node => {
|
|
2
2
|
try {
|
3
3
|
if (!node?.type && node?.text) {
|
4
4
|
return node?.text;
|
5
|
-
} else if (node?.type === 'mention') {
|
6
|
-
return '@' + node?.character?.name || '';
|
7
5
|
}
|
8
6
|
let n = Array.isArray(node) ? node : node?.children;
|
9
7
|
n = n && Array.isArray(n) ? n : n ? [n] : [];
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Transforms, Editor, Range, Element, Path, Node } from "slate";
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
|
-
import { customInsertNode
|
3
|
+
import { customInsertNode } from "./helper";
|
4
4
|
export const DEFAULT_TABLE_NODE = () => ({
|
5
5
|
type: "table",
|
6
6
|
children: [{
|
@@ -13,10 +13,7 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
13
13
|
text: ""
|
14
14
|
}],
|
15
15
|
cellBgColor: "#FFFFFF"
|
16
|
-
}]
|
17
|
-
size: {
|
18
|
-
width: 120
|
19
|
-
}
|
16
|
+
}]
|
20
17
|
}, {
|
21
18
|
type: "table-cell",
|
22
19
|
children: [{
|
@@ -25,10 +22,7 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
25
22
|
text: ""
|
26
23
|
}],
|
27
24
|
cellBgColor: "#FFFFFF"
|
28
|
-
}]
|
29
|
-
size: {
|
30
|
-
width: 120
|
31
|
-
}
|
25
|
+
}]
|
32
26
|
}, {
|
33
27
|
type: "table-cell",
|
34
28
|
children: [{
|
@@ -37,10 +31,7 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
37
31
|
text: ""
|
38
32
|
}],
|
39
33
|
cellBgColor: "#FFFFFF"
|
40
|
-
}]
|
41
|
-
size: {
|
42
|
-
width: 120
|
43
|
-
}
|
34
|
+
}]
|
44
35
|
}]
|
45
36
|
}, {
|
46
37
|
type: "table-row",
|
@@ -52,10 +43,7 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
52
43
|
text: ""
|
53
44
|
}],
|
54
45
|
cellBgColor: "#FFFFFF"
|
55
|
-
}]
|
56
|
-
size: {
|
57
|
-
width: 120
|
58
|
-
}
|
46
|
+
}]
|
59
47
|
}, {
|
60
48
|
type: "table-cell",
|
61
49
|
children: [{
|
@@ -64,10 +52,7 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
64
52
|
text: ""
|
65
53
|
}],
|
66
54
|
cellBgColor: "#FFFFFF"
|
67
|
-
}]
|
68
|
-
size: {
|
69
|
-
width: 120
|
70
|
-
}
|
55
|
+
}]
|
71
56
|
}, {
|
72
57
|
type: "table-cell",
|
73
58
|
children: [{
|
@@ -78,7 +63,9 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
78
63
|
cellBgColor: "#FFFFFF"
|
79
64
|
}],
|
80
65
|
size: {
|
81
|
-
|
66
|
+
widthInPercent: 100,
|
67
|
+
height: 100,
|
68
|
+
width: 365.3307291666667
|
82
69
|
}
|
83
70
|
}]
|
84
71
|
}, {
|
@@ -91,10 +78,7 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
91
78
|
text: ""
|
92
79
|
}],
|
93
80
|
cellBgColor: "#FFFFFF"
|
94
|
-
}]
|
95
|
-
size: {
|
96
|
-
width: 120
|
97
|
-
}
|
81
|
+
}]
|
98
82
|
}, {
|
99
83
|
type: "table-cell",
|
100
84
|
children: [{
|
@@ -103,10 +87,7 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
103
87
|
text: ""
|
104
88
|
}],
|
105
89
|
cellBgColor: "#FFFFFF"
|
106
|
-
}]
|
107
|
-
size: {
|
108
|
-
width: 120
|
109
|
-
}
|
90
|
+
}]
|
110
91
|
}, {
|
111
92
|
type: "table-cell",
|
112
93
|
children: [{
|
@@ -117,14 +98,14 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
117
98
|
cellBgColor: "#FFFFFF"
|
118
99
|
}],
|
119
100
|
size: {
|
120
|
-
|
101
|
+
height: 300,
|
102
|
+
widthInPercent: 100
|
121
103
|
}
|
122
104
|
}]
|
123
105
|
}],
|
124
106
|
rows: 3,
|
125
107
|
columns: 3
|
126
108
|
});
|
127
|
-
const isFreeGridTable = n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "freegridItem" && n.childType === "table";
|
128
109
|
const prefixKey = (obj, pk = "") => {
|
129
110
|
return Object.keys(obj).reduce((a, b) => {
|
130
111
|
a[`${pk}${b}`] = obj[b];
|
@@ -163,49 +144,12 @@ export class TableUtil {
|
|
163
144
|
customInsertNode(this.editor, newTable);
|
164
145
|
};
|
165
146
|
removeTable = () => {
|
166
|
-
|
167
|
-
match:
|
147
|
+
Transforms.removeNodes(this.editor, {
|
148
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
149
|
+
// mode:'highest'
|
168
150
|
});
|
169
|
-
if (freeGridItem) {
|
170
|
-
Transforms.removeNodes(this.editor, {
|
171
|
-
match: isFreeGridTable
|
172
|
-
});
|
173
|
-
} else {
|
174
|
-
Transforms.removeNodes(this.editor, {
|
175
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
176
|
-
});
|
177
|
-
}
|
178
|
-
};
|
179
|
-
duplicateTable = () => {
|
180
|
-
const {
|
181
|
-
selection
|
182
|
-
} = this.editor;
|
183
|
-
if (!!selection && Range.isCollapsed(selection)) {
|
184
|
-
const [freeGridItem] = Editor.nodes(this.editor, {
|
185
|
-
match: isFreeGridTable
|
186
|
-
});
|
187
|
-
let clone;
|
188
|
-
let path;
|
189
|
-
if (freeGridItem) {
|
190
|
-
const [freeGridNode, freeGridPath] = freeGridItem;
|
191
|
-
clone = freeGridNode;
|
192
|
-
path = freeGridPath;
|
193
|
-
} else {
|
194
|
-
const [[tableNode, tablePath]] = Editor.nodes(this.editor, {
|
195
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
196
|
-
});
|
197
|
-
clone = tableNode;
|
198
|
-
path = tablePath;
|
199
|
-
}
|
200
|
-
const nextPath = Path.next(path);
|
201
|
-
if (clone) {
|
202
|
-
const clonedNode = JSON.parse(JSON.stringify(clone));
|
203
|
-
Transforms.insertNodes(this.editor, clonedNode, {
|
204
|
-
at: nextPath
|
205
|
-
});
|
206
|
-
}
|
207
|
-
}
|
208
151
|
};
|
152
|
+
|
209
153
|
getDOMNode = path => {
|
210
154
|
try {
|
211
155
|
const [tableNode] = Editor.nodes(this.editor, {
|
@@ -242,12 +186,9 @@ export class TableUtil {
|
|
242
186
|
const [[table, tablePath]] = Editor.nodes(this.editor, {
|
243
187
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
244
188
|
});
|
245
|
-
const [
|
246
|
-
const
|
247
|
-
|
248
|
-
const path = isInsertNext ? Path.next(currentRow) : currentRow;
|
249
|
-
const insertData = isDuplicate ? JSON.parse(JSON.stringify(currentRowData)) : createRowOnInsertAbove(currentRowData, currentRow, this.editor);
|
250
|
-
Transforms.insertNodes(this.editor, insertData, {
|
189
|
+
const [, currentRow] = tableNode;
|
190
|
+
const path = action === "after" ? Path.next(currentRow) : currentRow;
|
191
|
+
Transforms.insertNodes(this.editor, createRow(Array(table.columns).fill("")), {
|
251
192
|
at: path
|
252
193
|
});
|
253
194
|
Transforms.setNodes(this.editor, {
|
@@ -258,23 +199,6 @@ export class TableUtil {
|
|
258
199
|
}
|
259
200
|
}
|
260
201
|
};
|
261
|
-
clearRow = () => {
|
262
|
-
const {
|
263
|
-
selection
|
264
|
-
} = this.editor;
|
265
|
-
if (!!selection && Range.isCollapsed(selection)) {
|
266
|
-
const [tableRow] = Editor.nodes(this.editor, {
|
267
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-row"
|
268
|
-
});
|
269
|
-
if (tableRow) {
|
270
|
-
const [tableRowNode, tableRowPath] = tableRow;
|
271
|
-
tableRowNode?.children?.forEach((cell, index) => {
|
272
|
-
const currentCellPath = [...tableRowPath, index];
|
273
|
-
clearCellText(this.editor, currentCellPath);
|
274
|
-
});
|
275
|
-
}
|
276
|
-
}
|
277
|
-
};
|
278
202
|
deleteRow = () => {
|
279
203
|
try {
|
280
204
|
const {
|
@@ -335,58 +259,6 @@ export class TableUtil {
|
|
335
259
|
}
|
336
260
|
}
|
337
261
|
};
|
338
|
-
duplicateColumn = () => {
|
339
|
-
const {
|
340
|
-
selection
|
341
|
-
} = this.editor;
|
342
|
-
if (!!selection && Range.isCollapsed(selection)) {
|
343
|
-
const [tableNode] = Editor.nodes(this.editor, {
|
344
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
|
345
|
-
});
|
346
|
-
if (tableNode) {
|
347
|
-
const [[table, tablePath]] = Editor.nodes(this.editor, {
|
348
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
349
|
-
});
|
350
|
-
const [, currentCell] = tableNode;
|
351
|
-
const currentCellPath = currentCell;
|
352
|
-
const insertNextCellPath = Path.next(currentCell);
|
353
|
-
for (let row = 0; row < table.rows; row++) {
|
354
|
-
currentCellPath[currentCellPath.length - 2] = row;
|
355
|
-
insertNextCellPath[insertNextCellPath?.length - 2] = row;
|
356
|
-
const cellNode = getNode(this.editor, currentCellPath);
|
357
|
-
Transforms.insertNodes(this.editor, JSON.parse(JSON.stringify(cellNode)), {
|
358
|
-
at: insertNextCellPath
|
359
|
-
});
|
360
|
-
}
|
361
|
-
Transforms.setNodes(this.editor, {
|
362
|
-
columns: table.columns + 1
|
363
|
-
}, {
|
364
|
-
at: tablePath
|
365
|
-
});
|
366
|
-
}
|
367
|
-
}
|
368
|
-
};
|
369
|
-
clearColumn = () => {
|
370
|
-
const {
|
371
|
-
selection
|
372
|
-
} = this.editor;
|
373
|
-
if (!!selection && Range.isCollapsed(selection)) {
|
374
|
-
const [tableNode] = Editor.nodes(this.editor, {
|
375
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
|
376
|
-
});
|
377
|
-
if (tableNode) {
|
378
|
-
const [[table]] = Editor.nodes(this.editor, {
|
379
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
380
|
-
});
|
381
|
-
const [, currentCell] = tableNode;
|
382
|
-
const currentCellPath = currentCell;
|
383
|
-
for (let row = 0; row < table.rows; row++) {
|
384
|
-
currentCellPath[currentCellPath.length - 2] = row;
|
385
|
-
clearCellText(this.editor, currentCellPath);
|
386
|
-
}
|
387
|
-
}
|
388
|
-
}
|
389
|
-
};
|
390
262
|
deleteColumn = () => {
|
391
263
|
try {
|
392
264
|
const {
|
@@ -454,7 +326,6 @@ export class TableUtil {
|
|
454
326
|
}, {
|
455
327
|
at: currentCellPath
|
456
328
|
});
|
457
|
-
applyColumnStyle(this.editor, currentCellPath, currentTablePath, cellProps, tableProps?.rows);
|
458
329
|
|
459
330
|
// cell bg entire
|
460
331
|
if (cellProps?.entireBgColor || tableProps?.borderColor || rowProps?.borderColor) {
|
@@ -492,14 +363,6 @@ export class TableUtil {
|
|
492
363
|
console.log(err);
|
493
364
|
}
|
494
365
|
};
|
495
|
-
resizeTableCell = (styleProps, path) => {
|
496
|
-
const cellProps = parseByPrefixKey(styleProps, "col.");
|
497
|
-
Transforms.setNodes(this.editor, {
|
498
|
-
...cellProps
|
499
|
-
}, {
|
500
|
-
at: path
|
501
|
-
});
|
502
|
-
};
|
503
366
|
getTableProps = () => {
|
504
367
|
const {
|
505
368
|
selection
|
@@ -622,14 +485,14 @@ export class TableUtil {
|
|
622
485
|
}
|
623
486
|
};
|
624
487
|
}
|
625
|
-
const createRow =
|
626
|
-
const newRow = Array.from(cellText, value => createTableCell(value
|
488
|
+
const createRow = cellText => {
|
489
|
+
const newRow = Array.from(cellText, value => createTableCell(value));
|
627
490
|
return {
|
628
491
|
type: "table-row",
|
629
492
|
children: newRow
|
630
493
|
};
|
631
494
|
};
|
632
|
-
export const createTableCell =
|
495
|
+
export const createTableCell = text => {
|
633
496
|
return {
|
634
497
|
type: "table-cell",
|
635
498
|
children: [{
|
@@ -637,35 +500,7 @@ export const createTableCell = (text, other = {}) => {
|
|
637
500
|
children: [{
|
638
501
|
text
|
639
502
|
}]
|
640
|
-
}]
|
641
|
-
size: {
|
642
|
-
width: 120
|
643
|
-
},
|
644
|
-
...other
|
645
|
-
};
|
646
|
-
};
|
647
|
-
const createRowOnInsertAbove = (currentRow, currRowPath, editor) => {
|
648
|
-
const isFirstRow = currRowPath[currRowPath?.length - 1] === 0;
|
649
|
-
const rowChild = currentRow?.children?.map((cell, i) => {
|
650
|
-
let other = {};
|
651
|
-
|
652
|
-
// remove the current row's size and add it on the currently inserting cell
|
653
|
-
if (isFirstRow) {
|
654
|
-
const cellPath = [...currRowPath, i];
|
655
|
-
Transforms.setNodes(editor, {
|
656
|
-
size: null
|
657
|
-
}, {
|
658
|
-
at: cellPath
|
659
|
-
});
|
660
|
-
other = {
|
661
|
-
size: cell?.size
|
662
|
-
};
|
663
|
-
}
|
664
|
-
return createTableCell("", other);
|
665
|
-
});
|
666
|
-
return {
|
667
|
-
type: "table-row",
|
668
|
-
children: rowChild
|
503
|
+
}]
|
669
504
|
};
|
670
505
|
};
|
671
506
|
|
@@ -714,43 +549,4 @@ const createTableNode = (cellText, rows, columns) => {
|
|
714
549
|
columns
|
715
550
|
};
|
716
551
|
return tableNode;
|
717
|
-
};
|
718
|
-
const columnStyleKeys = ["entireBgColor", "entireBorderColor", "entireTextColor", "entireFontFamily", "entireFontWeight", "entireTextSize"];
|
719
|
-
const applyColumnStyle = (editor, currentCellPath, currentTablePath, cellProps, rows) => {
|
720
|
-
const colStyle = columnStyleKeys.reduce((acc, key) => {
|
721
|
-
const style = cellProps[key];
|
722
|
-
if (style) {
|
723
|
-
acc[key] = style;
|
724
|
-
}
|
725
|
-
return acc;
|
726
|
-
}, {});
|
727
|
-
for (let r = 0; r < rows; r++) {
|
728
|
-
const cellPosition = currentCellPath[currentCellPath?.length - 1]; // cell position on each row as per selected column cell
|
729
|
-
|
730
|
-
Transforms.setNodes(editor, colStyle, {
|
731
|
-
at: [...currentTablePath, r, cellPosition]
|
732
|
-
});
|
733
|
-
}
|
734
|
-
};
|
735
|
-
export const clearCellText = (editor, currentCellPath) => {
|
736
|
-
try {
|
737
|
-
const existingCellNode = getNode(editor, currentCellPath);
|
738
|
-
Transforms.removeNodes(editor, {
|
739
|
-
at: currentCellPath
|
740
|
-
});
|
741
|
-
Transforms.insertNodes(editor, {
|
742
|
-
...(existingCellNode || {}),
|
743
|
-
children: [{
|
744
|
-
type: "paragraph",
|
745
|
-
children: [{
|
746
|
-
text: ""
|
747
|
-
}],
|
748
|
-
cellBgColor: "#FFFFFF"
|
749
|
-
}]
|
750
|
-
}, {
|
751
|
-
at: currentCellPath
|
752
|
-
});
|
753
|
-
} catch (err) {
|
754
|
-
console.log(err);
|
755
|
-
}
|
756
552
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "5.4.
|
3
|
+
"version": "5.4.1",
|
4
4
|
"description": "An Editor for flozy app brain",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -68,7 +68,7 @@
|
|
68
68
|
"storybook": "storybook dev -p 6006",
|
69
69
|
"build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
|
70
70
|
"publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
|
71
|
-
"publish:local": "rm -rf /Users/
|
71
|
+
"publish:local": "rm -rf /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist --copy-files"
|
72
72
|
},
|
73
73
|
"eslintConfig": {
|
74
74
|
"extends": [
|