|
@@ -1,5 +1,5 @@
|
1
|
1
|
import * as React from 'react'
|
2
|
|
-import { Utils, TLBounds, TLPointerInfo, SVGContainer } from '@tldraw/core'
|
|
2
|
+import { Utils, TLBounds, SVGContainer } from '@tldraw/core'
|
3
|
3
|
import { Vec } from '@tldraw/vec'
|
4
|
4
|
import { defaultStyle, getShapeStyle } from '../shared/shape-styles'
|
5
|
5
|
import {
|
|
@@ -47,45 +47,47 @@ export class ArrowUtil extends TDShapeUtil<T, E> {
|
47
|
47
|
pathCache = new WeakMap<T, string>()
|
48
|
48
|
|
49
|
49
|
getShape = (props: Partial<T>): T => {
|
50
|
|
- return Utils.deepMerge<T>(
|
51
|
|
- {
|
52
|
|
- id: 'id',
|
53
|
|
- type: TDShapeType.Arrow,
|
54
|
|
- name: 'Arrow',
|
55
|
|
- parentId: 'page',
|
56
|
|
- childIndex: 1,
|
57
|
|
- point: [0, 0],
|
58
|
|
- rotation: 0,
|
59
|
|
- bend: 0,
|
60
|
|
- handles: {
|
61
|
|
- start: {
|
62
|
|
- id: 'start',
|
63
|
|
- index: 0,
|
64
|
|
- point: [0, 0],
|
65
|
|
- canBind: true,
|
66
|
|
- },
|
67
|
|
- end: {
|
68
|
|
- id: 'end',
|
69
|
|
- index: 1,
|
70
|
|
- point: [1, 1],
|
71
|
|
- canBind: true,
|
72
|
|
- },
|
73
|
|
- bend: {
|
74
|
|
- id: 'bend',
|
75
|
|
- index: 2,
|
76
|
|
- point: [0.5, 0.5],
|
77
|
|
- },
|
|
50
|
+ return {
|
|
51
|
+ id: 'id',
|
|
52
|
+ type: TDShapeType.Arrow,
|
|
53
|
+ name: 'Arrow',
|
|
54
|
+ parentId: 'page',
|
|
55
|
+ childIndex: 1,
|
|
56
|
+ point: [0, 0],
|
|
57
|
+ rotation: 0,
|
|
58
|
+ bend: 0,
|
|
59
|
+ handles: {
|
|
60
|
+ start: {
|
|
61
|
+ id: 'start',
|
|
62
|
+ index: 0,
|
|
63
|
+ point: [0, 0],
|
|
64
|
+ canBind: true,
|
|
65
|
+ ...props.handles?.start,
|
78
|
66
|
},
|
79
|
|
- decorations: {
|
80
|
|
- end: Decoration.Arrow,
|
|
67
|
+ end: {
|
|
68
|
+ id: 'end',
|
|
69
|
+ index: 1,
|
|
70
|
+ point: [1, 1],
|
|
71
|
+ canBind: true,
|
|
72
|
+ ...props.handles?.end,
|
81
|
73
|
},
|
82
|
|
- style: {
|
83
|
|
- ...defaultStyle,
|
84
|
|
- isFilled: false,
|
|
74
|
+ bend: {
|
|
75
|
+ id: 'bend',
|
|
76
|
+ index: 2,
|
|
77
|
+ point: [0.5, 0.5],
|
|
78
|
+ ...props.handles?.bend,
|
85
|
79
|
},
|
86
|
80
|
},
|
87
|
|
- props
|
88
|
|
- )
|
|
81
|
+ decorations: props.decorations ?? {
|
|
82
|
+ end: Decoration.Arrow,
|
|
83
|
+ },
|
|
84
|
+ style: {
|
|
85
|
+ ...defaultStyle,
|
|
86
|
+ isFilled: false,
|
|
87
|
+ ...props.style,
|
|
88
|
+ },
|
|
89
|
+ ...props,
|
|
90
|
+ }
|
89
|
91
|
}
|
90
|
92
|
|
91
|
93
|
Component = TDShapeUtil.Component<T, E, TDMeta>(({ shape, isGhost, meta, events }, ref) => {
|