@gravity-ui/page-constructor 6.3.2-alpha.0 → 6.3.2-alpha.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/build/cjs/blocks/ContentLayout/index.d.ts +1 -1
- package/build/cjs/blocks/ExtendedFeatures/index.d.ts +1 -1
- package/build/cjs/blocks/FilterBlock/index.d.ts +1 -1
- package/build/cjs/blocks/Form/index.d.ts +1 -1
- package/build/cjs/blocks/Header/index.d.ts +1 -1
- package/build/cjs/blocks/HeaderSlider/index.d.ts +1 -1
- package/build/cjs/blocks/Icons/index.d.ts +1 -1
- package/build/cjs/blocks/Info/index.d.ts +1 -1
- package/build/cjs/blocks/Map/index.d.ts +1 -1
- package/build/cjs/blocks/Media/index.d.ts +1 -1
- package/build/cjs/blocks/PromoFeaturesBlock/index.d.ts +1 -1
- package/build/cjs/blocks/Questions/index.d.ts +1 -1
- package/build/cjs/blocks/Share/index.d.ts +1 -1
- package/build/cjs/blocks/Slider/index.d.ts +1 -1
- package/build/cjs/blocks/Table/index.d.ts +1 -1
- package/build/cjs/blocks/Tabs/index.d.ts +1 -1
- package/build/cjs/blocks/TestEditorBlock/index.d.ts +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.css +0 -0
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.d.ts +9 -0
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.js +115 -0
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.css +89 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.d.ts +12 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.js +27 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.css +37 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.d.ts +11 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.js +68 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.d.ts +10 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.js +22 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.css +3 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.d.ts +8 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.js +13 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Number/Number.d.ts +8 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Number/Number.js +16 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Number/Number.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.d.ts +10 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.js +12 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.css +6 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.d.ts +9 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js +35 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.css +3 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.d.ts +11 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.js +14 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Text/Text.d.ts +8 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Text/Text.js +13 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Text/Text.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.d.ts +8 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.js +13 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/utils.d.ts +3 -0
- package/build/cjs/editor-v2/components/DynamicForm/utils.js +23 -0
- package/build/cjs/editor-v2/components/DynamicForm/utils.js.map +1 -0
- package/build/cjs/editor-v2/components/Panels/Panels.css +37 -0
- package/build/cjs/editor-v2/components/Panels/Panels.d.ts +8 -0
- package/build/cjs/editor-v2/components/Panels/Panels.js +28 -0
- package/build/cjs/editor-v2/components/Panels/Panels.js.map +1 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.css +24 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.d.ts +10 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.js +13 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.js.map +1 -0
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.css +29 -0
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.d.ts +6 -0
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.js +17 -0
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.js.map +1 -0
- package/build/cjs/editor-v2/components/Tabs/Tabs.css +26 -0
- package/build/cjs/editor-v2/components/Tabs/Tabs.d.ts +13 -0
- package/build/cjs/editor-v2/components/Tabs/Tabs.js +32 -0
- package/build/cjs/editor-v2/components/Tabs/Tabs.js.map +1 -0
- package/build/cjs/editor-v2/constants.d.ts +1 -0
- package/build/cjs/editor-v2/constants.js +5 -0
- package/build/cjs/editor-v2/constants.js.map +1 -0
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.css +35 -0
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.d.ts +4 -0
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.js +58 -0
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.js.map +1 -0
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.css +33 -0
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.d.ts +5 -0
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.js +28 -0
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.js.map +1 -0
- package/build/cjs/editor-v2/containers/BlocksList/BlocksList.css +65 -0
- package/build/cjs/editor-v2/containers/BlocksList/BlocksList.d.ts +2 -0
- package/build/cjs/editor-v2/containers/BlocksList/BlocksList.js +43 -0
- package/build/cjs/editor-v2/containers/BlocksList/BlocksList.js.map +1 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.css +51 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.d.ts +21 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.js +40 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.js.map +1 -0
- package/build/cjs/editor-v2/containers/GlobalConfig/GlobalConfig.css +24 -0
- package/build/cjs/editor-v2/containers/GlobalConfig/GlobalConfig.d.ts +5 -0
- package/build/cjs/editor-v2/containers/GlobalConfig/GlobalConfig.js +17 -0
- package/build/cjs/editor-v2/containers/GlobalConfig/GlobalConfig.js.map +1 -0
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.css +62 -0
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.d.ts +7 -0
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.js +34 -0
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.js.map +1 -0
- package/build/cjs/editor-v2/containers/Overlay/Overlay.css +60 -0
- package/build/cjs/editor-v2/containers/Overlay/Overlay.d.ts +6 -0
- package/build/cjs/editor-v2/containers/Overlay/Overlay.js +90 -0
- package/build/cjs/editor-v2/containers/Overlay/Overlay.js.map +1 -0
- package/build/cjs/editor-v2/containers/Source/Source.css +27 -0
- package/build/cjs/editor-v2/containers/Source/Source.d.ts +2 -0
- package/build/cjs/editor-v2/containers/Source/Source.js +28 -0
- package/build/cjs/editor-v2/containers/Source/Source.js.map +1 -0
- package/build/cjs/editor-v2/containers/SourceCode/SourceCode.css +50 -0
- package/build/cjs/editor-v2/containers/SourceCode/SourceCode.d.ts +6 -0
- package/build/cjs/editor-v2/containers/SourceCode/SourceCode.js +41 -0
- package/build/cjs/editor-v2/containers/SourceCode/SourceCode.js.map +1 -0
- package/build/cjs/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.css +3 -0
- package/build/cjs/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.d.ts +7 -0
- package/build/cjs/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.js +18 -0
- package/build/cjs/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.js.map +1 -0
- package/build/cjs/editor-v2/containers/Tree/DragContext.css +38 -0
- package/build/cjs/editor-v2/containers/Tree/DragContext.d.ts +14 -0
- package/build/cjs/editor-v2/containers/Tree/DragContext.js +49 -0
- package/build/cjs/editor-v2/containers/Tree/DragContext.js.map +1 -0
- package/build/cjs/editor-v2/containers/Tree/Tree.css +23 -0
- package/build/cjs/editor-v2/containers/Tree/Tree.d.ts +2 -0
- package/build/cjs/editor-v2/containers/Tree/Tree.js +36 -0
- package/build/cjs/editor-v2/containers/Tree/Tree.js.map +1 -0
- package/build/cjs/editor-v2/containers/Tree/TreeContent.css +28 -0
- package/build/cjs/editor-v2/containers/Tree/TreeContent.d.ts +16 -0
- package/build/cjs/editor-v2/containers/Tree/TreeContent.js +61 -0
- package/build/cjs/editor-v2/containers/Tree/TreeContent.js.map +1 -0
- package/build/cjs/editor-v2/containers/Tree/TreeItem.css +66 -0
- package/build/cjs/editor-v2/containers/Tree/TreeItem.d.ts +13 -0
- package/build/cjs/editor-v2/containers/Tree/TreeItem.js +144 -0
- package/build/cjs/editor-v2/containers/Tree/TreeItem.js.map +1 -0
- package/build/cjs/editor-v2/containers/Tree/index.d.ts +4 -0
- package/build/cjs/editor-v2/containers/Tree/index.js +10 -0
- package/build/cjs/editor-v2/containers/Tree/index.js.map +1 -0
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.css +23 -0
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.d.ts +3 -0
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.js +54 -0
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.js.map +1 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreContext.d.ts +7 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreContext.js +10 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreContext.js.map +1 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreProvider.d.ts +5 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreProvider.js +35 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreProvider.js.map +1 -0
- package/build/cjs/editor-v2/context/editorStore/index.d.ts +2 -0
- package/build/cjs/editor-v2/context/editorStore/index.js +6 -0
- package/build/cjs/editor-v2/context/editorStore/index.js.map +1 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeContext.d.ts +12 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeContext.js +14 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeContext.js.map +1 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeProvider.d.ts +7 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeProvider.js +21 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeProvider.js.map +1 -0
- package/build/cjs/editor-v2/context/iframeContext/index.d.ts +2 -0
- package/build/cjs/editor-v2/context/iframeContext/index.js +6 -0
- package/build/cjs/editor-v2/context/iframeContext/index.js.map +1 -0
- package/build/cjs/editor-v2/hooks/useEditorTabs.d.ts +16 -0
- package/build/cjs/editor-v2/hooks/useEditorTabs.js +77 -0
- package/build/cjs/editor-v2/hooks/useEditorTabs.js.map +1 -0
- package/build/cjs/editor-v2/hooks/useMainEditorInitialize.d.ts +2 -0
- package/build/cjs/editor-v2/hooks/useMainEditorInitialize.js +31 -0
- package/build/cjs/editor-v2/hooks/useMainEditorInitialize.js.map +1 -0
- package/build/cjs/editor-v2/hooks/useMainEditorStore.d.ts +1 -0
- package/build/cjs/editor-v2/hooks/useMainEditorStore.js +13 -0
- package/build/cjs/editor-v2/hooks/useMainEditorStore.js.map +1 -0
- package/build/cjs/editor-v2/hooks/usePostMessageEvents.d.ts +6 -0
- package/build/cjs/editor-v2/hooks/usePostMessageEvents.js +19 -0
- package/build/cjs/editor-v2/hooks/usePostMessageEvents.js.map +1 -0
- package/build/cjs/editor-v2/index.d.ts +2 -0
- package/build/cjs/editor-v2/index.js +8 -0
- package/build/cjs/editor-v2/index.js.map +1 -0
- package/build/cjs/editor-v2/store.d.ts +48 -0
- package/build/cjs/editor-v2/store.js +181 -0
- package/build/cjs/editor-v2/store.js.map +1 -0
- package/build/cjs/editor-v2/styles/mixins.css +0 -0
- package/build/cjs/editor-v2/styles/root.css +12 -0
- package/build/cjs/editor-v2/styles/variables.css +0 -0
- package/build/cjs/editor-v2/utils/cn.d.ts +2 -0
- package/build/cjs/editor-v2/utils/cn.js +7 -0
- package/build/cjs/editor-v2/utils/cn.js.map +1 -0
- package/build/cjs/editor-v2/utils/code.d.ts +6 -0
- package/build/cjs/editor-v2/utils/code.js +13 -0
- package/build/cjs/editor-v2/utils/code.js.map +1 -0
- package/build/cjs/editor-v2/utils/index.d.ts +18 -0
- package/build/cjs/editor-v2/utils/index.js +159 -0
- package/build/cjs/editor-v2/utils/index.js.map +1 -0
- package/build/esm/blocks/ContentLayout/index.d.ts +1 -1
- package/build/esm/blocks/ExtendedFeatures/index.d.ts +1 -1
- package/build/esm/blocks/FilterBlock/index.d.ts +1 -1
- package/build/esm/blocks/Form/index.d.ts +1 -1
- package/build/esm/blocks/Header/index.d.ts +1 -1
- package/build/esm/blocks/HeaderSlider/index.d.ts +1 -1
- package/build/esm/blocks/Icons/index.d.ts +1 -1
- package/build/esm/blocks/Info/index.d.ts +1 -1
- package/build/esm/blocks/Map/index.d.ts +1 -1
- package/build/esm/blocks/Media/index.d.ts +1 -1
- package/build/esm/blocks/PromoFeaturesBlock/index.d.ts +1 -1
- package/build/esm/blocks/Questions/index.d.ts +1 -1
- package/build/esm/blocks/Share/index.d.ts +1 -1
- package/build/esm/blocks/Slider/index.d.ts +1 -1
- package/build/esm/blocks/Table/index.d.ts +1 -1
- package/build/esm/blocks/Tabs/index.d.ts +1 -1
- package/build/esm/blocks/TestEditorBlock/index.d.ts +1 -1
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.css +0 -0
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.d.ts +10 -0
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.js +113 -0
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.css +89 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.d.ts +13 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.js +25 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.css +37 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.d.ts +12 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.js +66 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.d.ts +10 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.js +19 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.css +3 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.d.ts +9 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.js +11 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Number/Number.d.ts +8 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Number/Number.js +13 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Number/Number.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.d.ts +10 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.js +9 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.css +6 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.d.ts +10 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js +33 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Select/Select.css +3 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Select/Select.d.ts +12 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Select/Select.js +12 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Select/Select.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Text/Text.d.ts +8 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Text/Text.js +10 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Text/Text.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.d.ts +8 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.js +10 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/utils.d.ts +3 -0
- package/build/esm/editor-v2/components/DynamicForm/utils.js +17 -0
- package/build/esm/editor-v2/components/DynamicForm/utils.js.map +1 -0
- package/build/esm/editor-v2/components/Panels/Panels.css +37 -0
- package/build/esm/editor-v2/components/Panels/Panels.d.ts +9 -0
- package/build/esm/editor-v2/components/Panels/Panels.js +24 -0
- package/build/esm/editor-v2/components/Panels/Panels.js.map +1 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.css +24 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.d.ts +11 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.js +9 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.js.map +1 -0
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.css +29 -0
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.d.ts +7 -0
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.js +15 -0
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.js.map +1 -0
- package/build/esm/editor-v2/components/Tabs/Tabs.css +26 -0
- package/build/esm/editor-v2/components/Tabs/Tabs.d.ts +14 -0
- package/build/esm/editor-v2/components/Tabs/Tabs.js +30 -0
- package/build/esm/editor-v2/components/Tabs/Tabs.js.map +1 -0
- package/build/esm/editor-v2/constants.d.ts +1 -0
- package/build/esm/editor-v2/constants.js +2 -0
- package/build/esm/editor-v2/constants.js.map +1 -0
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.css +35 -0
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.d.ts +5 -0
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.js +56 -0
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.js.map +1 -0
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.css +33 -0
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.d.ts +6 -0
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.js +26 -0
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.js.map +1 -0
- package/build/esm/editor-v2/containers/BlocksList/BlocksList.css +65 -0
- package/build/esm/editor-v2/containers/BlocksList/BlocksList.d.ts +3 -0
- package/build/esm/editor-v2/containers/BlocksList/BlocksList.js +41 -0
- package/build/esm/editor-v2/containers/BlocksList/BlocksList.js.map +1 -0
- package/build/esm/editor-v2/containers/Editor/Editor.css +51 -0
- package/build/esm/editor-v2/containers/Editor/Editor.d.ts +22 -0
- package/build/esm/editor-v2/containers/Editor/Editor.js +36 -0
- package/build/esm/editor-v2/containers/Editor/Editor.js.map +1 -0
- package/build/esm/editor-v2/containers/GlobalConfig/GlobalConfig.css +24 -0
- package/build/esm/editor-v2/containers/GlobalConfig/GlobalConfig.d.ts +6 -0
- package/build/esm/editor-v2/containers/GlobalConfig/GlobalConfig.js +15 -0
- package/build/esm/editor-v2/containers/GlobalConfig/GlobalConfig.js.map +1 -0
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.css +62 -0
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.d.ts +8 -0
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.js +32 -0
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.js.map +1 -0
- package/build/esm/editor-v2/containers/Overlay/Overlay.css +60 -0
- package/build/esm/editor-v2/containers/Overlay/Overlay.d.ts +7 -0
- package/build/esm/editor-v2/containers/Overlay/Overlay.js +88 -0
- package/build/esm/editor-v2/containers/Overlay/Overlay.js.map +1 -0
- package/build/esm/editor-v2/containers/Source/Source.css +27 -0
- package/build/esm/editor-v2/containers/Source/Source.d.ts +3 -0
- package/build/esm/editor-v2/containers/Source/Source.js +26 -0
- package/build/esm/editor-v2/containers/Source/Source.js.map +1 -0
- package/build/esm/editor-v2/containers/SourceCode/SourceCode.css +50 -0
- package/build/esm/editor-v2/containers/SourceCode/SourceCode.d.ts +7 -0
- package/build/esm/editor-v2/containers/SourceCode/SourceCode.js +39 -0
- package/build/esm/editor-v2/containers/SourceCode/SourceCode.js.map +1 -0
- package/build/esm/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.css +3 -0
- package/build/esm/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.d.ts +8 -0
- package/build/esm/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.js +14 -0
- package/build/esm/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.js.map +1 -0
- package/build/esm/editor-v2/containers/Tree/DragContext.css +38 -0
- package/build/esm/editor-v2/containers/Tree/DragContext.d.ts +15 -0
- package/build/esm/editor-v2/containers/Tree/DragContext.js +45 -0
- package/build/esm/editor-v2/containers/Tree/DragContext.js.map +1 -0
- package/build/esm/editor-v2/containers/Tree/Tree.css +23 -0
- package/build/esm/editor-v2/containers/Tree/Tree.d.ts +3 -0
- package/build/esm/editor-v2/containers/Tree/Tree.js +34 -0
- package/build/esm/editor-v2/containers/Tree/Tree.js.map +1 -0
- package/build/esm/editor-v2/containers/Tree/TreeContent.css +28 -0
- package/build/esm/editor-v2/containers/Tree/TreeContent.d.ts +17 -0
- package/build/esm/editor-v2/containers/Tree/TreeContent.js +57 -0
- package/build/esm/editor-v2/containers/Tree/TreeContent.js.map +1 -0
- package/build/esm/editor-v2/containers/Tree/TreeItem.css +66 -0
- package/build/esm/editor-v2/containers/Tree/TreeItem.d.ts +14 -0
- package/build/esm/editor-v2/containers/Tree/TreeItem.js +140 -0
- package/build/esm/editor-v2/containers/Tree/TreeItem.js.map +1 -0
- package/build/esm/editor-v2/containers/Tree/index.d.ts +4 -0
- package/build/esm/editor-v2/containers/Tree/index.js +5 -0
- package/build/esm/editor-v2/containers/Tree/index.js.map +1 -0
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.css +23 -0
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.d.ts +4 -0
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.js +52 -0
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.js.map +1 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreContext.d.ts +7 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreContext.js +6 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreContext.js.map +1 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreProvider.d.ts +5 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreProvider.js +30 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreProvider.js.map +1 -0
- package/build/esm/editor-v2/context/editorStore/index.d.ts +2 -0
- package/build/esm/editor-v2/context/editorStore/index.js +3 -0
- package/build/esm/editor-v2/context/editorStore/index.js.map +1 -0
- package/build/esm/editor-v2/context/iframeContext/IframeContext.d.ts +12 -0
- package/build/esm/editor-v2/context/iframeContext/IframeContext.js +10 -0
- package/build/esm/editor-v2/context/iframeContext/IframeContext.js.map +1 -0
- package/build/esm/editor-v2/context/iframeContext/IframeProvider.d.ts +7 -0
- package/build/esm/editor-v2/context/iframeContext/IframeProvider.js +16 -0
- package/build/esm/editor-v2/context/iframeContext/IframeProvider.js.map +1 -0
- package/build/esm/editor-v2/context/iframeContext/index.d.ts +2 -0
- package/build/esm/editor-v2/context/iframeContext/index.js +3 -0
- package/build/esm/editor-v2/context/iframeContext/index.js.map +1 -0
- package/build/esm/editor-v2/hooks/useEditorTabs.d.ts +16 -0
- package/build/esm/editor-v2/hooks/useEditorTabs.js +72 -0
- package/build/esm/editor-v2/hooks/useEditorTabs.js.map +1 -0
- package/build/esm/editor-v2/hooks/useMainEditorInitialize.d.ts +2 -0
- package/build/esm/editor-v2/hooks/useMainEditorInitialize.js +29 -0
- package/build/esm/editor-v2/hooks/useMainEditorInitialize.js.map +1 -0
- package/build/esm/editor-v2/hooks/useMainEditorStore.d.ts +1 -0
- package/build/esm/editor-v2/hooks/useMainEditorStore.js +8 -0
- package/build/esm/editor-v2/hooks/useMainEditorStore.js.map +1 -0
- package/build/esm/editor-v2/hooks/usePostMessageEvents.d.ts +6 -0
- package/build/esm/editor-v2/hooks/usePostMessageEvents.js +15 -0
- package/build/esm/editor-v2/hooks/usePostMessageEvents.js.map +1 -0
- package/build/esm/editor-v2/index.d.ts +2 -0
- package/build/esm/editor-v2/index.js +3 -0
- package/build/esm/editor-v2/index.js.map +1 -0
- package/build/esm/editor-v2/store.d.ts +48 -0
- package/build/esm/editor-v2/store.js +177 -0
- package/build/esm/editor-v2/store.js.map +1 -0
- package/build/esm/editor-v2/styles/mixins.css +0 -0
- package/build/esm/editor-v2/styles/root.css +12 -0
- package/build/esm/editor-v2/styles/variables.css +0 -0
- package/build/esm/editor-v2/utils/cn.d.ts +2 -0
- package/build/esm/editor-v2/utils/cn.js +4 -0
- package/build/esm/editor-v2/utils/cn.js.map +1 -0
- package/build/esm/editor-v2/utils/code.d.ts +6 -0
- package/build/esm/editor-v2/utils/code.js +9 -0
- package/build/esm/editor-v2/utils/code.js.map +1 -0
- package/build/esm/editor-v2/utils/index.d.ts +18 -0
- package/build/esm/editor-v2/utils/index.js +141 -0
- package/build/esm/editor-v2/utils/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionMessageTypes } from "../../../common/types/index.js";
|
|
2
|
+
interface UsePostMessageRequestReturn {
|
|
3
|
+
requestPostMessage: <K extends keyof ActionMessageTypes>(action: K, data: ActionMessageTypes[K]) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare function usePostMessageEvents(): UsePostMessageRequestReturn;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { requestActionPostMessage } from "../../../common/postMessage.js";
|
|
3
|
+
import { IframeContext } from "../context/iframeContext/index.js";
|
|
4
|
+
export function usePostMessageEvents() {
|
|
5
|
+
const { iframeElement } = React.useContext(IframeContext);
|
|
6
|
+
return {
|
|
7
|
+
requestPostMessage: (action, data) => {
|
|
8
|
+
if (iframeElement && iframeElement.contentWindow) {
|
|
9
|
+
return requestActionPostMessage(action, data, iframeElement.contentWindow);
|
|
10
|
+
}
|
|
11
|
+
return undefined;
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=usePostMessageEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePostMessageEvents.js","sourceRoot":"../../../../src","sources":["editor-v2/hooks/usePostMessageEvents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,wBAAwB,EAAC,uCAAoC;AAErE,OAAO,EAAC,aAAa,EAAC,0CAAiC;AASvD,MAAM,UAAU,oBAAoB;IAChC,MAAM,EAAC,aAAa,EAAC,GAAG,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAExD,OAAO;QACH,kBAAkB,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;YACjC,IAAI,aAAa,IAAI,aAAa,CAAC,aAAa,EAAE,CAAC;gBAC/C,OAAO,wBAAwB,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;YAC/E,CAAC;YAED,OAAO,SAAS,CAAC;QACrB,CAAC;KACJ,CAAC;AACN,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {requestActionPostMessage} from '../../../common/postMessage';\nimport {ActionMessageTypes} from '../../../common/types';\nimport {IframeContext} from '../context/iframeContext';\n\ninterface UsePostMessageRequestReturn {\n requestPostMessage: <K extends keyof ActionMessageTypes>(\n action: K,\n data: ActionMessageTypes[K],\n ) => void;\n}\n\nexport function usePostMessageEvents(): UsePostMessageRequestReturn {\n const {iframeElement} = React.useContext(IframeContext);\n\n return {\n requestPostMessage: (action, data) => {\n if (iframeElement && iframeElement.contentWindow) {\n return requestActionPostMessage(action, data, iframeElement.contentWindow);\n }\n\n return undefined;\n },\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../src","sources":["editor-v2/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,sCAAmC;AAClD,4CAAmC","sourcesContent":["export {Editor} from './containers/Editor/Editor';\nexport * from '../../common/types';\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { EditorState } from "../../common/store.js";
|
|
2
|
+
import { DynamicFormValue } from "../../common/types/index.js";
|
|
3
|
+
import { PageContentWithNavigation } from "../models/index.js";
|
|
4
|
+
export interface EditorMethods {
|
|
5
|
+
initialize(): void;
|
|
6
|
+
setSelectedBlock(path: number[] | null): void;
|
|
7
|
+
setHeight(height: number): void;
|
|
8
|
+
setDeviceWidth(deviceWidth: string): void;
|
|
9
|
+
setZoom(zoom: number): void;
|
|
10
|
+
increaseZoom(): void;
|
|
11
|
+
decreaseZoom(): void;
|
|
12
|
+
setConfig(data: Pick<EditorState, 'blocks' | 'subBlocks' | 'global'>): void;
|
|
13
|
+
setContent(data: PageContentWithNavigation): void;
|
|
14
|
+
insertBlock(path: number[], blockType: string, position?: 'prepend' | 'append'): void;
|
|
15
|
+
enableInsertMode(blockType: string): void;
|
|
16
|
+
enableReorderMode(path: number[]): void;
|
|
17
|
+
disableMode(): void;
|
|
18
|
+
updateField(path: string, value: DynamicFormValue): void;
|
|
19
|
+
deleteBlock(path: number[]): void;
|
|
20
|
+
duplicateBlock(path: number[]): void;
|
|
21
|
+
reorderBlock(path: number[], destination: number[], position?: 'prepend' | 'append'): void;
|
|
22
|
+
resetInitialize(): void;
|
|
23
|
+
resetBlocks(): void;
|
|
24
|
+
}
|
|
25
|
+
export type EditorStore = EditorState & EditorMethods;
|
|
26
|
+
export declare const createEditorStore: (overrideInitialState?: Partial<EditorState> | undefined) => import("zustand").UseBoundStore<Omit<Omit<Omit<import("zustand").StoreApi<EditorState & EditorMethods>, "subscribe"> & {
|
|
27
|
+
subscribe: {
|
|
28
|
+
(listener: (selectedState: EditorState & EditorMethods, previousSelectedState: EditorState & EditorMethods) => void): () => void;
|
|
29
|
+
<U>(selector: (state: EditorState & EditorMethods) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
30
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
31
|
+
fireImmediately?: boolean;
|
|
32
|
+
} | undefined): () => void;
|
|
33
|
+
};
|
|
34
|
+
}, "setState"> & {
|
|
35
|
+
setState<A extends string | {
|
|
36
|
+
type: string;
|
|
37
|
+
}>(partial: (EditorState & EditorMethods) | Partial<EditorState & EditorMethods> | ((state: EditorState & EditorMethods) => (EditorState & EditorMethods) | Partial<EditorState & EditorMethods>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
38
|
+
}, "persist"> & {
|
|
39
|
+
persist: {
|
|
40
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<EditorState & EditorMethods, EditorState & EditorMethods>>) => void;
|
|
41
|
+
clearStorage: () => void;
|
|
42
|
+
rehydrate: () => Promise<void> | void;
|
|
43
|
+
hasHydrated: () => boolean;
|
|
44
|
+
onHydrate: (fn: (state: EditorState & EditorMethods) => void) => () => void;
|
|
45
|
+
onFinishHydration: (fn: (state: EditorState & EditorMethods) => void) => () => void;
|
|
46
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<EditorState & EditorMethods, EditorState & EditorMethods>>;
|
|
47
|
+
};
|
|
48
|
+
}>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { initialStore } from "../../common/store.js";
|
|
3
|
+
import { initializeStore } from "../../common/utils.js";
|
|
4
|
+
import { ZOOM_STEPS } from "./constants.js";
|
|
5
|
+
import { duplicateArrayItem, generateChildrenPathFromArray, getDestinationShiftBeforeReorder, insert, isItemsNeighbours, modifyObjectByPath, removeFromArray, reorderArrayItems, } from "./utils/index.js";
|
|
6
|
+
export const createEditorStore = initializeStore(initialStore, (set, get) => ({
|
|
7
|
+
setHeight(height) {
|
|
8
|
+
// We have to add 200-500px, because of bottom padding or margin of last element
|
|
9
|
+
// which is not taken into calculation of final height
|
|
10
|
+
const newHeight = height + 500;
|
|
11
|
+
set((state) => ({ ...state, height: newHeight }));
|
|
12
|
+
},
|
|
13
|
+
setDeviceWidth(deviceWidth) {
|
|
14
|
+
set((state) => ({ ...state, deviceWidth }));
|
|
15
|
+
},
|
|
16
|
+
setZoom(zoom) {
|
|
17
|
+
if (zoom > 0) {
|
|
18
|
+
set((state) => ({ ...state, zoom }));
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
increaseZoom() {
|
|
22
|
+
const currentZoom = get().zoom;
|
|
23
|
+
for (const step of ZOOM_STEPS) {
|
|
24
|
+
if (currentZoom < step) {
|
|
25
|
+
get().setZoom(step);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
decreaseZoom() {
|
|
31
|
+
const currentZoom = get().zoom;
|
|
32
|
+
const reverseSteps = ZOOM_STEPS.slice().reverse();
|
|
33
|
+
for (const step of reverseSteps) {
|
|
34
|
+
if (currentZoom > step) {
|
|
35
|
+
get().setZoom(step);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
setConfig(data) {
|
|
41
|
+
set((state) => ({ ...state, ...data }));
|
|
42
|
+
},
|
|
43
|
+
insertBlock: (arrayPath, blockType, position = 'append') => {
|
|
44
|
+
if (position === 'append') {
|
|
45
|
+
// TODO: fix
|
|
46
|
+
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign
|
|
47
|
+
arrayPath[arrayPath.length - 1] = arrayPath[arrayPath.length - 1] + 1;
|
|
48
|
+
}
|
|
49
|
+
const blocksConfig = get().content.blocks;
|
|
50
|
+
const blocksData = get().blocks;
|
|
51
|
+
const foundBlock = blocksData.find(({ type }) => type === blockType);
|
|
52
|
+
const defaultValue = foundBlock && foundBlock.schema.default
|
|
53
|
+
? { ...foundBlock.schema.default, type: blockType }
|
|
54
|
+
: { type: blockType };
|
|
55
|
+
const newBlocksConfig = modifyObjectByPath(blocksConfig, arrayPath, (parentBlocks, index) => insert(parentBlocks, index, defaultValue));
|
|
56
|
+
set((state) => ({
|
|
57
|
+
...state,
|
|
58
|
+
content: { ...state.content, blocks: newBlocksConfig },
|
|
59
|
+
selectedBlock: arrayPath,
|
|
60
|
+
}));
|
|
61
|
+
},
|
|
62
|
+
enableInsertMode(blockType) {
|
|
63
|
+
set((state) => ({
|
|
64
|
+
...state,
|
|
65
|
+
manipulateOverlayMode: 'insert',
|
|
66
|
+
preInsertBlockType: blockType,
|
|
67
|
+
}));
|
|
68
|
+
},
|
|
69
|
+
disableMode() {
|
|
70
|
+
set((state) => ({
|
|
71
|
+
...state,
|
|
72
|
+
manipulateOverlayMode: false,
|
|
73
|
+
preInsertBlockType: undefined,
|
|
74
|
+
preReorderBlockPath: undefined,
|
|
75
|
+
}));
|
|
76
|
+
},
|
|
77
|
+
enableReorderMode(path) {
|
|
78
|
+
set((state) => ({
|
|
79
|
+
...state,
|
|
80
|
+
manipulateOverlayMode: 'reorder',
|
|
81
|
+
preReorderBlockPath: path,
|
|
82
|
+
}));
|
|
83
|
+
},
|
|
84
|
+
setContent(content) {
|
|
85
|
+
set((state) => ({
|
|
86
|
+
...state,
|
|
87
|
+
content: content,
|
|
88
|
+
}));
|
|
89
|
+
},
|
|
90
|
+
initialize() {
|
|
91
|
+
set((state) => ({
|
|
92
|
+
...state,
|
|
93
|
+
initialized: true,
|
|
94
|
+
}));
|
|
95
|
+
},
|
|
96
|
+
setSelectedBlock(path) {
|
|
97
|
+
set((state) => ({
|
|
98
|
+
...state,
|
|
99
|
+
selectedBlock: path,
|
|
100
|
+
}));
|
|
101
|
+
},
|
|
102
|
+
updateField(path, value) {
|
|
103
|
+
set((state) => {
|
|
104
|
+
const newConfig = _.set(state.content, path, value);
|
|
105
|
+
return {
|
|
106
|
+
...state,
|
|
107
|
+
content: newConfig,
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
deleteBlock: (arrayPath) => {
|
|
112
|
+
const blocksConfig = get().content.blocks;
|
|
113
|
+
const newBlocksConfig = modifyObjectByPath(blocksConfig, arrayPath, removeFromArray);
|
|
114
|
+
set((state) => ({
|
|
115
|
+
...state,
|
|
116
|
+
content: { ...state.content, blocks: newBlocksConfig },
|
|
117
|
+
selectedBlock: null,
|
|
118
|
+
}));
|
|
119
|
+
},
|
|
120
|
+
duplicateBlock: (arrayPath) => {
|
|
121
|
+
const blocksConfig = get().content.blocks;
|
|
122
|
+
const newBlocksConfig = modifyObjectByPath(blocksConfig, arrayPath, duplicateArrayItem);
|
|
123
|
+
set((state) => ({
|
|
124
|
+
...state,
|
|
125
|
+
content: { ...state.content, blocks: newBlocksConfig },
|
|
126
|
+
}));
|
|
127
|
+
},
|
|
128
|
+
reorderBlock: (arrayPath, destination, position = 'append') => {
|
|
129
|
+
// Create a copy of the destination array before any modifications
|
|
130
|
+
let finalDestinationPath = _.cloneDeep(destination);
|
|
131
|
+
if (position === 'append') {
|
|
132
|
+
// TODO: fix
|
|
133
|
+
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign
|
|
134
|
+
destination[destination.length - 1] = destination[destination.length - 1] + 1;
|
|
135
|
+
}
|
|
136
|
+
let newBlocksConfig;
|
|
137
|
+
const blocksConfig = get().content.blocks;
|
|
138
|
+
// Copy
|
|
139
|
+
const copiedBlock = _.get(blocksConfig, generateChildrenPathFromArray(arrayPath));
|
|
140
|
+
if (isItemsNeighbours(arrayPath, destination)) {
|
|
141
|
+
newBlocksConfig = modifyObjectByPath(blocksConfig, arrayPath, (parentBlocks) => {
|
|
142
|
+
return reorderArrayItems(parentBlocks, arrayPath[arrayPath.length - 1], destination[destination.length - 1]);
|
|
143
|
+
});
|
|
144
|
+
if (position === 'append' &&
|
|
145
|
+
destination[destination.length - 1] < arrayPath[arrayPath.length - 1]) {
|
|
146
|
+
finalDestinationPath[finalDestinationPath.length - 1] =
|
|
147
|
+
finalDestinationPath[finalDestinationPath.length - 1] + 1;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
const arrayDest = getDestinationShiftBeforeReorder(arrayPath, destination);
|
|
152
|
+
finalDestinationPath = _.cloneDeep(arrayDest);
|
|
153
|
+
// Delete
|
|
154
|
+
const blocksConfigWithoutBlock = modifyObjectByPath(blocksConfig, arrayPath, removeFromArray);
|
|
155
|
+
// Paste
|
|
156
|
+
newBlocksConfig = modifyObjectByPath(blocksConfigWithoutBlock, arrayDest, (parentBlocks, index) => insert(parentBlocks, index, copiedBlock));
|
|
157
|
+
}
|
|
158
|
+
set((state) => ({
|
|
159
|
+
...state,
|
|
160
|
+
content: { ...state.content, blocks: newBlocksConfig },
|
|
161
|
+
selectedBlock: finalDestinationPath,
|
|
162
|
+
}));
|
|
163
|
+
},
|
|
164
|
+
resetInitialize: () => {
|
|
165
|
+
set((state) => ({
|
|
166
|
+
...state,
|
|
167
|
+
initialized: false,
|
|
168
|
+
}));
|
|
169
|
+
},
|
|
170
|
+
resetBlocks: () => {
|
|
171
|
+
set((state) => ({
|
|
172
|
+
...state,
|
|
173
|
+
content: { ...state.content, blocks: [] },
|
|
174
|
+
}));
|
|
175
|
+
},
|
|
176
|
+
}));
|
|
177
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"../../../src","sources":["editor-v2/store.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,OAAO,EAAc,YAAY,EAAC,8BAA2B;AAE7D,OAAO,EAAC,eAAe,EAAC,8BAA2B;AAGnD,OAAO,EAAC,UAAU,EAAC,uBAAoB;AACvC,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,SAAS,EACT,eAAe,CAClB,CAAC;YACF,QAAQ;YACR,eAAe,GAAG,kBAAkB,CAChC,wBAAwB,EACxB,SAAS,EACT,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,EAAE,WAAW,CAAC,CACpE,CAAC;QACN,CAAC;QAED,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACZ,GAAG,KAAK;YACR,OAAO,EAAE,EAAC,GAAG,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAC;YACpD,aAAa,EAAE,oBAAoB;SACtC,CAAC,CAAC,CAAC;IACR,CAAC;IACD,eAAe,EAAE,GAAG,EAAE;QAClB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACZ,GAAG,KAAK;YACR,WAAW,EAAE,KAAK;SACrB,CAAC,CAAC,CAAC;IACR,CAAC;IACD,WAAW,EAAE,GAAG,EAAE;QACd,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACZ,GAAG,KAAK;YACR,OAAO,EAAE,EAAC,GAAG,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAC;SAC1C,CAAC,CAAC,CAAC;IACR,CAAC;CACJ,CAAC,CACL,CAAC","sourcesContent":["import _ from 'lodash';\n\nimport {EditorState, initialStore} from '../../common/store';\nimport {DynamicFormValue} from '../../common/types';\nimport {initializeStore} from '../../common/utils';\nimport {ConstructorBlock, PageContentWithNavigation} from '../models';\n\nimport {ZOOM_STEPS} from './constants';\nimport {\n duplicateArrayItem,\n generateChildrenPathFromArray,\n getDestinationShiftBeforeReorder,\n insert,\n isItemsNeighbours,\n modifyObjectByPath,\n removeFromArray,\n reorderArrayItems,\n} from './utils';\n\nexport interface EditorMethods {\n initialize(): void;\n setSelectedBlock(path: number[] | null): void;\n setHeight(height: number): void;\n setDeviceWidth(deviceWidth: string): void;\n setZoom(zoom: number): void;\n increaseZoom(): void;\n decreaseZoom(): void;\n setConfig(data: Pick<EditorState, 'blocks' | 'subBlocks' | 'global'>): void;\n setContent(data: PageContentWithNavigation): void;\n insertBlock(path: number[], blockType: string, position?: 'prepend' | 'append'): void;\n enableInsertMode(blockType: string): void;\n enableReorderMode(path: number[]): void;\n disableMode(): void;\n updateField(path: string, value: DynamicFormValue): void;\n deleteBlock(path: number[]): void;\n duplicateBlock(path: number[]): void;\n reorderBlock(path: number[], destination: number[], position?: 'prepend' | 'append'): void;\n resetInitialize(): void;\n resetBlocks(): void;\n}\n\nexport type EditorStore = EditorState & EditorMethods;\n\nexport const createEditorStore = initializeStore<EditorState, EditorMethods>(\n initialStore,\n (set, get) => ({\n setHeight(height: number) {\n // We have to add 200-500px, because of bottom padding or margin of last element\n // which is not taken into calculation of final height\n const newHeight = height + 500;\n set((state) => ({...state, height: newHeight}));\n },\n setDeviceWidth(deviceWidth: string) {\n set((state) => ({...state, deviceWidth}));\n },\n setZoom(zoom) {\n if (zoom > 0) {\n set((state) => ({...state, zoom}));\n }\n },\n increaseZoom() {\n const currentZoom = get().zoom;\n\n for (const step of ZOOM_STEPS) {\n if (currentZoom < step) {\n get().setZoom(step);\n break;\n }\n }\n },\n decreaseZoom() {\n const currentZoom = get().zoom;\n const reverseSteps = ZOOM_STEPS.slice().reverse();\n\n for (const step of reverseSteps) {\n if (currentZoom > step) {\n get().setZoom(step);\n break;\n }\n }\n },\n setConfig(data) {\n set((state) => ({...state, ...data}));\n },\n insertBlock: (arrayPath, blockType, position = 'append') => {\n if (position === 'append') {\n // TODO: fix\n // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign\n arrayPath[arrayPath.length - 1] = arrayPath[arrayPath.length - 1] + 1;\n }\n\n const blocksConfig = get().content.blocks;\n const blocksData = get().blocks;\n\n const foundBlock = blocksData.find(({type}) => type === blockType);\n const defaultValue =\n foundBlock && foundBlock.schema.default\n ? {...foundBlock.schema.default, type: blockType}\n : {type: blockType};\n\n const newBlocksConfig = modifyObjectByPath(\n blocksConfig,\n arrayPath,\n (parentBlocks, index) =>\n insert(parentBlocks, index, defaultValue as ConstructorBlock),\n );\n\n set((state) => ({\n ...state,\n content: {...state.content, blocks: newBlocksConfig},\n selectedBlock: arrayPath,\n }));\n },\n enableInsertMode(blockType: string) {\n set((state) => ({\n ...state,\n manipulateOverlayMode: 'insert',\n preInsertBlockType: blockType,\n }));\n },\n disableMode() {\n set((state) => ({\n ...state,\n manipulateOverlayMode: false,\n preInsertBlockType: undefined,\n preReorderBlockPath: undefined,\n }));\n },\n enableReorderMode(path) {\n set((state) => ({\n ...state,\n manipulateOverlayMode: 'reorder',\n preReorderBlockPath: path,\n }));\n },\n setContent(content) {\n set((state) => ({\n ...state,\n content: content,\n }));\n },\n initialize() {\n set((state) => ({\n ...state,\n initialized: true,\n }));\n },\n setSelectedBlock(path) {\n set((state) => ({\n ...state,\n selectedBlock: path,\n }));\n },\n updateField(path, value) {\n set((state) => {\n const newConfig = _.set(state.content, path, value);\n return {\n ...state,\n content: newConfig,\n };\n });\n },\n deleteBlock: (arrayPath) => {\n const blocksConfig = get().content.blocks;\n\n const newBlocksConfig = modifyObjectByPath(blocksConfig, arrayPath, removeFromArray);\n set((state) => ({\n ...state,\n content: {...state.content, blocks: newBlocksConfig},\n selectedBlock: null,\n }));\n },\n duplicateBlock: (arrayPath) => {\n const blocksConfig = get().content.blocks;\n\n const newBlocksConfig = modifyObjectByPath(blocksConfig, arrayPath, duplicateArrayItem);\n\n set((state) => ({\n ...state,\n content: {...state.content, blocks: newBlocksConfig},\n }));\n },\n reorderBlock: (arrayPath, destination, position = 'append') => {\n // Create a copy of the destination array before any modifications\n let finalDestinationPath: number[] = _.cloneDeep(destination);\n\n if (position === 'append') {\n // TODO: fix\n // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign\n destination[destination.length - 1] = destination[destination.length - 1] + 1;\n }\n\n let newBlocksConfig: ConstructorBlock[];\n const blocksConfig = get().content.blocks;\n // Copy\n const copiedBlock = _.get(blocksConfig, generateChildrenPathFromArray(arrayPath));\n\n if (isItemsNeighbours(arrayPath, destination)) {\n newBlocksConfig = modifyObjectByPath(blocksConfig, arrayPath, (parentBlocks) => {\n return reorderArrayItems(\n parentBlocks,\n arrayPath[arrayPath.length - 1],\n destination[destination.length - 1],\n );\n });\n\n if (\n position === 'append' &&\n destination[destination.length - 1] < arrayPath[arrayPath.length - 1]\n ) {\n finalDestinationPath[finalDestinationPath.length - 1] =\n finalDestinationPath[finalDestinationPath.length - 1] + 1;\n }\n } else {\n const arrayDest = getDestinationShiftBeforeReorder(arrayPath, destination);\n finalDestinationPath = _.cloneDeep(arrayDest);\n\n // Delete\n const blocksConfigWithoutBlock = modifyObjectByPath(\n blocksConfig,\n arrayPath,\n removeFromArray,\n );\n // Paste\n newBlocksConfig = modifyObjectByPath(\n blocksConfigWithoutBlock,\n arrayDest,\n (parentBlocks, index) => insert(parentBlocks, index, copiedBlock),\n );\n }\n\n set((state) => ({\n ...state,\n content: {...state.content, blocks: newBlocksConfig},\n selectedBlock: finalDestinationPath,\n }));\n },\n resetInitialize: () => {\n set((state) => ({\n ...state,\n initialized: false,\n }));\n },\n resetBlocks: () => {\n set((state) => ({\n ...state,\n content: {...state.content, blocks: []},\n }));\n },\n }),\n);\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
.g-root {
|
|
2
|
+
--g-color-base-brand: var(--g-color-private-black-550-solid);
|
|
3
|
+
--g-color-base-brand-hover: var(--g-color-private-black-600-solid);
|
|
4
|
+
--g-color-base-selection: var(--g-color-private-black-200);
|
|
5
|
+
--g-color-base-selection-hover: var(--g-color-private-black-300);
|
|
6
|
+
--g-color-base-brand: var(--g-color-text-primary);
|
|
7
|
+
--g-color-base-brand-hover: var(--g-color-text-complementary);
|
|
8
|
+
--g-color-text-brand-contrast: var(--g-color-text-light-primary);
|
|
9
|
+
--g-color-line-brand: var(--g-color-text-primary);
|
|
10
|
+
--g-color-text-brand: var(--g-color-private-brand-700-solid);
|
|
11
|
+
--g-color-text-brand-heavy: var(--g-color-private-black-700-solid);
|
|
12
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cn.js","sourceRoot":"../../../../src","sources":["editor-v2/utils/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAEhD,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAE5C,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC,EAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAC,CAAC,CAAC","sourcesContent":["import {withNaming} from '@bem-react/classname';\n\nexport const EDITOR_NAMESPACE = 'pceditor-';\n\nexport const editorCn = withNaming({n: EDITOR_NAMESPACE, e: '__', m: '_'});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.js","sourceRoot":"../../../../src","sources":["editor-v2/utils/code.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAI3B,MAAM,UAAU,SAAS,CAAC,IAAY;IAClC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAgB,CAAC;IAEnD,OAAO;QACH,GAAG,WAAW;QACd,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC;KAC9C,CAAC;AACN,CAAC","sourcesContent":["import yaml from 'js-yaml';\n\nimport {PageContent} from '../../models';\n\nexport function parseCode(code: string) {\n const pageContent = yaml.load(code) as PageContent;\n\n return {\n ...pageContent,\n blocks: pageContent.blocks?.filter(Boolean),\n };\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ConstructorBlock } from "../../models/index.js";
|
|
2
|
+
export declare function insert<T>(arr: Array<T>, index: number, newItem: T): T[];
|
|
3
|
+
export declare function removeFromArray<T>(array: Array<T>, index: number): T[];
|
|
4
|
+
export declare function swapArrayItems<T>(array: Array<T>, firstIndex: number, secondIndex: number): T[];
|
|
5
|
+
export declare function reorderArrayItems<T>(array: Array<T>, index: number, destination: number): T[];
|
|
6
|
+
export declare function duplicateArrayItem<T>(array: Array<T>, index: number): T[];
|
|
7
|
+
export declare function insertByPath<T extends object>(object: T, path: string, value: any): T;
|
|
8
|
+
export declare function splitPathAndIndex(path: string): {
|
|
9
|
+
path: string;
|
|
10
|
+
index: number;
|
|
11
|
+
} | undefined;
|
|
12
|
+
export declare function generateChildrenPathFromArray(indexes: number[]): string;
|
|
13
|
+
export declare function modifyObjectByPath(blocks: ConstructorBlock[], arrayPath: number[], modifyCallback: (parentBlocks: ConstructorBlock[], index: number) => ConstructorBlock[]): ConstructorBlock[];
|
|
14
|
+
export declare function isItemsNeighbours(arrayA: number[], arrayB: number[]): boolean;
|
|
15
|
+
export declare function getDestinationShiftBeforeReorder(arrayInit: number[], arrayDest: number[]): number[];
|
|
16
|
+
export declare function prepareShift(arrayInit: number[], arrayDest: number[]): number[];
|
|
17
|
+
export declare const getUrlOrigin: (url: string) => string | undefined;
|
|
18
|
+
export declare const getItemTitle: (item: object) => string | undefined;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
export function insert(arr, index, newItem) {
|
|
3
|
+
return [...arr.slice(0, index), newItem, ...arr.slice(index)];
|
|
4
|
+
}
|
|
5
|
+
export function removeFromArray(array, index) {
|
|
6
|
+
return [...array.slice(0, index), ...array.slice(index + 1)];
|
|
7
|
+
}
|
|
8
|
+
export function swapArrayItems(array, firstIndex, secondIndex) {
|
|
9
|
+
const results = array.slice();
|
|
10
|
+
const firstItem = array[firstIndex];
|
|
11
|
+
results[firstIndex] = array[secondIndex];
|
|
12
|
+
results[secondIndex] = firstItem;
|
|
13
|
+
return results;
|
|
14
|
+
}
|
|
15
|
+
export function reorderArrayItems(array, index, destination) {
|
|
16
|
+
const min = Math.min(index, destination);
|
|
17
|
+
const max = Math.max(index, destination);
|
|
18
|
+
const firstOperationRemove = index < destination;
|
|
19
|
+
const result = [];
|
|
20
|
+
result.push(...array.slice(0, min));
|
|
21
|
+
if (!firstOperationRemove) {
|
|
22
|
+
result.push(array[index]);
|
|
23
|
+
}
|
|
24
|
+
result.push(...array.slice(firstOperationRemove ? min + 1 : min, max));
|
|
25
|
+
if (firstOperationRemove) {
|
|
26
|
+
result.push(array[index]);
|
|
27
|
+
}
|
|
28
|
+
result.push(...array.slice(firstOperationRemove ? max : max + 1, array.length));
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
export function duplicateArrayItem(array, index) {
|
|
32
|
+
const duplicatedItem = _.cloneDeep(array[index]);
|
|
33
|
+
return [...array.slice(0, index), duplicatedItem, ...array.slice(index)];
|
|
34
|
+
}
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
export function insertByPath(object, path, value) {
|
|
37
|
+
if (!path) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
return _.setWith(_.clone(object), path, value, _.clone);
|
|
41
|
+
}
|
|
42
|
+
/*
|
|
43
|
+
* path: string;
|
|
44
|
+
* Example:
|
|
45
|
+
* 1. blocks[0] => {path: blocks, index: 0}
|
|
46
|
+
* 2. blocks[2].children[10] => {path: blocks[2].children, index: 10}
|
|
47
|
+
**/
|
|
48
|
+
export function splitPathAndIndex(path) {
|
|
49
|
+
// Match blocks[3], blocks[0].children[12], blocks[0], blocks[999999]
|
|
50
|
+
const bracketsRegExp = /(.*)\[(\d+)]$/g;
|
|
51
|
+
const regexpMatches = [...path.matchAll(bracketsRegExp)];
|
|
52
|
+
if (regexpMatches.length) {
|
|
53
|
+
return {
|
|
54
|
+
// blocks, blocks[0].children
|
|
55
|
+
path: regexpMatches[0][1],
|
|
56
|
+
// 3, 12, 0, 9999
|
|
57
|
+
index: Number(regexpMatches[0][2]),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line no-console
|
|
61
|
+
console.error('Non correct path for splitting');
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
/*
|
|
65
|
+
* [0, 4, 3] => [0].children[4].children[3]
|
|
66
|
+
* */
|
|
67
|
+
export function generateChildrenPathFromArray(indexes) {
|
|
68
|
+
if (!indexes.length) {
|
|
69
|
+
return '';
|
|
70
|
+
}
|
|
71
|
+
let resultPath = `[${indexes[0]}]`;
|
|
72
|
+
if (indexes.length > 1) {
|
|
73
|
+
for (let i = 1; i < indexes.length; i++) {
|
|
74
|
+
resultPath += `.children[${indexes[i]}]`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return resultPath;
|
|
78
|
+
}
|
|
79
|
+
export function modifyObjectByPath(blocks, arrayPath, modifyCallback) {
|
|
80
|
+
// [1]
|
|
81
|
+
// [4].children[3]
|
|
82
|
+
const insertPath = generateChildrenPathFromArray(arrayPath);
|
|
83
|
+
// path: '' index: 1
|
|
84
|
+
// path: '[4].children' index: 3
|
|
85
|
+
const splitPath = splitPathAndIndex(insertPath);
|
|
86
|
+
if (splitPath) {
|
|
87
|
+
const { path: parentPath, index } = splitPath;
|
|
88
|
+
// Get Array that lies on path
|
|
89
|
+
const parentArray = parentPath ? _.get(blocks, parentPath) : blocks;
|
|
90
|
+
const value = Array.isArray(parentArray) ? parentArray : [];
|
|
91
|
+
// Modify Array
|
|
92
|
+
const newModifiedArray = modifyCallback(value, index);
|
|
93
|
+
// Return it back
|
|
94
|
+
return insertByPath(blocks, parentPath, newModifiedArray);
|
|
95
|
+
}
|
|
96
|
+
return blocks;
|
|
97
|
+
}
|
|
98
|
+
export function isItemsNeighbours(arrayA, arrayB) {
|
|
99
|
+
if (arrayA.length !== arrayB.length) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
for (let i = 0; i < arrayA.length - 1; i++) {
|
|
103
|
+
if (arrayA[i] !== arrayB[i]) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
export function getDestinationShiftBeforeReorder(arrayInit, arrayDest) {
|
|
110
|
+
if (arrayInit.length === arrayDest.length || arrayInit.length > arrayDest.length) {
|
|
111
|
+
return arrayDest;
|
|
112
|
+
}
|
|
113
|
+
for (let i = 0; i < arrayInit.length; i++) {
|
|
114
|
+
if (arrayInit[i] < arrayDest[i]) {
|
|
115
|
+
return prepareShift(arrayInit, arrayDest);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return arrayDest;
|
|
119
|
+
}
|
|
120
|
+
export function prepareShift(arrayInit, arrayDest) {
|
|
121
|
+
if (arrayInit.length === arrayDest.length || arrayInit.length > arrayDest.length) {
|
|
122
|
+
return arrayDest;
|
|
123
|
+
}
|
|
124
|
+
return arrayDest.map((pathIndex, index) => index === arrayInit.length - 1 ? pathIndex - 1 : pathIndex);
|
|
125
|
+
}
|
|
126
|
+
export const getUrlOrigin = (url) => {
|
|
127
|
+
try {
|
|
128
|
+
const urlObject = new URL(url);
|
|
129
|
+
return urlObject.origin;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
export const getItemTitle = (item) => {
|
|
136
|
+
return (_.get(item, 'title.text') ||
|
|
137
|
+
_.get(item, 'title') ||
|
|
138
|
+
_.get(item, 'textContent.title') ||
|
|
139
|
+
_.get(item, 'content.title'));
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["editor-v2/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAIvB,MAAM,UAAU,MAAM,CAAI,GAAa,EAAE,KAAa,EAAE,OAAU;IAC9D,OAAO,CAAC,GAAG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C;QAC9C,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAmB,EAAE,SAAmB;IACjE,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QAC/E,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CACtC,KAAK,KAAK,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAC7D,CAAC;AACN,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE;IACxC,IAAI,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO,SAAS,CAAC,MAAM,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,SAAS,CAAC;IACrB,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAsB,EAAE;IAC7D,OAAO,CACH,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC;QACzB,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC;QACpB,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,mBAAmB,CAAC;QAChC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC,CAC/B,CAAC;AACN,CAAC,CAAC","sourcesContent":["import _ from 'lodash';\n\nimport {ConstructorBlock} from '../../models';\n\nexport function insert<T>(arr: Array<T>, index: number, newItem: T) {\n return [...arr.slice(0, index), newItem, ...arr.slice(index)];\n}\n\nexport function removeFromArray<T>(array: Array<T>, index: number) {\n return [...array.slice(0, index), ...array.slice(index + 1)];\n}\n\nexport function swapArrayItems<T>(array: Array<T>, firstIndex: number, secondIndex: number) {\n const results = array.slice();\n const firstItem = array[firstIndex];\n results[firstIndex] = array[secondIndex];\n results[secondIndex] = firstItem;\n return results;\n}\n\nexport function reorderArrayItems<T>(array: Array<T>, index: number, destination: number) {\n const min = Math.min(index, destination);\n const max = Math.max(index, destination);\n const firstOperationRemove = index < destination;\n const result = [];\n result.push(...array.slice(0, min));\n if (!firstOperationRemove) {\n result.push(array[index]);\n }\n result.push(...array.slice(firstOperationRemove ? min + 1 : min, max));\n if (firstOperationRemove) {\n result.push(array[index]);\n }\n result.push(...array.slice(firstOperationRemove ? max : max + 1, array.length));\n return result;\n}\n\nexport function duplicateArrayItem<T>(array: Array<T>, index: number) {\n const duplicatedItem = _.cloneDeep(array[index]);\n return [...array.slice(0, index), duplicatedItem, ...array.slice(index)];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function insertByPath<T extends object>(object: T, path: string, value: any) {\n if (!path) {\n return value as T;\n }\n\n return _.setWith(_.clone(object), path, value, _.clone);\n}\n\n/*\n * path: string;\n * Example:\n * 1. blocks[0] => {path: blocks, index: 0}\n * 2. blocks[2].children[10] => {path: blocks[2].children, index: 10}\n **/\nexport function splitPathAndIndex(path: string) {\n // Match blocks[3], blocks[0].children[12], blocks[0], blocks[999999]\n const bracketsRegExp = /(.*)\\[(\\d+)]$/g;\n const regexpMatches = [...path.matchAll(bracketsRegExp)];\n if (regexpMatches.length) {\n return {\n // blocks, blocks[0].children\n path: regexpMatches[0][1],\n // 3, 12, 0, 9999\n index: Number(regexpMatches[0][2]),\n };\n }\n\n // eslint-disable-next-line no-console\n console.error('Non correct path for splitting');\n return undefined;\n}\n\n/*\n * [0, 4, 3] => [0].children[4].children[3]\n * */\nexport function generateChildrenPathFromArray(indexes: number[]) {\n if (!indexes.length) {\n return '';\n }\n\n let resultPath = `[${indexes[0]}]`;\n\n if (indexes.length > 1) {\n for (let i = 1; i < indexes.length; i++) {\n resultPath += `.children[${indexes[i]}]`;\n }\n }\n\n return resultPath;\n}\n\nexport function modifyObjectByPath(\n blocks: ConstructorBlock[],\n arrayPath: number[],\n modifyCallback: (parentBlocks: ConstructorBlock[], index: number) => ConstructorBlock[],\n) {\n // [1]\n // [4].children[3]\n const insertPath = generateChildrenPathFromArray(arrayPath);\n // path: '' index: 1\n // path: '[4].children' index: 3\n const splitPath = splitPathAndIndex(insertPath);\n\n if (splitPath) {\n const {path: parentPath, index} = splitPath;\n // Get Array that lies on path\n const parentArray = parentPath ? _.get(blocks, parentPath) : blocks;\n\n const value = Array.isArray(parentArray) ? parentArray : [];\n // Modify Array\n const newModifiedArray = modifyCallback(value, index);\n\n // Return it back\n return insertByPath(blocks, parentPath, newModifiedArray);\n }\n\n return blocks;\n}\n\nexport function isItemsNeighbours(arrayA: number[], arrayB: number[]) {\n if (arrayA.length !== arrayB.length) {\n return false;\n }\n\n for (let i = 0; i < arrayA.length - 1; i++) {\n if (arrayA[i] !== arrayB[i]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function getDestinationShiftBeforeReorder(arrayInit: number[], arrayDest: number[]) {\n if (arrayInit.length === arrayDest.length || arrayInit.length > arrayDest.length) {\n return arrayDest;\n }\n\n for (let i = 0; i < arrayInit.length; i++) {\n if (arrayInit[i] < arrayDest[i]) {\n return prepareShift(arrayInit, arrayDest);\n }\n }\n\n return arrayDest;\n}\n\nexport function prepareShift(arrayInit: number[], arrayDest: number[]) {\n if (arrayInit.length === arrayDest.length || arrayInit.length > arrayDest.length) {\n return arrayDest;\n }\n\n return arrayDest.map((pathIndex, index) =>\n index === arrayInit.length - 1 ? pathIndex - 1 : pathIndex,\n );\n}\n\nexport const getUrlOrigin = (url: string) => {\n try {\n const urlObject = new URL(url);\n return urlObject.origin;\n } catch {\n return undefined;\n }\n};\n\nexport const getItemTitle = (item: object): string | undefined => {\n return (\n _.get(item, 'title.text') ||\n _.get(item, 'title') ||\n _.get(item, 'textContent.title') ||\n _.get(item, 'content.title')\n );\n};\n"]}
|