@logicflow/core 2.0.7 → 2.0.9
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 +10 -10
- package/.turbo/turbo-build.log +33 -33
- package/CHANGELOG.md +18 -2
- package/__tests__/algorithm/egde.test.ts +4 -4
- package/dist/index.css +3 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/LogicFlow.d.ts +3 -0
- package/es/LogicFlow.js +4 -0
- package/es/algorithm/edge.js +3 -5
- package/es/constant/index.d.ts +4 -0
- package/es/constant/index.js +4 -0
- package/es/event/eventArgs.d.ts +27 -1
- package/es/index.css +3 -0
- package/es/model/GraphModel.d.ts +3 -0
- package/es/model/GraphModel.js +84 -7
- package/es/model/edge/LineEdgeModel.d.ts +2 -0
- package/es/model/edge/LineEdgeModel.js +8 -0
- package/es/model/edge/PolylineEdgeModel.d.ts +1 -0
- package/es/model/edge/PolylineEdgeModel.js +4 -3
- package/es/model/node/HtmlNodeModel.d.ts +2 -2
- package/es/style/index.css +3 -0
- package/es/style/index.less +5 -0
- package/es/style/raw.d.ts +1 -1
- package/es/style/raw.js +1 -1
- package/es/view/edge/BaseEdge.d.ts +2 -0
- package/es/view/edge/BaseEdge.js +13 -1
- package/es/view/node/BaseNode.d.ts +2 -0
- package/es/view/node/BaseNode.js +14 -2
- package/es/view/overlay/BackgroundOverlay.js +2 -1
- package/lib/LogicFlow.d.ts +3 -0
- package/lib/LogicFlow.js +4 -0
- package/lib/algorithm/edge.js +3 -5
- package/lib/constant/index.d.ts +4 -0
- package/lib/constant/index.js +4 -0
- package/lib/event/eventArgs.d.ts +27 -1
- package/lib/index.css +3 -0
- package/lib/model/GraphModel.d.ts +3 -0
- package/lib/model/GraphModel.js +83 -6
- package/lib/model/edge/LineEdgeModel.d.ts +2 -0
- package/lib/model/edge/LineEdgeModel.js +8 -0
- package/lib/model/edge/PolylineEdgeModel.d.ts +1 -0
- package/lib/model/edge/PolylineEdgeModel.js +4 -3
- package/lib/model/node/HtmlNodeModel.d.ts +2 -2
- package/lib/style/index.css +3 -0
- package/lib/style/index.less +5 -0
- package/lib/style/raw.d.ts +1 -1
- package/lib/style/raw.js +1 -1
- package/lib/view/edge/BaseEdge.d.ts +2 -0
- package/lib/view/edge/BaseEdge.js +13 -1
- package/lib/view/node/BaseNode.d.ts +2 -0
- package/lib/view/node/BaseNode.js +14 -2
- package/lib/view/overlay/BackgroundOverlay.js +2 -1
- package/package.json +1 -1
- package/src/LogicFlow.tsx +6 -0
- package/src/algorithm/edge.ts +1 -1
- package/src/algorithm/outline.ts +1 -1
- package/src/constant/index.ts +4 -0
- package/src/event/eventArgs.ts +27 -1
- package/src/model/GraphModel.ts +111 -3
- package/src/model/edge/LineEdgeModel.ts +8 -0
- package/src/model/edge/PolylineEdgeModel.ts +5 -3
- package/src/style/index.less +5 -0
- package/src/style/raw.ts +3 -0
- package/src/view/Graph.tsx +3 -4
- package/src/view/edge/BaseEdge.tsx +16 -0
- package/src/view/node/BaseNode.tsx +17 -1
- package/src/view/overlay/BackgroundOverlay.tsx +11 -16
- package/src/view/overlay/OutlineOverlay.tsx +1 -1
- package/stats.html +1 -1
package/es/LogicFlow.d.ts
CHANGED
|
@@ -568,6 +568,8 @@ export declare class LogicFlow {
|
|
|
568
568
|
* 加载插件-内部方法
|
|
569
569
|
*/
|
|
570
570
|
private installPlugin;
|
|
571
|
+
/** 销毁当前实例 */
|
|
572
|
+
destroy(): void;
|
|
571
573
|
}
|
|
572
574
|
export declare namespace LogicFlow {
|
|
573
575
|
/**
|
|
@@ -638,6 +640,7 @@ export declare namespace LogicFlow {
|
|
|
638
640
|
};
|
|
639
641
|
type LabelConfig = {
|
|
640
642
|
id?: string;
|
|
643
|
+
type?: string;
|
|
641
644
|
x: number;
|
|
642
645
|
y: number;
|
|
643
646
|
content?: string;
|
package/es/LogicFlow.js
CHANGED
|
@@ -1166,6 +1166,10 @@ var LogicFlow = /** @class */ (function () {
|
|
|
1166
1166
|
this.components.push(extensionIns.render.bind(extensionIns));
|
|
1167
1167
|
this.extension[pluginName] = extensionIns;
|
|
1168
1168
|
};
|
|
1169
|
+
/** 销毁当前实例 */
|
|
1170
|
+
LogicFlow.prototype.destroy = function () {
|
|
1171
|
+
this.graphModel.destroy();
|
|
1172
|
+
};
|
|
1169
1173
|
// 全局配置的插件,所有的LogicFlow示例都会使用
|
|
1170
1174
|
LogicFlow.extensions = new Map();
|
|
1171
1175
|
return LogicFlow;
|
package/es/algorithm/edge.js
CHANGED
|
@@ -48,9 +48,7 @@ export var isInSegment = function (point, start, end) {
|
|
|
48
48
|
var endX = end.x, endY = end.y;
|
|
49
49
|
var k = (endY - startY) / (endX - startX);
|
|
50
50
|
var b = startY - k * startX;
|
|
51
|
-
return (x >= startX &&
|
|
52
|
-
|
|
53
|
-
y
|
|
54
|
-
y <= endY &&
|
|
55
|
-
Math.abs(y - k * x + b) < Number.EPSILON);
|
|
51
|
+
return (((x >= startX && x <= endX) || (x <= startX && x >= endX)) &&
|
|
52
|
+
((y >= startY && y <= endY) || (y <= startY && y >= endY)) &&
|
|
53
|
+
Math.abs(y - k * x - b) < Number.EPSILON);
|
|
56
54
|
};
|
package/es/constant/index.d.ts
CHANGED
|
@@ -49,12 +49,16 @@ export declare enum EventType {
|
|
|
49
49
|
NODE_CONTEXTMENU = "node:contextmenu",
|
|
50
50
|
NODE_ROTATE = "node:rotate",
|
|
51
51
|
NODE_RESIZE = "node:resize",
|
|
52
|
+
NODE_FOCUS = "node:focus",
|
|
53
|
+
NODE_BLUR = "node:blur",
|
|
52
54
|
NODE_PROPERTIES_CHANGE = "node:properties-change",
|
|
53
55
|
NODE_PROPERTIES_DELETE = "node:properties-delete",
|
|
54
56
|
EDGE_ADD = "edge:add",
|
|
55
57
|
EDGE_DELETE = "edge:delete",
|
|
56
58
|
EDGE_CLICK = "edge:click",
|
|
57
59
|
EDGE_DBCLICK = "edge:dbclick",
|
|
60
|
+
EDGE_FOCUS = "edge:focus",
|
|
61
|
+
EDGE_BLUR = "edge:blur",
|
|
58
62
|
EDGE_MOUSEENTER = "edge:mouseenter",
|
|
59
63
|
EDGE_MOUSELEAVE = "edge:mouseleave",
|
|
60
64
|
EDGE_CONTEXTMENU = "edge:contextmenu",
|
package/es/constant/index.js
CHANGED
|
@@ -54,6 +54,8 @@ export var EventType;
|
|
|
54
54
|
EventType["NODE_CONTEXTMENU"] = "node:contextmenu";
|
|
55
55
|
EventType["NODE_ROTATE"] = "node:rotate";
|
|
56
56
|
EventType["NODE_RESIZE"] = "node:resize";
|
|
57
|
+
EventType["NODE_FOCUS"] = "node:focus";
|
|
58
|
+
EventType["NODE_BLUR"] = "node:blur";
|
|
57
59
|
// 节点 properties 变化事件
|
|
58
60
|
EventType["NODE_PROPERTIES_CHANGE"] = "node:properties-change";
|
|
59
61
|
EventType["NODE_PROPERTIES_DELETE"] = "node:properties-delete";
|
|
@@ -62,6 +64,8 @@ export var EventType;
|
|
|
62
64
|
EventType["EDGE_DELETE"] = "edge:delete";
|
|
63
65
|
EventType["EDGE_CLICK"] = "edge:click";
|
|
64
66
|
EventType["EDGE_DBCLICK"] = "edge:dbclick";
|
|
67
|
+
EventType["EDGE_FOCUS"] = "edge:focus";
|
|
68
|
+
EventType["EDGE_BLUR"] = "edge:blur";
|
|
65
69
|
EventType["EDGE_MOUSEENTER"] = "edge:mouseenter";
|
|
66
70
|
EventType["EDGE_MOUSELEAVE"] = "edge:mouseleave";
|
|
67
71
|
EventType["EDGE_CONTEXTMENU"] = "edge:contextmenu";
|
package/es/event/eventArgs.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ interface NodeEventArgs {
|
|
|
97
97
|
/**
|
|
98
98
|
* 删除节点
|
|
99
99
|
*/
|
|
100
|
-
'node:delete': NodeEventArgsPick<'data'>;
|
|
100
|
+
'node:delete': NodeEventArgsPick<'data' | 'model'>;
|
|
101
101
|
/**
|
|
102
102
|
* 添加外部拖入节点
|
|
103
103
|
*/
|
|
@@ -151,6 +151,14 @@ interface NodeEventArgs {
|
|
|
151
151
|
*/
|
|
152
152
|
properties: Record<string, any>;
|
|
153
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* 节点获焦
|
|
156
|
+
*/
|
|
157
|
+
'node:focus': NodeEventArgsPick<'data'>;
|
|
158
|
+
/**
|
|
159
|
+
* 节点失焦
|
|
160
|
+
*/
|
|
161
|
+
'node:blur': NodeEventArgsPick<'data'>;
|
|
154
162
|
}
|
|
155
163
|
type EdgeEventArgsPick<T extends 'data' | 'e' | 'position'> = Pick<{
|
|
156
164
|
/**
|
|
@@ -217,6 +225,14 @@ interface EdgeEventArgs {
|
|
|
217
225
|
oldEdge: EdgeData;
|
|
218
226
|
};
|
|
219
227
|
};
|
|
228
|
+
/**
|
|
229
|
+
* 边获焦
|
|
230
|
+
*/
|
|
231
|
+
'edge:focus': EdgeEventArgsPick<'data'>;
|
|
232
|
+
/**
|
|
233
|
+
* 边失焦
|
|
234
|
+
*/
|
|
235
|
+
'edge:blur': EdgeEventArgsPick<'data'>;
|
|
220
236
|
}
|
|
221
237
|
/**
|
|
222
238
|
* 文本事件
|
|
@@ -333,6 +349,16 @@ interface CommonEventArgs {
|
|
|
333
349
|
*/
|
|
334
350
|
data: GraphData;
|
|
335
351
|
};
|
|
352
|
+
/**
|
|
353
|
+
* 画布容器大小发生变化触发,为了性能考虑对事件做了防抖处理,间隔为16ms
|
|
354
|
+
*/
|
|
355
|
+
'graph:resize': {
|
|
356
|
+
/**
|
|
357
|
+
* 更新后的画布数据
|
|
358
|
+
*/
|
|
359
|
+
target: HTMLElement;
|
|
360
|
+
contentRect: DOMRectReadOnly;
|
|
361
|
+
};
|
|
336
362
|
}
|
|
337
363
|
type AnchorEventArgsPick<T extends 'data' | 'e' | 'nodeModel' | 'edgeModel'> = Pick<{
|
|
338
364
|
/**
|
package/es/index.css
CHANGED
package/es/model/GraphModel.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export declare class GraphModel {
|
|
|
62
62
|
editConfigModel: EditConfigModel;
|
|
63
63
|
partial: boolean;
|
|
64
64
|
[propName: string]: any;
|
|
65
|
+
private waitCleanEffects;
|
|
65
66
|
constructor(options: LFOptions.Common);
|
|
66
67
|
get nodesMap(): GraphModel.NodesMapType;
|
|
67
68
|
get edgesMap(): GraphModel.EdgesMapType;
|
|
@@ -437,6 +438,8 @@ export declare class GraphModel {
|
|
|
437
438
|
* @returns
|
|
438
439
|
*/
|
|
439
440
|
setPartial(partial: boolean): void;
|
|
441
|
+
/** 销毁当前实例 */
|
|
442
|
+
destroy(): void;
|
|
440
443
|
}
|
|
441
444
|
export declare namespace GraphModel {
|
|
442
445
|
type NodesMapType = Record<string, {
|
package/es/model/GraphModel.js
CHANGED
|
@@ -15,6 +15,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
15
15
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
16
16
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17
17
|
};
|
|
18
|
+
var __values = (this && this.__values) || function(o) {
|
|
19
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
20
|
+
if (m) return m.call(o);
|
|
21
|
+
if (o && typeof o.length === "number") return {
|
|
22
|
+
next: function () {
|
|
23
|
+
if (o && i >= o.length) o = void 0;
|
|
24
|
+
return { value: o && o[i++], done: !o };
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
28
|
+
};
|
|
18
29
|
var __read = (this && this.__read) || function (o, n) {
|
|
19
30
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
20
31
|
if (!m) return o;
|
|
@@ -40,7 +51,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
40
51
|
}
|
|
41
52
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
42
53
|
};
|
|
43
|
-
import { find, forEach, map, merge } from 'lodash-es';
|
|
54
|
+
import { find, forEach, map, merge, isBoolean, debounce, isEqual } from 'lodash-es';
|
|
44
55
|
import { action, computed, observable } from 'mobx';
|
|
45
56
|
import { EditConfigModel, TransformModel, } from '.';
|
|
46
57
|
import { DEFAULT_VISIBLE_SPACE, ELEMENT_MAX_Z_INDEX, ElementState, ElementType, EventType, ModelType, OverlapMode, TextMode, } from '../constant';
|
|
@@ -49,6 +60,7 @@ import EventEmitter from '../event/eventEmitter';
|
|
|
49
60
|
import { Grid } from '../view/overlay';
|
|
50
61
|
var GraphModel = /** @class */ (function () {
|
|
51
62
|
function GraphModel(options) {
|
|
63
|
+
var _this = this;
|
|
52
64
|
// 维护所有节点和边类型对应的 model
|
|
53
65
|
this.modelMap = new Map();
|
|
54
66
|
// Remind:用于记录当前画布上所有节点和边的 model 的 Map
|
|
@@ -81,6 +93,7 @@ var GraphModel = /** @class */ (function () {
|
|
|
81
93
|
this.gridSize = 1;
|
|
82
94
|
// 控制是否开启局部渲染
|
|
83
95
|
this.partial = false;
|
|
96
|
+
this.waitCleanEffects = [];
|
|
84
97
|
var container = options.container, partial = options.partial, _a = options.background, background = _a === void 0 ? {} : _a, grid = options.grid, idGenerator = options.idGenerator, edgeGenerator = options.edgeGenerator, animation = options.animation, customTrajectory = options.customTrajectory;
|
|
85
98
|
this.rootEl = container;
|
|
86
99
|
this.partial = !!partial;
|
|
@@ -95,6 +108,32 @@ var GraphModel = /** @class */ (function () {
|
|
|
95
108
|
this.overlapMode = options.overlapMode || OverlapMode.DEFAULT;
|
|
96
109
|
this.width = options.width || this.rootEl.getBoundingClientRect().width;
|
|
97
110
|
this.height = options.height || this.rootEl.getBoundingClientRect().height;
|
|
111
|
+
var resizeObserver = new ResizeObserver(debounce((function (entries) {
|
|
112
|
+
var e_1, _a;
|
|
113
|
+
try {
|
|
114
|
+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
115
|
+
var entry = entries_1_1.value;
|
|
116
|
+
if (entry.target === _this.rootEl) {
|
|
117
|
+
_this.resize();
|
|
118
|
+
_this.eventCenter.emit('graph:resize', {
|
|
119
|
+
target: _this.rootEl,
|
|
120
|
+
contentRect: entry.contentRect,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
126
|
+
finally {
|
|
127
|
+
try {
|
|
128
|
+
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
|
129
|
+
}
|
|
130
|
+
finally { if (e_1) throw e_1.error; }
|
|
131
|
+
}
|
|
132
|
+
}), 16));
|
|
133
|
+
resizeObserver.observe(this.rootEl);
|
|
134
|
+
this.waitCleanEffects.push(function () {
|
|
135
|
+
resizeObserver.disconnect();
|
|
136
|
+
});
|
|
98
137
|
this.eventCenter = new EventEmitter();
|
|
99
138
|
this.editConfigModel = new EditConfigModel(options);
|
|
100
139
|
this.transformModel = new TransformModel(this.eventCenter, options);
|
|
@@ -375,6 +414,31 @@ var GraphModel = /** @class */ (function () {
|
|
|
375
414
|
throw new Error("\u627E\u4E0D\u5230".concat(edge.type, "\u5BF9\u5E94\u7684\u8FB9\u3002"));
|
|
376
415
|
}
|
|
377
416
|
var edgeModel = new Model(edge, _this);
|
|
417
|
+
// 根据edgeModel中存储的数据找到当前画布上的起终锚点坐标
|
|
418
|
+
// 判断当前起终锚点数据和Model中存储的起终点数据是否一致,不一致更新起终点信息
|
|
419
|
+
var sourceNodeId = edgeModel.sourceNodeId, targetNodeId = edgeModel.targetNodeId, _b = edgeModel.sourceAnchorId, sourceAnchorId = _b === void 0 ? '' : _b, _c = edgeModel.targetAnchorId, targetAnchorId = _c === void 0 ? '' : _c, startPoint = edgeModel.startPoint, endPoint = edgeModel.endPoint, text = edgeModel.text, textPosition = edgeModel.textPosition;
|
|
420
|
+
var updateAnchorPoint = function (node, anchorId, point, updatePoint) {
|
|
421
|
+
var anchor = node === null || node === void 0 ? void 0 : node.anchors.find(function (anchor) { return anchor.id === anchorId; });
|
|
422
|
+
if (anchor && !isEqual(anchor, point)) {
|
|
423
|
+
updatePoint(anchor);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
var sourceNode = _this.getNodeModelById(sourceNodeId);
|
|
427
|
+
var targetNode = _this.getNodeModelById(targetNodeId);
|
|
428
|
+
updateAnchorPoint(sourceNode, sourceAnchorId, startPoint, edgeModel.updateStartPoint.bind(edgeModel));
|
|
429
|
+
updateAnchorPoint(targetNode, targetAnchorId, endPoint, edgeModel.updateEndPoint.bind(edgeModel));
|
|
430
|
+
// 而文本需要先算一下文本与默认文本位置之间的相对位置差
|
|
431
|
+
// 再计算新路径的文本默认位置,加上相对位置差,得到调整后边的文本的位置
|
|
432
|
+
if (text) {
|
|
433
|
+
var x = text.x, y = text.y;
|
|
434
|
+
var defaultX = textPosition.x, defaultY = textPosition.y;
|
|
435
|
+
if (x && y && defaultX && defaultY) {
|
|
436
|
+
var deltaX = x - defaultX;
|
|
437
|
+
var deltaY = y - defaultY;
|
|
438
|
+
edgeModel.resetTextPosition();
|
|
439
|
+
edgeModel.moveText(deltaX, deltaY);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
378
442
|
_this.edgeModelMap.set(edgeModel.id, edgeModel);
|
|
379
443
|
_this.elementsModelMap.set(edgeModel.id, edgeModel);
|
|
380
444
|
return edgeModel;
|
|
@@ -666,11 +730,15 @@ var GraphModel = /** @class */ (function () {
|
|
|
666
730
|
* @param {string} nodeId 节点Id
|
|
667
731
|
*/
|
|
668
732
|
GraphModel.prototype.deleteNode = function (nodeId) {
|
|
669
|
-
var
|
|
733
|
+
var nodeModel = this.nodesMap[nodeId].model;
|
|
734
|
+
var nodeData = nodeModel.getData();
|
|
670
735
|
this.deleteEdgeBySource(nodeId);
|
|
671
736
|
this.deleteEdgeByTarget(nodeId);
|
|
672
737
|
this.nodes.splice(this.nodesMap[nodeId].index, 1);
|
|
673
|
-
this.eventCenter.emit(EventType.NODE_DELETE, {
|
|
738
|
+
this.eventCenter.emit(EventType.NODE_DELETE, {
|
|
739
|
+
data: nodeData,
|
|
740
|
+
model: nodeModel,
|
|
741
|
+
});
|
|
674
742
|
};
|
|
675
743
|
/**
|
|
676
744
|
* 添加节点
|
|
@@ -1250,10 +1318,7 @@ var GraphModel = /** @class */ (function () {
|
|
|
1250
1318
|
* 更新网格配置
|
|
1251
1319
|
*/
|
|
1252
1320
|
GraphModel.prototype.updateBackgroundOptions = function (options) {
|
|
1253
|
-
if (
|
|
1254
|
-
this.background = options;
|
|
1255
|
-
}
|
|
1256
|
-
else if (typeof this.background === 'boolean') {
|
|
1321
|
+
if (isBoolean(options) || isBoolean(this.background)) {
|
|
1257
1322
|
this.background = options;
|
|
1258
1323
|
}
|
|
1259
1324
|
else {
|
|
@@ -1381,6 +1446,18 @@ var GraphModel = /** @class */ (function () {
|
|
|
1381
1446
|
GraphModel.prototype.setPartial = function (partial) {
|
|
1382
1447
|
this.partial = partial;
|
|
1383
1448
|
};
|
|
1449
|
+
/** 销毁当前实例 */
|
|
1450
|
+
GraphModel.prototype.destroy = function () {
|
|
1451
|
+
try {
|
|
1452
|
+
this.waitCleanEffects.forEach(function (fn) {
|
|
1453
|
+
fn();
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
catch (err) {
|
|
1457
|
+
console.warn('error on destroy GraphModel', err);
|
|
1458
|
+
}
|
|
1459
|
+
this.waitCleanEffects.length = 0;
|
|
1460
|
+
};
|
|
1384
1461
|
__decorate([
|
|
1385
1462
|
observable
|
|
1386
1463
|
], GraphModel.prototype, "width", void 0);
|
|
@@ -16,6 +16,8 @@ export declare class LineEdgeModel extends BaseEdgeModel {
|
|
|
16
16
|
height?: number | undefined;
|
|
17
17
|
path?: string | undefined;
|
|
18
18
|
};
|
|
19
|
+
initEdgeData(data: LogicFlow.EdgeConfig): void;
|
|
20
|
+
getPath(points: Point[]): string;
|
|
19
21
|
getTextPosition(): Point;
|
|
20
22
|
}
|
|
21
23
|
export default LineEdgeModel;
|
|
@@ -65,6 +65,14 @@ var LineEdgeModel = /** @class */ (function (_super) {
|
|
|
65
65
|
var _a = this.properties.style, customStyle = _a === void 0 ? {} : _a;
|
|
66
66
|
return __assign(__assign(__assign({}, style), cloneDeep(line)), cloneDeep(customStyle));
|
|
67
67
|
};
|
|
68
|
+
LineEdgeModel.prototype.initEdgeData = function (data) {
|
|
69
|
+
_super.prototype.initEdgeData.call(this, data);
|
|
70
|
+
this.points = this.getPath([this.startPoint, this.endPoint]);
|
|
71
|
+
};
|
|
72
|
+
LineEdgeModel.prototype.getPath = function (points) {
|
|
73
|
+
var _a = __read(points, 2), start = _a[0], end = _a[1];
|
|
74
|
+
return "".concat(start.x, ",").concat(start.y, " ").concat(end.x, ",").concat(end.y);
|
|
75
|
+
};
|
|
68
76
|
LineEdgeModel.prototype.getTextPosition = function () {
|
|
69
77
|
return {
|
|
70
78
|
x: (this.startPoint.x + this.endPoint.x) / 2,
|
|
@@ -295,11 +295,12 @@ var PolylineEdgeModel = /** @class */ (function (_super) {
|
|
|
295
295
|
pointsList: pointsList,
|
|
296
296
|
});
|
|
297
297
|
};
|
|
298
|
+
PolylineEdgeModel.prototype.getPath = function (points) {
|
|
299
|
+
return points.map(function (point) { return "".concat(point.x, ",").concat(point.y); }).join(' ');
|
|
300
|
+
};
|
|
298
301
|
PolylineEdgeModel.prototype.initPoints = function () {
|
|
299
302
|
if (this.pointsList.length > 0) {
|
|
300
|
-
this.points = this.pointsList
|
|
301
|
-
.map(function (point) { return "".concat(point.x, ",").concat(point.y); })
|
|
302
|
-
.join(' ');
|
|
303
|
+
this.points = this.getPath(this.pointsList);
|
|
303
304
|
}
|
|
304
305
|
else {
|
|
305
306
|
this.updatePoints();
|
|
@@ -4,13 +4,13 @@ import { ModelType } from '../../constant';
|
|
|
4
4
|
import AnchorConfig = Model.AnchorConfig;
|
|
5
5
|
import LogicFlow from '../../LogicFlow';
|
|
6
6
|
import GraphModel from '../GraphModel';
|
|
7
|
-
export
|
|
7
|
+
export interface IHtmlNodeProperties {
|
|
8
8
|
width?: number;
|
|
9
9
|
height?: number;
|
|
10
10
|
style?: LogicFlow.CommonTheme;
|
|
11
11
|
textStyle?: LogicFlow.CommonTheme;
|
|
12
12
|
[key: string]: unknown;
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
14
|
export declare class HtmlNodeModel<P extends IHtmlNodeProperties = IHtmlNodeProperties> extends BaseNodeModel<P> {
|
|
15
15
|
modelType: ModelType;
|
|
16
16
|
constructor(data: LogicFlow.NodeConfig<P>, graphModel: GraphModel);
|
package/es/style/index.css
CHANGED
package/es/style/index.less
CHANGED
package/es/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.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 #187dffcc;\n box-shadow: 0 0 3px 0 #187dff80;\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";
|
|
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 #187dffcc;\n box-shadow: 0 0 3px 0 #187dff80;\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/es/style/raw.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Auto generated file, do not modify it!
|
|
4
4
|
*/
|
|
5
|
-
export var 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.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 #187dffcc;\n box-shadow: 0 0 3px 0 #187dff80;\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";
|
|
5
|
+
export var 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 #187dffcc;\n box-shadow: 0 0 3px 0 #187dff80;\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";
|
|
@@ -133,6 +133,8 @@ export declare abstract class BaseEdge<P extends IProps> extends Component<P, IE
|
|
|
133
133
|
* 不支持重写
|
|
134
134
|
*/
|
|
135
135
|
handleClick: (e: MouseEvent) => void;
|
|
136
|
+
handleFocus: () => void;
|
|
137
|
+
handleBlur: () => void;
|
|
136
138
|
/**
|
|
137
139
|
* @overridable 支持重写, 此方法为获取边的形状,如果需要自定义边的形状,请重写此方法。
|
|
138
140
|
* @example https://docs.logic-flow.cn/docs/#/zh/guide/basic/edge?id=%e5%9f%ba%e4%ba%8e-react-%e7%bb%84%e4%bb%b6%e8%87%aa%e5%ae%9a%e4%b9%89%e8%be%b9
|
package/es/view/edge/BaseEdge.js
CHANGED
|
@@ -194,6 +194,18 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
194
194
|
graphModel.selectEdgeById(model.id, isMultipleSelect(e, editConfigModel));
|
|
195
195
|
_this.toFront();
|
|
196
196
|
};
|
|
197
|
+
_this.handleFocus = function () {
|
|
198
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
199
|
+
graphModel.eventCenter.emit(EventType.EDGE_FOCUS, {
|
|
200
|
+
data: model.getData(),
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
_this.handleBlur = function () {
|
|
204
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
205
|
+
graphModel.eventCenter.emit(EventType.EDGE_BLUR, {
|
|
206
|
+
data: model.getData(),
|
|
207
|
+
});
|
|
208
|
+
};
|
|
197
209
|
return _this;
|
|
198
210
|
}
|
|
199
211
|
/**
|
|
@@ -382,7 +394,7 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
382
394
|
isSelected && 'lf-edge-selected',
|
|
383
395
|
]
|
|
384
396
|
.filter(Boolean)
|
|
385
|
-
.join(' '), onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, onClick: this.handleClick, onContextMenu: this.handleContextMenu, onMouseOver: this.setHoverOn, onMouseEnter: this.setHoverOn, onMouseLeave: this.setHoverOff, children: [this.getShape(), this.getAppend(), this.getText(), this.getArrow()] }), isShowAdjustPoint && isSelected ? this.getAdjustPoints() : ''] }));
|
|
397
|
+
.join(' '), onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, onClick: this.handleClick, onContextMenu: this.handleContextMenu, onMouseOver: this.setHoverOn, onMouseEnter: this.setHoverOn, onMouseLeave: this.setHoverOff, onFocus: this.handleFocus, onBlur: this.handleBlur, children: [this.getShape(), this.getAppend(), this.getText(), this.getArrow()] }), isShowAdjustPoint && isSelected ? this.getAdjustPoints() : ''] }));
|
|
386
398
|
};
|
|
387
399
|
BaseEdge.isObserved = false;
|
|
388
400
|
return BaseEdge;
|
|
@@ -38,6 +38,8 @@ export declare abstract class BaseNode<P extends IProps = IProps> extends Compon
|
|
|
38
38
|
handleClick: (e: MouseEvent) => void;
|
|
39
39
|
handleContextMenu: (ev: MouseEvent) => void;
|
|
40
40
|
handleMouseDown: (ev: MouseEvent) => void;
|
|
41
|
+
handleFocus: () => void;
|
|
42
|
+
handleBlur: () => void;
|
|
41
43
|
setHoverOn: (ev: MouseEvent) => void;
|
|
42
44
|
setHoverOff: (ev: MouseEvent) => void;
|
|
43
45
|
/**
|
package/es/view/node/BaseNode.js
CHANGED
|
@@ -218,7 +218,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
218
218
|
// 不是双击的,默认都是单击
|
|
219
219
|
if (isDoubleClick) {
|
|
220
220
|
if (editConfigModel.nodeTextEdit) {
|
|
221
|
-
if (model.text.editable) {
|
|
221
|
+
if (model.text.editable && editConfigModel.textMode === TextMode.TEXT) {
|
|
222
222
|
model.setSelected(false);
|
|
223
223
|
graphModel.setElementStateById(model.id, ElementState.TEXT_EDIT);
|
|
224
224
|
}
|
|
@@ -258,6 +258,18 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
258
258
|
_this.stepDrag && _this.stepDrag.handleMouseDown(ev);
|
|
259
259
|
}
|
|
260
260
|
};
|
|
261
|
+
_this.handleFocus = function () {
|
|
262
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
263
|
+
graphModel.eventCenter.emit(EventType.NODE_FOCUS, {
|
|
264
|
+
data: model.getData(),
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
_this.handleBlur = function () {
|
|
268
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
269
|
+
graphModel.eventCenter.emit(EventType.NODE_BLUR, {
|
|
270
|
+
data: model.getData(),
|
|
271
|
+
});
|
|
272
|
+
};
|
|
261
273
|
// 因为自定义节点的时候,可能会基于hover状态自定义不同的样式。
|
|
262
274
|
_this.setHoverOn = function (ev) {
|
|
263
275
|
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
@@ -417,7 +429,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
417
429
|
if (adjustNodePosition && draggable) {
|
|
418
430
|
this.stepDrag.setStep(gridSize * SCALE_X);
|
|
419
431
|
}
|
|
420
|
-
nodeShape = (_jsx("g", __assign({ className: "".concat(this.getStateClassName(), " ").concat(className), onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, onClick: this.handleClick, onMouseEnter: this.setHoverOn, onMouseOver: this.setHoverOn, onMouseLeave: this.setHoverOff, onMouseOut: this.onMouseOut, onContextMenu: this.handleContextMenu }, restAttributes, { children: nodeShapeInner })));
|
|
432
|
+
nodeShape = (_jsx("g", __assign({ className: "".concat(this.getStateClassName(), " ").concat(className), onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, onClick: this.handleClick, onMouseEnter: this.setHoverOn, onMouseOver: this.setHoverOn, onMouseLeave: this.setHoverOff, onMouseOut: this.onMouseOut, onContextMenu: this.handleContextMenu, onFocus: this.handleFocus, onBlur: this.handleBlur }, restAttributes, { children: nodeShapeInner })));
|
|
421
433
|
}
|
|
422
434
|
return nodeShape;
|
|
423
435
|
};
|
|
@@ -21,6 +21,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
21
21
|
};
|
|
22
22
|
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
23
23
|
import { Component } from 'preact/compat';
|
|
24
|
+
import { isObject } from 'lodash-es';
|
|
24
25
|
import { observer } from '../..';
|
|
25
26
|
var BackgroundOverlay = /** @class */ (function (_super) {
|
|
26
27
|
__extends(BackgroundOverlay, _super);
|
|
@@ -29,7 +30,7 @@ var BackgroundOverlay = /** @class */ (function (_super) {
|
|
|
29
30
|
}
|
|
30
31
|
BackgroundOverlay.prototype.render = function () {
|
|
31
32
|
var background = this.props.background;
|
|
32
|
-
return (_jsx("div", { className: "lf-background", children: _jsx("div", { style:
|
|
33
|
+
return (_jsx("div", { className: "lf-background", children: _jsx("div", { style: isObject(background) ? background : {}, className: "lf-background-area" }) }));
|
|
33
34
|
};
|
|
34
35
|
BackgroundOverlay = __decorate([
|
|
35
36
|
observer
|
package/lib/LogicFlow.d.ts
CHANGED
|
@@ -568,6 +568,8 @@ export declare class LogicFlow {
|
|
|
568
568
|
* 加载插件-内部方法
|
|
569
569
|
*/
|
|
570
570
|
private installPlugin;
|
|
571
|
+
/** 销毁当前实例 */
|
|
572
|
+
destroy(): void;
|
|
571
573
|
}
|
|
572
574
|
export declare namespace LogicFlow {
|
|
573
575
|
/**
|
|
@@ -638,6 +640,7 @@ export declare namespace LogicFlow {
|
|
|
638
640
|
};
|
|
639
641
|
type LabelConfig = {
|
|
640
642
|
id?: string;
|
|
643
|
+
type?: string;
|
|
641
644
|
x: number;
|
|
642
645
|
y: number;
|
|
643
646
|
content?: string;
|
package/lib/LogicFlow.js
CHANGED
|
@@ -1195,6 +1195,10 @@ var LogicFlow = /** @class */ (function () {
|
|
|
1195
1195
|
this.components.push(extensionIns.render.bind(extensionIns));
|
|
1196
1196
|
this.extension[pluginName] = extensionIns;
|
|
1197
1197
|
};
|
|
1198
|
+
/** 销毁当前实例 */
|
|
1199
|
+
LogicFlow.prototype.destroy = function () {
|
|
1200
|
+
this.graphModel.destroy();
|
|
1201
|
+
};
|
|
1198
1202
|
// 全局配置的插件,所有的LogicFlow示例都会使用
|
|
1199
1203
|
LogicFlow.extensions = new Map();
|
|
1200
1204
|
return LogicFlow;
|
package/lib/algorithm/edge.js
CHANGED
|
@@ -52,10 +52,8 @@ var isInSegment = function (point, start, end) {
|
|
|
52
52
|
var endX = end.x, endY = end.y;
|
|
53
53
|
var k = (endY - startY) / (endX - startX);
|
|
54
54
|
var b = startY - k * startX;
|
|
55
|
-
return (x >= startX &&
|
|
56
|
-
|
|
57
|
-
y
|
|
58
|
-
y <= endY &&
|
|
59
|
-
Math.abs(y - k * x + b) < Number.EPSILON);
|
|
55
|
+
return (((x >= startX && x <= endX) || (x <= startX && x >= endX)) &&
|
|
56
|
+
((y >= startY && y <= endY) || (y <= startY && y >= endY)) &&
|
|
57
|
+
Math.abs(y - k * x - b) < Number.EPSILON);
|
|
60
58
|
};
|
|
61
59
|
exports.isInSegment = isInSegment;
|
package/lib/constant/index.d.ts
CHANGED
|
@@ -49,12 +49,16 @@ export declare enum EventType {
|
|
|
49
49
|
NODE_CONTEXTMENU = "node:contextmenu",
|
|
50
50
|
NODE_ROTATE = "node:rotate",
|
|
51
51
|
NODE_RESIZE = "node:resize",
|
|
52
|
+
NODE_FOCUS = "node:focus",
|
|
53
|
+
NODE_BLUR = "node:blur",
|
|
52
54
|
NODE_PROPERTIES_CHANGE = "node:properties-change",
|
|
53
55
|
NODE_PROPERTIES_DELETE = "node:properties-delete",
|
|
54
56
|
EDGE_ADD = "edge:add",
|
|
55
57
|
EDGE_DELETE = "edge:delete",
|
|
56
58
|
EDGE_CLICK = "edge:click",
|
|
57
59
|
EDGE_DBCLICK = "edge:dbclick",
|
|
60
|
+
EDGE_FOCUS = "edge:focus",
|
|
61
|
+
EDGE_BLUR = "edge:blur",
|
|
58
62
|
EDGE_MOUSEENTER = "edge:mouseenter",
|
|
59
63
|
EDGE_MOUSELEAVE = "edge:mouseleave",
|
|
60
64
|
EDGE_CONTEXTMENU = "edge:contextmenu",
|
package/lib/constant/index.js
CHANGED
|
@@ -57,6 +57,8 @@ var EventType;
|
|
|
57
57
|
EventType["NODE_CONTEXTMENU"] = "node:contextmenu";
|
|
58
58
|
EventType["NODE_ROTATE"] = "node:rotate";
|
|
59
59
|
EventType["NODE_RESIZE"] = "node:resize";
|
|
60
|
+
EventType["NODE_FOCUS"] = "node:focus";
|
|
61
|
+
EventType["NODE_BLUR"] = "node:blur";
|
|
60
62
|
// 节点 properties 变化事件
|
|
61
63
|
EventType["NODE_PROPERTIES_CHANGE"] = "node:properties-change";
|
|
62
64
|
EventType["NODE_PROPERTIES_DELETE"] = "node:properties-delete";
|
|
@@ -65,6 +67,8 @@ var EventType;
|
|
|
65
67
|
EventType["EDGE_DELETE"] = "edge:delete";
|
|
66
68
|
EventType["EDGE_CLICK"] = "edge:click";
|
|
67
69
|
EventType["EDGE_DBCLICK"] = "edge:dbclick";
|
|
70
|
+
EventType["EDGE_FOCUS"] = "edge:focus";
|
|
71
|
+
EventType["EDGE_BLUR"] = "edge:blur";
|
|
68
72
|
EventType["EDGE_MOUSEENTER"] = "edge:mouseenter";
|
|
69
73
|
EventType["EDGE_MOUSELEAVE"] = "edge:mouseleave";
|
|
70
74
|
EventType["EDGE_CONTEXTMENU"] = "edge:contextmenu";
|