@riil-frontend/component-topology 6.0.0-alpha.31 → 6.0.0-alpha.33
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 +5 -5
- package/es/core/editor/components/Toolbar/widgets/FontColorButton.js +0 -4
- package/es/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +20 -16
- package/es/core/editor/components/Toolbar/widgets/FontSizeWidget.js +24 -18
- package/es/core/editor/components/Toolbar/widgets/FontStyleButton.js +46 -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 +41 -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 +69 -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 +20 -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/widgets/FontColorButton.js +0 -5
- package/lib/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +21 -16
- package/lib/core/editor/components/Toolbar/widgets/FontSizeWidget.js +25 -18
- package/lib/core/editor/components/Toolbar/widgets/FontStyleButton.js +47 -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 +55 -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 +81 -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 +31 -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
- package/es/core/editor/components/Toolbar/hooks/useFontStyleSetting.js +0 -52
- package/lib/core/editor/components/Toolbar/hooks/useFontStyleSetting.js +0 -64
@@ -5,7 +5,6 @@ import WidgetBox from "./WidgetBox";
|
|
5
5
|
import ColorPanel from "../../../../../components/ColorPanel";
|
6
6
|
import FontColorRange from "../../../../../components/ColorPanel/components/FontColorRange";
|
7
7
|
import styles from "./FontColorButton.module.scss";
|
8
|
-
import useFontStyleSetting from "../hooks/useFontStyleSetting";
|
9
8
|
|
10
9
|
function FontFamilySelect(props) {
|
11
10
|
var value = props.value,
|
@@ -16,9 +15,6 @@ function FontFamilySelect(props) {
|
|
16
15
|
disabled = _useState[0],
|
17
16
|
setDisabled = _useState[1];
|
18
17
|
|
19
|
-
var fontStyleSetting = useFontStyleSetting({
|
20
|
-
topo: topo
|
21
|
-
});
|
22
18
|
console.log(topo, 'topo这里需要处理颜色改变的事情');
|
23
19
|
|
24
20
|
var backOpacityChange = function backOpacityChange(value) {
|
@@ -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,25 @@ 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
|
-
|
43
|
+
topo.historyManager.beginTransaction();
|
44
|
+
setStyle({
|
44
45
|
fontFamily: val
|
45
46
|
});
|
47
|
+
topo.historyManager.endTransaction();
|
46
48
|
}
|
47
49
|
}));
|
48
50
|
}
|
49
51
|
|
50
|
-
export default FontFamilyWidget
|
52
|
+
export default textStyleSettingRouter(FontFamilyWidget, {
|
53
|
+
names: ['fontFamily']
|
54
|
+
});
|
@@ -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,24 @@ 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
|
-
|
40
|
+
topo.historyManager.beginTransaction();
|
41
|
+
setStyle({
|
39
42
|
fontSize: val
|
40
43
|
});
|
44
|
+
topo.historyManager.endTransaction();
|
41
45
|
}
|
42
46
|
}));
|
43
47
|
}
|
44
48
|
|
45
|
-
export default FontSizeWidget
|
49
|
+
export default textStyleSettingRouter(FontSizeWidget, {
|
50
|
+
names: ['fontSize']
|
51
|
+
});
|
@@ -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,65 @@ 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
|
-
|
77
|
-
|
78
|
-
};
|
79
|
-
fontStyleSetting.setStyle(style);
|
76
|
+
topo.historyManager.beginTransaction();
|
77
|
+
setStyle(formatStyle(selectedKeys));
|
78
|
+
topo.historyManager.endTransaction();
|
80
79
|
};
|
81
80
|
|
82
81
|
return /*#__PURE__*/React.createElement(WidgetBox, {
|
@@ -108,4 +107,6 @@ function FontStyleButton(props) {
|
|
108
107
|
})));
|
109
108
|
}
|
110
109
|
|
111
|
-
export default FontStyleButton
|
110
|
+
export default textStyleSettingRouter(FontStyleButton, {
|
111
|
+
names: ['bold', 'italic', 'underline']
|
112
|
+
});
|
@@ -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,41 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
3
|
+
var _excluded = ["Component", "styleNames"];
|
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
|
+
styleNames = props.styleNames,
|
12
|
+
widgetProps = _objectWithoutPropertiesLoose(props, _excluded); // 选中的元素
|
13
|
+
|
14
|
+
|
15
|
+
var selection = topo.selectionManager.useSelection();
|
16
|
+
var htSelection = useMemo(function () {
|
17
|
+
if (!selection.length) {
|
18
|
+
return [];
|
19
|
+
}
|
20
|
+
|
21
|
+
return topo.getHtTopo().getGraphView().getSelectionModel().getSelection().toArray();
|
22
|
+
}, [selection, topo]);
|
23
|
+
var value = useMemo(function () {
|
24
|
+
return getTextStyle(htSelection, styleNames) || {};
|
25
|
+
}, [htSelection, topo]);
|
26
|
+
var setStyle = useMemo(function () {
|
27
|
+
return function (style) {
|
28
|
+
htSelection.forEach(function (element) {
|
29
|
+
setTextStyle(element, style);
|
30
|
+
});
|
31
|
+
};
|
32
|
+
}, [htSelection]);
|
33
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
34
|
+
disabled: false,
|
35
|
+
htSelection: htSelection,
|
36
|
+
style: value,
|
37
|
+
setStyle: setStyle
|
38
|
+
}, widgetProps));
|
39
|
+
}
|
40
|
+
|
41
|
+
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,69 @@
|
|
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, styleNames) {
|
31
|
+
if (htSelection.length === 1) {
|
32
|
+
var element = htSelection[0];
|
33
|
+
return getElementTextStyle(element);
|
34
|
+
} else if (htSelection.length) {
|
35
|
+
// 多选时值相同返回?
|
36
|
+
var values = htSelection.map(function (element) {
|
37
|
+
return getElementTextStyle(element);
|
38
|
+
}).filter(function (item) {
|
39
|
+
return !!item;
|
40
|
+
});
|
41
|
+
|
42
|
+
if (!values.length) {
|
43
|
+
return null;
|
44
|
+
}
|
45
|
+
|
46
|
+
var value = {};
|
47
|
+
styleNames.forEach(function (styleName) {
|
48
|
+
var val = values[0][styleName];
|
49
|
+
var different = values.filter(function (obj) {
|
50
|
+
return obj[styleName] !== val;
|
51
|
+
});
|
52
|
+
|
53
|
+
if (!different.length) {
|
54
|
+
value[styleName] = val;
|
55
|
+
}
|
56
|
+
});
|
57
|
+
return Object.keys(value).length ? value : null;
|
58
|
+
}
|
59
|
+
|
60
|
+
return null;
|
61
|
+
}
|
62
|
+
export function setTextStyle(element, style) {
|
63
|
+
var type = getElementType(element);
|
64
|
+
var handler = typeMap[type];
|
65
|
+
|
66
|
+
if (handler) {
|
67
|
+
handler.setTextStyle(element, style);
|
68
|
+
}
|
69
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
3
|
+
var _excluded = ["Component"];
|
4
|
+
import React, { useMemo } from 'react';
|
5
|
+
import { setGlobalTagStyle, useValues } from "./globalTag";
|
6
|
+
|
7
|
+
function GlobalTagStyleSetting(props) {
|
8
|
+
var topo = props.topo;
|
9
|
+
|
10
|
+
var Component = props.Component,
|
11
|
+
widgetProps = _objectWithoutPropertiesLoose(props, _excluded);
|
12
|
+
|
13
|
+
var values = useValues(topo);
|
14
|
+
var setStyle = useMemo(function () {
|
15
|
+
return function (style) {
|
16
|
+
return setGlobalTagStyle(topo, style);
|
17
|
+
};
|
18
|
+
}, []);
|
19
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
20
|
+
style: values,
|
21
|
+
setStyle: setStyle
|
22
|
+
}, widgetProps));
|
23
|
+
}
|
24
|
+
|
25
|
+
export default GlobalTagStyleSetting;
|
@@ -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() {}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import React from 'react';
|
3
|
+
import ElementTextStyleSetting from "./ElementTextStyleSetting/ElementTextStyleSetting";
|
4
|
+
import GlobalTagStyleSetting from "./GlobalTagStyleSetting/GlobalTagStyleSetting";
|
5
|
+
|
6
|
+
function textStyleSettingRouter(Component, options) {
|
7
|
+
var names = (options === null || options === void 0 ? void 0 : options.names) || [];
|
8
|
+
return function TextStyleSettingButton(props) {
|
9
|
+
var topo = props.topo;
|
10
|
+
var selection = topo.selectionManager.useHtSelection();
|
11
|
+
var Widget = !selection.length ? GlobalTagStyleSetting : ElementTextStyleSetting;
|
12
|
+
return /*#__PURE__*/React.createElement(Widget, _extends({
|
13
|
+
Component: Component
|
14
|
+
}, props, {
|
15
|
+
styleNames: names
|
16
|
+
}));
|
17
|
+
};
|
18
|
+
}
|
19
|
+
|
20
|
+
export default textStyleSettingRouter;
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import React from 'react';
|
2
1
|
import classNames from 'classnames';
|
3
|
-
import
|
4
|
-
import OpenPropertyPanelListener from "./OpenPropertyPanelListener";
|
2
|
+
import React from 'react';
|
5
3
|
import CloseablePanel from "./CloseablePanel";
|
4
|
+
import OpenPropertyPanelListener from "./OpenPropertyPanelListener";
|
5
|
+
import Settings from "./Settings";
|
6
6
|
import styles from "./Settings.module.scss";
|
7
7
|
export default function PropertyView(props) {
|
8
8
|
var _classNames;
|
@@ -28,6 +28,10 @@ export default function PropertyView(props) {
|
|
28
28
|
}
|
29
29
|
|
30
30
|
var renderContent = function renderContent() {
|
31
|
+
if (!propertyPanelVisible) {
|
32
|
+
return null;
|
33
|
+
}
|
34
|
+
|
31
35
|
return /*#__PURE__*/React.createElement(OpenPropertyPanelListener, {
|
32
36
|
topo: topo
|
33
37
|
}, /*#__PURE__*/React.createElement(Settings, {
|
@@ -48,5 +52,7 @@ export default function PropertyView(props) {
|
|
48
52
|
propertyPanelVisible: false
|
49
53
|
});
|
50
54
|
}
|
51
|
-
},
|
55
|
+
}, /*#__PURE__*/React.createElement(OpenPropertyPanelListener, {
|
56
|
+
topo: topo
|
57
|
+
}, renderContent())));
|
52
58
|
}
|