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

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 (30) hide show
  1. package/build/index.js +1 -1
  2. package/es/core/editor/components/Sidebar/views/CanvasPanel/themes.js +30 -0
  3. package/es/core/editor/components/Sidebar/views/CanvasPanel/useCanvasThemeConfig.js +7 -8
  4. package/es/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +1 -1
  5. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/ElementTextStyleSetting.js +12 -4
  6. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/colorUtil.js +11 -0
  7. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/box.js +30 -0
  8. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +35 -7
  9. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/index.js +3 -1
  10. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/layerTitle.js +41 -7
  11. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/nodeTag.js +19 -7
  12. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +2 -10
  13. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/textStyleUtil.js +4 -2
  14. package/es/core/editor/components/settings/common/text/fontStyleUtil.js +11 -20
  15. package/es/core/models/TopoApp.js +1 -1
  16. package/lib/core/editor/components/Sidebar/views/CanvasPanel/themes.js +30 -0
  17. package/lib/core/editor/components/Sidebar/views/CanvasPanel/useCanvasThemeConfig.js +8 -8
  18. package/lib/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +1 -1
  19. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/ElementTextStyleSetting.js +12 -4
  20. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/colorUtil.js +13 -0
  21. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/box.js +45 -0
  22. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +41 -7
  23. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/index.js +4 -1
  24. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/layerTitle.js +46 -7
  25. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/nodeTag.js +24 -7
  26. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +1 -9
  27. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/textStyleUtil.js +4 -2
  28. package/lib/core/editor/components/settings/common/text/fontStyleUtil.js +12 -21
  29. package/lib/core/models/TopoApp.js +1 -1
  30. package/package.json +2 -2
@@ -7,6 +7,16 @@ var THEMES = [{
7
7
  globalEdgeTagColor: '#4d6277',
8
8
  text: {
9
9
  color: '#4d6277'
10
+ },
11
+ group: {
12
+ style: {
13
+ 'group.title.background': '#E4E9EE',
14
+ // 标题背景颜色
15
+ 'group.title.color': '#4D6277',
16
+ // 标题文字颜色
17
+ 'group.border.color': '#E4E9EE' // 边框颜色
18
+
19
+ }
10
20
  }
11
21
  }, {
12
22
  name: 'lightblue',
@@ -17,6 +27,16 @@ var THEMES = [{
17
27
  globalEdgeTagColor: '#4d6277',
18
28
  text: {
19
29
  color: '#4d6277'
30
+ },
31
+ group: {
32
+ style: {
33
+ 'group.title.background': '#E4E9EE',
34
+ // 标题背景颜色
35
+ 'group.title.color': '#4D6277',
36
+ // 标题文字颜色
37
+ 'group.border.color': '#E4E9EE' // 边框颜色
38
+
39
+ }
20
40
  }
21
41
  }, // {
22
42
  // name: 'yellow',
@@ -37,6 +57,16 @@ var THEMES = [{
37
57
  globalEdgeTagColor: '#ffffff',
38
58
  text: {
39
59
  color: '#ffffff'
60
+ },
61
+ group: {
62
+ style: {
63
+ 'group.title.background': '#08A5F4',
64
+ // 标题背景颜色
65
+ 'group.title.color': '#FFFFFF',
66
+ // 标题文字颜色
67
+ 'group.border.color': '#08A5F4' // 边框颜色
68
+
69
+ }
40
70
  }
41
71
  }];
42
72
  export default THEMES;
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { isClusterHtElement } from "../../../../../../utils/clusterUtil";
4
5
  import { getElements, isEdge, isGroup, isLayer, isNode, isText } from "../../../../../../utils/htElementUtils";
5
6
  import THEMES from "./themes";
6
7
 
@@ -95,14 +96,12 @@ function useCanvasThemeConfig(props) {
95
96
  if (isText(element)) {
96
97
  element.s('text.color', themeConfig.text.color);
97
98
  } else if (isGroup(element)) {
98
- return 'groupTitle';
99
- } else if (isNode(element)) {
100
- return 'nodeTag';
101
- } else if (isEdge(element)) {
102
- return 'edgeTag';
103
- } else if (isLayer(element)) {
104
- return 'layerTitle';
105
- }
99
+ if (isClusterHtElement(element)) {// 集群
100
+ } else {
101
+ // 区域(非集群)
102
+ element.s(themeConfig.group.style);
103
+ }
104
+ } else if (isEdge(element)) {}
106
105
  });
107
106
  }
