@gravity-ui/page-constructor 5.28.6 → 5.28.7-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/Media/Media.js +7 -2
- package/build/cjs/blocks/PromoFeaturesBlock/PromoFeaturesBlock.js +6 -1
- package/build/cjs/blocks/Questions/Questions.js +1 -1
- package/build/cjs/blocks/Questions/models.d.ts +1 -0
- package/build/cjs/blocks/Questions/models.js +1 -0
- package/build/cjs/blocks/Tabs/Tabs.js +8 -2
- package/build/cjs/blocks/Tabs/TabsTextContent/TabsTextContent.d.ts +2 -2
- package/build/cjs/blocks/Tabs/TabsTextContent/TabsTextContent.js +12 -6
- package/build/cjs/components/ContentList/ContentList.css +24 -0
- package/build/cjs/components/ContentList/ContentList.d.ts +1 -1
- package/build/cjs/components/ContentList/ContentList.js +2 -2
- package/build/cjs/components/Media/Media.js +11 -2
- package/build/cjs/components/Title/TitleItem.d.ts +1 -1
- package/build/cjs/containers/PageConstructor/PageConstructor.d.ts +3 -0
- package/build/cjs/containers/PageConstructor/PageConstructor.js +3 -2
- package/build/cjs/context/innerContext/InnerContext.d.ts +3 -0
- package/build/cjs/context/innerContext/InnerContext.js +1 -0
- package/build/cjs/grid/Col/Col.d.ts +1 -1
- package/build/cjs/models/constructor-items/common.d.ts +8 -0
- package/build/cjs/sub-blocks/Content/Content.css +4 -14
- package/build/cjs/sub-blocks/Content/Content.js +1 -1
- package/build/cjs/sub-blocks/LayoutItem/LayoutItem.js +9 -1
- package/build/cjs/utils/microdata.d.ts +3 -0
- package/build/cjs/utils/microdata.js +11 -0
- package/build/esm/blocks/Media/Media.js +7 -2
- package/build/esm/blocks/PromoFeaturesBlock/PromoFeaturesBlock.js +6 -1
- package/build/esm/blocks/Questions/Questions.js +1 -1
- package/build/esm/blocks/Questions/models.d.ts +1 -0
- package/build/esm/blocks/Questions/models.js +1 -0
- package/build/esm/blocks/Tabs/Tabs.js +8 -2
- package/build/esm/blocks/Tabs/TabsTextContent/TabsTextContent.d.ts +2 -2
- package/build/esm/blocks/Tabs/TabsTextContent/TabsTextContent.js +12 -6
- package/build/esm/components/ContentList/ContentList.css +24 -0
- package/build/esm/components/ContentList/ContentList.d.ts +1 -1
- package/build/esm/components/ContentList/ContentList.js +2 -2
- package/build/esm/components/Media/Media.js +12 -3
- package/build/esm/components/Title/TitleItem.d.ts +1 -1
- package/build/esm/containers/PageConstructor/PageConstructor.d.ts +3 -0
- package/build/esm/containers/PageConstructor/PageConstructor.js +3 -2
- package/build/esm/context/innerContext/InnerContext.d.ts +3 -0
- package/build/esm/context/innerContext/InnerContext.js +1 -0
- package/build/esm/grid/Col/Col.d.ts +1 -1
- package/build/esm/models/constructor-items/common.d.ts +8 -0
- package/build/esm/sub-blocks/Content/Content.css +4 -14
- package/build/esm/sub-blocks/Content/Content.js +1 -1
- package/build/esm/sub-blocks/LayoutItem/LayoutItem.js +9 -1
- package/build/esm/utils/microdata.d.ts +3 -0
- package/build/esm/utils/microdata.js +5 -0
- package/package.json +1 -1
- package/server/models/constructor-items/common.d.ts +8 -0
- package/widget/index.js +1 -1
|
@@ -53,6 +53,30 @@ unpredictable css rules order in build */
|
|
|
53
53
|
margin-top: 0;
|
|
54
54
|
margin-bottom: 0;
|
|
55
55
|
}
|
|
56
|
+
.pc-content-list_theme_light .pc-content-list__item *,
|
|
57
|
+
.pc-content-list_theme_light .pc-content-list__item .yfm,
|
|
58
|
+
.pc-content-list_theme_light .pc-content-list__item .yfm * {
|
|
59
|
+
color: var(--g-color-text-dark-primary);
|
|
60
|
+
}
|
|
61
|
+
.pc-content-list_theme_light .pc-content-list__item .yfm a {
|
|
62
|
+
color: var(--g-color-text-dark-primary);
|
|
63
|
+
text-decoration: underline;
|
|
64
|
+
}
|
|
65
|
+
.pc-content-list_theme_light .pc-content-list__item .yfm a:hover {
|
|
66
|
+
color: var(--g-color-text-dark-secondary);
|
|
67
|
+
}
|
|
68
|
+
.pc-content-list_theme_dark .pc-content-list__item *,
|
|
69
|
+
.pc-content-list_theme_dark .pc-content-list__item .yfm,
|
|
70
|
+
.pc-content-list_theme_dark .pc-content-list__item .yfm * {
|
|
71
|
+
color: var(--g-color-text-light-primary);
|
|
72
|
+
}
|
|
73
|
+
.pc-content-list_theme_dark .pc-content-list__item .yfm a {
|
|
74
|
+
color: var(--g-color-text-light-primary);
|
|
75
|
+
text-decoration: underline;
|
|
76
|
+
}
|
|
77
|
+
.pc-content-list_theme_dark .pc-content-list__item .yfm a:hover {
|
|
78
|
+
color: var(--g-color-text-light-secondary);
|
|
79
|
+
}
|
|
56
80
|
.pc-content-list__icon {
|
|
57
81
|
display: block;
|
|
58
82
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContentListProps } from '../../models';
|
|
2
2
|
import { QAProps } from '../../models/common';
|
|
3
3
|
import './ContentList.css';
|
|
4
|
-
declare const ContentList: ({ list, size, qa }: ContentListProps & QAProps) => JSX.Element;
|
|
4
|
+
declare const ContentList: ({ list, size, qa, theme }: ContentListProps & QAProps) => JSX.Element;
|
|
5
5
|
export default ContentList;
|
|
@@ -15,9 +15,9 @@ function getHeadingLevel(size) {
|
|
|
15
15
|
return 'h3';
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
const ContentList = ({ list, size = 'l', qa }) => {
|
|
18
|
+
const ContentList = ({ list, size = 'l', qa, theme }) => {
|
|
19
19
|
const qaAttributes = getQaAttrubutes(qa, ['image', 'title', 'text']);
|
|
20
|
-
return (React.createElement("div", { className: b({ size }), "data-qa": qa }, list === null || list === void 0 ? void 0 : list.map((item) => {
|
|
20
|
+
return (React.createElement("div", { className: b({ size, theme }), "data-qa": qa }, list === null || list === void 0 ? void 0 : list.map((item) => {
|
|
21
21
|
const { icon, title, text } = item;
|
|
22
22
|
return (React.createElement("div", { className: b('item', { 'without-title': !title }), key: uuidv4() },
|
|
23
23
|
React.createElement(ItemIcon, { icon: icon, className: b('icon'), qa: qaAttributes.image }),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useMemo, useState } from 'react';
|
|
1
|
+
import React, { useContext, useMemo, useState } from 'react';
|
|
2
|
+
import { InnerContext } from '../../context/innerContext';
|
|
2
3
|
import { block, getQaAttrubutes } from '../../utils';
|
|
3
4
|
import IframeVideoBlock from '../VideoBlock/VideoBlock';
|
|
4
5
|
import DataLens from './DataLens/DataLens';
|
|
@@ -9,8 +10,9 @@ import Video from './Video/Video';
|
|
|
9
10
|
import './Media.css';
|
|
10
11
|
const b = block('Media');
|
|
11
12
|
export const Media = (props) => {
|
|
12
|
-
const { image, video, youtube, videoIframe, dataLens, color, height, previewImg, parallax = false, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, disableImageSliderForArrayInput, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, autoplay, onImageLoad, iframe, margins, } = props;
|
|
13
|
+
const { image, video, youtube, videoIframe, dataLens, color, height, previewImg, parallax = false, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, disableImageSliderForArrayInput, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, autoplay, onImageLoad, iframe, margins, videoMicrodata, } = props;
|
|
13
14
|
const [hasVideoFallback, setHasVideoFallback] = useState(false);
|
|
15
|
+
const { microdata } = useContext(InnerContext);
|
|
14
16
|
const qaAttributes = getQaAttrubutes(qa, 'video');
|
|
15
17
|
const content = useMemo(() => {
|
|
16
18
|
let result = [];
|
|
@@ -77,6 +79,13 @@ export const Media = (props) => {
|
|
|
77
79
|
autoplay,
|
|
78
80
|
margins,
|
|
79
81
|
]);
|
|
80
|
-
|
|
82
|
+
const videoMicrodataScript = useMemo(() => {
|
|
83
|
+
var _a;
|
|
84
|
+
const json = JSON.stringify(Object.assign({ '@context': 'http://schema.org/', '@type': 'VideoObject', uploadDate: microdata === null || microdata === void 0 ? void 0 : microdata.contentUpdatedDate, contentUrl: ((_a = video === null || video === void 0 ? void 0 : video.src) === null || _a === void 0 ? void 0 : _a[0]) || videoIframe || youtube, thumbnailUrl: previewImg }, videoMicrodata));
|
|
85
|
+
return video || youtube || videoIframe ? (React.createElement("script", { type: "application/ld+json" }, json)) : null;
|
|
86
|
+
}, [microdata === null || microdata === void 0 ? void 0 : microdata.contentUpdatedDate, previewImg, video, videoIframe, videoMicrodata, youtube]);
|
|
87
|
+
return (React.createElement("div", { className: b(null, className), style: { backgroundColor: color }, "data-qa": qa },
|
|
88
|
+
videoMicrodataScript,
|
|
89
|
+
content));
|
|
81
90
|
};
|
|
82
91
|
export default Media;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QAProps, TextSize, TitleItemProps } from '../../models';
|
|
2
2
|
import './TitleItem.css';
|
|
3
|
-
export declare function getArrowSize(size: TextSize, isMobile: boolean):
|
|
3
|
+
export declare function getArrowSize(size: TextSize, isMobile: boolean): 20 | 24 | 16 | 13 | 22 | 26 | 38;
|
|
4
4
|
export interface TitleItemFullProps extends TitleItemProps, QAProps {
|
|
5
5
|
className?: string;
|
|
6
6
|
onClick?: () => void;
|
|
@@ -11,6 +11,9 @@ export interface PageConstructorProps {
|
|
|
11
11
|
custom?: CustomConfig;
|
|
12
12
|
renderMenu?: () => React.ReactNode;
|
|
13
13
|
navigation?: NavigationData;
|
|
14
|
+
microdata?: {
|
|
15
|
+
contentUpdatedDate: string;
|
|
16
|
+
};
|
|
14
17
|
}
|
|
15
18
|
export declare const Constructor: (props: PageConstructorProps) => JSX.Element;
|
|
16
19
|
export declare const PageConstructor: (props: PageConstructorProps) => JSX.Element;
|
|
@@ -18,7 +18,7 @@ import { ConstructorRow } from './components/ConstructorRow';
|
|
|
18
18
|
import './PageConstructor.css';
|
|
19
19
|
const b = cnBlock('page-constructor');
|
|
20
20
|
export const Constructor = (props) => {
|
|
21
|
-
const { content: { blocks = [], background } = {}, renderMenu, shouldRenderBlock, navigation, custom, } = props;
|
|
21
|
+
const { content: { blocks = [], background } = {}, renderMenu, shouldRenderBlock, navigation, custom, microdata, } = props;
|
|
22
22
|
const { context } = useMemo(() => ({
|
|
23
23
|
context: {
|
|
24
24
|
blockTypes: [...BlockTypes, ...getCustomTypes(['blocks', 'headers'], custom)],
|
|
@@ -35,8 +35,9 @@ export const Constructor = (props) => {
|
|
|
35
35
|
customization: {
|
|
36
36
|
decorators: custom === null || custom === void 0 ? void 0 : custom.decorators,
|
|
37
37
|
},
|
|
38
|
+
microdata,
|
|
38
39
|
},
|
|
39
|
-
}), [custom, shouldRenderBlock]);
|
|
40
|
+
}), [custom, shouldRenderBlock, microdata]);
|
|
40
41
|
const theme = useTheme();
|
|
41
42
|
const header = getHeaderBlock(blocks, context.headerBlockTypes);
|
|
42
43
|
const restBlocks = getOrderedBlocks(blocks, context.headerBlockTypes);
|
|
@@ -11,5 +11,8 @@ export interface InnerContextType {
|
|
|
11
11
|
loadables?: LoadableConfig;
|
|
12
12
|
shouldRenderBlock?: ShouldRenderBlock;
|
|
13
13
|
customization?: Pick<CustomConfig, 'decorators'>;
|
|
14
|
+
microdata?: {
|
|
15
|
+
contentUpdatedDate?: string;
|
|
16
|
+
};
|
|
14
17
|
}
|
|
15
18
|
export declare const InnerContext: React.Context<InnerContextType>;
|
|
@@ -5,4 +5,4 @@ export interface GridColumnProps extends GridColumnClassParams, Refable<HTMLDivE
|
|
|
5
5
|
style?: CSSProperties;
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
}
|
|
8
|
-
export declare const Col: React.ForwardRefExoticComponent<Pick<React.PropsWithChildren<GridColumnProps>, "style" | "children" | "sizes" | "className" | "hidden" | "role" | "qa" | "
|
|
8
|
+
export declare const Col: React.ForwardRefExoticComponent<Pick<React.PropsWithChildren<GridColumnProps>, "style" | "children" | "sizes" | "className" | "hidden" | "role" | "qa" | "offsets" | "orders" | "visible" | "alignSelf" | "justifyContent" | "reset"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -207,6 +207,14 @@ export interface MediaComponentIframeProps {
|
|
|
207
207
|
}
|
|
208
208
|
export interface MediaProps extends Animatable, Partial<MediaComponentDataLensProps>, Partial<MediaComponentYoutubeProps>, Partial<MediaComponentVideoIframeProps>, Partial<MediaComponentImageProps>, Partial<MediaComponentIframeProps>, Partial<MediaComponentVideoProps> {
|
|
209
209
|
color?: string;
|
|
210
|
+
videoMicrodata?: {
|
|
211
|
+
name?: string;
|
|
212
|
+
description?: string;
|
|
213
|
+
duration?: string;
|
|
214
|
+
uploadDate?: string;
|
|
215
|
+
contentUrl?: string;
|
|
216
|
+
thumbnailUrl?: string;
|
|
217
|
+
};
|
|
210
218
|
}
|
|
211
219
|
export interface BackgroundMediaProps extends MediaProps, Animatable, QAProps {
|
|
212
220
|
fullWidthMedia?: boolean;
|
|
@@ -87,9 +87,6 @@ unpredictable css rules order in build */
|
|
|
87
87
|
.pc-content_theme_dark .pc-content__title *,
|
|
88
88
|
.pc-content_theme_dark .pc-content__text .yfm,
|
|
89
89
|
.pc-content_theme_dark .pc-content__text .yfm *,
|
|
90
|
-
.pc-content_theme_dark .pc-content__list *,
|
|
91
|
-
.pc-content_theme_dark .pc-content__list .yfm,
|
|
92
|
-
.pc-content_theme_dark .pc-content__list .yfm *,
|
|
93
90
|
.pc-content_theme_dark .pc-content__links a {
|
|
94
91
|
color: var(--g-color-text-light-primary);
|
|
95
92
|
}
|
|
@@ -104,13 +101,11 @@ unpredictable css rules order in build */
|
|
|
104
101
|
.pc-content_theme_dark .pc-content__notice .yfm a:hover {
|
|
105
102
|
color: var(--g-color-text-light-primary);
|
|
106
103
|
}
|
|
107
|
-
.pc-content_theme_dark .pc-content__text .yfm a
|
|
108
|
-
.pc-content_theme_dark .pc-content__list .yfm a {
|
|
104
|
+
.pc-content_theme_dark .pc-content__text .yfm a {
|
|
109
105
|
color: var(--g-color-text-light-primary);
|
|
110
106
|
text-decoration: underline;
|
|
111
107
|
}
|
|
112
|
-
.pc-content_theme_dark .pc-content__text .yfm a:hover
|
|
113
|
-
.pc-content_theme_dark .pc-content__list .yfm a:hover {
|
|
108
|
+
.pc-content_theme_dark .pc-content__text .yfm a:hover {
|
|
114
109
|
color: var(--g-color-text-light-secondary);
|
|
115
110
|
}
|
|
116
111
|
.pc-content_theme_dark .pc-content__title a {
|
|
@@ -124,9 +119,6 @@ unpredictable css rules order in build */
|
|
|
124
119
|
.pc-content_theme_light .pc-content__title *,
|
|
125
120
|
.pc-content_theme_light .pc-content__text .yfm,
|
|
126
121
|
.pc-content_theme_light .pc-content__text .yfm *,
|
|
127
|
-
.pc-content_theme_light .pc-content__list *,
|
|
128
|
-
.pc-content_theme_light .pc-content__list .yfm,
|
|
129
|
-
.pc-content_theme_light .pc-content__list .yfm *,
|
|
130
122
|
.pc-content_theme_light .pc-content__links a {
|
|
131
123
|
color: var(--g-color-text-dark-primary);
|
|
132
124
|
}
|
|
@@ -141,13 +133,11 @@ unpredictable css rules order in build */
|
|
|
141
133
|
.pc-content_theme_light .pc-content__notice .yfm a:hover {
|
|
142
134
|
color: var(--g-color-text-dark-primary);
|
|
143
135
|
}
|
|
144
|
-
.pc-content_theme_light .pc-content__text .yfm a
|
|
145
|
-
.pc-content_theme_light .pc-content__list .yfm a {
|
|
136
|
+
.pc-content_theme_light .pc-content__text .yfm a {
|
|
146
137
|
color: var(--g-color-text-dark-primary);
|
|
147
138
|
text-decoration: underline;
|
|
148
139
|
}
|
|
149
|
-
.pc-content_theme_light .pc-content__text .yfm a:hover
|
|
150
|
-
.pc-content_theme_light .pc-content__list .yfm a:hover {
|
|
140
|
+
.pc-content_theme_light .pc-content__text .yfm a:hover {
|
|
151
141
|
color: var(--g-color-text-dark-secondary);
|
|
152
142
|
}
|
|
153
143
|
.pc-content_theme_light .pc-content__title a {
|
|
@@ -29,7 +29,7 @@ const Content = (props) => {
|
|
|
29
29
|
text && (React.createElement("div", { className: b('text', { ['without-title']: !hasTitle }) },
|
|
30
30
|
React.createElement(YFMWrapper, { content: text, modifiers: { constructor: true, [`constructor-size-${size}`]: true }, id: textId }))),
|
|
31
31
|
(list === null || list === void 0 ? void 0 : list.length) ? (React.createElement("div", { className: b('list') },
|
|
32
|
-
React.createElement(ContentList, { list: list, size: size, qa: qaAttributes.list }))) : null,
|
|
32
|
+
React.createElement(ContentList, { list: list, size: size, qa: qaAttributes.list, theme: theme }))) : null,
|
|
33
33
|
additionalInfo && (React.createElement("div", { className: b('notice') },
|
|
34
34
|
React.createElement(YFMWrapper, { content: additionalInfo, modifiers: {
|
|
35
35
|
constructor: true,
|
|
@@ -4,6 +4,7 @@ import { useUniqId } from '@gravity-ui/uikit';
|
|
|
4
4
|
import { FullscreenMedia, IconWrapper, Media, MetaInfo } from '../../components';
|
|
5
5
|
import { useTheme } from '../../context/theme';
|
|
6
6
|
import { block, getThemedValue } from '../../utils';
|
|
7
|
+
import { mergeVideoMicrodata, sanitizeMicrodata } from '../../utils/microdata';
|
|
7
8
|
import Content from '../Content/Content';
|
|
8
9
|
import { getLayoutItemLinks, hasFullscreen, showFullscreenIcon } from './utils';
|
|
9
10
|
import './LayoutItem.css';
|
|
@@ -17,13 +18,20 @@ const LayoutItem = (_a) => {
|
|
|
17
18
|
const contentProps = Object.assign(Object.assign({ controlPosition: areControlsInFooter ? 'bottom' : 'default' }, content), { links: normalizedLinks, size: 's', colSizes: { all: 12, md: 12 } });
|
|
18
19
|
const titleId = useUniqId();
|
|
19
20
|
const renderMedia = () => {
|
|
21
|
+
var _a;
|
|
20
22
|
if (!media) {
|
|
21
23
|
return null;
|
|
22
24
|
}
|
|
23
25
|
const themedMedia = getThemedValue(media, theme);
|
|
26
|
+
const mediaWithMicrodata = mergeVideoMicrodata(themedMedia, {
|
|
27
|
+
name: typeof content.title === 'string'
|
|
28
|
+
? sanitizeMicrodata(content.title)
|
|
29
|
+
: sanitizeMicrodata(((_a = content.title) === null || _a === void 0 ? void 0 : _a.text) || ''),
|
|
30
|
+
description: content.text ? sanitizeMicrodata(content.text) : undefined,
|
|
31
|
+
});
|
|
24
32
|
return fullscreen && hasFullscreen(themedMedia) ? (React.createElement(FullscreenMedia, { showFullscreenIcon: showFullscreenIcon(themedMedia) }, (_a = {}) => {
|
|
25
33
|
var { className: mediaClassName, fullscreen: _fullscreen } = _a, fullscreenMediaProps = __rest(_a, ["className", "fullscreen"]);
|
|
26
|
-
return (React.createElement(Media, Object.assign({},
|
|
34
|
+
return (React.createElement(Media, Object.assign({}, mediaWithMicrodata, fullscreenMediaProps, { className: b('media', { border }, mediaClassName), analyticsEvents: analyticsEvents })));
|
|
27
35
|
})) : (React.createElement(Media, Object.assign({}, themedMedia, { className: b('media', { border }), analyticsEvents: analyticsEvents })));
|
|
28
36
|
};
|
|
29
37
|
return (React.createElement("div", { className: b(null, className) },
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import sanitize from 'sanitize-html';
|
|
2
|
+
export const mergeVideoMicrodata = (values = {}, newValues = {}) => (Object.assign(Object.assign({}, values), { videoMicrodata: Object.assign(Object.assign({}, newValues), (values.videoMicrodata || {})) }));
|
|
3
|
+
export function sanitizeMicrodata(html) {
|
|
4
|
+
return html && sanitize(html, { allowedTags: [], allowedAttributes: {} });
|
|
5
|
+
}
|
package/package.json
CHANGED
|
@@ -207,6 +207,14 @@ export interface MediaComponentIframeProps {
|
|
|
207
207
|
}
|
|
208
208
|
export interface MediaProps extends Animatable, Partial<MediaComponentDataLensProps>, Partial<MediaComponentYoutubeProps>, Partial<MediaComponentVideoIframeProps>, Partial<MediaComponentImageProps>, Partial<MediaComponentIframeProps>, Partial<MediaComponentVideoProps> {
|
|
209
209
|
color?: string;
|
|
210
|
+
videoMicrodata?: {
|
|
211
|
+
name?: string;
|
|
212
|
+
description?: string;
|
|
213
|
+
duration?: string;
|
|
214
|
+
uploadDate?: string;
|
|
215
|
+
contentUrl?: string;
|
|
216
|
+
thumbnailUrl?: string;
|
|
217
|
+
};
|
|
210
218
|
}
|
|
211
219
|
export interface BackgroundMediaProps extends MediaProps, Animatable, QAProps {
|
|
212
220
|
fullWidthMedia?: boolean;
|