@flozy/editor 10.6.5 → 10.6.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 +17 -16
- package/dist/Editor/CommonEditor.js +133 -14
- package/dist/Editor/DialogWrapper.js +31 -25
- package/dist/Editor/Editor.css +57 -11
- package/dist/Editor/Elements/AI/PopoverAIInput.js +11 -3
- package/dist/Editor/Elements/AI/Styles.js +1 -0
- package/dist/Editor/Elements/Accordion/Accordion.js +45 -9
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +1 -23
- package/dist/Editor/Elements/AppHeader/AppHeader.js +10 -5
- package/dist/Editor/Elements/Button/EditorButton.js +26 -10
- package/dist/Editor/Elements/Carousel/CarouselItem.js +2 -1
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +61 -14
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +10 -7
- package/dist/Editor/Elements/Color Picker/Styles.js +15 -13
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/{MultiSelect.js → SelectV1.js} +125 -69
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +10 -10
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +28 -9
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +12 -5
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +40 -14
- package/dist/Editor/Elements/Divider/Divider.js +1 -1
- package/dist/Editor/Elements/Embed/Embed.css +4 -0
- package/dist/Editor/Elements/Embed/Video.js +1 -1
- package/dist/Editor/Elements/Form/Form.js +3 -3
- package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +0 -1
- package/dist/Editor/Elements/Form/FormField.js +1 -1
- package/dist/Editor/Elements/Form/Workflow/Styles.js +24 -22
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +35 -31
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +7 -4
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -0
- package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
- package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +1 -1
- package/dist/Editor/Elements/FreeGrid/helper.js +115 -0
- package/dist/Editor/Elements/FreeGrid/styles.js +9 -0
- package/dist/Editor/Elements/Grid/Grid.js +14 -2
- package/dist/Editor/Elements/Grid/GridItem.js +1 -1
- package/dist/Editor/Elements/Signature/Signature.css +2 -1
- package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +18 -5
- package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +16 -3
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/AddRowCol.js +8 -2
- package/dist/Editor/Elements/Table/DragButton.js +0 -1
- package/dist/Editor/Elements/Table/Draggable.js +6 -2
- package/dist/Editor/Elements/Table/Styles.js +7 -0
- package/dist/Editor/Elements/Table/Table.js +3 -3
- package/dist/Editor/Elements/Table/TableCell.js +24 -5
- package/dist/Editor/Elements/Title/title.js +8 -11
- package/dist/Editor/Elements/Variables/VariableButton.js +10 -1
- package/dist/Editor/MiniEditor.js +2 -1
- package/dist/Editor/Styles/EditorStyles.js +4 -4
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +10 -13
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +4 -2
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +6 -13
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +167 -42
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +7 -4
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +73 -13
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +58 -10
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +439 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +12 -5
- package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
- package/dist/Editor/assets/svg/BackIcon.js +18 -0
- package/dist/Editor/assets/svg/ThemeIcons.js +293 -0
- package/dist/Editor/common/Checkbox/index.js +46 -0
- package/dist/Editor/common/Checkbox/styles.js +45 -0
- package/dist/Editor/common/ColorPickerButton.js +41 -16
- package/dist/Editor/common/CustomColorPicker/index.js +130 -0
- package/dist/Editor/common/CustomColorPicker/style.js +53 -0
- package/dist/Editor/common/CustomDialog2/index.js +94 -0
- package/dist/Editor/common/CustomDialog2/style.js +67 -0
- package/dist/Editor/common/CustomSelect.js +43 -0
- package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +3 -0
- package/dist/Editor/common/Icon.js +28 -0
- package/dist/Editor/common/ImageSelector/ImageSelector.js +2 -2
- package/dist/Editor/common/ImageSelector/Styles.js +3 -9
- package/dist/Editor/common/LinkSettings/NavComponents.js +47 -63
- package/dist/Editor/common/LinkSettings/index.js +17 -28
- package/dist/Editor/common/LinkSettings/navOptions.js +2 -2
- package/dist/Editor/common/LinkSettings/style.js +164 -244
- package/dist/Editor/common/RadioGroup/index.js +48 -0
- package/dist/Editor/common/RadioGroup/styles.js +29 -0
- package/dist/Editor/common/RnD/ElementOptions/Actions.js +4 -5
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +2 -1
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Signature.js +4 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +4 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +3 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/styles.js +0 -1
- package/dist/Editor/common/RnD/OptionsPopup/style.js +0 -1
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +11 -2
- package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +28 -19
- package/dist/Editor/common/RnD/Utils/index.js +58 -25
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +45 -58
- package/dist/Editor/common/RnD/VirtualElement/helper.js +323 -132
- package/dist/Editor/common/RnD/VirtualElement/styles.js +22 -0
- package/dist/Editor/common/RnD/index.js +72 -38
- package/dist/Editor/common/Select/index.js +44 -7
- package/dist/Editor/common/Select/styles.js +30 -2
- package/dist/Editor/common/Shorthands/elements.js +54 -0
- package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +2 -2
- package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +12 -9
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
- package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +4 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +12 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +16 -8
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +36 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +115 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +16 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +2 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
- package/dist/Editor/common/SwipeableDrawer/style.js +14 -12
- package/dist/Editor/common/Uploader.js +16 -0
- package/dist/Editor/common/iconListV2.js +76 -0
- package/dist/Editor/common/iconslist.js +21 -0
- package/dist/Editor/commonStyle.js +116 -61
- package/dist/Editor/helper/deserialize/index.js +6 -4
- package/dist/Editor/helper/index.js +11 -2
- package/dist/Editor/helper/textIndeces.js +58 -0
- package/dist/Editor/helper/theme.js +203 -2
- package/dist/Editor/hooks/useEditorTheme.js +153 -0
- package/dist/Editor/hooks/useMouseMove.js +9 -3
- package/dist/Editor/hooks/useTable.js +5 -4
- package/dist/Editor/hooks/useThemeValues.js +63 -0
- package/dist/Editor/plugins/withCustomDeleteBackward.js +6 -1
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +14 -5
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/theme/ThemeList.js +50 -173
- package/dist/Editor/theme/index.js +149 -0
- package/dist/Editor/themeSettings/ActiveTheme.js +82 -0
- package/dist/Editor/themeSettings/buttons/index.js +300 -0
- package/dist/Editor/themeSettings/buttons/style.js +23 -0
- package/dist/Editor/themeSettings/colorTheme/index.js +310 -0
- package/dist/Editor/themeSettings/colorTheme/style.js +81 -0
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
- package/dist/Editor/themeSettings/fonts/index.js +240 -0
- package/dist/Editor/themeSettings/fonts/style.js +62 -0
- package/dist/Editor/themeSettings/icons.js +60 -0
- package/dist/Editor/themeSettings/index.js +380 -0
- package/dist/Editor/themeSettings/style.js +299 -0
- package/dist/Editor/themeSettingsAI/icons.js +96 -0
- package/dist/Editor/themeSettingsAI/index.js +355 -0
- package/dist/Editor/themeSettingsAI/saveTheme.js +202 -0
- package/dist/Editor/themeSettingsAI/style.js +332 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +173 -50
- package/dist/Editor/utils/accordion.js +158 -37
- package/dist/Editor/utils/button.js +1 -17
- package/dist/Editor/utils/customHooks/useTableResize.js +49 -9
- package/dist/Editor/utils/draftToSlate.js +3 -2
- package/dist/Editor/utils/events.js +18 -6
- package/dist/Editor/utils/font.js +40 -37
- package/dist/Editor/utils/formfield.js +1 -0
- package/dist/Editor/utils/helper.js +149 -30
- package/dist/Editor/utils/insertAppHeader.js +9 -5
- package/dist/Editor/utils/signature.js +2 -9
- package/dist/Editor/utils/updateFormName.js +22 -0
- package/package.json +4 -4
@@ -2,6 +2,8 @@ import { Editor, Node, Transforms, Element, Path, Range, Text } from "slate";
|
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
3
|
import insertNewLine from "./insertNewLine";
|
4
4
|
import { getDevice } from "../helper/theme";
|
5
|
+
import { activeMark, getSelectedElementStyle } from "./SlateUtilityFunctions";
|
6
|
+
import { getCurrentElementText } from "../plugins/withHTML";
|
5
7
|
export const windowVar = {};
|
6
8
|
let ST_TIMEOUT = null;
|
7
9
|
const BLOCKS = ["grid", "dataView"];
|
@@ -216,9 +218,13 @@ export const handleInsertLastElement = (event, editor) => {
|
|
216
218
|
};
|
217
219
|
export const isListItem = editor => {
|
218
220
|
const format = ["list-item", "check-list-item", "accordion-summary", "headingOne", "headingTwo", "headingThree"];
|
219
|
-
const [
|
221
|
+
const [node1, node2] = Editor.nodes(editor, {
|
220
222
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && format.indexOf(n.type) > -1
|
221
223
|
});
|
224
|
+
let node = node1;
|
225
|
+
if (node2 && node2[0] && node2[0].type === "accordion-summary") {
|
226
|
+
node = node2;
|
227
|
+
}
|
222
228
|
return node;
|
223
229
|
};
|
224
230
|
export const getNode = (editor, path) => {
|
@@ -333,7 +339,8 @@ const handleLinkBtnClick = (e, props, isMobilePreview, metadata) => {
|
|
333
339
|
}
|
334
340
|
}
|
335
341
|
};
|
336
|
-
export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick = () => {}, metadata = {}
|
342
|
+
export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick = () => {}, metadata = {}, isEditMode, isCustomMobile // for drawer in App Header
|
343
|
+
) => {
|
337
344
|
const props = {};
|
338
345
|
if (!readOnly) {
|
339
346
|
return {
|
@@ -365,6 +372,9 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
|
|
365
372
|
case "page":
|
366
373
|
const [page = "", section] = url?.split("#") || [];
|
367
374
|
const sec = section ? `#${section}` : "";
|
375
|
+
if (isEditMode) {
|
376
|
+
break;
|
377
|
+
}
|
368
378
|
if (page === "_currentPage") {
|
369
379
|
props.component = "button";
|
370
380
|
props.onClick = () => {
|
@@ -385,11 +395,12 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
|
|
385
395
|
const currentUserPage = getCurrentUserPage();
|
386
396
|
props.href = isCurrentPage(page) ? `./${currentUserPage}${sec}` : `./${url}`;
|
387
397
|
if (openInNewTab) {
|
388
|
-
if (isCurrentPage(page)) {
|
389
|
-
|
390
|
-
} else {
|
391
|
-
|
392
|
-
}
|
398
|
+
// if (isCurrentPage(page)) {
|
399
|
+
// // temp fix, if user is presented in current page, open in new tab option is restricted, we will scroll to the element in current page
|
400
|
+
// } else {
|
401
|
+
// props.target = "_blank";
|
402
|
+
// }
|
403
|
+
props.target = "_blank";
|
393
404
|
}
|
394
405
|
}
|
395
406
|
break;
|
@@ -424,7 +435,7 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
|
|
424
435
|
|
425
436
|
// for iphone fix
|
426
437
|
if (props.component === "a" && props.href) {
|
427
|
-
const isMobile = getDevice(window.innerWidth) === "xs";
|
438
|
+
const isMobile = isCustomMobile || getDevice(window.innerWidth) === "xs";
|
428
439
|
if (isMobile) {
|
429
440
|
props.component = "button"; // iphone is opening two tabs, on open in new tab because of a tag.
|
430
441
|
}
|
@@ -485,6 +496,34 @@ export const decodeString = str => {
|
|
485
496
|
console.log(err);
|
486
497
|
}
|
487
498
|
};
|
499
|
+
export const getContrastColor = color => {
|
500
|
+
let r, g, b;
|
501
|
+
|
502
|
+
// Check if the color is in hex format
|
503
|
+
if (color.startsWith("#")) {
|
504
|
+
r = parseInt(color.substring(1, 3), 16);
|
505
|
+
g = parseInt(color.substring(3, 5), 16);
|
506
|
+
b = parseInt(color.substring(5, 7), 16);
|
507
|
+
}
|
508
|
+
// Check if the color is in RGB/RGBA format
|
509
|
+
else if (color.startsWith("rgb")) {
|
510
|
+
const rgbValues = color.replace(/^rgba?\(|\s+|\)$/g, "") // Remove the rgb/rgba and spaces
|
511
|
+
.split(","); // Split the values into an array
|
512
|
+
|
513
|
+
r = parseInt(rgbValues[0]);
|
514
|
+
g = parseInt(rgbValues[1]);
|
515
|
+
b = parseInt(rgbValues[2]);
|
516
|
+
} else {
|
517
|
+
// If the format is not recognized, default to black text
|
518
|
+
return "#000000";
|
519
|
+
}
|
520
|
+
|
521
|
+
// Calculate relative luminance
|
522
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
523
|
+
|
524
|
+
// Return black for light colors, white for dark colors
|
525
|
+
return luminance > 0.5 ? "#000000" : "#FFFFFF";
|
526
|
+
};
|
488
527
|
export const onDeleteKey = (event, {
|
489
528
|
editor
|
490
529
|
}) => {
|
@@ -702,6 +741,10 @@ export const isRestrictedNode = (event, editor) => {
|
|
702
741
|
return isNodeRestricted;
|
703
742
|
}
|
704
743
|
};
|
744
|
+
export function capitalizeFirstLetter(str) {
|
745
|
+
if (!str) return str;
|
746
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
747
|
+
}
|
705
748
|
export const insertLineBreakAtEndOfPath = (editor, path) => {
|
706
749
|
try {
|
707
750
|
const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
|
@@ -720,6 +763,13 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
|
|
720
763
|
console.log(err);
|
721
764
|
}
|
722
765
|
};
|
766
|
+
export function isHavingSelection(editor) {
|
767
|
+
try {
|
768
|
+
return editor?.selection && !Range.isCollapsed(editor.selection);
|
769
|
+
} catch (err) {
|
770
|
+
console.log(err);
|
771
|
+
}
|
772
|
+
}
|
723
773
|
const omitNodes = ["site-settings", "page-settings"];
|
724
774
|
export function getInitialValue(value = [], readOnly) {
|
725
775
|
if (readOnly === "readonly" && value?.length) {
|
@@ -750,20 +800,17 @@ export function getInitialValue(value = [], readOnly) {
|
|
750
800
|
}
|
751
801
|
return value;
|
752
802
|
}
|
753
|
-
export function capitalizeFirstLetter(str) {
|
754
|
-
if (!str) return str;
|
755
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
756
|
-
}
|
757
|
-
export function isHavingSelection(editor) {
|
758
|
-
try {
|
759
|
-
return editor?.selection && !Range.isCollapsed(editor.selection);
|
760
|
-
} catch (err) {
|
761
|
-
console.log(err);
|
762
|
-
}
|
763
|
-
}
|
764
803
|
export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
|
765
804
|
return `${defaultCls} ${selected ? selectedClsName : ""}`;
|
766
805
|
}
|
806
|
+
export function handleNegativeInteger(val) {
|
807
|
+
return val < 0 ? 0 : val;
|
808
|
+
}
|
809
|
+
export const containsSurrogatePair = text => {
|
810
|
+
// Match surrogate pairs (high and low surrogate)
|
811
|
+
const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
812
|
+
return surrogatePairRegex.test(text);
|
813
|
+
};
|
767
814
|
export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
768
815
|
try {
|
769
816
|
const options = {
|
@@ -777,11 +824,6 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
|
777
824
|
return [];
|
778
825
|
}
|
779
826
|
};
|
780
|
-
export const containsSurrogatePair = text => {
|
781
|
-
// Match surrogate pairs (high and low surrogate)
|
782
|
-
const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
783
|
-
return surrogatePairRegex.test(text);
|
784
|
-
};
|
785
827
|
export const getSlateDom = (editor, range) => {
|
786
828
|
try {
|
787
829
|
const slateDom = ReactEditor.toDOMRange(editor, range);
|
@@ -822,7 +864,8 @@ export const clearWindowSelection = () => {
|
|
822
864
|
|
823
865
|
export const viewSlateSelection = () => {
|
824
866
|
// if ai is opened, remove the window selection class and open then slate selection, To resolve: focussing on the ai input removes window selection automatically
|
825
|
-
clearWindowSelection();
|
867
|
+
// clearWindowSelection();
|
868
|
+
|
826
869
|
const selectionBg = "rgba(35, 131, 226, 0.35)";
|
827
870
|
const root = document.documentElement;
|
828
871
|
root.style.setProperty("--slate-highlight-bg", selectionBg);
|
@@ -831,9 +874,24 @@ export const hideSlateSelection = () => {
|
|
831
874
|
const root = document.documentElement;
|
832
875
|
root.style.setProperty("--slate-highlight-bg", "none");
|
833
876
|
};
|
834
|
-
export
|
835
|
-
|
836
|
-
|
877
|
+
export const insertSlashNode = (editor, insertNode) => {
|
878
|
+
try {
|
879
|
+
// Delete the currently selected text
|
880
|
+
editor.deleteFragment();
|
881
|
+
const currentText = getCurrentElementText(editor);
|
882
|
+
const currentPath = editor?.selection?.anchor?.path;
|
883
|
+
let insertAt = currentPath;
|
884
|
+
if (currentText?.trim()) {
|
885
|
+
const parentPath = Path.parent(currentPath);
|
886
|
+
insertAt = Path.next(parentPath);
|
887
|
+
}
|
888
|
+
Transforms.insertNodes(editor, insertNode, {
|
889
|
+
at: insertAt
|
890
|
+
});
|
891
|
+
} catch (err) {
|
892
|
+
console.log(err);
|
893
|
+
}
|
894
|
+
};
|
837
895
|
export const isEverythingSelected = editor => {
|
838
896
|
const {
|
839
897
|
selection
|
@@ -864,6 +922,61 @@ export const getCurrentNodeText = editor => {
|
|
864
922
|
console.log("Error:", error);
|
865
923
|
}
|
866
924
|
};
|
925
|
+
function convertColorToRgb(color) {
|
926
|
+
if (color?.startsWith("#")) {
|
927
|
+
// HEX to RGB
|
928
|
+
let hex = color.replace("#", "");
|
929
|
+
let r, g, b;
|
930
|
+
if (hex.length === 3) {
|
931
|
+
hex = hex.split("").map(x => x + x).join("");
|
932
|
+
}
|
933
|
+
if (hex.length === 6) {
|
934
|
+
[r, g, b] = [hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)].map(val => parseInt(val, 16));
|
935
|
+
return `rgb(${r}, ${g}, ${b})`;
|
936
|
+
}
|
937
|
+
} else {
|
938
|
+
return color;
|
939
|
+
}
|
940
|
+
}
|
941
|
+
export const getSelectedColor = (selectedColor, theme, hideThemeColors) => {
|
942
|
+
const colorVars = hideThemeColors ? null : theme?.vars?.colors;
|
943
|
+
let selectedValue = selectedColor;
|
944
|
+
if (colorVars) {
|
945
|
+
const convertedColor = convertColorToRgb(selectedColor);
|
946
|
+
Object.entries(theme.colors).forEach(([key, value]) => {
|
947
|
+
const convertedThemeColor = convertColorToRgb(value);
|
948
|
+
if (convertedThemeColor === convertedColor) {
|
949
|
+
selectedValue = colorVars[key];
|
950
|
+
}
|
951
|
+
});
|
952
|
+
}
|
953
|
+
return selectedValue;
|
954
|
+
};
|
955
|
+
const themeTextFormats = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
|
956
|
+
export const getSelectedElementColor = (editor, format, theme) => {
|
957
|
+
const [isThemeText] = Editor.nodes(editor, {
|
958
|
+
at: editor.selection,
|
959
|
+
match: n => themeTextFormats.includes(n?.type)
|
960
|
+
});
|
961
|
+
if (!isThemeText) {
|
962
|
+
return activeMark(editor, "color") || "#000000";
|
963
|
+
}
|
964
|
+
const color = getSelectedElementStyle(format, editor, format);
|
965
|
+
return getSelectedColor(color, theme);
|
966
|
+
};
|
967
|
+
export const isHavingColor = color => {
|
968
|
+
if (!color) {
|
969
|
+
return false;
|
970
|
+
}
|
971
|
+
if (color.includes("rgba")) {
|
972
|
+
const match = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+),?\s*(\d*\.?\d+)?\)/);
|
973
|
+
if (!match) return false; // Invalid format
|
974
|
+
|
975
|
+
const alpha = match[4] !== undefined ? parseFloat(match[4]) : 1; // Default alpha = 1
|
976
|
+
return alpha !== 0;
|
977
|
+
}
|
978
|
+
return true;
|
979
|
+
};
|
867
980
|
const handleCopiedList = (el, domRange) => {
|
868
981
|
// Ensure you're working with an Element, not a Text node
|
869
982
|
const startEl = domRange.startContainer.nodeType === Node.ELEMENT_NODE ? domRange.startContainer : domRange.startContainer.parentElement;
|
@@ -883,11 +996,15 @@ const handleCopiedList = (el, domRange) => {
|
|
883
996
|
el.insertAdjacentText("afterbegin", "- ");
|
884
997
|
}
|
885
998
|
};
|
999
|
+
const cleanCopiedDOM = container => {
|
1000
|
+
container.querySelectorAll('[style*="display: none"], [contenteditable="false"]').forEach(el => el.remove());
|
1001
|
+
return container;
|
1002
|
+
};
|
886
1003
|
const getCopiedTextFormat = domRange => {
|
887
1004
|
const contents = domRange.cloneContents();
|
888
1005
|
const div = document.createElement("div");
|
889
1006
|
div.appendChild(contents);
|
890
|
-
|
1007
|
+
cleanCopiedDOM(div);
|
891
1008
|
// Replace <br> with newlines
|
892
1009
|
div.querySelectorAll("br").forEach(br => br.replaceWith("\n"));
|
893
1010
|
const BLOCK_TAGS = ["DIV", "P", "LI", "H1", "H2", "H3", "H4", "H5", "H6"];
|
@@ -915,6 +1032,7 @@ const getCopiedHTMLFormat = domRange => {
|
|
915
1032
|
const htmlContents = domRange.cloneContents();
|
916
1033
|
const container = document.createElement("div");
|
917
1034
|
container.appendChild(htmlContents);
|
1035
|
+
cleanCopiedDOM(container);
|
918
1036
|
const html = container.innerHTML;
|
919
1037
|
return html;
|
920
1038
|
};
|
@@ -939,4 +1057,5 @@ export const handleCopy = (event, editor) => {
|
|
939
1057
|
event.clipboardData?.setData("text/html", html);
|
940
1058
|
event.clipboardData?.setData("text/plain", text);
|
941
1059
|
event.clipboardData?.setData("application/x-slate-fragment", encodedFragment);
|
942
|
-
};
|
1060
|
+
};
|
1061
|
+
export const ALLOWED_TEXT_NODES = ["paragraph", "title", "headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "blockquote"];
|
@@ -8,27 +8,31 @@ export const appHeaderNode = ({
|
|
8
8
|
appLogo: "none",
|
9
9
|
menus: menus || [{
|
10
10
|
type: "menu",
|
11
|
-
url: "
|
11
|
+
url: "",
|
12
|
+
placeholder: "home",
|
12
13
|
target: "",
|
13
14
|
text: "Home",
|
14
15
|
linkType: "page"
|
15
16
|
}, {
|
16
17
|
type: "menu",
|
17
|
-
url: "
|
18
|
+
url: "",
|
19
|
+
placeholder: "wireframe2",
|
18
20
|
target: "",
|
19
21
|
text: "Wireframe",
|
20
22
|
linkType: "page"
|
21
23
|
}, {
|
22
24
|
type: "menu",
|
23
|
-
url: "
|
25
|
+
url: "",
|
24
26
|
target: "",
|
27
|
+
placeholder: "Work",
|
25
28
|
text: "Work",
|
26
29
|
linkType: "webAddress"
|
27
30
|
}, {
|
28
31
|
type: "menu",
|
29
|
-
url: "
|
32
|
+
url: "",
|
30
33
|
target: "",
|
31
34
|
text: "Contact",
|
35
|
+
placeholder: "Contact",
|
32
36
|
linkType: "webAddress"
|
33
37
|
}],
|
34
38
|
menuStyle: "stacked",
|
@@ -51,7 +55,7 @@ export const createAppHeaderNode = ({
|
|
51
55
|
children: [{
|
52
56
|
type: "grid-item",
|
53
57
|
grid: 12,
|
54
|
-
children: [
|
58
|
+
children: [appHeaderNode({
|
55
59
|
menus
|
56
60
|
})],
|
57
61
|
bgColor: "rgba(255, 255, 255, 0)",
|
@@ -1,9 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
import insertNewLine from "./insertNewLine";
|
3
|
-
import { getCurrentElementText } from "../plugins/withHTML";
|
1
|
+
import { insertSlashNode } from "./helper";
|
4
2
|
export const insertSignature = editor => {
|
5
|
-
const hasText = getCurrentElementText(editor);
|
6
|
-
const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor.selection.anchor.path;
|
7
3
|
const signature = {
|
8
4
|
type: "signature",
|
9
5
|
alignment: "center",
|
@@ -17,8 +13,5 @@ export const insertSignature = editor => {
|
|
17
13
|
text: " "
|
18
14
|
}]
|
19
15
|
};
|
20
|
-
|
21
|
-
at: insertPath
|
22
|
-
});
|
23
|
-
insertNewLine(editor);
|
16
|
+
insertSlashNode(editor, signature);
|
24
17
|
};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
const updateFormName = node => {
|
2
|
+
try {
|
3
|
+
if (!node || typeof node !== "object") return node;
|
4
|
+
let updatedNode = {
|
5
|
+
...node
|
6
|
+
};
|
7
|
+
if (updatedNode.type === "form") {
|
8
|
+
const timeStamp = Date.now();
|
9
|
+
const newFormName = `form_${timeStamp}`;
|
10
|
+
updatedNode.formName = newFormName;
|
11
|
+
updatedNode.uid = newFormName;
|
12
|
+
}
|
13
|
+
if (Array.isArray(updatedNode.children)) {
|
14
|
+
updatedNode.children = updatedNode.children.map(child => updateFormName(child));
|
15
|
+
}
|
16
|
+
return updatedNode;
|
17
|
+
} catch (err) {
|
18
|
+
console.warn("Error inside updateFormName", err);
|
19
|
+
return node;
|
20
|
+
}
|
21
|
+
};
|
22
|
+
export default updateFormName;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "10.6.
|
3
|
+
"version": "10.6.6",
|
4
4
|
"description": "An Editor for flozy app brain",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -38,7 +38,6 @@
|
|
38
38
|
"react-icons": "^4.10.1",
|
39
39
|
"react-katex": "^3.0.1",
|
40
40
|
"react-rnd": "^10.4.11",
|
41
|
-
"react-scripts": "5.0.1",
|
42
41
|
"react-signature-canvas": "^1.0.6",
|
43
42
|
"react-slick": "^0.29.0",
|
44
43
|
"sanitize-html": "^2.13.0",
|
@@ -69,7 +68,7 @@
|
|
69
68
|
"storybook": "storybook dev -p 6006",
|
70
69
|
"build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
|
71
70
|
"publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
|
72
|
-
"publish:local": "rm -rf /Users/
|
71
|
+
"publish:local": "rm -rf /Users/agenciflow08/Documents/flozyapp/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agenciflow08/Documents/flozyapp/client/node_modules/@flozy/editor/dist --copy-files",
|
73
72
|
"publish:flozy": "./publish-flozy.sh",
|
74
73
|
"publish:flozy2": "./publish-flozy2.sh",
|
75
74
|
"publish:permission": "chmod +x publish-flozy.sh && chmod +x publish-flozy2.sh"
|
@@ -122,7 +121,8 @@
|
|
122
121
|
"prop-types": "^15.8.1",
|
123
122
|
"source-map-explorer": "^2.5.3",
|
124
123
|
"storybook": "^7.4.0",
|
125
|
-
"webpack": "^5.88.2"
|
124
|
+
"webpack": "^5.88.2",
|
125
|
+
"react-scripts": "5.0.1"
|
126
126
|
},
|
127
127
|
"overrides": {
|
128
128
|
"react-refresh": "0.11.0"
|