@riil-frontend/component-topology 6.0.0-alpha.34 → 6.0.0-alpha.37

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 (51) hide show
  1. package/build/1.js +2 -2
  2. package/build/2.js +1 -1
  3. package/build/index.css +1 -1
  4. package/build/index.js +19 -19
  5. package/es/components/ColorPanel/components/ColorBlock/index.module.scss +1 -0
  6. package/es/components/ColorPanel/components/FontColorRange/index.module.scss +3 -4
  7. package/es/components/ColorPanel/index.module.scss +4 -3
  8. package/es/components/collapse/Collapse.module.scss +5 -4
  9. package/es/core/components/TopoView/GraphViewPanel.js +1 -0
  10. package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +10 -67
  11. package/es/core/editor/components/Sidebar/views/CanvasPanel/themes.js +42 -0
  12. package/es/core/editor/components/Sidebar/views/CanvasPanel/useCanvasThemeConfig.js +116 -0
  13. package/es/core/editor/components/Sidebar/views/ImagePanel/HtCustomImagePanel.js +12 -1
  14. package/es/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.js +12 -2
  15. package/es/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.module.scss +1 -1
  16. package/es/core/editor/components/Toolbar/widgets/EdgeColorButton/Content.js +12 -3
  17. package/es/core/editor/components/Toolbar/widgets/EdgeColorButton/EdgeColorButton.js +2 -2
  18. package/es/core/editor/components/Toolbar/widgets/NodeAlignWidget.js +11 -31
  19. package/es/core/editor/components/Toolbar/widgets/NodeAlignWidget.module.scss +11 -6
  20. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/colorUtil.js +50 -0
  21. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/edgeTag.js +7 -2
  22. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +20 -5
  23. package/es/core/editor/components/settings/common/AlignSetting/AlignSetting.module.scss +3 -2
  24. package/es/core/editor/components/settings/common/AlignSetting/AlignTypeList.js +34 -30
  25. package/es/core/editor/components/settings/common/AlignSetting/index.js +3 -3
  26. package/es/core/hooks/useCanvasTheme.js +26 -12
  27. package/es/core/models/TopoApp.js +1 -1
  28. package/lib/components/ColorPanel/components/ColorBlock/index.module.scss +1 -0
  29. package/lib/components/ColorPanel/components/FontColorRange/index.module.scss +3 -4
  30. package/lib/components/ColorPanel/index.module.scss +4 -3
  31. package/lib/components/collapse/Collapse.module.scss +5 -4
  32. package/lib/core/components/TopoView/GraphViewPanel.js +1 -0
  33. package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +11 -66
  34. package/lib/core/editor/components/Sidebar/views/CanvasPanel/themes.js +47 -0
  35. package/lib/core/editor/components/Sidebar/views/CanvasPanel/useCanvasThemeConfig.js +128 -0
  36. package/lib/core/editor/components/Sidebar/views/ImagePanel/HtCustomImagePanel.js +13 -1
  37. package/lib/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.js +13 -2
  38. package/lib/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.module.scss +1 -1
  39. package/lib/core/editor/components/Toolbar/widgets/EdgeColorButton/Content.js +12 -3
  40. package/lib/core/editor/components/Toolbar/widgets/EdgeColorButton/EdgeColorButton.js +2 -2
  41. package/lib/core/editor/components/Toolbar/widgets/NodeAlignWidget.js +11 -31
  42. package/lib/core/editor/components/Toolbar/widgets/NodeAlignWidget.module.scss +11 -6
  43. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/colorUtil.js +61 -0
  44. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/edgeTag.js +7 -2
  45. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +20 -5
  46. package/lib/core/editor/components/settings/common/AlignSetting/AlignSetting.module.scss +3 -2
  47. package/lib/core/editor/components/settings/common/AlignSetting/AlignTypeList.js +33 -29
  48. package/lib/core/editor/components/settings/common/AlignSetting/index.js +3 -3
  49. package/lib/core/hooks/useCanvasTheme.js +26 -12
  50. package/lib/core/models/TopoApp.js +1 -1
  51. package/package.json +3 -2
