@logicflow/core 2.1.4 → 2.2.0
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 -2
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +6 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/model/EditConfigModel.d.ts +3 -1
- package/es/model/EditConfigModel.js +5 -0
- package/es/model/GraphModel.js +1 -0
- package/es/tool/MultipleSelectTool.d.ts +1 -1
- package/es/tool/MultipleSelectTool.js +1 -1
- package/es/util/drag.d.ts +4 -4
- package/es/util/drag.js +12 -6
- package/es/view/Anchor.d.ts +3 -3
- package/es/view/Anchor.js +30 -4
- package/es/view/Control.js +1 -1
- package/es/view/Rotate.js +1 -1
- package/es/view/behavior/dnd.d.ts +4 -8
- package/es/view/behavior/dnd.js +50 -14
- package/es/view/edge/AdjustPoint.d.ts +1 -1
- package/es/view/edge/AdjustPoint.js +1 -1
- package/es/view/edge/BaseEdge.d.ts +2 -1
- package/es/view/edge/BaseEdge.js +18 -1
- package/es/view/edge/PolylineEdge.d.ts +1 -1
- package/es/view/edge/PolylineEdge.js +1 -1
- package/es/view/node/BaseNode.d.ts +2 -1
- package/es/view/node/BaseNode.js +17 -1
- package/es/view/overlay/BezierAdjustOverlay.js +1 -1
- package/es/view/overlay/CanvasOverlay.d.ts +12 -1
- package/es/view/overlay/CanvasOverlay.js +94 -15
- package/es/view/text/BaseText.d.ts +1 -1
- package/es/view/text/BaseText.js +1 -1
- package/lib/model/EditConfigModel.d.ts +3 -1
- package/lib/model/EditConfigModel.js +5 -0
- package/lib/model/GraphModel.js +1 -0
- package/lib/tool/MultipleSelectTool.d.ts +1 -1
- package/lib/tool/MultipleSelectTool.js +1 -1
- package/lib/util/drag.d.ts +4 -4
- package/lib/util/drag.js +12 -6
- package/lib/view/Anchor.d.ts +3 -3
- package/lib/view/Anchor.js +30 -4
- package/lib/view/Control.js +1 -1
- package/lib/view/Rotate.js +1 -1
- package/lib/view/behavior/dnd.d.ts +4 -8
- package/lib/view/behavior/dnd.js +50 -14
- package/lib/view/edge/AdjustPoint.d.ts +1 -1
- package/lib/view/edge/AdjustPoint.js +1 -1
- package/lib/view/edge/BaseEdge.d.ts +2 -1
- package/lib/view/edge/BaseEdge.js +18 -1
- package/lib/view/edge/PolylineEdge.d.ts +1 -1
- package/lib/view/edge/PolylineEdge.js +1 -1
- package/lib/view/node/BaseNode.d.ts +2 -1
- package/lib/view/node/BaseNode.js +17 -1
- package/lib/view/overlay/BezierAdjustOverlay.js +1 -1
- package/lib/view/overlay/CanvasOverlay.d.ts +12 -1
- package/lib/view/overlay/CanvasOverlay.js +94 -15
- package/lib/view/text/BaseText.d.ts +1 -1
- package/lib/view/text/BaseText.js +1 -1
- package/package.json +1 -1
- package/src/model/EditConfigModel.ts +3 -0
- package/src/model/GraphModel.ts +1 -0
- package/src/tool/MultipleSelectTool.tsx +2 -2
- package/src/util/drag.ts +16 -12
- package/src/view/Anchor.tsx +32 -6
- package/src/view/Control.tsx +1 -1
- package/src/view/Rotate.tsx +1 -1
- package/src/view/behavior/dnd.ts +55 -16
- package/src/view/edge/AdjustPoint.tsx +2 -2
- package/src/view/edge/BaseEdge.tsx +23 -3
- package/src/view/edge/PolylineEdge.tsx +2 -2
- package/src/view/node/BaseNode.tsx +21 -5
- package/src/view/overlay/BezierAdjustOverlay.tsx +1 -1
- package/src/view/overlay/CanvasOverlay.tsx +110 -4
- package/src/view/text/BaseText.tsx +5 -2
- package/stats.html +1 -1
|
@@ -114,6 +114,7 @@ export interface IEditConfigType {
|
|
|
114
114
|
nodeTextMode: TextMode;
|
|
115
115
|
edgeTextMode: TextMode;
|
|
116
116
|
snapGrid: boolean;
|
|
117
|
+
isPinching: boolean;
|
|
117
118
|
}
|
|
118
119
|
export type IConfigKeys = keyof IEditConfigType;
|
|
119
120
|
/**
|
|
@@ -129,6 +130,7 @@ export declare class EditConfigModel {
|
|
|
129
130
|
stopMoveGraph: boolean;
|
|
130
131
|
stopScrollGraph: boolean;
|
|
131
132
|
snapGrid: boolean;
|
|
133
|
+
isPinching: boolean;
|
|
132
134
|
/*********************************************************
|
|
133
135
|
* 文本相关配置(全局)
|
|
134
136
|
********************************************************/
|
|
@@ -170,7 +172,7 @@ export declare class EditConfigModel {
|
|
|
170
172
|
multipleSelectKey: string;
|
|
171
173
|
constructor(config: Partial<IEditConfigType>);
|
|
172
174
|
updateEditConfig(config: Partial<IEditConfigType>): void;
|
|
173
|
-
computeConfig(config: Partial<IEditConfigType>): Partial<IEditConfigType> & Pick<Partial<IEditConfigType>, "textMode" | "adjustEdgeStartAndEnd" | "edgeTextDraggable" | "edgeTextEdit" | "nodeTextDraggable" | "nodeTextEdit" | "adjustEdge" | "edgeTextMode" | "nodeTextMode" | "allowRotate" | "allowResize" | "isSilentMode" | "stopScrollGraph" | "stopZoomGraph" | "stopMoveGraph" | "textEdit" | "snapGrid" | "
|
|
175
|
+
computeConfig(config: Partial<IEditConfigType>): Partial<IEditConfigType> & Pick<Partial<IEditConfigType>, "textMode" | "adjustEdgeStartAndEnd" | "edgeTextDraggable" | "edgeTextEdit" | "nodeTextDraggable" | "nodeTextEdit" | "adjustEdge" | "edgeTextMode" | "nodeTextMode" | "allowRotate" | "allowResize" | "isSilentMode" | "stopScrollGraph" | "stopZoomGraph" | "stopMoveGraph" | "textEdit" | "snapGrid" | "adjustEdgeMiddle" | "adjustEdgeStart" | "adjustEdgeEnd" | "adjustNodePosition" | "hideAnchors" | "autoExpand" | "hoverOutline" | "nodeSelectedOutline" | "edgeSelectedOutline" | "textDraggable" | "multipleSelectKey" | "nodeTextMultiple" | "edgeTextMultiple" | "nodeTextVertical" | "edgeTextVertical" | "isPinching">;
|
|
174
176
|
updateTextMode(textMode: TextMode): void;
|
|
175
177
|
getConfig(): IEditConfigType;
|
|
176
178
|
}
|
|
@@ -62,6 +62,7 @@ var allKeys = [
|
|
|
62
62
|
'edgeTextMultiple', // 是否支持多个边文本
|
|
63
63
|
'nodeTextVertical', // 节点文本是否纵向显示
|
|
64
64
|
'edgeTextVertical', // 边文本是否纵向显示
|
|
65
|
+
'isPinching', //是否是双指捏合态
|
|
65
66
|
];
|
|
66
67
|
/**
|
|
67
68
|
* 页面编辑配置
|
|
@@ -76,6 +77,7 @@ var EditConfigModel = /** @class */ (function () {
|
|
|
76
77
|
this.stopMoveGraph = false;
|
|
77
78
|
this.stopScrollGraph = false;
|
|
78
79
|
this.snapGrid = false;
|
|
80
|
+
this.isPinching = false;
|
|
79
81
|
/*********************************************************
|
|
80
82
|
* 文本相关配置(全局)
|
|
81
83
|
********************************************************/
|
|
@@ -193,6 +195,9 @@ var EditConfigModel = /** @class */ (function () {
|
|
|
193
195
|
__decorate([
|
|
194
196
|
observable
|
|
195
197
|
], EditConfigModel.prototype, "snapGrid", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
observable
|
|
200
|
+
], EditConfigModel.prototype, "isPinching", void 0);
|
|
196
201
|
__decorate([
|
|
197
202
|
observable
|
|
198
203
|
], EditConfigModel.prototype, "textMode", void 0);
|
package/es/model/GraphModel.js
CHANGED
|
@@ -1096,6 +1096,7 @@ var GraphModel = /** @class */ (function () {
|
|
|
1096
1096
|
var _a;
|
|
1097
1097
|
this.selectElements.forEach(function (element) {
|
|
1098
1098
|
element === null || element === void 0 ? void 0 : element.setSelected(false);
|
|
1099
|
+
element === null || element === void 0 ? void 0 : element.setHovered(false);
|
|
1099
1100
|
});
|
|
1100
1101
|
this.selectElements.clear();
|
|
1101
1102
|
/**
|
|
@@ -5,7 +5,7 @@ export default class MultipleSelect extends Component<IToolProps> {
|
|
|
5
5
|
static toolName: string;
|
|
6
6
|
stepDrag: StepDrag;
|
|
7
7
|
constructor(props: IToolProps);
|
|
8
|
-
handleMouseDown: (ev:
|
|
8
|
+
handleMouseDown: (ev: PointerEvent) => void;
|
|
9
9
|
handleWheelEvent: (ev: WheelEvent) => void;
|
|
10
10
|
onDragging: ({ deltaX, deltaY }: IDragParams) => void;
|
|
11
11
|
handleContextMenu: (ev: MouseEvent) => void;
|
|
@@ -147,7 +147,7 @@ var MultipleSelect = /** @class */ (function (_super) {
|
|
|
147
147
|
height: "".concat(y1 - y + 20 * SCALE_Y, "px"),
|
|
148
148
|
'border-width': "".concat(2 * SCALE_X, "px"),
|
|
149
149
|
};
|
|
150
|
-
return (_jsx("div", { className: "lf-multiple-select", style: style,
|
|
150
|
+
return (_jsx("div", { className: "lf-multiple-select", style: style, onPointerDown: this.handleMouseDown, onContextMenu: this.handleContextMenu, onWheel: this.handleWheelEvent }));
|
|
151
151
|
};
|
|
152
152
|
MultipleSelect.toolName = 'multiple-select-tool';
|
|
153
153
|
MultipleSelect = __decorate([
|
package/es/util/drag.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import EventEmitter from '../event/eventEmitter';
|
|
|
3
3
|
export type IDragParams = {
|
|
4
4
|
deltaX: number;
|
|
5
5
|
deltaY: number;
|
|
6
|
-
event?:
|
|
6
|
+
event?: PointerEvent;
|
|
7
7
|
[key: string]: unknown;
|
|
8
8
|
};
|
|
9
9
|
export type ICreateDragParams = {
|
|
@@ -40,9 +40,9 @@ export declare class StepDrag {
|
|
|
40
40
|
constructor({ onDragStart, onDragging, onDragEnd, eventType, eventCenter, step, isStopPropagation, model, data, }: IStepperDragProps);
|
|
41
41
|
setStep(step: number): void;
|
|
42
42
|
setModel(model: Model.BaseModel): void;
|
|
43
|
-
handleMouseDown: (e:
|
|
44
|
-
handleMouseMove: (e:
|
|
45
|
-
handleMouseUp: (e:
|
|
43
|
+
handleMouseDown: (e: PointerEvent) => void;
|
|
44
|
+
handleMouseMove: (e: PointerEvent) => void;
|
|
45
|
+
handleMouseUp: (e: PointerEvent) => void;
|
|
46
46
|
cancelDrag: () => void;
|
|
47
47
|
destroy: () => void;
|
|
48
48
|
}
|
package/es/util/drag.js
CHANGED
|
@@ -23,11 +23,12 @@ var StepDrag = /** @class */ (function () {
|
|
|
23
23
|
return;
|
|
24
24
|
if (_this.isStopPropagation)
|
|
25
25
|
e.stopPropagation();
|
|
26
|
+
e.preventDefault();
|
|
26
27
|
_this.isStartDragging = true;
|
|
27
28
|
_this.startX = e.clientX;
|
|
28
29
|
_this.startY = e.clientY;
|
|
29
|
-
DOC.addEventListener('
|
|
30
|
-
DOC.addEventListener('
|
|
30
|
+
DOC.addEventListener('pointermove', _this.handleMouseMove, false);
|
|
31
|
+
DOC.addEventListener('pointerup', _this.handleMouseUp, false);
|
|
31
32
|
var elementData = (_a = _this.model) === null || _a === void 0 ? void 0 : _a.getData();
|
|
32
33
|
(_b = _this.eventCenter) === null || _b === void 0 ? void 0 : _b.emit(EventType["".concat(_this.eventType, "_MOUSEDOWN")], {
|
|
33
34
|
e: e,
|
|
@@ -39,6 +40,7 @@ var StepDrag = /** @class */ (function () {
|
|
|
39
40
|
var _a, _b;
|
|
40
41
|
if (_this.isStopPropagation)
|
|
41
42
|
e.stopPropagation();
|
|
43
|
+
e.preventDefault();
|
|
42
44
|
if (!_this.isStartDragging)
|
|
43
45
|
return;
|
|
44
46
|
_this.sumDeltaX += e.clientX - _this.startX;
|
|
@@ -94,11 +96,15 @@ var StepDrag = /** @class */ (function () {
|
|
|
94
96
|
_this.isStartDragging = false;
|
|
95
97
|
if (_this.isStopPropagation)
|
|
96
98
|
e.stopPropagation();
|
|
99
|
+
var target = e.target;
|
|
100
|
+
if (target && typeof target.releasePointerCapture === 'function') {
|
|
101
|
+
target.releasePointerCapture(e.pointerId);
|
|
102
|
+
}
|
|
97
103
|
// fix #568: 如果onDragging在下一个事件循环中触发,而drop在当前事件循环,会出现问题。
|
|
98
104
|
Promise.resolve().then(function () {
|
|
99
105
|
var _a, _b, _c;
|
|
100
|
-
DOC.removeEventListener('
|
|
101
|
-
DOC.removeEventListener('
|
|
106
|
+
DOC.removeEventListener('pointermove', _this.handleMouseMove, false);
|
|
107
|
+
DOC.removeEventListener('pointerup', _this.handleMouseUp, false);
|
|
102
108
|
var elementData = (_a = _this.model) === null || _a === void 0 ? void 0 : _a.getData();
|
|
103
109
|
(_b = _this.eventCenter) === null || _b === void 0 ? void 0 : _b.emit(EventType["".concat(_this.eventType, "_MOUSEUP")], {
|
|
104
110
|
e: e,
|
|
@@ -116,8 +122,8 @@ var StepDrag = /** @class */ (function () {
|
|
|
116
122
|
};
|
|
117
123
|
this.cancelDrag = function () {
|
|
118
124
|
var DOC = window === null || window === void 0 ? void 0 : window.document;
|
|
119
|
-
DOC.removeEventListener('
|
|
120
|
-
DOC.removeEventListener('
|
|
125
|
+
DOC.removeEventListener('pointermove', _this.handleMouseMove, false);
|
|
126
|
+
DOC.removeEventListener('pointerup', _this.handleMouseUp, false);
|
|
121
127
|
_this.onDragEnd({ event: undefined });
|
|
122
128
|
_this.isDragging = false;
|
|
123
129
|
};
|
package/es/view/Anchor.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ interface IProps {
|
|
|
13
13
|
anchorIndex: number;
|
|
14
14
|
graphModel: GraphModel;
|
|
15
15
|
nodeModel: BaseNodeModel;
|
|
16
|
-
setHoverOff: (e:
|
|
16
|
+
setHoverOff: (e: PointerEvent) => void;
|
|
17
17
|
}
|
|
18
18
|
interface IState {
|
|
19
19
|
startX: number;
|
|
@@ -38,8 +38,8 @@ declare class Anchor extends Component<IProps, IState> {
|
|
|
38
38
|
incomingEdgeList: import("../model").BaseEdgeModel<LogicFlow.PropertiesType>[];
|
|
39
39
|
outgoingEdgeList: import("../model").BaseEdgeModel<LogicFlow.PropertiesType>[];
|
|
40
40
|
};
|
|
41
|
-
checkEnd: (event:
|
|
42
|
-
moveAnchorEnd(endX: number, endY: number): void;
|
|
41
|
+
checkEnd: (event: PointerEvent | null | undefined) => import("../model").BaseEdgeModel<LogicFlow.PropertiesType> | null | undefined;
|
|
42
|
+
moveAnchorEnd(endX: number, endY: number, event?: PointerEvent): void;
|
|
43
43
|
isShowLine(): boolean;
|
|
44
44
|
render(): import("preact/compat").JSX.Element;
|
|
45
45
|
}
|
package/es/view/Anchor.js
CHANGED
|
@@ -103,7 +103,7 @@ var Anchor = /** @class */ (function (_super) {
|
|
|
103
103
|
endY: y1,
|
|
104
104
|
dragging: true,
|
|
105
105
|
});
|
|
106
|
-
_this.moveAnchorEnd(x1, y1);
|
|
106
|
+
_this.moveAnchorEnd(x1, y1, event);
|
|
107
107
|
if (nearBoundary.length > 0 && !stopMoveGraph && autoExpand) {
|
|
108
108
|
_this.t = createRaf(function () {
|
|
109
109
|
var _a = __read(nearBoundary, 2), translateX = _a[0], translateY = _a[1];
|
|
@@ -113,7 +113,7 @@ var Anchor = /** @class */ (function (_super) {
|
|
|
113
113
|
endX: endX - translateX,
|
|
114
114
|
endY: endY - translateY,
|
|
115
115
|
});
|
|
116
|
-
_this.moveAnchorEnd(endX - translateX, endY - translateY);
|
|
116
|
+
_this.moveAnchorEnd(endX - translateX, endY - translateY, event);
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
eventCenter.emit(EventType.ANCHOR_DRAG, {
|
|
@@ -139,6 +139,11 @@ var Anchor = /** @class */ (function (_super) {
|
|
|
139
139
|
_this.sourceRuleResults.clear();
|
|
140
140
|
_this.targetRuleResults.clear();
|
|
141
141
|
var _b = _this.props, graphModel = _b.graphModel, nodeModel = _b.nodeModel, anchorData = _b.anchorData;
|
|
142
|
+
// 拖拽结束清理:取消悬浮态
|
|
143
|
+
if (_this.preTargetNode) {
|
|
144
|
+
_this.preTargetNode.setHovered(false);
|
|
145
|
+
_this.preTargetNode = undefined;
|
|
146
|
+
}
|
|
142
147
|
graphModel.eventCenter.emit(EventType.ANCHOR_DRAGEND, {
|
|
143
148
|
data: anchorData,
|
|
144
149
|
e: event,
|
|
@@ -242,7 +247,7 @@ var Anchor = /** @class */ (function (_super) {
|
|
|
242
247
|
enumerable: false,
|
|
243
248
|
configurable: true
|
|
244
249
|
});
|
|
245
|
-
Anchor.prototype.moveAnchorEnd = function (endX, endY) {
|
|
250
|
+
Anchor.prototype.moveAnchorEnd = function (endX, endY, event) {
|
|
246
251
|
var _a, _b;
|
|
247
252
|
var _c = this.props, graphModel = _c.graphModel, nodeModel = _c.nodeModel, anchorData = _c.anchorData;
|
|
248
253
|
var info = targetNodeInfo({
|
|
@@ -279,11 +284,32 @@ var Anchor = /** @class */ (function (_super) {
|
|
|
279
284
|
else {
|
|
280
285
|
targetNode.setElementState(ElementState.NOT_ALLOW_CONNECT);
|
|
281
286
|
}
|
|
287
|
+
// 人工触发进入目标节点事件,同步设置 hovered 以驱动锚点显隐和样式
|
|
288
|
+
if (!targetNode.isHovered) {
|
|
289
|
+
var nodeData = targetNode.getData();
|
|
290
|
+
if (event) {
|
|
291
|
+
graphModel.eventCenter.emit(EventType.NODE_MOUSEENTER, {
|
|
292
|
+
data: nodeData,
|
|
293
|
+
e: event,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
targetNode.setHovered(true);
|
|
297
|
+
}
|
|
282
298
|
}
|
|
283
299
|
else if (this.preTargetNode &&
|
|
284
300
|
this.preTargetNode.state !== ElementState.DEFAULT) {
|
|
285
301
|
// 为了保证鼠标离开的时候,将上一个节点状态重置为正常状态。
|
|
286
302
|
this.preTargetNode.setElementState(ElementState.DEFAULT);
|
|
303
|
+
// 未命中任何节点:人工派发离开事件并取消悬浮,避免状态残留
|
|
304
|
+
var prevData = this.preTargetNode.getData();
|
|
305
|
+
if (event) {
|
|
306
|
+
graphModel.eventCenter.emit(EventType.NODE_MOUSELEAVE, {
|
|
307
|
+
data: prevData,
|
|
308
|
+
e: event,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
this.preTargetNode.setHovered(false);
|
|
312
|
+
this.preTargetNode = undefined;
|
|
287
313
|
}
|
|
288
314
|
};
|
|
289
315
|
Anchor.prototype.isShowLine = function () {
|
|
@@ -305,7 +331,7 @@ var Anchor = /** @class */ (function (_super) {
|
|
|
305
331
|
e: ev,
|
|
306
332
|
nodeModel: nodeModel,
|
|
307
333
|
});
|
|
308
|
-
},
|
|
334
|
+
}, onPointerDown: function (ev) {
|
|
309
335
|
graphModel.eventCenter.emit(EventType.ANCHOR_MOUSEDOWN, {
|
|
310
336
|
data: anchorData,
|
|
311
337
|
e: ev,
|
package/es/view/Control.js
CHANGED
|
@@ -346,7 +346,7 @@ var ResizeControl = /** @class */ (function (_super) {
|
|
|
346
346
|
ResizeControl.prototype.render = function () {
|
|
347
347
|
var _a = this.props, x = _a.x, y = _a.y, direction = _a.direction, model = _a.model;
|
|
348
348
|
var _b = model.getResizeControlStyle(), width = _b.width, height = _b.height, restStyle = __rest(_b, ["width", "height"]);
|
|
349
|
-
return (_jsxs("g", { className: "lf-resize-control lf-resize-control-".concat(direction), children: [_jsx(Rect, __assign({ className: "lf-resize-control-content", x: x, y: y, width: width !== null && width !== void 0 ? width : 7, height: height !== null && height !== void 0 ? height : 7 }, restStyle)), _jsx(Rect, { className: "lf-resize-control-content", x: x, y: y, width: 25, height: 25, fill: "transparent", stroke: "transparent",
|
|
349
|
+
return (_jsxs("g", { className: "lf-resize-control lf-resize-control-".concat(direction), children: [_jsx(Rect, __assign({ className: "lf-resize-control-content", x: x, y: y, width: width !== null && width !== void 0 ? width : 7, height: height !== null && height !== void 0 ? height : 7 }, restStyle)), _jsx(Rect, { className: "lf-resize-control-content", x: x, y: y, width: 25, height: 25, fill: "transparent", stroke: "transparent", onPointerDown: this.dragHandler.handleMouseDown })] }));
|
|
350
350
|
};
|
|
351
351
|
return ResizeControl;
|
|
352
352
|
}(Component));
|
package/es/view/Rotate.js
CHANGED
|
@@ -99,7 +99,7 @@ var RotateControlPoint = /** @class */ (function (_super) {
|
|
|
99
99
|
this.normal = new Vector(1, 0);
|
|
100
100
|
this.defaultAngle = this.normal.angle(new Vector(cx - x, cy - y));
|
|
101
101
|
nodeModel.defaultAngle = this.defaultAngle;
|
|
102
|
-
return (_jsx("g", { className: "lf-rotate-control", children: _jsx("g", {
|
|
102
|
+
return (_jsx("g", { className: "lf-rotate-control", children: _jsx("g", { onPointerDown: function (ev) {
|
|
103
103
|
_this.stepperDrag.handleMouseDown(ev);
|
|
104
104
|
}, children: _jsx(Circle, __assign({}, this.style, { cx: cx, cy: cy })) }) }));
|
|
105
105
|
};
|
|
@@ -6,22 +6,18 @@ export declare class Dnd {
|
|
|
6
6
|
nodeConfig: OnDragNodeConfig | null;
|
|
7
7
|
lf: LogicFlow;
|
|
8
8
|
fakeNode: BaseNodeModel | null;
|
|
9
|
+
docPointerMove?: (e: PointerEvent) => void;
|
|
10
|
+
docPointerUp?: (e: PointerEvent) => void;
|
|
9
11
|
constructor(params: {
|
|
10
12
|
lf: LogicFlow;
|
|
11
13
|
});
|
|
12
14
|
clientToLocalPoint({ x, y }: Position): Position;
|
|
15
|
+
isInsideCanvas(e: PointerEvent): boolean;
|
|
13
16
|
startDrag(nodeConfig: OnDragNodeConfig): void;
|
|
14
17
|
stopDrag: () => void;
|
|
15
|
-
dragEnter: (e:
|
|
18
|
+
dragEnter: (e: PointerEvent) => void;
|
|
16
19
|
onDragOver: (e: MouseEvent) => boolean;
|
|
17
20
|
onDragLeave: () => void;
|
|
18
21
|
onDrop: (e: MouseEvent) => void;
|
|
19
|
-
eventMap(): {
|
|
20
|
-
onMouseEnter: (e: MouseEvent) => void;
|
|
21
|
-
onMouseOver: (e: MouseEvent) => void;
|
|
22
|
-
onMouseMove: (e: MouseEvent) => boolean;
|
|
23
|
-
onMouseLeave: () => void;
|
|
24
|
-
onMouseUp: (e: MouseEvent) => void;
|
|
25
|
-
};
|
|
26
22
|
}
|
|
27
23
|
export default Dnd;
|
package/es/view/behavior/dnd.js
CHANGED
|
@@ -19,7 +19,12 @@ var Dnd = /** @class */ (function () {
|
|
|
19
19
|
this.fakeNode = null;
|
|
20
20
|
this.stopDrag = function () {
|
|
21
21
|
_this.nodeConfig = null;
|
|
22
|
-
|
|
22
|
+
if (_this.docPointerMove) {
|
|
23
|
+
window.document.removeEventListener('pointermove', _this.docPointerMove);
|
|
24
|
+
}
|
|
25
|
+
if (_this.docPointerUp) {
|
|
26
|
+
window.document.removeEventListener('pointerup', _this.docPointerUp);
|
|
27
|
+
}
|
|
23
28
|
};
|
|
24
29
|
this.dragEnter = function (e) {
|
|
25
30
|
if (!_this.nodeConfig || _this.fakeNode)
|
|
@@ -91,22 +96,53 @@ var Dnd = /** @class */ (function () {
|
|
|
91
96
|
y: snapToGrid(y1, gridSize, snapGrid),
|
|
92
97
|
};
|
|
93
98
|
};
|
|
99
|
+
Dnd.prototype.isInsideCanvas = function (e) {
|
|
100
|
+
var overlay = this.lf.graphModel.rootEl.querySelector('[name="canvas-overlay"]');
|
|
101
|
+
var topEl = window.document.elementFromPoint(e.clientX, e.clientY);
|
|
102
|
+
return (topEl === overlay ||
|
|
103
|
+
(topEl !== null && !!overlay && overlay.contains(topEl)));
|
|
104
|
+
};
|
|
94
105
|
Dnd.prototype.startDrag = function (nodeConfig) {
|
|
106
|
+
var _this = this;
|
|
95
107
|
var editConfigModel = this.lf.graphModel.editConfigModel;
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
if (editConfigModel === null || editConfigModel === void 0 ? void 0 : editConfigModel.isSilentMode)
|
|
109
|
+
return;
|
|
110
|
+
this.nodeConfig = nodeConfig;
|
|
111
|
+
// 指针移动:根据命中结果判断是否在画布覆盖层上,驱动假节点创建/移动或清理
|
|
112
|
+
this.docPointerMove = function (e) {
|
|
113
|
+
if (!_this.nodeConfig)
|
|
114
|
+
return;
|
|
115
|
+
// 离开画布:清理吸附线与假节点
|
|
116
|
+
if (!_this.isInsideCanvas(e)) {
|
|
117
|
+
_this.onDragLeave();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// 首次进入画布:创建假节点并初始化位置
|
|
121
|
+
if (!_this.fakeNode) {
|
|
122
|
+
_this.dragEnter(e);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
// 在画布内移动:更新假节点位置与吸附线
|
|
126
|
+
_this.onDragOver(e);
|
|
127
|
+
};
|
|
128
|
+
// 指针抬起:在画布内落点生成节点,否则清理假节点
|
|
129
|
+
this.docPointerUp = function (e) {
|
|
130
|
+
if (!_this.nodeConfig)
|
|
131
|
+
return;
|
|
132
|
+
if (_this.isInsideCanvas(e)) {
|
|
133
|
+
_this.onDrop(e);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
_this.onDragLeave();
|
|
137
|
+
}
|
|
138
|
+
// 阻止默认行为与冒泡,避免滚动/点击穿透
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
e.stopPropagation();
|
|
141
|
+
// 结束拖拽并移除监听
|
|
142
|
+
_this.stopDrag();
|
|
109
143
|
};
|
|
144
|
+
window.document.addEventListener('pointermove', this.docPointerMove);
|
|
145
|
+
window.document.addEventListener('pointerup', this.docPointerUp);
|
|
110
146
|
};
|
|
111
147
|
return Dnd;
|
|
112
148
|
}());
|
|
@@ -34,7 +34,7 @@ export declare class AdjustPoint extends Component<IProps, IState> {
|
|
|
34
34
|
targetRuleResults: Map<any, any>;
|
|
35
35
|
sourceRuleResults: Map<any, any>;
|
|
36
36
|
constructor(props: IProps);
|
|
37
|
-
handleMouseDown: (ev:
|
|
37
|
+
handleMouseDown: (ev: PointerEvent) => void;
|
|
38
38
|
onDragStart: () => void;
|
|
39
39
|
onDragging: ({ deltaX, deltaY }: IDragParams) => void;
|
|
40
40
|
onDragEnd: ({ event }: Partial<IDragParams>) => void;
|
|
@@ -348,7 +348,7 @@ var AdjustPoint = /** @class */ (function (_super) {
|
|
|
348
348
|
AdjustPoint.prototype.render = function () {
|
|
349
349
|
var _a = this.props, x = _a.x, y = _a.y, getAdjustPointShape = _a.getAdjustPointShape, edgeModel = _a.edgeModel;
|
|
350
350
|
var dragging = this.state.dragging;
|
|
351
|
-
return (_jsx("g", { pointerEvents: dragging ? 'none' : '',
|
|
351
|
+
return (_jsx("g", { pointerEvents: dragging ? 'none' : '', onPointerDown: this.handleMouseDown, children: !dragging ? getAdjustPointShape(x, y, edgeModel) : '' }));
|
|
352
352
|
};
|
|
353
353
|
return AdjustPoint;
|
|
354
354
|
}(Component));
|
|
@@ -17,6 +17,7 @@ export declare abstract class BaseEdge<P extends IProps> extends Component<P, IE
|
|
|
17
17
|
startTime?: number;
|
|
18
18
|
contextMenuTime?: number;
|
|
19
19
|
clickTimer?: number;
|
|
20
|
+
longPressTimer?: number;
|
|
20
21
|
textRef: import("preact").RefObject<any>;
|
|
21
22
|
constructor();
|
|
22
23
|
/**
|
|
@@ -131,7 +132,7 @@ export declare abstract class BaseEdge<P extends IProps> extends Component<P, IE
|
|
|
131
132
|
/**
|
|
132
133
|
* 不支持重写
|
|
133
134
|
*/
|
|
134
|
-
handleMouseDown: (e:
|
|
135
|
+
handleMouseDown: (e: PointerEvent) => void;
|
|
135
136
|
handleMouseUp: () => void;
|
|
136
137
|
/**
|
|
137
138
|
* 不支持重写
|
package/es/view/edge/BaseEdge.js
CHANGED
|
@@ -126,10 +126,24 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
126
126
|
_this.handleMouseDown = function (e) {
|
|
127
127
|
e.stopPropagation();
|
|
128
128
|
_this.startTime = new Date().getTime();
|
|
129
|
+
if (_this.longPressTimer) {
|
|
130
|
+
clearTimeout(_this.longPressTimer);
|
|
131
|
+
}
|
|
132
|
+
if (e.pointerType === 'touch') {
|
|
133
|
+
_this.longPressTimer = window.setTimeout(function () {
|
|
134
|
+
if (!_this.props.model.isDragging) {
|
|
135
|
+
_this.handleContextMenu(e);
|
|
136
|
+
}
|
|
137
|
+
}, 500);
|
|
138
|
+
}
|
|
129
139
|
};
|
|
130
140
|
_this.handleMouseUp = function () {
|
|
131
141
|
var model = _this.props.model;
|
|
132
142
|
_this.mouseUpDrag = model.isDragging;
|
|
143
|
+
if (_this.longPressTimer) {
|
|
144
|
+
clearTimeout(_this.longPressTimer);
|
|
145
|
+
_this.longPressTimer = undefined;
|
|
146
|
+
}
|
|
133
147
|
};
|
|
134
148
|
/**
|
|
135
149
|
* 不支持重写
|
|
@@ -452,7 +466,10 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
452
466
|
isSelected && 'lf-edge-selected',
|
|
453
467
|
]
|
|
454
468
|
.filter(Boolean)
|
|
455
|
-
.join(' '),
|
|
469
|
+
.join(' '), style: {
|
|
470
|
+
touchAction: 'none',
|
|
471
|
+
WebkitTouchCallout: 'none',
|
|
472
|
+
}, onClick: this.handleClick, onContextMenu: this.handleContextMenu, onPointerDown: this.handleMouseDown, onPointerUp: this.handleMouseUp, onPointerCancel: this.handleMouseUp, 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() : ''] }));
|
|
456
473
|
};
|
|
457
474
|
BaseEdge.isObserved = false;
|
|
458
475
|
return BaseEdge;
|
|
@@ -34,7 +34,7 @@ export declare class PolylineEdge extends BaseEdge<IPolylineEdgeProps> {
|
|
|
34
34
|
/**
|
|
35
35
|
* 不支持重写
|
|
36
36
|
*/
|
|
37
|
-
beforeDragStart: (e:
|
|
37
|
+
beforeDragStart: (e: PointerEvent, appendInfo: any) => void;
|
|
38
38
|
/**
|
|
39
39
|
* @overridable 支持重写, 此方法为获取边的形状,如果需要自定义边的形状,请重写此方法。
|
|
40
40
|
* @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
|
|
@@ -257,7 +257,7 @@ var PolylineEdge = /** @class */ (function (_super) {
|
|
|
257
257
|
}
|
|
258
258
|
appendInfo.direction = SegmentDirection.HORIZONTAL;
|
|
259
259
|
}
|
|
260
|
-
append = (_jsx("g", { className: this_1.isDragging ? 'lf-dragging' : 'lf-drag-able',
|
|
260
|
+
append = (_jsx("g", { className: this_1.isDragging ? 'lf-dragging' : 'lf-drag-able', onPointerDown: function (e) { return _this.beforeDragStart(e, appendInfo); }, children: _jsx("g", { className: className, children: this_1.getAppendShape(appendInfo) }) }));
|
|
261
261
|
}
|
|
262
262
|
LineAppendList.push(append);
|
|
263
263
|
};
|
|
@@ -19,6 +19,7 @@ export declare abstract class BaseNode<P extends IProps = IProps> extends Compon
|
|
|
19
19
|
mouseUpDrag?: boolean;
|
|
20
20
|
startTime?: number;
|
|
21
21
|
modelDisposer: IReactionDisposer;
|
|
22
|
+
longPressTimer?: number;
|
|
22
23
|
constructor(props: IProps);
|
|
23
24
|
componentWillUnmount(): void;
|
|
24
25
|
componentDidMount(): void;
|
|
@@ -37,7 +38,7 @@ export declare abstract class BaseNode<P extends IProps = IProps> extends Compon
|
|
|
37
38
|
handleMouseUp: () => void;
|
|
38
39
|
handleClick: (e: MouseEvent) => void;
|
|
39
40
|
handleContextMenu: (ev: MouseEvent) => void;
|
|
40
|
-
handleMouseDown: (ev:
|
|
41
|
+
handleMouseDown: (ev: PointerEvent) => void;
|
|
41
42
|
handleFocus: () => void;
|
|
42
43
|
handleBlur: () => void;
|
|
43
44
|
setHoverOn: (ev: MouseEvent) => void;
|
package/es/view/node/BaseNode.js
CHANGED
|
@@ -168,6 +168,10 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
168
168
|
_this.handleMouseUp = function () {
|
|
169
169
|
var model = _this.props.model;
|
|
170
170
|
_this.mouseUpDrag = model.isDragging;
|
|
171
|
+
if (_this.longPressTimer) {
|
|
172
|
+
clearTimeout(_this.longPressTimer);
|
|
173
|
+
_this.longPressTimer = undefined;
|
|
174
|
+
}
|
|
171
175
|
};
|
|
172
176
|
_this.handleClick = function (e) {
|
|
173
177
|
// 节点拖拽进画布之后,不触发click事件相关emit
|
|
@@ -268,6 +272,16 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
268
272
|
if (editConfigModel.adjustNodePosition && model.draggable) {
|
|
269
273
|
_this.stepDrag && _this.stepDrag.handleMouseDown(ev);
|
|
270
274
|
}
|
|
275
|
+
if (_this.longPressTimer) {
|
|
276
|
+
clearTimeout(_this.longPressTimer);
|
|
277
|
+
}
|
|
278
|
+
if (ev.pointerType === 'touch') {
|
|
279
|
+
_this.longPressTimer = window.setTimeout(function () {
|
|
280
|
+
if (!_this.props.model.isDragging) {
|
|
281
|
+
_this.handleContextMenu(ev);
|
|
282
|
+
}
|
|
283
|
+
}, 500);
|
|
284
|
+
}
|
|
271
285
|
};
|
|
272
286
|
_this.handleFocus = function () {
|
|
273
287
|
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
@@ -449,7 +463,9 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
449
463
|
if (adjustNodePosition && draggable) {
|
|
450
464
|
this.stepDrag.setStep(gridSize * SCALE_X);
|
|
451
465
|
}
|
|
452
|
-
nodeShape = (_jsx("g", __assign({ className: "".concat(this.getStateClassName(), " ").concat(className),
|
|
466
|
+
nodeShape = (_jsx("g", __assign({ className: "".concat(this.getStateClassName(), " ").concat(className), onPointerDown: this.handleMouseDown, onPointerUp: this.handleMouseUp, onClick: this.handleClick,
|
|
467
|
+
//因为移动端点击操作完成会按顺序触发enter、leave、click事件,所以会造成节点的闪烁,所以在这里没有统一状态为Pointer
|
|
468
|
+
onMouseEnter: this.setHoverOn, onMouseOver: this.setHoverOn, onMouseLeave: this.setHoverOff, onMouseOut: this.onMouseOut, onContextMenu: this.handleContextMenu, onFocus: this.handleFocus, onBlur: this.handleBlur }, restAttributes, { children: nodeShapeInner })));
|
|
453
469
|
}
|
|
454
470
|
return nodeShape;
|
|
455
471
|
};
|
|
@@ -88,7 +88,7 @@ var BezierAdjustAnchor = /** @class */ (function (_super) {
|
|
|
88
88
|
var x = position.x, y = position.y;
|
|
89
89
|
var bezierModel = this.props.bezierModel;
|
|
90
90
|
var adjustAnchor = bezierModel.getEdgeStyle().adjustAnchor;
|
|
91
|
-
return (_jsx(Circle, __assign({ className: "lf-bezier-adjust-anchor", x: x, y: y }, adjustAnchor, {
|
|
91
|
+
return (_jsx(Circle, __assign({ className: "lf-bezier-adjust-anchor", x: x, y: y }, adjustAnchor, { onPointerDown: function (ev) {
|
|
92
92
|
// if (edgeAddable !== false) {
|
|
93
93
|
_this.dragHandler.handleMouseDown(ev);
|
|
94
94
|
// }
|
|
@@ -13,13 +13,24 @@ export declare class CanvasOverlay extends Component<IProps, IState> {
|
|
|
13
13
|
stepDrag: StepDrag;
|
|
14
14
|
stepScrollX: number;
|
|
15
15
|
stepScrollY: number;
|
|
16
|
+
pointers: Map<number, {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}>;
|
|
20
|
+
pinchStartDistance?: number;
|
|
21
|
+
pinchStartScale?: number;
|
|
22
|
+
pinchLastCenterX?: number;
|
|
23
|
+
pinchLastCenterY?: number;
|
|
24
|
+
longPressTimer?: number;
|
|
16
25
|
constructor(props: IProps);
|
|
17
26
|
onDragging: ({ deltaX, deltaY }: IDragParams) => void;
|
|
18
27
|
onDragEnd: () => void;
|
|
19
28
|
zoomHandler: (ev: WheelEvent) => void;
|
|
20
29
|
clickHandler: (ev: MouseEvent) => void;
|
|
21
30
|
handleContextMenu: (ev: MouseEvent) => void;
|
|
22
|
-
|
|
31
|
+
pointerDownHandler: (ev: PointerEvent) => void;
|
|
32
|
+
pointerMoveHandler: (ev: PointerEvent) => void;
|
|
33
|
+
pointerUpHandler: (ev: PointerEvent) => void;
|
|
23
34
|
render(): import("preact/compat").JSX.Element;
|
|
24
35
|
}
|
|
25
36
|
export default CanvasOverlay;
|