108
107
 
@@ -8,7 +8,7 @@ function FontFamilySelect(props) {
8
8
  onChange = props.onChange;
9
9
  var items = ['宋体', '微软雅黑', '黑体', 'Arial'];
10
10
  return /*#__PURE__*/React.createElement(DropdownMenu, {
11
- value: value || '',
11
+ value: (items.includes(value) ? value : null) || '',
12
12
  valueRender: function valueRender(val) {
13
13
  return /*#__PURE__*/React.createElement("div", {
14
14
  style: {
@@ -9,7 +9,11 @@ function ElementTextStyleSetting(props) {
9
9
 
10
10
  var Component = props.Component,
11
11
  styleNames = props.styleNames,
12
- widgetProps = _objectWithoutPropertiesLoose(props, _excluded); // 选中的元素
12
+ widgetProps = _objectWithoutPropertiesLoose(props, _excluded); // 拓扑图是否加载
13
+
14
+
15
+ var _topo$store$useModelS = topo.store.useModelState('topoMod'),
16
+ graphLoaded = _topo$store$useModelS.graphLoaded; // 选中的元素
13
17
 
14
18
 
15
19
  var selection = topo.selectionManager.useSelection();
@@ -21,12 +25,16 @@ function ElementTextStyleSetting(props) {
21
25
  return topo.getHtTopo().getGraphView().getSelectionModel().getSelection().toArray();
22
26
  }, [selection, topo]);
23
27
  var value = useMemo(function () {
24
- return getTextStyle(htSelection, styleNames) || {};
25
- }, [htSelection, topo]);
28
+ if (!graphLoaded) {
29
+ return {};
30
+ }
31
+
32
+ return getTextStyle(htSelection, styleNames, topo) || {};
33
+ }, [graphLoaded, htSelection, topo]);
26
34
  var setStyle = useMemo(function () {
27
35
  return function (style) {
28
36
  htSelection.forEach(function (element) {
29
- setTextStyle(element, style);
37
+ setTextStyle(element, style, topo);
30
38
  });
31
39
  };
32
40
  }, [htSelection]);
@@ -23,6 +23,17 @@ export function parseColor(colorStr) {
23
23
  }
24
24
  };
25
25
  }
26
+ export function parseBackground(colorStr) {
27
+ var _background$rgb;
28
+
29
+ var background = parseColor(colorStr);
30
+ return {
31
+ background: background,
32
+ // 背景颜色,格式: {rgba: {}, hex: ''} | null
33
+ 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表示无
34
+
35
+ };
36
+ }
26
37
  export function formatHexColor(color) {
27
38
  return color ? color.hex : null;
28
39
  }
@@ -0,0 +1,30 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import fontStyleUtil from "../../../../../../settings/common/text/fontStyleUtil";
3
+ import { formatBackgroundRgbaColor, parseBackground, parseColor } from "../colorUtil";
4
+ export function getTextStyle(element) {
5
+ var underline = element.a('text.decoration') === 'underline';
6
+ return _extends({
7
+ color: parseColor(element.a('topLeftTextColor')),
8
+ underline: underline
9
+ }, fontStyleUtil.toMap(element.a('rectFont')), parseBackground(element.a('topLeftColor')));
10
+ }
11
+ export function setTextStyle(element, style) {
12
+ if ('underline' in style) {}
13
+
14
+ if ('color' in style) {
15
+ element.a('topLeftTextColor', style.color.hex);
16
+ } // 背景颜色
17
+
18
+
19
+ var prevStyle = getTextStyle(element);
20
+ element.a('topLeftColor', formatBackgroundRgbaColor(prevStyle, style));
21
+
22
+ var fontStyle = _extends({}, getTextStyle(element), style);
23
+
24
+ var fontStr = fontStyleUtil.build(fontStyle);
25
+ element.a('rectFont', fontStr);
26
+ }
27
+ export default {
28
+ getTextStyle: getTextStyle,
29
+ setTextStyle: setTextStyle
30
+ };
@@ -1,12 +1,40 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import fontStyleUtil from "../../../../../../settings/common/text/fontStyleUtil";
3
+ import { formatBackgroundRgbaColor, parseBackground, parseColor } from "../colorUtil";
4
+ import nodeTag from "./nodeTag";
1
5
  export function getTextStyle(element) {
2
- return {
3
- color: null,
4
- fontFamily: null,
5
- fontSize: null,
6
- fontStyle: []
7
- };
6
+ if (!element.isExpanded()) {
7
+ // eslint-disable-next-line import/no-named-as-default-member
8
+ return nodeTag.getTextStyle(element);
9
+ }
10
+
11
+ var underline = element.s('text.decoration') === 'underline';
12
+ return _extends({
13
+ color: parseColor(element.s('group.title.color')),
14
+ underline: underline
15
+ }, fontStyleUtil.toMap(element.s('group.title.font')), parseBackground(element.s('group.title.background')));
16
+ }
17
+ export function setTextStyle(element, style, topo) {
18
+ if (!element.isExpanded()) {
19
+ // eslint-disable-next-line import/no-named-as-default-member
20
+ return nodeTag.setTextStyle(element, style, topo);
21
+ } // if ('underline' in style) {
22
+ // }
23
+
24
+
25
+ if ('color' in style) {
26
+ element.s('group.title.color', style.color.hex);
27
+ } // 背景颜色
28
+
29
+
30
+ var prevStyle = getTextStyle(element);
31
+ element.s('group.title.background', formatBackgroundRgbaColor(prevStyle, style));
32
+
33
+ var fontStyle = _extends({}, getTextStyle(element), style);
34
+
35
+ var fontStr = fontStyleUtil.build(fontStyle);
36
+ element.s('group.title.font', fontStr);
8
37
  }
9
- export function setTextStyle(element, style) {}
10
38
  export default {
11
39
  getTextStyle: getTextStyle,
12
40
  setTextStyle: setTextStyle
@@ -3,10 +3,12 @@ import nodeTag from "./nodeTag";
3
3
  import edgeTag from "./edgeTag";
4
4
  import groupTitle from "./groupTitle";
5
5
  import layerTitle from "./layerTitle";
6
+ import box from "./box";
6
7
  export default {
7
8
  nodeTag: nodeTag,
8
9
  edgeTag: edgeTag,
9
10
  text: text,
10
11
  groupTitle: groupTitle,
11
- layerTitle: layerTitle
12
+ layerTitle: layerTitle,
13
+ box: box
12
14
  };
@@ -1,12 +1,46 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import fontStyleUtil from "../../../../../../settings/common/text/fontStyleUtil";
3
+ import { formatBackgroundRgbaColor, parseBackground, parseColor } from "../colorUtil";
4
+ var defaultStyle = {};
5
+
6
+ function getLabelStyle(element) {
7
+ return _extends({}, defaultStyle, element.a('labelStyle') || {});
8
+ }
9
+
10
+ function setLabelStyle(element, style) {
11
+ element.a('labelStyle', _extends({}, element.a('labelStyle'), style)); // eslint-disable-next-line no-underscore-dangle
12
+
13
+ element.__labelNode.a(style);
14
+ } // 分层标题文字样式
15
+
16
+
1
17
  export function getTextStyle(element) {
2
- return {
3
- color: null,
4
- fontFamily: null,
5
- fontSize: null,
6
- fontStyle: []
7
- };
18
+ var style = getLabelStyle(element);
19
+ var underline = null;
20
+ return _extends({
21
+ color: parseColor(style.fontColor),
22
+ underline: underline
23
+ }, fontStyleUtil.toMap(style.font), parseBackground(style.background));
24
+ }
25
+ export function setTextStyle(element, style) {
26
+ // if ('underline' in style) {
27
+ // }
28
+ var labelStyle = {};
29
+
30
+ if ('color' in style) {
31
+ labelStyle.fontColor = style.color.hex;
32
+ } // 背景颜色
33
+
34
+
35
+ var prevStyle = getTextStyle(element);
36
+ labelStyle.background = formatBackgroundRgbaColor(prevStyle, style);
37
+
38
+ var fontStyle = _extends({}, getTextStyle(element), style);
39
+
40
+ var fontStr = fontStyleUtil.build(fontStyle);
41
+ labelStyle.font = fontStr;
42
+ setLabelStyle(element, labelStyle);
8
43
  }
9
- export function setTextStyle(element, style) {}
10
44
  export default {
11
45
  getTextStyle: getTextStyle,
12
46
  setTextStyle: setTextStyle
@@ -1,12 +1,24 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import fontStyleUtil from "../../../../../../settings/common/text/fontStyleUtil";
3
+ import { formatBackgroundRgbaColor, parseBackground, parseColor } from "../colorUtil";
1
4
  export function getTextStyle(element) {
2
- return {
3
- color: null,
4
- fontFamily: null,
5
- fontSize: null,
6
- fontStyle: []
7
- };
5
+ var underline = null;
6
+ return _extends({
7
+ color: parseColor(element.a('ht.color')),
8
+ underline: underline
9
+ }, fontStyleUtil.toMap(element.a('ht.font')), parseBackground(element.a('ht.background')));
10
+ }
11
+ export function setTextStyle(element, style, topo) {
12
+ if ('background' in style || 'opacity' in style) {
13
+ // 背景颜色
14
+ var prevStyle = getTextStyle(element);
15
+ topo.setNodeLabelStyle(element, {
16
+ background: formatBackgroundRgbaColor(prevStyle, style)
17
+ });
18
+ } else {
19
+ topo.getHtTopo().setNodeLabelStyle(element, style);
20
+ }
8
21
  }
9
- export function setTextStyle(element, style) {}
10
22
  export default {
11
23
  getTextStyle: getTextStyle,
12
24
  setTextStyle: setTextStyle
@@ -1,20 +1,12 @@
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
+ import { formatBackgroundRgbaColor, parseBackground, parseColor } from "../colorUtil";
4
4
  export function getTextStyle(element) {
5
- var _background$rgb;
6
-
7
5
  var underline = element.s('text.decoration') === 'underline';
8
- var background = parseColor(element.s('textBackground'));
9
6
  return _extends({
10
7
  color: parseColor(element.s('text.color')),
11
8
  underline: underline
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
+ }, fontStyleUtil.toMap(element.s('text.font')), parseBackground(element.s('textBackground')));
18
10
  }
19
11
  export function setTextStyle(element, style) {
20
12
  if ('underline' in style) {
@@ -4,6 +4,8 @@ import typeMap from "./elements";
4
4
  function getElementType(element) {
5
5
  if (isText(element)) {
6
6
  return 'text';
7
+ } else if (element.a('type') === 'box') {
8
+ return 'box';
7
9
  } else if (isGroup(element)) {
8
10
  return 'groupTitle';
9
11
  } else if (isNode(element)) {
@@ -59,11 +61,11 @@ export function getTextStyle(htSelection, styleNames) {
59
61
 
60
62
  return null;
61
63
  }
62
- export function setTextStyle(element, style) {
64
+ export function setTextStyle(element, style, topo) {
63
65
  var type = getElementType(element);
64
66
  var handler = typeMap[type];
65
67
 
66
68
  if (handler) {
67
- handler.setTextStyle(element, style);
69
+ handler.setTextStyle(element, style, topo);
68
70
  }
69
71
  }
@@ -5,18 +5,17 @@ var fontStyleUtil = {
5
5
  font = '';
6
6
  }
7
7
 
8
- var arr = font.trim().split(' ');
8
+ var str = font.trim();
9
9
  var bold = font.indexOf('bold') > -1;
10
10
  var italic = font.indexOf('italic') > -1;
11
- var fontFamily;
12
- var fontSize;
11
+ str = str.trim().replace('bold ', '').trim().replace('italic ', '').trim();
12
+ var arr = str.split(' ');
13
+ var fontSizeStr = arr[0];
14
+ var fontFamily = str.replace(fontSizeStr, '').trim() || null;
15
+ var fontSize = null;
13
16
 
14
- if (arr.length) {
15
- fontFamily = arr[arr.length - 1];
16
- }
17
-
18
- if (arr.length >= 2) {
19
- fontSize = parseInt(arr[arr.length - 2].replace('px', ''), 10);
17
+ if (fontSizeStr) {
18
+ fontSize = parseInt(fontSizeStr.replace('px', ''), 10);
20
19
  }
21
20
 
22
21
  return {
@@ -28,17 +27,9 @@ var fontStyleUtil = {
28
27
  },
29
28
  // 字体样式格式: bold italic 12px 黑体 或 12px 黑体
30
29
  build: function build(style) {
31
- var font = '';
32
-
33
- if (style.bold) {
34
- font += 'bold ';
35
- }
36
-
37
- if (style.italic) {
38
- font += 'italic ';
39
- }
40
-
41
- return "" + font + style.fontSize + "px " + style.fontFamily;
30
+ return [style.bold ? 'bold' : null, style.italic ? 'italic' : null, style.fontSize ? style.fontSize + "px" : null, style.fontFamily].filter(function (item) {
31
+ return item !== null;
32
+ }).join(' ');
42
33
  },
43
34
  getFontStyleMap: function getFontStyleMap(obj, prefix) {
44
35
  var map = {};
@@ -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.37" === 'string' ? "6.0.0-alpha.37" : null;
25
+ var version = typeof "6.0.0-alpha.39" === 'string' ? "6.0.0-alpha.39" : null;
26
26
  console.info("\u62D3\u6251\u7248\u672C: " + version);
27
27
  /**
28
28
  * 拓扑显示和编辑
@@ -11,6 +11,16 @@ var THEMES = [{
11
11
  globalEdgeTagColor: '#4d6277',
12
12
  text: {
13
13
  color: '#4d6277'
14
+ },
15
+ group: {
16
+ style: {
17
+ 'group.title.background': '#E4E9EE',
18
+ // 标题背景颜色
19
+ 'group.title.color': '#4D6277',
20
+ // 标题文字颜色
21
+ 'group.border.color': '#E4E9EE' // 边框颜色
22
+
23
+ }
14
24
  }
15
25
  }, {
16
26
  name: 'lightblue',
@@ -21,6 +31,16 @@ var THEMES = [{
21
31
  globalEdgeTagColor: '#4d6277',
22
32
  text: {
23
33
  color: '#4d6277'
34
+ },
35
+ group: {
36
+ style: {
37
+ 'group.title.background': '#E4E9EE',
38
+ // 标题背景颜色
39
+ 'group.title.color': '#4D6277',
40
+ // 标题文字颜色
41
+ 'group.border.color': '#E4E9EE' // 边框颜色
42
+
43
+ }
24
44
  }
25
45
  }, // {
26
46
  // name: 'yellow',
@@ -41,6 +61,16 @@ var THEMES = [{
41
61
  globalEdgeTagColor: '#ffffff',
42
62
  text: {
43
63
  color: '#ffffff'
64
+ },
65
+ group: {
66
+ style: {
67
+ 'group.title.background': '#08A5F4',
68
+ // 标题背景颜色
69
+ 'group.title.color': '#FFFFFF',
70
+ // 标题文字颜色
71
+ 'group.border.color': '#08A5F4' // 边框颜色
72
+
73
+ }
44
74
  }
45
75
  }];
46
76
  var _default = THEMES;
@@ -11,6 +11,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
11
 
12
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
13
 
14
+ var _clusterUtil = require("../../../../../../utils/clusterUtil");
15
+
14
16
  var _htElementUtils = require("../../../../../../utils/htElementUtils");
15
17
 
16
18
  var _themes = _interopRequireDefault(require("./themes"));
@@ -106,14 +108,12 @@ function useCanvasThemeConfig(props) {
106
108
  if ((0, _htElementUtils.isText)(element)) {
107
109
  element.s('text.color', themeConfig.text.color);
108
110
  } 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
- }
111
+ if ((0, _clusterUtil.isClusterHtElement)(element)) {// 集群
112
+ } else {
113
+ // 区域(非集群)
114
+ element.s(themeConfig.group.style);
115
+ }
116
+ } else if ((0, _htElementUtils.isEdge)(element)) {}
117
117
  });
118
118
  }
119
119
 
@@ -22,7 +22,7 @@ function FontFamilySelect(props) {
22
22
  onChange = props.onChange;
23
23
  var items = ['宋体', '微软雅黑', '黑体', 'Arial'];
24
24
  return /*#__PURE__*/_react["default"].createElement(_DropdownMenu["default"], {
25
- value: value || '',
25
+ value: (items.includes(value) ? value : null) || '',
26
26
  valueRender: function valueRender(val) {
27
27
  return /*#__PURE__*/_react["default"].createElement("div", {
28
28
  style: {
@@ -23,7 +23,11 @@ function ElementTextStyleSetting(props) {
23
23
  var topo = props.topo;
24
24
  var Component = props.Component,
25
25
  styleNames = props.styleNames,
26
- widgetProps = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded); // 选中的元素
26
+ widgetProps = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded); // 拓扑图是否加载
27
+
28
+ var _topo$store$useModelS = topo.store.useModelState('topoMod'),
29
+ graphLoaded = _topo$store$useModelS.graphLoaded; // 选中的元素
30
+
27
31
 
28
32
  var selection = topo.selectionManager.useSelection();
29
33
  var htSelection = (0, _react.useMemo)(function () {
@@ -34,12 +38,16 @@ function ElementTextStyleSetting(props) {
34
38
  return topo.getHtTopo().getGraphView().getSelectionModel().getSelection().toArray();
35
39
  }, [selection, topo]);
36
40
  var value = (0, _react.useMemo)(function () {
37
- return (0, _textStyleUtil.getTextStyle)(htSelection, styleNames) || {};
38
- }, [htSelection, topo]);
41
+ if (!graphLoaded) {
42
+ return {};
43
+ }
44
+
45
+ return (0, _textStyleUtil.getTextStyle)(htSelection, styleNames, topo) || {};
46
+ }, [graphLoaded, htSelection, topo]);
39
47
  var setStyle = (0, _react.useMemo)(function () {
40
48
  return function (style) {
41
49
  htSelection.forEach(function (element) {
42
- (0, _textStyleUtil.setTextStyle)(element, style);
50
+ (0, _textStyleUtil.setTextStyle)(element, style, topo);
43
51
  });
44
52
  };
45
53
  }, [htSelection]);
@@ -5,6 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  exports.__esModule = true;
6
6
  exports.formatBackgroundRgbaColor = formatBackgroundRgbaColor;
7
7
  exports.formatHexColor = formatHexColor;
8
+ exports.parseBackground = parseBackground;
8
9
  exports.parseColor = parseColor;
9
10
 
10
11
  var _color = _interopRequireDefault(require("color"));
@@ -33,6 +34,18 @@ function parseColor(colorStr) {
33
34
  };
34
35
  }
35
36
 
37
+ function parseBackground(colorStr) {
38
+ var _background$rgb;
39
+
40
+ var background = parseColor(colorStr);
41
+ return {
42
+ background: background,
43
+ // 背景颜色,格式: {rgba: {}, hex: ''} | null
44
+ 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表示无
45
+
46
+ };
47
+ }
48
+
36
49
  function formatHexColor(color) {
37
50
  return color ? color.hex : null;
38
51
  }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports["default"] = void 0;
7
+ exports.getTextStyle = getTextStyle;
8
+ exports.setTextStyle = setTextStyle;
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var _fontStyleUtil = _interopRequireDefault(require("../../../../../../settings/common/text/fontStyleUtil"));
13
+
14
+ var _colorUtil = require("../colorUtil");
15
+
16
+ function getTextStyle(element) {
17
+ var underline = element.a('text.decoration') === 'underline';
18
+ return (0, _extends2["default"])({
19
+ color: (0, _colorUtil.parseColor)(element.a('topLeftTextColor')),
20
+ underline: underline
21
+ }, _fontStyleUtil["default"].toMap(element.a('rectFont')), (0, _colorUtil.parseBackground)(element.a('topLeftColor')));
22
+ }
23
+
24
+ function setTextStyle(element, style) {
25
+ if ('underline' in style) {}
26
+
27
+ if ('color' in style) {
28
+ element.a('topLeftTextColor', style.color.hex);
29
+ } // 背景颜色
30
+
31
+
32
+ var prevStyle = getTextStyle(element);
33
+ element.a('topLeftColor', (0, _colorUtil.formatBackgroundRgbaColor)(prevStyle, style));
34
+ var fontStyle = (0, _extends2["default"])({}, getTextStyle(element), style);
35
+
36
+ var fontStr = _fontStyleUtil["default"].build(fontStyle);
37
+
38
+ element.a('rectFont', fontStr);
39
+ }
40
+
41
+ var _default = {
42
+ getTextStyle: getTextStyle,
43
+ setTextStyle: setTextStyle
44
+ };
45
+ exports["default"] = _default;