@@ -1,19 +1,34 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import fontStyleUtil from "../../../../../../settings/common/text/fontStyleUtil";
3
+ import { formatBackgroundRgbaColor, parseColor } from "../colorUtil";
3
4
  export function getTextStyle(element) {
5
+ var _background$rgb;
6
+
4
7
  var underline = element.s('text.decoration') === 'underline';
8
+ var background = parseColor(element.s('textBackground'));
5
9
  return _extends({
6
- color: null,
10
+ color: parseColor(element.s('text.color')),
7
11
  underline: underline
8
- }, fontStyleUtil.toMap(element.s('text.font')));
12
+ }, fontStyleUtil.toMap(element.s('text.font')), {
13
+ background: background,
14
+ // 背景颜色,格式: {rgba: {}, hex: ''} | null
15
+ opacity: background === null || background === void 0 ? void 0 : (_background$rgb = background.rgb) === null || _background$rgb === void 0 ? void 0 : _background$rgb.a // 背景透明度。值范围 0-1, null,null表示无
16
+
17
+ });
9
18
  }
10
19
  export function setTextStyle(element, style) {
11
- var underline = style.underline;
12
-
13
20
  if ('underline' in style) {
14
- element.s('text.decoration', underline ? 'underline' : null);
21
+ element.s('text.decoration', style.underline ? 'underline' : null);
15
22
  }
16
23
 
24
+ if ('color' in style) {
25
+ element.s('text.color', style.color.hex);
26
+ } // 背景颜色
27
+
28
+
29
+ var prevStyle = getTextStyle(element);
30
+ element.s('textBackground', formatBackgroundRgbaColor(prevStyle, style));
31
+
17
32
  var fontStyle = _extends({}, getTextStyle(element), style);
18
33
 
19
34
  var fontStr = fontStyleUtil.build(fontStyle);
@@ -1,12 +1,13 @@
1
1
  @import "@alifd/next/variables";
2
2
 
3
3
  .AlignSetting {
4
+ margin: 11px 7px 17px 7px;
4
5
  :global {
5
6
  .#{$css-prefix}divider-ver {
6
7
  background: #EBECF0;
7
8
  margin-right: 3px;
8
9
  height: 16px;
9
-
10
+ width:1px;
10
11
  }
11
12
  }
12
13
 
@@ -16,7 +17,7 @@
16
17
  border-radius: 4px;
17
18
  border: none !important;
18
19
  color: #4D6277;
19
- padding-left: 6px;
20
+ padding-left: 2px;
20
21
  margin-right: 3px;
21
22
 
22
23
  &:active {
@@ -1,48 +1,49 @@
1
1
  import _Button from "@alifd/next/es/button";
2
2
  import _Icon from "@alifd/next/es/icon";
3
3
  import _Divider from "@alifd/next/es/divider";
4
- import React, { useState } from "react";
4
+ import React, { useState } from 'react';
5
5
  import styles from "./AlignSetting.module.scss";
6
6
  var TREE_LAYOUT_OPTIONS = [{
7
- value: "left",
8
- label: "左对齐",
9
- icon: "tuopu_zuoceduiqi"
7
+ value: 'left',
8
+ label: '左对齐',
9
+ icon: 'tuopu_zuoceduiqi'
10
10
  }, {
11
- value: "center",
12
- label: "水平居中",
13
- icon: "tuopu_shuipingjuzhongduiqi"
11
+ value: 'center',
12
+ label: '水平居中',
13
+ icon: 'tuopu_shuipingjuzhongduiqi'
14
14
  }, {
15
- value: "right",
16
- label: "右对齐",
17
- icon: "tuopu_youceduiqi"
15
+ value: 'right',
16
+ label: '右对齐',
17
+ icon: 'tuopu_youceduiqi'
18
18
  }, {
19
- value: "top",
20
- label: "靠上对齐",
21
- icon: "tuopu_dingbuduiqi"
19
+ value: 'top',
20
+ label: '靠上对齐',
21
+ icon: 'tuopu_dingbuduiqi'
22
22
  }, {
23
- value: "middle",
24
- label: "垂直居中",
25
- icon: "tuopu_chuizhijuzhongduiqi"
23
+ value: 'middle',
24
+ label: '垂直居中',
25
+ icon: 'tuopu_chuizhijuzhongduiqi'
26
26
  }, {
27
- value: "bottom",
28
- label: "靠下对齐",
29
- icon: "tuopu_dibuduiqi"
27
+ value: 'bottom',
28
+ label: '靠下对齐',
29
+ icon: 'tuopu_dibuduiqi'
30
30
  }, {
31
- value: "divide"
31
+ value: 'divide'
32
32
  }, {
33
- value: "distributeHorizontal",
34
- label: "横向分布",
35
- icon: "tuopu_shuipingdengjianjuduiqi"
33
+ value: 'distributeHorizontal',
34
+ label: '横向分布',
35
+ icon: 'tuopu_shuipingdengjianjuduiqi'
36
36
  }, {
37
- value: "distributeVertical",
38
- label: "纵向分布",
39
- icon: "tuopu_chuizhidengjianjuduiqi"
37
+ value: 'distributeVertical',
38
+ label: '纵向分布',
39
+ icon: 'tuopu_chuizhidengjianjuduiqi'
40
40
  }];
41
41
 
42
42
  var AlignTypeList = function AlignTypeList(props) {
43
43
  var _props$selected = props.selected,
44
- selected = _props$selected === void 0 ? "left" : _props$selected,
45
- onChange = props.onChange;
44
+ selected = _props$selected === void 0 ? 'left' : _props$selected,
45
+ onChange = props.onChange,
46
+ distributionDisabled = props.distributionDisabled;
46
47
 
47
48
  var _useState = useState(selected),
48
49
  value = _useState[0],
@@ -57,16 +58,19 @@ var AlignTypeList = function AlignTypeList(props) {
57
58
  return /*#__PURE__*/React.createElement("div", {
58
59
  className: styles.AlignSetting
59
60
  }, TREE_LAYOUT_OPTIONS.map(function (item, index, array) {
60
- return item.value === "divide" ? /*#__PURE__*/React.createElement(_Divider, {
61
+ return item.value === 'divide' ? /*#__PURE__*/React.createElement(_Divider, {
61
62
  key: index,
62
63
  direction: "ver"
63
64
  }) : /*#__PURE__*/React.createElement(_Button, {
64
65
  key: index,
65
66
  className: "" + styles.redioBtn,
67
+ text: true,
66
68
  onClick: function onClick() {
67
69
  handleChange(item);
68
70
  },
69
- title: item.label
71
+ title: item.label // eslint-disable-next-line no-unneeded-ternary
72
+ ,
73
+ disabled: (item.value === 'distributeHorizontal' || item.value === 'distributeVertical') && distributionDisabled
70
74
  }, /*#__PURE__*/React.createElement(_Icon, {
71
75
  type: item.icon
72
76
  }));
@@ -3,10 +3,9 @@ import { isEdge, isLayer } from "../../../../../../utils/htElementUtils";
3
3
  import AlignTypeList from "./AlignTypeList";
4
4
  export default function AlignSetting(props) {
5
5
  var topo = props.topo,
6
- getClickType = props.getClickType;
6
+ distributionDisabled = props.distributionDisabled;
7
7
 
8
8
  var alignOnChange = function alignOnChange(type) {
9
- getClickType(type);
10
9
  topo.historyManager.beginTransaction();
11
10
  var selection = topo.getHtTopo().getGraphView().getSelectionModel().getSelection().toArray();
12
11
  var nodes = selection.filter(function (ele) {
@@ -19,6 +18,7 @@ export default function AlignSetting(props) {
19
18
 
20
19
  return /*#__PURE__*/React.createElement(AlignTypeList, {
21
20
  onChange: alignOnChange,
22
- selected: "left"
21
+ selected: "left",
22
+ distributionDisabled: distributionDisabled
23
23
  });
24
24
  }
@@ -1,34 +1,48 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useEffect } from 'react';
3
3
  var themeMap = [{
4
- value: 'white',
4
+ name: 'white',
5
5
  label: '白色',
6
- color: '#FFFFFF'
6
+ color: null,
7
+ toolsTheme: 'lightgrayblue'
7
8
  }, {
8
- value: 'lightblue',
9
+ name: 'lightblue',
9
10
  label: '蓝色',
10
- color: '#F9FBFF'
11
+ color: '#F9FBFF',
12
+ toolsTheme: 'white'
11
13
  }, {
12
- value: 'yellow',
14
+ name: 'yellow',
13
15
  label: '黄色',
14
16
  color: '#FFFDE6'
15
17
  }, {
16
- value: 'green',
18
+ name: 'green',
17
19
  label: '绿色',
18
20
  color: '#EAFFE8'
19
21
  }, {
20
- value: 'dark',
22
+ name: 'dark',
21
23
  label: '深色',
22
- color: '#031425'
24
+ color: '#031425',
25
+ toolsTheme: 'black'
23
26
  }].reduce(function (map, item) {
24
27
  var _extends2;
25
28
 
26
- return _extends({}, map, (_extends2 = {}, _extends2[item.value] = item, _extends2));
29
+ return _extends({}, map, (_extends2 = {}, _extends2[item.name] = item, _extends2));
27
30
  }, {});
28
31
  export default function useCanvasTheme(props) {
29
- var canvasTheme = props.canvasTheme;
30
- useEffect(function () {// 设置
31
- }, [canvasTheme]);
32
+ var topo = props.topo,
33
+ canvasTheme = props.canvasTheme; // 拓扑图是否加载
34
+
35
+ var _topo$store$useModelS = topo.store.useModelState('topoMod'),
36
+ graphLoaded = _topo$store$useModelS.graphLoaded;
37
+
38
+ useEffect(function () {
39
+ // 设置
40
+ var themeConfig = themeMap[canvasTheme];
41
+
42
+ if (graphLoaded && themeConfig) {
43
+ topo.getHtTopo().setToolsTheme(themeConfig.toolsTheme);
44
+ }
45
+ }, [canvasTheme, graphLoaded]);
32
46
  return {
33
47
  canvasColor: themeMap[canvasTheme].color
34
48
  };
@@ -22,7 +22,7 @@ import topoFactory from "./topoFactory";
22
22
  import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
23
23
  import SelectionManager from "./SelectionManager"; // eslint-disable-next-line no-undef
24
24
 
25
- var version = typeof "6.0.0-alpha.34" === 'string' ? "6.0.0-alpha.34" : null;
25
+ var version = typeof "6.0.0-alpha.37" === 'string' ? "6.0.0-alpha.37" : null;
26
26
  console.info("\u62D3\u6251\u7248\u672C: " + version);
27
27
  /**
28
28
  * 拓扑显示和编辑
@@ -5,4 +5,5 @@
5
5
  height: 25px;
6
6
  border-radius: 50%;
7
7
  border: 1px solid;
8
+ cursor: pointer;
8
9
  }
@@ -4,15 +4,14 @@
4
4
  .content {
5
5
  display: flex;
6
6
  flex-direction: row;
7
- width: 84%;
8
- margin-left: 6%;
9
- overflow: hidden;
7
+ flex:1;
8
+ margin-left: 22px;
10
9
  .range {
11
10
  flex: 1;
12
11
  }
13
12
 
14
13
  .unit {
15
- margin-left: 10px;
14
+ margin-left: 14px;
16
15
  }
17
16
 
18
17
  :global {
@@ -1,13 +1,13 @@
1
1
  @import '~@alifd/next/variables.scss';
2
2
 
3
3
  .content{
4
- width: 210px;
4
+ width: 201px;
5
5
  .ul{
6
6
  width: 100%;
7
7
  .li{
8
8
  display: inline-block;
9
- width: 34.6px;
10
- line-height: 40px;
9
+ width: 33px;
10
+ line-height: 38px;
11
11
  .liBox{
12
12
  width: 31px;
13
13
  height: 31px;
@@ -31,4 +31,5 @@
31
31
  height: 25px;
32
32
  border-radius: 50%;
33
33
  overflow: hidden;
34
+ cursor: pointer;
34
35
  }
@@ -37,20 +37,21 @@
37
37
  flex-direction: column;
38
38
 
39
39
  :global {
40
- .#{$css-prefix}collapse-panel-content {
41
- flex: 1;
42
- overflow: auto;
43
- }
44
40
  .#{$css-prefix}collapse-panel.#{$css-prefix}collapse-panel-expanded {
45
41
  flex: 1;
46
42
  display: flex;
47
43
  flex-direction: column;
44
+ overflow: auto;
48
45
 
49
46
  .#{$css-prefix}collapse-panel-content {
50
47
  flex: 1;
51
48
  overflow: auto;
52
49
  }
53
50
  }
51
+ .#{$css-prefix}collapse-panel-content {
52
+ flex: 1;
53
+ overflow: auto;
54
+ }
54
55
  }
55
56
  }
56
57
 
@@ -17,6 +17,7 @@ function GraphViewPanel(props) {
17
17
  var canvasTheme = displayConfig.canvasTheme || 'white';
18
18
 
19
19
  var _useCanvasTheme = (0, _useCanvasTheme2["default"])({
20
+ topo: topo,
20
21
  canvasTheme: canvasTheme
21
22
  }),
22
23
  canvasColor = _useCanvasTheme.canvasColor;
@@ -7,84 +7,29 @@ exports["default"] = CanvasPanel;
7
7
 
8
8
  var _tag = _interopRequireDefault(require("@alifd/next/lib/tag"));
9
9
 
10
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
10
  var _react = _interopRequireWildcard(require("react"));
13
11
 
14
12
  var _CanvasPanelModule = _interopRequireDefault(require("./CanvasPanel.module.scss"));
15
13
 
14
+ var _useCanvasThemeConfig2 = _interopRequireDefault(require("./useCanvasThemeConfig"));
15
+
16
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
 
18
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
19
 
20
- var CANVAS_TOGGLE = [{
21
- value: 'white',
22
- label: '白色',
23
- color: '#FFFFFF',
24
- globalNodeLabelColor: '#4d6277',
25
- globalEdgeTagColor: '#4d6277'
26
- }, {
27
- value: 'lightblue',
28
- label: '蓝色',
29
- color: '#F9FBFF',
30
- globalNodeLabelColor: '#4d6277',
31
- globalEdgeTagColor: '#4d6277'
32
- }, // {
33
- // value: 'yellow',
34
- // label: '黄色',
35
- // color: '#FFFDE6',
36
- // },
37
- // {
38
- // value: 'green',
39
- // label: '绿色',
40
- // color: '#EAFFE8',
41
- // },
42
- {
43
- value: 'dark',
44
- label: '深色',
45
- color: '#031425',
46
- globalNodeLabelColor: '#ffffff',
47
- globalEdgeTagColor: '#ffffff'
48
- }];
49
-
50
20
  function CanvasPanel(props) {
51
21
  var topo = props.topo;
52
22
 
53
- var _topo$store$useModel = topo.store.useModel('displayConfig'),
54
- canvasTheme = _topo$store$useModel[0].canvasTheme,
55
- displayConfigDispatchers = _topo$store$useModel[1];
56
-
57
- var value = canvasTheme || 'white';
58
-
59
- var setCanvasTheme = function setCanvasTheme(themeItem) {
60
- var theme = themeItem.value;
61
- topo.historyManager.beginTransaction();
62
- displayConfigDispatchers.update({
63
- canvasTheme: theme
64
- }); // 设置资源/链路标注样式
65
-
66
- var _topo$store$getModelS = topo.store.getModelState('displayConfig'),
67
- nodeLabelStyle = _topo$store$getModelS.nodeLabelStyle,
68
- defaultEdgeLabelStyle = _topo$store$getModelS.defaultEdgeLabelStyle;
69
-
70
- var globalNodeLabelStyle = (0, _extends2["default"])({}, nodeLabelStyle, {
71
- color: themeItem.globalNodeLabelColor
72
- });
73
- topo.getHtTopo().setGlobalNodeLabelStyle(globalNodeLabelStyle);
74
- var globalEdgeTagStyle = (0, _extends2["default"])({}, defaultEdgeLabelStyle, {
75
- color: themeItem.globalEdgeTagColor
76
- });
77
- topo.getHtTopo().setGlobalEdgeTagStyle(globalEdgeTagStyle);
78
- displayConfigDispatchers.update({
79
- nodeLabelStyle: globalNodeLabelStyle,
80
- defaultEdgeLabelStyle: globalEdgeTagStyle
81
- });
82
- topo.historyManager.endTransaction();
83
- };
23
+ var _useCanvasThemeConfig = (0, _useCanvasThemeConfig2["default"])({
24
+ topo: topo
25
+ }),
26
+ themes = _useCanvasThemeConfig.themes,
27
+ canvasThemeName = _useCanvasThemeConfig.canvasThemeName,
28
+ setCanvasTheme = _useCanvasThemeConfig.setCanvasTheme;
84
29
 
85
30
  return /*#__PURE__*/_react["default"].createElement("div", {
86
31
  className: _CanvasPanelModule["default"].canvasToggle
87
- }, CANVAS_TOGGLE.map(function (item, index) {
32
+ }, themes.map(function (item, index) {
88
33
  return /*#__PURE__*/_react["default"].createElement("div", {
89
34
  className: _CanvasPanelModule["default"].canvas,
90
35
  key: index
@@ -93,9 +38,9 @@ function CanvasPanel(props) {
93
38
  style: {
94
39
  background: item.color
95
40
  },
96
- checked: value === item.value,
41
+ checked: item.name === canvasThemeName,
97
42
  onChange: function onChange(checked) {
98
- setCanvasTheme(item);
43
+ setCanvasTheme(item.name);
99
44
  }
100
45
  }, /*#__PURE__*/_react["default"].createElement("div", {
101
46
  className: _CanvasPanelModule["default"].box
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+ var THEMES = [{
6
+ name: 'white',
7
+ label: '白色',
8
+ color: '#FFFFFF',
9
+ toolsTheme: 'lightgrayblue',
10
+ globalNodeLabelColor: '#4d6277',
11
+ globalEdgeTagColor: '#4d6277',
12
+ text: {
13
+ color: '#4d6277'
14
+ }
15
+ }, {
16
+ name: 'lightblue',
17
+ label: '蓝色',
18
+ color: '#F9FBFF',
19
+ toolsTheme: 'white',
20
+ globalNodeLabelColor: '#4d6277',
21
+ globalEdgeTagColor: '#4d6277',
22
+ text: {
23
+ color: '#4d6277'
24
+ }
25
+ }, // {
26
+ // name: 'yellow',
27
+ // label: '黄色',
28
+ // color: '#FFFDE6',
29
+ // },
30
+ // {
31
+ // name: 'green',
32
+ // label: '绿色',
33
+ // color: '#EAFFE8',
34
+ // },
35
+ {
36
+ name: 'dark',
37
+ label: '深色',
38
+ color: '#031425',
39
+ toolsTheme: 'black',
40
+ globalNodeLabelColor: '#ffffff',
41
+ globalEdgeTagColor: '#ffffff',
42
+ text: {
43
+ color: '#ffffff'
44
+ }
45
+ }];
46
+ var _default = THEMES;
47
+ exports["default"] = _default;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports["default"] = void 0;
7
+
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
14
+ var _htElementUtils = require("../../../../../../utils/htElementUtils");
15
+
16
+ var _themes = _interopRequireDefault(require("./themes"));
17
+
18
+ function useCanvasThemeConfig(props) {
19
+ var topo = props.topo;
20
+
21
+ var _topo$store$useModel = topo.store.useModel('displayConfig'),
22
+ displayConfig = _topo$store$useModel[0],
23
+ displayConfigDispatchers = _topo$store$useModel[1];
24
+
25
+ var canvasThemeName = displayConfig.canvasTheme || 'white';
26
+
27
+ var setCanvasTheme = /*#__PURE__*/function () {
28
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(themeName) {
29
+ var themeConfig;
30
+ return _regenerator["default"].wrap(function _callee$(_context) {
31
+ while (1) {
32
+ switch (_context.prev = _context.next) {
33
+ case 0:
34
+ themeConfig = _themes["default"].find(function (item) {
35
+ return item.name === themeName;
36
+ });
37
+ topo.historyManager.beginTransaction();
38
+ _context.next = 4;
39
+ return displayConfigDispatchers.update({
40
+ canvasTheme: themeName
41
+ });
42
+
43
+ case 4:
44
+ _context.next = 6;
45
+ return setGlobalTagTheme(themeConfig);
46
+
47
+ case 6:
48
+ setElementsTheme(themeConfig);
49
+ topo.historyManager.endTransaction();
50
+
51
+ case 8:
52
+ case "end":
53
+ return _context.stop();
54
+ }
55
+ }
56
+ }, _callee);
57
+ }));
58
+
59
+ return function setCanvasTheme(_x) {
60
+ return _ref.apply(this, arguments);
61
+ };
62
+ }();
63
+
64
+ function setGlobalTagTheme(_x2) {
65
+ return _setGlobalTagTheme.apply(this, arguments);
66
+ }
67
+
68
+ function _setGlobalTagTheme() {
69
+ _setGlobalTagTheme = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(themeConfig) {
70
+ var _topo$store$getModelS, nodeLabelStyle, defaultEdgeLabelStyle, globalNodeLabelStyle, globalEdgeTagStyle;
71
+
72
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
73
+ while (1) {
74
+ switch (_context2.prev = _context2.next) {
75
+ case 0:
76
+ // 设置资源/链路标注样式
77
+ _topo$store$getModelS = topo.store.getModelState('displayConfig'), nodeLabelStyle = _topo$store$getModelS.nodeLabelStyle, defaultEdgeLabelStyle = _topo$store$getModelS.defaultEdgeLabelStyle;
78
+ globalNodeLabelStyle = (0, _extends2["default"])({}, nodeLabelStyle, {
79
+ color: themeConfig.globalNodeLabelColor
80
+ });
81
+ topo.getHtTopo().setGlobalNodeLabelStyle(globalNodeLabelStyle);
82
+ globalEdgeTagStyle = (0, _extends2["default"])({}, defaultEdgeLabelStyle, {
83
+ color: themeConfig.globalEdgeTagColor
84
+ });
85
+ topo.getHtTopo().setGlobalEdgeTagStyle(globalEdgeTagStyle);
86
+ _context2.next = 7;
87
+ return displayConfigDispatchers.update({
88
+ nodeLabelStyle: globalNodeLabelStyle,
89
+ defaultEdgeLabelStyle: globalEdgeTagStyle
90
+ });
91
+
92
+ case 7:
93
+ case "end":
94
+ return _context2.stop();
95
+ }
96
+ }
97
+ }, _callee2);
98
+ }));
99
+ return _setGlobalTagTheme.apply(this, arguments);
100
+ }
101
+
102
+ function setElementsTheme(themeConfig) {
103
+ var dm = topo.getHtTopo().getGraphView().dm();
104
+ var elements = (0, _htElementUtils.getElements)(dm);
105
+ elements.forEach(function (element) {
106
+ if ((0, _htElementUtils.isText)(element)) {
107
+ element.s('text.color', themeConfig.text.color);
108
+ } else if ((0, _htElementUtils.isGroup)(element)) {
109
+ return 'groupTitle';
110
+ } else if ((0, _htElementUtils.isNode)(element)) {
111
+ return 'nodeTag';
112
+ } else if ((0, _htElementUtils.isEdge)(element)) {
113
+ return 'edgeTag';
114
+ } else if ((0, _htElementUtils.isLayer)(element)) {
115
+ return 'layerTitle';
116
+ }
117
+ });
118
+ }
119
+
120
+ return {
121
+ themes: _themes["default"],
122
+ canvasThemeName: canvasThemeName,
123
+ setCanvasTheme: setCanvasTheme
124
+ };
125
+ }
126
+
127
+ var _default = useCanvasThemeConfig;
128
+ exports["default"] = _default;
@@ -7,6 +7,8 @@ exports["default"] = HtCustomImagePanel;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
11
+
10
12
  var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
11
13
 
12
14
  var _HtImagePaletteModule = _interopRequireDefault(require("./HtImagePalette.module.scss"));
@@ -38,10 +40,20 @@ function HtCustomImagePanel(props) {
38
40
  });
39
41
  } catch (error) {
40
42
  _rlog["default"].error('初始化资源面板失败', error);
41
- } // 注销组件
43
+ }
44
+
45
+ var hanleResize = function hanleResize() {
46
+ if (viewRef.current) {
47
+ topo.getHtTopo().invalideComponents();
48
+ }
49
+ };
42
50
 
51
+ var resizeObserver = new _resizeObserverPolyfill["default"](hanleResize);
52
+ resizeObserver.observe(container); // 注销组件
43
53
 
44
54
  return function () {
55
+ resizeObserver.disconnect();
56
+
45
57
  if (viewRef.current) {
46
58
  viewRef.current.destroy();
47
59
  viewRef.current = null;