@gravity-ui/page-constructor 4.11.1 → 4.13.0
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/Icons/Icons.js +6 -1
- package/build/cjs/blocks/Icons/schema.d.ts +162 -0
- package/build/cjs/blocks/Icons/schema.js +11 -0
- package/build/cjs/components/BackgroundImage/BackgroundImage.d.ts +1 -0
- package/build/cjs/components/BackgroundImage/BackgroundImage.js +5 -2
- package/build/cjs/components/BackgroundMedia/BackgroundMedia.d.ts +1 -1
- package/build/cjs/components/BackgroundMedia/BackgroundMedia.js +4 -3
- package/build/cjs/components/Image/Image.js +7 -5
- package/build/cjs/components/Media/Image/Image.d.ts +3 -2
- package/build/cjs/components/Media/Image/Image.js +8 -5
- package/build/cjs/components/Media/Media.d.ts +2 -2
- package/build/cjs/components/Media/Media.js +9 -6
- package/build/cjs/components/Media/Video/Video.d.ts +2 -2
- package/build/cjs/components/Media/Video/Video.js +13 -4
- package/build/cjs/models/constructor-items/blocks.d.ts +7 -5
- package/build/cjs/models/constructor-items/common.d.ts +1 -1
- package/build/cjs/text-transform/common.d.ts +7 -2
- package/build/cjs/text-transform/common.js +8 -2
- package/build/cjs/text-transform/transformers.d.ts +2 -0
- package/build/cjs/text-transform/transformers.js +11 -8
- package/build/cjs/utils/blocks.d.ts +1 -1
- package/build/cjs/utils/blocks.js +4 -3
- package/build/esm/blocks/Icons/Icons.js +7 -2
- package/build/esm/blocks/Icons/schema.d.ts +162 -0
- package/build/esm/blocks/Icons/schema.js +11 -0
- package/build/esm/components/BackgroundImage/BackgroundImage.d.ts +1 -0
- package/build/esm/components/BackgroundImage/BackgroundImage.js +5 -3
- package/build/esm/components/BackgroundMedia/BackgroundMedia.d.ts +1 -1
- package/build/esm/components/BackgroundMedia/BackgroundMedia.js +5 -4
- package/build/esm/components/Image/Image.js +7 -5
- package/build/esm/components/Media/Image/Image.d.ts +3 -2
- package/build/esm/components/Media/Image/Image.js +8 -6
- package/build/esm/components/Media/Media.d.ts +2 -2
- package/build/esm/components/Media/Media.js +10 -7
- package/build/esm/components/Media/Video/Video.d.ts +2 -2
- package/build/esm/components/Media/Video/Video.js +14 -5
- package/build/esm/models/constructor-items/blocks.d.ts +7 -5
- package/build/esm/models/constructor-items/common.d.ts +1 -1
- package/build/esm/text-transform/common.d.ts +7 -2
- package/build/esm/text-transform/common.js +7 -2
- package/build/esm/text-transform/transformers.d.ts +2 -0
- package/build/esm/text-transform/transformers.js +11 -8
- package/build/esm/utils/blocks.d.ts +1 -1
- package/build/esm/utils/blocks.js +5 -4
- package/package.json +1 -1
- package/server/models/constructor-items/blocks.d.ts +7 -5
- package/server/models/constructor-items/common.d.ts +1 -1
- package/server/text-transform/common.d.ts +7 -2
- package/server/text-transform/common.js +10 -2
- package/server/text-transform/transformers.d.ts +2 -0
- package/server/text-transform/transformers.js +11 -8
- package/server/utils/blocks.d.ts +1 -1
- package/server/utils/blocks.js +4 -3
- package/widget/index.js +1 -1
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
/* eslint-disable no-param-reassign */
|
|
2
|
-
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
3
1
|
import _ from 'lodash';
|
|
4
2
|
import { config } from './config';
|
|
5
3
|
import { filterContent } from './filter';
|
|
6
|
-
function transformBlocks(blocks, lang, customConfig = {}) {
|
|
4
|
+
function transformBlocks(blocks, lang, customConfig = {}, options = {}) {
|
|
7
5
|
const fullConfig = Object.assign(Object.assign({}, config), customConfig);
|
|
6
|
+
const { plugins = [] } = options;
|
|
8
7
|
const clonedBlocks = _.cloneDeep(blocks);
|
|
9
|
-
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block));
|
|
8
|
+
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block, plugins));
|
|
10
9
|
}
|
|
11
|
-
function transformBlock(lang, blocksConfig, block) {
|
|
10
|
+
function transformBlock(lang, blocksConfig, block, plugins) {
|
|
12
11
|
const blockConfig = blocksConfig[block.type];
|
|
13
12
|
if (block) {
|
|
14
13
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
@@ -19,7 +18,9 @@ function transformBlock(lang, blocksConfig, block) {
|
|
|
19
18
|
const configs = Array.isArray(blockConfig) ? blockConfig : [blockConfig];
|
|
20
19
|
configs.forEach((transformConfig) => {
|
|
21
20
|
const { fields, transformer: transformerRaw, parser } = transformConfig;
|
|
22
|
-
const transformer =
|
|
21
|
+
const transformer = (content) =>
|
|
22
|
+
// eslint-disable-next-line no-useless-call
|
|
23
|
+
transformerRaw.call(null, lang, content, { plugins });
|
|
23
24
|
if (fields) {
|
|
24
25
|
fields.forEach((field) => {
|
|
25
26
|
if (block[field]) {
|
|
@@ -43,9 +44,11 @@ function transformBlock(lang, blocksConfig, block) {
|
|
|
43
44
|
return block;
|
|
44
45
|
}
|
|
45
46
|
export const contentTransformer = ({ content, options }) => {
|
|
46
|
-
const { lang, customConfig = {}, vars } = options;
|
|
47
|
+
const { lang, customConfig = {}, vars, plugins = [] } = options;
|
|
47
48
|
const { blocks = [] } = (vars ? filterContent(content, vars) : content);
|
|
48
|
-
const transformedBlocks = transformBlocks(blocks, lang, customConfig
|
|
49
|
+
const transformedBlocks = transformBlocks(blocks, lang, customConfig, {
|
|
50
|
+
plugins,
|
|
51
|
+
});
|
|
49
52
|
return {
|
|
50
53
|
blocks: transformedBlocks,
|
|
51
54
|
};
|
|
@@ -7,4 +7,4 @@ export declare const getCustomTypes: (types: (keyof CustomConfig)[], customBlock
|
|
|
7
7
|
export declare const getOrderedBlocks: (blocks: ConstructorBlock[], headerBlockTypes?: string[]) => ConstructorBlock[];
|
|
8
8
|
export declare const getHeaderBlock: (blocks: ConstructorBlock[], headerBlockTypes?: string[]) => ConstructorBlock | undefined;
|
|
9
9
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
10
|
-
export declare const getQaAttrubutes: (qa?: string, customKeys
|
|
10
|
+
export declare const getQaAttrubutes: (qa?: string, ...customKeys: (string | Array<string>)[]) => Record<string, string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { camelCase } from 'lodash';
|
|
1
|
+
import { camelCase, flatten } from 'lodash';
|
|
2
2
|
import { PCShareSocialNetwork } from '../models';
|
|
3
3
|
const BLOCK_ELEMENTS = [
|
|
4
4
|
'div',
|
|
@@ -37,7 +37,7 @@ const BLOCK_ELEMENTS = [
|
|
|
37
37
|
'td',
|
|
38
38
|
];
|
|
39
39
|
const BLOCK_ELEMENTS_REGEX = `<(${BLOCK_ELEMENTS.join('|')})[^>]*>`;
|
|
40
|
-
const QA_ATTRIBUTES_KEYS = ['container', 'content', 'wrapper', 'image', 'button'];
|
|
40
|
+
const QA_ATTRIBUTES_KEYS = ['container', 'content', 'wrapper', 'image', 'button', 'animate'];
|
|
41
41
|
export function getHeaderTag(size) {
|
|
42
42
|
switch (size) {
|
|
43
43
|
case 'l':
|
|
@@ -111,13 +111,14 @@ export const getShareLink = (url, type, title, text) => {
|
|
|
111
111
|
return undefined;
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
|
-
export const getQaAttrubutes = (qa, customKeys
|
|
114
|
+
export const getQaAttrubutes = (qa, ...customKeys) => {
|
|
115
115
|
const attributes = {};
|
|
116
116
|
if (qa) {
|
|
117
|
-
const keys = QA_ATTRIBUTES_KEYS.concat(customKeys);
|
|
117
|
+
const keys = QA_ATTRIBUTES_KEYS.concat(flatten(customKeys));
|
|
118
118
|
keys.forEach((key) => {
|
|
119
119
|
attributes[camelCase(key)] = `${qa}-${key}`;
|
|
120
120
|
});
|
|
121
|
+
attributes.default = qa;
|
|
121
122
|
}
|
|
122
123
|
return attributes;
|
|
123
124
|
};
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ButtonSize } from '@gravity-ui/uikit';
|
|
3
3
|
import { GridColumnSize, GridColumnSizesType } from '../../grid/types';
|
|
4
4
|
import { ThemeSupporting } from '../../utils';
|
|
5
|
+
import { AnalyticsEventsBase } from '../common';
|
|
5
6
|
import { AnchorProps, Animatable, BackgroundImageProps, ButtonProps, ContentSize, ContentTextSize, ContentTheme, FileLinkProps, HeaderBreadCrumbsProps, HeaderImageSize, HeaderOffset, HeaderWidth, ImageDeviceProps, Justify, LegendTableMarkerType, LinkProps, MapProps, MediaDirection, MediaProps, TextSize, TextTheme, ThemedImage, ThemedMediaProps, ThemedMediaVideoProps, TitleItemBaseProps, TitleItemProps } from './common';
|
|
6
7
|
import { BannerCardProps, SubBlock, SubBlockModels } from './sub-blocks';
|
|
7
8
|
export declare enum BlockType {
|
|
@@ -241,14 +242,15 @@ export interface FilterBlockProps extends Animatable, LoadableChildren {
|
|
|
241
242
|
colSizes?: GridColumnSizesType;
|
|
242
243
|
centered?: boolean;
|
|
243
244
|
}
|
|
245
|
+
export interface IconsBlockItemProps extends AnalyticsEventsBase {
|
|
246
|
+
url: string;
|
|
247
|
+
text: string;
|
|
248
|
+
src: string;
|
|
249
|
+
}
|
|
244
250
|
export interface IconsBlockProps {
|
|
245
251
|
title?: string;
|
|
246
252
|
size?: 's' | 'm' | 'l';
|
|
247
|
-
items:
|
|
248
|
-
url: string;
|
|
249
|
-
text: string;
|
|
250
|
-
src: string;
|
|
251
|
-
}[];
|
|
253
|
+
items: IconsBlockItemProps[];
|
|
252
254
|
}
|
|
253
255
|
interface ContentLayoutBlockParams {
|
|
254
256
|
size?: ContentSize;
|
|
@@ -186,7 +186,7 @@ export interface MediaComponentDataLensProps {
|
|
|
186
186
|
export interface MediaProps extends Animatable, Partial<MediaComponentDataLensProps>, Partial<MediaComponentYoutubeProps>, Partial<MediaComponentImageProps>, Partial<MediaComponentVideoProps> {
|
|
187
187
|
color?: string;
|
|
188
188
|
}
|
|
189
|
-
export interface BackgroundMediaProps extends MediaProps, Animatable {
|
|
189
|
+
export interface BackgroundMediaProps extends MediaProps, Animatable, QAProps {
|
|
190
190
|
fullWidthMedia?: boolean;
|
|
191
191
|
className?: string;
|
|
192
192
|
mediaClassName?: string;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
|
|
1
2
|
import { Lang } from '../utils/configure';
|
|
2
3
|
export type ComplexItem = {
|
|
3
4
|
[key: string]: string;
|
|
4
5
|
};
|
|
5
6
|
export type Item = string | null | ComplexItem;
|
|
6
7
|
export type Transformer = (text: string) => string;
|
|
7
|
-
export type TransformerRaw = (lang: Lang, content: string
|
|
8
|
+
export type TransformerRaw = (lang: Lang, content: string, options: {
|
|
9
|
+
plugins: MarkdownItPluginCb[];
|
|
10
|
+
}) => string;
|
|
8
11
|
export type Parser<T = any> = (transformer: Transformer, block: T) => T;
|
|
9
12
|
export declare const createItemsParser: (fields: string[]) => (transformer: Transformer, items: Item[]) => (string | {
|
|
10
13
|
[x: string]: string;
|
|
11
14
|
} | null)[];
|
|
12
|
-
export declare function yfmTransformer(lang: Lang, content: string
|
|
15
|
+
export declare function yfmTransformer(lang: Lang, content: string, options?: {
|
|
16
|
+
plugins?: MarkdownItPluginCb[];
|
|
17
|
+
}): string;
|
|
13
18
|
export declare function typografTransformer(lang: Lang, content: string): string;
|
|
@@ -1,6 +1,10 @@
|
|
|
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.typografTransformer = exports.yfmTransformer = exports.createItemsParser = void 0;
|
|
7
|
+
const plugins_1 = __importDefault(require("@doc-tools/transform/lib/plugins"));
|
|
4
8
|
const utils_1 = require("./utils");
|
|
5
9
|
const createItemsParser = (fields) => (transformer, items) => items.map((item) => {
|
|
6
10
|
if (!item) {
|
|
@@ -20,8 +24,12 @@ const createItemsParser = (fields) => (transformer, items) => items.map((item) =
|
|
|
20
24
|
}
|
|
21
25
|
});
|
|
22
26
|
exports.createItemsParser = createItemsParser;
|
|
23
|
-
function yfmTransformer(lang, content) {
|
|
24
|
-
const {
|
|
27
|
+
function yfmTransformer(lang, content, options = {}) {
|
|
28
|
+
const { plugins = [] } = options;
|
|
29
|
+
const { html } = (0, utils_1.fullTransform)(content, {
|
|
30
|
+
lang,
|
|
31
|
+
plugins: [...plugins_1.default, ...plugins],
|
|
32
|
+
});
|
|
25
33
|
return html;
|
|
26
34
|
}
|
|
27
35
|
exports.yfmTransformer = yfmTransformer;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
|
|
1
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
2
3
|
import { Lang } from '../utils/configure';
|
|
3
4
|
export type ContentVariables = Record<string, string>;
|
|
@@ -9,6 +10,7 @@ export type ContentTransformerProps = {
|
|
|
9
10
|
lang: Lang;
|
|
10
11
|
customConfig?: {};
|
|
11
12
|
vars?: ContentVariables;
|
|
13
|
+
plugins?: MarkdownItPluginCb[];
|
|
12
14
|
};
|
|
13
15
|
};
|
|
14
16
|
export declare const contentTransformer: ({ content, options }: ContentTransformerProps) => {
|
|
@@ -4,17 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.contentTransformer = void 0;
|
|
7
|
-
/* eslint-disable no-param-reassign */
|
|
8
|
-
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
9
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
8
|
const config_1 = require("./config");
|
|
11
9
|
const filter_1 = require("./filter");
|
|
12
|
-
function transformBlocks(blocks, lang, customConfig = {}) {
|
|
10
|
+
function transformBlocks(blocks, lang, customConfig = {}, options = {}) {
|
|
13
11
|
const fullConfig = Object.assign(Object.assign({}, config_1.config), customConfig);
|
|
12
|
+
const { plugins = [] } = options;
|
|
14
13
|
const clonedBlocks = lodash_1.default.cloneDeep(blocks);
|
|
15
|
-
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block));
|
|
14
|
+
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block, plugins));
|
|
16
15
|
}
|
|
17
|
-
function transformBlock(lang, blocksConfig, block) {
|
|
16
|
+
function transformBlock(lang, blocksConfig, block, plugins) {
|
|
18
17
|
const blockConfig = blocksConfig[block.type];
|
|
19
18
|
if (block) {
|
|
20
19
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
@@ -25,7 +24,9 @@ function transformBlock(lang, blocksConfig, block) {
|
|
|
25
24
|
const configs = Array.isArray(blockConfig) ? blockConfig : [blockConfig];
|
|
26
25
|
configs.forEach((transformConfig) => {
|
|
27
26
|
const { fields, transformer: transformerRaw, parser } = transformConfig;
|
|
28
|
-
const transformer =
|
|
27
|
+
const transformer = (content) =>
|
|
28
|
+
// eslint-disable-next-line no-useless-call
|
|
29
|
+
transformerRaw.call(null, lang, content, { plugins });
|
|
29
30
|
if (fields) {
|
|
30
31
|
fields.forEach((field) => {
|
|
31
32
|
if (block[field]) {
|
|
@@ -49,9 +50,11 @@ function transformBlock(lang, blocksConfig, block) {
|
|
|
49
50
|
return block;
|
|
50
51
|
}
|
|
51
52
|
const contentTransformer = ({ content, options }) => {
|
|
52
|
-
const { lang, customConfig = {}, vars } = options;
|
|
53
|
+
const { lang, customConfig = {}, vars, plugins = [] } = options;
|
|
53
54
|
const { blocks = [] } = (vars ? (0, filter_1.filterContent)(content, vars) : content);
|
|
54
|
-
const transformedBlocks = transformBlocks(blocks, lang, customConfig
|
|
55
|
+
const transformedBlocks = transformBlocks(blocks, lang, customConfig, {
|
|
56
|
+
plugins,
|
|
57
|
+
});
|
|
55
58
|
return {
|
|
56
59
|
blocks: transformedBlocks,
|
|
57
60
|
};
|
package/server/utils/blocks.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export declare const getCustomTypes: (types: (keyof CustomConfig)[], customBlock
|
|
|
7
7
|
export declare const getOrderedBlocks: (blocks: ConstructorBlock[], headerBlockTypes?: string[]) => ConstructorBlock[];
|
|
8
8
|
export declare const getHeaderBlock: (blocks: ConstructorBlock[], headerBlockTypes?: string[]) => ConstructorBlock | undefined;
|
|
9
9
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
10
|
-
export declare const getQaAttrubutes: (qa?: string, customKeys
|
|
10
|
+
export declare const getQaAttrubutes: (qa?: string, ...customKeys: (string | Array<string>)[]) => Record<string, string>;
|
package/server/utils/blocks.js
CHANGED
|
@@ -40,7 +40,7 @@ const BLOCK_ELEMENTS = [
|
|
|
40
40
|
'td',
|
|
41
41
|
];
|
|
42
42
|
const BLOCK_ELEMENTS_REGEX = `<(${BLOCK_ELEMENTS.join('|')})[^>]*>`;
|
|
43
|
-
const QA_ATTRIBUTES_KEYS = ['container', 'content', 'wrapper', 'image', 'button'];
|
|
43
|
+
const QA_ATTRIBUTES_KEYS = ['container', 'content', 'wrapper', 'image', 'button', 'animate'];
|
|
44
44
|
function getHeaderTag(size) {
|
|
45
45
|
switch (size) {
|
|
46
46
|
case 'l':
|
|
@@ -122,13 +122,14 @@ const getShareLink = (url, type, title, text) => {
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
exports.getShareLink = getShareLink;
|
|
125
|
-
const getQaAttrubutes = (qa, customKeys
|
|
125
|
+
const getQaAttrubutes = (qa, ...customKeys) => {
|
|
126
126
|
const attributes = {};
|
|
127
127
|
if (qa) {
|
|
128
|
-
const keys = QA_ATTRIBUTES_KEYS.concat(customKeys);
|
|
128
|
+
const keys = QA_ATTRIBUTES_KEYS.concat((0, lodash_1.flatten)(customKeys));
|
|
129
129
|
keys.forEach((key) => {
|
|
130
130
|
attributes[(0, lodash_1.camelCase)(key)] = `${qa}-${key}`;
|
|
131
131
|
});
|
|
132
|
+
attributes.default = qa;
|
|
132
133
|
}
|
|
133
134
|
return attributes;
|
|
134
135
|
};
|