@gravity-ui/page-constructor 4.16.0 → 4.18.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.
Files changed (48) hide show
  1. package/build/cjs/components/CardBase/CardBase.d.ts +1 -0
  2. package/build/cjs/components/CardBase/CardBase.js +2 -2
  3. package/build/cjs/components/FileLink/FileLink.js +2 -2
  4. package/build/cjs/components/Link/Link.js +2 -2
  5. package/build/cjs/components/Title/TitleItem.js +3 -3
  6. package/build/cjs/constructor-items.d.ts +1 -1
  7. package/build/cjs/editor/components/AddBlock/AddBlock.js +1 -1
  8. package/build/cjs/models/constructor-items/common.d.ts +3 -0
  9. package/build/cjs/models/constructor-items/sub-blocks.d.ts +1 -0
  10. package/build/cjs/models/navigation.d.ts +3 -0
  11. package/build/cjs/navigation/components/NavigationItem/components/GithubButton/GithubButton.d.ts +1 -1
  12. package/build/cjs/navigation/components/NavigationItem/components/GithubButton/GithubButton.js +2 -2
  13. package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js +3 -3
  14. package/build/cjs/navigation/components/SocialIcon/SocialIcon.js +2 -2
  15. package/build/cjs/navigation/utils.d.ts +1 -0
  16. package/build/cjs/sub-blocks/BackgroundCard/BackgroundCard.js +2 -2
  17. package/build/cjs/sub-blocks/LayoutItem/utils.d.ts +1 -0
  18. package/build/cjs/text-transform/config.d.ts +1 -0
  19. package/build/cjs/text-transform/utils.d.ts +2 -0
  20. package/build/cjs/text-transform/utils.js +7 -26
  21. package/build/esm/components/CardBase/CardBase.d.ts +1 -0
  22. package/build/esm/components/CardBase/CardBase.js +2 -2
  23. package/build/esm/components/FileLink/FileLink.js +2 -2
  24. package/build/esm/components/Link/Link.js +2 -2
  25. package/build/esm/components/Title/TitleItem.js +3 -3
  26. package/build/esm/constructor-items.d.ts +1 -1
  27. package/build/esm/editor/components/AddBlock/AddBlock.js +1 -1
  28. package/build/esm/models/constructor-items/common.d.ts +3 -0
  29. package/build/esm/models/constructor-items/sub-blocks.d.ts +1 -0
  30. package/build/esm/models/navigation.d.ts +3 -0
  31. package/build/esm/navigation/components/NavigationItem/components/GithubButton/GithubButton.d.ts +1 -1
  32. package/build/esm/navigation/components/NavigationItem/components/GithubButton/GithubButton.js +2 -2
  33. package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js +3 -3
  34. package/build/esm/navigation/components/SocialIcon/SocialIcon.js +2 -2
  35. package/build/esm/navigation/utils.d.ts +1 -0
  36. package/build/esm/sub-blocks/BackgroundCard/BackgroundCard.js +2 -2
  37. package/build/esm/sub-blocks/LayoutItem/utils.d.ts +1 -0
  38. package/build/esm/text-transform/config.d.ts +1 -0
  39. package/build/esm/text-transform/utils.d.ts +2 -0
  40. package/build/esm/text-transform/utils.js +5 -25
  41. package/package.json +1 -1
  42. package/server/models/constructor-items/common.d.ts +3 -0
  43. package/server/models/constructor-items/sub-blocks.d.ts +1 -0
  44. package/server/models/navigation.d.ts +3 -0
  45. package/server/text-transform/config.d.ts +1 -0
  46. package/server/text-transform/utils.d.ts +2 -0
  47. package/server/text-transform/utils.js +7 -26
  48. package/widget/index.js +1 -1
