@logicflow/core 2.0.12 → 2.0.13

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/es/LogicFlow.d.ts CHANGED
@@ -263,6 +263,11 @@ export declare class LogicFlow {
263
263
  * @param toFront 是否将选中的元素置顶,默认为true
264
264
  */
265
265
  selectElementById(id: string, multiple?: boolean, toFront?: boolean): void;
266
+ /**
267
+ * 移除选中的元素
268
+ * @param id 元素ID
269
+ */
270
+ deselectElementById(id: string): void;
266
271
  /**
267
272
  * 获取选中的元素数据
268
273
  * @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的边,默认包括。
package/es/LogicFlow.js CHANGED
@@ -640,6 +640,13 @@ var LogicFlow = /** @class */ (function () {
640
640
  this.graphModel.toFront(id);
641
641
  }
642
642
  };
643
+ /**
644
+ * 移除选中的元素
645
+ * @param id 元素ID
646
+ */
647
+ LogicFlow.prototype.deselectElementById = function (id) {
648
+ this.graphModel.deselectElementById(id);
649
+ };
643
650
  /**
644
651
  * 获取选中的元素数据
645
652
  * @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的边,默认包括。
@@ -322,6 +322,7 @@ export declare class GraphModel {
322
322
  * @param multiple 是否允许多选,如果为true,不会将上一个选中的元素重置
323
323
  */
324
324
  selectElementById(id: string, multiple?: boolean): void;
325
+ deselectElementById(id: string): void;
325
326
  /**
326
327
  * 将所有选中的元素设置为非选中
327
328
  */
@@ -1054,6 +1054,12 @@ var GraphModel = /** @class */ (function () {
1054
1054
  var selectElement = this.getElement(id);
1055
1055
  selectElement === null || selectElement === void 0 ? void 0 : selectElement.setSelected(true);
1056
1056
  };
1057
+ GraphModel.prototype.deselectElementById = function (id) {
1058
+ var element = this.getElement(id);
1059
+ if (element) {
1060
+ element.setSelected(false);
1061
+ }
1062
+ };
1057
1063
  /**
1058
1064
  * 将所有选中的元素设置为非选中
1059
1065
  */
@@ -1590,6 +1596,9 @@ var GraphModel = /** @class */ (function () {
1590
1596
  __decorate([
1591
1597
  action
1592
1598
  ], GraphModel.prototype, "selectElementById", null);
1599
+ __decorate([
1600
+ action
1601
+ ], GraphModel.prototype, "deselectElementById", null);
1593
1602
  __decorate([
1594
1603
  action
1595
1604
  ], GraphModel.prototype, "clearSelectElements", null);
@@ -1,5 +1,4 @@
1
1
  import { Component, ComponentType } from 'preact/compat';
2
- import { CanvasOverlay } from './overlay';
3
2
  import DnD from './behavior/dnd';
4
3
  import Tool from '../tool';
5
4
  import { Options as LFOptions } from '../options';
@@ -13,8 +12,6 @@ type IGraphProps = {
13
12
  graphModel: GraphModel;
14
13
  };
15
14
  declare class Graph extends Component<IGraphProps> {
16
- canvasOverlayRef: import("preact").RefObject<CanvasOverlay>;
17
- getCanvasOverlay: () => CanvasOverlay | null;
18
15
  private handleResize;
19
16
  private throttleResize;
20
17
  componentDidMount(): void;
package/es/view/Graph.js CHANGED
@@ -45,7 +45,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
45
45
  return to.concat(ar || Array.prototype.slice.call(from));
46
46
  };
47
47
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
48
- import { Component, createRef } from 'preact/compat';
48
+ import { Component } from 'preact/compat';
49
49
  import { map, throttle } from 'lodash-es';
50
50
  import { CanvasOverlay, ToolOverlay, BackgroundOverlay, Grid, SnaplineOverlay, OutlineOverlay, BezierAdjustOverlay, ModificationOverlay, } from './overlay';
51
51
  import { observer } from '..';
@@ -54,10 +54,6 @@ var Graph = /** @class */ (function (_super) {
54
54
  __extends(Graph, _super);
55
55
  function Graph() {
56
56
  var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
57
- _this.canvasOverlayRef = createRef();
58
- _this.getCanvasOverlay = function () {
59
- return _this.canvasOverlayRef.current;
60
- };
61
57
  _this.handleResize = function () {
62
58
  var _a = _this.props, graphModel = _a.graphModel, options = _a.options;
63
59
  var width = graphModel.width, height = graphModel.height, isContainerWidth = graphModel.isContainerWidth, isContainerHeight = graphModel.isContainerHeight;
@@ -114,9 +110,9 @@ var Graph = /** @class */ (function (_super) {
114
110
  }
115
111
  var fakeNode = graphModel.fakeNode, editConfigModel = graphModel.editConfigModel, background = graphModel.background;
116
112
  var adjustEdge = editConfigModel.adjustEdge;
117
- return (_jsxs("div", { className: "lf-graph", "flow-id": graphModel.flowId, style: style, children: [_jsxs(CanvasOverlay, { ref: this.canvasOverlayRef, graphModel: graphModel, dnd: dnd, children: [_jsx("g", { className: "lf-base", children: map(graphModel.sortElements, function (nodeModel) {
113
+ return (_jsxs("div", { className: "lf-graph", "flow-id": graphModel.flowId, style: style, children: [_jsxs(CanvasOverlay, { graphModel: graphModel, dnd: dnd, children: [_jsx("g", { className: "lf-base", children: map(graphModel.sortElements, function (nodeModel) {
118
114
  return _this.getComponent(nodeModel, graphModel);
119
- }) }), fakeNode ? this.getComponent(fakeNode, graphModel) : ''] }), _jsxs(ModificationOverlay, { graphModel: graphModel, children: [_jsx(OutlineOverlay, { graphModel: graphModel }), adjustEdge ? _jsx(BezierAdjustOverlay, { graphModel: graphModel }) : '', options.snapline !== false ? (_jsx(SnaplineOverlay, { snaplineModel: snaplineModel })) : ('')] }), _jsx(ToolOverlay, { graphModel: graphModel, tool: tool, getCanvasOverlay: this.getCanvasOverlay }), background && _jsx(BackgroundOverlay, { background: background }), _jsx(Grid, { graphModel: graphModel })] }));
115
+ }) }), fakeNode ? this.getComponent(fakeNode, graphModel) : ''] }), _jsxs(ModificationOverlay, { graphModel: graphModel, children: [_jsx(OutlineOverlay, { graphModel: graphModel }), adjustEdge ? _jsx(BezierAdjustOverlay, { graphModel: graphModel }) : '', options.snapline !== false ? (_jsx(SnaplineOverlay, { snaplineModel: snaplineModel })) : ('')] }), _jsx(ToolOverlay, { graphModel: graphModel, tool: tool }), background && _jsx(BackgroundOverlay, { background: background }), _jsx(Grid, { graphModel: graphModel })] }));
120
116
  };
121
117
  Graph = __decorate([
122
118
  observer
@@ -1,11 +1,10 @@
1
1
  import { createElement as h, Component } from 'preact/compat';
2
- import { CanvasOverlay, OutlineOverlay } from '.';
2
+ import { OutlineOverlay } from '.';
3
3
  import { GraphModel } from '../../model';
4
4
  import { Tool } from '../../tool';
5
5
  type IProps = {
6
6
  graphModel: GraphModel;
7
7
  tool: Tool;
8
- getCanvasOverlay: () => CanvasOverlay | null;
9
8
  };
10
9
  export declare class ToolOverlay extends Component<IProps> {
11
10
  componentDidMount(): void;
@@ -15,7 +14,6 @@ export declare class ToolOverlay extends Component<IProps> {
15
14
  */
16
15
  getTools(): import("preact").VNode<import("../..").IToolProps>[];
17
16
  triggerToolRender(): void;
18
- zoomHandler: (e: WheelEvent) => void;
19
17
  render(): h.JSX.Element;
20
18
  }
21
19
  export default OutlineOverlay;
@@ -19,31 +19,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
19
19
  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;
20
20
  return c > 3 && r && Object.defineProperty(target, key, r), r;
21
21
  };
22
- var __read = (this && this.__read) || function (o, n) {
23
- var m = typeof Symbol === "function" && o[Symbol.iterator];
24
- if (!m) return o;
25
- var i = m.call(o), r, ar = [], e;
26
- try {
27
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
28
- }
29
- catch (error) { e = { error: error }; }
30
- finally {
31
- try {
32
- if (r && !r.done && (m = i["return"])) m.call(i);
33
- }
34
- finally { if (e) throw e.error; }
35
- }
36
- return ar;
37
- };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
43
- }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
46
- };
47
22
  import { jsx as _jsx } from "preact/jsx-runtime";
48
23
  import { createElement as h, Component } from 'preact/compat';
49
24
  import { OutlineOverlay } from '.';
@@ -51,13 +26,7 @@ import { observer } from '../..';
51
26
  var ToolOverlay = /** @class */ (function (_super) {
52
27
  __extends(ToolOverlay, _super);
53
28
  function ToolOverlay() {
54
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
55
- _this.zoomHandler = function (e) {
56
- var _a;
57
- // TODO 是否应该使用 dispatchEvent 来触发事件
58
- (_a = _this.props.getCanvasOverlay()) === null || _a === void 0 ? void 0 : _a.zoomHandler(e);
59
- };
60
- return _this;
29
+ return _super !== null && _super.apply(this, arguments) || this;
61
30
  }
62
31
  // 在react严格模式下,useEffect会执行两次,但是在LogicFlow内部,则只会触发一次componentDidMount和componentDidUpdate。
63
32
  // 其中第一次componentDidMount对应的graphModel为被丢弃的graphModel, 所以不应该生效。
@@ -95,13 +64,7 @@ var ToolOverlay = /** @class */ (function (_super) {
95
64
  };
96
65
  ToolOverlay.prototype.render = function () {
97
66
  var graphModel = this.props.graphModel;
98
- return (_jsx("div", { className: "lf-tool-overlay", id: "ToolOverlay_".concat(graphModel.flowId),
99
- /*
100
- * 默认情况下该容器设置了 pointer-events: none,不会触发这些事件
101
- * 只会在容器取消 pointer-events: none 后触发,用于缩放、滚动画布等操作
102
- * 目前只在 selection-select 插件中使用。为了能在元素内部进行框选,在开启选区后会关闭事件透传。需要手动触发事件
103
- */
104
- onWheel: this.zoomHandler, children: this.getTools() }));
67
+ return (_jsx("div", { className: "lf-tool-overlay", id: "ToolOverlay_".concat(graphModel.flowId), children: this.getTools() }));
105
68
  };
106
69
  ToolOverlay = __decorate([
107
70
  observer
@@ -263,6 +263,11 @@ export declare class LogicFlow {
263
263
  * @param toFront 是否将选中的元素置顶,默认为true
264
264
  */
265
265
  selectElementById(id: string, multiple?: boolean, toFront?: boolean): void;
266
+ /**
267
+ * 移除选中的元素
268
+ * @param id 元素ID
269
+ */
270
+ deselectElementById(id: string): void;
266
271
  /**
267
272
  * 获取选中的元素数据
268
273
  * @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的边,默认包括。
package/lib/LogicFlow.js CHANGED
@@ -669,6 +669,13 @@ var LogicFlow = /** @class */ (function () {
669
669
  this.graphModel.toFront(id);
670
670
  }
671
671
  };
672
+ /**
673
+ * 移除选中的元素
674
+ * @param id 元素ID
675
+ */
676
+ LogicFlow.prototype.deselectElementById = function (id) {
677
+ this.graphModel.deselectElementById(id);
678
+ };
672
679
  /**
673
680
  * 获取选中的元素数据
674
681
  * @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的边,默认包括。
@@ -322,6 +322,7 @@ export declare class GraphModel {
322
322
  * @param multiple 是否允许多选,如果为true,不会将上一个选中的元素重置
323
323
  */
324
324
  selectElementById(id: string, multiple?: boolean): void;
325
+ deselectElementById(id: string): void;
325
326
  /**
326
327
  * 将所有选中的元素设置为非选中
327
328
  */
@@ -1060,6 +1060,12 @@ var GraphModel = /** @class */ (function () {
1060
1060
  var selectElement = this.getElement(id);
1061
1061
  selectElement === null || selectElement === void 0 ? void 0 : selectElement.setSelected(true);
1062
1062
  };
1063
+ GraphModel.prototype.deselectElementById = function (id) {
1064
+ var element = this.getElement(id);
1065
+ if (element) {
1066
+ element.setSelected(false);
1067
+ }
1068
+ };
1063
1069
  /**
1064
1070
  * 将所有选中的元素设置为非选中
1065
1071
  */
@@ -1596,6 +1602,9 @@ var GraphModel = /** @class */ (function () {
1596
1602
  __decorate([
1597
1603
  mobx_1.action
1598
1604
  ], GraphModel.prototype, "selectElementById", null);
1605
+ __decorate([
1606
+ mobx_1.action
1607
+ ], GraphModel.prototype, "deselectElementById", null);
1599
1608
  __decorate([
1600
1609
  mobx_1.action
1601
1610
  ], GraphModel.prototype, "clearSelectElements", null);
@@ -1,5 +1,4 @@
1
1
  import { Component, ComponentType } from 'preact/compat';
2
- import { CanvasOverlay } from './overlay';
3
2
  import DnD from './behavior/dnd';
4
3
  import Tool from '../tool';
5
4
  import { Options as LFOptions } from '../options';
@@ -13,8 +12,6 @@ type IGraphProps = {
13
12
  graphModel: GraphModel;
14
13
  };
15
14
  declare class Graph extends Component<IGraphProps> {
16
- canvasOverlayRef: import("preact").RefObject<CanvasOverlay>;
17
- getCanvasOverlay: () => CanvasOverlay | null;
18
15
  private handleResize;
19
16
  private throttleResize;
20
17
  componentDidMount(): void;
package/lib/view/Graph.js CHANGED
@@ -56,10 +56,6 @@ var Graph = /** @class */ (function (_super) {
56
56
  __extends(Graph, _super);
57
57
  function Graph() {
58
58
  var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
59
- _this.canvasOverlayRef = (0, compat_1.createRef)();
60
- _this.getCanvasOverlay = function () {
61
- return _this.canvasOverlayRef.current;
62
- };
63
59
  _this.handleResize = function () {
64
60
  var _a = _this.props, graphModel = _a.graphModel, options = _a.options;
65
61
  var width = graphModel.width, height = graphModel.height, isContainerWidth = graphModel.isContainerWidth, isContainerHeight = graphModel.isContainerHeight;
@@ -116,9 +112,9 @@ var Graph = /** @class */ (function (_super) {
116
112
  }
117
113
  var fakeNode = graphModel.fakeNode, editConfigModel = graphModel.editConfigModel, background = graphModel.background;
118
114
  var adjustEdge = editConfigModel.adjustEdge;
119
- return ((0, jsx_runtime_1.jsxs)("div", { className: "lf-graph", "flow-id": graphModel.flowId, style: style, children: [(0, jsx_runtime_1.jsxs)(overlay_1.CanvasOverlay, { ref: this.canvasOverlayRef, graphModel: graphModel, dnd: dnd, children: [(0, jsx_runtime_1.jsx)("g", { className: "lf-base", children: (0, lodash_es_1.map)(graphModel.sortElements, function (nodeModel) {
115
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "lf-graph", "flow-id": graphModel.flowId, style: style, children: [(0, jsx_runtime_1.jsxs)(overlay_1.CanvasOverlay, { graphModel: graphModel, dnd: dnd, children: [(0, jsx_runtime_1.jsx)("g", { className: "lf-base", children: (0, lodash_es_1.map)(graphModel.sortElements, function (nodeModel) {
120
116
  return _this.getComponent(nodeModel, graphModel);
121
- }) }), fakeNode ? this.getComponent(fakeNode, graphModel) : ''] }), (0, jsx_runtime_1.jsxs)(overlay_1.ModificationOverlay, { graphModel: graphModel, children: [(0, jsx_runtime_1.jsx)(overlay_1.OutlineOverlay, { graphModel: graphModel }), adjustEdge ? (0, jsx_runtime_1.jsx)(overlay_1.BezierAdjustOverlay, { graphModel: graphModel }) : '', options.snapline !== false ? ((0, jsx_runtime_1.jsx)(overlay_1.SnaplineOverlay, { snaplineModel: snaplineModel })) : ('')] }), (0, jsx_runtime_1.jsx)(overlay_1.ToolOverlay, { graphModel: graphModel, tool: tool, getCanvasOverlay: this.getCanvasOverlay }), background && (0, jsx_runtime_1.jsx)(overlay_1.BackgroundOverlay, { background: background }), (0, jsx_runtime_1.jsx)(overlay_1.Grid, { graphModel: graphModel })] }));
117
+ }) }), fakeNode ? this.getComponent(fakeNode, graphModel) : ''] }), (0, jsx_runtime_1.jsxs)(overlay_1.ModificationOverlay, { graphModel: graphModel, children: [(0, jsx_runtime_1.jsx)(overlay_1.OutlineOverlay, { graphModel: graphModel }), adjustEdge ? (0, jsx_runtime_1.jsx)(overlay_1.BezierAdjustOverlay, { graphModel: graphModel }) : '', options.snapline !== false ? ((0, jsx_runtime_1.jsx)(overlay_1.SnaplineOverlay, { snaplineModel: snaplineModel })) : ('')] }), (0, jsx_runtime_1.jsx)(overlay_1.ToolOverlay, { graphModel: graphModel, tool: tool }), background && (0, jsx_runtime_1.jsx)(overlay_1.BackgroundOverlay, { background: background }), (0, jsx_runtime_1.jsx)(overlay_1.Grid, { graphModel: graphModel })] }));
122
118
  };
123
119
  Graph = __decorate([
124
120
  __1.observer
@@ -1,11 +1,10 @@
1
1
  import { createElement as h, Component } from 'preact/compat';
2
- import { CanvasOverlay, OutlineOverlay } from '.';
2
+ import { OutlineOverlay } from '.';
3
3
  import { GraphModel } from '../../model';
4
4
  import { Tool } from '../../tool';
5
5
  type IProps = {
6
6
  graphModel: GraphModel;
7
7
  tool: Tool;
8
- getCanvasOverlay: () => CanvasOverlay | null;
9
8
  };
10
9
  export declare class ToolOverlay extends Component<IProps> {
11
10
  componentDidMount(): void;
@@ -15,7 +14,6 @@ export declare class ToolOverlay extends Component<IProps> {
15
14
  */
16
15
  getTools(): import("preact").VNode<import("../..").IToolProps>[];
17
16
  triggerToolRender(): void;
18
- zoomHandler: (e: WheelEvent) => void;
19
17
  render(): h.JSX.Element;
20
18
  }
21
19
  export default OutlineOverlay;
@@ -20,31 +20,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
20
20
  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;
21
21
  return c > 3 && r && Object.defineProperty(target, key, r), r;
22
22
  };
23
- var __read = (this && this.__read) || function (o, n) {
24
- var m = typeof Symbol === "function" && o[Symbol.iterator];
25
- if (!m) return o;
26
- var i = m.call(o), r, ar = [], e;
27
- try {
28
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
29
- }
30
- catch (error) { e = { error: error }; }
31
- finally {
32
- try {
33
- if (r && !r.done && (m = i["return"])) m.call(i);
34
- }
35
- finally { if (e) throw e.error; }
36
- }
37
- return ar;
38
- };
39
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
40
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
41
- if (ar || !(i in from)) {
42
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
43
- ar[i] = from[i];
44
- }
45
- }
46
- return to.concat(ar || Array.prototype.slice.call(from));
47
- };
48
23
  Object.defineProperty(exports, "__esModule", { value: true });
49
24
  exports.ToolOverlay = void 0;
50
25
  var jsx_runtime_1 = require("preact/jsx-runtime");
@@ -54,13 +29,7 @@ var __1 = require("../..");
54
29
  var ToolOverlay = /** @class */ (function (_super) {
55
30
  __extends(ToolOverlay, _super);
56
31
  function ToolOverlay() {
57
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
58
- _this.zoomHandler = function (e) {
59
- var _a;
60
- // TODO 是否应该使用 dispatchEvent 来触发事件
61
- (_a = _this.props.getCanvasOverlay()) === null || _a === void 0 ? void 0 : _a.zoomHandler(e);
62
- };
63
- return _this;
32
+ return _super !== null && _super.apply(this, arguments) || this;
64
33
  }
65
34
  // 在react严格模式下,useEffect会执行两次,但是在LogicFlow内部,则只会触发一次componentDidMount和componentDidUpdate。
66
35
  // 其中第一次componentDidMount对应的graphModel为被丢弃的graphModel, 所以不应该生效。
@@ -98,13 +67,7 @@ var ToolOverlay = /** @class */ (function (_super) {
98
67
  };
99
68
  ToolOverlay.prototype.render = function () {
100
69
  var graphModel = this.props.graphModel;
101
- return ((0, jsx_runtime_1.jsx)("div", { className: "lf-tool-overlay", id: "ToolOverlay_".concat(graphModel.flowId),
102
- /*
103
- * 默认情况下该容器设置了 pointer-events: none,不会触发这些事件
104
- * 只会在容器取消 pointer-events: none 后触发,用于缩放、滚动画布等操作
105
- * 目前只在 selection-select 插件中使用。为了能在元素内部进行框选,在开启选区后会关闭事件透传。需要手动触发事件
106
- */
107
- onWheel: this.zoomHandler, children: this.getTools() }));
70
+ return ((0, jsx_runtime_1.jsx)("div", { className: "lf-tool-overlay", id: "ToolOverlay_".concat(graphModel.flowId), children: this.getTools() }));
108
71
  };
109
72
  ToolOverlay = __decorate([
110
73
  __1.observer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/core",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "description": "LogicFlow, help you quickly create flowcharts",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
package/src/LogicFlow.tsx CHANGED
@@ -733,6 +733,14 @@ export class LogicFlow {
733
733
  }
734
734
  }
735
735
 
736
+ /**
737
+ * 移除选中的元素
738
+ * @param id 元素ID
739
+ */
740
+ deselectElementById(id: string) {
741
+ this.graphModel.deselectElementById(id)
742
+ }
743
+
736
744
  /**
737
745
  * 获取选中的元素数据
738
746
  * @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的边,默认包括。
@@ -1817,7 +1825,7 @@ export namespace LogicFlow {
1817
1825
  * 基础图形线相关主题
1818
1826
  */
1819
1827
  line: EdgeTheme // 直线样式
1820
- polyline: EdgePolylineTheme // 折现样式
1828
+ polyline: EdgePolylineTheme // 折线样式
1821
1829
  bezier: EdgeBezierTheme // 贝塞尔曲线样式
1822
1830
  anchorLine: AnchorLineTheme // 从锚点拉出的边的样式
1823
1831
 
@@ -1197,6 +1197,14 @@ export class GraphModel {
1197
1197
  selectElement?.setSelected(true)
1198
1198
  }
1199
1199
 
1200
+ @action
1201
+ deselectElementById(id: string) {
1202
+ const element = this.getElement(id)
1203
+ if (element) {
1204
+ element.setSelected(false)
1205
+ }
1206
+ }
1207
+
1200
1208
  /**
1201
1209
  * 将所有选中的元素设置为非选中
1202
1210
  */
@@ -1,4 +1,4 @@
1
- import { Component, ComponentType, createRef } from 'preact/compat'
1
+ import { Component, ComponentType } from 'preact/compat'
2
2
  import { map, throttle } from 'lodash-es'
3
3
  import {
4
4
  CanvasOverlay,
@@ -38,10 +38,6 @@ type ContainerStyle = {
38
38
 
39
39
  @observer
40
40
  class Graph extends Component<IGraphProps> {
41
- canvasOverlayRef = createRef<CanvasOverlay>()
42
- getCanvasOverlay = () => {
43
- return this.canvasOverlayRef.current
44
- }
45
41
  private handleResize = () => {
46
42
  const { graphModel, options } = this.props
47
43
  const { width, height, isContainerWidth, isContainerHeight } = graphModel
@@ -113,11 +109,7 @@ class Graph extends Component<IGraphProps> {
113
109
  return (
114
110
  <div className="lf-graph" flow-id={graphModel.flowId} style={style}>
115
111
  {/* 元素层 */}
116
- <CanvasOverlay
117
- ref={this.canvasOverlayRef}
118
- graphModel={graphModel}
119
- dnd={dnd}
120
- >
112
+ <CanvasOverlay graphModel={graphModel} dnd={dnd}>
121
113
  <g className="lf-base">
122
114
  {map(graphModel.sortElements, (nodeModel) =>
123
115
  this.getComponent(nodeModel, graphModel),
@@ -136,11 +128,7 @@ class Graph extends Component<IGraphProps> {
136
128
  )}
137
129
  </ModificationOverlay>
138
130
  {/* 工具层:插件 */}
139
- <ToolOverlay
140
- graphModel={graphModel}
141
- tool={tool}
142
- getCanvasOverlay={this.getCanvasOverlay}
143
- />
131
+ <ToolOverlay graphModel={graphModel} tool={tool} />
144
132
  {/* 画布背景 */}
145
133
  {background && <BackgroundOverlay background={background} />}
146
134
  {/* 画布网格 */}
@@ -1,5 +1,5 @@
1
1
  import { createElement as h, Component } from 'preact/compat'
2
- import { CanvasOverlay, OutlineOverlay } from '.'
2
+ import { OutlineOverlay } from '.'
3
3
  import { observer } from '../..'
4
4
  import LogicFlow from '../../LogicFlow'
5
5
  import { GraphModel } from '../../model'
@@ -8,7 +8,6 @@ import { Tool } from '../../tool'
8
8
  type IProps = {
9
9
  graphModel: GraphModel
10
10
  tool: Tool
11
- getCanvasOverlay: () => CanvasOverlay | null
12
11
  }
13
12
 
14
13
  @observer
@@ -53,24 +52,10 @@ export class ToolOverlay extends Component<IProps> {
53
52
  lf.components = [] // 保证extension组件的render只执行一次
54
53
  }
55
54
 
56
- zoomHandler = (e: WheelEvent) => {
57
- // TODO 是否应该使用 dispatchEvent 来触发事件
58
- this.props.getCanvasOverlay()?.zoomHandler(e)
59
- }
60
-
61
55
  render() {
62
56
  const { graphModel } = this.props
63
57
  return (
64
- <div
65
- className="lf-tool-overlay"
66
- id={`ToolOverlay_${graphModel.flowId}`}
67
- /*
68
- * 默认情况下该容器设置了 pointer-events: none,不会触发这些事件
69
- * 只会在容器取消 pointer-events: none 后触发,用于缩放、滚动画布等操作
70
- * 目前只在 selection-select 插件中使用。为了能在元素内部进行框选,在开启选区后会关闭事件透传。需要手动触发事件
71
- */
72
- onWheel={this.zoomHandler}
73
- >
58
+ <div className="lf-tool-overlay" id={`ToolOverlay_${graphModel.flowId}`}>
74
59
  {this.getTools()}
75
60
  </div>
76
61
  )