@gravity-ui/page-constructor 6.0.0-alpha.3 → 6.0.0-alpha.5
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/README.md +4 -0
- package/build/cjs/blocks/Share/Share.js +5 -1
- package/build/cjs/blocks/Slider/schema.d.ts +20 -2
- package/build/cjs/blocks/Slider/schema.js +12 -1
- package/build/cjs/blocks/SliderOld/schema.d.ts +20 -2
- package/build/cjs/blocks/SliderOld/schema.js +12 -1
- package/build/cjs/blocks/Table/Table.css +4 -3
- package/build/cjs/blocks/Table/Table.js +3 -1
- package/build/cjs/components/Title/TitleItem.css +1 -0
- package/build/cjs/models/constructor-items/blocks.d.ts +1 -1
- package/build/cjs/sub-blocks/BannerCard/BannerCard.css +4 -0
- package/build/cjs/sub-blocks/Content/Content.css +27 -25
- package/build/cjs/text-transform/common.d.ts +4 -3
- package/build/cjs/text-transform/common.js +41 -18
- package/build/cjs/text-transform/config.d.ts +5 -2
- package/build/cjs/text-transform/config.js +84 -43
- package/build/cjs/text-transform/transformers.js +2 -2
- package/build/esm/blocks/Share/Share.js +5 -1
- package/build/esm/blocks/Slider/schema.d.ts +20 -2
- package/build/esm/blocks/Slider/schema.js +12 -1
- package/build/esm/blocks/SliderOld/schema.d.ts +20 -2
- package/build/esm/blocks/SliderOld/schema.js +12 -1
- package/build/esm/blocks/Table/Table.css +4 -3
- package/build/esm/blocks/Table/Table.js +4 -2
- package/build/esm/components/Title/TitleItem.css +1 -0
- package/build/esm/models/constructor-items/blocks.d.ts +1 -1
- package/build/esm/sub-blocks/BannerCard/BannerCard.css +4 -0
- package/build/esm/sub-blocks/Content/Content.css +27 -25
- package/build/esm/text-transform/common.d.ts +4 -3
- package/build/esm/text-transform/common.js +41 -18
- package/build/esm/text-transform/config.d.ts +5 -2
- package/build/esm/text-transform/config.js +85 -44
- package/build/esm/text-transform/transformers.js +2 -2
- package/package.json +1 -1
- package/schema/index.js +1 -1
- package/server/models/constructor-items/blocks.d.ts +1 -1
- package/server/text-transform/common.d.ts +4 -3
- package/server/text-transform/common.js +41 -18
- package/server/text-transform/config.d.ts +5 -2
- package/server/text-transform/config.js +84 -43
- package/server/text-transform/transformers.js +2 -2
- package/widget/index.js +1 -1
package/README.md
CHANGED
|
@@ -146,6 +146,10 @@ const post = {
|
|
|
146
146
|
|
|
147
147
|
You can find more utilities in this [section](https://github.com/gravity-ui/page-constructor/tree/main/src/text-transform)
|
|
148
148
|
|
|
149
|
+
### Detailed Documentation on Server Utilities and Transformers
|
|
150
|
+
|
|
151
|
+
For a comprehensive guide on using server utilities, including detailed explanations and advanced use cases, visit the [additional chapter on server utils usage](./docs/data-preparation.md).
|
|
152
|
+
|
|
149
153
|
### Custom blocks
|
|
150
154
|
|
|
151
155
|
The page constructor lets you use blocks that are user-defined in their app. Blocks are regular React components.
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
6
|
+
const components_1 = require("../../components");
|
|
6
7
|
const locationContext_1 = require("../../context/locationContext");
|
|
7
8
|
const hooks_1 = require("../../hooks");
|
|
8
9
|
const Facebook_1 = require("../../icons/Facebook");
|
|
@@ -26,7 +27,10 @@ const Share = ({ items, title }) => {
|
|
|
26
27
|
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ShareButton);
|
|
27
28
|
const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics(), [handleAnalytics]);
|
|
28
29
|
return (react_1.default.createElement("div", { className: b() },
|
|
29
|
-
react_1.default.createElement("h5", { className: b('title') }, title
|
|
30
|
+
react_1.default.createElement("h5", { className: b('title') }, title ? (react_1.default.createElement(components_1.YFMWrapper, { content: title, modifiers: {
|
|
31
|
+
constructor: true,
|
|
32
|
+
// constructorTheme: textTheme,
|
|
33
|
+
} })) : ((0, i18n_1.i18n)('constructor-share'))),
|
|
30
34
|
react_1.default.createElement("div", { className: b('items') }, items.map((type) => {
|
|
31
35
|
const url = (0, utils_1.getAbsolutePath)(hostname, pathname);
|
|
32
36
|
const socialUrl = (0, utils_1.getShareLink)(url, type);
|
|
@@ -69,7 +69,16 @@ export declare const SliderProps: {
|
|
|
69
69
|
type: string;
|
|
70
70
|
patternProperties: {
|
|
71
71
|
'.*': {
|
|
72
|
-
|
|
72
|
+
oneOf: ({
|
|
73
|
+
type: string[];
|
|
74
|
+
additionalProperties?: undefined;
|
|
75
|
+
} | {
|
|
76
|
+
type: string;
|
|
77
|
+
additionalProperties: boolean;
|
|
78
|
+
} | {
|
|
79
|
+
type: string;
|
|
80
|
+
additionalProperties?: undefined;
|
|
81
|
+
})[];
|
|
73
82
|
};
|
|
74
83
|
};
|
|
75
84
|
};
|
|
@@ -193,7 +202,16 @@ export declare const SliderBlock: {
|
|
|
193
202
|
type: string;
|
|
194
203
|
patternProperties: {
|
|
195
204
|
'.*': {
|
|
196
|
-
|
|
205
|
+
oneOf: ({
|
|
206
|
+
type: string[];
|
|
207
|
+
additionalProperties?: undefined;
|
|
208
|
+
} | {
|
|
209
|
+
type: string;
|
|
210
|
+
additionalProperties: boolean;
|
|
211
|
+
} | {
|
|
212
|
+
type: string;
|
|
213
|
+
additionalProperties?: undefined;
|
|
214
|
+
})[];
|
|
197
215
|
};
|
|
198
216
|
};
|
|
199
217
|
};
|
|
@@ -21,7 +21,18 @@ const LoadableProps = {
|
|
|
21
21
|
type: 'object',
|
|
22
22
|
patternProperties: {
|
|
23
23
|
'.*': {
|
|
24
|
-
|
|
24
|
+
oneOf: [
|
|
25
|
+
{
|
|
26
|
+
type: ['string', 'number', 'boolean'],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'object',
|
|
30
|
+
additionalProperties: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'array',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
25
36
|
},
|
|
26
37
|
},
|
|
27
38
|
},
|
|
@@ -60,7 +60,16 @@ export declare const SliderOldProps: {
|
|
|
60
60
|
type: string;
|
|
61
61
|
patternProperties: {
|
|
62
62
|
'.*': {
|
|
63
|
-
|
|
63
|
+
oneOf: ({
|
|
64
|
+
type: string[];
|
|
65
|
+
additionalProperties?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
type: string;
|
|
68
|
+
additionalProperties: boolean;
|
|
69
|
+
} | {
|
|
70
|
+
type: string;
|
|
71
|
+
additionalProperties?: undefined;
|
|
72
|
+
})[];
|
|
64
73
|
};
|
|
65
74
|
};
|
|
66
75
|
};
|
|
@@ -176,7 +185,16 @@ export declare const SliderOldBlock: {
|
|
|
176
185
|
type: string;
|
|
177
186
|
patternProperties: {
|
|
178
187
|
'.*': {
|
|
179
|
-
|
|
188
|
+
oneOf: ({
|
|
189
|
+
type: string[];
|
|
190
|
+
additionalProperties?: undefined;
|
|
191
|
+
} | {
|
|
192
|
+
type: string;
|
|
193
|
+
additionalProperties: boolean;
|
|
194
|
+
} | {
|
|
195
|
+
type: string;
|
|
196
|
+
additionalProperties?: undefined;
|
|
197
|
+
})[];
|
|
180
198
|
};
|
|
181
199
|
};
|
|
182
200
|
};
|
|
@@ -21,7 +21,18 @@ const LoadableProps = {
|
|
|
21
21
|
type: 'object',
|
|
22
22
|
patternProperties: {
|
|
23
23
|
'.*': {
|
|
24
|
-
|
|
24
|
+
oneOf: [
|
|
25
|
+
{
|
|
26
|
+
type: ['string', 'number', 'boolean'],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'object',
|
|
30
|
+
additionalProperties: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'array',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
25
36
|
},
|
|
26
37
|
},
|
|
27
38
|
},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
.pc-table-block__title {
|
|
1
|
+
.pc-table-block__title.pc-table-block__title {
|
|
2
2
|
margin: 0;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
/* use this for style redefinitions to awoid problems with
|
|
6
6
|
unpredictable css rules order in build */
|
|
7
|
-
.pc-table-block__title {
|
|
7
|
+
.pc-table-block__title.pc-table-block__title {
|
|
8
8
|
font-size: var(--g-text-display-2-font-size);
|
|
9
9
|
line-height: var(--g-text-display-2-line-height);
|
|
10
10
|
color: var(--pc-text-header-color);
|
|
@@ -14,11 +14,12 @@ unpredictable css rules order in build */
|
|
|
14
14
|
margin-right: 32px;
|
|
15
15
|
}
|
|
16
16
|
@media (max-width: 576px) {
|
|
17
|
-
.pc-table-block__title {
|
|
17
|
+
.pc-table-block__title.pc-table-block__title {
|
|
18
18
|
font-size: var(--g-text-display-1-font-size);
|
|
19
19
|
line-height: var(--g-text-display-1-line-height);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
|
|
22
23
|
.pc-table-block__table {
|
|
23
24
|
margin-top: 0;
|
|
24
25
|
}
|
|
@@ -13,7 +13,9 @@ const TableBlock = (props) => {
|
|
|
13
13
|
react_1.default.createElement(grid_1.Grid, { className: b('content') },
|
|
14
14
|
react_1.default.createElement(grid_1.Row, { className: b('row') },
|
|
15
15
|
react_1.default.createElement(grid_1.Col, { sizes: { [grid_1.GridColumnSize.Md]: 4, [grid_1.GridColumnSize.All]: 12 } },
|
|
16
|
-
react_1.default.createElement("h2",
|
|
16
|
+
react_1.default.createElement(components_1.YFMWrapper, { tagName: "h2", contentClassName: b('title'), content: title, modifiers: {
|
|
17
|
+
constructor: true,
|
|
18
|
+
} })),
|
|
17
19
|
react_1.default.createElement(grid_1.Col, { sizes: { [grid_1.GridColumnSize.Md]: 8, [grid_1.GridColumnSize.All]: 12 } },
|
|
18
20
|
react_1.default.createElement(components_1.Table, Object.assign({ className: b('table') }, table)))))));
|
|
19
21
|
};
|
|
@@ -50,7 +50,7 @@ export interface LoadableProps {
|
|
|
50
50
|
* @deprecated Will be moved to params
|
|
51
51
|
*/
|
|
52
52
|
serviceId?: number;
|
|
53
|
-
params?: Record<string, string | number | boolean>;
|
|
53
|
+
params?: Record<string, string | number | boolean | object>;
|
|
54
54
|
}
|
|
55
55
|
export interface LoadableChildren {
|
|
56
56
|
loadable?: LoadableProps;
|
|
@@ -16,6 +16,9 @@ unpredictable css rules order in build */
|
|
|
16
16
|
color: var(--g-color-text-light-primary);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
.pc-banner-card__text {
|
|
20
|
+
max-width: 100%;
|
|
21
|
+
}
|
|
19
22
|
.pc-banner-card__title.pc-banner-card__title {
|
|
20
23
|
font-size: var(--g-text-display-2-font-size);
|
|
21
24
|
line-height: var(--g-text-display-2-line-height);
|
|
@@ -57,6 +60,7 @@ unpredictable css rules order in build */
|
|
|
57
60
|
justify-content: space-between;
|
|
58
61
|
flex-direction: column;
|
|
59
62
|
align-items: baseline;
|
|
63
|
+
max-width: 100%;
|
|
60
64
|
}
|
|
61
65
|
.pc-banner-card__subtitle.pc-banner-card__subtitle {
|
|
62
66
|
display: inline-block;
|
|
@@ -81,73 +81,75 @@ unpredictable css rules order in build */
|
|
|
81
81
|
.pc-content_size_l .pc-content__buttons {
|
|
82
82
|
margin-top: 24px;
|
|
83
83
|
}
|
|
84
|
-
.pc-content_theme_dark {
|
|
84
|
+
.pc-content_theme_dark.pc-content_theme_dark {
|
|
85
85
|
--g-color-line-focus: var(--pc-color-line-focus-dark);
|
|
86
86
|
}
|
|
87
|
-
.pc-content_theme_dark .pc-content__title *,
|
|
88
|
-
.pc-content_theme_dark .pc-content__text .yfm,
|
|
89
|
-
.pc-content_theme_dark .pc-content__text .yfm *,
|
|
90
|
-
.pc-content_theme_dark .pc-content__links a {
|
|
87
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__title *,
|
|
88
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__text .yfm,
|
|
89
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__text .yfm *,
|
|
90
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__links a {
|
|
91
91
|
color: var(--g-color-text-light-primary);
|
|
92
92
|
}
|
|
93
|
-
.pc-content_theme_dark .pc-content__notice .yfm,
|
|
94
|
-
.pc-content_theme_dark .pc-content__notice .yfm * {
|
|
93
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__notice .yfm,
|
|
94
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__notice .yfm * {
|
|
95
95
|
color: var(--g-color-text-light-secondary);
|
|
96
96
|
}
|
|
97
|
-
.pc-content_theme_dark .pc-content__notice .yfm a {
|
|
97
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__notice .yfm a {
|
|
98
98
|
color: var(--g-color-text-light-secondary);
|
|
99
99
|
text-decoration: underline;
|
|
100
100
|
}
|
|
101
|
-
.pc-content_theme_dark .pc-content__notice .yfm a:hover {
|
|
101
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__notice .yfm a:hover {
|
|
102
102
|
color: var(--g-color-text-light-primary);
|
|
103
103
|
}
|
|
104
|
-
.pc-content_theme_dark .pc-content__text .yfm a {
|
|
104
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__text .yfm a {
|
|
105
105
|
color: var(--g-color-text-light-primary);
|
|
106
106
|
text-decoration: underline;
|
|
107
107
|
}
|
|
108
|
-
.pc-content_theme_dark .pc-content__text .yfm a:hover {
|
|
108
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__text .yfm a:hover {
|
|
109
109
|
color: var(--g-color-text-light-secondary);
|
|
110
110
|
}
|
|
111
|
-
.pc-content_theme_dark .pc-content__title a {
|
|
111
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__title a {
|
|
112
112
|
color: var(--g-color-text-light-primary);
|
|
113
113
|
text-decoration: underline;
|
|
114
114
|
text-decoration: none;
|
|
115
115
|
}
|
|
116
|
-
.pc-content_theme_dark .pc-content__title a:hover {
|
|
116
|
+
.pc-content_theme_dark.pc-content_theme_dark .pc-content__title a:hover {
|
|
117
117
|
color: var(--g-color-text-light-secondary);
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
.pc-content_theme_light .pc-
|
|
121
|
-
.pc-content_theme_light .pc-content__text .yfm
|
|
122
|
-
.pc-content_theme_light .pc-
|
|
119
|
+
|
|
120
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__title *,
|
|
121
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__text .yfm,
|
|
122
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__text .yfm *,
|
|
123
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__links a {
|
|
123
124
|
color: var(--g-color-text-dark-primary);
|
|
124
125
|
}
|
|
125
|
-
.pc-content_theme_light .pc-content__notice .yfm,
|
|
126
|
-
.pc-content_theme_light .pc-content__notice .yfm * {
|
|
126
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__notice .yfm,
|
|
127
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__notice .yfm * {
|
|
127
128
|
color: var(--g-color-text-dark-secondary);
|
|
128
129
|
}
|
|
129
|
-
.pc-content_theme_light .pc-content__notice .yfm a {
|
|
130
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__notice .yfm a {
|
|
130
131
|
color: var(--g-color-text-dark-secondary);
|
|
131
132
|
text-decoration: underline;
|
|
132
133
|
}
|
|
133
|
-
.pc-content_theme_light .pc-content__notice .yfm a:hover {
|
|
134
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__notice .yfm a:hover {
|
|
134
135
|
color: var(--g-color-text-dark-primary);
|
|
135
136
|
}
|
|
136
|
-
.pc-content_theme_light .pc-content__text .yfm a {
|
|
137
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__text .yfm a {
|
|
137
138
|
color: var(--g-color-text-dark-primary);
|
|
138
139
|
text-decoration: underline;
|
|
139
140
|
}
|
|
140
|
-
.pc-content_theme_light .pc-content__text .yfm a:hover {
|
|
141
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__text .yfm a:hover {
|
|
141
142
|
color: var(--g-color-text-dark-secondary);
|
|
142
143
|
}
|
|
143
|
-
.pc-content_theme_light .pc-content__title a {
|
|
144
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__title a {
|
|
144
145
|
color: var(--g-color-text-dark-primary);
|
|
145
146
|
text-decoration: underline;
|
|
146
147
|
text-decoration: none;
|
|
147
148
|
}
|
|
148
|
-
.pc-content_theme_light .pc-content__title a:hover {
|
|
149
|
+
.pc-content_theme_light.pc-content_theme_light .pc-content__title a:hover {
|
|
149
150
|
color: var(--g-color-text-dark-secondary);
|
|
150
151
|
}
|
|
152
|
+
|
|
151
153
|
.pc-content_control-position_bottom .pc-content__notice:has(+ .pc-content__buttons), .pc-content_control-position_bottom .pc-content__notice:has(+ .pc-content__links),
|
|
152
154
|
.pc-content_control-position_bottom .pc-content__list:has(+ .pc-content__buttons),
|
|
153
155
|
.pc-content_control-position_bottom .pc-content__list:has(+ .pc-content__links),
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { MarkdownItPluginCb } from '@diplodoc/transform/lib/plugins/typings';
|
|
2
2
|
import { Lang } from './types';
|
|
3
3
|
export type ComplexItem = {
|
|
4
|
-
[key: string]: string;
|
|
4
|
+
[key: string]: string | object;
|
|
5
5
|
};
|
|
6
6
|
export type Item = string | null | ComplexItem;
|
|
7
7
|
export type Transformer = (text: string) => string;
|
|
8
8
|
export type TransformerRaw = (lang: Lang, content: string, options: {
|
|
9
9
|
plugins: MarkdownItPluginCb[];
|
|
10
|
+
renderInline?: boolean;
|
|
10
11
|
}) => string;
|
|
11
12
|
export type Parser<T = any> = (transformer: Transformer, block: T) => T;
|
|
12
13
|
export declare const createItemsParser: (fields: string[]) => (transformer: Transformer, items: Item[]) => (string | {
|
|
13
|
-
[x: string]: string;
|
|
14
|
+
[x: string]: string | object;
|
|
14
15
|
} | null)[];
|
|
15
16
|
export declare function yfmTransformer(lang: Lang, content: string, options?: {
|
|
16
17
|
plugins?: MarkdownItPluginCb[];
|
|
17
|
-
}): string;
|
|
18
|
+
}, renderInline?: boolean): string;
|
|
18
19
|
export declare function typografTransformer(lang: Lang, content: string): string;
|
|
@@ -4,29 +4,52 @@ exports.typografTransformer = exports.yfmTransformer = exports.createItemsParser
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const plugins_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/plugins"));
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
|
-
const createItemsParser = (fields) => (transformer, items) =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
7
|
+
const createItemsParser = (fields) => (transformer, items) => {
|
|
8
|
+
const applyTransform = (itemLocal) => typeof itemLocal === 'string' ? transformer(itemLocal) : itemLocal;
|
|
9
|
+
return items.map((item) => {
|
|
10
|
+
if (!item) {
|
|
11
|
+
return item;
|
|
12
|
+
}
|
|
13
|
+
else if (typeof item === 'string') {
|
|
14
|
+
return transformer(item);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return Object.assign(Object.assign({}, item), fields.reduce((acc, fieldName) => {
|
|
18
|
+
if (fieldName.includes('.')) {
|
|
19
|
+
const [firstProperty, secondProperty] = fieldName.split('.');
|
|
20
|
+
const root = item[firstProperty];
|
|
21
|
+
if (!root || typeof root !== 'object') {
|
|
22
|
+
return acc;
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(root)) {
|
|
25
|
+
if (!acc[firstProperty]) {
|
|
26
|
+
// eslint-disable-next-line no-param-reassign
|
|
27
|
+
acc[firstProperty] = [];
|
|
28
|
+
}
|
|
29
|
+
// eslint-disable-next-line no-param-reassign
|
|
30
|
+
acc[firstProperty] = root.map((subItem) => (Object.assign(Object.assign({}, subItem), { [secondProperty]: applyTransform(subItem[secondProperty]) })));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// eslint-disable-next-line no-param-reassign
|
|
34
|
+
acc[firstProperty] = Object.assign(Object.assign({}, root), { [secondProperty]: applyTransform(root[secondProperty]) });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (item[fieldName]) {
|
|
38
|
+
// eslint-disable-next-line no-param-reassign
|
|
39
|
+
acc[fieldName] = applyTransform(item[fieldName]);
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}, {}));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
24
46
|
exports.createItemsParser = createItemsParser;
|
|
25
|
-
function yfmTransformer(lang, content, options = {}) {
|
|
47
|
+
function yfmTransformer(lang, content, options = {}, renderInline = false) {
|
|
26
48
|
const { plugins = [] } = options;
|
|
27
49
|
const { html } = (0, utils_1.fullTransform)(content, {
|
|
28
50
|
lang,
|
|
29
51
|
plugins: [...plugins_1.default, ...plugins],
|
|
52
|
+
renderInline,
|
|
30
53
|
});
|
|
31
54
|
return html;
|
|
32
55
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TitleItemProps } from '../models';
|
|
2
|
-
import { Parser, Transformer, TransformerRaw,
|
|
2
|
+
import { Parser, Transformer, TransformerRaw, yfmTransformer } from './common';
|
|
3
3
|
export declare const blockHeaderTransformer: ({
|
|
4
4
|
fields: string[];
|
|
5
|
-
transformer: typeof
|
|
5
|
+
transformer: typeof yfmTransformer;
|
|
6
6
|
parser: (transformer: Transformer, title: TitleItemProps | string) => string | {
|
|
7
7
|
text: string;
|
|
8
8
|
navTitle?: string | undefined;
|
|
@@ -14,15 +14,18 @@ export declare const blockHeaderTransformer: ({
|
|
|
14
14
|
custom?: import("react").ReactNode;
|
|
15
15
|
onClick?: (() => void) | undefined;
|
|
16
16
|
};
|
|
17
|
+
renderInline: boolean;
|
|
17
18
|
} | {
|
|
18
19
|
fields: string[];
|
|
19
20
|
transformer: typeof yfmTransformer;
|
|
20
21
|
parser?: undefined;
|
|
22
|
+
renderInline?: undefined;
|
|
21
23
|
})[];
|
|
22
24
|
interface BlockConfig {
|
|
23
25
|
transformer: TransformerRaw;
|
|
24
26
|
fields?: string[];
|
|
25
27
|
parser?: Parser;
|
|
28
|
+
renderInline?: boolean;
|
|
26
29
|
}
|
|
27
30
|
export type BlocksConfig = Record<string, BlockConfig | BlockConfig[]>;
|
|
28
31
|
export declare const config: BlocksConfig;
|