@gravity-ui/page-constructor 3.8.0 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/build/cjs/blocks/ContentLayout/schema.d.ts +2 -6
- package/build/cjs/blocks/Header/Header.css +4 -0
- package/build/cjs/blocks/Header/Header.js +2 -2
- package/build/cjs/blocks/Slider/Arrow/Arrow.js +1 -1
- package/build/cjs/blocks/Slider/Slider.css +2 -2
- package/build/cjs/blocks/Slider/Slider.js +2 -2
- package/build/cjs/blocks/Slider/utils.d.ts +2 -2
- package/build/cjs/blocks/Slider/utils.js +3 -1
- package/build/cjs/components/Image/schema.d.ts +1 -1
- package/build/cjs/components/Image/schema.js +7 -7
- package/build/cjs/components/Media/Image/Image.js +1 -1
- package/build/cjs/components/MetaInfo/MetaInfo.js +1 -1
- package/build/cjs/components/YFMWrapper/YFMWrapper.js +2 -1
- package/build/cjs/editor/containers/Form/Form.js +2 -2
- package/build/cjs/editor/dynamic-forms-custom/parser/index.js +2 -3
- package/build/cjs/editor/dynamic-forms-custom/parser/types.d.ts +1 -2
- package/build/cjs/editor/store/utils.js +3 -1
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +2 -3
- package/build/cjs/navigation/schema.js +1 -1
- package/build/cjs/schema/constants.d.ts +0 -1
- package/build/cjs/schema/validators/common.js +1 -1
- package/build/cjs/sub-blocks/Quote/schema.d.ts +0 -1
- package/build/cjs/sub-blocks/Quote/schema.js +1 -2
- package/build/cjs/utils/blocks.d.ts +1 -0
- package/build/cjs/utils/blocks.js +43 -1
- package/build/esm/blocks/ContentLayout/schema.d.ts +2 -6
- package/build/esm/blocks/Header/Header.css +4 -0
- package/build/esm/blocks/Header/Header.js +2 -2
- package/build/esm/blocks/Slider/Arrow/Arrow.js +1 -1
- package/build/esm/blocks/Slider/Slider.css +2 -2
- package/build/esm/blocks/Slider/Slider.js +2 -2
- package/build/esm/blocks/Slider/utils.d.ts +2 -2
- package/build/esm/blocks/Slider/utils.js +2 -1
- package/build/esm/components/Image/schema.d.ts +1 -1
- package/build/esm/components/Image/schema.js +6 -6
- package/build/esm/components/Media/Image/Image.js +1 -1
- package/build/esm/components/MetaInfo/MetaInfo.js +1 -1
- package/build/esm/components/YFMWrapper/YFMWrapper.js +2 -1
- package/build/esm/editor/containers/Form/Form.js +2 -2
- package/build/esm/editor/dynamic-forms-custom/parser/index.js +2 -3
- package/build/esm/editor/dynamic-forms-custom/parser/types.d.ts +1 -2
- package/build/esm/editor/store/utils.js +2 -1
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +2 -4
- package/build/esm/navigation/schema.js +2 -2
- package/build/esm/schema/constants.d.ts +0 -1
- package/build/esm/schema/validators/common.js +2 -2
- package/build/esm/sub-blocks/Quote/schema.d.ts +0 -1
- package/build/esm/sub-blocks/Quote/schema.js +2 -3
- package/build/esm/utils/blocks.d.ts +1 -0
- package/build/esm/utils/blocks.js +41 -0
- package/package.json +1 -1
- package/server/utils/blocks.d.ts +1 -0
- package/server/utils/blocks.js +43 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.8.2](https://github.com/gravity-ui/page-constructor/compare/v3.8.1...v3.8.2) (2023-06-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* quote validation ([#402](https://github.com/gravity-ui/page-constructor/issues/402)) ([3920561](https://github.com/gravity-ui/page-constructor/commit/3920561ebe0bac727826caf690d06d74d7affaef))
|
|
9
|
+
|
|
10
|
+
## [3.8.1](https://github.com/gravity-ui/page-constructor/compare/v3.8.0...v3.8.1) (2023-06-22)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* semantic markup ([#416](https://github.com/gravity-ui/page-constructor/issues/416)) ([1fd532c](https://github.com/gravity-ui/page-constructor/commit/1fd532ca0bcc2e6cd1f030b17be743c27fb2cf73))
|
|
16
|
+
|
|
3
17
|
## [3.8.0](https://github.com/gravity-ui/page-constructor/compare/v3.7.0...v3.8.0) (2023-06-22)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -12,9 +12,7 @@ export declare const ContentLayoutBlock: {
|
|
|
12
12
|
required: string[];
|
|
13
13
|
properties: {
|
|
14
14
|
src: {
|
|
15
|
-
type: string;
|
|
16
|
-
* @deprecated Use params on top level instead
|
|
17
|
-
*/
|
|
15
|
+
type: string;
|
|
18
16
|
pattern: string;
|
|
19
17
|
};
|
|
20
18
|
alt: {
|
|
@@ -143,9 +141,7 @@ export declare const ContentLayoutBlock: {
|
|
|
143
141
|
required: string[];
|
|
144
142
|
properties: {
|
|
145
143
|
src: {
|
|
146
|
-
type: string;
|
|
147
|
-
* @deprecated Use params on top level instead
|
|
148
|
-
*/
|
|
144
|
+
type: string;
|
|
149
145
|
pattern: string;
|
|
150
146
|
};
|
|
151
147
|
alt: {
|
|
@@ -76,6 +76,9 @@ unpredictable css rules order in build */
|
|
|
76
76
|
.pc-header-block__description {
|
|
77
77
|
margin-top: 16px;
|
|
78
78
|
font-weight: normal;
|
|
79
|
+
font-size: var(--yc-text-caption-2-font-size);
|
|
80
|
+
line-height: var(--yc-text-caption-2-line-height);
|
|
81
|
+
margin-block-end: var(--yc-text-body-1-line-height);
|
|
79
82
|
}
|
|
80
83
|
.pc-header-block__description .yfm,
|
|
81
84
|
.pc-header-block__description .yfm * {
|
|
@@ -167,6 +170,7 @@ unpredictable css rules order in build */
|
|
|
167
170
|
.pc-header-block__overtitle {
|
|
168
171
|
font-size: var(--yc-text-body-3-font-size);
|
|
169
172
|
line-height: var(--yc-text-body-3-line-height);
|
|
173
|
+
margin-block-start: var(--yc-text-body-3-line-height);
|
|
170
174
|
margin-bottom: 8px;
|
|
171
175
|
font-weight: 400;
|
|
172
176
|
}
|
|
@@ -51,12 +51,12 @@ const HeaderBlock = (props) => {
|
|
|
51
51
|
'vertical-offset': curVerticalOffset,
|
|
52
52
|
}) },
|
|
53
53
|
react_1.default.createElement(grid_1.Col, { sizes: titleSizes, className: b('content-inner') },
|
|
54
|
-
overtitle && (react_1.default.createElement("
|
|
54
|
+
overtitle && (react_1.default.createElement("p", { className: b('overtitle') },
|
|
55
55
|
react_1.default.createElement(components_1.HTML, null, overtitle))),
|
|
56
56
|
react_1.default.createElement("h1", { className: b('title') },
|
|
57
57
|
status,
|
|
58
58
|
react_1.default.createElement(components_1.HTML, null, title)),
|
|
59
|
-
description && (react_1.default.createElement("
|
|
59
|
+
description && (react_1.default.createElement("p", { className: b('description') },
|
|
60
60
|
react_1.default.createElement(YFMWrapper_1.default, { content: description, modifiers: { constructor: true } }))),
|
|
61
61
|
buttons && (react_1.default.createElement("div", { className: b('buttons'), "data-qa": "header-buttons" }, buttons &&
|
|
62
62
|
buttons.map((button, index) => (react_1.default.createElement(components_1.RouterLink, { href: button.url, key: index },
|
|
@@ -7,6 +7,6 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const b = (0, utils_1.block)('slider-block-arrow');
|
|
8
8
|
const Arrow = ({ type, handleClick, className, size = 16 }) => (react_1.default.createElement("div", { className: b({ type }, className) },
|
|
9
9
|
react_1.default.createElement("button", { className: b('button'), onClick: () => handleClick && handleClick(type) },
|
|
10
|
-
react_1.default.createElement("
|
|
10
|
+
react_1.default.createElement("span", { className: b('icon-wrapper') },
|
|
11
11
|
react_1.default.createElement(ToggleArrow_1.default, { size: size, type: 'horizontal', iconType: "navigation", className: b('icon') })))));
|
|
12
12
|
exports.default = Arrow;
|
|
@@ -133,8 +133,8 @@ unpredictable css rules order in build */
|
|
|
133
133
|
display: inline-flex;
|
|
134
134
|
justify-content: center;
|
|
135
135
|
}
|
|
136
|
-
.pc-SliderBlock__dots-list
|
|
137
|
-
.pc-SliderBlock__dots-list
|
|
136
|
+
.pc-SliderBlock__dots-list li.pc-SliderBlock__bar,
|
|
137
|
+
.pc-SliderBlock__dots-list li.pc-SliderBlock__dot {
|
|
138
138
|
margin: calc(12px / 2) 8px;
|
|
139
139
|
top: 0;
|
|
140
140
|
}
|
|
@@ -124,13 +124,13 @@ const SliderBlock = (props) => {
|
|
|
124
124
|
const renderBar = () => {
|
|
125
125
|
const barPosition = (DOT_GAP + DOT_WIDTH) * currentIndex;
|
|
126
126
|
const barWidth = DOT_WIDTH + (DOT_GAP + DOT_WIDTH) * (slidesCountByBreakpoint - 1);
|
|
127
|
-
return (slidesCountByBreakpoint > 1 && (react_1.default.createElement("
|
|
127
|
+
return (slidesCountByBreakpoint > 1 && (react_1.default.createElement("li", { className: b('bar'), style: {
|
|
128
128
|
left: barPosition,
|
|
129
129
|
width: barWidth,
|
|
130
130
|
} })));
|
|
131
131
|
};
|
|
132
132
|
const renderDot = (index) => {
|
|
133
|
-
return (react_1.default.createElement("
|
|
133
|
+
return (react_1.default.createElement("li", { key: index, className: b('dot', { active: index === currentIndex }), onClick: () => handleDotClick(index) }));
|
|
134
134
|
};
|
|
135
135
|
const renderNavigation = () => {
|
|
136
136
|
if (childrenCount <= slidesCountByBreakpoint || !dots || childrenCount === 1) {
|
|
@@ -12,9 +12,9 @@ export interface GetSlidesToShowParams {
|
|
|
12
12
|
}
|
|
13
13
|
export declare function getSlidesToShowWithDefaults({ contentLength, breakpoints, mobileFullscreen, }: GetSlidesToShowParams): {
|
|
14
14
|
sm: number;
|
|
15
|
-
md: number;
|
|
16
|
-
lg: number;
|
|
17
15
|
xl: number;
|
|
16
|
+
lg: number;
|
|
17
|
+
md: number;
|
|
18
18
|
};
|
|
19
19
|
export declare function getSliderResponsiveParams(breakpoints: SliderBreakpointParams): {
|
|
20
20
|
breakpoint: number;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSlidesToShowCount = exports.getSlidesCountByBreakpoint = exports.getSliderResponsiveParams = exports.getSlidesToShowWithDefaults = exports.DEFAULT_SLIDE_BREAKPOINTS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
4
6
|
const constants_1 = require("../../constants");
|
|
5
7
|
const models_1 = require("./models");
|
|
6
8
|
exports.DEFAULT_SLIDE_BREAKPOINTS = {
|
|
@@ -18,7 +20,7 @@ function getSlidesToShowWithDefaults({ contentLength, breakpoints, mobileFullscr
|
|
|
18
20
|
else {
|
|
19
21
|
result = breakpoints || exports.DEFAULT_SLIDE_BREAKPOINTS;
|
|
20
22
|
}
|
|
21
|
-
return Object.assign(Object.assign(Object.assign({}, exports.DEFAULT_SLIDE_BREAKPOINTS), result), { sm: !mobileFullscreen && contentLength > 1 ? exports.DEFAULT_SLIDE_BREAKPOINTS.sm : 1 });
|
|
23
|
+
return Object.assign(Object.assign(Object.assign({}, exports.DEFAULT_SLIDE_BREAKPOINTS), lodash_1.default.pickBy(result, (value) => !isNaN(value))), { sm: !mobileFullscreen && contentLength > 1 ? exports.DEFAULT_SLIDE_BREAKPOINTS.sm : 1 });
|
|
22
24
|
}
|
|
23
25
|
exports.getSlidesToShowWithDefaults = getSlidesToShowWithDefaults;
|
|
24
26
|
function getSliderResponsiveParams(breakpoints) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const imageUrlPattern = "^((http[s]?|ftp):\\/)?\\/?([^:\\/\\s]+)((\\/\\w+)*\\/)([\\w\\-\\.]+[^#?\\s]+)(.*)?(#[\\w\\-]+)?$";
|
|
2
2
|
export declare const ImageDeviceProps: {
|
|
3
3
|
type: string;
|
|
4
4
|
additionalProperties: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImageProps = exports.ImageObjectProps = exports.ImageDeviceProps = exports.
|
|
3
|
+
exports.ImageProps = exports.ImageObjectProps = exports.ImageDeviceProps = exports.imageUrlPattern = void 0;
|
|
4
4
|
const utils_1 = require("../../schema/validators/utils");
|
|
5
|
-
exports.
|
|
5
|
+
exports.imageUrlPattern = '^((http[s]?|ftp):\\/)?\\/?([^:\\/\\s]+)((\\/\\w+)*\\/)([\\w\\-\\.]+[^#?\\s]+)(.*)?(#[\\w\\-]+)?$';
|
|
6
6
|
const ImageBase = {
|
|
7
7
|
alt: {
|
|
8
8
|
type: 'string',
|
|
@@ -16,12 +16,12 @@ exports.ImageDeviceProps = {
|
|
|
16
16
|
type: 'object',
|
|
17
17
|
additionalProperties: false,
|
|
18
18
|
required: ['desktop', 'mobile'],
|
|
19
|
-
properties: Object.assign(Object.assign({}, ImageBase), { desktop: { type: 'string', pattern: exports.
|
|
19
|
+
properties: Object.assign(Object.assign({}, ImageBase), { desktop: { type: 'string', pattern: exports.imageUrlPattern }, tablet: {
|
|
20
20
|
type: 'string',
|
|
21
|
-
pattern: exports.
|
|
21
|
+
pattern: exports.imageUrlPattern,
|
|
22
22
|
}, mobile: {
|
|
23
23
|
type: 'string',
|
|
24
|
-
pattern: exports.
|
|
24
|
+
pattern: exports.imageUrlPattern,
|
|
25
25
|
} }),
|
|
26
26
|
};
|
|
27
27
|
exports.ImageObjectProps = {
|
|
@@ -30,14 +30,14 @@ exports.ImageObjectProps = {
|
|
|
30
30
|
required: ['src'],
|
|
31
31
|
properties: Object.assign(Object.assign({}, ImageBase), { src: {
|
|
32
32
|
type: 'string',
|
|
33
|
-
pattern: exports.
|
|
33
|
+
pattern: exports.imageUrlPattern,
|
|
34
34
|
} }),
|
|
35
35
|
};
|
|
36
36
|
exports.ImageProps = {
|
|
37
37
|
oneOf: [
|
|
38
38
|
{
|
|
39
39
|
type: 'string',
|
|
40
|
-
pattern: exports.
|
|
40
|
+
pattern: exports.imageUrlPattern,
|
|
41
41
|
optionName: 'url',
|
|
42
42
|
},
|
|
43
43
|
(0, utils_1.filteredItem)(Object.assign(Object.assign({}, exports.ImageObjectProps), { optionName: 'options' })),
|
|
@@ -40,7 +40,7 @@ const Image = (props) => {
|
|
|
40
40
|
};
|
|
41
41
|
const imageBackground = (oneImage) => {
|
|
42
42
|
const imageData = (0, utils_2.getMediaImage)(oneImage);
|
|
43
|
-
return (react_1.default.createElement(react_spring_1.animated.div, { style: { transform: parallaxInterpolate } },
|
|
43
|
+
return (react_1.default.createElement(react_spring_1.animated.div, { style: { transform: parallaxInterpolate || 'none' } },
|
|
44
44
|
react_1.default.createElement(BackgroundImage_1.default, Object.assign({}, imageData, { className: imageClass, style: { height } }))));
|
|
45
45
|
};
|
|
46
46
|
const imageOnly = (oneImage) => {
|
|
@@ -4,5 +4,5 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const b = (0, utils_1.block)('meta-info');
|
|
7
|
-
const MetaInfo = ({ items, className }) => (react_1.default.createElement("h4", { className: b(null, className) }, items.map((metaInfoItem) => (react_1.default.createElement("
|
|
7
|
+
const MetaInfo = ({ items, className }) => (react_1.default.createElement("h4", { className: b(null, className) }, items.map((metaInfoItem) => (react_1.default.createElement("span", { key: metaInfoItem, className: b('item') }, metaInfoItem)))));
|
|
8
8
|
exports.default = MetaInfo;
|
|
@@ -7,6 +7,7 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
7
7
|
const bem_cn_lite_1 = tslib_1.__importDefault(require("bem-cn-lite"));
|
|
8
8
|
const snakecase_keys_1 = tslib_1.__importDefault(require("snakecase-keys"));
|
|
9
9
|
const components_1 = require("../../components");
|
|
10
|
+
const blocks_1 = require("../../utils/blocks");
|
|
10
11
|
const yfm = (0, bem_cn_lite_1.default)('yfm');
|
|
11
|
-
const YFMWrapper = ({ content, modifiers, className, itemProp, }) => (react_1.default.createElement(components_1.HTML, { className: yfm(modifiers ? (0, snakecase_keys_1.default)(modifiers) : {}, className), itemProp: itemProp }, content));
|
|
12
|
+
const YFMWrapper = ({ content, modifiers, className, itemProp, }) => (react_1.default.createElement(components_1.HTML, { className: yfm(modifiers ? (0, snakecase_keys_1.default)(modifiers) : {}, className), itemProp: itemProp, block: (0, blocks_1.hasBlockTag)(content) }, content));
|
|
12
13
|
exports.default = YFMWrapper;
|
|
@@ -30,13 +30,13 @@ exports.Form = (0, react_1.memo)(({ content, onChange, activeBlockIndex, onSelec
|
|
|
30
30
|
break;
|
|
31
31
|
}
|
|
32
32
|
case FormTab.Blocks: {
|
|
33
|
-
form = (react_1.default.createElement(react_1.Fragment, null, blocks.map((blockData, index) => (react_1.default.createElement(BlockForm_1.BlockForm, { spec: blocksSpec[blockData.type], key: (0, utils_1.getBlockKey)(blockData, index), data: blockData, active: activeBlockIndex === index, onChange: (data) => {
|
|
33
|
+
form = (react_1.default.createElement(react_1.Fragment, null, blocks.map((blockData, index) => blocksSpec[blockData.type] ? (react_1.default.createElement(BlockForm_1.BlockForm, { spec: blocksSpec[blockData.type], key: (0, utils_1.getBlockKey)(blockData, index), data: blockData, active: activeBlockIndex === index, onChange: (data) => {
|
|
34
34
|
onChange(Object.assign(Object.assign({}, content), { blocks: [
|
|
35
35
|
...blocks.slice(0, index),
|
|
36
36
|
data,
|
|
37
37
|
...blocks.slice(index + 1),
|
|
38
38
|
] }));
|
|
39
|
-
}, onSelect: () => onSelect(index) })))));
|
|
39
|
+
}, onSelect: () => onSelect(index) })) : null)));
|
|
40
40
|
break;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -4,7 +4,6 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
/* eslint-disable no-param-reassign */
|
|
5
5
|
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
6
6
|
const dynamic_forms_1 = require("@gravity-ui/dynamic-forms");
|
|
7
|
-
const models_1 = require("../../../models");
|
|
8
7
|
const detect_1 = require("./detect");
|
|
9
8
|
const views_1 = require("./views");
|
|
10
9
|
class FormSpecParser {
|
|
@@ -140,10 +139,10 @@ class FormSpecParser {
|
|
|
140
139
|
}
|
|
141
140
|
getBlocksSpec() {
|
|
142
141
|
const blocks = this.definitions.children;
|
|
143
|
-
return Object.
|
|
142
|
+
return Object.entries(blocks).reduce((result, [blockName, blockData]) => {
|
|
144
143
|
result[blockName] = this.parseSchemaProperty({
|
|
145
144
|
name: blockName,
|
|
146
|
-
data: Object.assign({},
|
|
145
|
+
data: Object.assign({}, blockData),
|
|
147
146
|
required: true,
|
|
148
147
|
});
|
|
149
148
|
return result;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Spec as DynamicFormSpec, ObjectSpec } from '@gravity-ui/dynamic-forms';
|
|
2
|
-
import { BlockType } from '../../../models';
|
|
3
2
|
import { Schema } from '../../../schema';
|
|
4
3
|
export type OneOfSpec = {
|
|
5
4
|
oneOf: DynamicFormSpec[];
|
|
@@ -15,7 +14,7 @@ export interface SpecCustomProps {
|
|
|
15
14
|
}
|
|
16
15
|
export type Spec = Exclude<DynamicFormSpec, 'ObjectSpec'> | CustomObjectSpec | OneOfSpec;
|
|
17
16
|
export type CustomSpec = Spec & SpecCustomProps;
|
|
18
|
-
export type BlocksSpec = Record<
|
|
17
|
+
export type BlocksSpec = Record<string, CustomSpec>;
|
|
19
18
|
export type PageSpec = CustomSpec;
|
|
20
19
|
export interface FormSpecs {
|
|
21
20
|
blocks: BlocksSpec;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getErrorBoundaryState = exports.addEditorProps = exports.addBlock = exports.getNewBlockIndex = exports.duplicateBlock = exports.changeBlocksOrder = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
4
6
|
const changeBlocksOrder = (array, oldIndex, newIndex) => {
|
|
5
7
|
const result = [...array];
|
|
6
8
|
const element = result.splice(oldIndex, 1)[0];
|
|
@@ -10,7 +12,7 @@ const changeBlocksOrder = (array, oldIndex, newIndex) => {
|
|
|
10
12
|
exports.changeBlocksOrder = changeBlocksOrder;
|
|
11
13
|
const duplicateBlock = (array, index) => {
|
|
12
14
|
const result = [...array];
|
|
13
|
-
result.splice(index + 1, 0, result[index]);
|
|
15
|
+
result.splice(index + 1, 0, lodash_1.default.cloneDeep(result[index]));
|
|
14
16
|
return result;
|
|
15
17
|
};
|
|
16
18
|
exports.duplicateBlock = duplicateBlock;
|
|
@@ -9,10 +9,9 @@ const utils_2 = require("../../../../../utils");
|
|
|
9
9
|
const ContentWrapper_1 = require("../ContentWrapper/ContentWrapper");
|
|
10
10
|
const b = (0, utils_2.block)('navigation-dropdown');
|
|
11
11
|
const TOGGLE_ARROW_SIZE = 12;
|
|
12
|
-
exports.NavigationDropdown = react_1.default.forwardRef((
|
|
13
|
-
var { text, icon, isOpened, className, iconSize } = _a, props = tslib_1.__rest(_a, ["text", "icon", "isOpened", "className", "iconSize"]);
|
|
12
|
+
exports.NavigationDropdown = react_1.default.forwardRef(({ text, icon, isOpened, className, iconSize, onClick }, ref) => {
|
|
14
13
|
const iconData = icon && (0, utils_1.getMediaImage)(icon);
|
|
15
|
-
return (react_1.default.createElement("span",
|
|
14
|
+
return (react_1.default.createElement("span", { ref: ref, onClick: onClick, className: b(null, className) },
|
|
16
15
|
react_1.default.createElement(ContentWrapper_1.ContentWrapper, { text: text, icon: iconData, iconSize: iconSize }),
|
|
17
16
|
react_1.default.createElement(components_1.ToggleArrow, { className: b('arrow'), size: TOGGLE_ARROW_SIZE, type: 'vertical', iconType: "navigation", open: isOpened })));
|
|
18
17
|
});
|
|
@@ -12,12 +12,11 @@ exports.Quote = {
|
|
|
12
12
|
contentType: 'text',
|
|
13
13
|
}, image: (0, common_1.withTheme)(schema_1.ImageProps), logo: {
|
|
14
14
|
type: 'string',
|
|
15
|
-
pattern: schema_1.
|
|
15
|
+
pattern: schema_1.imageUrlPattern,
|
|
16
16
|
}, color: {
|
|
17
17
|
type: 'string',
|
|
18
18
|
}, url: {
|
|
19
19
|
type: 'string',
|
|
20
|
-
pattern: schema_1.urlPattern,
|
|
21
20
|
}, buttonText: {
|
|
22
21
|
type: 'string',
|
|
23
22
|
}, theme: common_1.ThemeProps, author: common_1.authorItem }),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Block, CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
|
|
2
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
3
|
export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4" | "h5";
|
|
4
|
+
export declare function hasBlockTag(content: string): boolean;
|
|
4
5
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
5
6
|
export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
|
|
6
7
|
export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomConfig) => {
|
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
|
|
3
|
+
exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.hasBlockTag = exports.getHeaderTag = void 0;
|
|
4
4
|
const models_1 = require("../models");
|
|
5
|
+
const BLOCK_ELEMENTS = [
|
|
6
|
+
'div',
|
|
7
|
+
'p',
|
|
8
|
+
'h[1-6]',
|
|
9
|
+
'address',
|
|
10
|
+
'article',
|
|
11
|
+
'aside',
|
|
12
|
+
'blockquote',
|
|
13
|
+
'canvas',
|
|
14
|
+
'dd',
|
|
15
|
+
'dl',
|
|
16
|
+
'dt',
|
|
17
|
+
'fieldset',
|
|
18
|
+
'figcaption',
|
|
19
|
+
'footer',
|
|
20
|
+
'header',
|
|
21
|
+
'hr',
|
|
22
|
+
'main',
|
|
23
|
+
'nav',
|
|
24
|
+
'section',
|
|
25
|
+
'video',
|
|
26
|
+
'pre',
|
|
27
|
+
'figure',
|
|
28
|
+
'form',
|
|
29
|
+
'pre',
|
|
30
|
+
'ol',
|
|
31
|
+
'ul',
|
|
32
|
+
'li',
|
|
33
|
+
'table',
|
|
34
|
+
'thead',
|
|
35
|
+
'tbody',
|
|
36
|
+
'tfoot',
|
|
37
|
+
'tr',
|
|
38
|
+
'th',
|
|
39
|
+
'td',
|
|
40
|
+
];
|
|
5
41
|
function getHeaderTag(size) {
|
|
6
42
|
switch (size) {
|
|
7
43
|
case 'l':
|
|
@@ -16,6 +52,12 @@ function getHeaderTag(size) {
|
|
|
16
52
|
}
|
|
17
53
|
}
|
|
18
54
|
exports.getHeaderTag = getHeaderTag;
|
|
55
|
+
function hasBlockTag(content) {
|
|
56
|
+
const blockElementRegex = `/<(${BLOCK_ELEMENTS.join('|')})\b[^>]*>/gi`;
|
|
57
|
+
const blockTags = content.match(blockElementRegex);
|
|
58
|
+
return Boolean(blockTags);
|
|
59
|
+
}
|
|
60
|
+
exports.hasBlockTag = hasBlockTag;
|
|
19
61
|
function getBlockKey(block, index) {
|
|
20
62
|
return `${block.type}-${index}`;
|
|
21
63
|
}
|
|
@@ -12,9 +12,7 @@ export declare const ContentLayoutBlock: {
|
|
|
12
12
|
required: string[];
|
|
13
13
|
properties: {
|
|
14
14
|
src: {
|
|
15
|
-
type: string;
|
|
16
|
-
* @deprecated Use params on top level instead
|
|
17
|
-
*/
|
|
15
|
+
type: string;
|
|
18
16
|
pattern: string;
|
|
19
17
|
};
|
|
20
18
|
alt: {
|
|
@@ -143,9 +141,7 @@ export declare const ContentLayoutBlock: {
|
|
|
143
141
|
required: string[];
|
|
144
142
|
properties: {
|
|
145
143
|
src: {
|
|
146
|
-
type: string;
|
|
147
|
-
* @deprecated Use params on top level instead
|
|
148
|
-
*/
|
|
144
|
+
type: string;
|
|
149
145
|
pattern: string;
|
|
150
146
|
};
|
|
151
147
|
alt: {
|
|
@@ -76,6 +76,9 @@ unpredictable css rules order in build */
|
|
|
76
76
|
.pc-header-block__description {
|
|
77
77
|
margin-top: 16px;
|
|
78
78
|
font-weight: normal;
|
|
79
|
+
font-size: var(--yc-text-caption-2-font-size);
|
|
80
|
+
line-height: var(--yc-text-caption-2-line-height);
|
|
81
|
+
margin-block-end: var(--yc-text-body-1-line-height);
|
|
79
82
|
}
|
|
80
83
|
.pc-header-block__description .yfm,
|
|
81
84
|
.pc-header-block__description .yfm * {
|
|
@@ -167,6 +170,7 @@ unpredictable css rules order in build */
|
|
|
167
170
|
.pc-header-block__overtitle {
|
|
168
171
|
font-size: var(--yc-text-body-3-font-size);
|
|
169
172
|
line-height: var(--yc-text-body-3-line-height);
|
|
173
|
+
margin-block-start: var(--yc-text-body-3-line-height);
|
|
170
174
|
margin-bottom: 8px;
|
|
171
175
|
font-weight: 400;
|
|
172
176
|
}
|
|
@@ -48,12 +48,12 @@ export const HeaderBlock = (props) => {
|
|
|
48
48
|
'vertical-offset': curVerticalOffset,
|
|
49
49
|
}) },
|
|
50
50
|
React.createElement(Col, { sizes: titleSizes, className: b('content-inner') },
|
|
51
|
-
overtitle && (React.createElement("
|
|
51
|
+
overtitle && (React.createElement("p", { className: b('overtitle') },
|
|
52
52
|
React.createElement(HTML, null, overtitle))),
|
|
53
53
|
React.createElement("h1", { className: b('title') },
|
|
54
54
|
status,
|
|
55
55
|
React.createElement(HTML, null, title)),
|
|
56
|
-
description && (React.createElement("
|
|
56
|
+
description && (React.createElement("p", { className: b('description') },
|
|
57
57
|
React.createElement(YFMWrapper, { content: description, modifiers: { constructor: true } }))),
|
|
58
58
|
buttons && (React.createElement("div", { className: b('buttons'), "data-qa": "header-buttons" }, buttons &&
|
|
59
59
|
buttons.map((button, index) => (React.createElement(RouterLink, { href: button.url, key: index },
|
|
@@ -5,6 +5,6 @@ import './Arrow.css';
|
|
|
5
5
|
const b = block('slider-block-arrow');
|
|
6
6
|
const Arrow = ({ type, handleClick, className, size = 16 }) => (React.createElement("div", { className: b({ type }, className) },
|
|
7
7
|
React.createElement("button", { className: b('button'), onClick: () => handleClick && handleClick(type) },
|
|
8
|
-
React.createElement("
|
|
8
|
+
React.createElement("span", { className: b('icon-wrapper') },
|
|
9
9
|
React.createElement(ToggleArrow, { size: size, type: 'horizontal', iconType: "navigation", className: b('icon') })))));
|
|
10
10
|
export default Arrow;
|
|
@@ -133,8 +133,8 @@ unpredictable css rules order in build */
|
|
|
133
133
|
display: inline-flex;
|
|
134
134
|
justify-content: center;
|
|
135
135
|
}
|
|
136
|
-
.pc-SliderBlock__dots-list
|
|
137
|
-
.pc-SliderBlock__dots-list
|
|
136
|
+
.pc-SliderBlock__dots-list li.pc-SliderBlock__bar,
|
|
137
|
+
.pc-SliderBlock__dots-list li.pc-SliderBlock__dot {
|
|
138
138
|
margin: calc(12px / 2) 8px;
|
|
139
139
|
top: 0;
|
|
140
140
|
}
|
|
@@ -121,13 +121,13 @@ export const SliderBlock = (props) => {
|
|
|
121
121
|
const renderBar = () => {
|
|
122
122
|
const barPosition = (DOT_GAP + DOT_WIDTH) * currentIndex;
|
|
123
123
|
const barWidth = DOT_WIDTH + (DOT_GAP + DOT_WIDTH) * (slidesCountByBreakpoint - 1);
|
|
124
|
-
return (slidesCountByBreakpoint > 1 && (React.createElement("
|
|
124
|
+
return (slidesCountByBreakpoint > 1 && (React.createElement("li", { className: b('bar'), style: {
|
|
125
125
|
left: barPosition,
|
|
126
126
|
width: barWidth,
|
|
127
127
|
} })));
|
|
128
128
|
};
|
|
129
129
|
const renderDot = (index) => {
|
|
130
|
-
return (React.createElement("
|
|
130
|
+
return (React.createElement("li", { key: index, className: b('dot', { active: index === currentIndex }), onClick: () => handleDotClick(index) }));
|
|
131
131
|
};
|
|
132
132
|
const renderNavigation = () => {
|
|
133
133
|
if (childrenCount <= slidesCountByBreakpoint || !dots || childrenCount === 1) {
|
|
@@ -12,9 +12,9 @@ export interface GetSlidesToShowParams {
|
|
|
12
12
|
}
|
|
13
13
|
export declare function getSlidesToShowWithDefaults({ contentLength, breakpoints, mobileFullscreen, }: GetSlidesToShowParams): {
|
|
14
14
|
sm: number;
|
|
15
|
-
md: number;
|
|
16
|
-
lg: number;
|
|
17
15
|
xl: number;
|
|
16
|
+
lg: number;
|
|
17
|
+
md: number;
|
|
18
18
|
};
|
|
19
19
|
export declare function getSliderResponsiveParams(breakpoints: SliderBreakpointParams): {
|
|
20
20
|
breakpoint: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
import { BREAKPOINTS } from '../../constants';
|
|
2
3
|
import { SliderBreakpointNames } from './models';
|
|
3
4
|
export const DEFAULT_SLIDE_BREAKPOINTS = {
|
|
@@ -15,7 +16,7 @@ export function getSlidesToShowWithDefaults({ contentLength, breakpoints, mobile
|
|
|
15
16
|
else {
|
|
16
17
|
result = breakpoints || DEFAULT_SLIDE_BREAKPOINTS;
|
|
17
18
|
}
|
|
18
|
-
return Object.assign(Object.assign(Object.assign({}, DEFAULT_SLIDE_BREAKPOINTS), result), { sm: !mobileFullscreen && contentLength > 1 ? DEFAULT_SLIDE_BREAKPOINTS.sm : 1 });
|
|
19
|
+
return Object.assign(Object.assign(Object.assign({}, DEFAULT_SLIDE_BREAKPOINTS), _.pickBy(result, (value) => !isNaN(value))), { sm: !mobileFullscreen && contentLength > 1 ? DEFAULT_SLIDE_BREAKPOINTS.sm : 1 });
|
|
19
20
|
}
|
|
20
21
|
export function getSliderResponsiveParams(breakpoints) {
|
|
21
22
|
return Object.entries(breakpoints).map(([breakpointName, slidesToShow]) => ({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const imageUrlPattern = "^((http[s]?|ftp):\\/)?\\/?([^:\\/\\s]+)((\\/\\w+)*\\/)([\\w\\-\\.]+[^#?\\s]+)(.*)?(#[\\w\\-]+)?$";
|
|
2
2
|
export declare const ImageDeviceProps: {
|
|
3
3
|
type: string;
|
|
4
4
|
additionalProperties: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { filteredItem } from '../../schema/validators/utils';
|
|
2
|
-
export const
|
|
2
|
+
export const imageUrlPattern = '^((http[s]?|ftp):\\/)?\\/?([^:\\/\\s]+)((\\/\\w+)*\\/)([\\w\\-\\.]+[^#?\\s]+)(.*)?(#[\\w\\-]+)?$';
|
|
3
3
|
const ImageBase = {
|
|
4
4
|
alt: {
|
|
5
5
|
type: 'string',
|
|
@@ -13,12 +13,12 @@ export const ImageDeviceProps = {
|
|
|
13
13
|
type: 'object',
|
|
14
14
|
additionalProperties: false,
|
|
15
15
|
required: ['desktop', 'mobile'],
|
|
16
|
-
properties: Object.assign(Object.assign({}, ImageBase), { desktop: { type: 'string', pattern:
|
|
16
|
+
properties: Object.assign(Object.assign({}, ImageBase), { desktop: { type: 'string', pattern: imageUrlPattern }, tablet: {
|
|
17
17
|
type: 'string',
|
|
18
|
-
pattern:
|
|
18
|
+
pattern: imageUrlPattern,
|
|
19
19
|
}, mobile: {
|
|
20
20
|
type: 'string',
|
|
21
|
-
pattern:
|
|
21
|
+
pattern: imageUrlPattern,
|
|
22
22
|
} }),
|
|
23
23
|
};
|
|
24
24
|
export const ImageObjectProps = {
|
|
@@ -27,14 +27,14 @@ export const ImageObjectProps = {
|
|
|
27
27
|
required: ['src'],
|
|
28
28
|
properties: Object.assign(Object.assign({}, ImageBase), { src: {
|
|
29
29
|
type: 'string',
|
|
30
|
-
pattern:
|
|
30
|
+
pattern: imageUrlPattern,
|
|
31
31
|
} }),
|
|
32
32
|
};
|
|
33
33
|
export const ImageProps = {
|
|
34
34
|
oneOf: [
|
|
35
35
|
{
|
|
36
36
|
type: 'string',
|
|
37
|
-
pattern:
|
|
37
|
+
pattern: imageUrlPattern,
|
|
38
38
|
optionName: 'url',
|
|
39
39
|
},
|
|
40
40
|
filteredItem(Object.assign(Object.assign({}, ImageObjectProps), { optionName: 'options' })),
|
|
@@ -38,7 +38,7 @@ const Image = (props) => {
|
|
|
38
38
|
};
|
|
39
39
|
const imageBackground = (oneImage) => {
|
|
40
40
|
const imageData = getMediaImage(oneImage);
|
|
41
|
-
return (React.createElement(animated.div, { style: { transform: parallaxInterpolate } },
|
|
41
|
+
return (React.createElement(animated.div, { style: { transform: parallaxInterpolate || 'none' } },
|
|
42
42
|
React.createElement(BackgroundImage, Object.assign({}, imageData, { className: imageClass, style: { height } }))));
|
|
43
43
|
};
|
|
44
44
|
const imageOnly = (oneImage) => {
|
|
@@ -2,5 +2,5 @@ import React from 'react';
|
|
|
2
2
|
import { block } from '../../utils';
|
|
3
3
|
import './MetaInfo.css';
|
|
4
4
|
const b = block('meta-info');
|
|
5
|
-
const MetaInfo = ({ items, className }) => (React.createElement("h4", { className: b(null, className) }, items.map((metaInfoItem) => (React.createElement("
|
|
5
|
+
const MetaInfo = ({ items, className }) => (React.createElement("h4", { className: b(null, className) }, items.map((metaInfoItem) => (React.createElement("span", { key: metaInfoItem, className: b('item') }, metaInfoItem)))));
|
|
6
6
|
export default MetaInfo;
|
|
@@ -4,6 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import block from 'bem-cn-lite';
|
|
5
5
|
import toSnakeCase from 'snakecase-keys';
|
|
6
6
|
import { HTML } from '../../components';
|
|
7
|
+
import { hasBlockTag } from '../../utils/blocks';
|
|
7
8
|
const yfm = block('yfm');
|
|
8
|
-
const YFMWrapper = ({ content, modifiers, className, itemProp, }) => (React.createElement(HTML, { className: yfm(modifiers ? toSnakeCase(modifiers) : {}, className), itemProp: itemProp }, content));
|
|
9
|
+
const YFMWrapper = ({ content, modifiers, className, itemProp, }) => (React.createElement(HTML, { className: yfm(modifiers ? toSnakeCase(modifiers) : {}, className), itemProp: itemProp, block: hasBlockTag(content) }, content));
|
|
9
10
|
export default YFMWrapper;
|
|
@@ -28,13 +28,13 @@ export const Form = memo(({ content, onChange, activeBlockIndex, onSelect, spec
|
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
case FormTab.Blocks: {
|
|
31
|
-
form = (React.createElement(Fragment, null, blocks.map((blockData, index) => (React.createElement(BlockForm, { spec: blocksSpec[blockData.type], key: getBlockKey(blockData, index), data: blockData, active: activeBlockIndex === index, onChange: (data) => {
|
|
31
|
+
form = (React.createElement(Fragment, null, blocks.map((blockData, index) => blocksSpec[blockData.type] ? (React.createElement(BlockForm, { spec: blocksSpec[blockData.type], key: getBlockKey(blockData, index), data: blockData, active: activeBlockIndex === index, onChange: (data) => {
|
|
32
32
|
onChange(Object.assign(Object.assign({}, content), { blocks: [
|
|
33
33
|
...blocks.slice(0, index),
|
|
34
34
|
data,
|
|
35
35
|
...blocks.slice(index + 1),
|
|
36
36
|
] }));
|
|
37
|
-
}, onSelect: () => onSelect(index) })))));
|
|
37
|
+
}, onSelect: () => onSelect(index) })) : null)));
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -2,7 +2,6 @@ import { __rest } from "tslib";
|
|
|
2
2
|
/* eslint-disable no-param-reassign */
|
|
3
3
|
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
4
4
|
import { SpecTypes } from '@gravity-ui/dynamic-forms';
|
|
5
|
-
import { BlockType } from '../../../models';
|
|
6
5
|
import { ParserType, detectParserType } from './detect';
|
|
7
6
|
import { getArrayViewSpec, getObjectViewSpec, getOneOfViewSpec, getPrimitiveViewSpec } from './views';
|
|
8
7
|
class FormSpecParser {
|
|
@@ -138,10 +137,10 @@ class FormSpecParser {
|
|
|
138
137
|
}
|
|
139
138
|
getBlocksSpec() {
|
|
140
139
|
const blocks = this.definitions.children;
|
|
141
|
-
return Object.
|
|
140
|
+
return Object.entries(blocks).reduce((result, [blockName, blockData]) => {
|
|
142
141
|
result[blockName] = this.parseSchemaProperty({
|
|
143
142
|
name: blockName,
|
|
144
|
-
data: Object.assign({},
|
|
143
|
+
data: Object.assign({}, blockData),
|
|
145
144
|
required: true,
|
|
146
145
|
});
|
|
147
146
|
return result;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Spec as DynamicFormSpec, ObjectSpec } from '@gravity-ui/dynamic-forms';
|
|
2
|
-
import { BlockType } from '../../../models';
|
|
3
2
|
import { Schema } from '../../../schema';
|
|
4
3
|
export type OneOfSpec = {
|
|
5
4
|
oneOf: DynamicFormSpec[];
|
|
@@ -15,7 +14,7 @@ export interface SpecCustomProps {
|
|
|
15
14
|
}
|
|
16
15
|
export type Spec = Exclude<DynamicFormSpec, 'ObjectSpec'> | CustomObjectSpec | OneOfSpec;
|
|
17
16
|
export type CustomSpec = Spec & SpecCustomProps;
|
|
18
|
-
export type BlocksSpec = Record<
|
|
17
|
+
export type BlocksSpec = Record<string, CustomSpec>;
|
|
19
18
|
export type PageSpec = CustomSpec;
|
|
20
19
|
export interface FormSpecs {
|
|
21
20
|
blocks: BlocksSpec;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
export const changeBlocksOrder = (array, oldIndex, newIndex) => {
|
|
2
3
|
const result = [...array];
|
|
3
4
|
const element = result.splice(oldIndex, 1)[0];
|
|
@@ -6,7 +7,7 @@ export const changeBlocksOrder = (array, oldIndex, newIndex) => {
|
|
|
6
7
|
};
|
|
7
8
|
export const duplicateBlock = (array, index) => {
|
|
8
9
|
const result = [...array];
|
|
9
|
-
result.splice(index + 1, 0, result[index]);
|
|
10
|
+
result.splice(index + 1, 0, _.cloneDeep(result[index]));
|
|
10
11
|
return result;
|
|
11
12
|
};
|
|
12
13
|
export const getNewBlockIndex = (id, orderedBlocksCount) => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { ToggleArrow } from '../../../../../components';
|
|
4
3
|
import { getMediaImage } from '../../../../../components/Media/Image/utils';
|
|
@@ -7,10 +6,9 @@ import { ContentWrapper } from '../ContentWrapper/ContentWrapper';
|
|
|
7
6
|
import './NavigationDropdown.css';
|
|
8
7
|
const b = block('navigation-dropdown');
|
|
9
8
|
const TOGGLE_ARROW_SIZE = 12;
|
|
10
|
-
export const NavigationDropdown = React.forwardRef((
|
|
11
|
-
var { text, icon, isOpened, className, iconSize } = _a, props = __rest(_a, ["text", "icon", "isOpened", "className", "iconSize"]);
|
|
9
|
+
export const NavigationDropdown = React.forwardRef(({ text, icon, isOpened, className, iconSize, onClick }, ref) => {
|
|
12
10
|
const iconData = icon && getMediaImage(icon);
|
|
13
|
-
return (React.createElement("span",
|
|
11
|
+
return (React.createElement("span", { ref: ref, onClick: onClick, className: b(null, className) },
|
|
14
12
|
React.createElement(ContentWrapper, { text: text, icon: iconData, iconSize: iconSize }),
|
|
15
13
|
React.createElement(ToggleArrow, { className: b('arrow'), size: TOGGLE_ARROW_SIZE, type: 'vertical', iconType: "navigation", open: isOpened })));
|
|
16
14
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { omit } from 'lodash';
|
|
2
|
-
import { ImageProps,
|
|
2
|
+
import { ImageProps, imageUrlPattern } from '../components/Image/schema';
|
|
3
3
|
import { ButtonProps } from '../schema/validators/common';
|
|
4
4
|
import { filteredArray } from '../schema/validators/utils';
|
|
5
5
|
const NavigationItemType = {
|
|
@@ -31,7 +31,7 @@ const NavigationItemBaseProps = {
|
|
|
31
31
|
},
|
|
32
32
|
icon: {
|
|
33
33
|
type: 'string',
|
|
34
|
-
pattern:
|
|
34
|
+
pattern: imageUrlPattern,
|
|
35
35
|
},
|
|
36
36
|
iconSize: {
|
|
37
37
|
type: 'number',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImageProps,
|
|
1
|
+
import { ImageProps, imageUrlPattern } from '../../components/Image/schema';
|
|
2
2
|
import { Theme } from '../../models';
|
|
3
3
|
import { AnalyticsEventSchema } from './event';
|
|
4
4
|
import { pixelEvents } from './pixel';
|
|
@@ -237,7 +237,7 @@ export const authorItem = {
|
|
|
237
237
|
},
|
|
238
238
|
avatar: {
|
|
239
239
|
type: 'string',
|
|
240
|
-
pattern:
|
|
240
|
+
pattern: imageUrlPattern,
|
|
241
241
|
},
|
|
242
242
|
description: {
|
|
243
243
|
type: 'string',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImageProps,
|
|
1
|
+
import { ImageProps, imageUrlPattern } from '../../components/Image/schema';
|
|
2
2
|
import { BaseProps, ThemeProps, authorItem, withTheme } from '../../schema/validators/common';
|
|
3
3
|
export const Quote = {
|
|
4
4
|
quote: {
|
|
@@ -9,12 +9,11 @@ export const Quote = {
|
|
|
9
9
|
contentType: 'text',
|
|
10
10
|
}, image: withTheme(ImageProps), logo: {
|
|
11
11
|
type: 'string',
|
|
12
|
-
pattern:
|
|
12
|
+
pattern: imageUrlPattern,
|
|
13
13
|
}, color: {
|
|
14
14
|
type: 'string',
|
|
15
15
|
}, url: {
|
|
16
16
|
type: 'string',
|
|
17
|
-
pattern: urlPattern,
|
|
18
17
|
}, buttonText: {
|
|
19
18
|
type: 'string',
|
|
20
19
|
}, theme: ThemeProps, author: authorItem }),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Block, CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
|
|
2
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
3
|
export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4" | "h5";
|
|
4
|
+
export declare function hasBlockTag(content: string): boolean;
|
|
4
5
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
5
6
|
export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
|
|
6
7
|
export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomConfig) => {
|
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
import { PCShareSocialNetwork } from '../models';
|
|
2
|
+
const BLOCK_ELEMENTS = [
|
|
3
|
+
'div',
|
|
4
|
+
'p',
|
|
5
|
+
'h[1-6]',
|
|
6
|
+
'address',
|
|
7
|
+
'article',
|
|
8
|
+
'aside',
|
|
9
|
+
'blockquote',
|
|
10
|
+
'canvas',
|
|
11
|
+
'dd',
|
|
12
|
+
'dl',
|
|
13
|
+
'dt',
|
|
14
|
+
'fieldset',
|
|
15
|
+
'figcaption',
|
|
16
|
+
'footer',
|
|
17
|
+
'header',
|
|
18
|
+
'hr',
|
|
19
|
+
'main',
|
|
20
|
+
'nav',
|
|
21
|
+
'section',
|
|
22
|
+
'video',
|
|
23
|
+
'pre',
|
|
24
|
+
'figure',
|
|
25
|
+
'form',
|
|
26
|
+
'pre',
|
|
27
|
+
'ol',
|
|
28
|
+
'ul',
|
|
29
|
+
'li',
|
|
30
|
+
'table',
|
|
31
|
+
'thead',
|
|
32
|
+
'tbody',
|
|
33
|
+
'tfoot',
|
|
34
|
+
'tr',
|
|
35
|
+
'th',
|
|
36
|
+
'td',
|
|
37
|
+
];
|
|
2
38
|
export function getHeaderTag(size) {
|
|
3
39
|
switch (size) {
|
|
4
40
|
case 'l':
|
|
@@ -12,6 +48,11 @@ export function getHeaderTag(size) {
|
|
|
12
48
|
return 'h2';
|
|
13
49
|
}
|
|
14
50
|
}
|
|
51
|
+
export function hasBlockTag(content) {
|
|
52
|
+
const blockElementRegex = `/<(${BLOCK_ELEMENTS.join('|')})\b[^>]*>/gi`;
|
|
53
|
+
const blockTags = content.match(blockElementRegex);
|
|
54
|
+
return Boolean(blockTags);
|
|
55
|
+
}
|
|
15
56
|
export function getBlockKey(block, index) {
|
|
16
57
|
return `${block.type}-${index}`;
|
|
17
58
|
}
|
package/package.json
CHANGED
package/server/utils/blocks.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Block, CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
|
|
2
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
3
|
export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4" | "h5";
|
|
4
|
+
export declare function hasBlockTag(content: string): boolean;
|
|
4
5
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
5
6
|
export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
|
|
6
7
|
export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomConfig) => {
|
package/server/utils/blocks.js
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
|
|
3
|
+
exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.hasBlockTag = exports.getHeaderTag = void 0;
|
|
4
4
|
const models_1 = require("../models");
|
|
5
|
+
const BLOCK_ELEMENTS = [
|
|
6
|
+
'div',
|
|
7
|
+
'p',
|
|
8
|
+
'h[1-6]',
|
|
9
|
+
'address',
|
|
10
|
+
'article',
|
|
11
|
+
'aside',
|
|
12
|
+
'blockquote',
|
|
13
|
+
'canvas',
|
|
14
|
+
'dd',
|
|
15
|
+
'dl',
|
|
16
|
+
'dt',
|
|
17
|
+
'fieldset',
|
|
18
|
+
'figcaption',
|
|
19
|
+
'footer',
|
|
20
|
+
'header',
|
|
21
|
+
'hr',
|
|
22
|
+
'main',
|
|
23
|
+
'nav',
|
|
24
|
+
'section',
|
|
25
|
+
'video',
|
|
26
|
+
'pre',
|
|
27
|
+
'figure',
|
|
28
|
+
'form',
|
|
29
|
+
'pre',
|
|
30
|
+
'ol',
|
|
31
|
+
'ul',
|
|
32
|
+
'li',
|
|
33
|
+
'table',
|
|
34
|
+
'thead',
|
|
35
|
+
'tbody',
|
|
36
|
+
'tfoot',
|
|
37
|
+
'tr',
|
|
38
|
+
'th',
|
|
39
|
+
'td',
|
|
40
|
+
];
|
|
5
41
|
function getHeaderTag(size) {
|
|
6
42
|
switch (size) {
|
|
7
43
|
case 'l':
|
|
@@ -16,6 +52,12 @@ function getHeaderTag(size) {
|
|
|
16
52
|
}
|
|
17
53
|
}
|
|
18
54
|
exports.getHeaderTag = getHeaderTag;
|
|
55
|
+
function hasBlockTag(content) {
|
|
56
|
+
const blockElementRegex = `/<(${BLOCK_ELEMENTS.join('|')})\b[^>]*>/gi`;
|
|
57
|
+
const blockTags = content.match(blockElementRegex);
|
|
58
|
+
return Boolean(blockTags);
|
|
59
|
+
}
|
|
60
|
+
exports.hasBlockTag = hasBlockTag;
|
|
19
61
|
function getBlockKey(block, index) {
|
|
20
62
|
return `${block.type}-${index}`;
|
|
21
63
|
}
|