@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
@@ -1,20 +1,54 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  exports.__esModule = true;
4
6
  exports["default"] = void 0;
5
7
  exports.getTextStyle = getTextStyle;
6
8
  exports.setTextStyle = setTextStyle;
7
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
+ var _nodeTag = _interopRequireDefault(require("./nodeTag"));
17
+
8
18
  function getTextStyle(element) {
9
- return {
10
- color: null,
11
- fontFamily: null,
12
- fontSize: null,
13
- fontStyle: []
14
- };
19
+ if (!element.isExpanded()) {
20
+ // eslint-disable-next-line import/no-named-as-default-member
21
+ return _nodeTag["default"].getTextStyle(element);
22
+ }
23
+
24
+ var underline = element.s('text.decoration') === 'underline';
25
+ return (0, _extends2["default"])({
26
+ color: (0, _colorUtil.parseColor)(element.s('group.title.color')),
27
+ underline: underline
28
+ }, _fontStyleUtil["default"].toMap(element.s('group.title.font')), (0, _colorUtil.parseBackground)(element.s('group.title.background')));
15
29
  }
16
30
 
17
- function setTextStyle(element, style) {}
31
+ function setTextStyle(element, style, topo) {
32
+ if (!element.isExpanded()) {
33
+ // eslint-disable-next-line import/no-named-as-default-member
34
+ return _nodeTag["default"].setTextStyle(element, style, topo);
35
+ } // if ('underline' in style) {
36
+ // }
37
+
38
+
39
+ if ('color' in style) {
40
+ element.s('group.title.color', style.color.hex);
41
+ } // 背景颜色
42
+
43
+
44
+ var prevStyle = getTextStyle(element);
45
+ element.s('group.title.background', (0, _colorUtil.formatBackgroundRgbaColor)(prevStyle, style));
46
+ var fontStyle = (0, _extends2["default"])({}, getTextStyle(element), style);
47
+
48
+ var fontStr = _fontStyleUtil["default"].build(fontStyle);
49
+
50
+ element.s('group.title.font', fontStr);
51
+ }
18
52
 
