@gravity-ui/page-constructor 4.15.0 → 4.15.1
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/HeaderSlider/schema.js +2 -2
- package/build/cjs/blocks/Info/schema.js +2 -2
- package/build/cjs/blocks/Media/schema.js +3 -2
- package/build/cjs/blocks/Questions/schema.js +2 -2
- package/build/cjs/blocks/Slider/Slider.js +6 -4
- package/build/cjs/blocks/Slider/utils.js +2 -2
- package/build/cjs/blocks/Tabs/schema.js +2 -2
- package/build/cjs/components/BalancedMasonry/BalancedMasonry.js +6 -4
- package/build/cjs/components/CardBase/CardBase.d.ts +1 -0
- package/build/cjs/components/CardBase/CardBase.js +7 -6
- package/build/cjs/components/FullWidthBackground/FullWidthBackground.js +2 -2
- package/build/cjs/components/Image/Image.d.ts +5 -0
- package/build/cjs/components/Image/Image.js +7 -8
- package/build/cjs/components/Map/GoogleMap.js +2 -2
- package/build/cjs/components/Map/YMap/YandexMap.js +2 -2
- package/build/cjs/components/Media/Image/Image.js +2 -2
- package/build/cjs/components/OverflowScroller/OverflowScroller.js +2 -2
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +2 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +2 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +2 -2
- package/build/cjs/editor/components/BlockForm/BlockForm.js +4 -3
- package/build/cjs/editor/components/PagePropsForm/PagePropsForm.js +2 -2
- package/build/cjs/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.js +2 -2
- package/build/cjs/editor/dynamic-forms-custom/config.js +2 -2
- package/build/cjs/editor/dynamic-forms-custom/hooks/useOneOf.js +5 -4
- package/build/cjs/editor/store/utils.js +2 -2
- package/build/cjs/editor/utils/index.js +2 -2
- package/build/cjs/hooks/useFocus.js +2 -2
- package/build/cjs/hooks/useHeightCalculator.js +2 -2
- package/build/cjs/hooks/useWindowBreakpoint.js +2 -2
- package/build/cjs/navigation/components/Navigation/Navigation.js +2 -2
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +2 -2
- package/build/cjs/navigation/schema.js +3 -2
- package/build/cjs/sub-blocks/BackgroundCard/schema.js +2 -2
- package/build/cjs/sub-blocks/BasicCard/schema.js +2 -2
- package/build/cjs/sub-blocks/LayoutItem/schema.js +2 -2
- package/build/cjs/sub-blocks/PriceDetailed/CombinedPriceDetailed/CombinedPriceDetailed.js +4 -4
- package/build/cjs/text-transform/config.js +2 -0
- package/build/cjs/text-transform/transformers.js +4 -3
- package/build/cjs/utils/blocks.js +5 -3
- package/build/esm/blocks/HeaderSlider/schema.js +2 -2
- package/build/esm/blocks/Info/schema.js +2 -2
- package/build/esm/blocks/Media/schema.js +1 -1
- package/build/esm/blocks/Questions/schema.js +2 -2
- package/build/esm/blocks/Slider/Slider.js +6 -4
- package/build/esm/blocks/Slider/utils.js +2 -2
- package/build/esm/blocks/Tabs/schema.js +2 -2
- package/build/esm/components/BalancedMasonry/BalancedMasonry.js +6 -4
- package/build/esm/components/CardBase/CardBase.d.ts +1 -0
- package/build/esm/components/CardBase/CardBase.js +8 -7
- package/build/esm/components/FullWidthBackground/FullWidthBackground.js +2 -2
- package/build/esm/components/Image/Image.d.ts +5 -0
- package/build/esm/components/Image/Image.js +7 -8
- package/build/esm/components/Map/GoogleMap.js +2 -2
- package/build/esm/components/Map/YMap/YandexMap.js +2 -2
- package/build/esm/components/Media/Image/Image.js +2 -2
- package/build/esm/components/OverflowScroller/OverflowScroller.js +2 -2
- package/build/esm/components/ReactPlayer/ReactPlayer.js +2 -2
- package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +2 -2
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +2 -2
- package/build/esm/editor/components/BlockForm/BlockForm.js +4 -3
- package/build/esm/editor/components/PagePropsForm/PagePropsForm.js +2 -2
- package/build/esm/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.js +2 -2
- package/build/esm/editor/dynamic-forms-custom/config.js +2 -2
- package/build/esm/editor/dynamic-forms-custom/hooks/useOneOf.js +5 -4
- package/build/esm/editor/store/utils.js +2 -2
- package/build/esm/editor/utils/index.js +2 -2
- package/build/esm/hooks/useFocus.js +2 -2
- package/build/esm/hooks/useHeightCalculator.js +2 -2
- package/build/esm/hooks/useWindowBreakpoint.js +2 -2
- package/build/esm/navigation/components/Navigation/Navigation.js +2 -2
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +1 -1
- package/build/esm/navigation/schema.js +1 -1
- package/build/esm/sub-blocks/BackgroundCard/schema.js +2 -2
- package/build/esm/sub-blocks/BasicCard/schema.js +2 -2
- package/build/esm/sub-blocks/LayoutItem/schema.js +1 -1
- package/build/esm/sub-blocks/PriceDetailed/CombinedPriceDetailed/CombinedPriceDetailed.js +4 -4
- package/build/esm/text-transform/config.js +2 -0
- package/build/esm/text-transform/transformers.js +4 -3
- package/build/esm/utils/blocks.js +2 -1
- package/package.json +1 -1
- package/server/text-transform/config.js +2 -0
- package/server/text-transform/transformers.js +4 -3
- package/server/utils/blocks.js +7 -3
- package/widget/index.js +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { memo, useMemo } from 'react';
|
|
2
2
|
import { DynamicField } from '@gravity-ui/dynamic-forms';
|
|
3
|
-
import
|
|
3
|
+
import noop from 'lodash/noop';
|
|
4
4
|
import { Form as FinalForm, FormSpy } from 'react-final-form';
|
|
5
5
|
import { dynamicConfig } from '../../dynamic-forms-custom/config';
|
|
6
6
|
export const PagePropsForm = memo(({ data: content, spec, onChange }) => {
|
|
7
7
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8
8
|
const initialValues = useMemo(() => ({ content }), []);
|
|
9
|
-
return (React.createElement(FinalForm, { initialValues: initialValues, onSubmit:
|
|
9
|
+
return (React.createElement(FinalForm, { initialValues: initialValues, onSubmit: noop }, () => (React.createElement("div", null,
|
|
10
10
|
React.createElement(FormSpy, { onChange: ({ values }) => onChange(Object.assign({}, values.content)), subscription: { values: true } }),
|
|
11
11
|
React.createElement(DynamicField, { name: "content", spec: spec, config: dynamicConfig })))));
|
|
12
12
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { Controller, GroupIndent, SpecTypes, transformArrOut, } from '@gravity-ui/dynamic-forms';
|
|
3
3
|
import Ajv from 'ajv';
|
|
4
|
-
import
|
|
4
|
+
import isEmpty from 'lodash/isEmpty';
|
|
5
5
|
import { block } from '../../../../utils';
|
|
6
6
|
import { getSpecTypeDefaultValue, useOneOf } from '../../hooks/useOneOf';
|
|
7
7
|
import './OneOfCustom.css';
|
|
@@ -17,7 +17,7 @@ const getOneOfCustomSpecDefaultType = (spec) => { var _a, _b; return ((_b = (_a
|
|
|
17
17
|
// dynamic-forms pass {} as default value for required properties of all types
|
|
18
18
|
// this function replaces {} with default value accordingly to selected OneOf option spec type
|
|
19
19
|
const getControllerDefautValue = (value, valueSpecType) => {
|
|
20
|
-
const isDefaultValue = typeof value === 'object' &&
|
|
20
|
+
const isDefaultValue = typeof value === 'object' && isEmpty(value);
|
|
21
21
|
const defaultValue = valueSpecType ? getSpecTypeDefaultValue(valueSpecType) : undefined;
|
|
22
22
|
return isDefaultValue ? defaultValue : value;
|
|
23
23
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { dynamicConfig as libConfig } from '@gravity-ui/dynamic-forms';
|
|
2
|
-
import
|
|
2
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
3
3
|
import { OneOfCustom } from './components/OneOfCustom/OneOfCustom';
|
|
4
4
|
const getDynamicConfig = () => {
|
|
5
|
-
const dynamicConfig =
|
|
5
|
+
const dynamicConfig = cloneDeep(libConfig);
|
|
6
6
|
dynamicConfig.object.inputs['oneof_custom'] = { Component: OneOfCustom, independent: true };
|
|
7
7
|
return dynamicConfig;
|
|
8
8
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SpecTypes, } from '@gravity-ui/dynamic-forms';
|
|
3
3
|
import { RadioButton, Select } from '@gravity-ui/uikit';
|
|
4
|
-
import
|
|
4
|
+
import isObjectLike from 'lodash/isObjectLike';
|
|
5
|
+
import some from 'lodash/some';
|
|
5
6
|
const MAX_TAB_TITLE_LENGTH = 20;
|
|
6
7
|
export const getSpecTypeDefaultValue = (type) => {
|
|
7
8
|
switch (type) {
|
|
@@ -18,10 +19,10 @@ export const getSpecTypeDefaultValue = (type) => {
|
|
|
18
19
|
export const useOneOf = ({ props, onTogglerChange }) => {
|
|
19
20
|
const { name, input, spec, Layout } = props;
|
|
20
21
|
const { order, disabled, oneOfParams } = spec.viewSpec;
|
|
21
|
-
const specProperties = React.useMemo(() => (
|
|
22
|
+
const specProperties = React.useMemo(() => (isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
|
|
22
23
|
const [oneOfValue, setOneOfValue] = React.useState(() => {
|
|
23
24
|
let valueKeys;
|
|
24
|
-
if (
|
|
25
|
+
if (isObjectLike(input.value)) {
|
|
25
26
|
const keys = Object.keys(input.value);
|
|
26
27
|
if (keys.length) {
|
|
27
28
|
valueKeys = keys;
|
|
@@ -54,7 +55,7 @@ export const useOneOf = ({ props, onTogglerChange }) => {
|
|
|
54
55
|
if ((oneOfParams === null || oneOfParams === void 0 ? void 0 : oneOfParams.toggler) !== 'radio' &&
|
|
55
56
|
((oneOfParams === null || oneOfParams === void 0 ? void 0 : oneOfParams.toggler) === 'select' ||
|
|
56
57
|
options.length > 3 ||
|
|
57
|
-
|
|
58
|
+
some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH))) {
|
|
58
59
|
return (React.createElement(Select, { width: "max", value: [oneOfValue], onUpdate: onOneOfChange, options: options, disabled: disabled, filterable: options.length > 7, qa: name }));
|
|
59
60
|
}
|
|
60
61
|
return (React.createElement(RadioButton, { value: oneOfValue, onChange: (event) => onOneOfChange([event.target.value]), disabled: disabled, qa: name }, options.map(({ value, title }) => (React.createElement(RadioButton.Option, { key: value, value: value }, title)))));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
2
2
|
export const changeBlocksOrder = (array, oldIndex, newIndex) => {
|
|
3
3
|
const result = [...array];
|
|
4
4
|
const element = result.splice(oldIndex, 1)[0];
|
|
@@ -7,7 +7,7 @@ export const changeBlocksOrder = (array, oldIndex, newIndex) => {
|
|
|
7
7
|
};
|
|
8
8
|
export const duplicateBlock = (array, index) => {
|
|
9
9
|
const result = [...array];
|
|
10
|
-
result.splice(index + 1, 0,
|
|
10
|
+
result.splice(index + 1, 0, cloneDeep(result[index]));
|
|
11
11
|
return result;
|
|
12
12
|
};
|
|
13
13
|
export const getNewBlockIndex = (id, orderedBlocksCount) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import capitalize from 'lodash/capitalize';
|
|
2
2
|
import { ViewModeItem } from '../types';
|
|
3
|
-
export const formatBlockName = (name) =>
|
|
3
|
+
export const formatBlockName = (name) => capitalize(name).replace(/(block|-)/g, ' ');
|
|
4
4
|
export const addCustomDecorator = (decorators, custom = {}) => {
|
|
5
5
|
const customDecorators = custom.decorators || {};
|
|
6
6
|
return Object.assign(Object.assign({}, custom), { decorators: Object.assign(Object.assign({}, customDecorators), { block: [...(customDecorators.block || []), ...decorators] }) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useContext, useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import noop from 'lodash/noop';
|
|
3
3
|
import { MobileContext } from '../context/mobileContext';
|
|
4
4
|
export default function useFocus(element) {
|
|
5
5
|
const isMobile = useContext(MobileContext);
|
|
@@ -25,7 +25,7 @@ export default function useFocus(element) {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
return
|
|
28
|
+
return noop;
|
|
29
29
|
}, [element, isMobile, setFocus, unsetFocus]);
|
|
30
30
|
return {
|
|
31
31
|
hasFocus,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import debounce from 'lodash/debounce';
|
|
3
3
|
const DEFAULT_RECALCULATE_ON_RESIZE_DELAY = 1000;
|
|
4
4
|
const DEFAULT_OPTIONS = {
|
|
5
5
|
recalculateOnResizeDelay: DEFAULT_RECALCULATE_ON_RESIZE_DELAY,
|
|
@@ -12,7 +12,7 @@ const useHeightCalculator = (containerRef, options = DEFAULT_OPTIONS) => {
|
|
|
12
12
|
setContainerHeight(containerRef.current.offsetHeight);
|
|
13
13
|
}, [containerRef, containerHeight, setContainerHeight]);
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
const handleResize =
|
|
15
|
+
const handleResize = debounce(calculateContainerHeight, recalculateOnResizeDelay);
|
|
16
16
|
handleResize();
|
|
17
17
|
window.addEventListener('resize', handleResize, { passive: true });
|
|
18
18
|
return () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import debounce from 'lodash/debounce';
|
|
3
3
|
import { BREAKPOINTS } from '../constants';
|
|
4
4
|
function calculate(windowWidth) {
|
|
5
5
|
const breakpointsSorted = Object.values(BREAKPOINTS).sort((b1, b2) => b1 - b2);
|
|
@@ -18,7 +18,7 @@ export default function useWindowBreakpoint() {
|
|
|
18
18
|
const [breakpoint, setBreakpoint] = useState(BREAKPOINTS.sm);
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
setBreakpoint(calculate(window.innerWidth));
|
|
21
|
-
const detect =
|
|
21
|
+
const detect = debounce(() => {
|
|
22
22
|
setBreakpoint(calculate(window.innerWidth));
|
|
23
23
|
}, 100);
|
|
24
24
|
detect();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import debounce from 'lodash/debounce';
|
|
3
3
|
import OutsideClick from '../../../components/OutsideClick/OutsideClick';
|
|
4
4
|
import { Col, Grid, Row } from '../../../grid';
|
|
5
5
|
import { block } from '../../../utils';
|
|
@@ -26,7 +26,7 @@ export const Navigation = ({ data, logo }) => {
|
|
|
26
26
|
setShowBorder(window.scrollY > 0);
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
const scrollHandler =
|
|
29
|
+
const scrollHandler = debounce(showBorderOnScroll, 20);
|
|
30
30
|
window.addEventListener('scroll', scrollHandler, { passive: true });
|
|
31
31
|
return () => window.removeEventListener('scroll', scrollHandler);
|
|
32
32
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useContext, useMemo } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import omit from 'lodash/omit';
|
|
4
4
|
import { BlockIdContext } from '../../../context/blockIdContext';
|
|
5
5
|
import { InnerContext } from '../../../context/innerContext';
|
|
6
6
|
import { NavigationItemType } from '../../../models';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import omit from 'lodash/omit';
|
|
2
2
|
import { ImageObjectProps } from '../../components/Image/schema';
|
|
3
3
|
import { BaseProps, CardBase, withTheme } from '../../schema/validators/common';
|
|
4
4
|
import { AnalyticsEventSchema } from '../../schema/validators/event';
|
|
5
5
|
import { ContentBase } from '../Content/schema';
|
|
6
|
-
const BackgroundCardContentProps =
|
|
6
|
+
const BackgroundCardContentProps = omit(ContentBase, ['size']);
|
|
7
7
|
export const BackgroundCard = {
|
|
8
8
|
'background-card': {
|
|
9
9
|
additionalProperties: false,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import omit from 'lodash/omit';
|
|
2
2
|
import { ImageProps } from '../../components/Image/schema';
|
|
3
3
|
import { BaseProps, CardBase } from '../../schema/validators/common';
|
|
4
4
|
import { ContentBase } from '../Content/schema';
|
|
5
|
-
const BasicCardContentProps =
|
|
5
|
+
const BasicCardContentProps = omit(ContentBase, ['size', 'theme']);
|
|
6
6
|
export const BasicCard = {
|
|
7
7
|
'basic-card': {
|
|
8
8
|
additionalProperties: false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { Fragment, useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import chunk from 'lodash/chunk';
|
|
3
3
|
import { CardBase } from '../../../components';
|
|
4
4
|
import { BREAKPOINTS } from '../../../constants';
|
|
5
5
|
import { Col, Grid, GridColumnSize, Row } from '../../../grid';
|
|
@@ -48,11 +48,11 @@ const CombinedPriceDetailed = (props) => {
|
|
|
48
48
|
React.createElement("div", null, descriptionComponents),
|
|
49
49
|
React.createElement("div", { className: b('description', { delimiter: useMixedView }) }, detailsComponents)));
|
|
50
50
|
};
|
|
51
|
-
const chunkedItems =
|
|
51
|
+
const chunkedItems = chunk(items, groupItemsSize);
|
|
52
52
|
return (React.createElement(CardBase, { className: b(), border: border, analyticsEvents: analyticsEvents },
|
|
53
53
|
React.createElement(CardBase.Content, null,
|
|
54
|
-
React.createElement(Grid, null, chunkedItems.map((
|
|
55
|
-
return (React.createElement(Row, { key: id, className: b('row') }, getPrice(
|
|
54
|
+
React.createElement(Grid, null, chunkedItems.map((item, id) => {
|
|
55
|
+
return (React.createElement(Row, { key: id, className: b('row') }, getPrice(item)));
|
|
56
56
|
})))));
|
|
57
57
|
};
|
|
58
58
|
export default CombinedPriceDetailed;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
1
3
|
import { __rest } from "tslib";
|
|
2
4
|
import { BlockType, SubBlockType, } from '../models';
|
|
3
5
|
import { createItemsParser, typografTransformer, yfmTransformer, } from './common';
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
2
|
+
import shuffle from 'lodash/shuffle';
|
|
2
3
|
import { config } from './config';
|
|
3
4
|
import { filterContent } from './filter';
|
|
4
5
|
function transformBlocks(blocks, lang, customConfig = {}, options = {}) {
|
|
5
6
|
const fullConfig = Object.assign(Object.assign({}, config), customConfig);
|
|
6
7
|
const { plugins = [] } = options;
|
|
7
|
-
const clonedBlocks =
|
|
8
|
+
const clonedBlocks = cloneDeep(blocks);
|
|
8
9
|
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block, plugins));
|
|
9
10
|
}
|
|
10
11
|
function transformBlock(lang, blocksConfig, block, plugins) {
|
|
11
12
|
const blockConfig = blocksConfig[block.type];
|
|
12
13
|
if (block) {
|
|
13
14
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
14
|
-
block.children =
|
|
15
|
+
block.children = shuffle(block.children);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
if (blockConfig) {
|
package/package.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable no-param-reassign */
|
|
3
|
+
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
2
4
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
5
|
var t = {};
|
|
4
6
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -4,20 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.contentTransformer = void 0;
|
|
7
|
-
const
|
|
7
|
+
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
8
|
+
const shuffle_1 = __importDefault(require("lodash/shuffle"));
|
|
8
9
|
const config_1 = require("./config");
|
|
9
10
|
const filter_1 = require("./filter");
|
|
10
11
|
function transformBlocks(blocks, lang, customConfig = {}, options = {}) {
|
|
11
12
|
const fullConfig = Object.assign(Object.assign({}, config_1.config), customConfig);
|
|
12
13
|
const { plugins = [] } = options;
|
|
13
|
-
const clonedBlocks =
|
|
14
|
+
const clonedBlocks = (0, cloneDeep_1.default)(blocks);
|
|
14
15
|
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block, plugins));
|
|
15
16
|
}
|
|
16
17
|
function transformBlock(lang, blocksConfig, block, plugins) {
|
|
17
18
|
const blockConfig = blocksConfig[block.type];
|
|
18
19
|
if (block) {
|
|
19
20
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
20
|
-
block.children =
|
|
21
|
+
block.children = (0, shuffle_1.default)(block.children);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
if (blockConfig) {
|
package/server/utils/blocks.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getQaAttrubutes = exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomTypes = exports.getCustomItems = exports.getBlockKey = exports.hasBlockTag = exports.getHeaderTag = void 0;
|
|
4
|
-
const
|
|
7
|
+
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
8
|
+
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
5
9
|
const models_1 = require("../models");
|
|
6
10
|
const BLOCK_ELEMENTS = [
|
|
7
11
|
'div',
|
|
@@ -125,9 +129,9 @@ exports.getShareLink = getShareLink;
|
|
|
125
129
|
const getQaAttrubutes = (qa, ...customKeys) => {
|
|
126
130
|
const attributes = {};
|
|
127
131
|
if (qa) {
|
|
128
|
-
const keys = QA_ATTRIBUTES_KEYS.concat((0,
|
|
132
|
+
const keys = QA_ATTRIBUTES_KEYS.concat((0, flatten_1.default)(customKeys));
|
|
129
133
|
keys.forEach((key) => {
|
|
130
|
-
attributes[(0,
|
|
134
|
+
attributes[(0, camelCase_1.default)(key)] = `${qa}-${key}`;
|
|
131
135
|
});
|
|
132
136
|
attributes.default = qa;
|
|
133
137
|
}
|