@@ -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
- Typograf.addRule({
38
- name: 'common/html/sup',
39
- queue: 'end',
40
- /* TODO mange with it: in typograf types AddRuleOptions.handler takes only one param: text.
41
- But in cloud-www was used this notation with 3 params */
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,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "4.16.0",
3
+ "version": "4.18.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -120,6 +120,7 @@ export interface MediaVideoProps extends AnalyticsEventsBase {
120
120
  }
121
121
  export interface LinkProps extends AnalyticsEventsBase, Stylable, Tabbable {
122
122
  url: string;
123
+ urlTitle?: string;
123
124
  text?: string;
124
125
  textSize?: TextSize;
125
126
  theme?: LinkTheme;
@@ -135,6 +136,7 @@ export interface FileLinkProps extends ClassNameProps, Tabbable {
135
136
  type?: FileLinkType;
136
137
  textSize?: TextSize;
137
138
  theme?: ContentTheme;
139
+ urlTitle?: string;
138
140
  onClick?: () => void;
139
141
  }
140
142
  export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
@@ -260,6 +262,7 @@ export interface TitleItemBaseProps {
260
262
  text: string;
261
263
  textSize?: TextSize;
262
264
  url?: string;
265
+ urlTitle?: string;
263
266
  custom?: string | ReactNode;
264
267
  onClick?: () => void;
265
268
  }
@@ -73,6 +73,7 @@ export interface QuoteProps extends Themable, CardBaseProps {
73
73
  }
74
74
  export interface BackgroundCardProps extends CardBaseProps, AnalyticsEventsBase, Omit<ContentBlockProps, 'colSizes' | 'centered'> {
75
75
  url?: string;
76
+ urlTitle?: string;
76
77
  background?: ThemeSupporting<ImageObjectProps>;
77
78
  paddingBottom?: 's' | 'm' | 'l' | 'xl';
78
79
  backgroundColor?: string;
@@ -29,6 +29,7 @@ export declare enum NavigationGithubButtonIcon {
29
29
  export interface NavigationGithubButton extends Omit<NavigationItemBase, 'icon'> {
30
30
  type: NavigationItemType.GithubButton;
31
31
  url: string;
32
+ urlTitle?: string;
32
33
  label?: string;
33
34
  icon?: keyof typeof NavigationGithubButtonIcon;
34
35
  size?: string;
@@ -36,6 +37,7 @@ export interface NavigationGithubButton extends Omit<NavigationItemBase, 'icon'>
36
37
  export interface NavigationLinkItem extends Omit<NavigationItemBase, 'url'> {
37
38
  type: NavigationItemType.Link;
38
39
  url: string;
40
+ urlTitle?: string;
39
41
  arrow?: boolean;
40
42
  target?: string;
41
43
  }
@@ -52,6 +54,7 @@ export interface NavigationSocialItem extends Omit<NavigationItemBase, 'text'> {
52
54
  type: NavigationItemType.Social;
53
55
  icon: ImageProps;
54
56
  url: string;
57
+ urlTitle?: string;
55
58
  }
56
59
  export type NavigationItemModel = NavigationLinkItem | NavigationButtonItem | NavigationDropdownItem;
57
60
  export type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | NavigationDropdownItem;
@@ -10,6 +10,7 @@ export declare const blockHeaderTransformer: ({
10
10
  justify?: import("../models").Justify | undefined;
11
11
  textSize?: import("../models").TextSize | undefined;
12
12
  url?: string | undefined;
13
+ urlTitle?: string | undefined;
13
14
  custom?: import("react").ReactNode;
14
15
  onClick?: (() => void) | undefined;
15
16
  };
@@ -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
- typograf_1.default.addRule({
54
- name: 'common/html/sup',
55
- queue: 'end',
56
- /* TODO mange with it: in typograf types AddRuleOptions.handler takes only one param: text.
57
- But in cloud-www was used this notation with 3 params */
58
- //@ts-ignore
59
- handler: function (text, settings, context) {
60
- const { prefs: { htmlEntity: { type = '' } = {} } = {} } = context;
61
- let symbols;
62
- switch (type) {
63
- case 'digit':
64
- symbols = '&#174;|&#169;|&#8482;';
65
- break;
66
- case 'name':
67
- symbols = '&reg;|&copy;|&trade;';
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));