@gravity-ui/page-constructor 5.5.0 → 5.6.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.
- package/build/cjs/sub-blocks/LayoutItem/LayoutItem.js +6 -3
- package/build/cjs/text-transform/common.d.ts +4 -4
- package/build/cjs/text-transform/transformers.d.ts +2 -2
- package/build/cjs/text-transform/types.d.ts +3 -0
- package/build/cjs/text-transform/types.js +2 -0
- package/build/cjs/text-transform/utils.d.ts +6 -6
- package/build/cjs/text-transform/utils.js +4 -5
- package/build/esm/sub-blocks/LayoutItem/LayoutItem.js +7 -4
- package/build/esm/text-transform/common.d.ts +4 -4
- package/build/esm/text-transform/transformers.d.ts +2 -2
- package/build/esm/text-transform/types.d.ts +3 -0
- package/build/esm/text-transform/types.js +1 -0
- package/build/esm/text-transform/utils.d.ts +6 -6
- package/build/esm/text-transform/utils.js +4 -5
- package/package.json +1 -1
- package/server/text-transform/common.d.ts +4 -4
- package/server/text-transform/transformers.d.ts +2 -2
- package/server/text-transform/types.d.ts +3 -0
- package/server/text-transform/types.js +2 -0
- package/server/text-transform/utils.d.ts +6 -6
- package/server/text-transform/utils.js +4 -5
- package/widget/index.js +1 -1
|
@@ -4,6 +4,7 @@ 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
6
|
const components_1 = require("../../components");
|
|
7
|
+
const theme_1 = require("../../context/theme");
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
const Content_1 = tslib_1.__importDefault(require("../Content/Content"));
|
|
9
10
|
const utils_2 = require("./utils");
|
|
@@ -12,16 +13,18 @@ const LayoutItem = (_a) => {
|
|
|
12
13
|
var _b = _a.content, { links, buttons } = _b, content = tslib_1.__rest(_b, ["links", "buttons"]), { metaInfo, media, border, fullscreen, icon, className, analyticsEvents, controlPosition = 'content' } = _a;
|
|
13
14
|
const normalizedLinks = (0, react_1.useMemo)(() => (0, utils_2.getLayoutItemLinks)(links), [links]);
|
|
14
15
|
const areControlsInFooter = controlPosition === 'footer';
|
|
16
|
+
const theme = (0, theme_1.useTheme)();
|
|
15
17
|
const contentProps = Object.assign(Object.assign(Object.assign({}, content), (areControlsInFooter ? {} : { links: normalizedLinks, buttons })), { size: 's', colSizes: { all: 12, md: 12 } });
|
|
16
18
|
const titleId = (0, uikit_1.useUniqId)();
|
|
17
19
|
const renderMedia = () => {
|
|
18
20
|
if (!media) {
|
|
19
21
|
return null;
|
|
20
22
|
}
|
|
21
|
-
|
|
23
|
+
const themedMedia = (0, utils_1.getThemedValue)(media, theme);
|
|
24
|
+
return fullscreen && (0, utils_2.hasFullscreen)(themedMedia) ? (react_1.default.createElement(components_1.FullscreenMedia, { showFullscreenIcon: (0, utils_2.showFullscreenIcon)(themedMedia) }, (_a = {}) => {
|
|
22
25
|
var { className: mediaClassName, fullscreen: _fullscreen } = _a, fullscreenMediaProps = tslib_1.__rest(_a, ["className", "fullscreen"]);
|
|
23
|
-
return (react_1.default.createElement(components_1.Media, Object.assign({},
|
|
24
|
-
})) : (react_1.default.createElement(components_1.Media, Object.assign({},
|
|
26
|
+
return (react_1.default.createElement(components_1.Media, Object.assign({}, themedMedia, fullscreenMediaProps, { className: b('media', { border }, mediaClassName), analyticsEvents: analyticsEvents })));
|
|
27
|
+
})) : (react_1.default.createElement(components_1.Media, Object.assign({}, themedMedia, { className: b('media', { border }), analyticsEvents: analyticsEvents })));
|
|
25
28
|
};
|
|
26
29
|
return (react_1.default.createElement("div", { className: b(null, className) },
|
|
27
30
|
renderMedia(),
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { MarkdownItPluginCb } from '@diplodoc/transform/lib/plugins/typings';
|
|
2
|
-
import { Lang } from '
|
|
2
|
+
import { Lang } from './types';
|
|
3
3
|
export type ComplexItem = {
|
|
4
4
|
[key: string]: string;
|
|
5
5
|
};
|
|
6
6
|
export type Item = string | null | ComplexItem;
|
|
7
7
|
export type Transformer = (text: string) => string;
|
|
8
|
-
export type TransformerRaw = (lang:
|
|
8
|
+
export type TransformerRaw = (lang: Lang, content: string, options: {
|
|
9
9
|
plugins: MarkdownItPluginCb[];
|
|
10
10
|
}) => string;
|
|
11
11
|
export type Parser<T = any> = (transformer: Transformer, block: T) => T;
|
|
12
12
|
export declare const createItemsParser: (fields: string[]) => (transformer: Transformer, items: Item[]) => (string | {
|
|
13
13
|
[x: string]: string;
|
|
14
14
|
} | null)[];
|
|
15
|
-
export declare function yfmTransformer(lang:
|
|
15
|
+
export declare function yfmTransformer(lang: Lang, content: string, options?: {
|
|
16
16
|
plugins?: MarkdownItPluginCb[];
|
|
17
17
|
}): string;
|
|
18
|
-
export declare function typografTransformer(lang:
|
|
18
|
+
export declare function typografTransformer(lang: Lang, content: string): string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { MarkdownItPluginCb } from '@diplodoc/transform/lib/plugins/typings';
|
|
2
|
-
import { Lang } from '@gravity-ui/uikit';
|
|
3
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
|
+
import { Lang } from './types';
|
|
4
4
|
export type ContentVariables = Record<string, string>;
|
|
5
5
|
export type ContentTransformerProps = {
|
|
6
6
|
content: {
|
|
7
7
|
blocks?: ConstructorBlock[];
|
|
8
8
|
};
|
|
9
9
|
options: {
|
|
10
|
-
lang:
|
|
10
|
+
lang: Lang;
|
|
11
11
|
customConfig?: {};
|
|
12
12
|
vars?: ContentVariables;
|
|
13
13
|
plugins?: MarkdownItPluginCb[];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Options, Output } from '@diplodoc/transform';
|
|
2
|
-
import { Lang } from '@gravity-ui/uikit';
|
|
3
2
|
import sanitize from 'sanitize-html';
|
|
3
|
+
import { Lang } from './types';
|
|
4
4
|
import AddRuleOptions = typograf.AddRuleOptions;
|
|
5
5
|
export declare enum TransformType {
|
|
6
6
|
Text = "text",
|
|
7
7
|
Html = "html"
|
|
8
8
|
}
|
|
9
9
|
interface TransformOptions extends Options {
|
|
10
|
-
lang:
|
|
10
|
+
lang: Lang;
|
|
11
11
|
}
|
|
12
12
|
export declare const DEFAULT_ALLOWED_TAGS: string[];
|
|
13
13
|
export declare const typografConfig: {
|
|
@@ -16,16 +16,16 @@ export declare const typografConfig: {
|
|
|
16
16
|
};
|
|
17
17
|
export declare const sanitizeStripOptions: sanitize.IOptions;
|
|
18
18
|
export declare function addTypografRules(options: AddRuleOptions[]): void;
|
|
19
|
-
export declare function typograf(text: string, lang?:
|
|
19
|
+
export declare function typograf(text: string, lang?: Lang): string;
|
|
20
20
|
export declare function sanitizeHtml(html: string, options?: sanitize.IOptions): string;
|
|
21
|
-
export declare function typografToHTML(text: string, lang:
|
|
22
|
-
export declare function typografToText(text: string, lang:
|
|
21
|
+
export declare function typografToHTML(text: string, lang: Lang, allowedTags?: string[]): string;
|
|
22
|
+
export declare function typografToText(text: string, lang: Lang): string;
|
|
23
23
|
export declare const transformMarkdown: (input: string, options: TransformOptions) => Output['result'];
|
|
24
24
|
export declare function fullTransform(input: string, { lang, ...options }: TransformOptions): Output['result'];
|
|
25
25
|
export interface TypografEntityParams {
|
|
26
26
|
entity: Record<string, string>;
|
|
27
27
|
fields: string[];
|
|
28
|
-
lang:
|
|
28
|
+
lang: Lang;
|
|
29
29
|
transformType: TransformType;
|
|
30
30
|
}
|
|
31
31
|
export declare function typografEntity({ entity, fields, lang, transformType, }: TypografEntityParams): Record<string, string>;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.typografEntity = exports.fullTransform = exports.transformMarkdown = exports.typografToText = exports.typografToHTML = exports.sanitizeHtml = exports.typograf = exports.addTypografRules = exports.sanitizeStripOptions = exports.typografConfig = exports.DEFAULT_ALLOWED_TAGS = exports.TransformType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const transform_1 = tslib_1.__importDefault(require("@diplodoc/transform"));
|
|
6
|
-
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
6
|
const sanitize_html_1 = tslib_1.__importDefault(require("sanitize-html"));
|
|
8
7
|
const typograf_1 = tslib_1.__importDefault(require("typograf"));
|
|
9
8
|
var TransformType;
|
|
@@ -48,10 +47,10 @@ function enableRules(tp) {
|
|
|
48
47
|
enabled.forEach((rule) => tp.enableRule(rule));
|
|
49
48
|
disabled.forEach((rule) => tp.disableRule(rule));
|
|
50
49
|
}
|
|
51
|
-
function typograf(text, lang =
|
|
50
|
+
function typograf(text, lang = 'ru') {
|
|
52
51
|
const localeByLang = {
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
ru: ['ru', 'en-US'],
|
|
53
|
+
en: ['en-US', 'ru'],
|
|
55
54
|
};
|
|
56
55
|
const tp = new typograf_1.default({
|
|
57
56
|
locale: localeByLang[lang],
|
|
@@ -85,7 +84,7 @@ function fullTransform(input, _a) {
|
|
|
85
84
|
return Object.assign(Object.assign({}, result), { html: typograf(html, lang), title: title && typograf(title, lang) });
|
|
86
85
|
}
|
|
87
86
|
exports.fullTransform = fullTransform;
|
|
88
|
-
function typografEntity({ entity, fields, lang =
|
|
87
|
+
function typografEntity({ entity, fields, lang = 'ru', transformType = TransformType.Text, }) {
|
|
89
88
|
const transformTypeMap = {
|
|
90
89
|
text: typografToText,
|
|
91
90
|
html: typografToHTML,
|
|
@@ -2,7 +2,8 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import { useUniqId } from '@gravity-ui/uikit';
|
|
4
4
|
import { Buttons, FullscreenMedia, IconWrapper, Links, Media, MetaInfo } from '../../components';
|
|
5
|
-
import {
|
|
5
|
+
import { useTheme } from '../../context/theme';
|
|
6
|
+
import { block, getThemedValue } from '../../utils';
|
|
6
7
|
import Content from '../Content/Content';
|
|
7
8
|
import { getLayoutItemLinks, hasFullscreen, showFullscreenIcon } from './utils';
|
|
8
9
|
import './LayoutItem.css';
|
|
@@ -11,16 +12,18 @@ const LayoutItem = (_a) => {
|
|
|
11
12
|
var _b = _a.content, { links, buttons } = _b, content = __rest(_b, ["links", "buttons"]), { metaInfo, media, border, fullscreen, icon, className, analyticsEvents, controlPosition = 'content' } = _a;
|
|
12
13
|
const normalizedLinks = useMemo(() => getLayoutItemLinks(links), [links]);
|
|
13
14
|
const areControlsInFooter = controlPosition === 'footer';
|
|
15
|
+
const theme = useTheme();
|
|
14
16
|
const contentProps = Object.assign(Object.assign(Object.assign({}, content), (areControlsInFooter ? {} : { links: normalizedLinks, buttons })), { size: 's', colSizes: { all: 12, md: 12 } });
|
|
15
17
|
const titleId = useUniqId();
|
|
16
18
|
const renderMedia = () => {
|
|
17
19
|
if (!media) {
|
|
18
20
|
return null;
|
|
19
21
|
}
|
|
20
|
-
|
|
22
|
+
const themedMedia = getThemedValue(media, theme);
|
|
23
|
+
return fullscreen && hasFullscreen(themedMedia) ? (React.createElement(FullscreenMedia, { showFullscreenIcon: showFullscreenIcon(themedMedia) }, (_a = {}) => {
|
|
21
24
|
var { className: mediaClassName, fullscreen: _fullscreen } = _a, fullscreenMediaProps = __rest(_a, ["className", "fullscreen"]);
|
|
22
|
-
return (React.createElement(Media, Object.assign({},
|
|
23
|
-
})) : (React.createElement(Media, Object.assign({},
|
|
25
|
+
return (React.createElement(Media, Object.assign({}, themedMedia, fullscreenMediaProps, { className: b('media', { border }, mediaClassName), analyticsEvents: analyticsEvents })));
|
|
26
|
+
})) : (React.createElement(Media, Object.assign({}, themedMedia, { className: b('media', { border }), analyticsEvents: analyticsEvents })));
|
|
24
27
|
};
|
|
25
28
|
return (React.createElement("div", { className: b(null, className) },
|
|
26
29
|
renderMedia(),
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { MarkdownItPluginCb } from '@diplodoc/transform/lib/plugins/typings';
|
|
2
|
-
import { Lang } from '
|
|
2
|
+
import { Lang } from './types';
|
|
3
3
|
export type ComplexItem = {
|
|
4
4
|
[key: string]: string;
|
|
5
5
|
};
|
|
6
6
|
export type Item = string | null | ComplexItem;
|
|
7
7
|
export type Transformer = (text: string) => string;
|
|
8
|
-
export type TransformerRaw = (lang:
|
|
8
|
+
export type TransformerRaw = (lang: Lang, content: string, options: {
|
|
9
9
|
plugins: MarkdownItPluginCb[];
|
|
10
10
|
}) => string;
|
|
11
11
|
export type Parser<T = any> = (transformer: Transformer, block: T) => T;
|
|
12
12
|
export declare const createItemsParser: (fields: string[]) => (transformer: Transformer, items: Item[]) => (string | {
|
|
13
13
|
[x: string]: string;
|
|
14
14
|
} | null)[];
|
|
15
|
-
export declare function yfmTransformer(lang:
|
|
15
|
+
export declare function yfmTransformer(lang: Lang, content: string, options?: {
|
|
16
16
|
plugins?: MarkdownItPluginCb[];
|
|
17
17
|
}): string;
|
|
18
|
-
export declare function typografTransformer(lang:
|
|
18
|
+
export declare function typografTransformer(lang: Lang, content: string): string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { MarkdownItPluginCb } from '@diplodoc/transform/lib/plugins/typings';
|
|
2
|
-
import { Lang } from '@gravity-ui/uikit';
|
|
3
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
|
+
import { Lang } from './types';
|
|
4
4
|
export type ContentVariables = Record<string, string>;
|
|
5
5
|
export type ContentTransformerProps = {
|
|
6
6
|
content: {
|
|
7
7
|
blocks?: ConstructorBlock[];
|
|
8
8
|
};
|
|
9
9
|
options: {
|
|
10
|
-
lang:
|
|
10
|
+
lang: Lang;
|
|
11
11
|
customConfig?: {};
|
|
12
12
|
vars?: ContentVariables;
|
|
13
13
|
plugins?: MarkdownItPluginCb[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Options, Output } from '@diplodoc/transform';
|
|
2
|
-
import { Lang } from '@gravity-ui/uikit';
|
|
3
2
|
import sanitize from 'sanitize-html';
|
|
3
|
+
import { Lang } from './types';
|
|
4
4
|
import AddRuleOptions = typograf.AddRuleOptions;
|
|
5
5
|
export declare enum TransformType {
|
|
6
6
|
Text = "text",
|
|
7
7
|
Html = "html"
|
|
8
8
|
}
|
|
9
9
|
interface TransformOptions extends Options {
|
|
10
|
-
lang:
|
|
10
|
+
lang: Lang;
|
|
11
11
|
}
|
|
12
12
|
export declare const DEFAULT_ALLOWED_TAGS: string[];
|
|
13
13
|
export declare const typografConfig: {
|
|
@@ -16,16 +16,16 @@ export declare const typografConfig: {
|
|
|
16
16
|
};
|
|
17
17
|
export declare const sanitizeStripOptions: sanitize.IOptions;
|
|
18
18
|
export declare function addTypografRules(options: AddRuleOptions[]): void;
|
|
19
|
-
export declare function typograf(text: string, lang?:
|
|
19
|
+
export declare function typograf(text: string, lang?: Lang): string;
|
|
20
20
|
export declare function sanitizeHtml(html: string, options?: sanitize.IOptions): string;
|
|
21
|
-
export declare function typografToHTML(text: string, lang:
|
|
22
|
-
export declare function typografToText(text: string, lang:
|
|
21
|
+
export declare function typografToHTML(text: string, lang: Lang, allowedTags?: string[]): string;
|
|
22
|
+
export declare function typografToText(text: string, lang: Lang): string;
|
|
23
23
|
export declare const transformMarkdown: (input: string, options: TransformOptions) => Output['result'];
|
|
24
24
|
export declare function fullTransform(input: string, { lang, ...options }: TransformOptions): Output['result'];
|
|
25
25
|
export interface TypografEntityParams {
|
|
26
26
|
entity: Record<string, string>;
|
|
27
27
|
fields: string[];
|
|
28
|
-
lang:
|
|
28
|
+
lang: Lang;
|
|
29
29
|
transformType: TransformType;
|
|
30
30
|
}
|
|
31
31
|
export declare function typografEntity({ entity, fields, lang, transformType, }: TypografEntityParams): Record<string, string>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import transformYFM from '@diplodoc/transform';
|
|
3
|
-
import { Lang } from '@gravity-ui/uikit';
|
|
4
3
|
import sanitize from 'sanitize-html';
|
|
5
4
|
import Typograf from 'typograf';
|
|
6
5
|
export var TransformType;
|
|
@@ -44,10 +43,10 @@ function enableRules(tp) {
|
|
|
44
43
|
enabled.forEach((rule) => tp.enableRule(rule));
|
|
45
44
|
disabled.forEach((rule) => tp.disableRule(rule));
|
|
46
45
|
}
|
|
47
|
-
export function typograf(text, lang =
|
|
46
|
+
export function typograf(text, lang = 'ru') {
|
|
48
47
|
const localeByLang = {
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
ru: ['ru', 'en-US'],
|
|
49
|
+
en: ['en-US', 'ru'],
|
|
51
50
|
};
|
|
52
51
|
const tp = new Typograf({
|
|
53
52
|
locale: localeByLang[lang],
|
|
@@ -75,7 +74,7 @@ export function fullTransform(input, _a) {
|
|
|
75
74
|
const { html, title } = result;
|
|
76
75
|
return Object.assign(Object.assign({}, result), { html: typograf(html, lang), title: title && typograf(title, lang) });
|
|
77
76
|
}
|
|
78
|
-
export function typografEntity({ entity, fields, lang =
|
|
77
|
+
export function typografEntity({ entity, fields, lang = 'ru', transformType = TransformType.Text, }) {
|
|
79
78
|
const transformTypeMap = {
|
|
80
79
|
text: typografToText,
|
|
81
80
|
html: typografToHTML,
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { MarkdownItPluginCb } from '@diplodoc/transform/lib/plugins/typings';
|
|
2
|
-
import { Lang } from '
|
|
2
|
+
import { Lang } from './types';
|
|
3
3
|
export type ComplexItem = {
|
|
4
4
|
[key: string]: string;
|
|
5
5
|
};
|
|
6
6
|
export type Item = string | null | ComplexItem;
|
|
7
7
|
export type Transformer = (text: string) => string;
|
|
8
|
-
export type TransformerRaw = (lang:
|
|
8
|
+
export type TransformerRaw = (lang: Lang, content: string, options: {
|
|
9
9
|
plugins: MarkdownItPluginCb[];
|
|
10
10
|
}) => string;
|
|
11
11
|
export type Parser<T = any> = (transformer: Transformer, block: T) => T;
|
|
12
12
|
export declare const createItemsParser: (fields: string[]) => (transformer: Transformer, items: Item[]) => (string | {
|
|
13
13
|
[x: string]: string;
|
|
14
14
|
} | null)[];
|
|
15
|
-
export declare function yfmTransformer(lang:
|
|
15
|
+
export declare function yfmTransformer(lang: Lang, content: string, options?: {
|
|
16
16
|
plugins?: MarkdownItPluginCb[];
|
|
17
17
|
}): string;
|
|
18
|
-
export declare function typografTransformer(lang:
|
|
18
|
+
export declare function typografTransformer(lang: Lang, content: string): string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { MarkdownItPluginCb } from '@diplodoc/transform/lib/plugins/typings';
|
|
2
|
-
import { Lang } from '@gravity-ui/uikit';
|
|
3
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
|
+
import { Lang } from './types';
|
|
4
4
|
export type ContentVariables = Record<string, string>;
|
|
5
5
|
export type ContentTransformerProps = {
|
|
6
6
|
content: {
|
|
7
7
|
blocks?: ConstructorBlock[];
|
|
8
8
|
};
|
|
9
9
|
options: {
|
|
10
|
-
lang:
|
|
10
|
+
lang: Lang;
|
|
11
11
|
customConfig?: {};
|
|
12
12
|
vars?: ContentVariables;
|
|
13
13
|
plugins?: MarkdownItPluginCb[];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Options, Output } from '@diplodoc/transform';
|
|
2
|
-
import { Lang } from '@gravity-ui/uikit';
|
|
3
2
|
import sanitize from 'sanitize-html';
|
|
3
|
+
import { Lang } from './types';
|
|
4
4
|
import AddRuleOptions = typograf.AddRuleOptions;
|
|
5
5
|
export declare enum TransformType {
|
|
6
6
|
Text = "text",
|
|
7
7
|
Html = "html"
|
|
8
8
|
}
|
|
9
9
|
interface TransformOptions extends Options {
|
|
10
|
-
lang:
|
|
10
|
+
lang: Lang;
|
|
11
11
|
}
|
|
12
12
|
export declare const DEFAULT_ALLOWED_TAGS: string[];
|
|
13
13
|
export declare const typografConfig: {
|
|
@@ -16,16 +16,16 @@ export declare const typografConfig: {
|
|
|
16
16
|
};
|
|
17
17
|
export declare const sanitizeStripOptions: sanitize.IOptions;
|
|
18
18
|
export declare function addTypografRules(options: AddRuleOptions[]): void;
|
|
19
|
-
export declare function typograf(text: string, lang?:
|
|
19
|
+
export declare function typograf(text: string, lang?: Lang): string;
|
|
20
20
|
export declare function sanitizeHtml(html: string, options?: sanitize.IOptions): string;
|
|
21
|
-
export declare function typografToHTML(text: string, lang:
|
|
22
|
-
export declare function typografToText(text: string, lang:
|
|
21
|
+
export declare function typografToHTML(text: string, lang: Lang, allowedTags?: string[]): string;
|
|
22
|
+
export declare function typografToText(text: string, lang: Lang): string;
|
|
23
23
|
export declare const transformMarkdown: (input: string, options: TransformOptions) => Output['result'];
|
|
24
24
|
export declare function fullTransform(input: string, { lang, ...options }: TransformOptions): Output['result'];
|
|
25
25
|
export interface TypografEntityParams {
|
|
26
26
|
entity: Record<string, string>;
|
|
27
27
|
fields: string[];
|
|
28
|
-
lang:
|
|
28
|
+
lang: Lang;
|
|
29
29
|
transformType: TransformType;
|
|
30
30
|
}
|
|
31
31
|
export declare function typografEntity({ entity, fields, lang, transformType, }: TypografEntityParams): Record<string, string>;
|
|
@@ -16,7 +16,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.typografEntity = exports.fullTransform = exports.transformMarkdown = exports.typografToText = exports.typografToHTML = exports.sanitizeHtml = exports.typograf = exports.addTypografRules = exports.sanitizeStripOptions = exports.typografConfig = exports.DEFAULT_ALLOWED_TAGS = exports.TransformType = void 0;
|
|
18
18
|
const transform_1 = __importDefault(require("@diplodoc/transform"));
|
|
19
|
-
const uikit_1 = require("@gravity-ui/uikit");
|
|
20
19
|
const sanitize_html_1 = __importDefault(require("sanitize-html"));
|
|
21
20
|
const typograf_1 = __importDefault(require("typograf"));
|
|
22
21
|
var TransformType;
|
|
@@ -61,10 +60,10 @@ function enableRules(tp) {
|
|
|
61
60
|
enabled.forEach((rule) => tp.enableRule(rule));
|
|
62
61
|
disabled.forEach((rule) => tp.disableRule(rule));
|
|
63
62
|
}
|
|
64
|
-
function typograf(text, lang =
|
|
63
|
+
function typograf(text, lang = 'ru') {
|
|
65
64
|
const localeByLang = {
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
ru: ['ru', 'en-US'],
|
|
66
|
+
en: ['en-US', 'ru'],
|
|
68
67
|
};
|
|
69
68
|
const tp = new typograf_1.default({
|
|
70
69
|
locale: localeByLang[lang],
|
|
@@ -98,7 +97,7 @@ function fullTransform(input, _a) {
|
|
|
98
97
|
return Object.assign(Object.assign({}, result), { html: typograf(html, lang), title: title && typograf(title, lang) });
|
|
99
98
|
}
|
|
100
99
|
exports.fullTransform = fullTransform;
|
|
101
|
-
function typografEntity({ entity, fields, lang =
|
|
100
|
+
function typografEntity({ entity, fields, lang = 'ru', transformType = TransformType.Text, }) {
|
|
102
101
|
const transformTypeMap = {
|
|
103
102
|
text: typografToText,
|
|
104
103
|
html: typografToHTML,
|