@riil-frontend/component-topology 2.4.6 → 2.5.2
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 +1 -1
- package/build/index.css +1 -1
- package/build/index.html +1 -1
- package/build/index.js +12 -12
- package/demo/5/345/205/266/344/273/226/347/273/204/344/273/266//350/265/204/346/272/220/346/246/202/350/247/210/347/273/204/344/273/266.md +9 -0
- package/demo/API//345/270/203/345/261/200.md +16 -0
- package/es/core/components/titlebar/TitleBar.module.scss +2 -1
- package/es/core/editor/components/settings/Settings.js +4 -1
- package/es/core/editor/components/settings/common/NodeSizeInput/NodeSizeInput.js +61 -18
- package/es/core/editor/components/settings/common/text/TextStyle.js +6 -1
- package/es/core/editor/components/settings/node/NodePropertyView.js +4 -2
- package/es/core/editor/components/settings/useSettingRuntimeState.d.ts +5 -0
- package/es/core/editor/components/settings/useSettingRuntimeState.js +23 -0
- package/es/core/models/TopoApp.js +4 -0
- package/es/core/viewer/components/titlebar/TopoViewerTitleBar.js +2 -4
- package/es/core/viewer/components/titlebar/ViewerTools.js +1 -4
- package/es/models/topoMod.js +0 -1
- package/es/style.js +0 -1
- package/es/topoCenter/models/TopoCenter.js +0 -6
- package/es/topoCenter/store/topoCenter.d.ts +0 -1
- package/es/topoCenter/store/topoCenter.js +1 -4
- package/es/utils/htElementUtils.js +4 -2
- package/lib/core/components/titlebar/TitleBar.module.scss +2 -1
- package/lib/core/editor/components/settings/Settings.js +5 -1
- package/lib/core/editor/components/settings/common/NodeSizeInput/NodeSizeInput.js +67 -18
- package/lib/core/editor/components/settings/common/text/TextStyle.js +6 -1
- package/lib/core/editor/components/settings/node/NodePropertyView.js +4 -2
- package/lib/core/editor/components/settings/useSettingRuntimeState.d.ts +5 -0
- package/lib/core/editor/components/settings/useSettingRuntimeState.js +32 -0
- package/lib/core/models/TopoApp.js +4 -0
- package/lib/core/viewer/components/titlebar/TopoViewerTitleBar.js +4 -8
- package/lib/core/viewer/components/titlebar/ViewerTools.js +1 -5
- package/lib/models/topoMod.js +0 -1
- package/lib/style.js +0 -1
- package/lib/topoCenter/models/TopoCenter.js +0 -6
- package/lib/topoCenter/store/topoCenter.d.ts +0 -1
- package/lib/topoCenter/store/topoCenter.js +1 -4
- package/lib/utils/htElementUtils.js +4 -2
- package/package.json +13 -13
- package/demo/5/345/205/266/344/273/226/347/273/204/344/273/266//351/200/211/346/213/251/350/265/204/346/272/220/346/214/211/351/222/256.md +0 -12
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 布局
|
|
3
|
+
order: 5
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
```text
|
|
7
|
+
//layoutName:
|
|
8
|
+
//星型布局:'circular',均衡布局:'hierarchical',
|
|
9
|
+
//树型布局:纵向:’towardsouth‘,横向’towardeast‘
|
|
10
|
+
|
|
11
|
+
let layout = new ht.layout.AutoLayout(graphView);
|
|
12
|
+
layout.layout(layoutName, function(){
|
|
13
|
+
//此处可以添加一些布局后的操作,如不需要,请忽略
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
```
|
|
@@ -8,6 +8,7 @@ import TextPropertyView from "./text/TextPropertyView";
|
|
|
8
8
|
import NodePropertyView from "./node/NodePropertyView";
|
|
9
9
|
import ViewPropertyView from "./view/ViewPropertyView";
|
|
10
10
|
import LinkPropertyView from "./link/LinkPropertyView";
|
|
11
|
+
import useSettingRuntimeState from "./useSettingRuntimeState";
|
|
11
12
|
|
|
12
13
|
function getElementType(selection) {
|
|
13
14
|
var selectionElement = selection[0];
|
|
@@ -37,6 +38,7 @@ export default function Settings(props) {
|
|
|
37
38
|
topoEditApi = props.topoEditApi,
|
|
38
39
|
selection = props.selection,
|
|
39
40
|
editorProps = props.editorProps;
|
|
41
|
+
var settingRuntimeState = useSettingRuntimeState();
|
|
40
42
|
var selectionSize = selection.length;
|
|
41
43
|
var selectionIds = selection.map(function (item) {
|
|
42
44
|
return item.id;
|
|
@@ -112,7 +114,8 @@ export default function Settings(props) {
|
|
|
112
114
|
selection: selection,
|
|
113
115
|
values: values,
|
|
114
116
|
onChange: updateElementProperty,
|
|
115
|
-
editorProps: editorProps
|
|
117
|
+
editorProps: editorProps,
|
|
118
|
+
settingRuntimeState: settingRuntimeState
|
|
116
119
|
})));
|
|
117
120
|
}
|
|
118
121
|
;
|
|
@@ -5,9 +5,11 @@ import React, { useState } from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import NodeSizeNumberPicker from "./NodeSizeNumberPicker";
|
|
7
7
|
import styles from "./NodeSizeInput.module.scss";
|
|
8
|
+
import rlog from "@riil-frontend/component-topology-utils/es/utils/rlog";
|
|
8
9
|
var FormItem = _Form.Item;
|
|
9
10
|
var Row = _Grid.Row,
|
|
10
11
|
Col = _Grid.Col;
|
|
12
|
+
var NODE_SIZE_LOCK = 'NODE_SIZE_LOCK';
|
|
11
13
|
/**
|
|
12
14
|
* 节点大小组件
|
|
13
15
|
*
|
|
@@ -15,12 +17,12 @@ var Row = _Grid.Row,
|
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
19
|
function NodeSizeInput(props) {
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
var node = props.node,
|
|
21
|
+
value = props.value,
|
|
22
|
+
onChange = props.onChange,
|
|
23
|
+
settingRuntimeState = props.settingRuntimeState;
|
|
24
|
+
var lock = settingRuntimeState.getAttr(NODE_SIZE_LOCK) !== false;
|
|
25
|
+
var RUNTIME_STATE_NAME_NODE_SIZE_INFO = "NODE_SIZE_INFO." + node.id;
|
|
24
26
|
|
|
25
27
|
var handleValue = function handleValue(val) {
|
|
26
28
|
if (!val || val < 1) {
|
|
@@ -34,22 +36,70 @@ function NodeSizeInput(props) {
|
|
|
34
36
|
return parseInt(val);
|
|
35
37
|
};
|
|
36
38
|
|
|
39
|
+
function initSizeRatio() {
|
|
40
|
+
var ratioInfo = {
|
|
41
|
+
ratio: value.width / value.height,
|
|
42
|
+
size: value
|
|
43
|
+
};
|
|
44
|
+
updateSizeRatioCurrentSize(ratioInfo);
|
|
45
|
+
rlog.debug('initSizeRatio', ratioInfo);
|
|
46
|
+
return ratioInfo;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function updateSizeRatioCurrentSize(ratioInfo) {
|
|
50
|
+
settingRuntimeState.setAttr(RUNTIME_STATE_NAME_NODE_SIZE_INFO, ratioInfo);
|
|
51
|
+
return ratioInfo;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getSizeRatio() {
|
|
55
|
+
return settingRuntimeState.getAttr(RUNTIME_STATE_NAME_NODE_SIZE_INFO);
|
|
56
|
+
}
|
|
57
|
+
|
|
37
58
|
var handleChange = function handleChange(name, attrValue) {
|
|
38
59
|
var _extends2;
|
|
39
60
|
|
|
40
61
|
var newSize = _extends({}, value, (_extends2 = {}, _extends2[name] = attrValue, _extends2));
|
|
41
62
|
|
|
42
63
|
if (lock) {
|
|
64
|
+
var ratioInfo = getSizeRatio();
|
|
65
|
+
|
|
66
|
+
if (!ratioInfo) {
|
|
67
|
+
// 首次没有比例时,初始化当前节点比例
|
|
68
|
+
ratioInfo = initSizeRatio();
|
|
69
|
+
rlog.debug('首次没有比例时,初始化当前节点比例', ratioInfo);
|
|
70
|
+
} else {
|
|
71
|
+
// 修改后,非锁定方式调整比例(画图调整节点大小,未开启锁定修改),重新初始化比例
|
|
72
|
+
var prevSize = ratioInfo.size;
|
|
73
|
+
|
|
74
|
+
if (value.width !== prevSize.width || value.height !== prevSize.height) {
|
|
75
|
+
ratioInfo = initSizeRatio();
|
|
76
|
+
rlog.debug('修改后,重新初始化比例', ratioInfo);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var ratio = ratioInfo.ratio;
|
|
81
|
+
|
|
43
82
|
if (name === 'width') {
|
|
44
|
-
newSize.height = handleValue(
|
|
83
|
+
newSize.height = handleValue(attrValue / ratio);
|
|
45
84
|
} else {
|
|
46
|
-
newSize.width = handleValue(
|
|
85
|
+
newSize.width = handleValue(attrValue * ratio);
|
|
47
86
|
}
|
|
87
|
+
|
|
88
|
+
updateSizeRatioCurrentSize({
|
|
89
|
+
ratio: ratio,
|
|
90
|
+
size: newSize
|
|
91
|
+
});
|
|
92
|
+
rlog.debug('按比例更新', name, attrValue, ratio, value, newSize, ratioInfo);
|
|
48
93
|
}
|
|
49
94
|
|
|
50
95
|
onChange(newSize);
|
|
51
96
|
};
|
|
52
97
|
|
|
98
|
+
var switchLock = function switchLock() {
|
|
99
|
+
var isLock = !lock;
|
|
100
|
+
settingRuntimeState.setAttr(NODE_SIZE_LOCK, isLock);
|
|
101
|
+
};
|
|
102
|
+
|
|
53
103
|
function parseValue(val) {
|
|
54
104
|
return val ? parseInt(val) : val;
|
|
55
105
|
}
|
|
@@ -76,16 +126,9 @@ function NodeSizeInput(props) {
|
|
|
76
126
|
}
|
|
77
127
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
78
128
|
className: styles.lockBtn,
|
|
79
|
-
onClick:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}, lock ? /*#__PURE__*/React.createElement("img", {
|
|
83
|
-
src: require("./img/icon_\u89E3\u9501.svg"),
|
|
84
|
-
title: "\u89E3\u9501",
|
|
85
|
-
alt: ""
|
|
86
|
-
}) : /*#__PURE__*/React.createElement("img", {
|
|
87
|
-
src: require("./img/icon_\u9501.svg"),
|
|
88
|
-
title: "\u9501\u5B9A",
|
|
129
|
+
onClick: switchLock
|
|
130
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
131
|
+
src: require(lock ? './img/icon_锁.svg' : './img/icon_解锁.svg'),
|
|
89
132
|
alt: ""
|
|
90
133
|
})), /*#__PURE__*/React.createElement(Col, null, /*#__PURE__*/React.createElement(FormItem, {
|
|
91
134
|
required: true,
|
|
@@ -9,7 +9,7 @@ var Option = _Select.Option;
|
|
|
9
9
|
|
|
10
10
|
function parseValue(value) {
|
|
11
11
|
return {
|
|
12
|
-
fontFamily: value.font.fontFamily || '
|
|
12
|
+
fontFamily: value.font.fontFamily || 'Arial',
|
|
13
13
|
fontSize: value.font.fontSize || 12,
|
|
14
14
|
color: value.color || '#000000',
|
|
15
15
|
fontStyleChecked: {
|
|
@@ -28,6 +28,11 @@ export default function TextStyle(props) {
|
|
|
28
28
|
autoUnmount: false,
|
|
29
29
|
values: parseValue(value),
|
|
30
30
|
onChange: function onChange(name, value) {
|
|
31
|
+
// 解决问题:文本设置,当前字号8,选中字号,点击退格键,字号变为12了
|
|
32
|
+
if (name === 'fontSize' && !value) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
var values = field.getValues();
|
|
32
37
|
var aValues = {
|
|
33
38
|
color: values.color,
|
|
@@ -37,7 +37,7 @@ export default function NodePropertyView(props) {
|
|
|
37
37
|
topoEditApi = props.topoEditApi,
|
|
38
38
|
values = props.values,
|
|
39
39
|
_onChange = props.onChange,
|
|
40
|
-
|
|
40
|
+
settingRuntimeState = props.settingRuntimeState;
|
|
41
41
|
var bindType = getBindType(values);
|
|
42
42
|
|
|
43
43
|
var field = _Field.useField({
|
|
@@ -135,6 +135,7 @@ export default function NodePropertyView(props) {
|
|
|
135
135
|
})), /*#__PURE__*/React.createElement(_Form.Item, {
|
|
136
136
|
label: "\u56FE\u7247\u5C3A\u5BF8"
|
|
137
137
|
}, /*#__PURE__*/React.createElement(NodeSizeInput, {
|
|
138
|
+
node: values,
|
|
138
139
|
value: {
|
|
139
140
|
width: values.width,
|
|
140
141
|
height: values.height
|
|
@@ -143,7 +144,8 @@ export default function NodePropertyView(props) {
|
|
|
143
144
|
_onChange('width', size.width);
|
|
144
145
|
|
|
145
146
|
_onChange('height', size.height);
|
|
146
|
-
}
|
|
147
|
+
},
|
|
148
|
+
settingRuntimeState: settingRuntimeState
|
|
147
149
|
}))))));
|
|
148
150
|
}; // 未绑定资源的节点,根据参数控制是否可关联资源
|
|
149
151
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
export default function () {
|
|
4
|
+
var _useState = useState({}),
|
|
5
|
+
state = _useState[0],
|
|
6
|
+
setState = _useState[1];
|
|
7
|
+
|
|
8
|
+
function setAttr(name, value) {
|
|
9
|
+
var _extends2;
|
|
10
|
+
|
|
11
|
+
setState(_extends({}, state, (_extends2 = {}, _extends2[name] = value, _extends2)));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getAttr(name) {
|
|
15
|
+
return state[name];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
state: state,
|
|
20
|
+
getAttr: getAttr,
|
|
21
|
+
setAttr: setAttr
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -423,6 +423,10 @@ var TopoApp = /*#__PURE__*/function () {
|
|
|
423
423
|
return refresh;
|
|
424
424
|
}();
|
|
425
425
|
|
|
426
|
+
_proto.getGraphView = function getGraphView() {
|
|
427
|
+
return this.view.topoClient.getGraphView();
|
|
428
|
+
};
|
|
429
|
+
|
|
426
430
|
_proto.getDataModel = function getDataModel() {
|
|
427
431
|
return this.view.topoClient.getDataModel();
|
|
428
432
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import _MenuButton from "@alifd/next/lib/menu-button";
|
|
2
1
|
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
2
|
import ViewerTools from "./ViewerTools";
|
|
4
|
-
import TitleWidget from "../../../components/titlebar/widgets/TitleWidget";
|
|
5
3
|
import styles from "../../../components/titlebar/TitleBar.module.scss";
|
|
6
|
-
|
|
4
|
+
import SearchWidget from "./widgets/SearchWidget";
|
|
7
5
|
export default function TopoViewerTitleBar(props) {
|
|
8
6
|
var topo = props.topo,
|
|
9
7
|
showEditButton = props.showEditButton,
|
|
@@ -13,7 +11,7 @@ export default function TopoViewerTitleBar(props) {
|
|
|
13
11
|
className: styles.titlebar
|
|
14
12
|
}, /*#__PURE__*/React.createElement("div", {
|
|
15
13
|
className: styles.left
|
|
16
|
-
}, children || /*#__PURE__*/React.createElement(
|
|
14
|
+
}, children || /*#__PURE__*/React.createElement(SearchWidget, {
|
|
17
15
|
topo: topo
|
|
18
16
|
})), /*#__PURE__*/React.createElement("div", {
|
|
19
17
|
className: styles.right
|
|
@@ -4,16 +4,13 @@ import _Button from "@alifd/next/lib/button";
|
|
|
4
4
|
import _Icon from "@alifd/next/lib/icon";
|
|
5
5
|
import _extends from "@babel/runtime/helpers/extends";
|
|
6
6
|
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
7
|
-
import SearchWidget from "./widgets/SearchWidget";
|
|
8
7
|
import styles from "../../../components/titlebar/TitleBar.module.scss";
|
|
9
8
|
import EditButton from "./widgets/EditButton";
|
|
10
9
|
export default function ViewerTools(props) {
|
|
11
10
|
var topo = props.topo,
|
|
12
11
|
_props$showEditButton = props.showEditButton,
|
|
13
12
|
showEditButton = _props$showEditButton === void 0 ? true : _props$showEditButton;
|
|
14
|
-
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(
|
|
15
|
-
topo: topo
|
|
16
|
-
}), showEditButton && /*#__PURE__*/React.createElement(EditButton, _extends({
|
|
13
|
+
return /*#__PURE__*/React.createElement("div", null, showEditButton && /*#__PURE__*/React.createElement(EditButton, _extends({
|
|
17
14
|
topo: topo
|
|
18
15
|
}, props)), /*#__PURE__*/React.createElement(_Dropdown, {
|
|
19
16
|
trigger: /*#__PURE__*/React.createElement(_Button, {
|
package/es/models/topoMod.js
CHANGED
package/es/style.js
CHANGED
|
@@ -18,7 +18,6 @@ import '@alifd/next/lib/select/style';
|
|
|
18
18
|
import '@alifd/next/lib/balloon/style';
|
|
19
19
|
import '@alifd/next/lib/grid/style';
|
|
20
20
|
import '@alifd/next/lib/box/style';
|
|
21
|
-
import '@alifd/next/lib/menu-button/style';
|
|
22
21
|
import '@alifd/next/lib/dropdown/style';
|
|
23
22
|
import '@alifd/next/lib/menu/style';
|
|
24
23
|
import '@alifd/next/lib/tab/style';
|
|
@@ -29,12 +29,6 @@ var TopoCenter = /*#__PURE__*/function (_TopoApp) {
|
|
|
29
29
|
id: _this.id
|
|
30
30
|
});
|
|
31
31
|
topoModDispatchers.refreshTopoTree();
|
|
32
|
-
|
|
33
|
-
var topoCenterDispatchers = _this.store.getModelDispatchers('topoCenter');
|
|
34
|
-
|
|
35
|
-
topoCenterDispatchers.update({
|
|
36
|
-
leftAsideOpen: true
|
|
37
|
-
});
|
|
38
32
|
}
|
|
39
33
|
})) || this;
|
|
40
34
|
var menuCommands = createMenuCommands(_assertThisInitialized(_this));
|
|
@@ -14,8 +14,6 @@ export default {
|
|
|
14
14
|
state: {
|
|
15
15
|
loading: true,
|
|
16
16
|
id: undefined,
|
|
17
|
-
leftAsideOpen: true,
|
|
18
|
-
// 左侧树是否展开
|
|
19
17
|
viewState: 'view' // view, create, 2种模式
|
|
20
18
|
|
|
21
19
|
},
|
|
@@ -47,8 +45,7 @@ export default {
|
|
|
47
45
|
id = urlParams.id || topoModState.topoId || '';
|
|
48
46
|
|
|
49
47
|
_this.update({
|
|
50
|
-
viewState: viewType
|
|
51
|
-
leftAsideOpen: viewType !== 'edit'
|
|
48
|
+
viewState: viewType
|
|
52
49
|
}); // 加载功能操作权限
|
|
53
50
|
|
|
54
51
|
|
|
@@ -64,9 +64,11 @@ export function getEdges(dataModel) {
|
|
|
64
64
|
return getElements(dataModel).filter(function (element) {
|
|
65
65
|
return element.getClassName() === 'ht.Edge';
|
|
66
66
|
}).map(function (element) {
|
|
67
|
+
var _element$getSource, _element$getTarget;
|
|
68
|
+
|
|
67
69
|
return _extends({}, element.getAttrObject(), {
|
|
68
|
-
source: element.getSource().getTag(),
|
|
69
|
-
target: element.getTarget().getTag(),
|
|
70
|
+
source: (_element$getSource = element.getSource()) === null || _element$getSource === void 0 ? void 0 : _element$getSource.getTag(),
|
|
71
|
+
target: (_element$getTarget = element.getTarget()) === null || _element$getTarget === void 0 ? void 0 : _element$getTarget.getTag(),
|
|
70
72
|
tag: element.getId()
|
|
71
73
|
});
|
|
72
74
|
});
|
|
@@ -27,6 +27,8 @@ var _ViewPropertyView = _interopRequireDefault(require("./view/ViewPropertyView"
|
|
|
27
27
|
|
|
28
28
|
var _LinkPropertyView = _interopRequireDefault(require("./link/LinkPropertyView"));
|
|
29
29
|
|
|
30
|
+
var _useSettingRuntimeState = _interopRequireDefault(require("./useSettingRuntimeState"));
|
|
31
|
+
|
|
30
32
|
function getElementType(selection) {
|
|
31
33
|
var selectionElement = selection[0];
|
|
32
34
|
var selectionSize = selection.length;
|
|
@@ -55,6 +57,7 @@ function Settings(props) {
|
|
|
55
57
|
topoEditApi = props.topoEditApi,
|
|
56
58
|
selection = props.selection,
|
|
57
59
|
editorProps = props.editorProps;
|
|
60
|
+
var settingRuntimeState = (0, _useSettingRuntimeState["default"])();
|
|
58
61
|
var selectionSize = selection.length;
|
|
59
62
|
var selectionIds = selection.map(function (item) {
|
|
60
63
|
return item.id;
|
|
@@ -128,7 +131,8 @@ function Settings(props) {
|
|
|
128
131
|
selection: selection,
|
|
129
132
|
values: values,
|
|
130
133
|
onChange: updateElementProperty,
|
|
131
|
-
editorProps: editorProps
|
|
134
|
+
editorProps: editorProps,
|
|
135
|
+
settingRuntimeState: settingRuntimeState
|
|
132
136
|
})));
|
|
133
137
|
}
|
|
134
138
|
|
|
@@ -21,9 +21,12 @@ var _NodeSizeNumberPicker = _interopRequireDefault(require("./NodeSizeNumberPick
|
|
|
21
21
|
|
|
22
22
|
var _NodeSizeInputModule = _interopRequireDefault(require("./NodeSizeInput.module.scss"));
|
|
23
23
|
|
|
24
|
+
var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/utils/rlog"));
|
|
25
|
+
|
|
24
26
|
var FormItem = _form["default"].Item;
|
|
25
27
|
var Row = _grid["default"].Row,
|
|
26
28
|
Col = _grid["default"].Col;
|
|
29
|
+
var NODE_SIZE_LOCK = 'NODE_SIZE_LOCK';
|
|
27
30
|
/**
|
|
28
31
|
* 节点大小组件
|
|
29
32
|
*
|
|
@@ -31,12 +34,12 @@ var Row = _grid["default"].Row,
|
|
|
31
34
|
*/
|
|
32
35
|
|
|
33
36
|
function NodeSizeInput(props) {
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
var node = props.node,
|
|
38
|
+
value = props.value,
|
|
39
|
+
onChange = props.onChange,
|
|
40
|
+
settingRuntimeState = props.settingRuntimeState;
|
|
41
|
+
var lock = settingRuntimeState.getAttr(NODE_SIZE_LOCK) !== false;
|
|
42
|
+
var RUNTIME_STATE_NAME_NODE_SIZE_INFO = "NODE_SIZE_INFO." + node.id;
|
|
40
43
|
|
|
41
44
|
var handleValue = function handleValue(val) {
|
|
42
45
|
if (!val || val < 1) {
|
|
@@ -50,22 +53,75 @@ function NodeSizeInput(props) {
|
|
|
50
53
|
return parseInt(val);
|
|
51
54
|
};
|
|
52
55
|
|
|
56
|
+
function initSizeRatio() {
|
|
57
|
+
var ratioInfo = {
|
|
58
|
+
ratio: value.width / value.height,
|
|
59
|
+
size: value
|
|
60
|
+
};
|
|
61
|
+
updateSizeRatioCurrentSize(ratioInfo);
|
|
62
|
+
|
|
63
|
+
_rlog["default"].debug('initSizeRatio', ratioInfo);
|
|
64
|
+
|
|
65
|
+
return ratioInfo;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function updateSizeRatioCurrentSize(ratioInfo) {
|
|
69
|
+
settingRuntimeState.setAttr(RUNTIME_STATE_NAME_NODE_SIZE_INFO, ratioInfo);
|
|
70
|
+
return ratioInfo;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getSizeRatio() {
|
|
74
|
+
return settingRuntimeState.getAttr(RUNTIME_STATE_NAME_NODE_SIZE_INFO);
|
|
75
|
+
}
|
|
76
|
+
|
|
53
77
|
var handleChange = function handleChange(name, attrValue) {
|
|
54
78
|
var _extends2;
|
|
55
79
|
|
|
56
80
|
var newSize = (0, _extends3["default"])({}, value, (_extends2 = {}, _extends2[name] = attrValue, _extends2));
|
|
57
81
|
|
|
58
82
|
if (lock) {
|
|
83
|
+
var ratioInfo = getSizeRatio();
|
|
84
|
+
|
|
85
|
+
if (!ratioInfo) {
|
|
86
|
+
// 首次没有比例时,初始化当前节点比例
|
|
87
|
+
ratioInfo = initSizeRatio();
|
|
88
|
+
|
|
89
|
+
_rlog["default"].debug('首次没有比例时,初始化当前节点比例', ratioInfo);
|
|
90
|
+
} else {
|
|
91
|
+
// 修改后,非锁定方式调整比例(画图调整节点大小,未开启锁定修改),重新初始化比例
|
|
92
|
+
var prevSize = ratioInfo.size;
|
|
93
|
+
|
|
94
|
+
if (value.width !== prevSize.width || value.height !== prevSize.height) {
|
|
95
|
+
ratioInfo = initSizeRatio();
|
|
96
|
+
|
|
97
|
+
_rlog["default"].debug('修改后,重新初始化比例', ratioInfo);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
var ratio = ratioInfo.ratio;
|
|
102
|
+
|
|
59
103
|
if (name === 'width') {
|
|
60
|
-
newSize.height = handleValue(
|
|
104
|
+
newSize.height = handleValue(attrValue / ratio);
|
|
61
105
|
} else {
|
|
62
|
-
newSize.width = handleValue(
|
|
106
|
+
newSize.width = handleValue(attrValue * ratio);
|
|
63
107
|
}
|
|
108
|
+
|
|
109
|
+
updateSizeRatioCurrentSize({
|
|
110
|
+
ratio: ratio,
|
|
111
|
+
size: newSize
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
_rlog["default"].debug('按比例更新', name, attrValue, ratio, value, newSize, ratioInfo);
|
|
64
115
|
}
|
|
65
116
|
|
|
66
117
|
onChange(newSize);
|
|
67
118
|
};
|
|
68
119
|
|
|
120
|
+
var switchLock = function switchLock() {
|
|
121
|
+
var isLock = !lock;
|
|
122
|
+
settingRuntimeState.setAttr(NODE_SIZE_LOCK, isLock);
|
|
123
|
+
};
|
|
124
|
+
|
|
69
125
|
function parseValue(val) {
|
|
70
126
|
return val ? parseInt(val) : val;
|
|
71
127
|
}
|
|
@@ -92,16 +148,9 @@ function NodeSizeInput(props) {
|
|
|
92
148
|
}
|
|
93
149
|
}))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
94
150
|
className: _NodeSizeInputModule["default"].lockBtn,
|
|
95
|
-
onClick:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}, lock ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
99
|
-
src: require("./img/icon_\u89E3\u9501.svg"),
|
|
100
|
-
title: "\u89E3\u9501",
|
|
101
|
-
alt: ""
|
|
102
|
-
}) : /*#__PURE__*/_react["default"].createElement("img", {
|
|
103
|
-
src: require("./img/icon_\u9501.svg"),
|
|
104
|
-
title: "\u9501\u5B9A",
|
|
151
|
+
onClick: switchLock
|
|
152
|
+
}, /*#__PURE__*/_react["default"].createElement("img", {
|
|
153
|
+
src: require(lock ? './img/icon_锁.svg' : './img/icon_解锁.svg'),
|
|
105
154
|
alt: ""
|
|
106
155
|
})), /*#__PURE__*/_react["default"].createElement(Col, null, /*#__PURE__*/_react["default"].createElement(FormItem, {
|
|
107
156
|
required: true,
|
|
@@ -25,7 +25,7 @@ var Option = _select["default"].Option;
|
|
|
25
25
|
|
|
26
26
|
function parseValue(value) {
|
|
27
27
|
return {
|
|
28
|
-
fontFamily: value.font.fontFamily || '
|
|
28
|
+
fontFamily: value.font.fontFamily || 'Arial',
|
|
29
29
|
fontSize: value.font.fontSize || 12,
|
|
30
30
|
color: value.color || '#000000',
|
|
31
31
|
fontStyleChecked: {
|
|
@@ -44,6 +44,11 @@ function TextStyle(props) {
|
|
|
44
44
|
autoUnmount: false,
|
|
45
45
|
values: parseValue(value),
|
|
46
46
|
onChange: function onChange(name, value) {
|
|
47
|
+
// 解决问题:文本设置,当前字号8,选中字号,点击退格键,字号变为12了
|
|
48
|
+
if (name === 'fontSize' && !value) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
47
52
|
var values = field.getValues();
|
|
48
53
|
var aValues = {
|
|
49
54
|
color: values.color,
|
|
@@ -59,7 +59,7 @@ function NodePropertyView(props) {
|
|
|
59
59
|
topoEditApi = props.topoEditApi,
|
|
60
60
|
values = props.values,
|
|
61
61
|
_onChange = props.onChange,
|
|
62
|
-
|
|
62
|
+
settingRuntimeState = props.settingRuntimeState;
|
|
63
63
|
var bindType = getBindType(values);
|
|
64
64
|
|
|
65
65
|
var field = _field["default"].useField({
|
|
@@ -157,6 +157,7 @@ function NodePropertyView(props) {
|
|
|
157
157
|
})), /*#__PURE__*/_react["default"].createElement(_form["default"].Item, {
|
|
158
158
|
label: "\u56FE\u7247\u5C3A\u5BF8"
|
|
159
159
|
}, /*#__PURE__*/_react["default"].createElement(_NodeSizeInput["default"], {
|
|
160
|
+
node: values,
|
|
160
161
|
value: {
|
|
161
162
|
width: values.width,
|
|
162
163
|
height: values.height
|
|
@@ -165,7 +166,8 @@ function NodePropertyView(props) {
|
|
|
165
166
|
_onChange('width', size.width);
|
|
166
167
|
|
|
167
168
|
_onChange('height', size.height);
|
|
168
|
-
}
|
|
169
|
+
},
|
|
170
|
+
settingRuntimeState: settingRuntimeState
|
|
169
171
|
}))))));
|
|
170
172
|
}; // 未绑定资源的节点,根据参数控制是否可关联资源
|
|
171
173
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports["default"] = _default;
|
|
7
|
+
|
|
8
|
+
var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
|
|
12
|
+
function _default() {
|
|
13
|
+
var _useState = (0, _react.useState)({}),
|
|
14
|
+
state = _useState[0],
|
|
15
|
+
setState = _useState[1];
|
|
16
|
+
|
|
17
|
+
function setAttr(name, value) {
|
|
18
|
+
var _extends2;
|
|
19
|
+
|
|
20
|
+
setState((0, _extends3["default"])({}, state, (_extends2 = {}, _extends2[name] = value, _extends2)));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getAttr(name) {
|
|
24
|
+
return state[name];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
state: state,
|
|
29
|
+
getAttr: getAttr,
|
|
30
|
+
setAttr: setAttr
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -449,6 +449,10 @@ var TopoApp = /*#__PURE__*/function () {
|
|
|
449
449
|
return refresh;
|
|
450
450
|
}();
|
|
451
451
|
|
|
452
|
+
_proto.getGraphView = function getGraphView() {
|
|
453
|
+
return this.view.topoClient.getGraphView();
|
|
454
|
+
};
|
|
455
|
+
|
|
452
456
|
_proto.getDataModel = function getDataModel() {
|
|
453
457
|
return this.view.topoClient.getDataModel();
|
|
454
458
|
};
|