@flozy/editor 3.9.8 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/ChatEditor.js +55 -45
- package/dist/Editor/CommonEditor.js +180 -111
- package/dist/Editor/Editor.css +9 -3
- package/dist/Editor/Elements/AI/AIInput.js +18 -24
- package/dist/Editor/Elements/AI/CustomSelect.js +19 -12
- package/dist/Editor/Elements/AI/PopoverAIInput.js +66 -89
- package/dist/Editor/Elements/AI/Styles.js +2 -1
- package/dist/Editor/Elements/AI/VoiceToText/AudioWave.js +73 -0
- package/dist/Editor/Elements/AI/VoiceToText/index.js +184 -0
- package/dist/Editor/Elements/AI/VoiceToText/style.js +40 -0
- package/dist/Editor/Elements/AI/helper.js +5 -3
- package/dist/Editor/Elements/Accordion/Accordion.js +74 -7
- package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +3 -2
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +4 -60
- package/dist/Editor/Elements/AppHeader/AppHeader.js +26 -4
- package/dist/Editor/Elements/Button/EditorButton.js +28 -16
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +60 -17
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
- package/dist/Editor/Elements/Color Picker/Styles.js +2 -1
- package/dist/Editor/Elements/Embed/Image.js +29 -21
- package/dist/Editor/Elements/Embed/Video.js +15 -11
- package/dist/Editor/Elements/Emoji/EmojiPicker.js +4 -2
- package/dist/Editor/Elements/Form/Form.js +1 -1
- package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +12 -3
- package/dist/Editor/Elements/Form/Workflow/UserInputs.js +2 -1
- package/dist/Editor/Elements/Grid/Grid.js +33 -16
- package/dist/Editor/Elements/Grid/GridItem.js +3 -1
- package/dist/Editor/Elements/Link/Link.js +6 -1
- package/dist/Editor/Elements/Link/LinkButton.js +4 -2
- package/dist/Editor/Elements/Link/LinkPopup.js +10 -3
- package/dist/Editor/Elements/Link/LinkPopupStyles.js +28 -0
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +8 -4
- package/dist/Editor/Elements/Redo/RedoButton.js +14 -0
- package/dist/Editor/Elements/Signature/SignaturePopup.js +20 -5
- package/dist/Editor/Elements/Table/Styles.js +23 -1
- package/dist/Editor/Elements/Table/Table.js +3 -2
- package/dist/Editor/Elements/Table/TableCell.js +70 -8
- package/dist/Editor/Elements/TableContextMenu/TableContextMenu.js +1 -0
- package/dist/Editor/Elements/Undo/UndoButton.js +14 -0
- package/dist/Editor/MiniEditor.js +3 -1
- package/dist/Editor/Styles/EditorStyles.js +1 -1
- package/dist/Editor/Toolbar/Basic/index.js +4 -2
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +26 -2
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +29 -18
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +29 -3
- package/dist/Editor/Toolbar/Mini/Options/Options.js +10 -0
- package/dist/Editor/Toolbar/Mini/Styles.js +7 -0
- package/dist/Editor/Toolbar/PopupTool/ButtonTemplatesCard.js +12 -13
- package/dist/Editor/Toolbar/PopupTool/FullViewCard.js +12 -13
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +4 -11
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +213 -86
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +40 -33
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +52 -7
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +438 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +7 -6
- package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
- package/dist/Editor/assets/svg/AIIcons.js +153 -1
- package/dist/Editor/assets/svg/AddTemplateIcon.js +13 -10
- package/dist/Editor/assets/svg/RedoIcon.js +27 -0
- package/dist/Editor/assets/svg/SettingsIcon.js +28 -0
- package/dist/Editor/assets/svg/TextIcon.js +8 -5
- package/dist/Editor/assets/svg/ThemeIcons.js +291 -0
- package/dist/Editor/assets/svg/UndoIcon.js +27 -0
- package/dist/Editor/common/ColorPickerButton.js +25 -9
- package/dist/Editor/common/CustomColorPicker/index.js +106 -0
- package/dist/Editor/common/CustomColorPicker/style.js +53 -0
- package/dist/Editor/common/CustomDialog/index.js +94 -0
- package/dist/Editor/common/CustomDialog/style.js +67 -0
- package/dist/Editor/common/CustomSelect.js +33 -0
- package/dist/Editor/common/DnD/DragHandleButton.js +56 -47
- package/dist/Editor/common/EditorCmds.js +35 -0
- package/dist/Editor/common/Icon.js +43 -3
- package/dist/Editor/common/LinkSettings/NavComponents.js +5 -2
- package/dist/Editor/common/LinkSettings/index.js +4 -2
- package/dist/Editor/common/LinkSettings/navOptions.js +7 -2
- package/dist/Editor/common/LinkSettings/style.js +11 -8
- package/dist/Editor/common/MentionsPopup/MentionsListCard.js +6 -1
- package/dist/Editor/common/MentionsPopup/Styles.js +5 -2
- package/dist/Editor/common/Section/index.js +57 -7
- package/dist/Editor/common/Section/styles.js +11 -0
- package/dist/Editor/common/Shorthands/elements.js +54 -0
- package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +7 -7
- package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +16 -16
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +13 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +1 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +31 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +13 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +14 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +14 -4
- package/dist/Editor/common/StyleBuilder/index.js +1 -1
- package/dist/Editor/common/iconslist.js +0 -31
- package/dist/Editor/helper/deserialize/index.js +14 -9
- package/dist/Editor/helper/theme.js +190 -4
- package/dist/Editor/hooks/useEditorTheme.js +139 -0
- package/dist/Editor/hooks/useMouseMove.js +4 -2
- package/dist/Editor/hooks/useWindowMessage.js +10 -7
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +47 -5
- package/dist/Editor/plugins/withLayout.js +15 -10
- package/dist/Editor/plugins/withTable.js +2 -2
- package/dist/Editor/theme/ThemeList.js +50 -173
- package/dist/Editor/theme/index.js +144 -0
- package/dist/Editor/themeSettings/ActiveTheme.js +72 -0
- package/dist/Editor/themeSettings/buttons/index.js +290 -0
- package/dist/Editor/themeSettings/buttons/style.js +21 -0
- package/dist/Editor/themeSettings/colorTheme/index.js +290 -0
- package/dist/Editor/themeSettings/colorTheme/style.js +77 -0
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +123 -0
- package/dist/Editor/themeSettings/fonts/index.js +213 -0
- package/dist/Editor/themeSettings/fonts/style.js +44 -0
- package/dist/Editor/themeSettings/icons.js +60 -0
- package/dist/Editor/themeSettings/index.js +320 -0
- package/dist/Editor/themeSettings/style.js +152 -0
- package/dist/Editor/themeSettingsAI/icons.js +96 -0
- package/dist/Editor/themeSettingsAI/index.js +356 -0
- package/dist/Editor/themeSettingsAI/saveTheme.js +190 -0
- package/dist/Editor/themeSettingsAI/style.js +247 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +161 -25
- package/dist/Editor/utils/button.js +1 -17
- package/dist/Editor/utils/draftToSlate.js +1 -1
- package/dist/Editor/utils/events.js +65 -6
- package/dist/Editor/utils/font.js +40 -37
- package/dist/Editor/utils/helper.js +74 -14
- package/dist/Editor/utils/table.js +51 -43
- package/package.json +3 -2
@@ -855,37 +855,6 @@ export const Carousal = props => /*#__PURE__*/_jsxs("svg", {
|
|
855
855
|
fill: "#64748B"
|
856
856
|
})]
|
857
857
|
});
|
858
|
-
export const PageSettings = (props = {}) => /*#__PURE__*/_jsxs("svg", {
|
859
|
-
width: "16",
|
860
|
-
height: "16",
|
861
|
-
viewBox: "0 0 16 16",
|
862
|
-
fill: "none",
|
863
|
-
xmlns: "http://www.w3.org/2000/svg",
|
864
|
-
...props,
|
865
|
-
children: [/*#__PURE__*/_jsx("path", {
|
866
|
-
d: "M13.2386 0.535156H2.76091C2.30289 0.535814 1.86383 0.718051 1.53996 1.04192C1.2161 1.36578 1.03386 1.80485 1.0332 2.26286V11.7453C1.03386 12.2033 1.2161 12.6424 1.53996 12.9663C1.86383 13.2901 2.30289 13.4724 2.76091 13.473H4.29405C4.30918 13.5774 4.3571 13.6743 4.43089 13.7497L5.23503 14.5539C5.3155 14.6344 5.42114 14.6849 5.53434 14.6969C5.64753 14.7089 5.76143 14.6818 5.85704 14.62L6.42979 14.2498C6.5507 14.308 6.67481 14.3594 6.80151 14.4036L6.94482 15.0704C6.96871 15.1816 7.02999 15.2813 7.11846 15.3528C7.20692 15.4243 7.31722 15.4634 7.43099 15.4635H8.56852C8.68229 15.4634 8.79259 15.4243 8.88105 15.3528C8.96952 15.2813 9.0308 15.1816 9.05469 15.0704L9.198 14.4036C9.32471 14.3594 9.44881 14.308 9.56972 14.2498L10.1425 14.62C10.2381 14.6818 10.352 14.7089 10.4652 14.6969C10.5784 14.6849 10.684 14.6344 10.7645 14.5539L11.5686 13.7497C11.6424 13.6743 11.6903 13.5774 11.7055 13.473H13.2386C13.6966 13.4724 14.1357 13.2901 14.4595 12.9663C14.7834 12.6424 14.9657 12.2033 14.9663 11.7453V2.26286C14.9657 1.80485 14.7834 1.36578 14.4595 1.04192C14.1357 0.718051 13.6966 0.535814 13.2386 0.535156ZM2.76091 1.53038H13.2386C13.4328 1.53051 13.6191 1.60772 13.7564 1.74506C13.8937 1.8824 13.971 2.06864 13.9711 2.26286V3.52082H2.02842V2.26286C2.02856 2.06864 2.10577 1.8824 2.24311 1.74506C2.38045 1.60772 2.56668 1.53051 2.76091 1.53038ZM10.345 13.5656L9.8643 13.2546C9.78643 13.2042 9.696 13.1765 9.60323 13.1747C9.51047 13.173 9.41906 13.1972 9.33932 13.2446C9.12471 13.3725 8.89275 13.4687 8.65063 13.5303C8.56076 13.553 8.47904 13.6005 8.41468 13.6672C8.35032 13.7339 8.30588 13.8173 8.28638 13.908L8.16596 14.4683H7.83355L7.71313 13.908C7.69363 13.8173 7.64919 13.7339 7.58483 13.6672C7.52047 13.6005 7.43875 13.553 7.34888 13.5303C7.10676 13.4687 6.8748 13.3725 6.66019 13.2446C6.58045 13.1972 6.48904 13.173 6.39628 13.1747C6.30351 13.1765 6.21308 13.2042 6.13521 13.2546L5.65452 13.5656L5.41915 13.3302L5.73015 12.8495C5.78059 12.7717 5.80825 12.6812 5.81001 12.5885C5.81177 12.4957 5.78755 12.4043 5.7401 12.3246C5.61223 12.1099 5.51603 11.878 5.45448 11.6359C5.4317 11.546 5.38428 11.4643 5.31754 11.3999C5.25081 11.3355 5.16743 11.2911 5.07679 11.2716L4.51648 11.1512V10.8188L5.07679 10.6984C5.16743 10.6789 5.25081 10.6344 5.31754 10.5701C5.38428 10.5057 5.4317 10.424 5.45448 10.3341C5.51603 10.092 5.61223 9.86003 5.7401 9.64542C5.78755 9.56568 5.81177 9.47427 5.81001 9.38151C5.80825 9.28874 5.78059 9.19831 5.73015 9.12044L5.41915 8.63975L5.65452 8.40438L6.13521 8.71538C6.21308 8.76582 6.30351 8.79348 6.39628 8.79524C6.48904 8.797 6.58045 8.77278 6.66019 8.72533C6.8748 8.59746 7.10676 8.50126 7.34888 8.43971C7.43875 8.41693 7.52047 8.36951 7.58483 8.30277C7.64919 8.23604 7.69363 8.15266 7.71313 8.06202L7.83355 7.50171H8.16596L8.28638 8.06202C8.30588 8.15266 8.35032 8.23604 8.41468 8.30277C8.47904 8.36951 8.56076 8.41693 8.65063 8.43971C8.89275 8.50126 9.12471 8.59746 9.33932 8.72533C9.41906 8.77278 9.51047 8.797 9.60323 8.79524C9.696 8.79348 9.78643 8.76582 9.8643 8.71538L10.345 8.40438L10.5804 8.63975L10.2694 9.12044C10.2189 9.19831 10.1913 9.28874 10.1895 9.38151C10.1877 9.47427 10.212 9.56568 10.2594 9.64542C10.3873 9.86003 10.4835 10.092 10.545 10.3341C10.5678 10.424 10.6152 10.5057 10.682 10.5701C10.7487 10.6344 10.8321 10.6789 10.9227 10.6984L11.483 10.8188V11.1512L10.9227 11.2716C10.8321 11.2911 10.7487 11.3355 10.682 11.3999C10.6152 11.4643 10.5678 11.546 10.545 11.6359C10.4835 11.878 10.3873 12.1099 10.2594 12.3246C10.212 12.4043 10.1877 12.4957 10.1895 12.5885C10.1913 12.6812 10.2189 12.7717 10.2694 12.8495L10.5804 13.3302L10.345 13.5656ZM11.7132 12.4001L11.7055 13.473C11.7493 13.3735 11.385 12.2838 11.4198 12.1832L12.0866 12.0399C12.1979 12.016 12.2975 11.9547 12.3691 11.8663C12.4406 11.7778 12.4797 11.6675 12.4797 11.5538V10.4162C12.4797 10.3025 12.4406 10.1921 12.3691 10.1037C12.2975 10.0152 12.1979 9.95394 12.0866 9.93005L11.4198 9.78674C11.3756 9.66004 11.3243 9.53593 11.2661 9.41502L11.6363 8.84227C11.6981 8.74666 11.7252 8.63276 11.7132 8.51957C11.7011 8.40637 11.6506 8.30073 11.5701 8.22026L10.766 7.41612C10.6855 7.33561 10.5799 7.28512 10.4667 7.27307C10.3535 7.26103 10.2396 7.28816 10.144 7.34994L9.57121 7.72016C9.4503 7.66194 9.3262 7.61061 9.1995 7.5664L9.05618 6.8996C9.03229 6.78837 8.97101 6.68869 8.88255 6.61716C8.79408 6.54563 8.68378 6.50657 8.57002 6.50649H7.43099C7.31722 6.50657 7.20692 6.54563 7.11846 6.61716C7.02999 6.68869 6.96871 6.78837 6.94482 6.8996L6.80151 7.5664C6.67481 7.61061 6.5507 7.66194 6.42979 7.72016L5.85704 7.35243C5.76143 7.29065 5.64753 7.26352 5.53434 7.27556C5.42114 7.28761 5.3155 7.3381 5.23503 7.41861L4.43089 8.22026C4.35038 8.30073 4.29989 8.40637 4.28784 8.51957C4.2758 8.63276 4.30293 8.74666 4.36471 8.84227L4.73493 9.41502C4.67671 9.53593 4.62538 9.66004 4.58117 9.78674L3.91437 9.93005C3.80314 9.95394 3.70346 10.0152 3.63193 10.1037C3.5604 10.1921 3.52134 10.3025 3.52126 10.4162V11.5538C3.52134 11.6675 3.5604 11.7778 3.63193 11.8663C3.70346 11.9547 3.80314 12.016 3.91437 12.0399L4.58117 12.1832C4.616 12.2828 4.25026 13.3775 4.29405 13.473V12.5C4.19775 12.5001 2.57072 12.4591 2.48171 12.4224C2.3927 12.3856 2.3118 12.3317 2.24364 12.2637C2.17548 12.1956 2.12138 12.1148 2.08446 12.0259C2.04753 11.937 2.02849 11.8416 2.02842 11.7453V4.51604H13.9711V11.7453C13.971 11.9396 13.8937 12.1258 13.7564 12.2631C13.6191 12.4005 11.9074 12.4 11.7132 12.4001Z",
|
867
|
-
fill: "#64748A"
|
868
|
-
}), /*#__PURE__*/_jsx("path", {
|
869
|
-
d: "M4.29405 13.473H2.76091C2.30289 13.4724 1.86383 13.2901 1.53996 12.9663C1.2161 12.6424 1.03386 12.2033 1.0332 11.7453V2.26286C1.03386 1.80485 1.2161 1.36578 1.53996 1.04192C1.86383 0.718051 2.30289 0.535814 2.76091 0.535156H13.2386C13.6966 0.535814 14.1357 0.718051 14.4595 1.04192C14.7834 1.36578 14.9657 1.80485 14.9663 2.26286V11.7453C14.9657 12.2033 14.7834 12.6424 14.4595 12.9663C14.1357 13.2901 13.6966 13.4724 13.2386 13.473H11.7055M4.29405 13.473C4.30918 13.5774 4.3571 13.6743 4.43089 13.7497L5.23503 14.5539C5.3155 14.6344 5.42114 14.6849 5.53434 14.6969C5.64753 14.7089 5.76143 14.6818 5.85704 14.62L6.42979 14.2498C6.5507 14.308 6.67481 14.3594 6.80151 14.4036L6.94482 15.0704C6.96871 15.1816 7.02999 15.2813 7.11846 15.3528C7.20692 15.4243 7.31722 15.4634 7.43099 15.4635H8.56852C8.68229 15.4634 8.79259 15.4243 8.88105 15.3528C8.96952 15.2813 9.0308 15.1816 9.05469 15.0704L9.198 14.4036C9.32471 14.3594 9.44881 14.308 9.56972 14.2498L10.1425 14.62C10.2381 14.6818 10.352 14.7089 10.4652 14.6969C10.5784 14.6849 10.684 14.6344 10.7645 14.5539L11.5686 13.7497C11.6424 13.6743 11.6903 13.5774 11.7055 13.473M4.29405 13.473C4.25026 13.3775 4.616 12.2828 4.58117 12.1832L3.91437 12.0399C3.80314 12.016 3.70346 11.9547 3.63193 11.8663C3.5604 11.7778 3.52134 11.6675 3.52126 11.5538V10.4162C3.52134 10.3025 3.5604 10.1921 3.63193 10.1037C3.70346 10.0152 3.80314 9.95394 3.91437 9.93005L4.58117 9.78674C4.62538 9.66004 4.67671 9.53593 4.73493 9.41502L4.36471 8.84227C4.30293 8.74666 4.2758 8.63276 4.28784 8.51957C4.29989 8.40637 4.35038 8.30073 4.43089 8.22026L5.23503 7.41861C5.3155 7.3381 5.42114 7.28761 5.53434 7.27556C5.64753 7.26352 5.76143 7.29065 5.85704 7.35243L6.42979 7.72016C6.5507 7.66194 6.67481 7.61061 6.80151 7.5664L6.94482 6.8996C6.96871 6.78837 7.02999 6.68869 7.11846 6.61716C7.20692 6.54563 7.31722 6.50657 7.43099 6.50649H8.57002C8.68378 6.50657 8.79408 6.54563 8.88255 6.61716C8.97101 6.68869 9.03229 6.78837 9.05618 6.8996L9.1995 7.5664C9.3262 7.61061 9.4503 7.66194 9.57121 7.72016L10.144 7.34994C10.2396 7.28816 10.3535 7.26103 10.4667 7.27307C10.5799 7.28512 10.6855 7.33561 10.766 7.41612L11.5701 8.22026C11.6506 8.30073 11.7011 8.40637 11.7132 8.51957C11.7252 8.63276 11.6981 8.74666 11.6363 8.84227L11.2661 9.41502C11.3243 9.53593 11.3756 9.66004 11.4198 9.78674L12.0866 9.93005C12.1979 9.95394 12.2975 10.0152 12.3691 10.1037C12.4406 10.1921 12.4797 10.3025 12.4797 10.4162V11.5538C12.4797 11.6675 12.4406 11.7778 12.3691 11.8663C12.2975 11.9547 12.1979 12.016 12.0866 12.0399L11.4198 12.1832C11.385 12.2838 11.7493 13.3735 11.7055 13.473M4.29405 13.473V12.5C4.19775 12.5001 2.57072 12.4591 2.48171 12.4224C2.3927 12.3856 2.3118 12.3317 2.24364 12.2637C2.17548 12.1956 2.12138 12.1148 2.08446 12.0259C2.04753 11.937 2.02849 11.8416 2.02842 11.7453V4.51604H13.9711V11.7453C13.971 11.9396 13.8937 12.1258 13.7564 12.2631C13.6191 12.4005 11.9074 12.4 11.7132 12.4001L11.7055 13.473M2.76091 1.53038H13.2386C13.4328 1.53051 13.6191 1.60772 13.7564 1.74506C13.8937 1.8824 13.971 2.06864 13.9711 2.26286V3.52082H2.02842V2.26286C2.02856 2.06864 2.10577 1.8824 2.24311 1.74506C2.38045 1.60772 2.56668 1.53051 2.76091 1.53038ZM10.345 13.5656L9.8643 13.2546C9.78643 13.2042 9.696 13.1765 9.60323 13.1747C9.51047 13.173 9.41906 13.1972 9.33932 13.2446C9.12471 13.3725 8.89275 13.4687 8.65063 13.5303C8.56076 13.553 8.47904 13.6005 8.41468 13.6672C8.35032 13.7339 8.30588 13.8173 8.28638 13.908L8.16596 14.4683H7.83355L7.71313 13.908C7.69363 13.8173 7.64919 13.7339 7.58483 13.6672C7.52047 13.6005 7.43875 13.553 7.34888 13.5303C7.10676 13.4687 6.8748 13.3725 6.66019 13.2446C6.58045 13.1972 6.48904 13.173 6.39628 13.1747C6.30351 13.1765 6.21308 13.2042 6.13521 13.2546L5.65452 13.5656L5.41915 13.3302L5.73015 12.8495C5.78059 12.7717 5.80825 12.6812 5.81001 12.5885C5.81177 12.4957 5.78755 12.4043 5.7401 12.3246C5.61223 12.1099 5.51603 11.878 5.45448 11.6359C5.4317 11.546 5.38428 11.4643 5.31754 11.3999C5.25081 11.3355 5.16743 11.2911 5.07679 11.2716L4.51648 11.1512V10.8188L5.07679 10.6984C5.16743 10.6789 5.25081 10.6344 5.31754 10.5701C5.38428 10.5057 5.4317 10.424 5.45448 10.3341C5.51603 10.092 5.61223 9.86003 5.7401 9.64542C5.78755 9.56568 5.81177 9.47427 5.81001 9.38151C5.80825 9.28874 5.78059 9.19831 5.73015 9.12044L5.41915 8.63975L5.65452 8.40438L6.13521 8.71538C6.21308 8.76582 6.30351 8.79348 6.39628 8.79524C6.48904 8.797 6.58045 8.77278 6.66019 8.72533C6.8748 8.59746 7.10676 8.50126 7.34888 8.43971C7.43875 8.41693 7.52047 8.36951 7.58483 8.30277C7.64919 8.23604 7.69363 8.15266 7.71313 8.06202L7.83355 7.50171H8.16596L8.28638 8.06202C8.30588 8.15266 8.35032 8.23604 8.41468 8.30277C8.47904 8.36951 8.56076 8.41693 8.65063 8.43971C8.89275 8.50126 9.12471 8.59746 9.33932 8.72533C9.41906 8.77278 9.51047 8.797 9.60323 8.79524C9.696 8.79348 9.78643 8.76582 9.8643 8.71538L10.345 8.40438L10.5804 8.63975L10.2694 9.12044C10.2189 9.19831 10.1913 9.28874 10.1895 9.38151C10.1877 9.47427 10.212 9.56568 10.2594 9.64542C10.3873 9.86003 10.4835 10.092 10.545 10.3341C10.5678 10.424 10.6152 10.5057 10.682 10.5701C10.7487 10.6344 10.8321 10.6789 10.9227 10.6984L11.483 10.8188V11.1512L10.9227 11.2716C10.8321 11.2911 10.7487 11.3355 10.682 11.3999C10.6152 11.4643 10.5678 11.546 10.545 11.6359C10.4835 11.878 10.3873 12.1099 10.2594 12.3246C10.212 12.4043 10.1877 12.4957 10.1895 12.5885C10.1913 12.6812 10.2189 12.7717 10.2694 12.8495L10.5804 13.3302L10.345 13.5656Z",
|
870
|
-
stroke: "white",
|
871
|
-
strokeWidth: "0.1"
|
872
|
-
}), /*#__PURE__*/_jsx("path", {
|
873
|
-
d: "M3.52105 3.02257C3.79587 3.02257 4.01866 2.79978 4.01866 2.52495C4.01866 2.25013 3.79587 2.02734 3.52105 2.02734C3.24623 2.02734 3.02344 2.25013 3.02344 2.52495C3.02344 2.79978 3.24623 3.02257 3.52105 3.02257Z",
|
874
|
-
fill: "#64748A",
|
875
|
-
stroke: "white",
|
876
|
-
strokeWidth: "0.1"
|
877
|
-
}), /*#__PURE__*/_jsx("path", {
|
878
|
-
d: "M5.01421 3.02257C5.28904 3.02257 5.51182 2.79978 5.51182 2.52495C5.51182 2.25013 5.28904 2.02734 5.01421 2.02734C4.73939 2.02734 4.5166 2.25013 4.5166 2.52495C4.5166 2.79978 4.73939 3.02257 5.01421 3.02257Z",
|
879
|
-
fill: "#64748A",
|
880
|
-
stroke: "white",
|
881
|
-
strokeWidth: "0.1"
|
882
|
-
}), /*#__PURE__*/_jsx("path", {
|
883
|
-
d: "M7.99972 8.99414C7.60605 8.99414 7.22122 9.11088 6.89389 9.32959C6.56656 9.5483 6.31144 9.85917 6.16079 10.2229C6.01014 10.5866 5.97072 10.9868 6.04752 11.3729C6.12433 11.759 6.3139 12.1137 6.59227 12.392C6.87063 12.6704 7.2253 12.86 7.61141 12.9368C7.99751 13.0136 8.39773 12.9742 8.76143 12.8235C9.12514 12.6729 9.436 12.4177 9.65472 12.0904C9.87343 11.7631 9.99017 11.3783 9.99017 10.9846C9.99017 10.4567 9.78046 9.95041 9.40718 9.57713C9.0339 9.20385 8.52762 8.99414 7.99972 8.99414ZM7.99972 11.9798C7.80289 11.9798 7.61047 11.9214 7.44681 11.8121C7.28314 11.7027 7.15558 11.5473 7.08026 11.3654C7.00493 11.1836 6.98522 10.9835 7.02362 10.7904C7.06202 10.5974 7.15681 10.42 7.29599 10.2809C7.43518 10.1417 7.61251 10.0469 7.80556 10.0085C7.99862 9.97008 8.19872 9.98979 8.38058 10.0651C8.56243 10.1404 8.71786 10.268 8.82722 10.4317C8.93658 10.5953 8.99494 10.7877 8.99494 10.9846C8.99494 11.2485 8.89009 11.5017 8.70345 11.6883C8.51681 11.875 8.26367 11.9798 7.99972 11.9798Z",
|
884
|
-
fill: "#64748A",
|
885
|
-
stroke: "white",
|
886
|
-
strokeWidth: "0.1"
|
887
|
-
})]
|
888
|
-
});
|
889
858
|
export const TextLeftAlign = props => /*#__PURE__*/_jsxs("svg", {
|
890
859
|
xmlns: "http://www.w3.org/2000/svg",
|
891
860
|
width: "24",
|
@@ -72,15 +72,20 @@ const ELEMENT_TAGS = {
|
|
72
72
|
type: "paragraph"
|
73
73
|
}),
|
74
74
|
TABLE: (el, children = []) => {
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
75
|
+
try {
|
76
|
+
const tableBody = (children || [])?.find(f => f?.type === "table-body");
|
77
|
+
const bodyChild = tableBody?.children || [];
|
78
|
+
const firstRowChildren = tableBody[0]?.children || [];
|
79
|
+
return {
|
80
|
+
type: "table",
|
81
|
+
overwriteChild: bodyChild,
|
82
|
+
// we are not having table-body in our json format, just we are wrapping table-row's inside the table
|
83
|
+
rows: bodyChild?.length,
|
84
|
+
columns: firstRowChildren?.length
|
85
|
+
};
|
86
|
+
} catch (err) {
|
87
|
+
console.log(err);
|
88
|
+
}
|
84
89
|
},
|
85
90
|
THEAD: () => ({
|
86
91
|
type: "table-head"
|
@@ -1,4 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { ReactEditor } from "slate-react";
|
2
|
+
import { fontFamilyMap, sizeMap } from "../utils/font";
|
3
|
+
import { Editor, Node } from "slate";
|
2
4
|
export const breakpoints = {
|
3
5
|
small: 0,
|
4
6
|
mobile: 600,
|
@@ -27,7 +29,7 @@ const overrideValues = (value, ot) => {
|
|
27
29
|
return Object.keys(value).reduce((a, b) => {
|
28
30
|
return {
|
29
31
|
...a,
|
30
|
-
[b]: overrides[ot] ? overrides[ot](value[b]) : value
|
32
|
+
[b]: overrides[ot] ? overrides[ot](value[b], value) : value
|
31
33
|
};
|
32
34
|
}, {});
|
33
35
|
};
|
@@ -44,7 +46,15 @@ const overrides = {
|
|
44
46
|
overrideReSizeH: val => {
|
45
47
|
return `${val?.height}px`;
|
46
48
|
},
|
47
|
-
overrideBorderRadius: val => {
|
49
|
+
overrideBorderRadius: (val, breakpointValues) => {
|
50
|
+
if (!val?.topLeft) {
|
51
|
+
Object.values(breakpointValues || {}).forEach(v => {
|
52
|
+
if (v) {
|
53
|
+
// Applying the values from breakpoints that exist to those that do not have
|
54
|
+
val = v;
|
55
|
+
}
|
56
|
+
});
|
57
|
+
}
|
48
58
|
return `${val?.topLeft}px ${val?.topRight}px ${val?.bottomLeft}px ${val?.bottomRight}px`;
|
49
59
|
}
|
50
60
|
};
|
@@ -97,4 +107,180 @@ export const getTRBLBreakPoints = (value, breakpoint) => {
|
|
97
107
|
} catch (err) {
|
98
108
|
console.log(err);
|
99
109
|
}
|
100
|
-
};
|
110
|
+
};
|
111
|
+
export function getElementStyle(editor, element, stylePropertyName) {
|
112
|
+
try {
|
113
|
+
const path = ReactEditor.findPath(editor, element);
|
114
|
+
if (path?.length) {
|
115
|
+
const currentEle = Node.get(editor, path);
|
116
|
+
const dom = ReactEditor.toDOMNode(editor, currentEle);
|
117
|
+
const editorBtn = dom?.querySelector("button.theme-element");
|
118
|
+
const elementStyle = window.getComputedStyle(editorBtn);
|
119
|
+
const style = elementStyle[stylePropertyName];
|
120
|
+
if (stylePropertyName === "fontFamily") {
|
121
|
+
const val = Object.entries(fontFamilyMap).find(([key, value]) => value === style)?.[0];
|
122
|
+
return val;
|
123
|
+
}
|
124
|
+
return style;
|
125
|
+
}
|
126
|
+
} catch (err) {
|
127
|
+
// console.log(err);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
export function getTextSizeVal(editor) {
|
131
|
+
try {
|
132
|
+
const currentNode = Node.get(editor, editor.selection.anchor.path);
|
133
|
+
const currentElement = ReactEditor.toDOMNode(editor, currentNode);
|
134
|
+
if (currentElement) {
|
135
|
+
const element = document.querySelector('span[data-slate-string="true"]');
|
136
|
+
const computedStyle = window.getComputedStyle(element);
|
137
|
+
return computedStyle.getPropertyValue("font-size") || "";
|
138
|
+
}
|
139
|
+
} catch (err) {
|
140
|
+
// console.log(err);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
export function getVariableValue(val) {
|
144
|
+
const bodyElement = document.body;
|
145
|
+
const computedStyle = getComputedStyle(bodyElement);
|
146
|
+
const [, variableName] = val?.match(/var\((--[^)]+)\)/) || [];
|
147
|
+
const varValue = computedStyle.getPropertyValue(variableName).trim();
|
148
|
+
return varValue;
|
149
|
+
}
|
150
|
+
export const textThemeFields = ["fontFamily", "fontSize", "color", "bold", "italic"
|
151
|
+
// "underline",
|
152
|
+
// "strikethrough",
|
153
|
+
];
|
154
|
+
|
155
|
+
const themeElements = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
|
156
|
+
export const isTextCustomized = editor => {
|
157
|
+
try {
|
158
|
+
if (editor.selection) {
|
159
|
+
const currentElement = Node.parent(editor, editor?.selection?.anchor?.path);
|
160
|
+
if (!currentElement) {
|
161
|
+
return false;
|
162
|
+
}
|
163
|
+
const {
|
164
|
+
children,
|
165
|
+
type
|
166
|
+
} = currentElement;
|
167
|
+
if (!themeElements.includes(type)) {
|
168
|
+
return false;
|
169
|
+
}
|
170
|
+
if (children?.length > 1) {
|
171
|
+
return true;
|
172
|
+
}
|
173
|
+
const customized = textThemeFields.some(field => {
|
174
|
+
const element = children[0] || {};
|
175
|
+
const value = element[field];
|
176
|
+
if (field === "fontSize") {
|
177
|
+
return Object.keys(value || {}).length;
|
178
|
+
} else {
|
179
|
+
return value;
|
180
|
+
}
|
181
|
+
});
|
182
|
+
return customized;
|
183
|
+
} else {
|
184
|
+
return null;
|
185
|
+
}
|
186
|
+
} catch (err) {
|
187
|
+
return null;
|
188
|
+
}
|
189
|
+
};
|
190
|
+
const addToTheme = (field, value, element) => {
|
191
|
+
switch (field) {
|
192
|
+
case "fontFamily":
|
193
|
+
return {
|
194
|
+
fontFamily: fontFamilyMap[value]
|
195
|
+
};
|
196
|
+
case "fontSize":
|
197
|
+
return {
|
198
|
+
fontSize: value?.lg
|
199
|
+
};
|
200
|
+
case "color":
|
201
|
+
return {
|
202
|
+
color: value
|
203
|
+
};
|
204
|
+
case "bold":
|
205
|
+
return {
|
206
|
+
fontWeight: "bold"
|
207
|
+
};
|
208
|
+
case "italic":
|
209
|
+
return {
|
210
|
+
fontStyle: "italic"
|
211
|
+
};
|
212
|
+
// case "underline":
|
213
|
+
// case "strikethrough":
|
214
|
+
// let textDecoration = "";
|
215
|
+
|
216
|
+
// if (element.underline) {
|
217
|
+
// textDecoration = "underline";
|
218
|
+
// }
|
219
|
+
|
220
|
+
// if (element.strikethrough) {
|
221
|
+
// textDecoration += " strikethrough";
|
222
|
+
// }
|
223
|
+
|
224
|
+
// return { textDecoration };
|
225
|
+
default:
|
226
|
+
return {};
|
227
|
+
}
|
228
|
+
};
|
229
|
+
const MAP_TEXT_THEME_FIELD = {
|
230
|
+
headingOne: "h1",
|
231
|
+
headingTwo: "h2",
|
232
|
+
headingThree: "h3",
|
233
|
+
headingFour: "h4",
|
234
|
+
headingFive: "h5",
|
235
|
+
headingSix: "h6",
|
236
|
+
paragraphOne: "para1",
|
237
|
+
paragraphTwo: "para2",
|
238
|
+
paragraphThree: "para3"
|
239
|
+
};
|
240
|
+
export const saveToTheme = editor => {
|
241
|
+
try {
|
242
|
+
if (editor.selection) {
|
243
|
+
const currentElement = Node.parent(editor, editor?.selection?.anchor?.path);
|
244
|
+
if (!currentElement) {
|
245
|
+
return false;
|
246
|
+
}
|
247
|
+
const {
|
248
|
+
children
|
249
|
+
} = currentElement;
|
250
|
+
if (children?.length > 1) {
|
251
|
+
return true;
|
252
|
+
}
|
253
|
+
let theme = {};
|
254
|
+
textThemeFields.forEach(field => {
|
255
|
+
const element = children[0] || {};
|
256
|
+
const value = element[field];
|
257
|
+
let style = {};
|
258
|
+
let isValueExist = false;
|
259
|
+
if (value) {
|
260
|
+
isValueExist = true;
|
261
|
+
if (field === "fontSize") {
|
262
|
+
isValueExist = !!Object.keys(value).length;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
if (isValueExist) {
|
266
|
+
style = addToTheme(field, value, element);
|
267
|
+
}
|
268
|
+
theme = {
|
269
|
+
...theme,
|
270
|
+
...style
|
271
|
+
};
|
272
|
+
});
|
273
|
+
textThemeFields.forEach(field => {
|
274
|
+
Editor.removeMark(editor, field);
|
275
|
+
});
|
276
|
+
return {
|
277
|
+
field: MAP_TEXT_THEME_FIELD[currentElement?.type],
|
278
|
+
theme
|
279
|
+
};
|
280
|
+
}
|
281
|
+
} catch (err) {
|
282
|
+
return;
|
283
|
+
}
|
284
|
+
};
|
285
|
+
export const HEADING_THEME_FIELDS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
286
|
+
export const PARAGRAPH_THEME_FIELDS = ["para1", "para2", "para3"];
|
@@ -0,0 +1,139 @@
|
|
1
|
+
import { useSlate } from "slate-react";
|
2
|
+
import { defaultTheme } from "../theme";
|
3
|
+
import { getPageSettings, updatePageSettings } from "../utils/pageSettings";
|
4
|
+
import { HEADING_THEME_FIELDS, PARAGRAPH_THEME_FIELDS } from "../helper/theme";
|
5
|
+
const MAP_FIELDS = {
|
6
|
+
HEADING: HEADING_THEME_FIELDS,
|
7
|
+
PARAGRAPH: PARAGRAPH_THEME_FIELDS
|
8
|
+
};
|
9
|
+
function getUpdatePayload(prevTheme = {}, update, actionData) {
|
10
|
+
const {
|
11
|
+
action,
|
12
|
+
fieldName
|
13
|
+
} = actionData || {};
|
14
|
+
const {
|
15
|
+
theme: prev
|
16
|
+
} = prevTheme;
|
17
|
+
let theme = {};
|
18
|
+
let themeProps = {};
|
19
|
+
switch (action) {
|
20
|
+
case "THEME_CHANGE":
|
21
|
+
theme = update;
|
22
|
+
break;
|
23
|
+
case "CSS_VAR_CHANGE":
|
24
|
+
const prevCssVars = prev?.cssVars || {};
|
25
|
+
const prevValue = prevCssVars[fieldName] || {};
|
26
|
+
themeProps = {
|
27
|
+
...(prev || {}),
|
28
|
+
cssVars: {
|
29
|
+
...prevCssVars,
|
30
|
+
[fieldName]: {
|
31
|
+
...prevValue,
|
32
|
+
...update
|
33
|
+
}
|
34
|
+
}
|
35
|
+
};
|
36
|
+
theme = {
|
37
|
+
...prevTheme,
|
38
|
+
theme: themeProps
|
39
|
+
};
|
40
|
+
break;
|
41
|
+
case "ELEMENT_PROPS_CHANGE":
|
42
|
+
const prevEleProps = prev?.elementProps || {};
|
43
|
+
const prevEleValue = prevEleProps[fieldName] || {};
|
44
|
+
themeProps = {
|
45
|
+
...(prev || {}),
|
46
|
+
elementProps: {
|
47
|
+
...prevEleProps,
|
48
|
+
[fieldName]: {
|
49
|
+
...prevEleValue,
|
50
|
+
...update
|
51
|
+
}
|
52
|
+
}
|
53
|
+
};
|
54
|
+
theme = {
|
55
|
+
...prevTheme,
|
56
|
+
theme: themeProps
|
57
|
+
};
|
58
|
+
break;
|
59
|
+
case "OTHER_PROPS_CHANGE":
|
60
|
+
themeProps = {
|
61
|
+
...(prev || {}),
|
62
|
+
otherProps: {
|
63
|
+
...(prev.otherProps || {}),
|
64
|
+
...update
|
65
|
+
}
|
66
|
+
};
|
67
|
+
theme = {
|
68
|
+
...prevTheme,
|
69
|
+
theme: themeProps
|
70
|
+
};
|
71
|
+
break;
|
72
|
+
case "FONT_CHANGE":
|
73
|
+
const {
|
74
|
+
elementProps = {},
|
75
|
+
otherProps = {}
|
76
|
+
} = prev;
|
77
|
+
const fields = MAP_FIELDS[actionData?.fieldType];
|
78
|
+
const headingUpdate = {};
|
79
|
+
fields?.forEach(field => {
|
80
|
+
const prevHeadingData = elementProps[field];
|
81
|
+
headingUpdate[field] = {
|
82
|
+
...prevHeadingData,
|
83
|
+
...update
|
84
|
+
};
|
85
|
+
});
|
86
|
+
themeProps = {
|
87
|
+
...(prev || {}),
|
88
|
+
elementProps: {
|
89
|
+
...elementProps,
|
90
|
+
...headingUpdate
|
91
|
+
},
|
92
|
+
otherProps: {
|
93
|
+
...otherProps,
|
94
|
+
headingFontFamily: update?.fontFamily
|
95
|
+
}
|
96
|
+
};
|
97
|
+
theme = {
|
98
|
+
...prevTheme,
|
99
|
+
theme: themeProps
|
100
|
+
};
|
101
|
+
break;
|
102
|
+
default:
|
103
|
+
theme = {
|
104
|
+
...prevTheme,
|
105
|
+
...(update || {})
|
106
|
+
};
|
107
|
+
break;
|
108
|
+
}
|
109
|
+
return theme;
|
110
|
+
}
|
111
|
+
const updateTheme = (editor, pageSt, update, actionData) => {
|
112
|
+
const {
|
113
|
+
pageProps
|
114
|
+
} = pageSt || {};
|
115
|
+
const {
|
116
|
+
theme
|
117
|
+
} = pageProps || {};
|
118
|
+
updatePageSettings(editor, {
|
119
|
+
...(pageProps || {}),
|
120
|
+
theme: getUpdatePayload(theme, update, actionData)
|
121
|
+
});
|
122
|
+
};
|
123
|
+
export const useEditorTheme = () => {
|
124
|
+
const editor = useSlate();
|
125
|
+
const {
|
126
|
+
element: pageSt
|
127
|
+
} = getPageSettings(editor) || {};
|
128
|
+
const {
|
129
|
+
pageProps
|
130
|
+
} = pageSt || {};
|
131
|
+
const {
|
132
|
+
theme
|
133
|
+
} = pageProps || {};
|
134
|
+
return {
|
135
|
+
selectedTheme: theme?.theme || defaultTheme?.theme,
|
136
|
+
updateTheme: (update, actionData) => updateTheme(editor, pageSt, update, actionData),
|
137
|
+
theme
|
138
|
+
};
|
139
|
+
};
|
@@ -29,6 +29,7 @@ export const EditorProvider = ({
|
|
29
29
|
const path = event?.target?.getAttribute("data-path");
|
30
30
|
const [popupType, setPopupType] = useState(""); // opened popup name in the editor will be stored
|
31
31
|
const [openAI, setOpenAI] = useState("");
|
32
|
+
const [selectedTheme, setSelectedTheme] = useState({});
|
32
33
|
const onDrop = () => {
|
33
34
|
setDrop(drop + 1);
|
34
35
|
};
|
@@ -55,7 +56,9 @@ export const EditorProvider = ({
|
|
55
56
|
popupType,
|
56
57
|
setPopupType,
|
57
58
|
openAI,
|
58
|
-
setOpenAI
|
59
|
+
setOpenAI,
|
60
|
+
selectedTheme,
|
61
|
+
setSelectedTheme
|
59
62
|
},
|
60
63
|
children: children
|
61
64
|
});
|
@@ -75,7 +78,6 @@ const useMouseMove = () => {
|
|
75
78
|
}, []);
|
76
79
|
const onMouseMove = e => {
|
77
80
|
const dpath = e?.target?.closest(".dpath");
|
78
|
-
console.log(dpath);
|
79
81
|
if (dpath) {
|
80
82
|
console.log(`Stopped position: (${e.clientX}, ${e.clientY})`, dpath);
|
81
83
|
setEvent({
|
@@ -4,9 +4,19 @@ const useWindowMessage = props => {
|
|
4
4
|
type
|
5
5
|
} = props;
|
6
6
|
const [message, setMessage] = useState(null);
|
7
|
+
const sendMessage = action => {
|
8
|
+
if (window.parent) {
|
9
|
+
window.parent.postMessage({
|
10
|
+
...action
|
11
|
+
}, "*");
|
12
|
+
}
|
13
|
+
};
|
7
14
|
useEffect(() => {
|
8
15
|
if (window.addEventListener) {
|
9
16
|
window.addEventListener("message", onMessage, false);
|
17
|
+
sendMessage({
|
18
|
+
isLoaded: true
|
19
|
+
});
|
10
20
|
} else {
|
11
21
|
window.attachEvent("onmessage", onMessage);
|
12
22
|
}
|
@@ -23,13 +33,6 @@ const useWindowMessage = props => {
|
|
23
33
|
setMessage(e?.data[type]);
|
24
34
|
}
|
25
35
|
};
|
26
|
-
const sendMessage = action => {
|
27
|
-
if (window.parent) {
|
28
|
-
window.parent.postMessage({
|
29
|
-
...action
|
30
|
-
}, "*");
|
31
|
-
}
|
32
|
-
};
|
33
36
|
return [message, sendMessage];
|
34
37
|
};
|
35
38
|
export default useWindowMessage;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Transforms, Path, Node } from "slate";
|
2
|
-
const AvoidCopying = ["headingOne", "headingTwo", "headingThree", "blockquote"];
|
2
|
+
const AvoidCopying = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree", "blockquote"];
|
3
3
|
const withEmbeds = editor => {
|
4
4
|
const {
|
5
5
|
isVoid,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Transforms, Editor, Element, Node } from "slate";
|
1
|
+
import { Transforms, Editor, Element, Node, Path } from "slate";
|
2
2
|
import deserialize from "../helper/deserialize";
|
3
3
|
import { decodeAndParseBase64 } from "../utils/helper";
|
4
4
|
const avoidDefaultInsert = ["table", "grid"];
|
@@ -15,7 +15,7 @@ const loopChildren = (children = [], defaultInsert) => {
|
|
15
15
|
}
|
16
16
|
return defaultInsert;
|
17
17
|
};
|
18
|
-
const getCurrentElement = editor => {
|
18
|
+
export const getCurrentElement = editor => {
|
19
19
|
try {
|
20
20
|
if (editor.selection) {
|
21
21
|
return Node.parent(editor, editor?.selection?.anchor?.path);
|
@@ -26,6 +26,48 @@ const getCurrentElement = editor => {
|
|
26
26
|
return null;
|
27
27
|
}
|
28
28
|
};
|
29
|
+
const getCurrentElementText = editor => {
|
30
|
+
try {
|
31
|
+
if (editor.selection) {
|
32
|
+
return Editor.string(editor, editor?.selection?.anchor?.path);
|
33
|
+
} else {
|
34
|
+
return null;
|
35
|
+
}
|
36
|
+
} catch (err) {
|
37
|
+
return null;
|
38
|
+
}
|
39
|
+
};
|
40
|
+
const insertAtNextNode = (editor, formattedFragment) => {
|
41
|
+
try {
|
42
|
+
const {
|
43
|
+
selection
|
44
|
+
} = editor;
|
45
|
+
if (selection) {
|
46
|
+
const parentPath = Path.parent(editor?.selection?.anchor?.path);
|
47
|
+
const nextPath = Path.next(parentPath);
|
48
|
+
Transforms.insertNodes(editor, {
|
49
|
+
type: "paragraph",
|
50
|
+
children: [{
|
51
|
+
text: ""
|
52
|
+
}]
|
53
|
+
}, {
|
54
|
+
at: nextPath
|
55
|
+
});
|
56
|
+
Transforms.insertFragment(editor, formattedFragment, {
|
57
|
+
at: nextPath
|
58
|
+
});
|
59
|
+
}
|
60
|
+
} catch (err) {
|
61
|
+
console.log(err);
|
62
|
+
}
|
63
|
+
};
|
64
|
+
const handleInsert = (editor, defaultInsert, fragment = []) => {
|
65
|
+
if (getCurrentElementText(editor) && fragment.some(f => f.type === "table")) {
|
66
|
+
insertAtNextNode(editor, fragment);
|
67
|
+
} else {
|
68
|
+
defaultInsert();
|
69
|
+
}
|
70
|
+
};
|
29
71
|
const formatFragment = {
|
30
72
|
"list-item": fragment => {
|
31
73
|
let refactorFragment = [];
|
@@ -64,11 +106,11 @@ const withHtml = editor => {
|
|
64
106
|
const currentEl = getCurrentElement(editor);
|
65
107
|
const eltype = currentEl?.type;
|
66
108
|
if (slateHTML && !formatFragment[eltype]) {
|
109
|
+
const decoded = decodeAndParseBase64(slateHTML);
|
67
110
|
const [tableNode] = Editor.nodes(editor, {
|
68
111
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
69
112
|
});
|
70
113
|
if (tableNode && tableNode[0]) {
|
71
|
-
const decoded = decodeAndParseBase64(slateHTML);
|
72
114
|
const defaultInsert = loopChildren(decoded, true);
|
73
115
|
if (defaultInsert) {
|
74
116
|
insertData(data);
|
@@ -79,7 +121,7 @@ const withHtml = editor => {
|
|
79
121
|
Transforms.insertText(editor, text);
|
80
122
|
}
|
81
123
|
} else {
|
82
|
-
insertData(data);
|
124
|
+
handleInsert(editor, () => insertData(data), decoded);
|
83
125
|
}
|
84
126
|
} else if (html) {
|
85
127
|
const parsed = new DOMParser().parseFromString(html, "text/html");
|
@@ -96,7 +138,7 @@ const withHtml = editor => {
|
|
96
138
|
}
|
97
139
|
const fragment = deserialize(parsed.body);
|
98
140
|
const formattedFragment = formatFragment[eltype] ? formatFragment[eltype](fragment) : fragment;
|
99
|
-
Transforms.insertFragment(editor, formattedFragment);
|
141
|
+
handleInsert(editor, () => Transforms.insertFragment(editor, formattedFragment), formattedFragment);
|
100
142
|
return;
|
101
143
|
} else {
|
102
144
|
insertData(data);
|
@@ -32,16 +32,21 @@ const withLayout = editor => {
|
|
32
32
|
editor.normalizeNode = ([node, path]) => {
|
33
33
|
if (path.length === 0) {
|
34
34
|
if (editor.children.length <= 1 && Editor.string(editor, [0, 0]) === "") {
|
35
|
-
const
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
35
|
+
const {
|
36
|
+
anchor
|
37
|
+
} = editor?.selection || {};
|
38
|
+
if (anchor?.offset !== 0) {
|
39
|
+
const title = {
|
40
|
+
type: "title",
|
41
|
+
children: [{
|
42
|
+
text: "Untitled"
|
43
|
+
}]
|
44
|
+
};
|
45
|
+
Transforms.insertNodes(editor, title, {
|
46
|
+
at: path.concat(0),
|
47
|
+
select: true
|
48
|
+
});
|
49
|
+
}
|
45
50
|
}
|
46
51
|
if (editor.children.length === 0) {
|
47
52
|
const paragraph = {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Editor, Range, Point, Element, Transforms, Node } from "slate";
|
2
2
|
import { TableUtil, createTableCell } from "../utils/table";
|
3
|
-
const NON_DELETABLE_BLOCKS = ["table-cell", "carousel-item"];
|
3
|
+
const NON_DELETABLE_BLOCKS = ["table-cell", "carousel-item", "page-settings"];
|
4
4
|
const withTable = editor => {
|
5
5
|
const {
|
6
6
|
deleteBackward,
|
@@ -8,7 +8,7 @@ const withTable = editor => {
|
|
8
8
|
delete: slateDelete
|
9
9
|
} = editor;
|
10
10
|
editor.delete = arg => {
|
11
|
-
if (arg
|
11
|
+
if (arg?.reverse) {
|
12
12
|
const table = new TableUtil(editor);
|
13
13
|
const cellsSelected = table.isCellSelected(editor.selection);
|
14
14
|
if (cellsSelected && cellsSelected.length > 1) {
|