@gravity-ui/page-constructor 6.0.0-alpha.0 → 6.0.0-alpha.1

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.
@@ -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;
@@ -13,20 +13,47 @@ const createItemsParser = (fields) => (transformer, items) => items.map((item) =
13
13
  }
14
14
  else {
15
15
  return Object.assign(Object.assign({}, item), fields.reduce((acc, fieldName) => {
16
- if (item[fieldName]) {
16
+ if (fieldName.includes('.')) {
17
+ const [firstProperty, secondProperty] = fieldName.split('.');
18
+ const root = item[firstProperty];
19
+ if (!root || typeof root !== 'object') {
20
+ return acc;
21
+ }
22
+ if (Array.isArray(root)) {
23
+ if (!acc[firstProperty]) {
24
+ // eslint-disable-next-line no-param-reassign
25
+ acc[firstProperty] = [];
26
+ }
27
+ // eslint-disable-next-line no-param-reassign
28
+ acc[firstProperty] = root.map((subItem) => (Object.assign(Object.assign({}, subItem), { [secondProperty]: typeof subItem[secondProperty] === 'string'
29
+ ? transformer(subItem[secondProperty])
30
+ : subItem[secondProperty] })));
31
+ }
32
+ else {
33
+ // eslint-disable-next-line no-param-reassign
34
+ acc[firstProperty] = Object.assign(Object.assign({}, root), { [secondProperty]: typeof root[secondProperty] === 'string'
35
+ ? transformer(root[secondProperty])
36
+ : root[secondProperty] });
37
+ }
38
+ }
39
+ else if (item[fieldName]) {
17
40
  // eslint-disable-next-line no-param-reassign
18
- acc[fieldName] = transformer(item[fieldName]);
41
+ acc[fieldName] =
42
+ typeof item[fieldName] === 'string'
43
+ ? transformer(item[fieldName])
44
+ : item[fieldName];
19
45
  }
20
46
  return acc;
21
47
  }, {}));
22
48
  }
23
49
  });
24
50
  exports.createItemsParser = createItemsParser;
