@logicflow/core 2.0.6 → 2.0.7
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 +21 -0
- package/__tests__/algorithm/egde.test.ts +36 -23
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/event/eventArgs.d.ts +23 -29
- package/es/model/GraphModel.d.ts +10 -0
- package/es/model/GraphModel.js +26 -1
- package/es/model/edge/BaseEdgeModel.d.ts +1 -0
- package/es/model/node/BaseNodeModel.js +1 -1
- package/es/util/drag.d.ts +1 -0
- package/es/util/drag.js +11 -0
- package/es/view/Anchor.js +6 -8
- package/es/view/Control.js +1 -1
- package/es/view/Graph.js +3 -15
- package/es/view/behavior/dnd.js +1 -0
- package/es/view/edge/BaseEdge.d.ts +3 -1
- package/es/view/edge/BaseEdge.js +8 -5
- package/es/view/overlay/BackgroundOverlay.d.ts +4 -14
- package/es/view/overlay/BackgroundOverlay.js +11 -1
- package/es/view/overlay/Grid.d.ts +4 -3
- package/es/view/overlay/Grid.js +8 -31
- package/es/view/text/BaseText.js +1 -1
- package/lib/event/eventArgs.d.ts +23 -29
- package/lib/model/GraphModel.d.ts +10 -0
- package/lib/model/GraphModel.js +25 -0
- package/lib/model/edge/BaseEdgeModel.d.ts +1 -0
- package/lib/model/node/BaseNodeModel.js +1 -1
- package/lib/util/drag.d.ts +1 -0
- package/lib/util/drag.js +11 -0
- package/lib/view/Anchor.js +6 -8
- package/lib/view/Control.js +1 -1
- package/lib/view/Graph.js +3 -15
- package/lib/view/behavior/dnd.js +1 -0
- package/lib/view/edge/BaseEdge.d.ts +3 -1
- package/lib/view/edge/BaseEdge.js +8 -5
- package/lib/view/overlay/BackgroundOverlay.d.ts +4 -14
- package/lib/view/overlay/BackgroundOverlay.js +11 -1
- package/lib/view/overlay/Grid.d.ts +4 -3
- package/lib/view/overlay/Grid.js +8 -31
- package/lib/view/text/BaseText.js +1 -1
- package/package.json +1 -1
- package/src/algorithm/edge.ts +2 -4
- package/src/event/eventArgs.ts +23 -29
- package/src/model/GraphModel.ts +12 -1
- package/src/model/edge/BaseEdgeModel.ts +1 -0
- package/src/model/node/BaseNodeModel.ts +1 -1
- package/src/model/node/HtmlNodeModel.ts +1 -1
- package/src/util/drag.ts +12 -0
- package/src/view/Anchor.tsx +7 -8
- package/src/view/Control.tsx +1 -1
- package/src/view/Graph.tsx +2 -3
- package/src/view/behavior/dnd.ts +1 -0
- package/src/view/edge/BaseEdge.tsx +8 -3
- package/src/view/overlay/Grid.tsx +13 -9
- package/src/view/text/BaseText.tsx +1 -1
- package/stats.html +1 -1
package/src/view/behavior/dnd.ts
CHANGED
|
@@ -29,6 +29,7 @@ export abstract class BaseEdge<P extends IProps> extends Component<
|
|
|
29
29
|
> {
|
|
30
30
|
static isObserved: boolean = false
|
|
31
31
|
static extendsKey?: string
|
|
32
|
+
mouseUpDrag?: boolean
|
|
32
33
|
|
|
33
34
|
startTime?: number
|
|
34
35
|
contextMenuTime?: number
|
|
@@ -385,13 +386,16 @@ export abstract class BaseEdge<P extends IProps> extends Component<
|
|
|
385
386
|
e.stopPropagation()
|
|
386
387
|
this.startTime = new Date().getTime()
|
|
387
388
|
}
|
|
389
|
+
handleMouseUp = () => {
|
|
390
|
+
const { model } = this.props
|
|
391
|
+
this.mouseUpDrag = model.isDragging
|
|
392
|
+
}
|
|
388
393
|
/**
|
|
389
394
|
* 不支持重写
|
|
390
395
|
*/
|
|
391
|
-
|
|
396
|
+
handleClick = (e: MouseEvent) => {
|
|
392
397
|
if (!this.startTime) return
|
|
393
|
-
|
|
394
|
-
if (time > 200) return // 事件大于200ms,认为是拖拽。
|
|
398
|
+
if (this.mouseUpDrag) return // 如果是拖拽,不触发click事件。
|
|
395
399
|
const isRightClick = e.button === 2
|
|
396
400
|
if (isRightClick) return
|
|
397
401
|
// 这里 IE 11不能正确显示
|
|
@@ -490,6 +494,7 @@ export abstract class BaseEdge<P extends IProps> extends Component<
|
|
|
490
494
|
.join(' ')}
|
|
491
495
|
onMouseDown={this.handleMouseDown}
|
|
492
496
|
onMouseUp={this.handleMouseUp}
|
|
497
|
+
onClick={this.handleClick}
|
|
493
498
|
onContextMenu={this.handleContextMenu}
|
|
494
499
|
onMouseOver={this.setHoverOn}
|
|
495
500
|
onMouseEnter={this.setHoverOn}
|
|
@@ -5,19 +5,24 @@ import { createUuid } from '../../util'
|
|
|
5
5
|
import { GraphModel } from '../../model'
|
|
6
6
|
import { DEFAULT_GRID_SIZE } from '../../constant'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type IProps = GridOptions & {
|
|
8
|
+
type IProps = {
|
|
11
9
|
graphModel: GraphModel
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
@observer
|
|
15
13
|
export class Grid extends Component<IProps> {
|
|
14
|
+
gridOptions: Grid.GridOptions
|
|
15
|
+
|
|
16
16
|
readonly id = createUuid()
|
|
17
17
|
|
|
18
|
+
constructor(props: IProps) {
|
|
19
|
+
super(props)
|
|
20
|
+
this.gridOptions = this.props.graphModel.grid
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
// 网格类型为点状
|
|
19
24
|
renderDot() {
|
|
20
|
-
const { config, size = 1, visible } = this.
|
|
25
|
+
const { config, size = 1, visible } = this.gridOptions
|
|
21
26
|
|
|
22
27
|
const { color, thickness = 2 } = config ?? {}
|
|
23
28
|
|
|
@@ -37,7 +42,7 @@ export class Grid extends Component<IProps> {
|
|
|
37
42
|
// 网格类型为交叉线
|
|
38
43
|
// todo: 采用背景缩放的方式,实现更好的体验
|
|
39
44
|
renderMesh() {
|
|
40
|
-
const { config, size = 1, visible } = this.
|
|
45
|
+
const { config, size = 1, visible } = this.gridOptions
|
|
41
46
|
const { color, thickness = 1 } = config ?? {}
|
|
42
47
|
|
|
43
48
|
// 对于交叉线网格,线的宽度不能大于网格大小的一半
|
|
@@ -48,7 +53,7 @@ export class Grid extends Component<IProps> {
|
|
|
48
53
|
<path
|
|
49
54
|
d={d}
|
|
50
55
|
stroke={color}
|
|
51
|
-
strokeWidth={strokeWidth}
|
|
56
|
+
strokeWidth={strokeWidth / 2}
|
|
52
57
|
opacity={opacity}
|
|
53
58
|
fill="transparent"
|
|
54
59
|
/>
|
|
@@ -57,10 +62,9 @@ export class Grid extends Component<IProps> {
|
|
|
57
62
|
|
|
58
63
|
render() {
|
|
59
64
|
const {
|
|
60
|
-
type,
|
|
61
|
-
size = 1,
|
|
62
65
|
graphModel: { transformModel },
|
|
63
66
|
} = this.props
|
|
67
|
+
const { type, size = 1 } = this.gridOptions
|
|
64
68
|
const { SCALE_X, SKEW_Y, SKEW_X, SCALE_Y, TRANSLATE_X, TRANSLATE_Y } =
|
|
65
69
|
transformModel
|
|
66
70
|
const matrixString = [
|
|
@@ -124,7 +128,7 @@ export namespace Grid {
|
|
|
124
128
|
/**
|
|
125
129
|
* 网格的颜色
|
|
126
130
|
*/
|
|
127
|
-
color
|
|
131
|
+
color?: string
|
|
128
132
|
/**
|
|
129
133
|
* 网格的宽度
|
|
130
134
|
* - 对于 `dot` 点状网格,表示点的大小
|