@evergis/react 3.1.92 → 3.1.94
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/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +27 -9
- package/dist/react.esm.js.map +1 -1
- package/package.json +6 -4
package/dist/react.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import { IconButton, Flex, transition, Chip, Icon, Description, FlexSpan, IconToggle, Popup, Menu, DraggableTree, shadows, Divider, LegendToggler, Tooltip as Tooltip$1, DropdownField, MultiSelectContainer, IconButtonButton, FlatButton, DraggableTreeContainer, Dialog, DialogTitle, ThemeProvider, darkTheme, DialogContent, CircularProgress, LinearProgress, H2, defaultTheme, Preview, Dropdown, Blank, Popover, UploaderItemArea, UploaderTitleWrapper, Uploader, NumberRangeSlider, useAsyncAutocomplete, AutoComplete, Checkbox, RangeNumberInput, dateFormat } from '@evergis/uilib-gl';
|
|
3
|
-
import { createContext, memo, useRef, useState,
|
|
3
|
+
import { createContext, memo, useRef, useState, useCallback, useEffect, useContext, useMemo, Fragment } from 'react';
|
|
4
4
|
import styled, { createGlobalStyle, css, useTheme } from 'styled-components';
|
|
5
5
|
import { lineChartClassNames, BarChart as BarChart$1, barChartClassNames, LineChart, PieChart } from '@evergis/charts';
|
|
6
6
|
import { AttributeType, generateId, GeometryType, RemoteTaskStatus } from '@evergis/api';
|
|
@@ -21,6 +21,8 @@ import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
|
|
|
21
21
|
import 'mapbox-gl/dist/mapbox-gl.css';
|
|
22
22
|
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
23
23
|
import ReactMarkdown from 'react-markdown';
|
|
24
|
+
import rehypeRaw from 'rehype-raw';
|
|
25
|
+
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
|
|
24
26
|
import remarkGfm from 'remark-gfm';
|
|
25
27
|
import { Terminal } from '@xterm/xterm';
|
|
26
28
|
import { FitAddon } from '@xterm/addon-fit';
|
|
@@ -3933,6 +3935,15 @@ const ServerNotificationsContext = createContext({});
|
|
|
3933
3935
|
const useServerNotifications = (url, initialized) => {
|
|
3934
3936
|
const hubConnection = useRef(null);
|
|
3935
3937
|
const [connection, setConnection] = useState(null);
|
|
3938
|
+
const subscribeNotifications = useCallback(() => {
|
|
3939
|
+
if (!connection || connection.state !== "Connected") {
|
|
3940
|
+
return;
|
|
3941
|
+
}
|
|
3942
|
+
connection
|
|
3943
|
+
.invoke("SubscribeNotifications", [])
|
|
3944
|
+
.then(() => console.info("Подписка `SubscribeNotifications` оформлена"))
|
|
3945
|
+
.catch(err => console.info("Ошибка подписки `SubscribeNotifications`:", err));
|
|
3946
|
+
}, [connection]);
|
|
3936
3947
|
useEffect(() => {
|
|
3937
3948
|
if (!initialized) {
|
|
3938
3949
|
return;
|
|
@@ -3941,6 +3952,7 @@ const useServerNotifications = (url, initialized) => {
|
|
|
3941
3952
|
.withUrl(`${url}?clientId=${generateId()}`, {
|
|
3942
3953
|
withCredentials: true,
|
|
3943
3954
|
})
|
|
3955
|
+
.withAutomaticReconnect({ nextRetryDelayInMilliseconds: () => 3000 })
|
|
3944
3956
|
.configureLogging(LogLevel.Information)
|
|
3945
3957
|
.build();
|
|
3946
3958
|
hubConnection.current
|
|
@@ -3953,10 +3965,9 @@ const useServerNotifications = (url, initialized) => {
|
|
|
3953
3965
|
if (!connection || connection.state !== "Connected") {
|
|
3954
3966
|
return;
|
|
3955
3967
|
}
|
|
3956
|
-
connection
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
.catch(err => console.info("Ошибка подписки `SubscribeNotifications`:", err));
|
|
3968
|
+
connection.onreconnecting(() => console.info("Переподключение к серверным нотификациям"));
|
|
3969
|
+
connection.onreconnected(subscribeNotifications);
|
|
3970
|
+
subscribeNotifications();
|
|
3960
3971
|
}, [connection]);
|
|
3961
3972
|
return connection;
|
|
3962
3973
|
};
|
|
@@ -8061,6 +8072,13 @@ const MarkdownWrapper = styled.div `
|
|
|
8061
8072
|
}
|
|
8062
8073
|
`;
|
|
8063
8074
|
|
|
8075
|
+
const sanitizeSchema = {
|
|
8076
|
+
...defaultSchema,
|
|
8077
|
+
attributes: {
|
|
8078
|
+
...defaultSchema.attributes,
|
|
8079
|
+
"*": [...(defaultSchema.attributes?.["*"] || []), "style"],
|
|
8080
|
+
},
|
|
8081
|
+
};
|
|
8064
8082
|
const ElementMarkdown = memo(({ elementConfig, type }) => {
|
|
8065
8083
|
const { attributes } = useWidgetContext(type);
|
|
8066
8084
|
const { t } = useGlobalContext();
|
|
@@ -8081,16 +8099,16 @@ const ElementMarkdown = memo(({ elementConfig, type }) => {
|
|
|
8081
8099
|
const shouldShowExpand = expandLength > 0 && markdownString.length > expandLength;
|
|
8082
8100
|
// If expand is not needed, show full content
|
|
8083
8101
|
if (!shouldShowExpand) {
|
|
8084
|
-
return (jsx(MarkdownWrapper, { children: jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: markdownString }) }));
|
|
8102
|
+
return (jsx(MarkdownWrapper, { children: jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], rehypePlugins: [rehypeRaw, [rehypeSanitize, sanitizeSchema]], children: markdownString }) }));
|
|
8085
8103
|
}
|
|
8086
8104
|
// Collapsed state
|
|
8087
8105
|
if (!expanded) {
|
|
8088
8106
|
// Truncated content for collapsed state
|
|
8089
8107
|
const truncatedContent = markdownString.substring(0, expandLength);
|
|
8090
|
-
return (jsxs(MarkdownWrapper, { children: [jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: truncatedContent }), jsx(LegendToggler, { onClick: () => setExpanded(true), children: t("more", { ns: "dashboard", defaultValue: "Подробнее" }) })] }));
|
|
8108
|
+
return (jsxs(MarkdownWrapper, { children: [jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], rehypePlugins: [rehypeRaw, [rehypeSanitize, sanitizeSchema]], children: truncatedContent }), jsx(LegendToggler, { onClick: () => setExpanded(true), children: t("more", { ns: "dashboard", defaultValue: "Подробнее" }) })] }));
|
|
8091
8109
|
}
|
|
8092
8110
|
// Expanded state
|
|
8093
|
-
return (jsxs(MarkdownWrapper, { children: [jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: markdownString }), jsx(LegendToggler, { toggled: true, onClick: () => setExpanded(false), children: t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) })] }));
|
|
8111
|
+
return (jsxs(MarkdownWrapper, { children: [jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], rehypePlugins: [rehypeRaw, rehypeSanitize], children: markdownString }), jsx(LegendToggler, { toggled: true, onClick: () => setExpanded(false), children: t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) })] }));
|
|
8094
8112
|
});
|
|
8095
8113
|
|
|
8096
8114
|
const SmallPreviewContainer = styled.div `
|
|
@@ -8423,7 +8441,7 @@ const ElementUploader = memo(({ elementConfig, type }) => {
|
|
|
8423
8441
|
if (index === -1)
|
|
8424
8442
|
return;
|
|
8425
8443
|
const resourceId = files[index].id;
|
|
8426
|
-
await api.file.deleteResource(resourceId);
|
|
8444
|
+
await api.file.deleteResource({ resourceId });
|
|
8427
8445
|
setFiles(currentFiles => currentFiles.filter(({ id }) => id !== resourceId));
|
|
8428
8446
|
}, [files]);
|
|
8429
8447
|
const renderTitle = useMemo(() => {
|