@riil-frontend/component-topology 6.0.0-alpha.31 → 6.0.0-alpha.32
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/index.css +1 -1
- package/build/index.js +2 -2
- package/es/core/editor/components/Toolbar/hooks/textStyleSetting/EmptySetting.js +8 -0
- package/es/core/editor/components/Toolbar/hooks/textStyleSetting/edgeTagSetting.js +8 -0
- package/es/core/editor/components/Toolbar/hooks/textStyleSetting/globalTag.js +36 -0
- package/es/core/editor/components/Toolbar/hooks/textStyleSetting/nodeTagSetting.js +8 -0
- package/es/core/editor/components/Toolbar/hooks/textStyleSetting/text.js +8 -0
- package/es/core/editor/components/Toolbar/hooks/useFontStyleSetting.js +47 -24
- package/es/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +16 -16
- package/es/core/editor/components/Toolbar/widgets/FontSizeWidget.js +20 -18
- package/es/core/editor/components/Toolbar/widgets/FontStyleButton.js +42 -45
- package/es/core/editor/components/Toolbar/widgets/NodeSizeButton/NodeSizeButton.js +3 -2
- package/es/core/editor/components/Toolbar/widgets/components/DropdownButton.js +4 -2
- package/es/core/editor/components/Toolbar/widgets/components/DropdownMenu.js +6 -1
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/ElementTextStyleSetting.js +40 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/edgeTag.js +13 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +13 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/index.js +12 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/layerTitle.js +13 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/nodeTag.js +13 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +25 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/textStyleUtil.js +46 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/GlobalTagStyleSetting/GlobalTagStyleSetting.js +25 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/GlobalTagStyleSetting/globalTag.js +36 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/textStyleSettingRouter.js +17 -0
- package/es/core/editor/components/settings/PropertyView.js +10 -4
- package/es/core/editor/components/settings/common/text/fontStyleUtil.js +5 -4
- package/es/core/editor/components/settings/propertyViews/text/TextPropertyView.js +1 -1
- package/es/core/models/TopoApp.js +1 -1
- package/lib/core/editor/components/Toolbar/hooks/textStyleSetting/EmptySetting.js +13 -0
- package/lib/core/editor/components/Toolbar/hooks/textStyleSetting/edgeTagSetting.js +13 -0
- package/lib/core/editor/components/Toolbar/hooks/textStyleSetting/globalTag.js +47 -0
- package/lib/core/editor/components/Toolbar/hooks/textStyleSetting/nodeTagSetting.js +13 -0
- package/lib/core/editor/components/Toolbar/hooks/textStyleSetting/text.js +13 -0
- package/lib/core/editor/components/Toolbar/hooks/useFontStyleSetting.js +54 -28
- package/lib/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +17 -16
- package/lib/core/editor/components/Toolbar/widgets/FontSizeWidget.js +21 -18
- package/lib/core/editor/components/Toolbar/widgets/FontStyleButton.js +43 -48
- package/lib/core/editor/components/Toolbar/widgets/NodeSizeButton/NodeSizeButton.js +3 -2
- package/lib/core/editor/components/Toolbar/widgets/components/DropdownButton.js +5 -2
- package/lib/core/editor/components/Toolbar/widgets/components/DropdownMenu.js +5 -1
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/ElementTextStyleSetting.js +54 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/edgeTag.js +23 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +23 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/index.js +25 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/layerTitle.js +23 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/nodeTag.js +23 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +40 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/textStyleUtil.js +58 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/GlobalTagStyleSetting/GlobalTagStyleSetting.js +39 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/GlobalTagStyleSetting/globalTag.js +47 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/textStyleSettingRouter.js +28 -0
- package/lib/core/editor/components/settings/PropertyView.js +11 -5
- package/lib/core/editor/components/settings/common/text/fontStyleUtil.js +5 -4
- package/lib/core/editor/components/settings/propertyViews/text/TextPropertyView.js +1 -1
- package/lib/core/models/TopoApp.js +1 -1
- package/package.json +2 -2
@@ -0,0 +1,36 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
var defaultStyle = {
|
3
|
+
color: '#AFB9C2',
|
4
|
+
fontFamily: '微软雅黑'
|
5
|
+
};
|
6
|
+
export function useValues(topo) {
|
7
|
+
var displayConfigState = topo.store.useModelState('displayConfig');
|
8
|
+
var nodeLabelStyle = displayConfigState.nodeLabelStyle,
|
9
|
+
defaultEdgeLabelStyle = displayConfigState.defaultEdgeLabelStyle;
|
10
|
+
return {
|
11
|
+
color: (nodeLabelStyle === null || nodeLabelStyle === void 0 ? void 0 : nodeLabelStyle.color) || defaultStyle.color,
|
12
|
+
fontFamily: (nodeLabelStyle === null || nodeLabelStyle === void 0 ? void 0 : nodeLabelStyle.fontFamily) || defaultStyle.fontFamily,
|
13
|
+
fontSize: nodeLabelStyle === null || nodeLabelStyle === void 0 ? void 0 : nodeLabelStyle.fontSize
|
14
|
+
};
|
15
|
+
}
|
16
|
+
export var setGlobalTagStyle = function setGlobalTagStyle(topo, styleData) {
|
17
|
+
var _topo$store$getModel = topo.store.getModel('displayConfig'),
|
18
|
+
displayConfigState = _topo$store$getModel[0],
|
19
|
+
displayConfigDispatchers = _topo$store$getModel[1];
|
20
|
+
|
21
|
+
var nodeLabelStyle = displayConfigState.nodeLabelStyle,
|
22
|
+
defaultEdgeLabelStyle = displayConfigState.defaultEdgeLabelStyle;
|
23
|
+
|
24
|
+
var globalNodeLabelStyle = _extends({}, nodeLabelStyle, styleData);
|
25
|
+
|
26
|
+
topo.getHtTopo().setGlobalNodeLabelStyle(globalNodeLabelStyle);
|
27
|
+
|
28
|
+
var globalEdgeTagStyle = _extends({}, defaultEdgeLabelStyle, styleData);
|
29
|
+
|
30
|
+
topo.getHtTopo().setGlobalEdgeTagStyle(globalEdgeTagStyle);
|
31
|
+
displayConfigDispatchers.update({
|
32
|
+
nodeLabelStyle: globalNodeLabelStyle,
|
33
|
+
defaultEdgeLabelStyle: globalEdgeTagStyle
|
34
|
+
});
|
35
|
+
};
|
36
|
+
export function setStyle() {}
|
@@ -1,42 +1,63 @@
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
2
1
|
import React, { useMemo } from 'react';
|
3
2
|
import { isText } from "../../../../../utils/htElementDataUtil";
|
4
3
|
import { isGroup, isLayer, isNode } from "../../../../../utils/htElementUtils";
|
4
|
+
import * as globalTagSetting from "./textStyleSetting/globalTag";
|
5
|
+
import * as EmptySetting from "./textStyleSetting/EmptySetting"; // 文本
|
5
6
|
|
6
|
-
function
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
function getElementType(element) {
|
8
|
+
if (isNode(element)) {
|
9
|
+
return 'nodeTag';
|
10
|
+
} else if (isGroup(element)) {
|
11
|
+
return 'group';
|
12
|
+
} else if (isText(element)) {
|
13
|
+
return 'text';
|
14
|
+
} else if (isLayer(element)) {
|
15
|
+
return 'layer';
|
16
|
+
}
|
17
|
+
|
18
|
+
return null;
|
19
|
+
}
|
20
|
+
|
21
|
+
function getType(selectionElements) {
|
22
|
+
if (!selectionElements.length) {
|
23
|
+
return 'globalTag';
|
24
|
+
} else if (selectionElements.length === 1) {
|
25
|
+
var element = selectionElements[0];
|
26
|
+
return getElementType(element);
|
27
|
+
}
|
10
28
|
|
11
|
-
|
12
|
-
|
13
|
-
displayConfigDispatchers = _topo$store$useModel[1];
|
29
|
+
return null;
|
30
|
+
}
|
14
31
|
|
15
|
-
|
16
|
-
|
32
|
+
var useValuesHookMap = {
|
33
|
+
globalTag: globalTagSetting.useValues,
|
34
|
+
empty: EmptySetting.useValues
|
35
|
+
};
|
17
36
|
|
18
|
-
|
19
|
-
|
37
|
+
function useValues(topo, selection) {
|
38
|
+
var type = getType(selection);
|
39
|
+
var useValuesHandle = useValuesHookMap[type] || useValuesHookMap.empty;
|
40
|
+
var values = useValuesHandle(topo, selection);
|
41
|
+
return values;
|
42
|
+
}
|
20
43
|
|
21
|
-
|
44
|
+
var elementSetStyleMap = {};
|
22
45
|
|
23
|
-
|
46
|
+
function useFontStyleSetting(props) {
|
47
|
+
var topo = props.topo;
|
48
|
+
var selection = topo.selectionManager.useHtSelection();
|
49
|
+
var buttonEnabled = true; // const values = useValues(topo, selection)
|
24
50
|
|
25
|
-
|
26
|
-
displayConfigDispatchers.update({
|
27
|
-
nodeLabelStyle: globalNodeLabelStyle,
|
28
|
-
defaultEdgeLabelStyle: globalEdgeTagStyle
|
29
|
-
});
|
30
|
-
};
|
51
|
+
var values = {};
|
31
52
|
|
32
53
|
var setStyle = function setStyle(styleData) {
|
33
54
|
topo.historyManager.beginTransaction(); // 全局调整(资源和链路):无选择时,按钮亮起,即可修改全局资源和链路的标注,不影响“文本”、框名称、区域名称、分层名称的格式。
|
34
55
|
|
35
|
-
if (!
|
36
|
-
setGlobalTagStyle(styleData);
|
56
|
+
if (!selection.length) {
|
57
|
+
globalTagSetting.setGlobalTagStyle(topo, styleData);
|
37
58
|
} else {
|
38
|
-
|
39
|
-
|
59
|
+
selection.forEach(function (element) {
|
60
|
+
var elementType = getElementType(element);
|
40
61
|
});
|
41
62
|
}
|
42
63
|
|
@@ -44,7 +65,9 @@ function useFontStyleSetting(props) {
|
|
44
65
|
};
|
45
66
|
|
46
67
|
return {
|
68
|
+
selection: selection,
|
47
69
|
buttonEnabled: buttonEnabled,
|
70
|
+
values: values,
|
48
71
|
setStyle: setStyle
|
49
72
|
};
|
50
73
|
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import React, { useState } from 'react';
|
2
|
-
import useFontStyleSetting from "../hooks/useFontStyleSetting";
|
1
|
+
import React, { useState, useEffect } from 'react';
|
3
2
|
import DropdownMenu from "./components/DropdownMenu";
|
3
|
+
import textStyleSettingRouter from "./components/textStyleSetting/textStyleSettingRouter.js";
|
4
4
|
import WidgetBox from "./WidgetBox";
|
5
5
|
|
6
6
|
function FontFamilySelect(props) {
|
@@ -8,7 +8,14 @@ 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: value || '',
|
12
|
+
valueRender: function valueRender(val) {
|
13
|
+
return /*#__PURE__*/React.createElement("div", {
|
14
|
+
style: {
|
15
|
+
width: 48
|
16
|
+
}
|
17
|
+
}, val || '微软雅黑');
|
18
|
+
},
|
12
19
|
onChange: onChange
|
13
20
|
}, items.map(function (item) {
|
14
21
|
return /*#__PURE__*/React.createElement(DropdownMenu.Item, {
|
@@ -23,28 +30,21 @@ function FontFamilySelect(props) {
|
|
23
30
|
|
24
31
|
function FontFamilyWidget(props) {
|
25
32
|
var topo = props.topo,
|
26
|
-
showLabel = props.showLabel
|
27
|
-
|
28
|
-
|
29
|
-
value = _useState[0],
|
30
|
-
setValue = _useState[1];
|
31
|
-
|
32
|
-
var fontStyleSetting = useFontStyleSetting({
|
33
|
-
topo: topo
|
34
|
-
});
|
33
|
+
showLabel = props.showLabel,
|
34
|
+
style = props.style,
|
35
|
+
setStyle = props.setStyle;
|
35
36
|
return /*#__PURE__*/React.createElement(WidgetBox, {
|
36
37
|
label: "\u5B57\u4F53",
|
37
38
|
tooltip: "\u5B57\u4F53",
|
38
39
|
showLabel: showLabel
|
39
40
|
}, /*#__PURE__*/React.createElement(FontFamilySelect, {
|
40
|
-
value:
|
41
|
+
value: style.fontFamily,
|
41
42
|
onChange: function onChange(val) {
|
42
|
-
|
43
|
-
fontStyleSetting.setStyle({
|
43
|
+
setStyle({
|
44
44
|
fontFamily: val
|
45
45
|
});
|
46
46
|
}
|
47
47
|
}));
|
48
48
|
}
|
49
49
|
|
50
|
-
export default FontFamilyWidget;
|
50
|
+
export default textStyleSettingRouter(FontFamilyWidget);
|
@@ -1,15 +1,24 @@
|
|
1
|
-
import React, { useState } from 'react';
|
2
|
-
import useFontStyleSetting from "../hooks/useFontStyleSetting";
|
1
|
+
import React, { useEffect, useState } from 'react';
|
3
2
|
import DropdownMenu from "./components/DropdownMenu";
|
3
|
+
import textStyleSettingRouter from "./components/textStyleSetting/textStyleSettingRouter.js";
|
4
4
|
import WidgetBox from "./WidgetBox";
|
5
5
|
|
6
6
|
function FontSizeSelect(props) {
|
7
7
|
var value = props.value,
|
8
|
-
|
8
|
+
_onChange = props.onChange;
|
9
9
|
var items = [9, 10, 11, 12, 14, 16, 18, 20, 24, 30, 36];
|
10
10
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
11
|
-
value: value,
|
12
|
-
|
11
|
+
value: "" + (value || ''),
|
12
|
+
valueRender: function valueRender(val) {
|
13
|
+
return /*#__PURE__*/React.createElement("div", {
|
14
|
+
style: {
|
15
|
+
width: 18
|
16
|
+
}
|
17
|
+
}, val || 12);
|
18
|
+
},
|
19
|
+
onChange: function onChange(val) {
|
20
|
+
return _onChange(parseInt(val, 10));
|
21
|
+
}
|
13
22
|
}, items.map(function (item) {
|
14
23
|
return /*#__PURE__*/React.createElement(DropdownMenu.Item, {
|
15
24
|
key: item
|
@@ -19,27 +28,20 @@ function FontSizeSelect(props) {
|
|
19
28
|
|
20
29
|
function FontSizeWidget(props) {
|
21
30
|
var topo = props.topo,
|
22
|
-
showLabel = props.showLabel
|
23
|
-
|
24
|
-
|
25
|
-
});
|
26
|
-
|
27
|
-
var _useState = useState(12),
|
28
|
-
fontSize = _useState[0],
|
29
|
-
setFontSize = _useState[1];
|
30
|
-
|
31
|
+
showLabel = props.showLabel,
|
32
|
+
style = props.style,
|
33
|
+
setStyle = props.setStyle;
|
31
34
|
return /*#__PURE__*/React.createElement(WidgetBox, {
|
32
35
|
label: "\u5B57\u53F7",
|
33
36
|
showLabel: showLabel
|
34
37
|
}, /*#__PURE__*/React.createElement(FontSizeSelect, {
|
35
|
-
value: fontSize,
|
38
|
+
value: style.fontSize,
|
36
39
|
onChange: function onChange(val) {
|
37
|
-
|
38
|
-
fontStyleSetting.setStyle({
|
40
|
+
setStyle({
|
39
41
|
fontSize: val
|
40
42
|
});
|
41
43
|
}
|
42
44
|
}));
|
43
45
|
}
|
44
46
|
|
45
|
-
export default FontSizeWidget;
|
47
|
+
export default textStyleSettingRouter(FontSizeWidget);
|
@@ -1,8 +1,7 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
1
2
|
import React, { useState, useEffect } from 'react';
|
2
|
-
import { isText } from "../../../../../utils/htElementUtils";
|
3
|
-
import fontStyleUtil from "../../settings/common/text/fontStyleUtil";
|
4
|
-
import useFontStyleSetting from "../hooks/useFontStyleSetting";
|
5
3
|
import DropdownMenu from "./components/DropdownMenu";
|
4
|
+
import textStyleSettingRouter from "./components/textStyleSetting/textStyleSettingRouter.js";
|
6
5
|
import WidgetBox from "./WidgetBox";
|
7
6
|
var items = [{
|
8
7
|
key: 'bold',
|
@@ -18,65 +17,63 @@ var items = [{
|
|
18
17
|
icon: 'Underline'
|
19
18
|
}];
|
20
19
|
|
21
|
-
function
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
function buildValue(obj) {
|
21
|
+
return Object.keys(obj).filter(function (key) {
|
22
|
+
return !!obj[key];
|
23
|
+
});
|
24
|
+
}
|
25
|
+
|
26
|
+
function formatStyle(arr) {
|
27
|
+
return items.map(function (item) {
|
28
|
+
return item.key;
|
29
|
+
}).reduce(function (map, name) {
|
30
|
+
var _extends2;
|
31
|
+
|
32
|
+
return _extends({}, map, (_extends2 = {}, _extends2[name] = arr.includes(name), _extends2));
|
33
|
+
}, {});
|
29
34
|
}
|
30
35
|
|
31
36
|
function FontStyleButton(props) {
|
32
37
|
var topo = props.topo,
|
33
|
-
showLabel = props.showLabel
|
38
|
+
showLabel = props.showLabel,
|
39
|
+
style = props.style,
|
40
|
+
setStyle = props.setStyle;
|
41
|
+
|
42
|
+
var _useState = useState(false),
|
43
|
+
disabled = _useState[0],
|
44
|
+
setDisabled = _useState[1];
|
34
45
|
|
35
|
-
var
|
36
|
-
|
37
|
-
|
46
|
+
var bold = style.bold,
|
47
|
+
italic = style.italic,
|
48
|
+
underline = style.underline;
|
38
49
|
|
39
|
-
var _useState2 = useState(
|
40
|
-
|
41
|
-
|
50
|
+
var _useState2 = useState(buildValue({
|
51
|
+
bold: bold,
|
52
|
+
italic: italic,
|
53
|
+
underline: underline
|
54
|
+
})),
|
55
|
+
value = _useState2[0],
|
56
|
+
setValue = _useState2[1]; // 选中的元素
|
42
57
|
|
43
58
|
|
44
59
|
var selection = topo.selectionManager.useHtSelection();
|
45
|
-
var fontStyleSetting = useFontStyleSetting({
|
46
|
-
topo: topo
|
47
|
-
});
|
48
60
|
useEffect(function () {
|
49
61
|
setDisabled(false);
|
50
|
-
var fontObj = {};
|
51
|
-
|
52
|
-
if (selection.length === 1) {
|
53
|
-
var element = selection[0];
|
54
|
-
|
55
|
-
if (isText(element)) {
|
56
|
-
fontObj = getTextFontStyle(element);
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
var newValue = Object.keys(fontObj).reduce(function (result, key) {
|
61
|
-
if (fontObj[key]) {
|
62
|
-
return [].concat(result, [key]);
|
63
|
-
}
|
64
|
-
|
65
|
-
return result;
|
66
|
-
}, []);
|
67
|
-
setValue(newValue);
|
68
62
|
}, [selection]);
|
63
|
+
useEffect(function () {
|
64
|
+
setValue(buildValue({
|
65
|
+
bold: bold,
|
66
|
+
italic: italic,
|
67
|
+
underline: underline
|
68
|
+
}));
|
69
|
+
}, [bold, italic, underline]);
|
69
70
|
/**
|
70
71
|
*
|
71
72
|
* @param {Array} selectedKeys
|
72
73
|
*/
|
73
74
|
|
74
75
|
var handleChange = function handleChange(selectedKeys) {
|
75
|
-
|
76
|
-
var style = {
|
77
|
-
fontBold: selectedKeys.includes('bold')
|
78
|
-
};
|
79
|
-
fontStyleSetting.setStyle(style);
|
76
|
+
setStyle(formatStyle(selectedKeys));
|
80
77
|
};
|
81
78
|
|
82
79
|
return /*#__PURE__*/React.createElement(WidgetBox, {
|
@@ -108,4 +105,4 @@ function FontStyleButton(props) {
|
|
108
105
|
})));
|
109
106
|
}
|
110
107
|
|
111
|
-
export default FontStyleButton;
|
108
|
+
export default textStyleSettingRouter(FontStyleButton);
|
@@ -44,9 +44,10 @@ function NodeSizeButton(props) {
|
|
44
44
|
setDisabled(false);
|
45
45
|
|
46
46
|
if (selection.length === 1) {
|
47
|
+
var element = nodes[0];
|
47
48
|
setSize({
|
48
|
-
width:
|
49
|
-
height:
|
49
|
+
width: element.getWidth(),
|
50
|
+
height: element.getHeight()
|
50
51
|
});
|
51
52
|
}
|
52
53
|
} else {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import _Dropdown from "@alifd/next/es/dropdown";
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
3
|
import React, { useState } from 'react';
|
3
4
|
import PropTypes from 'prop-types';
|
4
5
|
import ButtonBox from "./ButtonBox";
|
@@ -11,17 +12,18 @@ function DropdownButton(props) {
|
|
11
12
|
showArrow = _props$showArrow === void 0 ? true : _props$showArrow,
|
12
13
|
_props$showContainer = props.showContainer,
|
13
14
|
showContainer = _props$showContainer === void 0 ? true : _props$showContainer,
|
15
|
+
buttonBoxProps = props.buttonBoxProps,
|
14
16
|
children = props.children;
|
15
17
|
|
16
18
|
var _useState = useState(false),
|
17
19
|
visible = _useState[0],
|
18
20
|
setVisible = _useState[1];
|
19
21
|
|
20
|
-
var button = /*#__PURE__*/React.createElement(ButtonBox, {
|
22
|
+
var button = /*#__PURE__*/React.createElement(ButtonBox, _extends({
|
21
23
|
active: visible,
|
22
24
|
disabled: disabled,
|
23
25
|
showArrow: showArrow
|
24
|
-
}, trigger);
|
26
|
+
}, buttonBoxProps), trigger);
|
25
27
|
|
26
28
|
var renderContent = function renderContent() {
|
27
29
|
if (!visible) {
|
@@ -12,10 +12,15 @@ function DropdownMenu(props) {
|
|
12
12
|
var selectedKeys = Array.isArray(value) ? value : [value];
|
13
13
|
var valueDisplay = valueRender ? valueRender(value) : value;
|
14
14
|
var selectMode = multiple ? 'multiple' : 'single';
|
15
|
+
|
16
|
+
var handleChange = function handleChange(keys) {
|
17
|
+
onChange(multiple ? keys : keys[0]);
|
18
|
+
};
|
19
|
+
|
15
20
|
var menu = /*#__PURE__*/React.createElement(_Menu, {
|
16
21
|
selectMode: selectMode,
|
17
22
|
selectedKeys: selectedKeys,
|
18
|
-
onSelect:
|
23
|
+
onSelect: handleChange
|
19
24
|
}, children);
|
20
25
|
return /*#__PURE__*/React.createElement(DropdownButton, {
|
21
26
|
trigger: valueDisplay,
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
3
|
+
var _excluded = ["Component"];
|
4
|
+
import React, { useMemo, useState } from 'react';
|
5
|
+
import { getTextStyle, setTextStyle } from "./textStyleUtil";
|
6
|
+
|
7
|
+
function ElementTextStyleSetting(props) {
|
8
|
+
var topo = props.topo;
|
9
|
+
|
10
|
+
var Component = props.Component,
|
11
|
+
widgetProps = _objectWithoutPropertiesLoose(props, _excluded); // 选中的元素
|
12
|
+
|
13
|
+
|
14
|
+
var selection = topo.selectionManager.useSelection();
|
15
|
+
var htSelection = useMemo(function () {
|
16
|
+
if (!selection.length) {
|
17
|
+
return [];
|
18
|
+
}
|
19
|
+
|
20
|
+
return topo.getHtTopo().getGraphView().getSelectionModel().getSelection().toArray();
|
21
|
+
}, [selection, topo]);
|
22
|
+
var value = useMemo(function () {
|
23
|
+
return getTextStyle(htSelection) || {};
|
24
|
+
}, [htSelection, topo]);
|
25
|
+
var setStyle = useMemo(function () {
|
26
|
+
return function (style) {
|
27
|
+
htSelection.forEach(function (element) {
|
28
|
+
setTextStyle(element, style);
|
29
|
+
});
|
30
|
+
};
|
31
|
+
}, [htSelection]);
|
32
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
33
|
+
disabled: false,
|
34
|
+
htSelection: htSelection,
|
35
|
+
style: value,
|
36
|
+
setStyle: setStyle
|
37
|
+
}, widgetProps));
|
38
|
+
}
|
39
|
+
|
40
|
+
export default ElementTextStyleSetting;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export function getTextStyle(element) {
|
2
|
+
return {
|
3
|
+
color: null,
|
4
|
+
fontFamily: null,
|
5
|
+
fontSize: null,
|
6
|
+
fontStyle: []
|
7
|
+
};
|
8
|
+
}
|
9
|
+
export function setTextStyle(element, style) {}
|
10
|
+
export default {
|
11
|
+
getTextStyle: getTextStyle,
|
12
|
+
setTextStyle: setTextStyle
|
13
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export function getTextStyle(element) {
|
2
|
+
return {
|
3
|
+
color: null,
|
4
|
+
fontFamily: null,
|
5
|
+
fontSize: null,
|
6
|
+
fontStyle: []
|
7
|
+
};
|
8
|
+
}
|
9
|
+
export function setTextStyle(element, style) {}
|
10
|
+
export default {
|
11
|
+
getTextStyle: getTextStyle,
|
12
|
+
setTextStyle: setTextStyle
|
13
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import text from "./text";
|
2
|
+
import nodeTag from "./nodeTag";
|
3
|
+
import edgeTag from "./edgeTag";
|
4
|
+
import groupTitle from "./groupTitle";
|
5
|
+
import layerTitle from "./layerTitle";
|
6
|
+
export default {
|
7
|
+
nodeTag: nodeTag,
|
8
|
+
edgeTag: edgeTag,
|
9
|
+
text: text,
|
10
|
+
groupTitle: groupTitle,
|
11
|
+
layerTitle: layerTitle
|
12
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export function getTextStyle(element) {
|
2
|
+
return {
|
3
|
+
color: null,
|
4
|
+
fontFamily: null,
|
5
|
+
fontSize: null,
|
6
|
+
fontStyle: []
|
7
|
+
};
|
8
|
+
}
|
9
|
+
export function setTextStyle(element, style) {}
|
10
|
+
export default {
|
11
|
+
getTextStyle: getTextStyle,
|
12
|
+
setTextStyle: setTextStyle
|
13
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export function getTextStyle(element) {
|
2
|
+
return {
|
3
|
+
color: null,
|
4
|
+
fontFamily: null,
|
5
|
+
fontSize: null,
|
6
|
+
fontStyle: []
|
7
|
+
};
|
8
|
+
}
|
9
|
+
export function setTextStyle(element, style) {}
|
10
|
+
export default {
|
11
|
+
getTextStyle: getTextStyle,
|
12
|
+
setTextStyle: setTextStyle
|
13
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import fontStyleUtil from "../../../../../../settings/common/text/fontStyleUtil";
|
3
|
+
export function getTextStyle(element) {
|
4
|
+
var underline = element.s('text.decoration') === 'underline';
|
5
|
+
return _extends({
|
6
|
+
color: null,
|
7
|
+
underline: underline
|
8
|
+
}, fontStyleUtil.toMap(element.s('text.font')));
|
9
|
+
}
|
10
|
+
export function setTextStyle(element, style) {
|
11
|
+
var underline = style.underline;
|
12
|
+
|
13
|
+
if ('underline' in style) {
|
14
|
+
element.s('text.decoration', underline ? 'underline' : null);
|
15
|
+
}
|
16
|
+
|
17
|
+
var fontStyle = _extends({}, getTextStyle(element), style);
|
18
|
+
|
19
|
+
var fontStr = fontStyleUtil.build(fontStyle);
|
20
|
+
element.s('text.font', fontStr);
|
21
|
+
}
|
22
|
+
export default {
|
23
|
+
getTextStyle: getTextStyle,
|
24
|
+
setTextStyle: setTextStyle
|
25
|
+
};
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { isGroup, isLayer, isNode, isText, isEdge } from "../../../../../../../../utils/htElementUtils";
|
2
|
+
import typeMap from "./elements";
|
3
|
+
|
4
|
+
function getElementType(element) {
|
5
|
+
if (isText(element)) {
|
6
|
+
return 'text';
|
7
|
+
} else if (isGroup(element)) {
|
8
|
+
return 'groupTitle';
|
9
|
+
} else if (isNode(element)) {
|
10
|
+
return 'nodeTag';
|
11
|
+
} else if (isEdge(element)) {
|
12
|
+
return 'edgeTag';
|
13
|
+
} else if (isLayer(element)) {
|
14
|
+
return 'layerTitle';
|
15
|
+
}
|
16
|
+
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
|
20
|
+
export function getElementTextStyle(element) {
|
21
|
+
var type = getElementType(element);
|
22
|
+
var handler = typeMap[type];
|
23
|
+
|
24
|
+
if (handler) {
|
25
|
+
return handler.getTextStyle(element);
|
26
|
+
}
|
27
|
+
|
28
|
+
return null;
|
29
|
+
}
|
30
|
+
export function getTextStyle(htSelection) {
|
31
|
+
if (htSelection.length === 1) {
|
32
|
+
var element = htSelection[0];
|
33
|
+
return getElementTextStyle(element);
|
34
|
+
} // 多选时值相同返回?
|
35
|
+
|
36
|
+
|
37
|
+
return null;
|
38
|
+
}
|
39
|
+
export function setTextStyle(element, style) {
|
40
|
+
var type = getElementType(element);
|
41
|
+
var handler = typeMap[type];
|
42
|
+
|
43
|
+
if (handler) {
|
44
|
+
handler.setTextStyle(element, style);
|
45
|
+
}
|
46
|
+
}
|