@gravity-ui/blog-constructor 2.1.0-alpha.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +22 -0
- package/build/cjs/blocks/Author/Author.js +2 -2
- package/build/cjs/components/FeedHeader/components/Controls/Controls.js +3 -2
- package/build/cjs/components/Paginator/Paginator.css +3 -0
- package/build/cjs/components/Paginator/components/PaginatorItem.js +31 -4
- package/build/cjs/components/PostInfo/components/Sharing.js +9 -16
- package/build/cjs/constructor/BlogConstructorProvider.d.ts +0 -2
- package/build/cjs/constructor/BlogConstructorProvider.js +1 -3
- package/build/cjs/models/common.d.ts +1 -3
- package/build/cjs/models/common.js +2 -6
- package/build/cjs/utils/common.d.ts +1 -0
- package/build/cjs/utils/common.js +6 -1
- package/build/esm/blocks/Author/Author.js +2 -2
- package/build/esm/components/FeedHeader/components/Controls/Controls.js +3 -2
- package/build/esm/components/Paginator/Paginator.css +3 -0
- package/build/esm/components/Paginator/components/PaginatorItem.js +9 -2
- package/build/esm/components/PostInfo/components/Sharing.js +10 -17
- package/build/esm/constructor/BlogConstructorProvider.d.ts +0 -2
- package/build/esm/constructor/BlogConstructorProvider.js +1 -3
- package/build/esm/models/common.d.ts +1 -3
- package/build/esm/models/common.js +1 -5
- package/build/esm/utils/common.d.ts +1 -0
- package/build/esm/utils/common.js +4 -0
- package/package.json +1 -4
- package/server/models/common.d.ts +1 -3
- package/server/models/common.js +2 -6
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.1.0](https://github.com/gravity-ui/blog-constructor/compare/v2.0.2...v2.1.0) (2023-04-06)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* change source field with author description ([#5](https://github.com/gravity-ui/blog-constructor/issues/5)) ([fb7151c](https://github.com/gravity-ui/blog-constructor/commit/fb7151ceac39b2e4407c7110da0314b87c4db72b))
|
9
|
+
|
10
|
+
## [2.0.2](https://github.com/gravity-ui/blog-constructor/compare/v2.0.1...v2.0.2) (2023-04-05)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* covering pagination buttons into 'a' tag ([#23](https://github.com/gravity-ui/blog-constructor/issues/23)) ([e603f2e](https://github.com/gravity-ui/blog-constructor/commit/e603f2e2b0f86d492132174a1c8172786e7a09a1))
|
16
|
+
|
17
|
+
## [2.0.1](https://github.com/gravity-ui/blog-constructor/compare/v2.0.0...v2.0.1) (2023-04-04)
|
18
|
+
|
19
|
+
|
20
|
+
### Bug Fixes
|
21
|
+
|
22
|
+
* throw virtualization threshold prop in Select ([#26](https://github.com/gravity-ui/blog-constructor/issues/26)) ([ccb0f19](https://github.com/gravity-ui/blog-constructor/commit/ccb0f19a904e54fd43ca66195da9e94925d0a26f))
|
23
|
+
* throw virtualization threshold prop in Select ([#26](https://github.com/gravity-ui/blog-constructor/issues/26)) ([0aa5aed](https://github.com/gravity-ui/blog-constructor/commit/0aa5aeda9a0afd99ae8590c6b666c033a12b7fba))
|
24
|
+
|
3
25
|
## [2.0.0](https://github.com/gravity-ui/blog-constructor/compare/v1.1.2...v2.0.0) (2023-04-03)
|
4
26
|
|
5
27
|
|
@@ -43,10 +43,10 @@ const Author = (props) => {
|
|
43
43
|
return {
|
44
44
|
firstName: (author === null || author === void 0 ? void 0 : author.firstName) || '',
|
45
45
|
secondName: (author === null || author === void 0 ? void 0 : author.secondName) || '',
|
46
|
-
description: (author === null || author === void 0 ? void 0 : author.
|
46
|
+
description: (author === null || author === void 0 ? void 0 : author.shortDescription) || '',
|
47
47
|
avatar: authorAvatar,
|
48
48
|
};
|
49
|
-
}, [author === null || author === void 0 ? void 0 : author.avatar, author === null || author === void 0 ? void 0 : author.firstName, author === null || author === void 0 ? void 0 : author.
|
49
|
+
}, [author === null || author === void 0 ? void 0 : author.avatar, author === null || author === void 0 ? void 0 : author.firstName, author === null || author === void 0 ? void 0 : author.shortDescription, author === null || author === void 0 ? void 0 : author.secondName, image]);
|
50
50
|
if (!(authorItem === null || authorItem === void 0 ? void 0 : authorItem.firstName) || !(authorItem === null || authorItem === void 0 ? void 0 : authorItem.secondName)) {
|
51
51
|
return null;
|
52
52
|
}
|
@@ -41,6 +41,7 @@ const cn_1 = require("../../../../utils/cn");
|
|
41
41
|
const b = (0, cn_1.block)('feed-controls');
|
42
42
|
const ICON_SIZE = 16;
|
43
43
|
const DEFAULT_PAGE = 1;
|
44
|
+
const VIRTUALIZATION_THRESHOLD = 1000;
|
44
45
|
const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery, queryParams, }) => {
|
45
46
|
const { hasLikes } = (0, react_1.useContext)(LikesContext_1.LikesContext);
|
46
47
|
const { savedOnly: savedOnlyInitial, search: searchInitial, tags: tagInitial, services: servicesInitial, } = queryParams || {};
|
@@ -91,13 +92,13 @@ const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery,
|
|
91
92
|
initial: [tagInitial],
|
92
93
|
list: tagsItems,
|
93
94
|
defaultLabel: (0, i18n_1.i18)(i18n_1.Keyset.AllTags),
|
94
|
-
}), disablePortal: true, renderOption: customRenders_1.renderOption })),
|
95
|
+
}), disablePortal: true, virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: customRenders_1.renderOption })),
|
95
96
|
services.length > 0 ? (react_1.default.createElement("div", { className: b('filter-item') },
|
96
97
|
react_1.default.createElement(uikit_1.Select, { className: b('select'), size: "xl", multiple: true, filterable: true, disablePortal: true, options: services, defaultValue: servicesItems, popupClassName: b('popup'), onUpdate: handleServicesSelect, placeholder: (0, i18n_1.i18)(i18n_1.Keyset.AllServices), renderControl: (0, customRenders_1.renderSwitcher)({
|
97
98
|
initial: servicesItems,
|
98
99
|
list: services,
|
99
100
|
defaultLabel: (0, i18n_1.i18)(i18n_1.Keyset.AllServices),
|
100
|
-
}), renderOption: customRenders_1.renderOption, renderFilter: customRenders_1.renderFilter }))) : null,
|
101
|
+
}), virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: customRenders_1.renderOption, renderFilter: customRenders_1.renderFilter }))) : null,
|
101
102
|
hasLikes ? (react_1.default.createElement("div", { className: b('filter-item', { 'width-auto': true }) },
|
102
103
|
react_1.default.createElement(uikit_1.Button, { view: 'outlined', className: b('saved-only-button', { savedOnly }), size: "xl", onClick: handleSavedOnly },
|
103
104
|
react_1.default.createElement(uikit_1.Icon, { data: Save_1.Save, size: ICON_SIZE, className: b('icon', { savedOnly }) }),
|
@@ -1,15 +1,42 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
4
24
|
};
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
26
|
exports.PaginatorItem = void 0;
|
7
|
-
const react_1 =
|
27
|
+
const react_1 = __importStar(require("react"));
|
8
28
|
const uikit_1 = require("@gravity-ui/uikit");
|
29
|
+
const LocaleContext_1 = require("../../../contexts/LocaleContext");
|
30
|
+
const common_1 = require("../../../utils/common");
|
9
31
|
const cn_1 = require("../../../utils/cn");
|
10
32
|
const b = (0, cn_1.block)('paginator');
|
11
33
|
const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, }) => {
|
34
|
+
const { locale } = (0, react_1.useContext)(LocaleContext_1.LocaleContext);
|
35
|
+
const urlPath = (0, common_1.getBlogPath)((locale === null || locale === void 0 ? void 0 : locale.pathPrefix) || '');
|
12
36
|
const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
|
13
|
-
|
37
|
+
const navTag = itemKey > 0 ? `${mods.type || 'page'}=${itemKey}` : itemKey;
|
38
|
+
const navigationLink = `${urlPath || ''}?${navTag}`;
|
39
|
+
return (react_1.default.createElement("a", { href: navigationLink, className: b('link', mods), onClick: (event) => event.preventDefault() },
|
40
|
+
react_1.default.createElement(uikit_1.Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) }, content)));
|
14
41
|
};
|
15
42
|
exports.PaginatorItem = PaginatorItem;
|
@@ -27,35 +27,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.Sharing = void 0;
|
30
|
-
const useAnalytics_1 = require("@gravity-ui/page-constructor/build/esm/hooks/useAnalytics");
|
31
|
-
const uikit_1 = require("@gravity-ui/uikit");
|
32
30
|
const react_1 = __importStar(require("react"));
|
31
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
33
32
|
const MobileContext_1 = require("../../../contexts/MobileContext");
|
34
|
-
const PostPageContext_1 = require("../../../contexts/PostPageContext");
|
35
33
|
const RouterContext_1 = require("../../../contexts/RouterContext");
|
36
|
-
const
|
37
|
-
const utils_1 = require("../../../counters/utils");
|
34
|
+
const PostPageContext_1 = require("../../../contexts/PostPageContext");
|
38
35
|
const i18n_1 = require("../../../i18n");
|
39
|
-
const
|
40
|
-
const common_1 = require("../../../models/common");
|
36
|
+
const common_1 = require("../../../utils/common");
|
41
37
|
const cn_1 = require("../../../utils/cn");
|
42
|
-
const
|
38
|
+
const utils_1 = require("../../../counters/utils");
|
43
39
|
// @ts-ignore
|
40
|
+
const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
|
41
|
+
const ShareArrowUp_1 = require("../../../icons/ShareArrowUp");
|
44
42
|
const b = (0, cn_1.block)('post-info');
|
45
43
|
const Sharing = ({ theme, metrikaGoal }) => {
|
46
44
|
const router = (0, react_1.useContext)(RouterContext_1.RouterContext);
|
47
45
|
const isMobile = (0, react_1.useContext)(MobileContext_1.MobileContext);
|
48
46
|
const { shareOptions } = (0, react_1.useContext)(PostPageContext_1.PostPageContext);
|
49
|
-
const
|
50
|
-
const handleMetrika = (0, react_1.useCallback)(() => {
|
47
|
+
const handleMetrika = () => {
|
51
48
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
|
52
|
-
}
|
53
|
-
const handleAnalytics = (0, react_1.useCallback)(() => {
|
54
|
-
handleAnalyticsGlobal();
|
55
|
-
handleMetrika();
|
56
|
-
}, [handleAnalyticsGlobal, handleMetrika]);
|
49
|
+
};
|
57
50
|
return (react_1.default.createElement("div", { className: b('item') },
|
58
51
|
react_1.default.createElement("span", { className: b('icon') },
|
59
|
-
react_1.default.createElement(uikit_1.SharePopover, { url: (0,
|
52
|
+
react_1.default.createElement(uikit_1.SharePopover, { url: (0, common_1.getAbsolutePath)(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: (0, i18n_1.i18)(i18n_1.Keyset.ActionShare), customIcon: ShareArrowUp_1.ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika: handleMetrika }))));
|
60
53
|
};
|
61
54
|
exports.Sharing = Sharing;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { AnalyticsContextProps } from '@gravity-ui/page-constructor/build/esm/context/analyticsContext';
|
3
2
|
import { RouterContextProps } from '../contexts/RouterContext';
|
4
3
|
import { UserContextProps } from '../contexts/UserContext';
|
5
4
|
import { DeviceContextProps } from '../contexts/DeviceContext';
|
@@ -12,7 +11,6 @@ export interface BlogConstructorProviderProps {
|
|
12
11
|
theme?: ThemeValueType;
|
13
12
|
user?: UserContextProps;
|
14
13
|
device?: DeviceContextProps;
|
15
|
-
analytics?: AnalyticsContextProps;
|
16
14
|
children?: React.ReactNode;
|
17
15
|
}
|
18
16
|
export declare const BlogConstructorProvider: React.FC<BlogConstructorProviderProps>;
|
@@ -25,7 +25,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
26
|
exports.BlogConstructorProvider = void 0;
|
27
27
|
const react_1 = __importStar(require("react"));
|
28
|
-
const analyticsContext_1 = require("@gravity-ui/page-constructor/build/esm/context/analyticsContext");
|
29
28
|
const MobileContext_1 = require("../contexts/MobileContext");
|
30
29
|
const LocaleContext_1 = require("../contexts/LocaleContext");
|
31
30
|
const RouterContext_1 = require("../contexts/RouterContext");
|
@@ -33,7 +32,7 @@ const UserContext_1 = require("../contexts/UserContext");
|
|
33
32
|
const DeviceContext_1 = require("../contexts/DeviceContext");
|
34
33
|
const ThemeValueContext_1 = require("../contexts/theme/ThemeValueContext");
|
35
34
|
const constants_1 = require("../constants");
|
36
|
-
const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, user = {}, device = {},
|
35
|
+
const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, user = {}, device = {}, children, }) => {
|
37
36
|
const context = [
|
38
37
|
react_1.default.createElement(ThemeValueContext_1.ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
|
39
38
|
react_1.default.createElement(LocaleContext_1.LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
|
@@ -41,7 +40,6 @@ const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = c
|
|
41
40
|
react_1.default.createElement(MobileContext_1.MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
|
42
41
|
react_1.default.createElement(UserContext_1.UserContext.Provider, { value: user, key: "user-context" }),
|
43
42
|
react_1.default.createElement(DeviceContext_1.DeviceContext.Provider, { value: device, key: "device-context" }),
|
44
|
-
react_1.default.createElement(analyticsContext_1.AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
|
45
43
|
].reduceRight((prev, provider) => react_1.default.cloneElement(provider, {}, prev), children);
|
46
44
|
return react_1.default.createElement(react_1.Fragment, null, context);
|
47
45
|
};
|
@@ -18,6 +18,7 @@ export type Author = {
|
|
18
18
|
secondName: string | null;
|
19
19
|
description: string | null;
|
20
20
|
fullDescription: string | null;
|
21
|
+
shortDescription: string | null;
|
21
22
|
} & {
|
22
23
|
[x: string]: string | null;
|
23
24
|
};
|
@@ -149,6 +150,3 @@ export type HandleChangeQueryParams = (params: Query) => void;
|
|
149
150
|
export type SetQueryType = (params: Query, options?: {
|
150
151
|
[y: string]: boolean;
|
151
152
|
}) => Promise<void> | void;
|
152
|
-
export declare enum DefaultEventNames {
|
153
|
-
ShareButton = "share-button-click"
|
154
|
-
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.BlockType = exports.Theme = void 0;
|
4
4
|
var Theme;
|
5
5
|
(function (Theme) {
|
6
6
|
Theme["Light"] = "light";
|
@@ -19,8 +19,4 @@ var BlockType;
|
|
19
19
|
BlockType["Suggest"] = "blog-suggest-block";
|
20
20
|
BlockType["Meta"] = "blog-meta-block";
|
21
21
|
BlockType["Feed"] = "blog-feed-block";
|
22
|
-
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
23
|
-
var DefaultEventNames;
|
24
|
-
(function (DefaultEventNames) {
|
25
|
-
DefaultEventNames["ShareButton"] = "share-button-click";
|
26
|
-
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|
22
|
+
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
@@ -34,6 +34,7 @@ type GetBreadcrumbsProps = {
|
|
34
34
|
tags?: Tag[];
|
35
35
|
pathPrefix?: string;
|
36
36
|
};
|
37
|
+
export declare const getBlogPath: (pathPrefix: string) => string;
|
37
38
|
export declare const getBreadcrumbs: ({ tags, pathPrefix }: GetBreadcrumbsProps) => HeaderBreadCrumbsProps;
|
38
39
|
export declare const isMetrikaExist: (goal: NewMetrikaGoal, existGoals: NewMetrikaGoal[]) => boolean;
|
39
40
|
export declare const getBlogElementMetrika: (blogCustomGoal: NewMetrikaGoal, existingGoals?: MetrikaGoal) => string | string[] | NewMetrikaGoal[];
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
11
11
|
return t;
|
12
12
|
};
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
-
exports.scrollOnPageChange = exports.getFeedQueryParams = exports.getBlogElementMetrika = exports.isMetrikaExist = exports.getBreadcrumbs = exports.updateContentSizes = exports.getTagFilterUrl = exports.postLikeStatus = exports.getTags = exports.scrollToHash = exports.getPageSearchParams = exports.getAbsolutePath = void 0;
|
14
|
+
exports.scrollOnPageChange = exports.getFeedQueryParams = exports.getBlogElementMetrika = exports.isMetrikaExist = exports.getBreadcrumbs = exports.getBlogPath = exports.updateContentSizes = exports.getTagFilterUrl = exports.postLikeStatus = exports.getTags = exports.scrollToHash = exports.getPageSearchParams = exports.getAbsolutePath = void 0;
|
15
15
|
const url_1 = require("url");
|
16
16
|
const lodash_1 = require("lodash");
|
17
17
|
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
@@ -65,6 +65,11 @@ const updateContentSizes = (_a) => {
|
|
65
65
|
return (Object.assign(Object.assign({}, contentData), { size: size || constants_1.CONTENT_DEFAULT_SIZE, colSizes: colSizes || constants_1.CONTENT_DEFAULT_COL_SIZES, theme: theme || constants_1.CONTENT_DEFAULT_THEME }));
|
66
66
|
};
|
67
67
|
exports.updateContentSizes = updateContentSizes;
|
68
|
+
const getBlogPath = (pathPrefix) => {
|
69
|
+
const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
|
70
|
+
return `${prefix}blog`;
|
71
|
+
};
|
72
|
+
exports.getBlogPath = getBlogPath;
|
68
73
|
const getBreadcrumbs = ({ tags, pathPrefix }) => {
|
69
74
|
const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
|
70
75
|
const breadcrumbs = {
|
@@ -18,10 +18,10 @@ export const Author = (props) => {
|
|
18
18
|
return {
|
19
19
|
firstName: (author === null || author === void 0 ? void 0 : author.firstName) || '',
|
20
20
|
secondName: (author === null || author === void 0 ? void 0 : author.secondName) || '',
|
21
|
-
description: (author === null || author === void 0 ? void 0 : author.
|
21
|
+
description: (author === null || author === void 0 ? void 0 : author.shortDescription) || '',
|
22
22
|
avatar: authorAvatar,
|
23
23
|
};
|
24
|
-
}, [author === null || author === void 0 ? void 0 : author.avatar, author === null || author === void 0 ? void 0 : author.firstName, author === null || author === void 0 ? void 0 : author.
|
24
|
+
}, [author === null || author === void 0 ? void 0 : author.avatar, author === null || author === void 0 ? void 0 : author.firstName, author === null || author === void 0 ? void 0 : author.shortDescription, author === null || author === void 0 ? void 0 : author.secondName, image]);
|
25
25
|
if (!(authorItem === null || authorItem === void 0 ? void 0 : authorItem.firstName) || !(authorItem === null || authorItem === void 0 ? void 0 : authorItem.secondName)) {
|
26
26
|
return null;
|
27
27
|
}
|
@@ -13,6 +13,7 @@ import './Controls.css';
|
|
13
13
|
const b = block('feed-controls');
|
14
14
|
const ICON_SIZE = 16;
|
15
15
|
const DEFAULT_PAGE = 1;
|
16
|
+
const VIRTUALIZATION_THRESHOLD = 1000;
|
16
17
|
export const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery, queryParams, }) => {
|
17
18
|
const { hasLikes } = useContext(LikesContext);
|
18
19
|
const { savedOnly: savedOnlyInitial, search: searchInitial, tags: tagInitial, services: servicesInitial, } = queryParams || {};
|
@@ -63,13 +64,13 @@ export const Controls = ({ setIsFetching, tags = [], services = [], handleChange
|
|
63
64
|
initial: [tagInitial],
|
64
65
|
list: tagsItems,
|
65
66
|
defaultLabel: i18(Keyset.AllTags),
|
66
|
-
}), disablePortal: true, renderOption: renderOption })),
|
67
|
+
}), disablePortal: true, virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: renderOption })),
|
67
68
|
services.length > 0 ? (React.createElement("div", { className: b('filter-item') },
|
68
69
|
React.createElement(Select, { className: b('select'), size: "xl", multiple: true, filterable: true, disablePortal: true, options: services, defaultValue: servicesItems, popupClassName: b('popup'), onUpdate: handleServicesSelect, placeholder: i18(Keyset.AllServices), renderControl: renderSwitcher({
|
69
70
|
initial: servicesItems,
|
70
71
|
list: services,
|
71
72
|
defaultLabel: i18(Keyset.AllServices),
|
72
|
-
}), renderOption: renderOption, renderFilter: renderFilter }))) : null,
|
73
|
+
}), virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: renderOption, renderFilter: renderFilter }))) : null,
|
73
74
|
hasLikes ? (React.createElement("div", { className: b('filter-item', { 'width-auto': true }) },
|
74
75
|
React.createElement(Button, { view: 'outlined', className: b('saved-only-button', { savedOnly }), size: "xl", onClick: handleSavedOnly },
|
75
76
|
React.createElement(Icon, { data: Save, size: ICON_SIZE, className: b('icon', { savedOnly }) }),
|
@@ -1,9 +1,16 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { useContext } from 'react';
|
2
2
|
import { Button } from '@gravity-ui/uikit';
|
3
|
+
import { LocaleContext } from '../../../contexts/LocaleContext';
|
4
|
+
import { getBlogPath } from '../../../utils/common';
|
3
5
|
import { block } from '../../../utils/cn';
|
4
6
|
import '../Paginator.css';
|
5
7
|
const b = block('paginator');
|
6
8
|
export const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, }) => {
|
9
|
+
const { locale } = useContext(LocaleContext);
|
10
|
+
const urlPath = getBlogPath((locale === null || locale === void 0 ? void 0 : locale.pathPrefix) || '');
|
7
11
|
const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
|
8
|
-
|
12
|
+
const navTag = itemKey > 0 ? `${mods.type || 'page'}=${itemKey}` : itemKey;
|
13
|
+
const navigationLink = `${urlPath || ''}?${navTag}`;
|
14
|
+
return (React.createElement("a", { href: navigationLink, className: b('link', mods), onClick: (event) => event.preventDefault() },
|
15
|
+
React.createElement(Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) }, content)));
|
9
16
|
};
|
@@ -1,32 +1,25 @@
|
|
1
|
-
import {
|
1
|
+
import React, { useContext } from 'react';
|
2
2
|
import { SharePopover } from '@gravity-ui/uikit';
|
3
|
-
import React, { useCallback, useContext } from 'react';
|
4
3
|
import { MobileContext } from '../../../contexts/MobileContext';
|
5
|
-
import { PostPageContext } from '../../../contexts/PostPageContext';
|
6
4
|
import { RouterContext } from '../../../contexts/RouterContext';
|
7
|
-
import
|
8
|
-
import {
|
9
|
-
import { Keyset, i18 } from '../../../i18n';
|
10
|
-
import { ShareArrowUp } from '../../../icons/ShareArrowUp';
|
11
|
-
import { DefaultEventNames } from '../../../models/common';
|
12
|
-
import { block } from '../../../utils/cn';
|
5
|
+
import { PostPageContext } from '../../../contexts/PostPageContext';
|
6
|
+
import { i18, Keyset } from '../../../i18n';
|
13
7
|
import { getAbsolutePath } from '../../../utils/common';
|
8
|
+
import { block } from '../../../utils/cn';
|
9
|
+
import { MetrikaCounter } from '../../../counters/utils';
|
14
10
|
// @ts-ignore
|
11
|
+
import metrika from '../../../counters/metrika.js';
|
12
|
+
import { ShareArrowUp } from '../../../icons/ShareArrowUp';
|
15
13
|
import '../PostInfo.css';
|
16
14
|
const b = block('post-info');
|
17
15
|
export const Sharing = ({ theme, metrikaGoal }) => {
|
18
16
|
const router = useContext(RouterContext);
|
19
17
|
const isMobile = useContext(MobileContext);
|
20
18
|
const { shareOptions } = useContext(PostPageContext);
|
21
|
-
const
|
22
|
-
const handleMetrika = useCallback(() => {
|
19
|
+
const handleMetrika = () => {
|
23
20
|
metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
|
24
|
-
}
|
25
|
-
const handleAnalytics = useCallback(() => {
|
26
|
-
handleAnalyticsGlobal();
|
27
|
-
handleMetrika();
|
28
|
-
}, [handleAnalyticsGlobal, handleMetrika]);
|
21
|
+
};
|
29
22
|
return (React.createElement("div", { className: b('item') },
|
30
23
|
React.createElement("span", { className: b('icon') },
|
31
|
-
React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: i18(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika:
|
24
|
+
React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: i18(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika: handleMetrika }))));
|
32
25
|
};
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { AnalyticsContextProps } from '@gravity-ui/page-constructor/build/esm/context/analyticsContext';
|
3
2
|
import { RouterContextProps } from '../contexts/RouterContext';
|
4
3
|
import { UserContextProps } from '../contexts/UserContext';
|
5
4
|
import { DeviceContextProps } from '../contexts/DeviceContext';
|
@@ -12,7 +11,6 @@ export interface BlogConstructorProviderProps {
|
|
12
11
|
theme?: ThemeValueType;
|
13
12
|
user?: UserContextProps;
|
14
13
|
device?: DeviceContextProps;
|
15
|
-
analytics?: AnalyticsContextProps;
|
16
14
|
children?: React.ReactNode;
|
17
15
|
}
|
18
16
|
export declare const BlogConstructorProvider: React.FC<BlogConstructorProviderProps>;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import React, { Fragment } from 'react';
|
2
|
-
import { AnalyticsContext, } from '@gravity-ui/page-constructor/build/esm/context/analyticsContext';
|
3
2
|
import { MobileContext } from '../contexts/MobileContext';
|
4
3
|
import { LocaleContext } from '../contexts/LocaleContext';
|
5
4
|
import { RouterContext } from '../contexts/RouterContext';
|
@@ -7,7 +6,7 @@ import { UserContext } from '../contexts/UserContext';
|
|
7
6
|
import { DeviceContext } from '../contexts/DeviceContext';
|
8
7
|
import { ThemeValueContext } from '../contexts/theme/ThemeValueContext';
|
9
8
|
import { DEFAULT_THEME } from '../constants';
|
10
|
-
export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, user = {}, device = {},
|
9
|
+
export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, user = {}, device = {}, children, }) => {
|
11
10
|
const context = [
|
12
11
|
React.createElement(ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
|
13
12
|
React.createElement(LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
|
@@ -15,7 +14,6 @@ export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, th
|
|
15
14
|
React.createElement(MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
|
16
15
|
React.createElement(UserContext.Provider, { value: user, key: "user-context" }),
|
17
16
|
React.createElement(DeviceContext.Provider, { value: device, key: "device-context" }),
|
18
|
-
React.createElement(AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
|
19
17
|
].reduceRight((prev, provider) => React.cloneElement(provider, {}, prev), children);
|
20
18
|
return React.createElement(Fragment, null, context);
|
21
19
|
};
|
@@ -18,6 +18,7 @@ export type Author = {
|
|
18
18
|
secondName: string | null;
|
19
19
|
description: string | null;
|
20
20
|
fullDescription: string | null;
|
21
|
+
shortDescription: string | null;
|
21
22
|
} & {
|
22
23
|
[x: string]: string | null;
|
23
24
|
};
|
@@ -149,6 +150,3 @@ export type HandleChangeQueryParams = (params: Query) => void;
|
|
149
150
|
export type SetQueryType = (params: Query, options?: {
|
150
151
|
[y: string]: boolean;
|
151
152
|
}) => Promise<void> | void;
|
152
|
-
export declare enum DefaultEventNames {
|
153
|
-
ShareButton = "share-button-click"
|
154
|
-
}
|
@@ -16,8 +16,4 @@ export var BlockType;
|
|
16
16
|
BlockType["Suggest"] = "blog-suggest-block";
|
17
17
|
BlockType["Meta"] = "blog-meta-block";
|
18
18
|
BlockType["Feed"] = "blog-feed-block";
|
19
|
-
})(BlockType || (BlockType = {}));
|
20
|
-
export var DefaultEventNames;
|
21
|
-
(function (DefaultEventNames) {
|
22
|
-
DefaultEventNames["ShareButton"] = "share-button-click";
|
23
|
-
})(DefaultEventNames || (DefaultEventNames = {}));
|
19
|
+
})(BlockType || (BlockType = {}));
|
@@ -34,6 +34,7 @@ type GetBreadcrumbsProps = {
|
|
34
34
|
tags?: Tag[];
|
35
35
|
pathPrefix?: string;
|
36
36
|
};
|
37
|
+
export declare const getBlogPath: (pathPrefix: string) => string;
|
37
38
|
export declare const getBreadcrumbs: ({ tags, pathPrefix }: GetBreadcrumbsProps) => HeaderBreadCrumbsProps;
|
38
39
|
export declare const isMetrikaExist: (goal: NewMetrikaGoal, existGoals: NewMetrikaGoal[]) => boolean;
|
39
40
|
export declare const getBlogElementMetrika: (blogCustomGoal: NewMetrikaGoal, existingGoals?: MetrikaGoal) => string | string[] | NewMetrikaGoal[];
|
@@ -57,6 +57,10 @@ export const updateContentSizes = (_a) => {
|
|
57
57
|
var { size, colSizes, theme } = _a, contentData = __rest(_a, ["size", "colSizes", "theme"]);
|
58
58
|
return (Object.assign(Object.assign({}, contentData), { size: size || CONTENT_DEFAULT_SIZE, colSizes: colSizes || CONTENT_DEFAULT_COL_SIZES, theme: theme || CONTENT_DEFAULT_THEME }));
|
59
59
|
};
|
60
|
+
export const getBlogPath = (pathPrefix) => {
|
61
|
+
const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
|
62
|
+
return `${prefix}blog`;
|
63
|
+
};
|
60
64
|
export const getBreadcrumbs = ({ tags, pathPrefix }) => {
|
61
65
|
const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
|
62
66
|
const breadcrumbs = {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gravity-ui/blog-constructor",
|
3
|
-
"version": "2.1.0
|
3
|
+
"version": "2.1.0",
|
4
4
|
"description": "Gravity UI Blog Constructor",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": {
|
@@ -140,8 +140,5 @@
|
|
140
140
|
"*.{json,yaml,yml,md}": [
|
141
141
|
"prettier --write"
|
142
142
|
]
|
143
|
-
},
|
144
|
-
"publishConfig": {
|
145
|
-
"tag": "alpha"
|
146
143
|
}
|
147
144
|
}
|
@@ -18,6 +18,7 @@ export type Author = {
|
|
18
18
|
secondName: string | null;
|
19
19
|
description: string | null;
|
20
20
|
fullDescription: string | null;
|
21
|
+
shortDescription: string | null;
|
21
22
|
} & {
|
22
23
|
[x: string]: string | null;
|
23
24
|
};
|
@@ -149,6 +150,3 @@ export type HandleChangeQueryParams = (params: Query) => void;
|
|
149
150
|
export type SetQueryType = (params: Query, options?: {
|
150
151
|
[y: string]: boolean;
|
151
152
|
}) => Promise<void> | void;
|
152
|
-
export declare enum DefaultEventNames {
|
153
|
-
ShareButton = "share-button-click"
|
154
|
-
}
|
package/server/models/common.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.BlockType = exports.Theme = void 0;
|
4
4
|
var Theme;
|
5
5
|
(function (Theme) {
|
6
6
|
Theme["Light"] = "light";
|
@@ -19,8 +19,4 @@ var BlockType;
|
|
19
19
|
BlockType["Suggest"] = "blog-suggest-block";
|
20
20
|
BlockType["Meta"] = "blog-meta-block";
|
21
21
|
BlockType["Feed"] = "blog-feed-block";
|
22
|
-
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
23
|
-
var DefaultEventNames;
|
24
|
-
(function (DefaultEventNames) {
|
25
|
-
DefaultEventNames["ShareButton"] = "share-button-click";
|
26
|
-
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|
22
|
+
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|