@logicflow/core 2.2.0-alpha.1 → 2.2.0-alpha.3
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/.turbo/turbo-build$colon$dev.log +2 -57
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +12 -0
- package/dist/index.css +3 -2
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/LogicFlow.d.ts +9 -0
- package/es/constant/index.d.ts +1 -1
- package/es/constant/index.js +1 -1
- package/es/constant/theme.d.ts +136 -0
- package/es/constant/theme.js +680 -0
- package/es/index.css +3 -2
- package/es/model/GraphModel.d.ts +9 -2
- package/es/model/GraphModel.js +17 -6
- package/es/model/TransformModel.js +9 -9
- package/es/model/edge/BaseEdgeModel.js +7 -2
- package/es/model/edge/PolylineEdgeModel.d.ts +6 -0
- package/es/model/edge/PolylineEdgeModel.js +23 -1
- package/es/model/node/BaseNodeModel.d.ts +12 -1
- package/es/model/node/BaseNodeModel.js +6 -1
- package/es/model/node/HtmlNodeModel.d.ts +12 -0
- package/es/model/node/HtmlNodeModel.js +19 -0
- package/es/model/node/PolygonNodeModel.js +3 -3
- package/es/options.d.ts +1 -1
- package/es/style/index.css +3 -2
- package/es/style/index.less +3 -2
- package/es/style/raw.d.ts +1 -1
- package/es/style/raw.js +1 -1
- package/es/tool/MultipleSelectTool.js +6 -5
- package/es/util/edge.d.ts +1 -1
- package/es/util/edge.js +2 -2
- package/es/util/geometry.d.ts +8 -0
- package/es/util/geometry.js +79 -0
- package/es/util/theme.d.ts +2 -65
- package/es/util/theme.js +4 -281
- package/es/view/Control.d.ts +5 -0
- package/es/view/Control.js +44 -57
- package/es/view/edge/PolylineEdge.js +13 -2
- package/es/view/node/BaseNode.d.ts +1 -0
- package/es/view/node/BaseNode.js +14 -10
- package/es/view/node/HtmlNode.js +2 -4
- package/es/view/overlay/Grid.d.ts +12 -1
- package/es/view/overlay/Grid.js +85 -23
- package/es/view/overlay/OutlineOverlay.d.ts +1 -0
- package/es/view/overlay/OutlineOverlay.js +17 -16
- package/es/view/overlay/gridConfig.d.ts +46 -0
- package/es/view/overlay/gridConfig.js +99 -0
- package/es/view/shape/Polygon.d.ts +0 -7
- package/es/view/shape/Polygon.js +12 -43
- package/lib/LogicFlow.d.ts +9 -0
- package/lib/constant/index.d.ts +1 -1
- package/lib/constant/index.js +16 -2
- package/lib/constant/theme.d.ts +136 -0
- package/lib/constant/theme.js +683 -0
- package/lib/index.css +3 -2
- package/lib/model/GraphModel.d.ts +9 -2
- package/lib/model/GraphModel.js +18 -7
- package/lib/model/TransformModel.js +9 -9
- package/lib/model/edge/BaseEdgeModel.js +7 -2
- package/lib/model/edge/PolylineEdgeModel.d.ts +6 -0
- package/lib/model/edge/PolylineEdgeModel.js +23 -1
- package/lib/model/node/BaseNodeModel.d.ts +12 -1
- package/lib/model/node/BaseNodeModel.js +6 -1
- package/lib/model/node/HtmlNodeModel.d.ts +12 -0
- package/lib/model/node/HtmlNodeModel.js +19 -0
- package/lib/model/node/PolygonNodeModel.js +3 -3
- package/lib/options.d.ts +1 -1
- package/lib/style/index.css +3 -2
- package/lib/style/index.less +3 -2
- package/lib/style/raw.d.ts +1 -1
- package/lib/style/raw.js +1 -1
- package/lib/tool/MultipleSelectTool.js +6 -5
- package/lib/util/edge.d.ts +1 -1
- package/lib/util/edge.js +2 -2
- package/lib/util/geometry.d.ts +8 -0
- package/lib/util/geometry.js +81 -1
- package/lib/util/theme.d.ts +2 -65
- package/lib/util/theme.js +15 -292
- package/lib/view/Control.d.ts +5 -0
- package/lib/view/Control.js +44 -57
- package/lib/view/edge/PolylineEdge.js +13 -2
- package/lib/view/node/BaseNode.d.ts +1 -0
- package/lib/view/node/BaseNode.js +14 -10
- package/lib/view/node/HtmlNode.js +1 -3
- package/lib/view/overlay/Grid.d.ts +12 -1
- package/lib/view/overlay/Grid.js +83 -21
- package/lib/view/overlay/OutlineOverlay.d.ts +1 -0
- package/lib/view/overlay/OutlineOverlay.js +17 -16
- package/lib/view/overlay/gridConfig.d.ts +46 -0
- package/lib/view/overlay/gridConfig.js +104 -0
- package/lib/view/shape/Polygon.d.ts +0 -7
- package/lib/view/shape/Polygon.js +13 -45
- package/package.json +1 -1
- package/src/LogicFlow.tsx +10 -0
- package/src/constant/index.ts +2 -2
- package/src/constant/theme.ts +708 -0
- package/src/model/GraphModel.ts +19 -7
- package/src/model/TransformModel.ts +9 -9
- package/src/model/edge/BaseEdgeModel.ts +10 -2
- package/src/model/edge/PolylineEdgeModel.ts +26 -1
- package/src/model/node/BaseNodeModel.ts +9 -1
- package/src/model/node/HtmlNodeModel.ts +14 -0
- package/src/model/node/PolygonNodeModel.ts +2 -0
- package/src/options.ts +1 -1
- package/src/style/index.less +3 -2
- package/src/style/raw.ts +3 -2
- package/src/tool/MultipleSelectTool.tsx +6 -5
- package/src/util/edge.ts +2 -1
- package/src/util/geometry.ts +99 -0
- package/src/util/theme.ts +12 -303
- package/src/view/Control.tsx +61 -63
- package/src/view/edge/PolylineEdge.tsx +14 -2
- package/src/view/node/BaseNode.tsx +8 -3
- package/src/view/node/HtmlNode.tsx +27 -10
- package/src/view/overlay/Grid.tsx +187 -30
- package/src/view/overlay/OutlineOverlay.tsx +35 -47
- package/src/view/overlay/gridConfig.ts +103 -0
- package/src/view/shape/Polygon.tsx +12 -49
- package/stats.html +1 -1
|
@@ -17,7 +17,8 @@ export declare class GraphModel {
|
|
|
17
17
|
width: number;
|
|
18
18
|
height: number;
|
|
19
19
|
theme: LogicFlow.Theme;
|
|
20
|
-
|
|
20
|
+
themeMode: LogicFlow.ThemeMode | string;
|
|
21
|
+
customStyles: LogicFlow.Theme;
|
|
21
22
|
grid: Grid.GridOptions;
|
|
22
23
|
readonly eventCenter: EventEmitter;
|
|
23
24
|
readonly modelMap: Map<string, LogicFlow.GraphElementCtor>;
|
|
@@ -404,7 +405,7 @@ export declare class GraphModel {
|
|
|
404
405
|
* 设置主题
|
|
405
406
|
* todo docs link
|
|
406
407
|
*/
|
|
407
|
-
setTheme(style: Partial<LogicFlow.Theme>, themeMode?:
|
|
408
|
+
setTheme(style: Partial<LogicFlow.Theme>, themeMode?: LogicFlow.ThemeMode | string): void;
|
|
408
409
|
/**
|
|
409
410
|
* 设置主题
|
|
410
411
|
* todo docs link
|
|
@@ -419,6 +420,7 @@ export declare class GraphModel {
|
|
|
419
420
|
diamond: LogicFlow.CommonTheme;
|
|
420
421
|
ellipse: LogicFlow.CommonTheme;
|
|
421
422
|
polygon: LogicFlow.CommonTheme;
|
|
423
|
+
html: LogicFlow.CommonTheme;
|
|
422
424
|
line: LogicFlow.CommonTheme;
|
|
423
425
|
polyline: LogicFlow.CommonTheme;
|
|
424
426
|
bezier: LogicFlow.EdgeBezierTheme;
|
|
@@ -433,8 +435,13 @@ export declare class GraphModel {
|
|
|
433
435
|
rotateControl: LogicFlow.CommonTheme;
|
|
434
436
|
resizeControl: LogicFlow.CommonTheme;
|
|
435
437
|
resizeOutline: LogicFlow.CommonTheme;
|
|
438
|
+
multiSelect?: {
|
|
439
|
+
xPadding?: number | undefined;
|
|
440
|
+
yPadding?: number | undefined;
|
|
441
|
+
} | undefined;
|
|
436
442
|
edgeAdjust: LogicFlow.CommonTheme;
|
|
437
443
|
outline: LogicFlow.OutlineTheme;
|
|
444
|
+
edgeOutline: LogicFlow.OutlineTheme;
|
|
438
445
|
edgeAnimation: LogicFlow.EdgeAnimation;
|
|
439
446
|
};
|
|
440
447
|
/**
|
package/lib/model/GraphModel.js
CHANGED
|
@@ -69,6 +69,7 @@ var GraphModel = /** @class */ (function () {
|
|
|
69
69
|
function GraphModel(options) {
|
|
70
70
|
var _this = this;
|
|
71
71
|
var _a, _b;
|
|
72
|
+
this.themeMode = 'default';
|
|
72
73
|
// 维护所有节点和边类型对应的 model
|
|
73
74
|
this.modelMap = new Map();
|
|
74
75
|
// Remind:用于记录当前画布上所有节点和边的 model 的 Map
|
|
@@ -103,6 +104,9 @@ var GraphModel = /** @class */ (function () {
|
|
|
103
104
|
this.partial = false;
|
|
104
105
|
this.waitCleanEffects = [];
|
|
105
106
|
var container = options.container, partial = options.partial, _c = options.background, background = _c === void 0 ? {} : _c, grid = options.grid, idGenerator = options.idGenerator, edgeGenerator = options.edgeGenerator, animation = options.animation, customTrajectory = options.customTrajectory, customTargetAnchor = options.customTargetAnchor;
|
|
107
|
+
this.themeMode = options.themeMode || 'default';
|
|
108
|
+
var initialGrid = constant_1.gridModeMap[this.themeMode] || constant_1.gridModeMap['default'];
|
|
109
|
+
var initialBackground = constant_1.backgroundModeMap[this.themeMode] || constant_1.backgroundModeMap['default'];
|
|
106
110
|
this.rootEl = container;
|
|
107
111
|
this.partial = !!partial;
|
|
108
112
|
this.background = background;
|
|
@@ -111,11 +115,14 @@ var GraphModel = /** @class */ (function () {
|
|
|
111
115
|
// TODO:需要让用户设置成 0 吗?后面可以讨论一下
|
|
112
116
|
this.gridSize = grid.size || 1; // 默认 gridSize 设置为 1
|
|
113
117
|
}
|
|
114
|
-
this.customStyles = options.style || {};
|
|
115
|
-
this.grid = overlay_1.Grid.getGridOptions(grid !== null && grid !== void 0 ? grid : false);
|
|
118
|
+
this.customStyles = (options.style || {});
|
|
116
119
|
this.theme = (0, util_1.setupTheme)(options.style, options.themeMode);
|
|
120
|
+
this.grid = overlay_1.Grid.getGridOptions((0, lodash_es_1.assign)({}, initialGrid, grid));
|
|
117
121
|
this.theme.grid = (0, lodash_es_1.cloneDeep)(this.grid);
|
|
118
|
-
|
|
122
|
+
if (background) {
|
|
123
|
+
this.background = (0, lodash_es_1.cloneDeep)((0, lodash_es_1.assign)({}, initialBackground, background));
|
|
124
|
+
this.theme.background = (0, lodash_es_1.cloneDeep)((0, lodash_es_1.assign)({}, initialBackground, background));
|
|
125
|
+
}
|
|
119
126
|
this.edgeType = options.edgeType || 'polyline';
|
|
120
127
|
this.animation = (0, util_1.setupAnimation)(animation);
|
|
121
128
|
this.overlapMode = options.overlapMode || constant_1.OverlapMode.DEFAULT;
|
|
@@ -1338,11 +1345,12 @@ var GraphModel = /** @class */ (function () {
|
|
|
1338
1345
|
GraphModel.prototype.setTheme = function (style, themeMode) {
|
|
1339
1346
|
var _a;
|
|
1340
1347
|
if (themeMode) {
|
|
1348
|
+
this.themeMode = themeMode;
|
|
1341
1349
|
// 修改背景颜色
|
|
1342
|
-
|
|
1343
|
-
this.updateBackgroundOptions(__assign(__assign({}, (typeof this.background === 'object' ? this.background : {})),
|
|
1344
|
-
|
|
1345
|
-
this.updateGridOptions(overlay_1.Grid.getGridOptions(__assign(__assign({}, this.grid),
|
|
1350
|
+
constant_1.backgroundModeMap[themeMode] &&
|
|
1351
|
+
this.updateBackgroundOptions(__assign(__assign({}, (typeof this.background === 'object' ? this.background : {})), constant_1.backgroundModeMap[themeMode]));
|
|
1352
|
+
constant_1.gridModeMap[themeMode] &&
|
|
1353
|
+
this.updateGridOptions(overlay_1.Grid.getGridOptions(__assign(__assign({}, this.grid), constant_1.gridModeMap[themeMode])));
|
|
1346
1354
|
}
|
|
1347
1355
|
if (style.background) {
|
|
1348
1356
|
this.updateBackgroundOptions(style.background);
|
|
@@ -1535,6 +1543,9 @@ var GraphModel = /** @class */ (function () {
|
|
|
1535
1543
|
__decorate([
|
|
1536
1544
|
mobx_1.observable
|
|
1537
1545
|
], GraphModel.prototype, "theme", void 0);
|
|
1546
|
+
__decorate([
|
|
1547
|
+
mobx_1.observable
|
|
1548
|
+
], GraphModel.prototype, "themeMode", void 0);
|
|
1538
1549
|
__decorate([
|
|
1539
1550
|
mobx_1.observable
|
|
1540
1551
|
], GraphModel.prototype, "grid", void 0);
|
|
@@ -33,15 +33,15 @@ var translateLimitsMap = {
|
|
|
33
33
|
};
|
|
34
34
|
var TransformModel = /** @class */ (function () {
|
|
35
35
|
function TransformModel(eventCenter, options) {
|
|
36
|
-
this.MINI_SCALE_SIZE = 0.2;
|
|
37
|
-
this.MAX_SCALE_SIZE = 16;
|
|
38
|
-
this.SCALE_X = 1;
|
|
39
|
-
this.SKEW_Y = 0;
|
|
40
|
-
this.SKEW_X = 0;
|
|
41
|
-
this.SCALE_Y = 1;
|
|
42
|
-
this.TRANSLATE_X = 0;
|
|
43
|
-
this.TRANSLATE_Y = 0;
|
|
44
|
-
this.ZOOM_SIZE = 0.04;
|
|
36
|
+
this.MINI_SCALE_SIZE = 0.2; // 缩小的最小值
|
|
37
|
+
this.MAX_SCALE_SIZE = 16; // 放大的最大值
|
|
38
|
+
this.SCALE_X = 1; // x轴缩放比例
|
|
39
|
+
this.SKEW_Y = 0; // y轴倾斜角度
|
|
40
|
+
this.SKEW_X = 0; // x轴倾斜角度
|
|
41
|
+
this.SCALE_Y = 1; // y轴缩放比例
|
|
42
|
+
this.TRANSLATE_X = 0; // x轴平移距离
|
|
43
|
+
this.TRANSLATE_Y = 0; // y轴平移距离
|
|
44
|
+
this.ZOOM_SIZE = 0.04; // 缩放比例变化量
|
|
45
45
|
// 限制画布可移动区域
|
|
46
46
|
this.translateLimitMinX = -Infinity;
|
|
47
47
|
this.translateLimitMinY = -Infinity;
|
|
@@ -195,8 +195,13 @@ var BaseEdgeModel = /** @class */ (function () {
|
|
|
195
195
|
*/
|
|
196
196
|
BaseEdgeModel.prototype.getOutlineStyle = function () {
|
|
197
197
|
var graphModel = this.graphModel;
|
|
198
|
-
var
|
|
199
|
-
|
|
198
|
+
var edgeOutline = graphModel.theme.edgeOutline;
|
|
199
|
+
var attributes = __assign({}, edgeOutline);
|
|
200
|
+
if (this.isHovered) {
|
|
201
|
+
var hoverStyle = edgeOutline.hover || {};
|
|
202
|
+
attributes = __assign(__assign({}, attributes), hoverStyle);
|
|
203
|
+
}
|
|
204
|
+
return (0, lodash_es_1.cloneDeep)(attributes);
|
|
200
205
|
};
|
|
201
206
|
/**
|
|
202
207
|
* 重新自定义文本位置
|
|
@@ -12,6 +12,12 @@ export declare class PolylineEdgeModel extends BaseEdgeModel {
|
|
|
12
12
|
offset?: number;
|
|
13
13
|
dbClickPosition?: Point;
|
|
14
14
|
initEdgeData(data: LogicFlow.EdgeConfig): void;
|
|
15
|
+
setAttributes(): void;
|
|
16
|
+
/**
|
|
17
|
+
* 计算默认 offset:箭头与折线重叠长度 + 5
|
|
18
|
+
* 重叠长度采用箭头样式中的 offset(沿边方向的长度)
|
|
19
|
+
*/
|
|
20
|
+
private getDefaultOffset;
|
|
15
21
|
getEdgeStyle(): {
|
|
16
22
|
[x: string]: unknown;
|
|
17
23
|
fill?: string | undefined;
|
|
@@ -72,12 +72,34 @@ var PolylineEdgeModel = /** @class */ (function (_super) {
|
|
|
72
72
|
return _this;
|
|
73
73
|
}
|
|
74
74
|
PolylineEdgeModel.prototype.initEdgeData = function (data) {
|
|
75
|
-
|
|
75
|
+
var providedOffset = (0, lodash_es_1.get)(data, 'properties.offset');
|
|
76
|
+
// 当用户未传入 offset 时,按“箭头与折线重叠长度 + 5”作为默认值
|
|
77
|
+
// 其中“重叠长度”采用箭头样式中的 offset(沿边方向的长度)
|
|
78
|
+
this.offset =
|
|
79
|
+
typeof providedOffset === 'number'
|
|
80
|
+
? providedOffset
|
|
81
|
+
: this.getDefaultOffset();
|
|
76
82
|
if (data.pointsList) {
|
|
77
83
|
this.pointsList = data.pointsList;
|
|
78
84
|
}
|
|
79
85
|
_super.prototype.initEdgeData.call(this, data);
|
|
80
86
|
};
|
|
87
|
+
PolylineEdgeModel.prototype.setAttributes = function () {
|
|
88
|
+
var newOffset = this.properties.offset;
|
|
89
|
+
if (newOffset && newOffset !== this.offset) {
|
|
90
|
+
this.offset = newOffset;
|
|
91
|
+
this.updatePoints();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* 计算默认 offset:箭头与折线重叠长度 + 5
|
|
96
|
+
* 重叠长度采用箭头样式中的 offset(沿边方向的长度)
|
|
97
|
+
*/
|
|
98
|
+
PolylineEdgeModel.prototype.getDefaultOffset = function () {
|
|
99
|
+
var arrowStyle = this.getArrowStyle();
|
|
100
|
+
var arrowOverlap = typeof arrowStyle.offset === 'number' ? arrowStyle.offset : 0;
|
|
101
|
+
return arrowOverlap + 5;
|
|
102
|
+
};
|
|
81
103
|
PolylineEdgeModel.prototype.getEdgeStyle = function () {
|
|
82
104
|
var polyline = this.graphModel.theme.polyline;
|
|
83
105
|
var style = _super.prototype.getEdgeStyle.call(this);
|
|
@@ -185,7 +185,18 @@ export declare class BaseNodeModel<P extends PropertiesType = PropertiesType> im
|
|
|
185
185
|
* 获取当前节点缩放控制节点的样式
|
|
186
186
|
*/
|
|
187
187
|
getResizeControlStyle(): LogicFlow.CommonTheme;
|
|
188
|
-
getResizeOutlineStyle():
|
|
188
|
+
getResizeOutlineStyle(): {
|
|
189
|
+
[x: string]: unknown;
|
|
190
|
+
fill?: string | undefined;
|
|
191
|
+
stroke?: string | undefined;
|
|
192
|
+
strokeWidth?: number | undefined;
|
|
193
|
+
radius?: number | undefined;
|
|
194
|
+
rx?: number | undefined;
|
|
195
|
+
ry?: number | undefined;
|
|
196
|
+
width?: number | undefined;
|
|
197
|
+
height?: number | undefined;
|
|
198
|
+
path?: string | undefined;
|
|
199
|
+
};
|
|
189
200
|
/**
|
|
190
201
|
* @overridable 支持重写
|
|
191
202
|
* 获取当前节点锚点样式
|
|
@@ -382,7 +382,12 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
382
382
|
};
|
|
383
383
|
BaseNodeModel.prototype.getResizeOutlineStyle = function () {
|
|
384
384
|
var resizeOutline = this.graphModel.theme.resizeOutline;
|
|
385
|
-
|
|
385
|
+
var attributes = __assign({}, resizeOutline);
|
|
386
|
+
if (this.isHovered) {
|
|
387
|
+
var hoverStyle = resizeOutline.hover || {};
|
|
388
|
+
attributes = __assign(__assign({}, attributes), hoverStyle);
|
|
389
|
+
}
|
|
390
|
+
return (0, lodash_es_1.cloneDeep)(attributes);
|
|
386
391
|
};
|
|
387
392
|
/**
|
|
388
393
|
* @overridable 支持重写
|
|
@@ -16,5 +16,17 @@ export declare class HtmlNodeModel<P extends IHtmlNodeProperties = IHtmlNodeProp
|
|
|
16
16
|
constructor(data: LogicFlow.NodeConfig<P>, graphModel: GraphModel);
|
|
17
17
|
setAttributes(): void;
|
|
18
18
|
getDefaultAnchor(): AnchorConfig[];
|
|
19
|
+
getNodeStyle(): {
|
|
20
|
+
[x: string]: unknown;
|
|
21
|
+
fill?: string | undefined;
|
|
22
|
+
stroke?: string | undefined;
|
|
23
|
+
strokeWidth?: number | undefined;
|
|
24
|
+
radius?: number | undefined;
|
|
25
|
+
rx?: number | undefined;
|
|
26
|
+
ry?: number | undefined;
|
|
27
|
+
width?: number | undefined;
|
|
28
|
+
height?: number | undefined;
|
|
29
|
+
path?: string | undefined;
|
|
30
|
+
};
|
|
19
31
|
}
|
|
20
32
|
export default HtmlNodeModel;
|
|
@@ -14,11 +14,23 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
17
28
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
30
|
};
|
|
20
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
32
|
exports.HtmlNodeModel = void 0;
|
|
33
|
+
var lodash_es_1 = require("lodash-es");
|
|
22
34
|
var BaseNodeModel_1 = __importDefault(require("./BaseNodeModel"));
|
|
23
35
|
var constant_1 = require("../../constant");
|
|
24
36
|
var HtmlNodeModel = /** @class */ (function (_super) {
|
|
@@ -48,6 +60,13 @@ var HtmlNodeModel = /** @class */ (function (_super) {
|
|
|
48
60
|
{ x: x - width / 2, y: y, id: "".concat(this.id, "_3") },
|
|
49
61
|
];
|
|
50
62
|
};
|
|
63
|
+
HtmlNodeModel.prototype.getNodeStyle = function () {
|
|
64
|
+
var style = _super.prototype.getNodeStyle.call(this);
|
|
65
|
+
var _a = this.graphModel.theme, baseNode = _a.baseNode, html = _a.html;
|
|
66
|
+
var _b = this.properties.style, customStyle = _b === void 0 ? {} : _b;
|
|
67
|
+
var finalStyle = __assign(__assign(__assign(__assign({}, style), (0, lodash_es_1.cloneDeep)(baseNode)), (0, lodash_es_1.cloneDeep)(html)), (0, lodash_es_1.cloneDeep)(customStyle));
|
|
68
|
+
return finalStyle;
|
|
69
|
+
};
|
|
51
70
|
return HtmlNodeModel;
|
|
52
71
|
}(BaseNodeModel_1.default));
|
|
53
72
|
exports.HtmlNodeModel = HtmlNodeModel;
|
|
@@ -94,9 +94,9 @@ var PolygonNodeModel = /** @class */ (function (_super) {
|
|
|
94
94
|
};
|
|
95
95
|
PolygonNodeModel.prototype.getNodeStyle = function () {
|
|
96
96
|
var style = _super.prototype.getNodeStyle.call(this);
|
|
97
|
-
var
|
|
98
|
-
var
|
|
99
|
-
return __assign(__assign(__assign({}, style), (0, lodash_es_1.cloneDeep)(polygon)), (0, lodash_es_1.cloneDeep)(customStyle));
|
|
97
|
+
var _a = this.graphModel, polygon = _a.theme.polygon, customPolygon = _a.customStyles.polygon;
|
|
98
|
+
var _b = this.properties.style, customStyle = _b === void 0 ? {} : _b;
|
|
99
|
+
return __assign(__assign(__assign(__assign({}, style), (0, lodash_es_1.cloneDeep)(polygon)), (0, lodash_es_1.cloneDeep)(customPolygon)), (0, lodash_es_1.cloneDeep)(customStyle));
|
|
100
100
|
};
|
|
101
101
|
Object.defineProperty(PolygonNodeModel.prototype, "pointsPosition", {
|
|
102
102
|
/**
|
package/lib/options.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export declare namespace Options {
|
|
|
70
70
|
edgeGenerator?: EdgeGeneratorType;
|
|
71
71
|
customTargetAnchor?: customTargetAnchorType;
|
|
72
72
|
customTrajectory?: (props: CustomAnchorLineProps) => h.JSX.Element;
|
|
73
|
-
themeMode?:
|
|
73
|
+
themeMode?: LogicFlow.ThemeMode;
|
|
74
74
|
parentTransform?: TransformModel;
|
|
75
75
|
[key: string]: unknown;
|
|
76
76
|
}
|
package/lib/style/index.css
CHANGED
|
@@ -177,8 +177,9 @@
|
|
|
177
177
|
}
|
|
178
178
|
.lf-multiple-select {
|
|
179
179
|
position: absolute;
|
|
180
|
-
border: 2px dashed #
|
|
181
|
-
|
|
180
|
+
border: 2px dashed #4271dfcc;
|
|
181
|
+
border-radius: 12px;
|
|
182
|
+
box-shadow: 0 0 3px 0 #4271df80;
|
|
182
183
|
cursor: move;
|
|
183
184
|
}
|
|
184
185
|
.lf-edge-adjust-point {
|
package/lib/style/index.less
CHANGED
|
@@ -215,8 +215,9 @@
|
|
|
215
215
|
|
|
216
216
|
.lf-multiple-select {
|
|
217
217
|
position: absolute;
|
|
218
|
-
border: 2px dashed #
|
|
219
|
-
|
|
218
|
+
border: 2px dashed #4271dfcc;
|
|
219
|
+
border-radius: 12px;
|
|
220
|
+
box-shadow: 0 0 3px 0 #4271df80;
|
|
220
221
|
cursor: move;
|
|
221
222
|
}
|
|
222
223
|
|
package/lib/style/raw.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto generated file, do not modify it!
|
|
3
3
|
*/
|
|
4
|
-
export declare const content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n*:focus {\n outline: none;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #
|
|
4
|
+
export declare const content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n*:focus {\n outline: none;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #4271dfcc;\n border-radius: 12px;\n box-shadow: 0 0 3px 0 #4271df80;\n cursor: move;\n}\n.lf-edge-adjust-point {\n cursor: move;\n}\n.lf-rotate-control {\n cursor: grabbing;\n}\n.lf-resize-control-nw {\n cursor: nw-resize;\n}\n.lf-resize-control-n {\n cursor: n-resize;\n}\n.lf-resize-control-ne {\n cursor: ne-resize;\n}\n.lf-resize-control-e {\n cursor: e-resize;\n}\n.lf-resize-control-se {\n cursor: se-resize;\n}\n.lf-resize-control-s {\n cursor: s-resize;\n}\n.lf-resize-control-sw {\n cursor: sw-resize;\n}\n.lf-resize-control-w {\n cursor: w-resize;\n}\n";
|
package/lib/style/raw.js
CHANGED
|
@@ -5,4 +5,4 @@ exports.content = void 0;
|
|
|
5
5
|
/**
|
|
6
6
|
* Auto generated file, do not modify it!
|
|
7
7
|
*/
|
|
8
|
-
exports.content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n*:focus {\n outline: none;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #
|
|
8
|
+
exports.content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n*:focus {\n outline: none;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #4271dfcc;\n border-radius: 12px;\n box-shadow: 0 0 3px 0 #4271df80;\n cursor: move;\n}\n.lf-edge-adjust-point {\n cursor: move;\n}\n.lf-rotate-control {\n cursor: grabbing;\n}\n.lf-resize-control-nw {\n cursor: nw-resize;\n}\n.lf-resize-control-n {\n cursor: n-resize;\n}\n.lf-resize-control-ne {\n cursor: ne-resize;\n}\n.lf-resize-control-e {\n cursor: e-resize;\n}\n.lf-resize-control-se {\n cursor: se-resize;\n}\n.lf-resize-control-s {\n cursor: s-resize;\n}\n.lf-resize-control-sw {\n cursor: sw-resize;\n}\n.lf-resize-control-w {\n cursor: w-resize;\n}\n";
|
|
@@ -117,8 +117,9 @@ var MultipleSelect = /** @class */ (function (_super) {
|
|
|
117
117
|
}
|
|
118
118
|
MultipleSelect.prototype.render = function () {
|
|
119
119
|
var _a, _b;
|
|
120
|
-
var _c = this.props.graphModel, selectElements = _c.selectElements, transformModel = _c.transformModel;
|
|
120
|
+
var _c = this.props.graphModel, selectElements = _c.selectElements, transformModel = _c.transformModel, theme = _c.theme;
|
|
121
121
|
var _d = this.props.lf.getTransform(), SCALE_X = _d.SCALE_X, SCALE_Y = _d.SCALE_Y;
|
|
122
|
+
var _e = theme.multiSelect || {}, _f = _e.xPadding, xPadding = _f === void 0 ? 8 : _f, _g = _e.yPadding, yPadding = _g === void 0 ? 8 : _g;
|
|
122
123
|
if (selectElements.size <= 1)
|
|
123
124
|
return;
|
|
124
125
|
var x = Number.MAX_SAFE_INTEGER;
|
|
@@ -143,10 +144,10 @@ var MultipleSelect = /** @class */ (function (_super) {
|
|
|
143
144
|
_a = __read(transformModel.CanvasPointToHtmlPoint([x, y]), 2), x = _a[0], y = _a[1];
|
|
144
145
|
_b = __read(transformModel.CanvasPointToHtmlPoint([x1, y1]), 2), x1 = _b[0], y1 = _b[1];
|
|
145
146
|
var style = {
|
|
146
|
-
left: "".concat(x - (20 * SCALE_X) / 2, "px"),
|
|
147
|
-
top: "".concat(y - (20 * SCALE_Y) / 2, "px"),
|
|
148
|
-
width: "".concat(x1 - x + 20 * SCALE_X, "px"),
|
|
149
|
-
height: "".concat(y1 - y + 20 * SCALE_Y, "px"),
|
|
147
|
+
left: "".concat(x - (20 * SCALE_X) / 2 - xPadding / 2, "px"),
|
|
148
|
+
top: "".concat(y - (20 * SCALE_Y) / 2 - yPadding / 2, "px"),
|
|
149
|
+
width: "".concat(x1 - x + 20 * SCALE_X + xPadding, "px"),
|
|
150
|
+
height: "".concat(y1 - y + 20 * SCALE_Y + yPadding, "px"),
|
|
150
151
|
'border-width': "".concat(2 * SCALE_X, "px"),
|
|
151
152
|
};
|
|
152
153
|
return ((0, jsx_runtime_1.jsx)("div", { className: "lf-multiple-select", style: style, onPointerDown: this.handleMouseDown, onContextMenu: this.handleContextMenu, onWheel: this.handleWheelEvent }));
|
package/lib/util/edge.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare const getExpandedBBox: (bbox: BoxBounds, offset: number) => BoxBo
|
|
|
16
16
|
export declare const pointDirection: (point: Point, bbox: BoxBounds) => Direction;
|
|
17
17
|
export declare const getExpandedBBoxPoint: (expendBBox: BoxBounds, bbox: BoxBounds, point: Point) => Point;
|
|
18
18
|
export declare const mergeBBox: (b1: BoxBounds, b2: BoxBounds) => BoxBounds;
|
|
19
|
-
export declare const getBBoxOfPoints: (points?: Point[], offset?: number) => BoxBounds;
|
|
19
|
+
export declare const getBBoxOfPoints: (points?: Point[], offset?: number, heightOffset?: number) => BoxBounds;
|
|
20
20
|
export declare const getPointsFromBBox: (bbox: BoxBounds) => [Point, Point, Point, Point];
|
|
21
21
|
export declare const isPointOutsideBBox: (point: Point, bbox: BoxBounds) => boolean;
|
|
22
22
|
export declare const getBBoxXCrossPoints: (bbox: BoxBounds, x: number) => [Point, Point] | [
|
package/lib/util/edge.js
CHANGED
|
@@ -166,7 +166,7 @@ exports.mergeBBox = mergeBBox;
|
|
|
166
166
|
* 1、获取起始终点相邻点(expendBboxPoint)的bbox
|
|
167
167
|
* 2、polylineEdge, bezierEdge,获取outline边框,这种情况传入offset
|
|
168
168
|
*/
|
|
169
|
-
var getBBoxOfPoints = function (points, offset) {
|
|
169
|
+
var getBBoxOfPoints = function (points, offset, heightOffset) {
|
|
170
170
|
if (points === void 0) { points = []; }
|
|
171
171
|
var xList = [];
|
|
172
172
|
var yList = [];
|
|
@@ -182,7 +182,7 @@ var getBBoxOfPoints = function (points, offset) {
|
|
|
182
182
|
var height = maxY - minY;
|
|
183
183
|
if (offset) {
|
|
184
184
|
width += offset;
|
|
185
|
-
height += offset;
|
|
185
|
+
height += heightOffset || offset;
|
|
186
186
|
}
|
|
187
187
|
return {
|
|
188
188
|
centerX: (minX + maxX) / 2,
|
package/lib/util/geometry.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import LogicFlow from '../LogicFlow';
|
|
2
2
|
import PointTuple = LogicFlow.PointTuple;
|
|
3
|
+
import Point = LogicFlow.Point;
|
|
3
4
|
export declare function snapToGrid(point: number, gridSize: number, snapGrid: boolean): number;
|
|
4
5
|
export declare function getGridOffset(distance: number, gridSize: number): number;
|
|
5
6
|
/**
|
|
@@ -9,3 +10,10 @@ export declare function getGridOffset(distance: number, gridSize: number): numbe
|
|
|
9
10
|
* @param height
|
|
10
11
|
*/
|
|
11
12
|
export declare function normalizePolygon(points?: PointTuple[], width?: number, height?: number): PointTuple[];
|
|
13
|
+
/**
|
|
14
|
+
* 通用圆角生成:为菱形、多边形、折线在转折处生成与矩形视觉一致的圆角
|
|
15
|
+
* - 圆角基于角平分线,切点距顶点的距离 t = r * tan(theta/2)
|
|
16
|
+
* - 半径会根据相邻边长度进行钳制,避免超过边长造成断裂
|
|
17
|
+
* - 多边形/菱形保持闭合;折线保持开口
|
|
18
|
+
*/
|
|
19
|
+
export declare const generateRoundedCorners: (points: Point[], radius: number, isClosedShape: boolean) => Point[];
|
package/lib/util/geometry.js
CHANGED
|
@@ -25,7 +25,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
25
25
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.normalizePolygon = exports.getGridOffset = exports.snapToGrid = void 0;
|
|
28
|
+
exports.generateRoundedCorners = exports.normalizePolygon = exports.getGridOffset = exports.snapToGrid = void 0;
|
|
29
29
|
function snapToGrid(point, gridSize, snapGrid) {
|
|
30
30
|
// 开启节网格对齐时才根据网格尺寸校准坐标
|
|
31
31
|
if (!snapGrid)
|
|
@@ -78,3 +78,83 @@ function normalizePolygon(points, width, height) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
exports.normalizePolygon = normalizePolygon;
|
|
81
|
+
/**
|
|
82
|
+
* 通用圆角生成:为菱形、多边形、折线在转折处生成与矩形视觉一致的圆角
|
|
83
|
+
* - 圆角基于角平分线,切点距顶点的距离 t = r * tan(theta/2)
|
|
84
|
+
* - 半径会根据相邻边长度进行钳制,避免超过边长造成断裂
|
|
85
|
+
* - 多边形/菱形保持闭合;折线保持开口
|
|
86
|
+
*/
|
|
87
|
+
var generateRoundedCorners = function (points, radius, isClosedShape) {
|
|
88
|
+
var n = points.length;
|
|
89
|
+
if (n < 2 || radius <= 0)
|
|
90
|
+
return points.slice();
|
|
91
|
+
var toVec = function (a, b) { return ({ x: b.x - a.x, y: b.y - a.y }); };
|
|
92
|
+
var len = function (v) { return Math.hypot(v.x, v.y); };
|
|
93
|
+
var norm = function (v) {
|
|
94
|
+
var l = len(v) || 1;
|
|
95
|
+
return { x: v.x / l, y: v.y / l };
|
|
96
|
+
};
|
|
97
|
+
var result = [];
|
|
98
|
+
// 用二次贝塞尔近似圆角,控制点取角点,避免复杂圆心计算
|
|
99
|
+
var makeRoundCorner = function (prev, curr, next) {
|
|
100
|
+
var vPrev = toVec(curr, prev);
|
|
101
|
+
var vNext = toVec(curr, next);
|
|
102
|
+
var dPrev = len(vPrev);
|
|
103
|
+
var dNext = len(vNext);
|
|
104
|
+
if (dPrev < 1e-6 || dNext < 1e-6)
|
|
105
|
+
return [curr];
|
|
106
|
+
var uPrev = norm(vPrev);
|
|
107
|
+
var uNext = norm(vNext);
|
|
108
|
+
var t = Math.min(radius, dPrev * 0.45, dNext * 0.45);
|
|
109
|
+
var start = { x: curr.x + uPrev.x * t, y: curr.y + uPrev.y * t };
|
|
110
|
+
var end = { x: curr.x + uNext.x * t, y: curr.y + uNext.y * t };
|
|
111
|
+
// 二次贝塞尔采样:B(s) = (1-s)^2*start + 2(1-s)s*curr + s^2*end
|
|
112
|
+
var steps = 10; // 3段近似,简洁且效果稳定
|
|
113
|
+
var pts = [start];
|
|
114
|
+
for (var k = 1; k < steps; k++) {
|
|
115
|
+
var s = k / steps;
|
|
116
|
+
var a = 1 - s;
|
|
117
|
+
pts.push({
|
|
118
|
+
x: a * a * start.x + 2 * a * s * curr.x + s * s * end.x,
|
|
119
|
+
y: a * a * start.y + 2 * a * s * curr.y + s * s * end.y,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
pts.push(end);
|
|
123
|
+
return pts;
|
|
124
|
+
};
|
|
125
|
+
for (var i = 0; i < n; i++) {
|
|
126
|
+
var prevIdx = i === 0 ? (isClosedShape ? n - 1 : 0) : i - 1;
|
|
127
|
+
var nextIdx = i === n - 1 ? (isClosedShape ? 0 : n - 1) : i + 1;
|
|
128
|
+
var prev = points[prevIdx];
|
|
129
|
+
var curr = points[i];
|
|
130
|
+
var next = points[nextIdx];
|
|
131
|
+
var isEndpoint = !isClosedShape && (i === 0 || i === n - 1);
|
|
132
|
+
if (isEndpoint) {
|
|
133
|
+
// 折线两端不处理圆角
|
|
134
|
+
result.push(curr);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
var arc = makeRoundCorner(prev, curr, next);
|
|
138
|
+
arc.forEach(function (p) { return result.push(p); });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// 去重处理:避免连续重复点
|
|
142
|
+
var dedup = [];
|
|
143
|
+
for (var i = 0; i < result.length; i++) {
|
|
144
|
+
var p = result[i];
|
|
145
|
+
if (dedup.length === 0 ||
|
|
146
|
+
Math.hypot(p.x - dedup[dedup.length - 1].x, p.y - dedup[dedup.length - 1].y) > 1e-6) {
|
|
147
|
+
dedup.push(p);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// 闭合图形:确保首尾不重复闭合
|
|
151
|
+
if (isClosedShape && dedup.length > 1) {
|
|
152
|
+
var first = dedup[0];
|
|
153
|
+
var last = dedup[dedup.length - 1];
|
|
154
|
+
if (Math.hypot(first.x - last.x, first.y - last.y) < 1e-6) {
|
|
155
|
+
dedup.pop();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return dedup;
|
|
159
|
+
};
|
|
160
|
+
exports.generateRoundedCorners = generateRoundedCorners;
|
package/lib/util/theme.d.ts
CHANGED
|
@@ -1,69 +1,6 @@
|
|
|
1
1
|
import LogicFlow from '../LogicFlow';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const radiusMode: any;
|
|
4
|
-
export declare const darkMode: any;
|
|
5
|
-
export declare const colorfulMode: any;
|
|
6
|
-
export declare const themeModeMap: {
|
|
7
|
-
colorful: any;
|
|
8
|
-
dark: any;
|
|
9
|
-
radius: any;
|
|
10
|
-
default: LogicFlow.Theme;
|
|
11
|
-
};
|
|
12
|
-
export declare const darkBackground: {
|
|
13
|
-
background: string;
|
|
14
|
-
};
|
|
15
|
-
export declare const colorfulBackground: {
|
|
16
|
-
background: string;
|
|
17
|
-
};
|
|
18
|
-
export declare const defaultBackground: {
|
|
19
|
-
background: string;
|
|
20
|
-
};
|
|
21
|
-
export declare const backgroundModeMap: {
|
|
22
|
-
colorful: {
|
|
23
|
-
background: string;
|
|
24
|
-
};
|
|
25
|
-
dark: {
|
|
26
|
-
background: string;
|
|
27
|
-
};
|
|
28
|
-
radius: {
|
|
29
|
-
background: string;
|
|
30
|
-
};
|
|
31
|
-
default: {
|
|
32
|
-
background: string;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export declare const darkGrid: {
|
|
36
|
-
color: string;
|
|
37
|
-
thickness: number;
|
|
38
|
-
};
|
|
39
|
-
export declare const colorfulGrid: {
|
|
40
|
-
color: string;
|
|
41
|
-
thickness: number;
|
|
42
|
-
};
|
|
43
|
-
export declare const defaultGrid: {
|
|
44
|
-
color: string;
|
|
45
|
-
thickness: number;
|
|
46
|
-
};
|
|
47
|
-
export declare const gridModeMap: {
|
|
48
|
-
colorful: {
|
|
49
|
-
color: string;
|
|
50
|
-
thickness: number;
|
|
51
|
-
};
|
|
52
|
-
dark: {
|
|
53
|
-
color: string;
|
|
54
|
-
thickness: number;
|
|
55
|
-
};
|
|
56
|
-
radius: {
|
|
57
|
-
color: string;
|
|
58
|
-
thickness: number;
|
|
59
|
-
};
|
|
60
|
-
default: {
|
|
61
|
-
color: string;
|
|
62
|
-
thickness: number;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
export declare const setupTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string) => LogicFlow.Theme;
|
|
2
|
+
export declare const setupTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: LogicFlow.ThemeMode | string) => LogicFlow.Theme;
|
|
66
3
|
export declare const addThemeMode: (themeMode: string, style: Partial<LogicFlow.Theme>) => void;
|
|
67
4
|
export declare const removeThemeMode: (themeMode: string) => void;
|
|
68
5
|
export declare const clearThemeMode: () => void;
|
|
69
|
-
export declare const updateTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?:
|
|
6
|
+
export declare const updateTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: LogicFlow.ThemeMode | string) => LogicFlow.Theme;
|