@logicflow/core 2.0.11 → 2.0.12
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 +7 -7
- package/CHANGELOG.md +9 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/constant/index.d.ts +2 -0
- package/es/constant/index.js +2 -0
- package/es/event/eventArgs.d.ts +8 -0
- package/es/model/GraphModel.js +3 -0
- package/es/model/edge/BezierEdgeModel.js +3 -0
- package/es/model/edge/PolylineEdgeModel.js +3 -0
- package/es/view/Anchor.js +15 -2
- package/es/view/Control.d.ts +1 -0
- package/es/view/Control.js +4 -0
- package/es/view/Graph.d.ts +3 -0
- package/es/view/Graph.js +7 -3
- package/es/view/overlay/ToolOverlay.d.ts +3 -1
- package/es/view/overlay/ToolOverlay.js +39 -2
- package/lib/constant/index.d.ts +2 -0
- package/lib/constant/index.js +2 -0
- package/lib/event/eventArgs.d.ts +8 -0
- package/lib/model/GraphModel.js +3 -0
- package/lib/model/edge/BezierEdgeModel.js +3 -0
- package/lib/model/edge/PolylineEdgeModel.js +3 -0
- package/lib/view/Anchor.js +15 -2
- package/lib/view/Control.d.ts +1 -0
- package/lib/view/Control.js +4 -0
- package/lib/view/Graph.d.ts +3 -0
- package/lib/view/Graph.js +6 -2
- package/lib/view/overlay/ToolOverlay.d.ts +3 -1
- package/lib/view/overlay/ToolOverlay.js +39 -2
- package/package.json +1 -1
- package/src/constant/index.ts +2 -0
- package/src/event/eventArgs.ts +8 -0
- package/src/model/GraphModel.ts +1 -1
- package/src/model/edge/BezierEdgeModel.ts +1 -1
- package/src/model/edge/PolylineEdgeModel.ts +1 -1
- package/src/view/Anchor.tsx +15 -4
- package/src/view/Control.tsx +5 -0
- package/src/view/Graph.tsx +15 -3
- package/src/view/overlay/ToolOverlay.tsx +17 -2
- package/stats.html +1 -1
package/src/view/Graph.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, ComponentType } from 'preact/compat'
|
|
1
|
+
import { Component, ComponentType, createRef } from 'preact/compat'
|
|
2
2
|
import { map, throttle } from 'lodash-es'
|
|
3
3
|
import {
|
|
4
4
|
CanvasOverlay,
|
|
@@ -38,6 +38,10 @@ 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
|
+
}
|
|
41
45
|
private handleResize = () => {
|
|
42
46
|
const { graphModel, options } = this.props
|
|
43
47
|
const { width, height, isContainerWidth, isContainerHeight } = graphModel
|
|
@@ -109,7 +113,11 @@ class Graph extends Component<IGraphProps> {
|
|
|
109
113
|
return (
|
|
110
114
|
<div className="lf-graph" flow-id={graphModel.flowId} style={style}>
|
|
111
115
|
{/* 元素层 */}
|
|
112
|
-
<CanvasOverlay
|
|
116
|
+
<CanvasOverlay
|
|
117
|
+
ref={this.canvasOverlayRef}
|
|
118
|
+
graphModel={graphModel}
|
|
119
|
+
dnd={dnd}
|
|
120
|
+
>
|
|
113
121
|
<g className="lf-base">
|
|
114
122
|
{map(graphModel.sortElements, (nodeModel) =>
|
|
115
123
|
this.getComponent(nodeModel, graphModel),
|
|
@@ -128,7 +136,11 @@ class Graph extends Component<IGraphProps> {
|
|
|
128
136
|
)}
|
|
129
137
|
</ModificationOverlay>
|
|
130
138
|
{/* 工具层:插件 */}
|
|
131
|
-
<ToolOverlay
|
|
139
|
+
<ToolOverlay
|
|
140
|
+
graphModel={graphModel}
|
|
141
|
+
tool={tool}
|
|
142
|
+
getCanvasOverlay={this.getCanvasOverlay}
|
|
143
|
+
/>
|
|
132
144
|
{/* 画布背景 */}
|
|
133
145
|
{background && <BackgroundOverlay background={background} />}
|
|
134
146
|
{/* 画布网格 */}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createElement as h, Component } from 'preact/compat'
|
|
2
|
-
import { OutlineOverlay } from '.'
|
|
2
|
+
import { CanvasOverlay, OutlineOverlay } from '.'
|
|
3
3
|
import { observer } from '../..'
|
|
4
4
|
import LogicFlow from '../../LogicFlow'
|
|
5
5
|
import { GraphModel } from '../../model'
|
|
@@ -8,6 +8,7 @@ import { Tool } from '../../tool'
|
|
|
8
8
|
type IProps = {
|
|
9
9
|
graphModel: GraphModel
|
|
10
10
|
tool: Tool
|
|
11
|
+
getCanvasOverlay: () => CanvasOverlay | null
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
@observer
|
|
@@ -52,10 +53,24 @@ export class ToolOverlay extends Component<IProps> {
|
|
|
52
53
|
lf.components = [] // 保证extension组件的render只执行一次
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
zoomHandler = (e: WheelEvent) => {
|
|
57
|
+
// TODO 是否应该使用 dispatchEvent 来触发事件
|
|
58
|
+
this.props.getCanvasOverlay()?.zoomHandler(e)
|
|
59
|
+
}
|
|
60
|
+
|
|
55
61
|
render() {
|
|
56
62
|
const { graphModel } = this.props
|
|
57
63
|
return (
|
|
58
|
-
<div
|
|
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
|
+
>
|
|
59
74
|
{this.getTools()}
|
|
60
75
|
</div>
|
|
61
76
|
)
|