@evergis/react 4.0.98 → 4.0.99
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/dist/components/Dashboard/componentTypes.d.ts +1 -1
- package/dist/components/Dashboard/elements/ElementMarkdown/styled.d.ts +5 -2
- package/dist/components/Dashboard/types.d.ts +14 -0
- package/dist/index.js +36 -5
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +36 -5
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -74,7 +74,7 @@ export interface ElementLinkConfig extends Omit<ConfigContainerChild, "options"
|
|
|
74
74
|
export interface ElementLinkProps extends Omit<ContainerProps, "elementConfig"> {
|
|
75
75
|
elementConfig?: ElementLinkConfig;
|
|
76
76
|
}
|
|
77
|
-
export type ElementMarkdownOptions = Pick<ConfigOptions, "expandLength" | "noMargin">;
|
|
77
|
+
export type ElementMarkdownOptions = Pick<ConfigOptions, "expandLength" | "noMargin" | "typography">;
|
|
78
78
|
export interface ElementMarkdownConfig extends Omit<ConfigContainerChild, "options" | "type"> {
|
|
79
79
|
type?: "markdown";
|
|
80
80
|
options?: ElementMarkdownOptions;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { MarkdownTypography } from '../../types';
|
|
2
|
+
export interface MarkdownWrapperProps {
|
|
3
|
+
$typography?: MarkdownTypography;
|
|
2
4
|
$noMargin?: boolean;
|
|
3
|
-
}
|
|
5
|
+
}
|
|
6
|
+
export declare const MarkdownWrapper: import('styled-components').StyledComponent<"div", any, MarkdownWrapperProps, never>;
|
|
@@ -180,6 +180,19 @@ export interface ConfigLayoutOptions {
|
|
|
180
180
|
barWidth?: number;
|
|
181
181
|
barHeight?: number;
|
|
182
182
|
}
|
|
183
|
+
/** Теги markdown, для которых можно переопределить типографику из конфига. */
|
|
184
|
+
export type MarkdownTypographyTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "li" | "code";
|
|
185
|
+
/** Переопределение размера/интервала/начертания одного тега markdown. */
|
|
186
|
+
export interface MarkdownTagTypography {
|
|
187
|
+
fontSize?: FontSizeToken | string;
|
|
188
|
+
lineHeight?: string;
|
|
189
|
+
fontWeight?: number | string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Пер-тег типографика markdown-виджета. Отсутствующий тег или свойство —
|
|
193
|
+
* дефолт `MarkdownWrapper` (см. `elements/ElementMarkdown/styled.ts`).
|
|
194
|
+
*/
|
|
195
|
+
export type MarkdownTypography = Partial<Record<MarkdownTypographyTag, MarkdownTagTypography>>;
|
|
183
196
|
/** Типографика и цвета. */
|
|
184
197
|
export interface ConfigTypographyOptions {
|
|
185
198
|
fontSize?: string;
|
|
@@ -192,6 +205,7 @@ export interface ConfigTypographyOptions {
|
|
|
192
205
|
colors?: string[];
|
|
193
206
|
colorAttribute?: string;
|
|
194
207
|
statusColors?: Record<RemoteTaskStatus, string>;
|
|
208
|
+
typography?: MarkdownTypography;
|
|
195
209
|
}
|
|
196
210
|
/** Поведение «раскрытия». */
|
|
197
211
|
export interface ConfigExpandableOptions {
|
package/dist/index.js
CHANGED
|
@@ -10062,6 +10062,20 @@ const ElementLink = React.memo(({ type, elementConfig }) => {
|
|
|
10062
10062
|
: jsxRuntime.jsx(LocalLink, { style: style, link: link });
|
|
10063
10063
|
});
|
|
10064
10064
|
|
|
10065
|
+
/**
|
|
10066
|
+
* Пер-тег переопределение типографики из конфига. Пустой результат, если для тега
|
|
10067
|
+
* ничего не задано — тогда действует дефолт, объявленный в самом правиле тега.
|
|
10068
|
+
*/
|
|
10069
|
+
const tagTypography = (tag) => ({ $typography }) => {
|
|
10070
|
+
const style = $typography?.[tag];
|
|
10071
|
+
if (!style)
|
|
10072
|
+
return "";
|
|
10073
|
+
return styled.css `
|
|
10074
|
+
${style.fontSize && `font-size: ${style.fontSize};`}
|
|
10075
|
+
${style.lineHeight && `line-height: ${style.lineHeight};`}
|
|
10076
|
+
${style.fontWeight != null && `font-weight: ${style.fontWeight};`}
|
|
10077
|
+
`;
|
|
10078
|
+
};
|
|
10065
10079
|
const MarkdownWrapper = styled.div.withConfig({ displayName: "MarkdownWrapper", componentId: "sc-1iv8z8a" }) `
|
|
10066
10080
|
padding: 0;
|
|
10067
10081
|
background: transparent;
|
|
@@ -10076,6 +10090,7 @@ const MarkdownWrapper = styled.div.withConfig({ displayName: "MarkdownWrapper",
|
|
|
10076
10090
|
letter-spacing: 0.0052rem;
|
|
10077
10091
|
margin: 0 0 1rem 0;
|
|
10078
10092
|
font-weight: 400;
|
|
10093
|
+
${tagTypography("p")}
|
|
10079
10094
|
|
|
10080
10095
|
&:last-child {
|
|
10081
10096
|
margin-bottom: 0;
|
|
@@ -10091,16 +10106,31 @@ const MarkdownWrapper = styled.div.withConfig({ displayName: "MarkdownWrapper",
|
|
|
10091
10106
|
h1 {
|
|
10092
10107
|
font-size: 1.5rem;
|
|
10093
10108
|
line-height: 1.75rem;
|
|
10109
|
+
${tagTypography("h1")}
|
|
10094
10110
|
}
|
|
10095
10111
|
|
|
10096
10112
|
h2 {
|
|
10097
10113
|
font-size: 1.25rem;
|
|
10098
10114
|
line-height: 1.5rem;
|
|
10115
|
+
${tagTypography("h2")}
|
|
10099
10116
|
}
|
|
10100
10117
|
|
|
10101
10118
|
h3 {
|
|
10102
10119
|
font-size: 1rem;
|
|
10103
10120
|
line-height: 1.25rem;
|
|
10121
|
+
${tagTypography("h3")}
|
|
10122
|
+
}
|
|
10123
|
+
|
|
10124
|
+
h4 {
|
|
10125
|
+
${tagTypography("h4")}
|
|
10126
|
+
}
|
|
10127
|
+
|
|
10128
|
+
h5 {
|
|
10129
|
+
${tagTypography("h5")}
|
|
10130
|
+
}
|
|
10131
|
+
|
|
10132
|
+
h6 {
|
|
10133
|
+
${tagTypography("h6")}
|
|
10104
10134
|
}
|
|
10105
10135
|
|
|
10106
10136
|
/* Images */
|
|
@@ -10135,6 +10165,7 @@ const MarkdownWrapper = styled.div.withConfig({ displayName: "MarkdownWrapper",
|
|
|
10135
10165
|
font-size: 0.875rem;
|
|
10136
10166
|
line-height: 1rem;
|
|
10137
10167
|
margin-bottom: 0.5rem;
|
|
10168
|
+
${tagTypography("li")}
|
|
10138
10169
|
}
|
|
10139
10170
|
}
|
|
10140
10171
|
|
|
@@ -10145,6 +10176,7 @@ const MarkdownWrapper = styled.div.withConfig({ displayName: "MarkdownWrapper",
|
|
|
10145
10176
|
border-radius: 0.25rem;
|
|
10146
10177
|
font-family: monospace;
|
|
10147
10178
|
font-size: 0.8125rem;
|
|
10179
|
+
${tagTypography("code")}
|
|
10148
10180
|
}
|
|
10149
10181
|
|
|
10150
10182
|
pre {
|
|
@@ -10197,8 +10229,7 @@ const ElementMarkdown = React.memo(({ elementConfig, type }) => {
|
|
|
10197
10229
|
const { t } = useGlobalContext();
|
|
10198
10230
|
const [expanded, setExpanded] = React.useState(false);
|
|
10199
10231
|
const { attributeName, value, options } = elementConfig || {};
|
|
10200
|
-
const { noMargin } = options || {};
|
|
10201
|
-
const expandLength = options?.expandLength || 0;
|
|
10232
|
+
const { noMargin, expandLength = 0, typography } = options || {};
|
|
10202
10233
|
// Get Markdown content from:
|
|
10203
10234
|
// 1. value (static content)
|
|
10204
10235
|
// 2. attribute by attributeName (dynamic content from data)
|
|
@@ -10214,16 +10245,16 @@ const ElementMarkdown = React.memo(({ elementConfig, type }) => {
|
|
|
10214
10245
|
const shouldShowExpand = expandLength > 0 && markdownString.length > expandLength;
|
|
10215
10246
|
// If expand is not needed, show full content
|
|
10216
10247
|
if (!shouldShowExpand) {
|
|
10217
|
-
return (jsxRuntime.jsx(MarkdownWrapper, { "$noMargin": noMargin, children: jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], rehypePlugins: [rehypeRaw, [rehypeSanitize, sanitizeSchema]], children: markdownString }) }));
|
|
10248
|
+
return (jsxRuntime.jsx(MarkdownWrapper, { "$typography": typography, "$noMargin": noMargin, children: jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], rehypePlugins: [rehypeRaw, [rehypeSanitize, sanitizeSchema]], children: markdownString }) }));
|
|
10218
10249
|
}
|
|
10219
10250
|
// Collapsed state
|
|
10220
10251
|
if (!expanded) {
|
|
10221
10252
|
// Truncated content for collapsed state
|
|
10222
10253
|
const truncatedContent = markdownString.substring(0, expandLength);
|
|
10223
|
-
return (jsxRuntime.jsxs(MarkdownWrapper, { "$noMargin": noMargin, children: [jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], rehypePlugins: [rehypeRaw, [rehypeSanitize, sanitizeSchema]], children: truncatedContent }), jsxRuntime.jsx(uilibGl.LegendToggler, { onClick: () => setExpanded(true), children: t("more", { ns: "dashboard", defaultValue: "Подробнее" }) })] }));
|
|
10254
|
+
return (jsxRuntime.jsxs(MarkdownWrapper, { "$typography": typography, "$noMargin": noMargin, children: [jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], rehypePlugins: [rehypeRaw, [rehypeSanitize, sanitizeSchema]], children: truncatedContent }), jsxRuntime.jsx(uilibGl.LegendToggler, { onClick: () => setExpanded(true), children: t("more", { ns: "dashboard", defaultValue: "Подробнее" }) })] }));
|
|
10224
10255
|
}
|
|
10225
10256
|
// Expanded state
|
|
10226
|
-
return (jsxRuntime.jsxs(MarkdownWrapper, { "$noMargin": noMargin, children: [jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], rehypePlugins: [rehypeRaw, rehypeSanitize], children: markdownString }), jsxRuntime.jsx(uilibGl.LegendToggler, { toggled: true, onClick: () => setExpanded(false), children: t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) })] }));
|
|
10257
|
+
return (jsxRuntime.jsxs(MarkdownWrapper, { "$typography": typography, "$noMargin": noMargin, children: [jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], rehypePlugins: [rehypeRaw, [rehypeSanitize, sanitizeSchema]], children: markdownString }), jsxRuntime.jsx(uilibGl.LegendToggler, { toggled: true, onClick: () => setExpanded(false), children: t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) })] }));
|
|
10227
10258
|
});
|
|
10228
10259
|
|
|
10229
10260
|
const SmallPreviewContainer = styled.div.withConfig({ displayName: "SmallPreviewContainer", componentId: "sc-1tgzhdl" }) `
|