@gravity-ui/page-constructor 4.15.0 → 4.15.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/text-transform/utils.d.ts +2 -0
- package/build/cjs/text-transform/utils.js +7 -26
- package/build/esm/text-transform/utils.d.ts +2 -0
- package/build/esm/text-transform/utils.js +5 -25
- package/package.json +1 -1
- package/server/text-transform/utils.d.ts +2 -0
- package/server/text-transform/utils.js +7 -26
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Options, Output } from '@doc-tools/transform';
|
|
2
2
|
import sanitize from 'sanitize-html';
|
|
3
3
|
import { Lang } from '../utils/configure';
|
|
4
|
+
import AddRuleOptions = typograf.AddRuleOptions;
|
|
4
5
|
export declare enum TransformType {
|
|
5
6
|
Text = "text",
|
|
6
7
|
Html = "html"
|
|
@@ -14,6 +15,7 @@ export declare const typografConfig: {
|
|
|
14
15
|
disabled: string[];
|
|
15
16
|
};
|
|
16
17
|
export declare const sanitizeStripOptions: sanitize.IOptions;
|
|
18
|
+
export declare function addTypografRules(options: AddRuleOptions[]): void;
|
|
17
19
|
export declare function typograf(text: string, lang?: Lang): string;
|
|
18
20
|
export declare function sanitizeHtml(html: string, options?: sanitize.IOptions): string;
|
|
19
21
|
export declare function typografToHTML(text: string, lang: Lang, allowedTags?: string[]): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.typografEntity = exports.fullTransform = exports.transformMarkdown = exports.typografToText = exports.typografToHTML = exports.sanitizeHtml = exports.typograf = exports.sanitizeStripOptions = exports.typografConfig = exports.DEFAULT_ALLOWED_TAGS = exports.TransformType = void 0;
|
|
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("@doc-tools/transform"));
|
|
6
6
|
const sanitize_html_1 = tslib_1.__importDefault(require("sanitize-html"));
|
|
@@ -37,31 +37,12 @@ exports.sanitizeStripOptions = {
|
|
|
37
37
|
allowedTags: [],
|
|
38
38
|
allowedAttributes: {},
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
handler: function (text, settings, context) {
|
|
47
|
-
const { prefs: { htmlEntity: { type = '' } = {} } = {} } = context;
|
|
48
|
-
let symbols;
|
|
49
|
-
switch (type) {
|
|
50
|
-
case 'digit':
|
|
51
|
-
symbols = '®|©|™';
|
|
52
|
-
break;
|
|
53
|
-
case 'name':
|
|
54
|
-
symbols = '®|©|™';
|
|
55
|
-
break;
|
|
56
|
-
default:
|
|
57
|
-
symbols = '®|©|™';
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
const symbolsRegex = new RegExp(`(?<!<sup>\\s*)(${symbols})|(${symbols})(?!\\s*<\\/sup>)`, 'gi');
|
|
61
|
-
return text.replace(symbolsRegex, '<sup>$1</sup>');
|
|
62
|
-
},
|
|
63
|
-
htmlAttrs: false,
|
|
64
|
-
});
|
|
40
|
+
function addTypografRules(options) {
|
|
41
|
+
options.forEach((option) => {
|
|
42
|
+
typograf_1.default.addRule(option);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.addTypografRules = addTypografRules;
|
|
65
46
|
function enableRules(tp) {
|
|
66
47
|
const { disabled, enabled } = exports.typografConfig;
|
|
67
48
|
enabled.forEach((rule) => tp.enableRule(rule));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Options, Output } from '@doc-tools/transform';
|
|
2
2
|
import sanitize from 'sanitize-html';
|
|
3
3
|
import { Lang } from '../utils/configure';
|
|
4
|
+
import AddRuleOptions = typograf.AddRuleOptions;
|
|
4
5
|
export declare enum TransformType {
|
|
5
6
|
Text = "text",
|
|
6
7
|
Html = "html"
|
|
@@ -14,6 +15,7 @@ export declare const typografConfig: {
|
|
|
14
15
|
disabled: string[];
|
|
15
16
|
};
|
|
16
17
|
export declare const sanitizeStripOptions: sanitize.IOptions;
|
|
18
|
+
export declare function addTypografRules(options: AddRuleOptions[]): void;
|
|
17
19
|
export declare function typograf(text: string, lang?: Lang): string;
|
|
18
20
|
export declare function sanitizeHtml(html: string, options?: sanitize.IOptions): string;
|
|
19
21
|
export declare function typografToHTML(text: string, lang: Lang, allowedTags?: string[]): string;
|
|
@@ -34,31 +34,11 @@ export const sanitizeStripOptions = {
|
|
|
34
34
|
allowedTags: [],
|
|
35
35
|
allowedAttributes: {},
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//@ts-ignore
|
|
43
|
-
handler: function (text, settings, context) {
|
|
44
|
-
const { prefs: { htmlEntity: { type = '' } = {} } = {} } = context;
|
|
45
|
-
let symbols;
|
|
46
|
-
switch (type) {
|
|
47
|
-
case 'digit':
|
|
48
|
-
symbols = '®|©|™';
|
|
49
|
-
break;
|
|
50
|
-
case 'name':
|
|
51
|
-
symbols = '®|©|™';
|
|
52
|
-
break;
|
|
53
|
-
default:
|
|
54
|
-
symbols = '®|©|™';
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
const symbolsRegex = new RegExp(`(?<!<sup>\\s*)(${symbols})|(${symbols})(?!\\s*<\\/sup>)`, 'gi');
|
|
58
|
-
return text.replace(symbolsRegex, '<sup>$1</sup>');
|
|
59
|
-
},
|
|
60
|
-
htmlAttrs: false,
|
|
61
|
-
});
|
|
37
|
+
export function addTypografRules(options) {
|
|
38
|
+
options.forEach((option) => {
|
|
39
|
+
Typograf.addRule(option);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
62
42
|
function enableRules(tp) {
|
|
63
43
|
const { disabled, enabled } = typografConfig;
|
|
64
44
|
enabled.forEach((rule) => tp.enableRule(rule));
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Options, Output } from '@doc-tools/transform';
|
|
2
2
|
import sanitize from 'sanitize-html';
|
|
3
3
|
import { Lang } from '../utils/configure';
|
|
4
|
+
import AddRuleOptions = typograf.AddRuleOptions;
|
|
4
5
|
export declare enum TransformType {
|
|
5
6
|
Text = "text",
|
|
6
7
|
Html = "html"
|
|
@@ -14,6 +15,7 @@ export declare const typografConfig: {
|
|
|
14
15
|
disabled: string[];
|
|
15
16
|
};
|
|
16
17
|
export declare const sanitizeStripOptions: sanitize.IOptions;
|
|
18
|
+
export declare function addTypografRules(options: AddRuleOptions[]): void;
|
|
17
19
|
export declare function typograf(text: string, lang?: Lang): string;
|
|
18
20
|
export declare function sanitizeHtml(html: string, options?: sanitize.IOptions): string;
|
|
19
21
|
export declare function typografToHTML(text: string, lang: Lang, allowedTags?: string[]): string;
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.typografEntity = exports.fullTransform = exports.transformMarkdown = exports.typografToText = exports.typografToHTML = exports.sanitizeHtml = exports.typograf = exports.sanitizeStripOptions = exports.typografConfig = exports.DEFAULT_ALLOWED_TAGS = exports.TransformType = void 0;
|
|
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("@doc-tools/transform"));
|
|
19
19
|
const sanitize_html_1 = __importDefault(require("sanitize-html"));
|
|
20
20
|
const typograf_1 = __importDefault(require("typograf"));
|
|
@@ -50,31 +50,12 @@ exports.sanitizeStripOptions = {
|
|
|
50
50
|
allowedTags: [],
|
|
51
51
|
allowedAttributes: {},
|
|
52
52
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
handler: function (text, settings, context) {
|
|
60
|
-
const { prefs: { htmlEntity: { type = '' } = {} } = {} } = context;
|
|
61
|
-
let symbols;
|
|
62
|
-
switch (type) {
|
|
63
|
-
case 'digit':
|
|
64
|
-
symbols = '®|©|™';
|
|
65
|
-
break;
|
|
66
|
-
case 'name':
|
|
67
|
-
symbols = '®|©|™';
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
symbols = '®|©|™';
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
const symbolsRegex = new RegExp(`(?<!<sup>\\s*)(${symbols})|(${symbols})(?!\\s*<\\/sup>)`, 'gi');
|
|
74
|
-
return text.replace(symbolsRegex, '<sup>$1</sup>');
|
|
75
|
-
},
|
|
76
|
-
htmlAttrs: false,
|
|
77
|
-
});
|
|
53
|
+
function addTypografRules(options) {
|
|
54
|
+
options.forEach((option) => {
|
|
55
|
+
typograf_1.default.addRule(option);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.addTypografRules = addTypografRules;
|
|
78
59
|
function enableRules(tp) {
|
|
79
60
|
const { disabled, enabled } = exports.typografConfig;
|
|
80
61
|
enabled.forEach((rule) => tp.enableRule(rule));
|