@riil-frontend/component-topology 6.0.0-alpha.34 → 6.0.0-alpha.35
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/build/1.js +2 -2
- package/build/2.js +1 -1
- package/build/index.css +1 -1
- package/build/index.js +19 -19
- package/es/components/collapse/Collapse.module.scss +5 -4
- package/es/core/editor/components/Sidebar/views/ImagePanel/HtCustomImagePanel.js +12 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.js +12 -2
- package/es/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.module.scss +1 -1
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/colorUtil.js +50 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/edgeTag.js +7 -2
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +20 -5
- package/es/core/models/TopoApp.js +1 -1
- package/lib/components/collapse/Collapse.module.scss +5 -4
- package/lib/core/editor/components/Sidebar/views/ImagePanel/HtCustomImagePanel.js +13 -1
- package/lib/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.js +13 -2
- package/lib/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.module.scss +1 -1
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/colorUtil.js +61 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/edgeTag.js +7 -2
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +20 -5
- package/lib/core/models/TopoApp.js +1 -1
- package/package.json +3 -2
@@ -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
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
2
|
+
import ResizeObserver from 'resize-observer-polyfill';
|
2
3
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
3
4
|
import styles from "./HtImagePalette.module.scss";
|
4
5
|
/**
|
@@ -25,10 +26,20 @@ export default function HtCustomImagePanel(props) {
|
|
25
26
|
});
|
26
27
|
} catch (error) {
|
27
28
|
rlog.error('初始化资源面板失败', error);
|
28
|
-
}
|
29
|
+
}
|
29
30
|
|
31
|
+
var hanleResize = function hanleResize() {
|
32
|
+
if (viewRef.current) {
|
33
|
+
topo.getHtTopo().invalideComponents();
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
var resizeObserver = new ResizeObserver(hanleResize);
|
38
|
+
resizeObserver.observe(container); // 注销组件
|
30
39
|
|
31
40
|
return function () {
|
41
|
+
resizeObserver.disconnect();
|
42
|
+
|
32
43
|
if (viewRef.current) {
|
33
44
|
viewRef.current.destroy();
|
34
45
|
viewRef.current = null;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
2
2
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
3
|
+
import ResizeObserver from 'resize-observer-polyfill';
|
3
4
|
import styles from "./HtImagePalette.module.scss";
|
4
5
|
/**
|
5
6
|
* 组件面板
|
@@ -23,13 +24,22 @@ export default function HtImagePalette(props) {
|
|
23
24
|
viewRef.current = htTopo.createImagePalette(container, {
|
24
25
|
icons: icons
|
25
26
|
});
|
26
|
-
console.error(viewRef.current);
|
27
27
|
} catch (error) {
|
28
28
|
rlog.error('初始化资源面板失败', error);
|
29
|
-
}
|
29
|
+
}
|
30
30
|
|
31
|
+
var hanleResize = function hanleResize() {
|
32
|
+
if (viewRef.current) {
|
33
|
+
topo.getHtTopo().invalideComponents();
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
var resizeObserver = new ResizeObserver(hanleResize);
|
38
|
+
resizeObserver.observe(container); // 注销组件
|
31
39
|
|
32
40
|
return function () {
|
41
|
+
resizeObserver.disconnect();
|
42
|
+
|
33
43
|
if (viewRef.current) {
|
34
44
|
viewRef.current.destroy();
|
35
45
|
viewRef.current = null;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import Color from 'color';
|
2
|
+
/**
|
3
|
+
* 解析颜色字符串为对象
|
4
|
+
*
|
5
|
+
* @param {string} colorStr
|
6
|
+
* @returns {null|{hex, rgb:{r,g,b,a}}}
|
7
|
+
*/
|
8
|
+
|
9
|
+
export function parseColor(colorStr) {
|
10
|
+
if (!colorStr) {
|
11
|
+
return null;
|
12
|
+
}
|
13
|
+
|
14
|
+
var color = Color(colorStr);
|
15
|
+
var rgb = color.rgb();
|
16
|
+
return {
|
17
|
+
hex: color.hex(),
|
18
|
+
rgb: {
|
19
|
+
r: rgb.color[0],
|
20
|
+
g: rgb.color[1],
|
21
|
+
b: rgb.color[2],
|
22
|
+
a: rgb.valpha
|
23
|
+
}
|
24
|
+
};
|
25
|
+
}
|
26
|
+
export function formatHexColor(color) {
|
27
|
+
return color ? color.hex : null;
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* 格式化背景rgba颜色
|
31
|
+
* @param {{background, opacity}} prevColor
|
32
|
+
* @param {{background, opacity}} currentColor
|
33
|
+
*/
|
34
|
+
|
35
|
+
export function formatBackgroundRgbaColor(prevColor, currentColor) {
|
36
|
+
if (!('background' in currentColor) && !('opacity' in currentColor)) {
|
37
|
+
return null;
|
38
|
+
}
|
39
|
+
|
40
|
+
var colorObj = Object.assign(prevColor, currentColor);
|
41
|
+
var background = colorObj.background,
|
42
|
+
opacity = colorObj.opacity;
|
43
|
+
|
44
|
+
if (!background) {
|
45
|
+
return null;
|
46
|
+
}
|
47
|
+
|
48
|
+
var rgb = background.rgb;
|
49
|
+
return "rgba(" + rgb.r + ", " + rgb.g + ", " + rgb.b + ", " + opacity + ")";
|
50
|
+
}
|
@@ -1,9 +1,14 @@
|
|
1
1
|
export function getTextStyle(element) {
|
2
2
|
return {
|
3
3
|
color: null,
|
4
|
+
// 文字颜色
|
4
5
|
fontFamily: null,
|
5
|
-
fontSize: null,
|
6
|
-
|
6
|
+
fontSize: null // fontBold: false, // 文字样式加粗 @V1.2
|
7
|
+
// fontItalic: false, // 文字样式斜体 @V1.2
|
8
|
+
// fontUnderline: false, // 文字样式下划线 @V1.2
|
9
|
+
// background: {rgb: {}, hex: ''}, // 背景颜色,rgba格式。null表示无
|
10
|
+
// opacity: 1, // 背景透明度。值范围 0-1, null,null表示无
|
11
|
+
|
7
12
|
};
|
8
13
|
}
|
9
14
|
export function setTextStyle(element, style) {}
|
@@ -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:
|
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);
|
@@ -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.
|
25
|
+
var version = typeof "6.0.0-alpha.35" === 'string' ? "6.0.0-alpha.35" : null;
|
26
26
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
27
27
|
/**
|
28
28
|
* 拓扑显示和编辑
|
@@ -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
|
|
@@ -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;
|
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
10
10
|
var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
|
11
11
|
|
12
|
+
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
13
|
+
|
12
14
|
var _HtImagePaletteModule = _interopRequireDefault(require("./HtImagePalette.module.scss"));
|
13
15
|
|
14
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); }
|
@@ -36,13 +38,22 @@ function HtImagePalette(props) {
|
|
36
38
|
viewRef.current = htTopo.createImagePalette(container, {
|
37
39
|
icons: icons
|
38
40
|
});
|
39
|
-
console.error(viewRef.current);
|
40
41
|
} catch (error) {
|
41
42
|
_rlog["default"].error('初始化资源面板失败', error);
|
42
|
-
}
|
43
|
+
}
|
44
|
+
|
45
|
+
var hanleResize = function hanleResize() {
|
46
|
+
if (viewRef.current) {
|
47
|
+
topo.getHtTopo().invalideComponents();
|
48
|
+
}
|
49
|
+
};
|
43
50
|
|
51
|
+
var resizeObserver = new _resizeObserverPolyfill["default"](hanleResize);
|
52
|
+
resizeObserver.observe(container); // 注销组件
|
44
53
|
|
45
54
|
return function () {
|
55
|
+
resizeObserver.disconnect();
|
56
|
+
|
46
57
|
if (viewRef.current) {
|
47
58
|
viewRef.current.destroy();
|
48
59
|
viewRef.current = null;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports.formatBackgroundRgbaColor = formatBackgroundRgbaColor;
|
7
|
+
exports.formatHexColor = formatHexColor;
|
8
|
+
exports.parseColor = parseColor;
|
9
|
+
|
10
|
+
var _color = _interopRequireDefault(require("color"));
|
11
|
+
|
12
|
+
/**
|
13
|
+
* 解析颜色字符串为对象
|
14
|
+
*
|
15
|
+
* @param {string} colorStr
|
16
|
+
* @returns {null|{hex, rgb:{r,g,b,a}}}
|
17
|
+
*/
|
18
|
+
function parseColor(colorStr) {
|
19
|
+
if (!colorStr) {
|
20
|
+
return null;
|
21
|
+
}
|
22
|
+
|
23
|
+
var color = (0, _color["default"])(colorStr);
|
24
|
+
var rgb = color.rgb();
|
25
|
+
return {
|
26
|
+
hex: color.hex(),
|
27
|
+
rgb: {
|
28
|
+
r: rgb.color[0],
|
29
|
+
g: rgb.color[1],
|
30
|
+
b: rgb.color[2],
|
31
|
+
a: rgb.valpha
|
32
|
+
}
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
function formatHexColor(color) {
|
37
|
+
return color ? color.hex : null;
|
38
|
+
}
|
39
|
+
/**
|
40
|
+
* 格式化背景rgba颜色
|
41
|
+
* @param {{background, opacity}} prevColor
|
42
|
+
* @param {{background, opacity}} currentColor
|
43
|
+
*/
|
44
|
+
|
45
|
+
|
46
|
+
function formatBackgroundRgbaColor(prevColor, currentColor) {
|
47
|
+
if (!('background' in currentColor) && !('opacity' in currentColor)) {
|
48
|
+
return null;
|
49
|
+
}
|
50
|
+
|
51
|
+
var colorObj = Object.assign(prevColor, currentColor);
|
52
|
+
var background = colorObj.background,
|
53
|
+
opacity = colorObj.opacity;
|
54
|
+
|
55
|
+
if (!background) {
|
56
|
+
return null;
|
57
|
+
}
|
58
|
+
|
59
|
+
var rgb = background.rgb;
|
60
|
+
return "rgba(" + rgb.r + ", " + rgb.g + ", " + rgb.b + ", " + opacity + ")";
|
61
|
+
}
|
@@ -8,9 +8,14 @@ exports.setTextStyle = setTextStyle;
|
|
8
8
|
function getTextStyle(element) {
|
9
9
|
return {
|
10
10
|
color: null,
|
11
|
+
// 文字颜色
|
11
12
|
fontFamily: null,
|
12
|
-
fontSize: null,
|
13
|
-
|
13
|
+
fontSize: null // fontBold: false, // 文字样式加粗 @V1.2
|
14
|
+
// fontItalic: false, // 文字样式斜体 @V1.2
|
15
|
+
// fontUnderline: false, // 文字样式下划线 @V1.2
|
16
|
+
// background: {rgb: {}, hex: ''}, // 背景颜色,rgba格式。null表示无
|
17
|
+
// opacity: 1, // 背景透明度。值范围 0-1, null,null表示无
|
18
|
+
|
14
19
|
};
|
15
20
|
}
|
16
21
|
|
@@ -11,21 +11,36 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
11
11
|
|
12
12
|
var _fontStyleUtil = _interopRequireDefault(require("../../../../../../settings/common/text/fontStyleUtil"));
|
13
13
|
|
14
|
+
var _colorUtil = require("../colorUtil");
|
15
|
+
|
14
16
|
function getTextStyle(element) {
|
17
|
+
var _background$rgb;
|
18
|
+
|
15
19
|
var underline = element.s('text.decoration') === 'underline';
|
20
|
+
var background = (0, _colorUtil.parseColor)(element.s('textBackground'));
|
16
21
|
return (0, _extends2["default"])({
|
17
|
-
color:
|
22
|
+
color: (0, _colorUtil.parseColor)(element.s('text.color')),
|
18
23
|
underline: underline
|
19
|
-
}, _fontStyleUtil["default"].toMap(element.s('text.font'))
|
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
|
+
});
|
20
30
|
}
|
21
31
|
|
22
32
|
function setTextStyle(element, style) {
|
23
|
-
var underline = style.underline;
|
24
|
-
|
25
33
|
if ('underline' in style) {
|
26
|
-
element.s('text.decoration', underline ? 'underline' : null);
|
34
|
+
element.s('text.decoration', style.underline ? 'underline' : null);
|
27
35
|
}
|
28
36
|
|
37
|
+
if ('color' in style) {
|
38
|
+
element.s('text.color', style.color.hex);
|
39
|
+
} // 背景颜色
|
40
|
+
|
41
|
+
|
42
|
+
var prevStyle = getTextStyle(element);
|
43
|
+
element.s('textBackground', (0, _colorUtil.formatBackgroundRgbaColor)(prevStyle, style));
|
29
44
|
var fontStyle = (0, _extends2["default"])({}, getTextStyle(element), style);
|
30
45
|
|
31
46
|
var fontStr = _fontStyleUtil["default"].build(fontStyle);
|
@@ -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.
|
55
|
+
var version = typeof "6.0.0-alpha.35" === 'string' ? "6.0.0-alpha.35" : 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.
|
3
|
+
"version": "6.0.0-alpha.35",
|
4
4
|
"description": "拓扑",
|
5
5
|
"scripts": {
|
6
6
|
"start": "build-scripts start",
|
@@ -41,6 +41,7 @@
|
|
41
41
|
"@ahooksjs/use-sortable-plugin": "^0.2.1",
|
42
42
|
"@ahooksjs/use-tree-plugin": "^0.2.1",
|
43
43
|
"@alifd/biz-anchor": "^1.1.7",
|
44
|
+
"color": "^4.2.3",
|
44
45
|
"@ice/store": "^1.4.2",
|
45
46
|
"@riil-frontend/component-topo-icon-select": "^1.0.17",
|
46
47
|
"@riil-frontend/component-topology-utils": "^2.1.0",
|
@@ -115,6 +116,6 @@
|
|
115
116
|
"access": "public"
|
116
117
|
},
|
117
118
|
"license": "MIT",
|
118
|
-
"homepage": "https://unpkg.com/@riil-frontend/component-topology@6.0.0-alpha.
|
119
|
+
"homepage": "https://unpkg.com/@riil-frontend/component-topology@6.0.0-alpha.35/build/index.html",
|
119
120
|
"gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
|
120
121
|
}
|