@gravity-ui/page-constructor 6.3.2-alpha.2 → 6.3.2-alpha.3
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/CardLayout/index.d.ts +1 -1
- package/build/cjs/blocks/CardLayout/index.js.map +1 -1
- package/build/cjs/blocks/Header/dynamic-form.d.ts +1 -1
- package/build/cjs/blocks/Header/dynamic-form.js.map +1 -1
- package/build/cjs/blocks/Slider/dynamic-form.d.ts +1 -1
- package/build/cjs/blocks/Slider/dynamic-form.js.map +1 -1
- package/build/cjs/blocks/TestEditorBlock/form.d.ts +1 -1
- package/build/cjs/blocks/TestEditorBlock/form.js.map +1 -1
- package/build/cjs/common/postMessage.d.ts +4 -0
- package/build/cjs/common/postMessage.js +31 -0
- package/build/cjs/common/postMessage.js.map +1 -0
- package/build/cjs/common/store.d.ts +40 -0
- package/build/cjs/common/store.js +20 -0
- package/build/cjs/common/store.js.map +1 -0
- package/build/cjs/common/types/actions.d.ts +36 -0
- package/build/cjs/common/types/actions.js +3 -0
- package/build/cjs/common/types/actions.js.map +1 -0
- package/build/cjs/common/types/common.d.ts +5 -0
- package/build/cjs/common/types/common.js +3 -0
- package/build/cjs/common/types/common.js.map +1 -0
- package/build/cjs/common/types/forms.d.ts +97 -0
- package/build/cjs/common/types/forms.js +3 -0
- package/build/cjs/common/types/forms.js.map +1 -0
- package/build/cjs/common/types/index.d.ts +4 -0
- package/build/cjs/common/types/index.js +8 -0
- package/build/cjs/common/types/index.js.map +1 -0
- package/build/cjs/common/types/messages.d.ts +9 -0
- package/build/cjs/common/types/messages.js +3 -0
- package/build/cjs/common/types/messages.js.map +1 -0
- package/build/cjs/common/utils.d.ts +25 -0
- package/build/cjs/common/utils.js +22 -0
- package/build/cjs/common/utils.js.map +1 -0
- package/build/cjs/components/Image/dynamic-form.d.ts +1 -1
- package/build/cjs/components/Image/dynamic-form.js.map +1 -1
- package/build/cjs/constructor-items.d.ts +1 -1
- package/build/cjs/constructor-items.js.map +1 -1
- package/build/cjs/context/editorStoreContext/PCEditorStoreContext.d.ts +1 -1
- package/build/cjs/context/editorStoreContext/PCEditorStoreContext.js +1 -1
- package/build/cjs/context/editorStoreContext/PCEditorStoreContext.js.map +1 -1
- package/build/cjs/context/editorStoreContext/PCEditorStoreProvider.js +1 -1
- package/build/cjs/context/editorStoreContext/PCEditorStoreProvider.js.map +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.d.ts +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.js.map +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.css +0 -13
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.d.ts +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.js.map +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.d.ts +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.js.map +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.d.ts +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js.map +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.d.ts +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.js.map +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/utils.d.ts +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/utils.js.map +1 -1
- package/build/cjs/editor-v2/components/Panels/Panels.css +0 -13
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.css +3 -13
- package/build/cjs/editor-v2/components/Tabs/Tabs.css +7 -2
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.css +0 -13
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.js +1 -1
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.js.map +1 -1
- package/build/cjs/editor-v2/containers/BlockConfigForm/BlockConfigForm.css +20 -0
- package/build/cjs/editor-v2/containers/BlockConfigForm/BlockConfigForm.d.ts +5 -0
- package/build/cjs/editor-v2/containers/{BlockConfig/BlockConfig.js → BlockConfigForm/BlockConfigForm.js} +4 -4
- package/build/cjs/editor-v2/containers/BlockConfigForm/BlockConfigForm.js.map +1 -0
- package/build/cjs/editor-v2/containers/BlocksList/BlocksList.css +3 -16
- package/build/cjs/editor-v2/containers/BlocksList/BlocksList.js.map +1 -1
- package/build/cjs/editor-v2/containers/Editor/Editor.css +0 -13
- package/build/cjs/editor-v2/containers/Editor/Editor.js +3 -2
- package/build/cjs/editor-v2/containers/Editor/Editor.js.map +1 -1
- package/build/cjs/editor-v2/containers/GlobalConfig/GlobalConfig.css +2 -17
- package/build/cjs/editor-v2/containers/GlobalConfig/GlobalConfig.js.map +1 -1
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.css +1 -14
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.js +1 -1
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.js.map +1 -1
- package/build/cjs/editor-v2/containers/Overlay/Overlay.css +21 -17
- package/build/cjs/editor-v2/containers/Overlay/Overlay.js +2 -2
- package/build/cjs/editor-v2/containers/Overlay/Overlay.js.map +1 -1
- package/build/cjs/editor-v2/containers/Source/Source.css +0 -13
- package/build/cjs/editor-v2/containers/SourceCode/SourceCode.css +1 -14
- package/build/cjs/editor-v2/containers/Tree/DragContext.css +2 -15
- package/build/cjs/editor-v2/containers/Tree/Tree.css +0 -13
- package/build/cjs/editor-v2/containers/Tree/TreeContent.css +0 -16
- package/build/cjs/editor-v2/containers/Tree/TreeItem.css +1 -17
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.css +3 -13
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.js +1 -1
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.js.map +1 -1
- package/build/cjs/editor-v2/containers/index.d.ts +7 -0
- package/build/cjs/editor-v2/containers/index.js +19 -0
- package/build/cjs/editor-v2/containers/index.js.map +1 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreProvider.js +1 -1
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreProvider.js.map +1 -1
- package/build/cjs/editor-v2/hooks/index.d.ts +2 -0
- package/build/cjs/editor-v2/hooks/index.js +8 -0
- package/build/cjs/editor-v2/hooks/index.js.map +1 -0
- package/build/cjs/editor-v2/hooks/useEditorTabs.js +2 -2
- package/build/cjs/editor-v2/hooks/useEditorTabs.js.map +1 -1
- package/build/cjs/editor-v2/hooks/useMainEditorInitialize.js +1 -1
- package/build/cjs/editor-v2/hooks/useMainEditorInitialize.js.map +1 -1
- package/build/cjs/editor-v2/hooks/usePostMessageEvents.d.ts +1 -1
- package/build/cjs/editor-v2/hooks/usePostMessageEvents.js +1 -1
- package/build/cjs/editor-v2/hooks/usePostMessageEvents.js.map +1 -1
- package/build/cjs/editor-v2/index.d.ts +5 -2
- package/build/cjs/editor-v2/index.js +5 -4
- package/build/cjs/editor-v2/index.js.map +1 -1
- package/build/cjs/editor-v2/store.d.ts +2 -2
- package/build/cjs/editor-v2/store.js +2 -2
- package/build/cjs/editor-v2/store.js.map +1 -1
- package/build/cjs/editor-v2/styles/root.css +3 -6
- package/build/cjs/editor-v2/utils/index.d.ts +2 -0
- package/build/cjs/editor-v2/utils/index.js +2 -0
- package/build/cjs/editor-v2/utils/index.js.map +1 -1
- package/build/cjs/hooks/usePCEditorInitializeEvents.js.map +1 -1
- package/build/cjs/hooks/usePCEditorStore.d.ts +1 -1
- package/build/cjs/hooks/usePostMessageAPI.d.ts +1 -1
- package/build/cjs/hooks/usePostMessageAPI.js.map +1 -1
- package/build/cjs/sub-blocks/BackgroundCard/dynamic-form.d.ts +1 -1
- package/build/cjs/sub-blocks/BackgroundCard/dynamic-form.js.map +1 -1
- package/build/cjs/utils/form-generator.d.ts +1 -1
- package/build/cjs/utils/form-generator.js.map +1 -1
- package/build/esm/blocks/CardLayout/index.d.ts +1 -1
- package/build/esm/blocks/CardLayout/index.js.map +1 -1
- package/build/esm/blocks/Header/dynamic-form.d.ts +1 -1
- package/build/esm/blocks/Header/dynamic-form.js.map +1 -1
- package/build/esm/blocks/Slider/dynamic-form.d.ts +1 -1
- package/build/esm/blocks/Slider/dynamic-form.js.map +1 -1
- package/build/esm/blocks/TestEditorBlock/form.d.ts +1 -1
- package/build/esm/blocks/TestEditorBlock/form.js.map +1 -1
- package/build/esm/common/postMessage.d.ts +4 -0
- package/build/esm/common/postMessage.js +25 -0
- package/build/esm/common/postMessage.js.map +1 -0
- package/build/esm/common/store.d.ts +40 -0
- package/build/esm/common/store.js +17 -0
- package/build/esm/common/store.js.map +1 -0
- package/build/esm/common/types/actions.d.ts +36 -0
- package/build/esm/common/types/actions.js +2 -0
- package/build/esm/common/types/actions.js.map +1 -0
- package/build/esm/common/types/common.d.ts +5 -0
- package/build/esm/common/types/common.js +2 -0
- package/build/esm/common/types/common.js.map +1 -0
- package/build/esm/common/types/forms.d.ts +97 -0
- package/build/esm/common/types/forms.js +2 -0
- package/build/esm/common/types/forms.js.map +1 -0
- package/build/esm/common/types/index.d.ts +4 -0
- package/build/esm/common/types/index.js +5 -0
- package/build/esm/common/types/index.js.map +1 -0
- package/build/esm/common/types/messages.d.ts +9 -0
- package/build/esm/common/types/messages.js +2 -0
- package/build/esm/common/types/messages.js.map +1 -0
- package/build/esm/common/utils.d.ts +25 -0
- package/build/esm/common/utils.js +17 -0
- package/build/esm/common/utils.js.map +1 -0
- package/build/esm/components/Image/dynamic-form.d.ts +1 -1
- package/build/esm/components/Image/dynamic-form.js.map +1 -1
- package/build/esm/constructor-items.d.ts +1 -1
- package/build/esm/constructor-items.js.map +1 -1
- package/build/esm/context/editorStoreContext/PCEditorStoreContext.d.ts +1 -1
- package/build/esm/context/editorStoreContext/PCEditorStoreContext.js +1 -1
- package/build/esm/context/editorStoreContext/PCEditorStoreContext.js.map +1 -1
- package/build/esm/context/editorStoreContext/PCEditorStoreProvider.js +1 -1
- package/build/esm/context/editorStoreContext/PCEditorStoreProvider.js.map +1 -1
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.d.ts +1 -1
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.js.map +1 -1
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.css +0 -13
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.d.ts +1 -1
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.js.map +1 -1
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.d.ts +1 -1
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.js.map +1 -1
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.d.ts +1 -1
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js.map +1 -1
- package/build/esm/editor-v2/components/DynamicForm/Fields/Select/Select.d.ts +1 -1
- package/build/esm/editor-v2/components/DynamicForm/Fields/Select/Select.js.map +1 -1
- package/build/esm/editor-v2/components/DynamicForm/utils.d.ts +1 -1
- package/build/esm/editor-v2/components/DynamicForm/utils.js.map +1 -1
- package/build/esm/editor-v2/components/Panels/Panels.css +0 -13
- package/build/esm/editor-v2/components/Sidebar/Sidebar.css +3 -13
- package/build/esm/editor-v2/components/Tabs/Tabs.css +7 -2
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.css +0 -13
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.js +1 -1
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.js.map +1 -1
- package/build/esm/editor-v2/containers/BlockConfigForm/BlockConfigForm.css +20 -0
- package/build/esm/editor-v2/containers/BlockConfigForm/BlockConfigForm.d.ts +6 -0
- package/build/esm/editor-v2/containers/{BlockConfig/BlockConfig.js → BlockConfigForm/BlockConfigForm.js} +5 -5
- package/build/esm/editor-v2/containers/BlockConfigForm/BlockConfigForm.js.map +1 -0
- package/build/esm/editor-v2/containers/BlocksList/BlocksList.css +3 -16
- package/build/esm/editor-v2/containers/BlocksList/BlocksList.js.map +1 -1
- package/build/esm/editor-v2/containers/Editor/Editor.css +0 -13
- package/build/esm/editor-v2/containers/Editor/Editor.js +3 -2
- package/build/esm/editor-v2/containers/Editor/Editor.js.map +1 -1
- package/build/esm/editor-v2/containers/GlobalConfig/GlobalConfig.css +2 -17
- package/build/esm/editor-v2/containers/GlobalConfig/GlobalConfig.js.map +1 -1
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.css +1 -14
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.js +1 -1
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.js.map +1 -1
- package/build/esm/editor-v2/containers/Overlay/Overlay.css +21 -17
- package/build/esm/editor-v2/containers/Overlay/Overlay.js +2 -2
- package/build/esm/editor-v2/containers/Overlay/Overlay.js.map +1 -1
- package/build/esm/editor-v2/containers/Source/Source.css +0 -13
- package/build/esm/editor-v2/containers/SourceCode/SourceCode.css +1 -14
- package/build/esm/editor-v2/containers/Tree/DragContext.css +2 -15
- package/build/esm/editor-v2/containers/Tree/Tree.css +0 -13
- package/build/esm/editor-v2/containers/Tree/TreeContent.css +0 -16
- package/build/esm/editor-v2/containers/Tree/TreeItem.css +1 -17
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.css +3 -13
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.js +1 -1
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.js.map +1 -1
- package/build/esm/editor-v2/containers/index.d.ts +7 -0
- package/build/esm/editor-v2/containers/index.js +8 -0
- package/build/esm/editor-v2/containers/index.js.map +1 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreProvider.js +1 -1
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreProvider.js.map +1 -1
- package/build/esm/editor-v2/hooks/index.d.ts +2 -0
- package/build/esm/editor-v2/hooks/index.js +3 -0
- package/build/esm/editor-v2/hooks/index.js.map +1 -0
- package/build/esm/editor-v2/hooks/useEditorTabs.js +2 -2
- package/build/esm/editor-v2/hooks/useEditorTabs.js.map +1 -1
- package/build/esm/editor-v2/hooks/useMainEditorInitialize.js +1 -1
- package/build/esm/editor-v2/hooks/useMainEditorInitialize.js.map +1 -1
- package/build/esm/editor-v2/hooks/usePostMessageEvents.d.ts +1 -1
- package/build/esm/editor-v2/hooks/usePostMessageEvents.js +1 -1
- package/build/esm/editor-v2/hooks/usePostMessageEvents.js.map +1 -1
- package/build/esm/editor-v2/index.d.ts +5 -2
- package/build/esm/editor-v2/index.js +5 -2
- package/build/esm/editor-v2/index.js.map +1 -1
- package/build/esm/editor-v2/store.d.ts +2 -2
- package/build/esm/editor-v2/store.js +2 -2
- package/build/esm/editor-v2/store.js.map +1 -1
- package/build/esm/editor-v2/styles/root.css +3 -6
- package/build/esm/editor-v2/utils/index.d.ts +2 -0
- package/build/esm/editor-v2/utils/index.js +2 -0
- package/build/esm/editor-v2/utils/index.js.map +1 -1
- package/build/esm/hooks/usePCEditorInitializeEvents.js.map +1 -1
- package/build/esm/hooks/usePCEditorStore.d.ts +1 -1
- package/build/esm/hooks/usePostMessageAPI.d.ts +1 -1
- package/build/esm/hooks/usePostMessageAPI.js.map +1 -1
- package/build/esm/sub-blocks/BackgroundCard/dynamic-form.d.ts +1 -1
- package/build/esm/sub-blocks/BackgroundCard/dynamic-form.js.map +1 -1
- package/build/esm/utils/form-generator.d.ts +1 -1
- package/build/esm/utils/form-generator.js.map +1 -1
- package/package.json +1 -2
- package/widget/index.js +1 -1
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.css +0 -29
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.d.ts +0 -6
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.js +0 -17
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.js.map +0 -1
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.css +0 -33
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.d.ts +0 -5
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.js.map +0 -1
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.css +0 -29
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.d.ts +0 -7
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.js +0 -15
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.js.map +0 -1
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.css +0 -33
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.d.ts +0 -6
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.js.map +0 -1
|
@@ -1,16 +1,3 @@
|
|
|
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
|
-
}
|
|
13
|
-
|
|
14
1
|
.pceditor-source-code {
|
|
15
2
|
height: 100%;
|
|
16
3
|
padding: 16px 12px;
|
|
@@ -23,7 +10,7 @@
|
|
|
23
10
|
font-weight: 500;
|
|
24
11
|
font-size: 13px;
|
|
25
12
|
line-height: 18px;
|
|
26
|
-
color: var(--g-color-
|
|
13
|
+
color: var(--g-color-text-secondary);
|
|
27
14
|
}
|
|
28
15
|
.pceditor-source-code__code {
|
|
29
16
|
white-space: pre;
|
|
@@ -1,21 +1,8 @@
|
|
|
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
|
-
}
|
|
13
|
-
|
|
14
1
|
.pceditor-preview {
|
|
15
2
|
position: absolute;
|
|
16
3
|
height: auto;
|
|
17
|
-
background-color: var(--g-color-
|
|
18
|
-
border: 1px dashed var(--g-color-
|
|
4
|
+
background-color: var(--g-color-text-hint);
|
|
5
|
+
border: 1px dashed var(--g-color-text-primary);
|
|
19
6
|
border-radius: 4px;
|
|
20
7
|
padding: 8px;
|
|
21
8
|
z-index: 1000;
|
|
@@ -1,16 +1,3 @@
|
|
|
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
|
-
}
|
|
13
|
-
|
|
14
1
|
.pceditor-tree {
|
|
15
2
|
padding: 12px;
|
|
16
3
|
position: relative;
|
|
@@ -1,16 +1,3 @@
|
|
|
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
|
-
}
|
|
13
|
-
|
|
14
1
|
.pceditor-tree-content {
|
|
15
2
|
position: relative;
|
|
16
3
|
}
|
|
@@ -20,9 +7,6 @@
|
|
|
20
7
|
border-radius: 4px;
|
|
21
8
|
transition: background-color 0.2s;
|
|
22
9
|
}
|
|
23
|
-
.pceditor-tree-content__drop-zone:hover {
|
|
24
|
-
background-color: var(--g-color-text-light-secondary);
|
|
25
|
-
}
|
|
26
10
|
.pceditor-tree-content__children {
|
|
27
11
|
margin-top: 8px;
|
|
28
12
|
}
|
|
@@ -1,16 +1,3 @@
|
|
|
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
|
-
}
|
|
13
|
-
|
|
14
1
|
.pceditor-tree-item {
|
|
15
2
|
padding: 8px;
|
|
16
3
|
margin-bottom: 8px;
|
|
@@ -47,7 +34,7 @@
|
|
|
47
34
|
display: none;
|
|
48
35
|
}
|
|
49
36
|
.pceditor-tree-item__type {
|
|
50
|
-
color: var(--g-color-text-
|
|
37
|
+
color: var(--g-color-text-secondary);
|
|
51
38
|
}
|
|
52
39
|
.pceditor-tree-item__title {
|
|
53
40
|
white-space: nowrap;
|
|
@@ -60,7 +47,4 @@
|
|
|
60
47
|
margin-bottom: 0;
|
|
61
48
|
border-radius: 4px;
|
|
62
49
|
transition: background-color 0.2s;
|
|
63
|
-
}
|
|
64
|
-
.pceditor-tree-item__children-drop-zone:hover {
|
|
65
|
-
background-color: var(--g-color-text-light-secondary);
|
|
66
50
|
}
|
|
@@ -1,16 +1,3 @@
|
|
|
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
|
-
}
|
|
13
|
-
|
|
14
1
|
.pceditor-view-switches {
|
|
15
2
|
padding: 12px;
|
|
16
3
|
display: inline-flex;
|
|
@@ -20,4 +7,7 @@
|
|
|
20
7
|
.pceditor-view-switches__zoom {
|
|
21
8
|
display: flex;
|
|
22
9
|
gap: 4px;
|
|
10
|
+
}
|
|
11
|
+
.pceditor-view-switches__zoom-select {
|
|
12
|
+
min-width: 80px;
|
|
23
13
|
}
|
|
@@ -46,7 +46,7 @@ const ViewSwitches = () => {
|
|
|
46
46
|
setZoom(newZoom);
|
|
47
47
|
}
|
|
48
48
|
}, [setZoom]);
|
|
49
|
-
return (_jsxs("div", { className: b(), role: "toolbar", "aria-label": "View controls", children: [_jsx(SegmentedRadioGroup, { value: deviceWidth, onUpdate: setDeviceWidth, "aria-label": "Device viewport selector", children: DEVICE_OPTIONS.map(({ value, label, ariaLabel }) => (_jsx(SegmentedRadioGroup.Option, { value: value, "aria-label": ariaLabel, children: label }, value))) }), _jsxs("div", { className: b('zoom'), role: "group", "aria-label": "Zoom controls", children: [_jsx(Button, { view: "flat", onClick: decreaseZoom, "aria-label": "Decrease zoom", disabled: zoom <= Math.min(...ZOOM_STEPS), children: _jsx(Icon, { data: Minus }) }), _jsx(Select, { multiple: false, value: currentZoomValue, options: zoomOptions, onUpdate: handleZoomUpdate, "aria-label": "Select zoom level", width: "max" }), _jsx(Button, { view: "flat", onClick: increaseZoom, "aria-label": "Increase zoom", disabled: zoom >= Math.max(...ZOOM_STEPS), children: _jsx(Icon, { data: Plus }) })] })] }));
|
|
49
|
+
return (_jsxs("div", { className: b(), role: "toolbar", "aria-label": "View controls", children: [_jsx(SegmentedRadioGroup, { value: deviceWidth, onUpdate: setDeviceWidth, "aria-label": "Device viewport selector", children: DEVICE_OPTIONS.map(({ value, label, ariaLabel }) => (_jsx(SegmentedRadioGroup.Option, { value: value, "aria-label": ariaLabel, children: label }, value))) }), _jsxs("div", { className: b('zoom'), role: "group", "aria-label": "Zoom controls", children: [_jsx(Button, { view: "flat", onClick: decreaseZoom, "aria-label": "Decrease zoom", disabled: zoom <= Math.min(...ZOOM_STEPS), children: _jsx(Icon, { data: Minus }) }), _jsx(Select, { className: b('zoom-select'), multiple: false, value: currentZoomValue, options: zoomOptions, onUpdate: handleZoomUpdate, "aria-label": "Select zoom level", width: "max" }), _jsx(Button, { view: "flat", onClick: increaseZoom, "aria-label": "Increase zoom", disabled: zoom >= Math.max(...ZOOM_STEPS), children: _jsx(Icon, { data: Plus }) })] })] }));
|
|
50
50
|
};
|
|
51
51
|
export default React.memo(ViewSwitches);
|
|
52
52
|
//# sourceMappingURL=ViewSwitches.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewSwitches.js","sourceRoot":"../../../../../src","sources":["editor-v2/containers/ViewSwitches/ViewSwitches.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAC,UAAU,EAAC,2BAAwB;AAC3C,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAClE,OAAO,EAAC,QAAQ,EAAC,0BAAuB;AAExC,OAAO,oBAAoB,CAAC;AAE5B,MAAM,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;AAcpC;;;;;GAKG;AACH,MAAM,cAAc,GAAmB;IACnC;QACI,KAAK,EAAE,KAAC,IAAI,IAAC,IAAI,EAAE,OAAO,GAAI;QAC9B,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,cAAc;KAC5B;IACD;QACI,KAAK,EAAE,KAAC,IAAI,IAAC,IAAI,EAAE,UAAU,GAAI;QACjC,KAAK,EAAE,OAAO;QACd,SAAS,EAAE,aAAa;KAC3B;IACD;QACI,KAAK,EAAE,KAAC,IAAI,IAAC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KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,cAAc,gBACb,0BAA0B,YAEpC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAC,EAAE,EAAE,CAAC,CAC/C,KAAC,mBAAmB,CAAC,MAAM,IAAa,KAAK,EAAE,KAAK,gBAAc,SAAS,YACtE,KAAK,IADuB,KAAK,CAET,CAChC,CAAC,GACgB,EAEtB,eAAK,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAC,OAAO,gBAAY,eAAe,aAC9D,KAAC,MAAM,IACH,IAAI,EAAC,MAAM,EACX,OAAO,EAAE,YAAY,gBACV,eAAe,EAC1B,QAAQ,EAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,YAEzC,KAAC,IAAI,IAAC,IAAI,EAAE,KAAK,GAAI,GAChB,EAET,KAAC,MAAM,IACH,QAAQ,EAAE,KAAK,EACf,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,gBAAgB,gBACf,mBAAmB,EAC9B,KAAK,EAAC,KAAK,GACb,EAEF,KAAC,MAAM,IACH,IAAI,EAAC,MAAM,EACX,OAAO,EAAE,YAAY,gBACV,eAAe,EAC1B,QAAQ,EAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,YAEzC,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,GAAI,GACf,IACP,IACJ,CACT,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport {Display, Minus, Plus, Smartphone} from '@gravity-ui/icons';\nimport {Button, Icon, SegmentedRadioGroup, Select} from '@gravity-ui/uikit';\n\nimport {ZOOM_STEPS} from '../../constants';\nimport {useMainEditorStore} from '../../hooks/useMainEditorStore';\nimport {editorCn} from '../../utils/cn';\n\nimport './ViewSwitches.scss';\n\nconst b = editorCn('view-switches');\n\n/**\n * Device option type definition\n */\ninterface DeviceOption {\n /** React node to display as the option label */\n label: React.ReactNode;\n /** Device width value (e.g., '100%', '768px') */\n value: string;\n /** Descriptive name for accessibility */\n ariaLabel: string;\n}\n\n/**\n * Available device viewport options\n * - Desktop: 100% width\n * - Tablet: 768px width\n * - Mobile: 576px width\n */\nconst DEVICE_OPTIONS: DeviceOption[] = [\n {\n label: <Icon data={Display} />,\n value: '100%',\n ariaLabel: 'Desktop view',\n },\n {\n label: <Icon data={Smartphone} />,\n value: '768px',\n ariaLabel: 'Tablet view',\n },\n {\n label: <Icon width={14} data={Smartphone} />,\n value: '576px',\n ariaLabel: 'Mobile view',\n },\n];\n\nconst ViewSwitches: React.FC = () => {\n const {zoom, setZoom, decreaseZoom, increaseZoom, deviceWidth, setDeviceWidth} =\n useMainEditorStore();\n\n // Memoize zoom options to prevent unnecessary recalculations\n const zoomOptions = React.useMemo(\n () =>\n ZOOM_STEPS.map((step) => ({\n value: String(step),\n content: `${step}%`,\n })),\n [],\n );\n\n // Memoize current zoom value for Select component\n const currentZoomValue = React.useMemo(() => [String(zoom)], [zoom]);\n\n // Create stable callback for zoom updates\n const handleZoomUpdate = React.useCallback(\n (value: string | string[]) => {\n const newZoom = Number(Array.isArray(value) ? value[0] : value);\n if (!isNaN(newZoom) && ZOOM_STEPS.includes(newZoom)) {\n setZoom(newZoom);\n }\n },\n [setZoom],\n );\n\n return (\n <div className={b()} role=\"toolbar\" aria-label=\"View controls\">\n <SegmentedRadioGroup\n value={deviceWidth}\n onUpdate={setDeviceWidth}\n aria-label=\"Device viewport selector\"\n >\n {DEVICE_OPTIONS.map(({value, label, ariaLabel}) => (\n <SegmentedRadioGroup.Option key={value} value={value} aria-label={ariaLabel}>\n {label}\n </SegmentedRadioGroup.Option>\n ))}\n </SegmentedRadioGroup>\n\n <div className={b('zoom')} role=\"group\" aria-label=\"Zoom controls\">\n <Button\n view=\"flat\"\n onClick={decreaseZoom}\n aria-label=\"Decrease zoom\"\n disabled={zoom <= Math.min(...ZOOM_STEPS)}\n >\n <Icon data={Minus} />\n </Button>\n\n <Select\n multiple={false}\n value={currentZoomValue}\n options={zoomOptions}\n onUpdate={handleZoomUpdate}\n aria-label=\"Select zoom level\"\n width=\"max\"\n />\n\n <Button\n view=\"flat\"\n onClick={increaseZoom}\n aria-label=\"Increase zoom\"\n disabled={zoom >= Math.max(...ZOOM_STEPS)}\n >\n <Icon data={Plus} />\n </Button>\n </div>\n </div>\n );\n};\n\nexport default React.memo(ViewSwitches);\n"]}
|
|
1
|
+
{"version":3,"file":"ViewSwitches.js","sourceRoot":"../../../../../src","sources":["editor-v2/containers/ViewSwitches/ViewSwitches.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAC,UAAU,EAAC,2BAAwB;AAC3C,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAClE,OAAO,EAAC,QAAQ,EAAC,0BAAuB;AAExC,OAAO,oBAAoB,CAAC;AAE5B,MAAM,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;AAcpC;;;;;GAKG;AACH,MAAM,cAAc,GAAmB;IACnC;QACI,KAAK,EAAE,KAAC,IAAI,IAAC,IAAI,EAAE,OAAO,GAAI;QAC9B,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,cAAc;KAC5B;IACD;QACI,KAAK,EAAE,KAAC,IAAI,IAAC,IAAI,EAAE,UAAU,GAAI;QACjC,KAAK,EAAE,OAAO;QACd,SAAS,EAAE,aAAa;KAC3B;IACD;QACI,KAAK,EAAE,KAAC,IAAI,IAAC,KAAK,EAAE,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AAW,EAClB,QAAQ,EAAE,cAAc,gBACb,0BAA0B,YAEpC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAC,EAAE,EAAE,CAAC,CAC/C,KAAC,mBAAmB,CAAC,MAAM,IAAa,KAAK,EAAE,KAAK,gBAAc,SAAS,YACtE,KAAK,IADuB,KAAK,CAET,CAChC,CAAC,GACgB,EAEtB,eAAK,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAC,OAAO,gBAAY,eAAe,aAC9D,KAAC,MAAM,IACH,IAAI,EAAC,MAAM,EACX,OAAO,EAAE,YAAY,gBACV,eAAe,EAC1B,QAAQ,EAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,YAEzC,KAAC,IAAI,IAAC,IAAI,EAAE,KAAK,GAAI,GAChB,EAET,KAAC,MAAM,IACH,SAAS,EAAE,CAAC,CAAC,aAAa,CAAC,EAC3B,QAAQ,EAAE,KAAK,EACf,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,gBAAgB,gBACf,mBAAmB,EAC9B,KAAK,EAAC,KAAK,GACb,EAEF,KAAC,MAAM,IACH,IAAI,EAAC,MAAM,EACX,OAAO,EAAE,YAAY,gBACV,eAAe,EAC1B,QAAQ,EAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,YAEzC,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,GAAI,GACf,IACP,IACJ,CACT,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport {Display, Minus, Plus, Smartphone} from '@gravity-ui/icons';\nimport {Button, Icon, SegmentedRadioGroup, Select} from '@gravity-ui/uikit';\n\nimport {ZOOM_STEPS} from '../../constants';\nimport {useMainEditorStore} from '../../hooks/useMainEditorStore';\nimport {editorCn} from '../../utils/cn';\n\nimport './ViewSwitches.scss';\n\nconst b = editorCn('view-switches');\n\n/**\n * Device option type definition\n */\ninterface DeviceOption {\n /** React node to display as the option label */\n label: React.ReactNode;\n /** Device width value (e.g., '100%', '768px') */\n value: string;\n /** Descriptive name for accessibility */\n ariaLabel: string;\n}\n\n/**\n * Available device viewport options\n * - Desktop: 100% width\n * - Tablet: 768px width\n * - Mobile: 576px width\n */\nconst DEVICE_OPTIONS: DeviceOption[] = [\n {\n label: <Icon data={Display} />,\n value: '100%',\n ariaLabel: 'Desktop view',\n },\n {\n label: <Icon data={Smartphone} />,\n value: '768px',\n ariaLabel: 'Tablet view',\n },\n {\n label: <Icon width={14} data={Smartphone} />,\n value: '576px',\n ariaLabel: 'Mobile view',\n },\n];\n\nconst ViewSwitches: React.FC = () => {\n const {zoom, setZoom, decreaseZoom, increaseZoom, deviceWidth, setDeviceWidth} =\n useMainEditorStore();\n\n // Memoize zoom options to prevent unnecessary recalculations\n const zoomOptions = React.useMemo(\n () =>\n ZOOM_STEPS.map((step) => ({\n value: String(step),\n content: `${step}%`,\n })),\n [],\n );\n\n // Memoize current zoom value for Select component\n const currentZoomValue = React.useMemo(() => [String(zoom)], [zoom]);\n\n // Create stable callback for zoom updates\n const handleZoomUpdate = React.useCallback(\n (value: string | string[]) => {\n const newZoom = Number(Array.isArray(value) ? value[0] : value);\n if (!isNaN(newZoom) && ZOOM_STEPS.includes(newZoom)) {\n setZoom(newZoom);\n }\n },\n [setZoom],\n );\n\n return (\n <div className={b()} role=\"toolbar\" aria-label=\"View controls\">\n <SegmentedRadioGroup\n value={deviceWidth}\n onUpdate={setDeviceWidth}\n aria-label=\"Device viewport selector\"\n >\n {DEVICE_OPTIONS.map(({value, label, ariaLabel}) => (\n <SegmentedRadioGroup.Option key={value} value={value} aria-label={ariaLabel}>\n {label}\n </SegmentedRadioGroup.Option>\n ))}\n </SegmentedRadioGroup>\n\n <div className={b('zoom')} role=\"group\" aria-label=\"Zoom controls\">\n <Button\n view=\"flat\"\n onClick={decreaseZoom}\n aria-label=\"Decrease zoom\"\n disabled={zoom <= Math.min(...ZOOM_STEPS)}\n >\n <Icon data={Minus} />\n </Button>\n\n <Select\n className={b('zoom-select')}\n multiple={false}\n value={currentZoomValue}\n options={zoomOptions}\n onUpdate={handleZoomUpdate}\n aria-label=\"Select zoom level\"\n width=\"max\"\n />\n\n <Button\n view=\"flat\"\n onClick={increaseZoom}\n aria-label=\"Increase zoom\"\n disabled={zoom >= Math.max(...ZOOM_STEPS)}\n >\n <Icon data={Plus} />\n </Button>\n </div>\n </div>\n );\n};\n\nexport default React.memo(ViewSwitches);\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Editor } from "./Editor/Editor.js";
|
|
2
|
+
export { default as BlockConfigForm } from "./BlockConfigForm/BlockConfigForm.js";
|
|
3
|
+
export { default as BlocksList } from "./BlocksList/BlocksList.js";
|
|
4
|
+
export { default as Source } from "./Source/Source.js";
|
|
5
|
+
export { default as SourceCode } from "./SourceCode/SourceCode.js";
|
|
6
|
+
export { default as Tree } from "./Tree/Tree.js";
|
|
7
|
+
export { default as ViewSwitches } from "./ViewSwitches/ViewSwitches.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Editor } from "./Editor/Editor.js";
|
|
2
|
+
export { default as BlockConfigForm } from "./BlockConfigForm/BlockConfigForm.js";
|
|
3
|
+
export { default as BlocksList } from "./BlocksList/BlocksList.js";
|
|
4
|
+
export { default as Source } from "./Source/Source.js";
|
|
5
|
+
export { default as SourceCode } from "./SourceCode/SourceCode.js";
|
|
6
|
+
export { default as Tree } from "./Tree/Tree.js";
|
|
7
|
+
export { default as ViewSwitches } from "./ViewSwitches/ViewSwitches.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["editor-v2/containers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,2BAAwB;AACvC,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,6CAA0C;AAC7E,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,mCAAgC;AAC9D,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,2BAAwB;AAClD,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,mCAAgC;AAC9D,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,uBAAoB;AAC5C,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,uCAAoC","sourcesContent":["export {Editor} from './Editor/Editor';\nexport {default as BlockConfigForm} from './BlockConfigForm/BlockConfigForm';\nexport {default as BlocksList} from './BlocksList/BlocksList';\nexport {default as Source} from './Source/Source';\nexport {default as SourceCode} from './SourceCode/SourceCode';\nexport {default as Tree} from './Tree/Tree';\nexport {default as ViewSwitches} from './ViewSwitches/ViewSwitches';\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { removeFn } from "
|
|
3
|
+
import { removeFn } from "../../../common/utils.js";
|
|
4
4
|
import { createEditorStore } from "../../store.js";
|
|
5
5
|
import { IframeContext } from "../iframeContext/index.js";
|
|
6
6
|
import { MainEditorStoreContext } from "./MainEditorStoreContext.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MainEditorStoreProvider.js","sourceRoot":"../../../../../src","sources":["editor-v2/context/editorStore/MainEditorStoreProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAC,QAAQ,EAAC,
|
|
1
|
+
{"version":3,"file":"MainEditorStoreProvider.js","sourceRoot":"../../../../../src","sources":["editor-v2/context/editorStore/MainEditorStoreProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAC,QAA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port {EditorState} from '../../../common/store';\nimport {StoreSyncMessage} from '../../../common/types';\nimport {removeFn} from '../../../common/utils';\nimport {EditorStore, createEditorStore} from '../../store';\nimport {IframeContext} from '../iframeContext';\n\nimport {MainEditorStoreContext} from './MainEditorStoreContext';\n\ninterface MainEditorProviderProps extends React.PropsWithChildren {}\n\nexport const MainEditorStoreProvider = ({children}: MainEditorProviderProps) => {\n const {iframeElement} = React.useContext(IframeContext);\n const storeRef = React.useRef<StoreApi<EditorStore>>();\n\n const sendPostMessage = React.useCallback(\n (data: EditorState) => {\n const message: StoreSyncMessage = {\n state: data,\n };\n\n if (iframeElement && iframeElement.contentWindow) {\n iframeElement.contentWindow.postMessage(message, '*');\n }\n },\n [iframeElement],\n );\n\n if (!storeRef.current) {\n storeRef.current = createEditorStore();\n }\n\n React.useEffect(() => {\n storeRef.current?.subscribe((state) => {\n sendPostMessage(removeFn(state));\n });\n }, [sendPostMessage]);\n\n return (\n <MainEditorStoreContext.Provider\n value={{\n state: storeRef.current,\n }}\n >\n {children}\n </MainEditorStoreContext.Provider>\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["editor-v2/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,kCAA+B;AAC5D,OAAO,EAAC,kBAAkB,EAAC,gCAA6B","sourcesContent":["export {usePostMessageEvents} from './usePostMessageEvents';\nexport {useMainEditorStore} from './useMainEditorStore';\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import Tabs from "../components/Tabs/Tabs.js";
|
|
4
|
-
import
|
|
4
|
+
import BlockConfigForm from "../containers/BlockConfigForm/BlockConfigForm.js";
|
|
5
5
|
import BlocksList from "../containers/BlocksList/BlocksList.js";
|
|
6
6
|
import GlobalConfig from "../containers/GlobalConfig/GlobalConfig.js";
|
|
7
7
|
import SourceCode from "../containers/SourceCode/SourceCode.js";
|
|
@@ -50,7 +50,7 @@ export const useEditorTabs = ({ leftTabs, rightTabs, }) => {
|
|
|
50
50
|
{
|
|
51
51
|
id: 'block-config',
|
|
52
52
|
title: 'INPUTS',
|
|
53
|
-
component:
|
|
53
|
+
component: BlockConfigForm,
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
id: 'source-code-yaml',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditorTabs.js","sourceRoot":"../../../../src","sources":["editor-v2/hooks/useEditorTabs.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,IAAqB,mCAAgC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"useEditorTabs.js","sourceRoot":"../../../../src","sources":["editor-v2/hooks/useEditorTabs.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,IAAqB,mCAAgC;AAC5D,OAAO,eAAe,yDAAsD;AAC5E,OAAO,UAAU,+CAA4C;AAC7D,OAAO,YAAY,mDAAgD;AACnE,OAAO,UAAU,+CAA4C;AAC7D,OAAO,IAAI,oCAA2B;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC1B,QAAQ,EACR,SAAS,GAIZ,EAAE,EAAE;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CACtB,GAAG,EAAE,CAAC,CAAC;QACH,IAAI,EAAE;YACF;gBACI,EAAE,EAAE,MAAM;gBACV,KAAK,EAAE,MAAM;gBACb,SAAS,EAAE,GAAG,EAAE,CAAC,CACb,KAAC,IAAI,IACD,KAAK,EAAE;wBACH;4BACI,EAAE,EAAE,aAAa;4BACjB,KAAK,EAAE,QAAQ;4BACf,SAAS,EAAE,UAAU;yBACxB;wBACD;4BACI,EAAE,EAAE,QAAQ;4BACZ,KAAK,EAAE,QAAQ;4BACf,SAAS,EAAE,IAAI;yBAClB;wBACD;4BACI,EAAE,EAAE,kBAAkB;4BACtB,KAAK,EAAE,MAAM;4BACb,SAAS,EAAE,GAAG,EAAE,CAAC,KAAC,UAAU,IAAC,MAAM,EAAC,MAAM,GAAG;yBAChD;wBACD;4BACI,EAAE,EAAE,kBAAkB;4BACtB,KAAK,EAAE,MAAM;4BACb,SAAS,EAAE,GAAG,EAAE,CAAC,KAAC,UAAU,IAAC,MAAM,EAAC,MAAM,GAAG;yBAChD;qBACJ,GACH,CACL;aACJ;YACD;gBACI,EAAE,EAAE,YAAY;gBAChB,KAAK,EAAE,YAAY;gBACnB,SAAS,EAAE,YAAY;aAC1B;YACD,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;SACtB;QACD,KAAK,EAAE;YACH;gBACI,EAAE,EAAE,MAAM;gBACV,KAAK,EAAE,MAAM;gBACb,SAAS,EAAE,GAAG,EAAE,CAAC,CACb,KAAC,IAAI,IACD,KAAK,EAAE;wBACH;4BACI,EAAE,EAAE,cAAc;4BAClB,KAAK,EAAE,QAAQ;4BACf,SAAS,EAAE,eAAe;yBAC7B;wBACD;4BACI,EAAE,EAAE,kBAAkB;4BACtB,KAAK,EAAE,MAAM;4BACb,SAAS,EAAE,GAAG,EAAE,CAAC,KAAC,UAAU,IAAC,MAAM,EAAC,MAAM,GAAG;yBAChD;wBACD;4BACI,EAAE,EAAE,kBAAkB;4BACtB,KAAK,EAAE,MAAM;4BACb,SAAS,EAAE,GAAG,EAAE,CAAC,KAAC,UAAU,IAAC,MAAM,EAAC,MAAM,GAAG;yBAChD;qBACJ,GACH,CACL;aACJ;YACD,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;SACvB;KACJ,CAAC,EACF,CAAC,QAAQ,EAAE,SAAS,CAAC,CACxB,CAAC;IAEF,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import * as React from 'react';\n\nimport Tabs, {TabsItemProps} from '../components/Tabs/Tabs';\nimport BlockConfigForm from '../containers/BlockConfigForm/BlockConfigForm';\nimport BlocksList from '../containers/BlocksList/BlocksList';\nimport GlobalConfig from '../containers/GlobalConfig/GlobalConfig';\nimport SourceCode from '../containers/SourceCode/SourceCode';\nimport Tree from '../containers/Tree';\n\nexport const useEditorTabs = ({\n leftTabs,\n rightTabs,\n}: {\n leftTabs?: TabsItemProps[];\n rightTabs?: TabsItemProps[];\n}) => {\n const tabs = React.useMemo(\n () => ({\n left: [\n {\n id: 'page',\n title: 'PAGE',\n component: () => (\n <Tabs\n items={[\n {\n id: 'blocks-list',\n title: 'BLOCKS',\n component: BlocksList,\n },\n {\n id: 'layers',\n title: 'LAYERS',\n component: Tree,\n },\n {\n id: 'source-code-yaml',\n title: 'YAML',\n component: () => <SourceCode format=\"yaml\" />,\n },\n {\n id: 'source-code-json',\n title: 'JSON',\n component: () => <SourceCode format=\"json\" />,\n },\n ]}\n />\n ),\n },\n {\n id: 'navigation',\n title: 'NAVIGATION',\n component: GlobalConfig,\n },\n ...(leftTabs || []),\n ],\n right: [\n {\n id: 'edit',\n title: 'EDIT',\n component: () => (\n <Tabs\n items={[\n {\n id: 'block-config',\n title: 'INPUTS',\n component: BlockConfigForm,\n },\n {\n id: 'source-code-yaml',\n title: 'YAML',\n component: () => <SourceCode format=\"yaml\" />,\n },\n {\n id: 'source-code-json',\n title: 'JSON',\n component: () => <SourceCode format=\"json\" />,\n },\n ]}\n />\n ),\n },\n ...(rightTabs || []),\n ],\n }),\n [leftTabs, rightTabs],\n );\n\n return tabs;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { usePostMessageAPIListener } from "
|
|
1
|
+
import { usePostMessageAPIListener } from "../../common/postMessage.js";
|
|
2
2
|
import { useMainEditorStore } from "./useMainEditorStore.js";
|
|
3
3
|
import { usePostMessageEvents } from "./usePostMessageEvents.js";
|
|
4
4
|
const useMainEditorInitialize = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMainEditorInitialize.js","sourceRoot":"../../../../src","sources":["editor-v2/hooks/useMainEditorInitialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAC,
|
|
1
|
+
{"version":3,"file":"useMainEditorInitialize.js","sourceRoot":"../../../../src","sources":["editor-v2/hooks/useMainEditorInitialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAC,oCAAiC;AAEnE,OAAO,EAAC,kBAAkB,EAAC,gCAA6B;AACxD,OAAO,EAAC,oBAAoB,EAAC,kCAA+B;AAE5D,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACjC,MAAM,EAAC,kBAAkB,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACpD,MAAM,EACF,UAAU,EACV,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,GACtB,GAAG,kBAAkB,EAAE,CAAC;IAEzB,yBAAyB,CACrB,SAAS,EACT,GAAG,EAAE;QACD,UAAU,EAAE,CAAC;QACb,kBAAkB,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;QAC/C,kBAAkB,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;IAClD,CAAC,EACD,CAAC,kBAAkB,CAAC,CACvB,CAAC;IAEF,yBAAyB,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE;QACrD,UAAU,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,yBAAyB,CAAC,qBAAqB,EAAE,CAAC,IAAI,EAAE,EAAE;QACtD,SAAS,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,yBAAyB,CACrB,aAAa,EACb,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE;QACjB,IAAI,qBAAqB,KAAK,QAAQ,IAAI,IAAI,IAAI,QAAQ,IAAI,kBAAkB,EAAE,CAAC;YAC/E,WAAW,CACP,IAAI,EACJ,kBAAkB,EAClB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAC5D,CAAC;QACN,CAAC;QACD,IAAI,qBAAqB,KAAK,SAAS,IAAI,IAAI,IAAI,QAAQ,IAAI,mBAAmB,EAAE,CAAC;YACjF,YAAY,CACR,mBAAmB,EACnB,IAAI,EACJ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAC5D,CAAC;QACN,CAAC;QACD,WAAW,EAAE,CAAC;IAClB,CAAC,EACD,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAC5C,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC","sourcesContent":["import {usePostMessageAPIListener} from '../../common/postMessage';\n\nimport {useMainEditorStore} from './useMainEditorStore';\nimport {usePostMessageEvents} from './usePostMessageEvents';\n\nconst useMainEditorInitialize = () => {\n const {requestPostMessage} = usePostMessageEvents();\n const {\n initialize,\n setConfig,\n setContent,\n manipulateOverlayMode,\n disableMode,\n insertBlock,\n reorderBlock,\n preInsertBlockType,\n preReorderBlockPath,\n } = useMainEditorStore();\n\n usePostMessageAPIListener(\n 'ON_INIT',\n () => {\n initialize();\n requestPostMessage('GET_SUPPORTED_BLOCKS', {});\n requestPostMessage('GET_INITIAL_CONTENT', {});\n },\n [requestPostMessage],\n );\n\n usePostMessageAPIListener('ON_INITIAL_CONTENT', (data) => {\n setContent(data);\n });\n\n usePostMessageAPIListener('ON_SUPPORTED_BLOCKS', (data) => {\n setConfig(data);\n });\n\n usePostMessageAPIListener(\n 'ON_MOUSE_UP',\n ({path, position}) => {\n if (manipulateOverlayMode === 'insert' && path && position && preInsertBlockType) {\n insertBlock(\n path,\n preInsertBlockType,\n ['left', 'top'].includes(position) ? 'prepend' : 'append',\n );\n }\n if (manipulateOverlayMode === 'reorder' && path && position && preReorderBlockPath) {\n reorderBlock(\n preReorderBlockPath,\n path,\n ['left', 'top'].includes(position) ? 'prepend' : 'append',\n );\n }\n disableMode();\n },\n [preInsertBlockType, preReorderBlockPath],\n );\n};\n\nexport default useMainEditorInitialize;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionMessageTypes } from "
|
|
1
|
+
import { ActionMessageTypes } from "../../common/types/index.js";
|
|
2
2
|
interface UsePostMessageRequestReturn {
|
|
3
3
|
requestPostMessage: <K extends keyof ActionMessageTypes>(action: K, data: ActionMessageTypes[K]) => void;
|
|
4
4
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { requestActionPostMessage } from "
|
|
2
|
+
import { requestActionPostMessage } from "../../common/postMessage.js";
|
|
3
3
|
import { IframeContext } from "../context/iframeContext/index.js";
|
|
4
4
|
export function usePostMessageEvents() {
|
|
5
5
|
const { iframeElement } = React.useContext(IframeContext);
|
|
@@ -1 +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,
|
|
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,oCAAiC;AAElE,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"]}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "
|
|
1
|
+
export * from "../common/types/index.js";
|
|
2
|
+
export * from "./containers/index.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export * from "./utils/index.js";
|
|
5
|
+
export * from "./constants.js";
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "
|
|
1
|
+
export * from "../common/types/index.js";
|
|
2
|
+
export * from "./containers/index.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export * from "./utils/index.js";
|
|
5
|
+
export * from "./constants.js";
|
|
3
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../src","sources":["editor-v2/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../src","sources":["editor-v2/index.ts"],"names":[],"mappings":"AAAA,yCAAgC;AAChC,sCAA6B;AAC7B,iCAAwB;AACxB,iCAAwB;AACxB,+BAA4B","sourcesContent":["export * from '../common/types';\nexport * from './containers';\nexport * from './hooks';\nexport * from './utils';\nexport * from './constants';\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EditorState } from "
|
|
2
|
-
import { DynamicFormValue } from "
|
|
1
|
+
import { EditorState } from "../common/store.js";
|
|
2
|
+
import { DynamicFormValue } from "../common/types/index.js";
|
|
3
3
|
import { PageContentWithNavigation } from "../models/index.js";
|
|
4
4
|
export interface EditorMethods {
|
|
5
5
|
initialize(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { initialStore } from "
|
|
3
|
-
import { initializeStore } from "
|
|
2
|
+
import { initialStore } from "../common/store.js";
|
|
3
|
+
import { initializeStore } from "../common/utils.js";
|
|
4
4
|
import { ZOOM_STEPS } from "./constants.js";
|
|
5
5
|
import { duplicateArrayItem, generateChildrenPathFromArray, getDestinationShiftBeforeReorder, insert, isItemsNeighbours, modifyObjectByPath, removeFromArray, reorderArrayItems, } from "./utils/index.js";
|
|
6
6
|
export const createEditorStore = initializeStore(initialStore, (set, get) => ({
|
|
@@ -1 +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,OAAO,EACH,kBAAkB,EAClB,6BAA6B,EAC7B,gCAAgC,EAChC,MAAM,EACN,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,GACpB,yBAAgB;AA0BjB,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAC5C,YAAY,EACZ,CAAC,GAAG,E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AC;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"]}
|
|
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,2BAAwB;AAE1D,OAAO,EAAC,eAAe,EAAC,2BAAwB;AAGhD,OAAO,EAAC,UAAU,EAAC,uBAAoB;AACvC,OAAO,EACH,kBAAkB,EAClB,6BAA6B,EAC7B,gCAAgC,EAChC,MAAM,EACN,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,GACpB,yBAAgB;AA0BjB,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAC5C,YAAY,EACZ,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACX,SAAS,CAAC,MAAc;QACpB,gFAAgF;QAChF,sDAAsD;QACtD,MAAM,SAAS,GAAG,MAAM,GAAG,GAAG,CAAC;QAC/B,GAAG,CAAC,CAAC,KAAK,EAAE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BAAoB;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"]}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
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
2
|
--g-color-base-selection: var(--g-color-private-black-200);
|
|
5
3
|
--g-color-base-selection-hover: var(--g-color-private-black-300);
|
|
6
|
-
--g-color-base-brand: var(--g-color-
|
|
7
|
-
--g-color-base-brand-hover: var(--g-color-
|
|
4
|
+
--g-color-base-brand: var(--g-color-private-black-850-solid);
|
|
5
|
+
--g-color-base-brand-hover: var(--g-color-private-black-700-solid);
|
|
8
6
|
--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
7
|
--g-color-text-brand-heavy: var(--g-color-private-black-700-solid);
|
|
8
|
+
--g-color-line-brand: var(--g-color-text-primary);
|
|
12
9
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ConstructorBlock } from "../../models/index.js";
|
|
2
|
+
export * from "./code.js";
|
|
3
|
+
export * from "./cn.js";
|
|
2
4
|
export declare function insert<T>(arr: Array<T>, index: number, newItem: T): T[];
|
|
3
5
|
export declare function removeFromArray<T>(array: Array<T>, index: number): T[];
|
|
4
6
|
export declare function swapArrayItems<T>(array: Array<T>, firstIndex: number, secondIndex: number): T[];
|
|
@@ -1 +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,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,eAAe,CAAI,KAAe,EAAE,KAAa;IAC7D,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,cAAc,CAAI,KAAe,EAAE,UAAkB,EAAE,WAAmB;IACtF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACpC,OAAO,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;IACzC,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;IACjC,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAI,KAAe,EAAE,KAAa,EAAE,WAAmB;IACpF,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACzC,MAAM,oBAAoB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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"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["editor-v2/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAGvB,0BAAuB;AACvB,wBAAqB;AAErB,MAAM,UAAU,MAAM,CAAI,GAAa,EAAE,KAAa,EAAE,OAAU;IAC9D,OAAO,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,eAAe,CAAI,KAAe,EAAE,KAAa;IAC7D,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,cAAc,CAAI,KAAe,EAAE,UAAkB,EAAE,WAAmB;IACtF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACpC,OAAO,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;IACzC,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;IACjC,OAAO,OA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;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';\nexport * from './code';\nexport * from './cn';\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"]}
|