25
- function yfmTransformer(lang, content, options = {}) {
51
+ function yfmTransformer(lang, content, options = {}, renderInline = false) {
26
52
  const { plugins = [] } = options;
27
53
  const { html } = (0, utils_1.fullTransform)(content, {
28
54
  lang,
29
55
  plugins: [...plugins_1.default, ...plugins],
56
+ renderInline,
30
57
  });
31
58
  return html;
32
59
  }
@@ -1,8 +1,8 @@
1
1
  import { TitleItemProps } from '../models';
2
- import { Parser, Transformer, TransformerRaw, typografTransformer, yfmTransformer } from './common';
2
+ import { Parser, Transformer, TransformerRaw, yfmTransformer } from './common';
3
3
  export declare const blockHeaderTransformer: ({
4
4
  fields: string[];
5
- transformer: typeof typografTransformer;
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;
@@ -6,10 +6,26 @@ exports.config = exports.blockHeaderTransformer = void 0;
6
6
  const tslib_1 = require("tslib");
7
7
  const models_1 = require("../models");
8
8
  const common_1 = require("./common");
9
- function parseTableBlock(transformer, content) {
9
+ function parseTableBlockLegend(transformer, content) {
10
10
  const legend = content === null || content === void 0 ? void 0 : content.legend;
11
11
  return Object.assign(Object.assign({}, (content || {})), { legend: legend && legend.map((string) => transformer(string)) });
12
12
  }
13
+ function parseTableBlockContent(transformer, content) {
14
+ const legend = content === null || content === void 0 ? void 0 : content.legend;
15
+ const tableContent = content === null || content === void 0 ? void 0 : content.content;
16
+ return Object.assign(Object.assign({}, (content || {})), { content: tableContent &&
17
+ tableContent.map((row, i) => row.map((cell, j) => {
18
+ if (legend) {
19
+ if (i === 0 || j === 0) {
20
+ return transformer(cell);
21
+ }
22
+ return cell;
23
+ }
24
+ else {
25
+ return transformer(cell);
26
+ }
27
+ })) });
28
+ }
13
29
  function parseFeatures(transformer, items) {
14
30
  return items.map((_a) => {
15
31
  var { title, text } = _a, rest = tslib_1.__rest(_a, ["title", "text"]);
@@ -84,8 +100,9 @@ function parseContentLayoutTitle(transformer, content) {
84
100
  exports.blockHeaderTransformer = [
85
101
  {
86
102
  fields: ['title'],
87
- transformer: common_1.typografTransformer,
103
+ transformer: common_1.yfmTransformer,
88
104
  parser: parseTitle,
105
+ renderInline: true,
89
106
  },
90
107
  {
91
108
  fields: ['description'],
@@ -142,26 +159,30 @@ exports.config = {
142
159
  ],
143
160
  [models_1.SubBlockType.Quote]: [
144
161
  {
145
- fields: ['text'],
146
- transformer: common_1.typografTransformer,
147
- },
148
- {
149
- fields: ['yfmText'],
162
+ fields: ['text', 'yfmText'],
150
163
  transformer: common_1.yfmTransformer,
164
+ renderInline: true,
151
165
  },
152
166
  ],
153
167
  [models_1.BlockType.ExtendedFeaturesBlock]: [
154
168
  ...exports.blockHeaderTransformer,
155
169
  {
156
170
  fields: ['items'],
157
- transformer: common_1.typografTransformer,
171
+ transformer: common_1.yfmTransformer,
158
172
  parser: (0, common_1.createItemsParser)(['title']),
173
+ renderInline: true,
159
174
  },
160
175
  {
161
176
  fields: ['items'],
162
177
  transformer: common_1.yfmTransformer,
163
178
  parser: (0, common_1.createItemsParser)(['text', 'additionalInfo']),
164
179
  },
180
+ {
181
+ fields: ['items'],
182
+ transformer: common_1.yfmTransformer,
183
+ parser: (0, common_1.createItemsParser)(['list.text']),
184
+ renderInline: true,
185
+ },
165
186
  ],
166
187
  [models_1.BlockType.PromoFeaturesBlock]: [
167
188
  ...exports.blockHeaderTransformer,
@@ -191,7 +212,8 @@ exports.config = {
191
212
  [models_1.BlockType.BannerBlock]: [
192
213
  {
193
214
  fields: ['title'],
194
- transformer: common_1.typografTransformer,
215
+ transformer: common_1.yfmTransformer,
216
+ renderInline: true,
195
217
  },
196
218
  {
197
219
  fields: ['subtitle'],
@@ -244,7 +266,13 @@ exports.config = {
244
266
  {
245
267
  fields: ['table'],
246
268
  transformer: common_1.yfmTransformer,
247
- parser: parseTableBlock,
269
+ parser: parseTableBlockLegend,
270
+ },
271
+ {
272
+ fields: ['table'],
273
+ transformer: common_1.yfmTransformer,
274
+ parser: parseTableBlockContent,
275
+ renderInline: true,
248
276
  },
249
277
  ],
250
278
  [models_1.BlockType.HeaderSliderBlock]: [
@@ -270,6 +298,11 @@ exports.config = {
270
298
  fields: ['description'],
271
299
  transformer: common_1.yfmTransformer,
272
300
  },
301
+ {
302
+ fields: ['overtitle', 'title'],
303
+ transformer: common_1.yfmTransformer,
304
+ renderInline: true,
305
+ },
273
306
  ],
274
307
  [models_1.BlockType.ContentLayoutBlock]: [
275
308
  {
@@ -323,13 +356,20 @@ exports.config = {
323
356
  [models_1.SubBlockType.PriceCard]: [
324
357
  {
325
358
  fields: ['title'],
326
- transformer: common_1.typografTransformer,
359
+ transformer: common_1.yfmTransformer,
360
+ renderInline: true,
327
361
  },
328
362
  {
329
363
  fields: ['list'],
330
364
  transformer: common_1.yfmTransformer,
331
365
  parser: (0, common_1.createItemsParser)(['text']),
332
366
  },
367
+ {
368
+ fields: ['list'],
369
+ transformer: common_1.yfmTransformer,
370
+ parser: (0, common_1.createItemsParser)(['title']),
371
+ renderInline: true,
372
+ },
333
373
  ],
334
374
  [models_1.BlockType.FormBlock]: [
335
375
  {
@@ -22,10 +22,10 @@ function transformBlock(lang, blocksConfig, block, plugins) {
22
22
  if (blockConfig) {
23
23
  const configs = Array.isArray(blockConfig) ? blockConfig : [blockConfig];
24
24
  configs.forEach((transformConfig) => {
25
- const { fields, transformer: transformerRaw, parser } = transformConfig;
25
+ const { fields, transformer: transformerRaw, parser, renderInline } = transformConfig;
26
26
  const transformer = (content) =>
27
27
  // eslint-disable-next-line no-useless-call
28
- transformerRaw.call(null, lang, content, { plugins });
28
+ transformerRaw.call(null, lang, content, { plugins, renderInline });
29
29
  if (fields) {
30
30
  fields.forEach((field) => {
31
31
  if (block[field]) {
@@ -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;
@@ -9,19 +9,46 @@ export const createItemsParser = (fields) => (transformer, items) => items.map((
9
9
  }
10
10
  else {
11
11
  return Object.assign(Object.assign({}, item), fields.reduce((acc, fieldName) => {
12
- if (item[fieldName]) {
12
+ if (fieldName.includes('.')) {
13
+ const [firstProperty, secondProperty] = fieldName.split('.');
14
+ const root = item[firstProperty];
15
+ if (!root || typeof root !== 'object') {
16
+ return acc;
17
+ }
18
+ if (Array.isArray(root)) {
19
+ if (!acc[firstProperty]) {
20
+ // eslint-disable-next-line no-param-reassign
21
+ acc[firstProperty] = [];
22
+ }
23
+ // eslint-disable-next-line no-param-reassign
24
+ acc[firstProperty] = root.map((subItem) => (Object.assign(Object.assign({}, subItem), { [secondProperty]: typeof subItem[secondProperty] === 'string'
25
+ ? transformer(subItem[secondProperty])
26
+ : subItem[secondProperty] })));
27
+ }
28
+ else {
29
+ // eslint-disable-next-line no-param-reassign
30
+ acc[firstProperty] = Object.assign(Object.assign({}, root), { [secondProperty]: typeof root[secondProperty] === 'string'
31
+ ? transformer(root[secondProperty])
32
+ : root[secondProperty] });
33
+ }
34
+ }
35
+ else if (item[fieldName]) {
13
36
  // eslint-disable-next-line no-param-reassign
14
- acc[fieldName] = transformer(item[fieldName]);
37
+ acc[fieldName] =
38
+ typeof item[fieldName] === 'string'
39
+ ? transformer(item[fieldName])
40
+ : item[fieldName];
15
41
  }
16
42
  return acc;
17
43
  }, {}));
18
44
  }
19
45
  });
20
- export function yfmTransformer(lang, content, options = {}) {
46
+ export function yfmTransformer(lang, content, options = {}, renderInline = false) {
21
47
  const { plugins = [] } = options;
22
48
  const { html } = fullTransform(content, {
23
49
  lang,
24
50
  plugins: [...defaultPlugins, ...plugins],
51
+ renderInline,
25
52
  });
26
53
  return html;
27
54
  }
@@ -1,8 +1,8 @@
1
1
  import { TitleItemProps } from '../models';
2
- import { Parser, Transformer, TransformerRaw, typografTransformer, yfmTransformer } from './common';
2
+ import { Parser, Transformer, TransformerRaw, yfmTransformer } from './common';
3
3
  export declare const blockHeaderTransformer: ({
4
4
  fields: string[];
5
- transformer: typeof typografTransformer;
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;
@@ -3,10 +3,26 @@
3
3
  import { __rest } from "tslib";
4
4
  import { BlockType, SubBlockType, } from '../models';
5
5
  import { createItemsParser, typografTransformer, yfmTransformer, } from './common';
6
- function parseTableBlock(transformer, content) {
6
+ function parseTableBlockLegend(transformer, content) {
7
7
  const legend = content === null || content === void 0 ? void 0 : content.legend;
8
8
  return Object.assign(Object.assign({}, (content || {})), { legend: legend && legend.map((string) => transformer(string)) });
9
9
  }
10
+ function parseTableBlockContent(transformer, content) {
11
+ const legend = content === null || content === void 0 ? void 0 : content.legend;
12
+ const tableContent = content === null || content === void 0 ? void 0 : content.content;
13
+ return Object.assign(Object.assign({}, (content || {})), { content: tableContent &&
14
+ tableContent.map((row, i) => row.map((cell, j) => {
15
+ if (legend) {
16
+ if (i === 0 || j === 0) {
17
+ return transformer(cell);
18
+ }
19
+ return cell;
20
+ }
21
+ else {
22
+ return transformer(cell);
23
+ }
24
+ })) });
25
+ }
10
26
  function parseFeatures(transformer, items) {
11
27
  return items.map((_a) => {
12
28
  var { title, text } = _a, rest = __rest(_a, ["title", "text"]);
@@ -81,8 +97,9 @@ function parseContentLayoutTitle(transformer, content) {
81
97
  export const blockHeaderTransformer = [
82
98
  {
83
99
  fields: ['title'],
84
- transformer: typografTransformer,
100
+ transformer: yfmTransformer,
85
101
  parser: parseTitle,
102
+ renderInline: true,
86
103
  },
87
104
  {
88
105
  fields: ['description'],
@@ -139,26 +156,30 @@ export const config = {
139
156
  ],
140
157
  [SubBlockType.Quote]: [
141
158
  {
142
- fields: ['text'],
143
- transformer: typografTransformer,
144
- },
145
- {
146
- fields: ['yfmText'],
159
+ fields: ['text', 'yfmText'],
147
160
  transformer: yfmTransformer,
161
+ renderInline: true,
148
162
  },
149
163
  ],
150
164
  [BlockType.ExtendedFeaturesBlock]: [
151
165
  ...blockHeaderTransformer,
152
166
  {
153
167
  fields: ['items'],
154
- transformer: typografTransformer,
168
+ transformer: yfmTransformer,
155
169
  parser: createItemsParser(['title']),
170
+ renderInline: true,
156
171
  },
157
172
  {
158
173
  fields: ['items'],
159
174
  transformer: yfmTransformer,
160
175
  parser: createItemsParser(['text', 'additionalInfo']),
161
176
  },
177
+ {
178
+ fields: ['items'],
179
+ transformer: yfmTransformer,
180
+ parser: createItemsParser(['list.text']),
181
+ renderInline: true,
182
+ },
162
183
  ],
163
184
  [BlockType.PromoFeaturesBlock]: [
164
185
  ...blockHeaderTransformer,
@@ -188,7 +209,8 @@ export const config = {
188
209
  [BlockType.BannerBlock]: [
189
210
  {
190
211
  fields: ['title'],
191
- transformer: typografTransformer,
212
+ transformer: yfmTransformer,
213
+ renderInline: true,
192
214
  },
193
215
  {
194
216
  fields: ['subtitle'],
@@ -241,7 +263,13 @@ export const config = {
241
263
  {
242
264
  fields: ['table'],
243
265
  transformer: yfmTransformer,
244
- parser: parseTableBlock,
266
+ parser: parseTableBlockLegend,
267
+ },
268
+ {
269
+ fields: ['table'],
270
+ transformer: yfmTransformer,
271
+ parser: parseTableBlockContent,
272
+ renderInline: true,
245
273
  },
246
274
  ],
247
275
  [BlockType.HeaderSliderBlock]: [
@@ -267,6 +295,11 @@ export const config = {
267
295
  fields: ['description'],
268
296
  transformer: yfmTransformer,
269
297
  },
298
+ {
299
+ fields: ['overtitle', 'title'],
300
+ transformer: yfmTransformer,
301
+ renderInline: true,
302
+ },
270
303
  ],
271
304
  [BlockType.ContentLayoutBlock]: [
272
305
  {
@@ -320,13 +353,20 @@ export const config = {
320
353
  [SubBlockType.PriceCard]: [
321
354
  {
322
355
  fields: ['title'],
323
- transformer: typografTransformer,
356
+ transformer: yfmTransformer,
357
+ renderInline: true,
324
358
  },
325
359
  {
326
360
  fields: ['list'],
327
361
  transformer: yfmTransformer,
328
362
  parser: createItemsParser(['text']),
329
363
  },
364
+ {
365
+ fields: ['list'],
366
+ transformer: yfmTransformer,
367
+ parser: createItemsParser(['title']),
368
+ renderInline: true,
369
+ },
330
370
  ],
331
371
  [BlockType.FormBlock]: [
332
372
  {
@@ -18,10 +18,10 @@ function transformBlock(lang, blocksConfig, block, plugins) {
18
18
  if (blockConfig) {
19
19
  const configs = Array.isArray(blockConfig) ? blockConfig : [blockConfig];
20
20
  configs.forEach((transformConfig) => {
21
- const { fields, transformer: transformerRaw, parser } = transformConfig;
21
+ const { fields, transformer: transformerRaw, parser, renderInline } = transformConfig;
22
22
  const transformer = (content) =>
23
23
  // eslint-disable-next-line no-useless-call
24
- transformerRaw.call(null, lang, content, { plugins });
24
+ transformerRaw.call(null, lang, content, { plugins, renderInline });
25
25
  if (fields) {
26
26
  fields.forEach((field) => {
27
27
  if (block[field]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "6.0.0-alpha.0",
3
+ "version": "6.0.0-alpha.1",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -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;
@@ -15,20 +15,47 @@ const createItemsParser = (fields) => (transformer, items) => items.map((item) =
15
15
  }
16
16
  else {
17
17
  return Object.assign(Object.assign({}, item), fields.reduce((acc, fieldName) => {
18
- if (item[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]: typeof subItem[secondProperty] === 'string'
31
+ ? transformer(subItem[secondProperty])
32
+ : subItem[secondProperty] })));
33
+ }
34
+ else {
35
+ // eslint-disable-next-line no-param-reassign
36
+ acc[firstProperty] = Object.assign(Object.assign({}, root), { [secondProperty]: typeof root[secondProperty] === 'string'
37
+ ? transformer(root[secondProperty])
38
+ : root[secondProperty] });
39
+ }
40
+ }
41
+ else if (item[fieldName]) {
19
42
  // eslint-disable-next-line no-param-reassign
20
- acc[fieldName] = transformer(item[fieldName]);
43
+ acc[fieldName] =
44
+ typeof item[fieldName] === 'string'
45
+ ? transformer(item[fieldName])
46
+ : item[fieldName];
21
47
  }
22
48
  return acc;
23
49
  }, {}));
24
50
  }
25
51
  });
26
52
  exports.createItemsParser = createItemsParser;
27
- function yfmTransformer(lang, content, options = {}) {
53
+ function yfmTransformer(lang, content, options = {}, renderInline = false) {
28
54
  const { plugins = [] } = options;
29
55
  const { html } = (0, utils_1.fullTransform)(content, {
30
56
  lang,
31
57
  plugins: [...plugins_1.default, ...plugins],
58
+ renderInline,
32
59
  });
33
60
  return html;
34
61
  }
@@ -1,8 +1,8 @@
1
1
  import { TitleItemProps } from '../models';
2
- import { Parser, Transformer, TransformerRaw, typografTransformer, yfmTransformer } from './common';
2
+ import { Parser, Transformer, TransformerRaw, yfmTransformer } from './common';
3
3
  export declare const blockHeaderTransformer: ({
4
4
  fields: string[];
5
- transformer: typeof typografTransformer;
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;
@@ -16,10 +16,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.config = exports.blockHeaderTransformer = void 0;
17
17
  const models_1 = require("../models");
18
18
  const common_1 = require("./common");
19
- function parseTableBlock(transformer, content) {
19
+ function parseTableBlockLegend(transformer, content) {
20
20
  const legend = content === null || content === void 0 ? void 0 : content.legend;
21
21
  return Object.assign(Object.assign({}, (content || {})), { legend: legend && legend.map((string) => transformer(string)) });
22
22
  }
23
+ function parseTableBlockContent(transformer, content) {
24
+ const legend = content === null || content === void 0 ? void 0 : content.legend;
25
+ const tableContent = content === null || content === void 0 ? void 0 : content.content;
26
+ return Object.assign(Object.assign({}, (content || {})), { content: tableContent &&
27
+ tableContent.map((row, i) => row.map((cell, j) => {
28
+ if (legend) {
29
+ if (i === 0 || j === 0) {
30
+ return transformer(cell);
31
+ }
32
+ return cell;
33
+ }
34
+ else {
35
+ return transformer(cell);
36
+ }
37
+ })) });
38
+ }
23
39
  function parseFeatures(transformer, items) {
24
40
  return items.map((_a) => {
25
41
  var { title, text } = _a, rest = __rest(_a, ["title", "text"]);
@@ -94,8 +110,9 @@ function parseContentLayoutTitle(transformer, content) {
94
110
  exports.blockHeaderTransformer = [
95
111
  {
96
112
  fields: ['title'],
97
- transformer: common_1.typografTransformer,
113
+ transformer: common_1.yfmTransformer,
98
114
  parser: parseTitle,
115
+ renderInline: true,
99
116
  },
100
117
  {
101
118
  fields: ['description'],
@@ -152,26 +169,30 @@ exports.config = {
152
169
  ],
153
170
  [models_1.SubBlockType.Quote]: [
154
171
  {
155
- fields: ['text'],
156
- transformer: common_1.typografTransformer,
157
- },
158
- {
159
- fields: ['yfmText'],
172
+ fields: ['text', 'yfmText'],
160
173
  transformer: common_1.yfmTransformer,
174
+ renderInline: true,
161
175
  },
162
176
  ],
163
177
  [models_1.BlockType.ExtendedFeaturesBlock]: [
164
178
  ...exports.blockHeaderTransformer,
165
179
  {
166
180
  fields: ['items'],
167
- transformer: common_1.typografTransformer,
181
+ transformer: common_1.yfmTransformer,
168
182
  parser: (0, common_1.createItemsParser)(['title']),
183
+ renderInline: true,
169
184
  },
170
185
  {
171
186
  fields: ['items'],
172
187
  transformer: common_1.yfmTransformer,
173
188
  parser: (0, common_1.createItemsParser)(['text', 'additionalInfo']),
174
189
  },
190
+ {
191
+ fields: ['items'],
192
+ transformer: common_1.yfmTransformer,
193
+ parser: (0, common_1.createItemsParser)(['list.text']),
194
+ renderInline: true,
195
+ },
175
196
  ],
176
197
  [models_1.BlockType.PromoFeaturesBlock]: [
177
198
  ...exports.blockHeaderTransformer,
@@ -201,7 +222,8 @@ exports.config = {
201
222
  [models_1.BlockType.BannerBlock]: [
202
223
  {
203
224
  fields: ['title'],
204
- transformer: common_1.typografTransformer,
225
+ transformer: common_1.yfmTransformer,
226
+ renderInline: true,
205
227
  },
206
228
  {
207
229
  fields: ['subtitle'],
@@ -254,7 +276,13 @@ exports.config = {
254
276
  {
255
277
  fields: ['table'],
256
278
  transformer: common_1.yfmTransformer,
257
- parser: parseTableBlock,
279
+ parser: parseTableBlockLegend,
280
+ },
281
+ {
282
+ fields: ['table'],
283
+ transformer: common_1.yfmTransformer,
284
+ parser: parseTableBlockContent,
285
+ renderInline: true,
258
286
  },
259
287
  ],
260
288
  [models_1.BlockType.HeaderSliderBlock]: [
@@ -280,6 +308,11 @@ exports.config = {
280
308
  fields: ['description'],
281
309
  transformer: common_1.yfmTransformer,
282
310
  },
311
+ {
312
+ fields: ['overtitle', 'title'],
313
+ transformer: common_1.yfmTransformer,
314
+ renderInline: true,
315
+ },
283
316
  ],
284
317
  [models_1.BlockType.ContentLayoutBlock]: [
285
318
  {
@@ -333,13 +366,20 @@ exports.config = {
333
366
  [models_1.SubBlockType.PriceCard]: [
334
367
  {
335
368
  fields: ['title'],
336
- transformer: common_1.typografTransformer,
369
+ transformer: common_1.yfmTransformer,
370
+ renderInline: true,
337
371
  },
338
372
  {
339
373
  fields: ['list'],
340
374
  transformer: common_1.yfmTransformer,
341
375
  parser: (0, common_1.createItemsParser)(['text']),
342
376
  },
377
+ {
378
+ fields: ['list'],
379
+ transformer: common_1.yfmTransformer,
380
+ parser: (0, common_1.createItemsParser)(['title']),
381
+ renderInline: true,
382
+ },
343
383
  ],
344
384
  [models_1.BlockType.FormBlock]: [
345
385
  {
@@ -24,10 +24,10 @@ function transformBlock(lang, blocksConfig, block, plugins) {
24
24
  if (blockConfig) {
25
25
  const configs = Array.isArray(blockConfig) ? blockConfig : [blockConfig];
26
26
  configs.forEach((transformConfig) => {
27
- const { fields, transformer: transformerRaw, parser } = transformConfig;
27
+ const { fields, transformer: transformerRaw, parser, renderInline } = transformConfig;
28
28
  const transformer = (content) =>
29
29
  // eslint-disable-next-line no-useless-call
30
- transformerRaw.call(null, lang, content, { plugins });
30
+ transformerRaw.call(null, lang, content, { plugins, renderInline });
31
31
  if (fields) {
32
32
  fields.forEach((field) => {
33
33
  if (block[field]) {