@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/lib/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/lib/index.css
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/lib/model/GraphModel.js
CHANGED
|
@@ -16,6 +16,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
16
16
|
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;
|
|
17
17
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
18
|
};
|
|
19
|
+
var __values = (this && this.__values) || function(o) {
|
|
20
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
21
|
+
if (m) return m.call(o);
|
|
22
|
+
if (o && typeof o.length === "number") return {
|
|
23
|
+
next: function () {
|
|
24
|
+
if (o && i >= o.length) o = void 0;
|
|
25
|
+
return { value: o && o[i++], done: !o };
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
29
|
+
};
|
|
19
30
|
var __read = (this && this.__read) || function (o, n) {
|
|
20
31
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
21
32
|
if (!m) return o;
|
|
@@ -55,6 +66,7 @@ var eventEmitter_1 = __importDefault(require("../event/eventEmitter"));
|
|
|
55
66
|
var overlay_1 = require("../view/overlay");
|
|
56
67
|
var GraphModel = /** @class */ (function () {
|
|
57
68
|
function GraphModel(options) {
|
|
69
|
+
var _this = this;
|
|
58
70
|
// 维护所有节点和边类型对应的 model
|
|
59
71
|
this.modelMap = new Map();
|
|
60
72
|
// Remind:用于记录当前画布上所有节点和边的 model 的 Map
|
|
@@ -87,6 +99,7 @@ var GraphModel = /** @class */ (function () {
|
|
|
87
99
|
this.gridSize = 1;
|
|
88
100
|
// 控制是否开启局部渲染
|
|
89
101
|
this.partial = false;
|
|
102
|
+
this.waitCleanEffects = [];
|
|
90
103
|
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;
|
|
91
104
|
this.rootEl = container;
|
|
92
105
|
this.partial = !!partial;
|
|
@@ -101,6 +114,32 @@ var GraphModel = /** @class */ (function () {
|
|
|
101
114
|
this.overlapMode = options.overlapMode || constant_1.OverlapMode.DEFAULT;
|
|
102
115
|
this.width = options.width || this.rootEl.getBoundingClientRect().width;
|
|
103
116
|
this.height = options.height || this.rootEl.getBoundingClientRect().height;
|
|
117
|
+
var resizeObserver = new ResizeObserver((0, lodash_es_1.debounce)((function (entries) {
|
|
118
|
+
var e_1, _a;
|
|
119
|
+
try {
|
|
120
|
+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
121
|
+
var entry = entries_1_1.value;
|
|
122
|
+
if (entry.target === _this.rootEl) {
|
|
123
|
+
_this.resize();
|
|
124
|
+
_this.eventCenter.emit('graph:resize', {
|
|
125
|
+
target: _this.rootEl,
|
|
126
|
+
contentRect: entry.contentRect,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
132
|
+
finally {
|
|
133
|
+
try {
|
|
134
|
+
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
|
135
|
+
}
|
|
136
|
+
finally { if (e_1) throw e_1.error; }
|
|
137
|
+
}
|
|
138
|
+
}), 16));
|
|
139
|
+
resizeObserver.observe(this.rootEl);
|
|
140
|
+
this.waitCleanEffects.push(function () {
|
|
141
|
+
resizeObserver.disconnect();
|
|
142
|
+
});
|
|
104
143
|
this.eventCenter = new eventEmitter_1.default();
|
|
105
144
|
this.editConfigModel = new _1.EditConfigModel(options);
|
|
106
145
|
this.transformModel = new _1.TransformModel(this.eventCenter, options);
|
|
@@ -381,6 +420,31 @@ var GraphModel = /** @class */ (function () {
|
|
|
381
420
|
throw new Error("\u627E\u4E0D\u5230".concat(edge.type, "\u5BF9\u5E94\u7684\u8FB9\u3002"));
|
|
382
421
|
}
|
|
383
422
|
var edgeModel = new Model(edge, _this);
|
|
423
|
+
// 根据edgeModel中存储的数据找到当前画布上的起终锚点坐标
|
|
424
|
+
// 判断当前起终锚点数据和Model中存储的起终点数据是否一致,不一致更新起终点信息
|
|
425
|
+
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;
|
|
426
|
+
var updateAnchorPoint = function (node, anchorId, point, updatePoint) {
|
|
427
|
+
var anchor = node === null || node === void 0 ? void 0 : node.anchors.find(function (anchor) { return anchor.id === anchorId; });
|
|
428
|
+
if (anchor && !(0, lodash_es_1.isEqual)(anchor, point)) {
|
|
429
|
+
updatePoint(anchor);
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
var sourceNode = _this.getNodeModelById(sourceNodeId);
|
|
433
|
+
var targetNode = _this.getNodeModelById(targetNodeId);
|
|
434
|
+
updateAnchorPoint(sourceNode, sourceAnchorId, startPoint, edgeModel.updateStartPoint.bind(edgeModel));
|
|
435
|
+
updateAnchorPoint(targetNode, targetAnchorId, endPoint, edgeModel.updateEndPoint.bind(edgeModel));
|
|
436
|
+
// 而文本需要先算一下文本与默认文本位置之间的相对位置差
|
|
437
|
+
// 再计算新路径的文本默认位置,加上相对位置差,得到调整后边的文本的位置
|
|
438
|
+
if (text) {
|
|
439
|
+
var x = text.x, y = text.y;
|
|
440
|
+
var defaultX = textPosition.x, defaultY = textPosition.y;
|
|
441
|
+
if (x && y && defaultX && defaultY) {
|
|
442
|
+
var deltaX = x - defaultX;
|
|
443
|
+
var deltaY = y - defaultY;
|
|
444
|
+
edgeModel.resetTextPosition();
|
|
445
|
+
edgeModel.moveText(deltaX, deltaY);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
384
448
|
_this.edgeModelMap.set(edgeModel.id, edgeModel);
|
|
385
449
|
_this.elementsModelMap.set(edgeModel.id, edgeModel);
|
|
386
450
|
return edgeModel;
|
|
@@ -672,11 +736,15 @@ var GraphModel = /** @class */ (function () {
|
|
|
672
736
|
* @param {string} nodeId 节点Id
|
|
673
737
|
*/
|
|
674
738
|
GraphModel.prototype.deleteNode = function (nodeId) {
|
|
675
|
-
var
|
|
739
|
+
var nodeModel = this.nodesMap[nodeId].model;
|
|
740
|
+
var nodeData = nodeModel.getData();
|
|
676
741
|
this.deleteEdgeBySource(nodeId);
|
|
677
742
|
this.deleteEdgeByTarget(nodeId);
|
|
678
743
|
this.nodes.splice(this.nodesMap[nodeId].index, 1);
|
|
679
|
-
this.eventCenter.emit(constant_1.EventType.NODE_DELETE, {
|
|
744
|
+
this.eventCenter.emit(constant_1.EventType.NODE_DELETE, {
|
|
745
|
+
data: nodeData,
|
|
746
|
+
model: nodeModel,
|
|
747
|
+
});
|
|
680
748
|
};
|
|
681
749
|
/**
|
|
682
750
|
* 添加节点
|
|
@@ -1256,10 +1324,7 @@ var GraphModel = /** @class */ (function () {
|
|
|
1256
1324
|
* 更新网格配置
|
|
1257
1325
|
*/
|
|
1258
1326
|
GraphModel.prototype.updateBackgroundOptions = function (options) {
|
|
1259
|
-
if (
|
|
1260
|
-
this.background = options;
|
|
1261
|
-
}
|
|
1262
|
-
else if (typeof this.background === 'boolean') {
|
|
1327
|
+
if ((0, lodash_es_1.isBoolean)(options) || (0, lodash_es_1.isBoolean)(this.background)) {
|
|
1263
1328
|
this.background = options;
|
|
1264
1329
|
}
|
|
1265
1330
|
else {
|
|
@@ -1387,6 +1452,18 @@ var GraphModel = /** @class */ (function () {
|
|
|
1387
1452
|
GraphModel.prototype.setPartial = function (partial) {
|
|
1388
1453
|
this.partial = partial;
|
|
1389
1454
|
};
|
|
1455
|
+
/** 销毁当前实例 */
|
|
1456
|
+
GraphModel.prototype.destroy = function () {
|
|
1457
|
+
try {
|
|
1458
|
+
this.waitCleanEffects.forEach(function (fn) {
|
|
1459
|
+
fn();
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
catch (err) {
|
|
1463
|
+
console.warn('error on destroy GraphModel', err);
|
|
1464
|
+
}
|
|
1465
|
+
this.waitCleanEffects.length = 0;
|
|
1466
|
+
};
|
|
1390
1467
|
__decorate([
|
|
1391
1468
|
mobx_1.observable
|
|
1392
1469
|
], 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;
|
|
@@ -71,6 +71,14 @@ var LineEdgeModel = /** @class */ (function (_super) {
|
|
|
71
71
|
var _a = this.properties.style, customStyle = _a === void 0 ? {} : _a;
|
|
72
72
|
return __assign(__assign(__assign({}, style), (0, lodash_es_1.cloneDeep)(line)), (0, lodash_es_1.cloneDeep)(customStyle));
|
|
73
73
|
};
|
|
74
|
+
LineEdgeModel.prototype.initEdgeData = function (data) {
|
|
75
|
+
_super.prototype.initEdgeData.call(this, data);
|
|
76
|
+
this.points = this.getPath([this.startPoint, this.endPoint]);
|
|
77
|
+
};
|
|
78
|
+
LineEdgeModel.prototype.getPath = function (points) {
|
|
79
|
+
var _a = __read(points, 2), start = _a[0], end = _a[1];
|
|
80
|
+
return "".concat(start.x, ",").concat(start.y, " ").concat(end.x, ",").concat(end.y);
|
|
81
|
+
};
|
|
74
82
|
LineEdgeModel.prototype.getTextPosition = function () {
|
|
75
83
|
return {
|
|
76
84
|
x: (this.startPoint.x + this.endPoint.x) / 2,
|
|
@@ -298,11 +298,12 @@ var PolylineEdgeModel = /** @class */ (function (_super) {
|
|
|
298
298
|
pointsList: pointsList,
|
|
299
299
|
});
|
|
300
300
|
};
|
|
301
|
+
PolylineEdgeModel.prototype.getPath = function (points) {
|
|
302
|
+
return points.map(function (point) { return "".concat(point.x, ",").concat(point.y); }).join(' ');
|
|
303
|
+
};
|
|
301
304
|
PolylineEdgeModel.prototype.initPoints = function () {
|
|
302
305
|
if (this.pointsList.length > 0) {
|
|
303
|
-
this.points = this.pointsList
|
|
304
|
-
.map(function (point) { return "".concat(point.x, ",").concat(point.y); })
|
|
305
|
-
.join(' ');
|
|
306
|
+
this.points = this.getPath(this.pointsList);
|
|
306
307
|
}
|
|
307
308
|
else {
|
|
308
309
|
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/lib/style/index.css
CHANGED
package/lib/style/index.less
CHANGED
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.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/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.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";
|
|
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 #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
|
|
@@ -220,6 +220,18 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
220
220
|
graphModel.selectEdgeById(model.id, (0, util_1.isMultipleSelect)(e, editConfigModel));
|
|
221
221
|
_this.toFront();
|
|
222
222
|
};
|
|
223
|
+
_this.handleFocus = function () {
|
|
224
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
225
|
+
graphModel.eventCenter.emit(constant_1.EventType.EDGE_FOCUS, {
|
|
226
|
+
data: model.getData(),
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
_this.handleBlur = function () {
|
|
230
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
231
|
+
graphModel.eventCenter.emit(constant_1.EventType.EDGE_BLUR, {
|
|
232
|
+
data: model.getData(),
|
|
233
|
+
});
|
|
234
|
+
};
|
|
223
235
|
return _this;
|
|
224
236
|
}
|
|
225
237
|
/**
|
|
@@ -408,7 +420,7 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
408
420
|
isSelected && 'lf-edge-selected',
|
|
409
421
|
]
|
|
410
422
|
.filter(Boolean)
|
|
411
|
-
.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() : ''] }));
|
|
423
|
+
.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() : ''] }));
|
|
412
424
|
};
|
|
413
425
|
BaseEdge.isObserved = false;
|
|
414
426
|
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
|
/**
|
|
@@ -222,7 +222,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
222
222
|
// 不是双击的,默认都是单击
|
|
223
223
|
if (isDoubleClick) {
|
|
224
224
|
if (editConfigModel.nodeTextEdit) {
|
|
225
|
-
if (model.text.editable) {
|
|
225
|
+
if (model.text.editable && editConfigModel.textMode === constant_1.TextMode.TEXT) {
|
|
226
226
|
model.setSelected(false);
|
|
227
227
|
graphModel.setElementStateById(model.id, constant_1.ElementState.TEXT_EDIT);
|
|
228
228
|
}
|
|
@@ -262,6 +262,18 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
262
262
|
_this.stepDrag && _this.stepDrag.handleMouseDown(ev);
|
|
263
263
|
}
|
|
264
264
|
};
|
|
265
|
+
_this.handleFocus = function () {
|
|
266
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
267
|
+
graphModel.eventCenter.emit(constant_1.EventType.NODE_FOCUS, {
|
|
268
|
+
data: model.getData(),
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
_this.handleBlur = function () {
|
|
272
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
273
|
+
graphModel.eventCenter.emit(constant_1.EventType.NODE_BLUR, {
|
|
274
|
+
data: model.getData(),
|
|
275
|
+
});
|
|
276
|
+
};
|
|
265
277
|
// 因为自定义节点的时候,可能会基于hover状态自定义不同的样式。
|
|
266
278
|
_this.setHoverOn = function (ev) {
|
|
267
279
|
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
@@ -421,7 +433,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
421
433
|
if (adjustNodePosition && draggable) {
|
|
422
434
|
this.stepDrag.setStep(gridSize * SCALE_X);
|
|
423
435
|
}
|
|
424
|
-
nodeShape = ((0, jsx_runtime_1.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 })));
|
|
436
|
+
nodeShape = ((0, jsx_runtime_1.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 })));
|
|
425
437
|
}
|
|
426
438
|
return nodeShape;
|
|
427
439
|
};
|
|
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
exports.BackgroundOverlay = void 0;
|
|
25
25
|
var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
26
26
|
var compat_1 = require("preact/compat");
|
|
27
|
+
var lodash_es_1 = require("lodash-es");
|
|
27
28
|
var __1 = require("../..");
|
|
28
29
|
var BackgroundOverlay = /** @class */ (function (_super) {
|
|
29
30
|
__extends(BackgroundOverlay, _super);
|
|
@@ -32,7 +33,7 @@ var BackgroundOverlay = /** @class */ (function (_super) {
|
|
|
32
33
|
}
|
|
33
34
|
BackgroundOverlay.prototype.render = function () {
|
|
34
35
|
var background = this.props.background;
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "lf-background", children: (0, jsx_runtime_1.jsx)("div", { style:
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "lf-background", children: (0, jsx_runtime_1.jsx)("div", { style: (0, lodash_es_1.isObject)(background) ? background : {}, className: "lf-background-area" }) }));
|
|
36
37
|
};
|
|
37
38
|
BackgroundOverlay = __decorate([
|
|
38
39
|
__1.observer
|
package/package.json
CHANGED
package/src/LogicFlow.tsx
CHANGED
|
@@ -1369,6 +1369,11 @@ export class LogicFlow {
|
|
|
1369
1369
|
this.components.push(extensionIns.render.bind(extensionIns))
|
|
1370
1370
|
this.extension[pluginName] = extensionIns
|
|
1371
1371
|
}
|
|
1372
|
+
|
|
1373
|
+
/** 销毁当前实例 */
|
|
1374
|
+
destroy() {
|
|
1375
|
+
this.graphModel.destroy()
|
|
1376
|
+
}
|
|
1372
1377
|
}
|
|
1373
1378
|
|
|
1374
1379
|
// Option
|
|
@@ -1451,6 +1456,7 @@ export namespace LogicFlow {
|
|
|
1451
1456
|
// label数据类型声明
|
|
1452
1457
|
export type LabelConfig = {
|
|
1453
1458
|
id?: string // label唯一标识
|
|
1459
|
+
type?: string
|
|
1454
1460
|
x: number
|
|
1455
1461
|
y: number
|
|
1456
1462
|
content?: string // 富文本内容
|
package/src/algorithm/edge.ts
CHANGED
|
@@ -62,6 +62,6 @@ export const isInSegment = (point: Point, start: Point, end: Point) => {
|
|
|
62
62
|
return (
|
|
63
63
|
((x >= startX && x <= endX) || (x <= startX && x >= endX)) &&
|
|
64
64
|
((y >= startY && y <= endY) || (y <= startY && y >= endY)) &&
|
|
65
|
-
Math.abs(y - k * x
|
|
65
|
+
Math.abs(y - k * x - b) < Number.EPSILON
|
|
66
66
|
)
|
|
67
67
|
}
|
package/src/algorithm/outline.ts
CHANGED
|
@@ -66,7 +66,7 @@ export const getEdgeOutline = (
|
|
|
66
66
|
edge: BaseEdgeModel,
|
|
67
67
|
): OutlineInfo | undefined => {
|
|
68
68
|
if (edge.modelType === ModelType.LINE_EDGE) {
|
|
69
|
-
return getLineOutline(edge)
|
|
69
|
+
return getLineOutline(edge as LineEdgeModel)
|
|
70
70
|
}
|
|
71
71
|
if (edge.modelType === ModelType.POLYLINE_EDGE) {
|
|
72
72
|
return getPolylineOutline(edge as PolylineEdgeModel)
|
package/src/constant/index.ts
CHANGED
|
@@ -57,6 +57,8 @@ export enum EventType {
|
|
|
57
57
|
NODE_CONTEXTMENU = 'node:contextmenu',
|
|
58
58
|
NODE_ROTATE = 'node:rotate',
|
|
59
59
|
NODE_RESIZE = 'node:resize',
|
|
60
|
+
NODE_FOCUS = 'node:focus',
|
|
61
|
+
NODE_BLUR = 'node:blur',
|
|
60
62
|
|
|
61
63
|
// 节点 properties 变化事件
|
|
62
64
|
NODE_PROPERTIES_CHANGE = 'node:properties-change',
|
|
@@ -67,6 +69,8 @@ export enum EventType {
|
|
|
67
69
|
EDGE_DELETE = 'edge:delete',
|
|
68
70
|
EDGE_CLICK = 'edge:click',
|
|
69
71
|
EDGE_DBCLICK = 'edge:dbclick',
|
|
72
|
+
EDGE_FOCUS = 'edge:focus',
|
|
73
|
+
EDGE_BLUR = 'edge:blur',
|
|
70
74
|
|
|
71
75
|
EDGE_MOUSEENTER = 'edge:mouseenter',
|
|
72
76
|
EDGE_MOUSELEAVE = 'edge:mouseleave',
|
package/src/event/eventArgs.ts
CHANGED
|
@@ -132,7 +132,7 @@ interface NodeEventArgs {
|
|
|
132
132
|
/**
|
|
133
133
|
* 删除节点
|
|
134
134
|
*/
|
|
135
|
-
'node:delete': NodeEventArgsPick<'data'>
|
|
135
|
+
'node:delete': NodeEventArgsPick<'data' | 'model'>
|
|
136
136
|
/**
|
|
137
137
|
* 添加外部拖入节点
|
|
138
138
|
*/
|
|
@@ -188,6 +188,14 @@ interface NodeEventArgs {
|
|
|
188
188
|
*/
|
|
189
189
|
properties: Record<string, any>
|
|
190
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* 节点获焦
|
|
193
|
+
*/
|
|
194
|
+
'node:focus': NodeEventArgsPick<'data'>
|
|
195
|
+
/**
|
|
196
|
+
* 节点失焦
|
|
197
|
+
*/
|
|
198
|
+
'node:blur': NodeEventArgsPick<'data'>
|
|
191
199
|
}
|
|
192
200
|
|
|
193
201
|
type EdgeEventArgsPick<T extends 'data' | 'e' | 'position'> = Pick<
|
|
@@ -259,6 +267,14 @@ interface EdgeEventArgs {
|
|
|
259
267
|
oldEdge: EdgeData
|
|
260
268
|
}
|
|
261
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* 边获焦
|
|
272
|
+
*/
|
|
273
|
+
'edge:focus': EdgeEventArgsPick<'data'>
|
|
274
|
+
/**
|
|
275
|
+
* 边失焦
|
|
276
|
+
*/
|
|
277
|
+
'edge:blur': EdgeEventArgsPick<'data'>
|
|
262
278
|
}
|
|
263
279
|
|
|
264
280
|
/**
|
|
@@ -414,6 +430,16 @@ interface CommonEventArgs {
|
|
|
414
430
|
*/
|
|
415
431
|
data: GraphData
|
|
416
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* 画布容器大小发生变化触发,为了性能考虑对事件做了防抖处理,间隔为16ms
|
|
435
|
+
*/
|
|
436
|
+
'graph:resize': {
|
|
437
|
+
/**
|
|
438
|
+
* 更新后的画布数据
|
|
439
|
+
*/
|
|
440
|
+
target: HTMLElement
|
|
441
|
+
contentRect: DOMRectReadOnly
|
|
442
|
+
}
|
|
417
443
|
}
|
|
418
444
|
|
|
419
445
|
type AnchorEventArgsPick<T extends 'data' | 'e' | 'nodeModel' | 'edgeModel'> =
|