@gravity-ui/page-constructor 4.9.1-alpha.0 → 4.10.1-alpha.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/CardLayout/CardLayout.d.ts +2 -2
- package/build/cjs/blocks/CardLayout/CardLayout.js +1 -1
- package/build/cjs/blocks/HeaderSlider/HeaderSlider.css +3 -0
- package/build/cjs/blocks/Slider/Slider.css +3 -1
- package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.css +38 -0
- package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +3 -2
- package/build/cjs/models/constructor-items/blocks.d.ts +1 -0
- package/build/cjs/models/constructor.d.ts +6 -1
- package/build/cjs/text-transform/common.d.ts +2 -3
- package/build/cjs/text-transform/common.js +2 -7
- package/build/cjs/text-transform/transformers.d.ts +0 -2
- package/build/cjs/text-transform/transformers.js +8 -6
- package/build/esm/blocks/CardLayout/CardLayout.d.ts +2 -2
- package/build/esm/blocks/CardLayout/CardLayout.js +1 -1
- package/build/esm/blocks/HeaderSlider/HeaderSlider.css +3 -0
- package/build/esm/blocks/Slider/Slider.css +3 -1
- package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.css +38 -0
- package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts +1 -0
- package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +4 -2
- package/build/esm/models/constructor-items/blocks.d.ts +1 -0
- package/build/esm/models/constructor.d.ts +6 -1
- package/build/esm/text-transform/common.d.ts +2 -3
- package/build/esm/text-transform/common.js +2 -6
- package/build/esm/text-transform/transformers.d.ts +0 -2
- package/build/esm/text-transform/transformers.js +8 -6
- package/package.json +1 -1
- package/server/models/constructor-items/blocks.d.ts +1 -0
- package/server/models/constructor.d.ts +6 -1
- package/server/text-transform/common.d.ts +2 -3
- package/server/text-transform/common.js +2 -9
- package/server/text-transform/transformers.d.ts +0 -2
- package/server/text-transform/transformers.js +8 -6
- package/styles/mixins.scss +1 -0
- package/styles/storybook/common.scss +2 -0
- package/widget/index.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CardLayoutBlockProps as CardLayoutBlockParams, WithChildren } from '../../models';
|
|
3
|
-
export type CardLayoutBlockProps = WithChildren<Omit<CardLayoutBlockParams, 'children'
|
|
2
|
+
import { CardLayoutBlockProps as CardLayoutBlockParams, ClassNameProps, WithChildren } from '../../models';
|
|
3
|
+
export type CardLayoutBlockProps = WithChildren<Omit<CardLayoutBlockParams, 'children'>> & ClassNameProps;
|
|
4
4
|
declare const CardLayout: React.FC<CardLayoutBlockProps>;
|
|
5
5
|
export default CardLayout;
|
|
@@ -11,7 +11,7 @@ const DEFAULT_SIZES = {
|
|
|
11
11
|
md: 4,
|
|
12
12
|
};
|
|
13
13
|
const b = (0, utils_1.block)('card-layout-block');
|
|
14
|
-
const CardLayout = ({ title, description, animated, colSizes = DEFAULT_SIZES, children, }) => (react_1.default.createElement(components_1.AnimateBlock, { className: b(), animate: animated },
|
|
14
|
+
const CardLayout = ({ title, description, animated, colSizes = DEFAULT_SIZES, children, className, }) => (react_1.default.createElement(components_1.AnimateBlock, { className: b(null, className), animate: animated },
|
|
15
15
|
(title || description) && react_1.default.createElement(components_1.Title, { title: title, subtitle: description }),
|
|
16
16
|
react_1.default.createElement(grid_1.Row, null, react_1.default.Children.map(children, (child, index) => (react_1.default.createElement(grid_1.Col, { key: index, sizes: colSizes, className: b('item') }, child))))));
|
|
17
17
|
exports.default = CardLayout;
|
|
@@ -46,6 +46,9 @@ unpredictable css rules order in build */
|
|
|
46
46
|
padding-left: 0;
|
|
47
47
|
padding-right: 0;
|
|
48
48
|
}
|
|
49
|
+
.pc-header-slider-block__item-content .pc-header-block__container-fluid {
|
|
50
|
+
padding-left: 24px;
|
|
51
|
+
}
|
|
49
52
|
.pc-header-slider-block .slick-track .slick-slide {
|
|
50
53
|
max-width: 100%;
|
|
51
54
|
}
|
|
@@ -373,7 +373,9 @@ unpredictable css rules order in build */
|
|
|
373
373
|
padding-left: 0;
|
|
374
374
|
}
|
|
375
375
|
.pc-SliderBlock_type_header-card.pc-SliderBlock:not(.pc-SliderBlock_type_header-card_one-slide) .slick-slide {
|
|
376
|
-
padding-right: 0;
|
|
376
|
+
padding-right: 0 !important;
|
|
377
|
+
padding-left: 0 !important;
|
|
378
|
+
/* stylelint-enable declaration-no-important */
|
|
377
379
|
}
|
|
378
380
|
.pc-SliderBlock_type_header-card.pc-SliderBlock:not(.pc-SliderBlock_type_header-card_one-slide) .slick-slide:last-child {
|
|
379
381
|
padding-right: 0;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-constructor-block.pc-constructor-block_indentTop_0 {
|
|
4
|
+
margin-top: 0;
|
|
5
|
+
}
|
|
6
|
+
.pc-constructor-block.pc-constructor-block_indentTop_xs {
|
|
7
|
+
margin-top: 16px;
|
|
8
|
+
}
|
|
9
|
+
.pc-constructor-block.pc-constructor-block_indentTop_s {
|
|
10
|
+
margin-top: 24px;
|
|
11
|
+
}
|
|
12
|
+
.pc-constructor-block.pc-constructor-block_indentTop_m {
|
|
13
|
+
margin-top: 32px;
|
|
14
|
+
}
|
|
15
|
+
.pc-constructor-block.pc-constructor-block_indentTop_l {
|
|
16
|
+
margin-top: 48px;
|
|
17
|
+
}
|
|
18
|
+
.pc-constructor-block.pc-constructor-block_indentTop_xl {
|
|
19
|
+
margin-top: 64px;
|
|
20
|
+
}
|
|
21
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_0 {
|
|
22
|
+
padding-bottom: 0;
|
|
23
|
+
}
|
|
24
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_xs {
|
|
25
|
+
padding-bottom: 16px;
|
|
26
|
+
}
|
|
27
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_s {
|
|
28
|
+
padding-bottom: 24px;
|
|
29
|
+
}
|
|
30
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_m {
|
|
31
|
+
padding-bottom: 32px;
|
|
32
|
+
}
|
|
33
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_l {
|
|
34
|
+
padding-bottom: 48px;
|
|
35
|
+
}
|
|
36
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_xl {
|
|
37
|
+
padding-bottom: 64px;
|
|
38
|
+
}
|
package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js
CHANGED
|
@@ -9,9 +9,10 @@ const BlockDecoration_1 = require("../../../../customization/BlockDecoration");
|
|
|
9
9
|
const utils_1 = require("../../../../utils");
|
|
10
10
|
const b = (0, utils_1.block)('constructor-block');
|
|
11
11
|
const ConstructorBlock = ({ index = 0, data, children, }) => {
|
|
12
|
-
const { type } = data;
|
|
12
|
+
const { type, indent } = data;
|
|
13
13
|
const blockBaseProps = (0, react_1.useMemo)(() => lodash_1.default.pick(data, ['anchor', 'visible', 'resetPaddings']), [data]);
|
|
14
|
+
const { top, bottom } = indent || { top: 'l', bottom: 'l' };
|
|
14
15
|
return (react_1.default.createElement(BlockDecoration_1.BlockDecoration, Object.assign({ type: type, index: index }, blockBaseProps),
|
|
15
|
-
react_1.default.createElement(BlockBase_1.default, Object.assign({ className: b({ type }) }, blockBaseProps), children)));
|
|
16
|
+
react_1.default.createElement(BlockBase_1.default, Object.assign({ className: b({ type, indentTop: top, indentBottom: bottom }) }, blockBaseProps), children)));
|
|
16
17
|
};
|
|
17
18
|
exports.ConstructorBlock = ConstructorBlock;
|
|
@@ -6,7 +6,12 @@ export interface PageData {
|
|
|
6
6
|
export interface Menu {
|
|
7
7
|
title: string;
|
|
8
8
|
}
|
|
9
|
-
export type ConstructorBlock = ConstructorItem | CustomBlock
|
|
9
|
+
export type ConstructorBlock = (ConstructorItem | CustomBlock) & {
|
|
10
|
+
indent?: {
|
|
11
|
+
top?: string;
|
|
12
|
+
bottom?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
10
15
|
export interface PageContent extends Animatable {
|
|
11
16
|
blocks: ConstructorBlock[];
|
|
12
17
|
menu?: Menu;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
|
|
2
1
|
import { Lang } from '../utils/configure';
|
|
3
2
|
export type ComplexItem = {
|
|
4
3
|
[key: string]: string;
|
|
5
4
|
};
|
|
6
5
|
export type Item = string | null | ComplexItem;
|
|
7
6
|
export type Transformer = (text: string) => string;
|
|
8
|
-
export type TransformerRaw = (lang: Lang, content: string
|
|
7
|
+
export type TransformerRaw = (lang: Lang, content: string) => string;
|
|
9
8
|
export type Parser<T = any> = (transformer: Transformer, block: T) => T;
|
|
10
9
|
export declare const createItemsParser: (fields: string[]) => (transformer: Transformer, items: Item[]) => (string | {
|
|
11
10
|
[x: string]: string;
|
|
12
11
|
} | null)[];
|
|
13
|
-
export declare function yfmTransformer(lang: Lang, content: string
|
|
12
|
+
export declare function yfmTransformer(lang: Lang, content: string): string;
|
|
14
13
|
export declare function typografTransformer(lang: Lang, content: string): string;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.typografTransformer = exports.yfmTransformer = exports.createItemsParser = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const plugins_1 = tslib_1.__importDefault(require("@doc-tools/transform/lib/plugins"));
|
|
6
4
|
const utils_1 = require("./utils");
|
|
7
5
|
const createItemsParser = (fields) => (transformer, items) => items.map((item) => {
|
|
8
6
|
if (!item) {
|
|
@@ -22,11 +20,8 @@ const createItemsParser = (fields) => (transformer, items) => items.map((item) =
|
|
|
22
20
|
}
|
|
23
21
|
});
|
|
24
22
|
exports.createItemsParser = createItemsParser;
|
|
25
|
-
function yfmTransformer(lang, content
|
|
26
|
-
const { html } = (0, utils_1.fullTransform)(content, {
|
|
27
|
-
lang,
|
|
28
|
-
plugins: [...plugins_1.default, ...additionalPlugins],
|
|
29
|
-
});
|
|
23
|
+
function yfmTransformer(lang, content) {
|
|
24
|
+
const { html } = (0, utils_1.fullTransform)(content, { lang });
|
|
30
25
|
return html;
|
|
31
26
|
}
|
|
32
27
|
exports.yfmTransformer = yfmTransformer;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
|
|
2
1
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
2
|
import { Lang } from '../utils/configure';
|
|
4
3
|
export type ContentVariables = Record<string, string>;
|
|
@@ -10,7 +9,6 @@ export type ContentTransformerProps = {
|
|
|
10
9
|
lang: Lang;
|
|
11
10
|
customConfig?: {};
|
|
12
11
|
vars?: ContentVariables;
|
|
13
|
-
additionalPlugins?: MarkdownItPluginCb[];
|
|
14
12
|
};
|
|
15
13
|
};
|
|
16
14
|
export declare const contentTransformer: ({ content, options }: ContentTransformerProps) => {
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contentTransformer = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
/* eslint-disable no-param-reassign */
|
|
6
|
+
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
5
7
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
8
|
const config_1 = require("./config");
|
|
7
9
|
const filter_1 = require("./filter");
|
|
8
|
-
function transformBlocks(blocks, lang, customConfig = {}
|
|
10
|
+
function transformBlocks(blocks, lang, customConfig = {}) {
|
|
9
11
|
const fullConfig = Object.assign(Object.assign({}, config_1.config), customConfig);
|
|
10
12
|
const clonedBlocks = lodash_1.default.cloneDeep(blocks);
|
|
11
|
-
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block
|
|
13
|
+
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block));
|
|
12
14
|
}
|
|
13
|
-
function transformBlock(lang, blocksConfig, block
|
|
15
|
+
function transformBlock(lang, blocksConfig, block) {
|
|
14
16
|
const blockConfig = blocksConfig[block.type];
|
|
15
17
|
if (block) {
|
|
16
18
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
@@ -21,7 +23,7 @@ function transformBlock(lang, blocksConfig, block, additionalPlugins) {
|
|
|
21
23
|
const configs = Array.isArray(blockConfig) ? blockConfig : [blockConfig];
|
|
22
24
|
configs.forEach((transformConfig) => {
|
|
23
25
|
const { fields, transformer: transformerRaw, parser } = transformConfig;
|
|
24
|
-
const transformer =
|
|
26
|
+
const transformer = transformerRaw.bind(null, lang);
|
|
25
27
|
if (fields) {
|
|
26
28
|
fields.forEach((field) => {
|
|
27
29
|
if (block[field]) {
|
|
@@ -45,9 +47,9 @@ function transformBlock(lang, blocksConfig, block, additionalPlugins) {
|
|
|
45
47
|
return block;
|
|
46
48
|
}
|
|
47
49
|
const contentTransformer = ({ content, options }) => {
|
|
48
|
-
const { lang, customConfig = {}, vars
|
|
50
|
+
const { lang, customConfig = {}, vars } = options;
|
|
49
51
|
const { blocks = [] } = (vars ? (0, filter_1.filterContent)(content, vars) : content);
|
|
50
|
-
const transformedBlocks = transformBlocks(blocks, lang, customConfig
|
|
52
|
+
const transformedBlocks = transformBlocks(blocks, lang, customConfig);
|
|
51
53
|
return {
|
|
52
54
|
blocks: transformedBlocks,
|
|
53
55
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CardLayoutBlockProps as CardLayoutBlockParams, WithChildren } from '../../models';
|
|
2
|
+
import { CardLayoutBlockProps as CardLayoutBlockParams, ClassNameProps, WithChildren } from '../../models';
|
|
3
3
|
import './CardLayout.css';
|
|
4
|
-
export type CardLayoutBlockProps = WithChildren<Omit<CardLayoutBlockParams, 'children'
|
|
4
|
+
export type CardLayoutBlockProps = WithChildren<Omit<CardLayoutBlockParams, 'children'>> & ClassNameProps;
|
|
5
5
|
declare const CardLayout: React.FC<CardLayoutBlockProps>;
|
|
6
6
|
export default CardLayout;
|
|
@@ -9,7 +9,7 @@ const DEFAULT_SIZES = {
|
|
|
9
9
|
md: 4,
|
|
10
10
|
};
|
|
11
11
|
const b = block('card-layout-block');
|
|
12
|
-
const CardLayout = ({ title, description, animated, colSizes = DEFAULT_SIZES, children, }) => (React.createElement(AnimateBlock, { className: b(), animate: animated },
|
|
12
|
+
const CardLayout = ({ title, description, animated, colSizes = DEFAULT_SIZES, children, className, }) => (React.createElement(AnimateBlock, { className: b(null, className), animate: animated },
|
|
13
13
|
(title || description) && React.createElement(Title, { title: title, subtitle: description }),
|
|
14
14
|
React.createElement(Row, null, React.Children.map(children, (child, index) => (React.createElement(Col, { key: index, sizes: colSizes, className: b('item') }, child))))));
|
|
15
15
|
export default CardLayout;
|
|
@@ -46,6 +46,9 @@ unpredictable css rules order in build */
|
|
|
46
46
|
padding-left: 0;
|
|
47
47
|
padding-right: 0;
|
|
48
48
|
}
|
|
49
|
+
.pc-header-slider-block__item-content .pc-header-block__container-fluid {
|
|
50
|
+
padding-left: 24px;
|
|
51
|
+
}
|
|
49
52
|
.pc-header-slider-block .slick-track .slick-slide {
|
|
50
53
|
max-width: 100%;
|
|
51
54
|
}
|
|
@@ -373,7 +373,9 @@ unpredictable css rules order in build */
|
|
|
373
373
|
padding-left: 0;
|
|
374
374
|
}
|
|
375
375
|
.pc-SliderBlock_type_header-card.pc-SliderBlock:not(.pc-SliderBlock_type_header-card_one-slide) .slick-slide {
|
|
376
|
-
padding-right: 0;
|
|
376
|
+
padding-right: 0 !important;
|
|
377
|
+
padding-left: 0 !important;
|
|
378
|
+
/* stylelint-enable declaration-no-important */
|
|
377
379
|
}
|
|
378
380
|
.pc-SliderBlock_type_header-card.pc-SliderBlock:not(.pc-SliderBlock_type_header-card_one-slide) .slick-slide:last-child {
|
|
379
381
|
padding-right: 0;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-constructor-block.pc-constructor-block_indentTop_0 {
|
|
4
|
+
margin-top: 0;
|
|
5
|
+
}
|
|
6
|
+
.pc-constructor-block.pc-constructor-block_indentTop_xs {
|
|
7
|
+
margin-top: 16px;
|
|
8
|
+
}
|
|
9
|
+
.pc-constructor-block.pc-constructor-block_indentTop_s {
|
|
10
|
+
margin-top: 24px;
|
|
11
|
+
}
|
|
12
|
+
.pc-constructor-block.pc-constructor-block_indentTop_m {
|
|
13
|
+
margin-top: 32px;
|
|
14
|
+
}
|
|
15
|
+
.pc-constructor-block.pc-constructor-block_indentTop_l {
|
|
16
|
+
margin-top: 48px;
|
|
17
|
+
}
|
|
18
|
+
.pc-constructor-block.pc-constructor-block_indentTop_xl {
|
|
19
|
+
margin-top: 64px;
|
|
20
|
+
}
|
|
21
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_0 {
|
|
22
|
+
padding-bottom: 0;
|
|
23
|
+
}
|
|
24
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_xs {
|
|
25
|
+
padding-bottom: 16px;
|
|
26
|
+
}
|
|
27
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_s {
|
|
28
|
+
padding-bottom: 24px;
|
|
29
|
+
}
|
|
30
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_m {
|
|
31
|
+
padding-bottom: 32px;
|
|
32
|
+
}
|
|
33
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_l {
|
|
34
|
+
padding-bottom: 48px;
|
|
35
|
+
}
|
|
36
|
+
.pc-constructor-block.pc-constructor-block_indentBottom_xl {
|
|
37
|
+
padding-bottom: 64px;
|
|
38
|
+
}
|
package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BlockDecorationProps, ConstructorBlock as ConstructorBlockType, WithChildren } from '../../../../models';
|
|
3
|
+
import './ConstructorBlock.css';
|
|
3
4
|
interface ConstructorBlockProps extends Pick<BlockDecorationProps, 'index'> {
|
|
4
5
|
data: ConstructorBlockType;
|
|
5
6
|
}
|
package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js
CHANGED
|
@@ -3,10 +3,12 @@ import _ from 'lodash';
|
|
|
3
3
|
import BlockBase from '../../../../components/BlockBase/BlockBase';
|
|
4
4
|
import { BlockDecoration } from '../../../../customization/BlockDecoration';
|
|
5
5
|
import { block } from '../../../../utils';
|
|
6
|
+
import './ConstructorBlock.css';
|
|
6
7
|
const b = block('constructor-block');
|
|
7
8
|
export const ConstructorBlock = ({ index = 0, data, children, }) => {
|
|
8
|
-
const { type } = data;
|
|
9
|
+
const { type, indent } = data;
|
|
9
10
|
const blockBaseProps = useMemo(() => _.pick(data, ['anchor', 'visible', 'resetPaddings']), [data]);
|
|
11
|
+
const { top, bottom } = indent || { top: 'l', bottom: 'l' };
|
|
10
12
|
return (React.createElement(BlockDecoration, Object.assign({ type: type, index: index }, blockBaseProps),
|
|
11
|
-
React.createElement(BlockBase, Object.assign({ className: b({ type }) }, blockBaseProps), children)));
|
|
13
|
+
React.createElement(BlockBase, Object.assign({ className: b({ type, indentTop: top, indentBottom: bottom }) }, blockBaseProps), children)));
|
|
12
14
|
};
|
|
@@ -6,7 +6,12 @@ export interface PageData {
|
|
|
6
6
|
export interface Menu {
|
|
7
7
|
title: string;
|
|
8
8
|
}
|
|
9
|
-
export type ConstructorBlock = ConstructorItem | CustomBlock
|
|
9
|
+
export type ConstructorBlock = (ConstructorItem | CustomBlock) & {
|
|
10
|
+
indent?: {
|
|
11
|
+
top?: string;
|
|
12
|
+
bottom?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
10
15
|
export interface PageContent extends Animatable {
|
|
11
16
|
blocks: ConstructorBlock[];
|
|
12
17
|
menu?: Menu;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
|
|
2
1
|
import { Lang } from '../utils/configure';
|
|
3
2
|
export type ComplexItem = {
|
|
4
3
|
[key: string]: string;
|
|
5
4
|
};
|
|
6
5
|
export type Item = string | null | ComplexItem;
|
|
7
6
|
export type Transformer = (text: string) => string;
|
|
8
|
-
export type TransformerRaw = (lang: Lang, content: string
|
|
7
|
+
export type TransformerRaw = (lang: Lang, content: string) => string;
|
|
9
8
|
export type Parser<T = any> = (transformer: Transformer, block: T) => T;
|
|
10
9
|
export declare const createItemsParser: (fields: string[]) => (transformer: Transformer, items: Item[]) => (string | {
|
|
11
10
|
[x: string]: string;
|
|
12
11
|
} | null)[];
|
|
13
|
-
export declare function yfmTransformer(lang: Lang, content: string
|
|
12
|
+
export declare function yfmTransformer(lang: Lang, content: string): string;
|
|
14
13
|
export declare function typografTransformer(lang: Lang, content: string): string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import defaultPlugins from '@doc-tools/transform/lib/plugins';
|
|
2
1
|
import { fullTransform, typografToHTML } from './utils';
|
|
3
2
|
export const createItemsParser = (fields) => (transformer, items) => items.map((item) => {
|
|
4
3
|
if (!item) {
|
|
@@ -17,11 +16,8 @@ export const createItemsParser = (fields) => (transformer, items) => items.map((
|
|
|
17
16
|
}, {}));
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
|
-
export function yfmTransformer(lang, content
|
|
21
|
-
const { html } = fullTransform(content, {
|
|
22
|
-
lang,
|
|
23
|
-
plugins: [...defaultPlugins, ...additionalPlugins],
|
|
24
|
-
});
|
|
19
|
+
export function yfmTransformer(lang, content) {
|
|
20
|
+
const { html } = fullTransform(content, { lang });
|
|
25
21
|
return html;
|
|
26
22
|
}
|
|
27
23
|
export function typografTransformer(lang, content) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
|
|
2
1
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
2
|
import { Lang } from '../utils/configure';
|
|
4
3
|
export type ContentVariables = Record<string, string>;
|
|
@@ -10,7 +9,6 @@ export type ContentTransformerProps = {
|
|
|
10
9
|
lang: Lang;
|
|
11
10
|
customConfig?: {};
|
|
12
11
|
vars?: ContentVariables;
|
|
13
|
-
additionalPlugins?: MarkdownItPluginCb[];
|
|
14
12
|
};
|
|
15
13
|
};
|
|
16
14
|
export declare const contentTransformer: ({ content, options }: ContentTransformerProps) => {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
1
3
|
import _ from 'lodash';
|
|
2
4
|
import { config } from './config';
|
|
3
5
|
import { filterContent } from './filter';
|
|
4
|
-
function transformBlocks(blocks, lang, customConfig = {}
|
|
6
|
+
function transformBlocks(blocks, lang, customConfig = {}) {
|
|
5
7
|
const fullConfig = Object.assign(Object.assign({}, config), customConfig);
|
|
6
8
|
const clonedBlocks = _.cloneDeep(blocks);
|
|
7
|
-
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block
|
|
9
|
+
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block));
|
|
8
10
|
}
|
|
9
|
-
function transformBlock(lang, blocksConfig, block
|
|
11
|
+
function transformBlock(lang, blocksConfig, block) {
|
|
10
12
|
const blockConfig = blocksConfig[block.type];
|
|
11
13
|
if (block) {
|
|
12
14
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
@@ -17,7 +19,7 @@ function transformBlock(lang, blocksConfig, block, additionalPlugins) {
|
|
|
17
19
|
const configs = Array.isArray(blockConfig) ? blockConfig : [blockConfig];
|
|
18
20
|
configs.forEach((transformConfig) => {
|
|
19
21
|
const { fields, transformer: transformerRaw, parser } = transformConfig;
|
|
20
|
-
const transformer =
|
|
22
|
+
const transformer = transformerRaw.bind(null, lang);
|
|
21
23
|
if (fields) {
|
|
22
24
|
fields.forEach((field) => {
|
|
23
25
|
if (block[field]) {
|
|
@@ -41,9 +43,9 @@ function transformBlock(lang, blocksConfig, block, additionalPlugins) {
|
|
|
41
43
|
return block;
|
|
42
44
|
}
|
|
43
45
|
export const contentTransformer = ({ content, options }) => {
|
|
44
|
-
const { lang, customConfig = {}, vars
|
|
46
|
+
const { lang, customConfig = {}, vars } = options;
|
|
45
47
|
const { blocks = [] } = (vars ? filterContent(content, vars) : content);
|
|
46
|
-
const transformedBlocks = transformBlocks(blocks, lang, customConfig
|
|
48
|
+
const transformedBlocks = transformBlocks(blocks, lang, customConfig);
|
|
47
49
|
return {
|
|
48
50
|
blocks: transformedBlocks,
|
|
49
51
|
};
|
package/package.json
CHANGED
|
@@ -6,7 +6,12 @@ export interface PageData {
|
|
|
6
6
|
export interface Menu {
|
|
7
7
|
title: string;
|
|
8
8
|
}
|
|
9
|
-
export type ConstructorBlock = ConstructorItem | CustomBlock
|
|
9
|
+
export type ConstructorBlock = (ConstructorItem | CustomBlock) & {
|
|
10
|
+
indent?: {
|
|
11
|
+
top?: string;
|
|
12
|
+
bottom?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
10
15
|
export interface PageContent extends Animatable {
|
|
11
16
|
blocks: ConstructorBlock[];
|
|
12
17
|
menu?: Menu;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
|
|
2
1
|
import { Lang } from '../utils/configure';
|
|
3
2
|
export type ComplexItem = {
|
|
4
3
|
[key: string]: string;
|
|
5
4
|
};
|
|
6
5
|
export type Item = string | null | ComplexItem;
|
|
7
6
|
export type Transformer = (text: string) => string;
|
|
8
|
-
export type TransformerRaw = (lang: Lang, content: string
|
|
7
|
+
export type TransformerRaw = (lang: Lang, content: string) => string;
|
|
9
8
|
export type Parser<T = any> = (transformer: Transformer, block: T) => T;
|
|
10
9
|
export declare const createItemsParser: (fields: string[]) => (transformer: Transformer, items: Item[]) => (string | {
|
|
11
10
|
[x: string]: string;
|
|
12
11
|
} | null)[];
|
|
13
|
-
export declare function yfmTransformer(lang: Lang, content: string
|
|
12
|
+
export declare function yfmTransformer(lang: Lang, content: string): string;
|
|
14
13
|
export declare function typografTransformer(lang: Lang, content: string): string;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.typografTransformer = exports.yfmTransformer = exports.createItemsParser = void 0;
|
|
7
|
-
const plugins_1 = __importDefault(require("@doc-tools/transform/lib/plugins"));
|
|
8
4
|
const utils_1 = require("./utils");
|
|
9
5
|
const createItemsParser = (fields) => (transformer, items) => items.map((item) => {
|
|
10
6
|
if (!item) {
|
|
@@ -24,11 +20,8 @@ const createItemsParser = (fields) => (transformer, items) => items.map((item) =
|
|
|
24
20
|
}
|
|
25
21
|
});
|
|
26
22
|
exports.createItemsParser = createItemsParser;
|
|
27
|
-
function yfmTransformer(lang, content
|
|
28
|
-
const { html } = (0, utils_1.fullTransform)(content, {
|
|
29
|
-
lang,
|
|
30
|
-
plugins: [...plugins_1.default, ...additionalPlugins],
|
|
31
|
-
});
|
|
23
|
+
function yfmTransformer(lang, content) {
|
|
24
|
+
const { html } = (0, utils_1.fullTransform)(content, { lang });
|
|
32
25
|
return html;
|
|
33
26
|
}
|
|
34
27
|
exports.yfmTransformer = yfmTransformer;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
|
|
2
1
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
2
|
import { Lang } from '../utils/configure';
|
|
4
3
|
export type ContentVariables = Record<string, string>;
|
|
@@ -10,7 +9,6 @@ export type ContentTransformerProps = {
|
|
|
10
9
|
lang: Lang;
|
|
11
10
|
customConfig?: {};
|
|
12
11
|
vars?: ContentVariables;
|
|
13
|
-
additionalPlugins?: MarkdownItPluginCb[];
|
|
14
12
|
};
|
|
15
13
|
};
|
|
16
14
|
export declare const contentTransformer: ({ content, options }: ContentTransformerProps) => {
|
|
@@ -4,15 +4,17 @@ 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 */
|
|
7
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
10
|
const config_1 = require("./config");
|
|
9
11
|
const filter_1 = require("./filter");
|
|
10
|
-
function transformBlocks(blocks, lang, customConfig = {}
|
|
12
|
+
function transformBlocks(blocks, lang, customConfig = {}) {
|
|
11
13
|
const fullConfig = Object.assign(Object.assign({}, config_1.config), customConfig);
|
|
12
14
|
const clonedBlocks = lodash_1.default.cloneDeep(blocks);
|
|
13
|
-
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block
|
|
15
|
+
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block));
|
|
14
16
|
}
|
|
15
|
-
function transformBlock(lang, blocksConfig, block
|
|
17
|
+
function transformBlock(lang, blocksConfig, block) {
|
|
16
18
|
const blockConfig = blocksConfig[block.type];
|
|
17
19
|
if (block) {
|
|
18
20
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
@@ -23,7 +25,7 @@ function transformBlock(lang, blocksConfig, block, additionalPlugins) {
|
|
|
23
25
|
const configs = Array.isArray(blockConfig) ? blockConfig : [blockConfig];
|
|
24
26
|
configs.forEach((transformConfig) => {
|
|
25
27
|
const { fields, transformer: transformerRaw, parser } = transformConfig;
|
|
26
|
-
const transformer =
|
|
28
|
+
const transformer = transformerRaw.bind(null, lang);
|
|
27
29
|
if (fields) {
|
|
28
30
|
fields.forEach((field) => {
|
|
29
31
|
if (block[field]) {
|
|
@@ -47,9 +49,9 @@ function transformBlock(lang, blocksConfig, block, additionalPlugins) {
|
|
|
47
49
|
return block;
|
|
48
50
|
}
|
|
49
51
|
const contentTransformer = ({ content, options }) => {
|
|
50
|
-
const { lang, customConfig = {}, vars
|
|
52
|
+
const { lang, customConfig = {}, vars } = options;
|
|
51
53
|
const { blocks = [] } = (vars ? (0, filter_1.filterContent)(content, vars) : content);
|
|
52
|
-
const transformedBlocks = transformBlocks(blocks, lang, customConfig
|
|
54
|
+
const transformedBlocks = transformBlocks(blocks, lang, customConfig);
|
|
53
55
|
return {
|
|
54
56
|
blocks: transformedBlocks,
|
|
55
57
|
};
|
package/styles/mixins.scss
CHANGED