@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
@@ -4,6 +4,7 @@ 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"];
|
7
8
|
export const formatDate = (date, format = "MM/DD/YYYY") => {
|
8
9
|
if (!date) return "";
|
9
10
|
var d = new Date(date),
|
@@ -163,7 +164,7 @@ export const handleInsertLastElement = (event, editor) => {
|
|
163
164
|
if (isFreeGrid) {
|
164
165
|
return;
|
165
166
|
}
|
166
|
-
const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => c.type
|
167
|
+
const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => BLOCKS.includes(c.type));
|
167
168
|
if (!ReactEditor.isFocused(editor)) {
|
168
169
|
if (isLastElementEmpty) {
|
169
170
|
if (hasPath) {
|
@@ -212,7 +213,7 @@ export const isListItem = editor => {
|
|
212
213
|
});
|
213
214
|
return node;
|
214
215
|
};
|
215
|
-
const getNode = (editor, path) => {
|
216
|
+
export const getNode = (editor, path) => {
|
216
217
|
try {
|
217
218
|
return Node.get(editor, path);
|
218
219
|
} catch (err) {
|
@@ -264,6 +265,17 @@ export const decodeAndParseBase64 = encodedString => {
|
|
264
265
|
const jsonData = JSON.parse(decodedURLString);
|
265
266
|
return jsonData;
|
266
267
|
};
|
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
|
+
};
|
267
279
|
export const hasVerticalScrollbar = (element = {}) => {
|
268
280
|
return element.scrollHeight > element.clientHeight;
|
269
281
|
};
|
@@ -611,4 +623,93 @@ export const isPageSettings = (event, editor) => {
|
|
611
623
|
isPageSettingsNode = true;
|
612
624
|
return isPageSettingsNode;
|
613
625
|
}
|
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
|
+
}
|
614
715
|
};
|
@@ -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] : [];
|
@@ -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 } from "./helper";
|
3
|
+
import { customInsertNode, getNode } from "./helper";
|
4
4
|
export const DEFAULT_TABLE_NODE = () => ({
|
5
5
|
type: "table",
|
6
6
|
children: [{
|
@@ -13,7 +13,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
13
13
|
text: ""
|
14
14
|
}],
|
15
15
|
cellBgColor: "#FFFFFF"
|
16
|
-
}]
|
16
|
+
}],
|
17
|
+
size: {
|
18
|
+
width: 120
|
19
|
+
}
|
17
20
|
}, {
|
18
21
|
type: "table-cell",
|
19
22
|
children: [{
|
@@ -22,7 +25,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
22
25
|
text: ""
|
23
26
|
}],
|
24
27
|
cellBgColor: "#FFFFFF"
|
25
|
-
}]
|
28
|
+
}],
|
29
|
+
size: {
|
30
|
+
width: 120
|
31
|
+
}
|
26
32
|
}, {
|
27
33
|
type: "table-cell",
|
28
34
|
children: [{
|
@@ -31,7 +37,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
31
37
|
text: ""
|
32
38
|
}],
|
33
39
|
cellBgColor: "#FFFFFF"
|
34
|
-
}]
|
40
|
+
}],
|
41
|
+
size: {
|
42
|
+
width: 120
|
43
|
+
}
|
35
44
|
}]
|
36
45
|
}, {
|
37
46
|
type: "table-row",
|
@@ -43,7 +52,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
43
52
|
text: ""
|
44
53
|
}],
|
45
54
|
cellBgColor: "#FFFFFF"
|
46
|
-
}]
|
55
|
+
}],
|
56
|
+
size: {
|
57
|
+
width: 120
|
58
|
+
}
|
47
59
|
}, {
|
48
60
|
type: "table-cell",
|
49
61
|
children: [{
|
@@ -52,7 +64,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
52
64
|
text: ""
|
53
65
|
}],
|
54
66
|
cellBgColor: "#FFFFFF"
|
55
|
-
}]
|
67
|
+
}],
|
68
|
+
size: {
|
69
|
+
width: 120
|
70
|
+
}
|
56
71
|
}, {
|
57
72
|
type: "table-cell",
|
58
73
|
children: [{
|
@@ -63,9 +78,7 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
63
78
|
cellBgColor: "#FFFFFF"
|
64
79
|
}],
|
65
80
|
size: {
|
66
|
-
|
67
|
-
height: 100,
|
68
|
-
width: 365.3307291666667
|
81
|
+
width: 120
|
69
82
|
}
|
70
83
|
}]
|
71
84
|
}, {
|
@@ -78,7 +91,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
78
91
|
text: ""
|
79
92
|
}],
|
80
93
|
cellBgColor: "#FFFFFF"
|
81
|
-
}]
|
94
|
+
}],
|
95
|
+
size: {
|
96
|
+
width: 120
|
97
|
+
}
|
82
98
|
}, {
|
83
99
|
type: "table-cell",
|
84
100
|
children: [{
|
@@ -87,7 +103,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
87
103
|
text: ""
|
88
104
|
}],
|
89
105
|
cellBgColor: "#FFFFFF"
|
90
|
-
}]
|
106
|
+
}],
|
107
|
+
size: {
|
108
|
+
width: 120
|
109
|
+
}
|
91
110
|
}, {
|
92
111
|
type: "table-cell",
|
93
112
|
children: [{
|
@@ -98,14 +117,14 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
98
117
|
cellBgColor: "#FFFFFF"
|
99
118
|
}],
|
100
119
|
size: {
|
101
|
-
|
102
|
-
widthInPercent: 100
|
120
|
+
width: 120
|
103
121
|
}
|
104
122
|
}]
|
105
123
|
}],
|
106
124
|
rows: 3,
|
107
125
|
columns: 3
|
108
126
|
});
|
127
|
+
const isFreeGridTable = n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "freegridItem" && n.childType === "table";
|
109
128
|
const prefixKey = (obj, pk = "") => {
|
110
129
|
return Object.keys(obj).reduce((a, b) => {
|
111
130
|
a[`${pk}${b}`] = obj[b];
|
@@ -144,12 +163,49 @@ export class TableUtil {
|
|
144
163
|
customInsertNode(this.editor, newTable);
|
145
164
|
};
|
146
165
|
removeTable = () => {
|
147
|
-
|
148
|
-
match:
|
149
|
-
// mode:'highest'
|
166
|
+
const [freeGridItem] = Editor.nodes(this.editor, {
|
167
|
+
match: isFreeGridTable
|
150
168
|
});
|
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
|
+
}
|
151
208
|
};
|
152
|
-
|
153
209
|
getDOMNode = path => {
|
154
210
|
try {
|
155
211
|
const [tableNode] = Editor.nodes(this.editor, {
|
@@ -186,9 +242,12 @@ export class TableUtil {
|
|
186
242
|
const [[table, tablePath]] = Editor.nodes(this.editor, {
|
187
243
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
188
244
|
});
|
189
|
-
const [, currentRow] = tableNode;
|
190
|
-
const
|
191
|
-
|
245
|
+
const [currentRowData, currentRow] = tableNode;
|
246
|
+
const isDuplicate = action === "duplicate";
|
247
|
+
const isInsertNext = action === "after" || isDuplicate;
|
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, {
|
192
251
|
at: path
|
193
252
|
});
|
194
253
|
Transforms.setNodes(this.editor, {
|
@@ -199,6 +258,23 @@ export class TableUtil {
|
|
199
258
|
}
|
200
259
|
}
|
201
260
|
};
|
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
|
+
};
|
202
278
|
deleteRow = () => {
|
203
279
|
try {
|
204
280
|
const {
|
@@ -259,6 +335,58 @@ export class TableUtil {
|
|
259
335
|
}
|
260
336
|
}
|
261
337
|
};
|
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
|
+
};
|
262
390
|
deleteColumn = () => {
|
263
391
|
try {
|
264
392
|
const {
|
@@ -326,6 +454,7 @@ export class TableUtil {
|
|
326
454
|
}, {
|
327
455
|
at: currentCellPath
|
328
456
|
});
|
457
|
+
applyColumnStyle(this.editor, currentCellPath, currentTablePath, cellProps, tableProps?.rows);
|
329
458
|
|
330
459
|
// cell bg entire
|
331
460
|
if (cellProps?.entireBgColor || tableProps?.borderColor || rowProps?.borderColor) {
|
@@ -363,6 +492,14 @@ export class TableUtil {
|
|
363
492
|
console.log(err);
|
364
493
|
}
|
365
494
|
};
|
495
|
+
resizeTableCell = (styleProps, path) => {
|
496
|
+
const cellProps = parseByPrefixKey(styleProps, "col.");
|
497
|
+
Transforms.setNodes(this.editor, {
|
498
|
+
...cellProps
|
499
|
+
}, {
|
500
|
+
at: path
|
501
|
+
});
|
502
|
+
};
|
366
503
|
getTableProps = () => {
|
367
504
|
const {
|
368
505
|
selection
|
@@ -485,14 +622,14 @@ export class TableUtil {
|
|
485
622
|
}
|
486
623
|
};
|
487
624
|
}
|
488
|
-
const createRow = cellText => {
|
489
|
-
const newRow = Array.from(cellText, value => createTableCell(value));
|
625
|
+
const createRow = (cellText, other) => {
|
626
|
+
const newRow = Array.from(cellText, value => createTableCell(value, other));
|
490
627
|
return {
|
491
628
|
type: "table-row",
|
492
629
|
children: newRow
|
493
630
|
};
|
494
631
|
};
|
495
|
-
export const createTableCell = text => {
|
632
|
+
export const createTableCell = (text, other = {}) => {
|
496
633
|
return {
|
497
634
|
type: "table-cell",
|
498
635
|
children: [{
|
@@ -500,7 +637,35 @@ export const createTableCell = text => {
|
|
500
637
|
children: [{
|
501
638
|
text
|
502
639
|
}]
|
503
|
-
}]
|
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
|
504
669
|
};
|
505
670
|
};
|
506
671
|
|
@@ -549,4 +714,43 @@ const createTableNode = (cellText, rows, columns) => {
|
|
549
714
|
columns
|
550
715
|
};
|
551
716
|
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
|
+
}
|
552
756
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.6.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/agmac30/Documents/CODE_BASE/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac30/Documents/CODE_BASE/flozy/client/node_modules/@flozy/editor/dist --copy-files"
|
72
72
|
},
|
73
73
|
"eslintConfig": {
|
74
74
|
"extends": [
|