@flozy/editor 10.2.1 → 10.2.2
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 +120 -16
- package/dist/Editor/DialogWrapper.js +31 -25
- package/dist/Editor/Editor.css +46 -8
- package/dist/Editor/Elements/AI/PopoverAIInput.js +11 -3
- package/dist/Editor/Elements/Accordion/Accordion.js +6 -2
- package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
- package/dist/Editor/Elements/Button/EditorButton.js +25 -9
- 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/ColumnView.js +4 -2
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +454 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +21 -6
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +5 -2
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +3 -2
- package/dist/Editor/Elements/DataView/Layouts/Options/index.js +11 -0
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +8 -4
- package/dist/Editor/Elements/Embed/Image.js +3 -2
- package/dist/Editor/Elements/Embed/Video.js +1 -1
- package/dist/Editor/Elements/EmbedScript/Code.js +14 -2
- package/dist/Editor/Elements/EmbedScript/EmbedScriptPopup.js +57 -28
- package/dist/Editor/Elements/EmbedScript/styles.js +89 -0
- package/dist/Editor/Elements/Form/Form.js +181 -168
- package/dist/Editor/Elements/Form/FormElements/FormText.js +23 -6
- package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +3 -2
- package/dist/Editor/Elements/Form/FormField.js +13 -6
- package/dist/Editor/Elements/Form/Workflow/Styles.js +24 -22
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +36 -31
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +7 -4
- package/dist/Editor/Elements/FreeGrid/Options/More.js +8 -8
- package/dist/Editor/Elements/FreeGrid/helper.js +113 -0
- package/dist/Editor/Elements/FreeGrid/styles.js +67 -7
- package/dist/Editor/Elements/Grid/Grid.js +14 -2
- package/dist/Editor/Elements/Grid/GridItem.js +1 -1
- package/dist/Editor/Elements/List/CheckList.js +3 -2
- package/dist/Editor/Elements/Search/SearchAttachment.js +40 -9
- package/dist/Editor/Elements/Search/SearchButton.js +9 -8
- package/dist/Editor/Elements/Search/SearchList.js +9 -7
- 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/index.js +6 -1
- package/dist/Editor/Elements/SimpleText/style.js +2 -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 +6 -6
- package/dist/Editor/Elements/Variables/VariableButton.js +10 -1
- package/dist/Editor/MiniEditor.js +2 -1
- package/dist/Editor/Styles/EditorStyles.js +5 -5
- 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 +72 -12
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +100 -27
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +439 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +1 -1
- package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
- package/dist/Editor/assets/svg/BackIcon.js +18 -0
- package/dist/Editor/assets/svg/ClearAllRounded.js +31 -0
- package/dist/Editor/assets/svg/ResetIconNew.js +23 -0
- package/dist/Editor/assets/svg/SettingsIcon.js +1 -0
- package/dist/Editor/assets/svg/ThemeIcons.js +293 -0
- package/dist/Editor/common/ColorPickerButton.js +38 -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 +31 -1
- package/dist/Editor/common/ImageSelector/Styles.js +3 -9
- package/dist/Editor/common/LinkSettings/NavComponents.js +34 -8
- package/dist/Editor/common/LinkSettings/index.js +84 -68
- package/dist/Editor/common/LinkSettings/style.js +245 -30
- package/dist/Editor/common/RnD/ElementOptions/Actions.js +13 -14
- package/dist/Editor/common/RnD/ElementOptions/Icons/LinkIcon.js +1 -0
- package/dist/Editor/common/RnD/ElementOptions/index.js +2 -2
- package/dist/Editor/common/RnD/ElementOptions/styles.js +28 -1
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +6 -5
- 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 +147 -12
- package/dist/Editor/common/RnD/OptionsPopup/index.js +8 -5
- package/dist/Editor/common/RnD/OptionsPopup/style.js +121 -19
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +8 -5
- 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 +3 -1
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +48 -54
- package/dist/Editor/common/RnD/VirtualElement/helper.js +143 -131
- package/dist/Editor/common/RnD/VirtualElement/styles.js +16 -0
- package/dist/Editor/common/RnD/index.js +6 -11
- package/dist/Editor/common/Select/index.js +2 -0
- package/dist/Editor/common/Shorthands/elements.js +65 -11
- package/dist/Editor/common/SnackBar/index.js +43 -0
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
- 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/fontSize.js +16 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +7 -6
- package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +13 -6
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +5 -7
- package/dist/Editor/common/Uploader.js +8 -0
- package/dist/Editor/common/iconListV2.js +156 -6
- package/dist/Editor/common/iconslist.js +24 -0
- package/dist/Editor/commonStyle.js +168 -62
- package/dist/Editor/helper/index.js +4 -0
- 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 +8 -5
- package/dist/Editor/hooks/useTable.js +5 -4
- package/dist/Editor/hooks/useThemeValues.js +63 -0
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +3 -1
- 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 +361 -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 +169 -45
- package/dist/Editor/utils/accordion.js +14 -4
- 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 +50 -6
- package/dist/Editor/utils/font.js +40 -37
- package/dist/Editor/utils/form.js +4 -4
- package/dist/Editor/utils/formfield.js +8 -2
- package/dist/Editor/utils/helper.js +109 -19
- package/dist/Editor/utils/signature.js +2 -9
- package/package.json +4 -4
@@ -7,43 +7,43 @@ export const sizeMap = {
|
|
7
7
|
export const fontFamilyMap = {
|
8
8
|
PoppinsRegular: "PoppinsRegular",
|
9
9
|
PoppinsBold: "PoppinsBold",
|
10
|
-
sans:
|
11
|
-
serif:
|
12
|
-
monospace:
|
13
|
-
roboto: "
|
14
|
-
qwitcher: "
|
15
|
-
garamond: "
|
16
|
-
anton: "
|
17
|
-
dmserif: "
|
18
|
-
inter: "
|
19
|
-
libre: "
|
20
|
-
montserrat: "
|
21
|
-
opensans: "
|
22
|
-
publicsans: "
|
23
|
-
raleway: "
|
24
|
-
spacemono: "
|
25
|
-
bulgarian: "
|
26
|
-
impact: "
|
27
|
-
redacted: "
|
28
|
-
greatVibes: "
|
29
|
-
zeyada: "
|
30
|
-
allura: "
|
31
|
-
pinyon: "
|
32
|
-
muellerhoff: "
|
33
|
-
dawning: "
|
10
|
+
sans: 'Helvetica, Arial, "sans serif"',
|
11
|
+
serif: 'Georgia, "Times New Roaman", serif',
|
12
|
+
monospace: 'Monaco, "Courier New", monospace',
|
13
|
+
roboto: "Roboto, sans-serif",
|
14
|
+
qwitcher: '"Qwitcher Grypen", cursive',
|
15
|
+
garamond: '"EB Garamond", serif',
|
16
|
+
anton: "Anton, sans-serif",
|
17
|
+
dmserif: '"DM Serif Text", serif',
|
18
|
+
inter: "Inter, sans-serif",
|
19
|
+
libre: '"Libre Baskerville", serif',
|
20
|
+
montserrat: "Montserrat, sans-serif",
|
21
|
+
opensans: '"Open Sans", sans-serif',
|
22
|
+
publicsans: '"Public Sans", sans-serif',
|
23
|
+
raleway: "Raleway, sans-serif",
|
24
|
+
spacemono: '"Space Mono", sans-serif',
|
25
|
+
bulgarian: '"Bulgarian Garamond", monospace',
|
26
|
+
impact: "Impact, serif",
|
27
|
+
redacted: '"Redacted Script", cursive',
|
28
|
+
greatVibes: '"Great Vibes", cursive',
|
29
|
+
zeyada: "Zeyada, cursive",
|
30
|
+
allura: "Allura, cursive",
|
31
|
+
pinyon: '"Pinyon Script", cursive',
|
32
|
+
muellerhoff: '"Herr Von Muellerhoff", cursive',
|
33
|
+
dawning: '"Dawning of a New Day", cursive',
|
34
34
|
// New Font Added for Type Signature
|
35
|
-
comingsoon: "
|
36
|
-
dancingScript: "
|
37
|
-
engagement: "
|
38
|
-
gaegu: "
|
39
|
-
ingridDarling: "
|
40
|
-
kitaOne: "
|
41
|
-
laBelleAurore: "
|
42
|
-
lobster: "
|
43
|
-
meaCulpa: "
|
44
|
-
meddon: "
|
45
|
-
merriWeather: "
|
46
|
-
theGirlNextDoor: "
|
35
|
+
comingsoon: '"Coming Soon", cursive',
|
36
|
+
dancingScript: '"Dancing Script", cursive',
|
37
|
+
engagement: "Engagement, cursive",
|
38
|
+
gaegu: "Gaegu, cursive",
|
39
|
+
ingridDarling: '"Ingrid Darling", cursive',
|
40
|
+
kitaOne: "Times",
|
41
|
+
laBelleAurore: '"La Belle Aurore", cursive',
|
42
|
+
lobster: "Lobster, cursive",
|
43
|
+
meaCulpa: '"Mea Culpa", cursive',
|
44
|
+
meddon: "Meddon, cursive",
|
45
|
+
merriWeather: "Merriweather, serif",
|
46
|
+
theGirlNextDoor: '"The Girl Next Door", cursive'
|
47
47
|
};
|
48
48
|
export const fontOptions = Object.keys(fontFamilyMap).map(m => {
|
49
49
|
return {
|
@@ -62,7 +62,10 @@ export const signedTextFonts = Object.keys(fontFamilyMap).slice(-12).map(m => {
|
|
62
62
|
export const headingMap = {
|
63
63
|
headingOne: "32px",
|
64
64
|
headingTwo: "24px",
|
65
|
-
headingThree: "19px"
|
65
|
+
headingThree: "19px",
|
66
|
+
headingFour: "16px",
|
67
|
+
headingFive: "13px",
|
68
|
+
headingSix: "11px"
|
66
69
|
};
|
67
70
|
export const fontWeightOptions = [{
|
68
71
|
text: "Bold",
|
@@ -22,8 +22,14 @@ export const formField = data => {
|
|
22
22
|
},
|
23
23
|
fontFamily: data?.fontFamily ? data?.fontFamily : "",
|
24
24
|
textSize: data?.textSize ? data?.textSize : "",
|
25
|
-
textColor: data?.textColor
|
26
|
-
fontWeight: data?.fontWeight ? data?.fontWeight : "500"
|
25
|
+
textColor: data?.textColor && `${data?.textColor} !important`,
|
26
|
+
fontWeight: data?.fontWeight ? data?.fontWeight : "500",
|
27
|
+
borderRadius: {
|
28
|
+
topLeft: 8,
|
29
|
+
topRight: 8,
|
30
|
+
bottomLeft: 8,
|
31
|
+
bottomRight: 8
|
32
|
+
}
|
27
33
|
};
|
28
34
|
};
|
29
35
|
export const insertGridItem = editor => {
|
@@ -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"];
|
@@ -485,6 +487,34 @@ export const decodeString = str => {
|
|
485
487
|
console.log(err);
|
486
488
|
}
|
487
489
|
};
|
490
|
+
export const getContrastColor = color => {
|
491
|
+
let r, g, b;
|
492
|
+
|
493
|
+
// Check if the color is in hex format
|
494
|
+
if (color.startsWith("#")) {
|
495
|
+
r = parseInt(color.substring(1, 3), 16);
|
496
|
+
g = parseInt(color.substring(3, 5), 16);
|
497
|
+
b = parseInt(color.substring(5, 7), 16);
|
498
|
+
}
|
499
|
+
// Check if the color is in RGB/RGBA format
|
500
|
+
else if (color.startsWith("rgb")) {
|
501
|
+
const rgbValues = color.replace(/^rgba?\(|\s+|\)$/g, "") // Remove the rgb/rgba and spaces
|
502
|
+
.split(","); // Split the values into an array
|
503
|
+
|
504
|
+
r = parseInt(rgbValues[0]);
|
505
|
+
g = parseInt(rgbValues[1]);
|
506
|
+
b = parseInt(rgbValues[2]);
|
507
|
+
} else {
|
508
|
+
// If the format is not recognized, default to black text
|
509
|
+
return "#000000";
|
510
|
+
}
|
511
|
+
|
512
|
+
// Calculate relative luminance
|
513
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
514
|
+
|
515
|
+
// Return black for light colors, white for dark colors
|
516
|
+
return luminance > 0.5 ? "#000000" : "#FFFFFF";
|
517
|
+
};
|
488
518
|
export const onDeleteKey = (event, {
|
489
519
|
editor
|
490
520
|
}) => {
|
@@ -702,6 +732,10 @@ export const isRestrictedNode = (event, editor) => {
|
|
702
732
|
return isNodeRestricted;
|
703
733
|
}
|
704
734
|
};
|
735
|
+
export function capitalizeFirstLetter(str) {
|
736
|
+
if (!str) return str;
|
737
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
738
|
+
}
|
705
739
|
export const insertLineBreakAtEndOfPath = (editor, path) => {
|
706
740
|
try {
|
707
741
|
const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
|
@@ -720,6 +754,13 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
|
|
720
754
|
console.log(err);
|
721
755
|
}
|
722
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
|
+
}
|
723
764
|
const omitNodes = ["site-settings", "page-settings"];
|
724
765
|
export function getInitialValue(value = [], readOnly) {
|
725
766
|
if (readOnly === "readonly" && value?.length) {
|
@@ -750,20 +791,17 @@ export function getInitialValue(value = [], readOnly) {
|
|
750
791
|
}
|
751
792
|
return value;
|
752
793
|
}
|
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
794
|
export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
|
765
795
|
return `${defaultCls} ${selected ? selectedClsName : ""}`;
|
766
796
|
}
|
797
|
+
export function handleNegativeInteger(val) {
|
798
|
+
return val < 0 ? 0 : val;
|
799
|
+
}
|
800
|
+
export const containsSurrogatePair = text => {
|
801
|
+
// Match surrogate pairs (high and low surrogate)
|
802
|
+
const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
803
|
+
return surrogatePairRegex.test(text);
|
804
|
+
};
|
767
805
|
export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
768
806
|
try {
|
769
807
|
const options = {
|
@@ -777,11 +815,6 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
|
777
815
|
return [];
|
778
816
|
}
|
779
817
|
};
|
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
818
|
export const getSlateDom = (editor, range) => {
|
786
819
|
try {
|
787
820
|
const slateDom = ReactEditor.toDOMRange(editor, range);
|
@@ -831,9 +864,24 @@ export const hideSlateSelection = () => {
|
|
831
864
|
const root = document.documentElement;
|
832
865
|
root.style.setProperty("--slate-highlight-bg", "none");
|
833
866
|
};
|
834
|
-
export
|
835
|
-
|
836
|
-
|
867
|
+
export const insertSlashNode = (editor, insertNode) => {
|
868
|
+
try {
|
869
|
+
// Delete the currently selected text
|
870
|
+
editor.deleteFragment();
|
871
|
+
const currentText = getCurrentElementText(editor);
|
872
|
+
const currentPath = editor?.selection?.anchor?.path;
|
873
|
+
let insertAt = currentPath;
|
874
|
+
if (currentText?.trim()) {
|
875
|
+
const parentPath = Path.parent(currentPath);
|
876
|
+
insertAt = Path.next(parentPath);
|
877
|
+
}
|
878
|
+
Transforms.insertNodes(editor, insertNode, {
|
879
|
+
at: insertAt
|
880
|
+
});
|
881
|
+
} catch (err) {
|
882
|
+
console.log(err);
|
883
|
+
}
|
884
|
+
};
|
837
885
|
export const isEverythingSelected = editor => {
|
838
886
|
const {
|
839
887
|
selection
|
@@ -863,4 +911,46 @@ export const getCurrentNodeText = editor => {
|
|
863
911
|
} catch (error) {
|
864
912
|
console.log("Error:", error);
|
865
913
|
}
|
914
|
+
};
|
915
|
+
function convertColorToRgb(color) {
|
916
|
+
if (color?.startsWith("#")) {
|
917
|
+
// HEX to RGB
|
918
|
+
let hex = color.replace("#", "");
|
919
|
+
let r, g, b;
|
920
|
+
if (hex.length === 3) {
|
921
|
+
hex = hex.split("").map(x => x + x).join("");
|
922
|
+
}
|
923
|
+
if (hex.length === 6) {
|
924
|
+
[r, g, b] = [hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)].map(val => parseInt(val, 16));
|
925
|
+
return `rgb(${r}, ${g}, ${b})`;
|
926
|
+
}
|
927
|
+
} else {
|
928
|
+
return color;
|
929
|
+
}
|
930
|
+
}
|
931
|
+
export const getSelectedColor = (selectedColor, theme, hideThemeColors) => {
|
932
|
+
const colorVars = hideThemeColors ? null : theme?.vars?.colors;
|
933
|
+
let selectedValue = selectedColor;
|
934
|
+
if (colorVars) {
|
935
|
+
const convertedColor = convertColorToRgb(selectedColor);
|
936
|
+
Object.entries(theme.colors).forEach(([key, value]) => {
|
937
|
+
const convertedThemeColor = convertColorToRgb(value);
|
938
|
+
if (convertedThemeColor === convertedColor) {
|
939
|
+
selectedValue = colorVars[key];
|
940
|
+
}
|
941
|
+
});
|
942
|
+
}
|
943
|
+
return selectedValue;
|
944
|
+
};
|
945
|
+
const themeTextFormats = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
|
946
|
+
export const getSelectedElementColor = (editor, format, theme) => {
|
947
|
+
const [isThemeText] = Editor.nodes(editor, {
|
948
|
+
at: editor.selection,
|
949
|
+
match: n => themeTextFormats.includes(n?.type)
|
950
|
+
});
|
951
|
+
if (!isThemeText) {
|
952
|
+
return activeMark(editor, "color") || "#000000";
|
953
|
+
}
|
954
|
+
const color = getSelectedElementStyle(format, editor, format);
|
955
|
+
return getSelectedColor(color, theme);
|
866
956
|
};
|
@@ -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
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "10.2.
|
3
|
+
"version": "10.2.2",
|
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"
|