19
53
  var _default = {
20
54
  getTextStyle: getTextStyle,
@@ -15,11 +15,14 @@ var _groupTitle = _interopRequireDefault(require("./groupTitle"));
15
15
 
16
16
  var _layerTitle = _interopRequireDefault(require("./layerTitle"));
17
17
 
18
+ var _box = _interopRequireDefault(require("./box"));
19
+
18
20
  var _default = {
19
21
  nodeTag: _nodeTag["default"],
20
22
  edgeTag: _edgeTag["default"],
21
23
  text: _text["default"],
22
24
  groupTitle: _groupTitle["default"],
23
- layerTitle: _layerTitle["default"]
25
+ layerTitle: _layerTitle["default"],
26
+ box: _box["default"]
24
27
  };
25
28
  exports["default"] = _default;
@@ -1,20 +1,59 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  exports.__esModule = true;
4
6
  exports["default"] = void 0;
5
7
  exports.getTextStyle = getTextStyle;
6
8
  exports.setTextStyle = setTextStyle;
7
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
+ var defaultStyle = {};
17
+
18
+ function getLabelStyle(element) {
19
+ return (0, _extends2["default"])({}, defaultStyle, element.a('labelStyle') || {});
20
+ }
21
+
22
+ function setLabelStyle(element, style) {
23
+ element.a('labelStyle', (0, _extends2["default"])({}, element.a('labelStyle'), style)); // eslint-disable-next-line no-underscore-dangle
24
+
25
+ element.__labelNode.a(style);
26
+ } // 分层标题文字样式
27
+
28
+
8
29
  function getTextStyle(element) {
9
- return {
10
- color: null,
11
- fontFamily: null,
12
- fontSize: null,
13
- fontStyle: []
14
- };
30
+ var style = getLabelStyle(element);
31
+ var underline = null;
32
+ return (0, _extends2["default"])({
33
+ color: (0, _colorUtil.parseColor)(style.fontColor),
34
+ underline: underline
35
+ }, _fontStyleUtil["default"].toMap(style.font), (0, _colorUtil.parseBackground)(style.background));
15
36
  }
16
37
 
17
- function setTextStyle(element, style) {}
38
+ function setTextStyle(element, style) {
39
+ // if ('underline' in style) {
40
+ // }
41
+ var labelStyle = {};
42
+
43
+ if ('color' in style) {
44
+ labelStyle.fontColor = style.color.hex;
45
+ } // 背景颜色
46
+
47
+
48
+ var prevStyle = getTextStyle(element);
49
+ labelStyle.background = (0, _colorUtil.formatBackgroundRgbaColor)(prevStyle, style);
50
+ var fontStyle = (0, _extends2["default"])({}, getTextStyle(element), style);
51
+
52
+ var fontStr = _fontStyleUtil["default"].build(fontStyle);
53
+
54
+ labelStyle.font = fontStr;
55
+ setLabelStyle(element, labelStyle);
56
+ }
18
57
 
19
58
  var _default = {
20
59
  getTextStyle: getTextStyle,
@@ -1,20 +1,37 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  exports.__esModule = true;
4
6
  exports["default"] = void 0;
5
7
  exports.getTextStyle = getTextStyle;
6
8
  exports.setTextStyle = setTextStyle;
7
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
+
8
16
  function getTextStyle(element) {
9
- return {
10
- color: null,
11
- fontFamily: null,
12
- fontSize: null,
13
- fontStyle: []
14
- };
17
+ var underline = null;
18
+ return (0, _extends2["default"])({
19
+ color: (0, _colorUtil.parseColor)(element.a('ht.color')),
20
+ underline: underline
21
+ }, _fontStyleUtil["default"].toMap(element.a('ht.font')), (0, _colorUtil.parseBackground)(element.a('ht.background')));
15
22
  }
16
23
 
17
- function setTextStyle(element, style) {}
24
+ function setTextStyle(element, style, topo) {
25
+ if ('background' in style || 'opacity' in style) {
26
+ // 背景颜色
27
+ var prevStyle = getTextStyle(element);
28
+ topo.setNodeLabelStyle(element, {
29
+ background: (0, _colorUtil.formatBackgroundRgbaColor)(prevStyle, style)
30
+ });
31
+ } else {
32
+ topo.getHtTopo().setNodeLabelStyle(element, style);
33
+ }
34
+ }
18
35
 
19
36
  var _default = {
20
37
  getTextStyle: getTextStyle,
@@ -14,19 +14,11 @@ var _fontStyleUtil = _interopRequireDefault(require("../../../../../../settings/
14
14
  var _colorUtil = require("../colorUtil");
15
15
 
16
16
  function getTextStyle(element) {
17
- var _background$rgb;
18
-
19
17
  var underline = element.s('text.decoration') === 'underline';
20
- var background = (0, _colorUtil.parseColor)(element.s('textBackground'));
21
18
  return (0, _extends2["default"])({
22
19
  color: (0, _colorUtil.parseColor)(element.s('text.color')),
23
20
  underline: underline
24
- }, _fontStyleUtil["default"].toMap(element.s('text.font')), {
25
- background: background,
26
- // 背景颜色,格式: {rgba: {}, hex: ''} | null
27
- 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表示无
28
-
29
- });
21
+ }, _fontStyleUtil["default"].toMap(element.s('text.font')), (0, _colorUtil.parseBackground)(element.s('textBackground')));
30
22
  }
31
23
 
32
24
  function setTextStyle(element, style) {
@@ -14,6 +14,8 @@ var _elements = _interopRequireDefault(require("./elements"));
14
14
  function getElementType(element) {
15
15
  if ((0, _htElementUtils.isText)(element)) {
16
16
  return 'text';
17
+ } else if (element.a('type') === 'box') {
18
+ return 'box';
17
19
  } else if ((0, _htElementUtils.isGroup)(element)) {
18
20
  return 'groupTitle';
19
21
  } else if ((0, _htElementUtils.isNode)(element)) {
@@ -71,11 +73,11 @@ function getTextStyle(htSelection, styleNames) {
71
73
  return null;
72
74
  }
73
75
 
74
- function setTextStyle(element, style) {
76
+ function setTextStyle(element, style, topo) {
75
77
  var type = getElementType(element);
76
78
  var handler = _elements["default"][type];
77
79
 
78
80
  if (handler) {
79
- handler.setTextStyle(element, style);
81
+ handler.setTextStyle(element, style, topo);
80
82
  }
81
83
  }
@@ -9,18 +9,17 @@ var fontStyleUtil = {
9
9
  font = '';
10
10
  }
11
11
 
12
- var arr = font.trim().split(' ');
12
+ var str = font.trim();
13
13
  var bold = font.indexOf('bold') > -1;
14
14
  var italic = font.indexOf('italic') > -1;
15
- var fontFamily;
16
- var fontSize;
17
-
18
- if (arr.length) {
19
- fontFamily = arr[arr.length - 1];
20
- }
21
-
22
- if (arr.length >= 2) {
23
- fontSize = parseInt(arr[arr.length - 2].replace('px', ''), 10);
15
+ str = str.trim().replace('bold ', '').trim().replace('italic ', '').trim();
16
+ var arr = str.split(' ');
17
+ var fontSizeStr = arr[0];
18
+ var fontFamily = str.replace(fontSizeStr, '').trim() || null;
19
+ var fontSize = null;
20
+
21
+ if (fontSizeStr) {
22
+ fontSize = parseInt(fontSizeStr.replace('px', ''), 10);
24
23
  }
25
24
 
26
25
  return {
@@ -32,17 +31,9 @@ var fontStyleUtil = {
32
31
  },
33
32
  // 字体样式格式: bold italic 12px 黑体 或 12px 黑体
34
33
  build: function build(style) {
35
- var font = '';
36
-
37
- if (style.bold) {
38
- font += 'bold ';
39
- }
40
-
41
- if (style.italic) {
42
- font += 'italic ';
43
- }
44
-
45
- return "" + font + style.fontSize + "px " + style.fontFamily;
34
+ return [style.bold ? 'bold' : null, style.italic ? 'italic' : null, style.fontSize ? style.fontSize + "px" : null, style.fontFamily].filter(function (item) {
35
+ return item !== null;
36
+ }).join(' ');
46
37
  },
47
38
  getFontStyleMap: function getFontStyleMap(obj, prefix) {
48
39
  var map = {};
@@ -52,7 +52,7 @@ var _ElementTagTipConfig = _interopRequireDefault(require("./tagstips/ElementTag
52
52
  var _SelectionManager = _interopRequireDefault(require("./SelectionManager"));
53
53
 
54
54
  // eslint-disable-next-line no-undef
55
- var version = typeof "6.0.0-alpha.37" === 'string' ? "6.0.0-alpha.37" : null;
55
+ var version = typeof "6.0.0-alpha.39" === 'string' ? "6.0.0-alpha.39" : null;
56
56
  console.info("\u62D3\u6251\u7248\u672C: " + version);
57
57
  /**
58
58
  * 拓扑显示和编辑
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "6.0.0-alpha.37",
3
+ "version": "6.0.0-alpha.39",
4
4
  "description": "拓扑",
5
5
  "scripts": {
6
6
  "start": "build-scripts start",
@@ -116,6 +116,6 @@
116
116
  "access": "public"
117
117
  },
118
118
  "license": "MIT",
119
- "homepage": "https://unpkg.com/@riil-frontend/component-topology@6.0.0-alpha.37/build/index.html",
119
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@6.0.0-alpha.39/build/index.html",
120
120
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
121
121
  }