aldehyde 0.2.473 → 0.2.475

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.
Files changed (203) hide show
  1. package/lib/controls/action/utils.d.ts +1 -1
  2. package/lib/controls/entity-select/entity-select.d.ts +2 -2
  3. package/lib/controls/entity-select/entity-select.d.ts.map +1 -1
  4. package/lib/controls/entity-select/entity-select.js +16 -7
  5. package/lib/controls/entity-select/entity-select.js.map +1 -1
  6. package/lib/controls/entry-control.d.ts.map +1 -1
  7. package/lib/controls/entry-control.js +3 -2
  8. package/lib/controls/entry-control.js.map +1 -1
  9. package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +47 -3
  10. package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.js +12 -12
  11. package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.js.map +1 -1
  12. package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.json +77 -0
  13. package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.ttf +0 -0
  14. package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.woff +0 -0
  15. package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.woff2 +0 -0
  16. package/lib/controls/select/index.d.ts.map +1 -1
  17. package/lib/controls/select/index.js +13 -7
  18. package/lib/controls/select/index.js.map +1 -1
  19. package/lib/controls/text/index.less +1 -0
  20. package/lib/controls/view-control.d.ts.map +1 -1
  21. package/lib/controls/view-control.js +1 -0
  22. package/lib/controls/view-control.js.map +1 -1
  23. package/lib/detail/button/edit-button.d.ts.map +1 -1
  24. package/lib/detail/button/edit-button.js +23 -11
  25. package/lib/detail/button/edit-button.js.map +1 -1
  26. package/lib/detail/button/view-button.d.ts.map +1 -1
  27. package/lib/detail/button/view-button.js +21 -10
  28. package/lib/detail/button/view-button.js.map +1 -1
  29. package/lib/draw-canvas/edit/components/asset-bar/index.d.ts +5 -0
  30. package/lib/draw-canvas/edit/components/asset-bar/index.d.ts.map +1 -0
  31. package/lib/draw-canvas/edit/components/asset-bar/index.js +79 -0
  32. package/lib/draw-canvas/edit/components/asset-bar/index.js.map +1 -0
  33. package/lib/draw-canvas/edit/components/asset-bar/index.less +36 -0
  34. package/lib/draw-canvas/edit/components/main-header/index.d.ts +19 -0
  35. package/lib/draw-canvas/edit/components/main-header/index.d.ts.map +1 -0
  36. package/lib/draw-canvas/edit/components/main-header/index.js +203 -0
  37. package/lib/draw-canvas/edit/components/main-header/index.js.map +1 -0
  38. package/lib/draw-canvas/edit/components/main-header/index.less +21 -0
  39. package/lib/draw-canvas/edit/components/render/index.d.ts +90 -0
  40. package/lib/draw-canvas/edit/components/render/index.d.ts.map +1 -0
  41. package/lib/draw-canvas/edit/components/render/index.js +692 -0
  42. package/lib/draw-canvas/edit/components/render/index.js.map +1 -0
  43. package/lib/draw-canvas/edit/components/render/types.d.ts +247 -0
  44. package/lib/draw-canvas/edit/components/render/types.d.ts.map +1 -0
  45. package/lib/draw-canvas/edit/components/render/types.js +66 -0
  46. package/lib/draw-canvas/edit/components/render/types.js.map +1 -0
  47. package/lib/draw-canvas/edit/components/setting-form/imag-upload.d.ts +26 -0
  48. package/lib/draw-canvas/edit/components/setting-form/imag-upload.d.ts.map +1 -0
  49. package/lib/draw-canvas/edit/components/setting-form/imag-upload.js +83 -0
  50. package/lib/draw-canvas/edit/components/setting-form/imag-upload.js.map +1 -0
  51. package/lib/draw-canvas/edit/components/setting-form/index.d.ts +17 -0
  52. package/lib/draw-canvas/edit/components/setting-form/index.d.ts.map +1 -0
  53. package/lib/draw-canvas/edit/components/setting-form/index.js +243 -0
  54. package/lib/draw-canvas/edit/components/setting-form/index.js.map +1 -0
  55. package/lib/draw-canvas/edit/constant.d.ts +7 -0
  56. package/lib/draw-canvas/edit/constant.d.ts.map +1 -0
  57. package/lib/draw-canvas/edit/constant.js +7 -0
  58. package/lib/draw-canvas/edit/constant.js.map +1 -0
  59. package/lib/draw-canvas/edit/index.d.ts +8 -0
  60. package/lib/draw-canvas/edit/index.d.ts.map +1 -0
  61. package/lib/draw-canvas/edit/index.js +165 -0
  62. package/lib/draw-canvas/edit/index.js.map +1 -0
  63. package/lib/draw-canvas/edit/index.less +49 -0
  64. package/lib/draw-canvas/view/index.d.ts +8 -0
  65. package/lib/draw-canvas/view/index.d.ts.map +1 -0
  66. package/lib/draw-canvas/view/index.js +50 -0
  67. package/lib/draw-canvas/view/index.js.map +1 -0
  68. package/lib/draw-canvas/view/index.less +60 -0
  69. package/lib/draw-canvas/view/view.d.ts +10 -0
  70. package/lib/draw-canvas/view/view.d.ts.map +1 -0
  71. package/lib/draw-canvas/view/view.js +104 -0
  72. package/lib/draw-canvas/view/view.js.map +1 -0
  73. package/lib/form/form-Item-group.d.ts.map +1 -1
  74. package/lib/form/form-Item-group.js +4 -4
  75. package/lib/form/form-Item-group.js.map +1 -1
  76. package/lib/icon/local-aliIcon/iconfont.js +5 -5
  77. package/lib/icon/local-aliIcon/iconfont.js.map +1 -1
  78. package/lib/lowcode-components/index.d.ts +2 -0
  79. package/lib/lowcode-components/index.d.ts.map +1 -1
  80. package/lib/lowcode-components/index.js +2 -1
  81. package/lib/lowcode-components/index.js.map +1 -1
  82. package/lib/lowcode-components/lowcode-view/component/assets.d.ts.map +1 -1
  83. package/lib/lowcode-components/lowcode-view/component/assets.js +8 -0
  84. package/lib/lowcode-components/lowcode-view/component/assets.js.map +1 -1
  85. package/lib/lowcode-components/radar-chart/index.d.ts +51 -0
  86. package/lib/lowcode-components/radar-chart/index.d.ts.map +1 -0
  87. package/lib/lowcode-components/radar-chart/index.js +276 -0
  88. package/lib/lowcode-components/radar-chart/index.js.map +1 -0
  89. package/lib/module/dtmpl-edit-card.d.ts.map +1 -1
  90. package/lib/module/dtmpl-edit-card.js +18 -1
  91. package/lib/module/dtmpl-edit-card.js.map +1 -1
  92. package/lib/module/dtmpl-edit-page.d.ts.map +1 -1
  93. package/lib/module/dtmpl-edit-page.js +19 -2
  94. package/lib/module/dtmpl-edit-page.js.map +1 -1
  95. package/lib/routable/ltmpl-route.d.ts +2 -0
  96. package/lib/routable/ltmpl-route.d.ts.map +1 -1
  97. package/lib/routable/ltmpl-route.js +20 -4
  98. package/lib/routable/ltmpl-route.js.map +1 -1
  99. package/lib/table/act-table.d.ts +2 -0
  100. package/lib/table/act-table.d.ts.map +1 -1
  101. package/lib/table/act-table.js +4 -4
  102. package/lib/table/act-table.js.map +1 -1
  103. package/lib/table/column/column-builder.d.ts.map +1 -1
  104. package/lib/table/column/column-builder.js +23 -8
  105. package/lib/table/column/column-builder.js.map +1 -1
  106. package/lib/table/relation-table.d.ts +7 -0
  107. package/lib/table/relation-table.d.ts.map +1 -1
  108. package/lib/tmpl/control-type-supportor.d.ts.map +1 -1
  109. package/lib/tmpl/control-type-supportor.js +1 -0
  110. package/lib/tmpl/control-type-supportor.js.map +1 -1
  111. package/lib/tmpl/hcservice-v3.d.ts +3 -0
  112. package/lib/tmpl/hcservice-v3.d.ts.map +1 -1
  113. package/lib/tmpl/hcservice-v3.js +61 -0
  114. package/lib/tmpl/hcservice-v3.js.map +1 -1
  115. package/lib/tmpl/interface.d.ts +17 -1
  116. package/lib/tmpl/interface.d.ts.map +1 -1
  117. package/lib/tmpl/interface.js.map +1 -1
  118. package/lib/tmpl/tmpl-config-analysis.js +1 -1
  119. package/lib/tmpl/tmpl-config-analysis.js.map +1 -1
  120. package/lib/units/index.d.ts +3 -1
  121. package/lib/units/index.d.ts.map +1 -1
  122. package/lib/units/index.js +33 -3
  123. package/lib/units/index.js.map +1 -1
  124. package/package.json +4 -1
  125. package/src/aldehyde/controls/entity-select/entity-select.tsx +18 -8
  126. package/src/aldehyde/controls/entry-control.tsx +3 -2
  127. package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +47 -3
  128. package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.js +1 -1
  129. package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.json +77 -0
  130. package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.ttf +0 -0
  131. package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.woff +0 -0
  132. package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.woff2 +0 -0
  133. package/src/aldehyde/controls/select/index.tsx +7 -6
  134. package/src/aldehyde/controls/text/index.less +1 -0
  135. package/src/aldehyde/controls/view-control.tsx +1 -0
  136. package/src/aldehyde/detail/button/edit-button.tsx +21 -22
  137. package/src/aldehyde/detail/button/view-button.tsx +23 -21
  138. package/src/aldehyde/draw-canvas/edit/components/asset-bar/index.less +36 -0
  139. package/src/aldehyde/draw-canvas/edit/components/asset-bar/index.tsx +95 -0
  140. package/src/aldehyde/draw-canvas/edit/components/main-header/index.less +21 -0
  141. package/src/aldehyde/draw-canvas/edit/components/main-header/index.tsx +233 -0
  142. package/src/aldehyde/draw-canvas/edit/components/render/draws/bg-draw.ts +163 -0
  143. package/src/aldehyde/draw-canvas/edit/components/render/draws/contextmenu-draw.ts +307 -0
  144. package/src/aldehyde/draw-canvas/edit/components/render/draws/graph-draw.ts +251 -0
  145. package/src/aldehyde/draw-canvas/edit/components/render/draws/index.ts +7 -0
  146. package/src/aldehyde/draw-canvas/edit/components/render/draws/link-draw.ts +1416 -0
  147. package/src/aldehyde/draw-canvas/edit/components/render/draws/preview-draw.ts +275 -0
  148. package/src/aldehyde/draw-canvas/edit/components/render/draws/ref-line-draw.ts +72 -0
  149. package/src/aldehyde/draw-canvas/edit/components/render/draws/ruler-draw.ts +167 -0
  150. package/src/aldehyde/draw-canvas/edit/components/render/graphs/base-graph.ts +241 -0
  151. package/src/aldehyde/draw-canvas/edit/components/render/graphs/bezier.ts +542 -0
  152. package/src/aldehyde/draw-canvas/edit/components/render/graphs/circle.ts +700 -0
  153. package/src/aldehyde/draw-canvas/edit/components/render/graphs/curve.ts +501 -0
  154. package/src/aldehyde/draw-canvas/edit/components/render/graphs/index.ts +6 -0
  155. package/src/aldehyde/draw-canvas/edit/components/render/graphs/line.ts +494 -0
  156. package/src/aldehyde/draw-canvas/edit/components/render/graphs/rect.ts +681 -0
  157. package/src/aldehyde/draw-canvas/edit/components/render/handlers/drag-handlers.ts +69 -0
  158. package/src/aldehyde/draw-canvas/edit/components/render/handlers/drag-outside-handlers.ts +159 -0
  159. package/src/aldehyde/draw-canvas/edit/components/render/handlers/graph-handlers.ts +108 -0
  160. package/src/aldehyde/draw-canvas/edit/components/render/handlers/index.ts +9 -0
  161. package/src/aldehyde/draw-canvas/edit/components/render/handlers/key-move-handlers.ts +50 -0
  162. package/src/aldehyde/draw-canvas/edit/components/render/handlers/link-handlers.ts +46 -0
  163. package/src/aldehyde/draw-canvas/edit/components/render/handlers/selection-handlers.ts +393 -0
  164. package/src/aldehyde/draw-canvas/edit/components/render/handlers/shutcut-handlers.ts +46 -0
  165. package/src/aldehyde/draw-canvas/edit/components/render/handlers/text-handlers.ts +82 -0
  166. package/src/aldehyde/draw-canvas/edit/components/render/handlers/zoom-handlers.ts +60 -0
  167. package/src/aldehyde/draw-canvas/edit/components/render/index.ts +776 -0
  168. package/src/aldehyde/draw-canvas/edit/components/render/tools/align-tool.ts +91 -0
  169. package/src/aldehyde/draw-canvas/edit/components/render/tools/asset-tool.ts +142 -0
  170. package/src/aldehyde/draw-canvas/edit/components/render/tools/attract-tool.ts +440 -0
  171. package/src/aldehyde/draw-canvas/edit/components/render/tools/copy-tool.ts +269 -0
  172. package/src/aldehyde/draw-canvas/edit/components/render/tools/import-export-tool.ts +603 -0
  173. package/src/aldehyde/draw-canvas/edit/components/render/tools/index.ts +9 -0
  174. package/src/aldehyde/draw-canvas/edit/components/render/tools/link-tool.ts +225 -0
  175. package/src/aldehyde/draw-canvas/edit/components/render/tools/position-tool.ts +194 -0
  176. package/src/aldehyde/draw-canvas/edit/components/render/tools/selection-tool.ts +132 -0
  177. package/src/aldehyde/draw-canvas/edit/components/render/tools/z-index-tool.ts +227 -0
  178. package/src/aldehyde/draw-canvas/edit/components/render/types.ts +291 -0
  179. package/src/aldehyde/draw-canvas/edit/components/render/utils/a-star.ts +116 -0
  180. package/src/aldehyde/draw-canvas/edit/components/render/utils/bezier-scene-func.ts +73 -0
  181. package/src/aldehyde/draw-canvas/edit/components/setting-form/imag-upload.tsx +118 -0
  182. package/src/aldehyde/draw-canvas/edit/components/setting-form/index.tsx +295 -0
  183. package/src/aldehyde/draw-canvas/edit/constant.ts +6 -0
  184. package/src/aldehyde/draw-canvas/edit/index.less +49 -0
  185. package/src/aldehyde/draw-canvas/edit/index.tsx +197 -0
  186. package/src/aldehyde/draw-canvas/view/index.less +60 -0
  187. package/src/aldehyde/draw-canvas/view/index.tsx +48 -0
  188. package/src/aldehyde/draw-canvas/view/view.tsx +114 -0
  189. package/src/aldehyde/form/form-Item-group.tsx +5 -5
  190. package/src/aldehyde/icon/local-aliIcon/iconfont.js +1 -1
  191. package/src/aldehyde/lowcode-components/index.ts +4 -2
  192. package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +8 -0
  193. package/src/aldehyde/lowcode-components/radar-chart/index.tsx +323 -0
  194. package/src/aldehyde/module/dtmpl-edit-card.tsx +18 -1
  195. package/src/aldehyde/module/dtmpl-edit-page.tsx +19 -2
  196. package/src/aldehyde/routable/ltmpl-route.tsx +39 -3
  197. package/src/aldehyde/table/act-table.tsx +7 -4
  198. package/src/aldehyde/table/column/column-builder.tsx +29 -9
  199. package/src/aldehyde/tmpl/control-type-supportor.tsx +1 -0
  200. package/src/aldehyde/tmpl/hcservice-v3.tsx +44 -0
  201. package/src/aldehyde/tmpl/interface.tsx +15 -1
  202. package/src/aldehyde/tmpl/tmpl-config-analysis.tsx +1 -1
  203. package/src/aldehyde/units/index.tsx +31 -3
@@ -0,0 +1,700 @@
1
+ import Konva from 'konva';
2
+ import { GraphAnchor, Render, AssetInfoPoint } from '../types';
3
+ import { GraphDraw, LinkDraw, PreviewDraw } from '../draws';
4
+ import { BaseGraph } from './base-graph';
5
+
6
+ /**
7
+ * 图形 圆/椭圆
8
+ */
9
+ export class Circle extends BaseGraph {
10
+ // 实现:更新 图形 的 调整点 的 锚点位置
11
+ static override updateAnchorShadows(graph: Konva.Group, anchorShadows: Konva.Circle[]): void {
12
+ const { width, height } = graph.size();
13
+ for (const shadow of anchorShadows) {
14
+ switch (shadow.attrs.adjustType) {
15
+ case 'top':
16
+ shadow.position({ x: width / 2, y: 0 });
17
+ break;
18
+ case 'bottom':
19
+ shadow.position({ x: width / 2, y: height });
20
+ break;
21
+ case 'left':
22
+ shadow.position({ x: 0, y: height / 2 });
23
+ break;
24
+ case 'right':
25
+ shadow.position({ x: width, y: height / 2 });
26
+ break;
27
+ case 'top-left':
28
+ shadow.position({ x: 0, y: 0 });
29
+ break;
30
+ case 'top-right':
31
+ shadow.position({ x: width, y: 0 });
32
+ break;
33
+ case 'bottom-left':
34
+ shadow.position({ x: 0, y: height });
35
+ break;
36
+ case 'bottom-right':
37
+ shadow.position({ x: width, y: height });
38
+ break;
39
+ }
40
+ }
41
+ }
42
+
43
+ // 实现:更新 图形 的 连接点 的 锚点位置
44
+ static override updateLinkAnchorShadows(graph: Konva.Group, linkAnchorShadows: Konva.Circle[]): void {
45
+ const { width, height } = graph.size();
46
+ for (const shadow of linkAnchorShadows) {
47
+ switch (shadow.attrs.alias) {
48
+ case 'top':
49
+ shadow.position({ x: width / 2, y: 0 });
50
+ break;
51
+ case 'bottom':
52
+ shadow.position({ x: width / 2, y: height });
53
+ break;
54
+ case 'left':
55
+ shadow.position({ x: 0, y: height / 2 });
56
+ break;
57
+ case 'right':
58
+ shadow.position({ x: width, y: height / 2 });
59
+ break;
60
+ case 'center':
61
+ shadow.position({ x: width / 2, y: height / 2 });
62
+ break;
63
+ }
64
+ }
65
+ }
66
+
67
+ // 实现:生成 调整点
68
+ static override createAnchorShapes(
69
+ render: Render,
70
+ graph: Konva.Group,
71
+ anchorAndShadows: {
72
+ anchor: GraphAnchor,
73
+ anchorShadow: Konva.Circle,
74
+ shape?: Konva.Shape
75
+ }[],
76
+ // eslint-disable-next-line
77
+ adjustAnchor?: GraphAnchor
78
+ ): {
79
+ anchorAndShadows: {
80
+ anchor: GraphAnchor;
81
+ anchorShadow: Konva.Circle;
82
+ shape?: Konva.Shape | undefined;
83
+ }[]
84
+ } {
85
+ const stageState = render.getStageState();
86
+ for (const anchorAndShadow of anchorAndShadows) {
87
+ const { anchor, anchorShadow } = anchorAndShadow;
88
+ const x = render.toStageValue(anchorShadow.getAbsolutePosition().x - stageState.x),
89
+ y = render.toStageValue(anchorShadow.getAbsolutePosition().y - stageState.y);
90
+ const offset = render.toStageValue(render.pointSize + 5);
91
+ const anchorShape = new Konva.Line({
92
+ name: 'anchor',
93
+ anchor: anchor,
94
+ stroke: `rgba(0,0,255,0.4)`,
95
+ strokeWidth: render.toStageValue(2),
96
+ hitStrokeWidth: render.toStageValue(3),
97
+ x,
98
+ y,
99
+ points: {
100
+ 'top-left': [[-offset, offset / 2], [-offset, -offset], [offset / 2, -offset]].flat(),
101
+ top: [[-offset, -offset], [offset, -offset]].flat(),
102
+ 'top-right': [[-offset / 2, -offset], [offset, -offset], [offset, offset / 2]].flat(),
103
+ right: [[offset, -offset], [offset, offset]].flat(),
104
+ 'bottom-right': [[-offset / 2, offset], [offset, offset], [offset, -offset / 2]].flat(),
105
+ bottom: [[-offset, offset], [offset, offset]].flat(),
106
+ 'bottom-left': [[-offset, -offset / 2], [-offset, offset], [offset / 2, offset]].flat(),
107
+ left: [[-offset, -offset], [-offset, offset]].flat()
108
+ }[anchor.adjustType] ?? [],
109
+ rotation: graph.getAbsoluteRotation(), // 旋转角度
110
+ visible: graph.attrs.adjusting || graph.attrs.hover === true
111
+ });
112
+ anchorShape.on('mouseenter', () => {
113
+ document.body.style.cursor = 'move';
114
+ graph.setAttr('hover', true);
115
+ graph.setAttr('hoverAnchor', true);
116
+ });
117
+ anchorShape.on('mouseleave', () => {
118
+ document.body.style.cursor = anchorShape.attrs.adjusting ? 'move' : 'default';
119
+ graph.setAttr('hover', false);
120
+ graph.setAttr('hoverAnchor', false);
121
+ // 进入其他元素区域时离开需要靠它 redraw
122
+ render.redraw([GraphDraw.name]);
123
+ });
124
+ anchorAndShadow.shape = anchorShape;
125
+ }
126
+ return { anchorAndShadows };
127
+ }
128
+
129
+ // 实现:调整 图形
130
+ static override adjust(
131
+ render: Render,
132
+ graph: Konva.Group,
133
+ graphSnap: Konva.Group,
134
+ adjustShape: Konva.Shape,
135
+ anchorAndShadows: {
136
+ anchor: GraphAnchor,
137
+ anchorShadow: Konva.Circle,
138
+ shape?: Konva.Shape | undefined,
139
+ }[],
140
+ startPoint: Konva.Vector2d,
141
+ endPoint: Konva.Vector2d,
142
+ hoverRect?: Konva.Rect
143
+ ) {
144
+ // 目标 圆/椭圆
145
+ const circle = graph.findOne('.graph') as Konva.Ellipse;
146
+ // 镜像
147
+ const circleSnap = graphSnap.findOne('.graph') as Konva.Ellipse;
148
+ // 调整点 锚点
149
+ const anchors = (graph.find('.anchor') ?? []) as Konva.Circle[];
150
+ // 镜像
151
+ const anchorsSnap = (graphSnap.find('.anchor') ?? []) as Konva.Circle[];
152
+ // 连接点 锚点
153
+ const linkAnchors = (graph.find('.link-anchor') ?? []) as Konva.Circle[];
154
+ if (circle && circleSnap) {
155
+ const [graphRotation, adjustType, ex, ey] = [
156
+ Math.round(graph.rotation()),
157
+ adjustShape.attrs.anchor?.adjustType,
158
+ endPoint.x,
159
+ endPoint.y
160
+ ];
161
+ let anchorShadow: Konva.Circle | undefined, anchorShadowAcross: Konva.Circle | undefined;
162
+ switch (adjustType) {
163
+ case 'top':
164
+ anchorShadow = anchorsSnap.find((o) => o.attrs.adjustType === 'top');
165
+ anchorShadowAcross = anchorsSnap.find((o) => o.attrs.adjustType === 'bottom');
166
+ break;
167
+ case 'bottom':
168
+ anchorShadow = anchorsSnap.find((o) => o.attrs.adjustType === 'bottom');
169
+ anchorShadowAcross = anchorsSnap.find((o) => o.attrs.adjustType === 'top');
170
+ break;
171
+ case 'left':
172
+ anchorShadow = anchorsSnap.find((o) => o.attrs.adjustType === 'left');
173
+ anchorShadowAcross = anchorsSnap.find((o) => o.attrs.adjustType === 'right');
174
+ break;
175
+ case 'right':
176
+ anchorShadow = anchorsSnap.find((o) => o.attrs.adjustType === 'right');
177
+ anchorShadowAcross = anchorsSnap.find((o) => o.attrs.adjustType === 'left');
178
+ break;
179
+ case 'top-left':
180
+ anchorShadow = anchorsSnap.find((o) => o.attrs.adjustType === 'top-left');
181
+ anchorShadowAcross = anchorsSnap.find((o) => o.attrs.adjustType === 'bottom-right');
182
+ break;
183
+ case 'top-right':
184
+ anchorShadow = anchorsSnap.find((o) => o.attrs.adjustType === 'top-right');
185
+ anchorShadowAcross = anchorsSnap.find((o) => o.attrs.adjustType === 'bottom-left');
186
+ break;
187
+ case 'bottom-left':
188
+ anchorShadow = anchorsSnap.find((o) => o.attrs.adjustType === 'bottom-left');
189
+ anchorShadowAcross = anchorsSnap.find((o) => o.attrs.adjustType === 'top-right');
190
+ break;
191
+ case 'bottom-right':
192
+ anchorShadow = anchorsSnap.find((o) => o.attrs.adjustType === 'bottom-right');
193
+ anchorShadowAcross = anchorsSnap.find((o) => o.attrs.adjustType === 'top-left');
194
+ break;
195
+ }
196
+ if (anchorShadow && anchorShadowAcross) {
197
+ const { x: sx, y: sy } = anchorShadow.getAbsolutePosition();
198
+ const { x: ax, y: ay } = anchorShadowAcross.getAbsolutePosition();
199
+ {
200
+ const d1 = Math.sqrt(Math.pow(sx - ax, 2) + Math.pow(sy - ay, 2));
201
+ const d2 = Math.sqrt(Math.pow(ex - ax, 2) + Math.pow(ey - ay, 2));
202
+ const r1 = d2 / d1;
203
+ let zeroWidth = 1, zeroHeight = 1;
204
+ switch (adjustType) {
205
+ case 'top':
206
+ if (graphRotation >= 45 && graphRotation < 135) {
207
+ zeroHeight = ex <= ax ? 0 : 1;
208
+ } else if (graphRotation >= -135 && graphRotation < -45) {
209
+ zeroHeight = ex >= ax ? 0 : 1;
210
+ } else if (graphRotation >= -45 && graphRotation < 45) {
211
+ zeroHeight = ey >= ay ? 0 : 1;
212
+ } else {
213
+ zeroHeight = ey <= ay ? 0 : 1;
214
+ }
215
+ break;
216
+ case 'bottom':
217
+ if (graphRotation >= 45 && graphRotation < 135) {
218
+ zeroHeight = ex <= ax ? 1 : 0;
219
+ } else if (graphRotation >= -135 && graphRotation < -45) {
220
+ zeroHeight = ex >= ax ? 1 : 0;
221
+ } else if (graphRotation >= -45 && graphRotation < 45) {
222
+ zeroHeight = ey >= ay ? 1 : 0;
223
+ } else {
224
+ zeroHeight = ey <= ay ? 1 : 0;
225
+ }
226
+ break;
227
+ case 'left':
228
+ if (graphRotation >= 45 && graphRotation < 135) {
229
+ zeroWidth = ey >= ay ? 0 : 1;
230
+ } else if (graphRotation >= -135 && graphRotation < -45) {
231
+ zeroWidth = ex <= ax ? 0 : 1;
232
+ } else if (graphRotation >= -45 && graphRotation < 45) {
233
+ zeroWidth = ex >= ax ? 0 : 1;
234
+ } else {
235
+ zeroWidth = ey <= ay ? 0 : 1;
236
+ }
237
+ break;
238
+ case 'right':
239
+ if (graphRotation >= 45 && graphRotation < 135) {
240
+ zeroWidth = ey >= ay ? 1 : 0;
241
+ } else if (graphRotation >= -135 && graphRotation < -45) {
242
+ zeroWidth = ex <= ax ? 1 : 0;
243
+ } else if (graphRotation >= -45 && graphRotation < 45) {
244
+ zeroWidth = ex >= ax ? 1 : 0;
245
+ } else {
246
+ zeroWidth = ey <= ay ? 1 : 0;
247
+ }
248
+ break;
249
+ case 'top-left':
250
+ if (graphRotation > -45 && graphRotation < 45) {
251
+ if (ex >= ax && ey >= ay) {
252
+ zeroWidth = 0;
253
+ zeroHeight = 0;
254
+ } else {
255
+ zeroWidth = 1;
256
+ zeroHeight = 1;
257
+ }
258
+ } else if (graphRotation === 45) {
259
+ if (ey >= ay) {
260
+ zeroWidth = 0;
261
+ zeroHeight = 0;
262
+ } else {
263
+ zeroWidth = 1;
264
+ zeroHeight = 1;
265
+ }
266
+ } else if (graphRotation > 45 && graphRotation < 135) {
267
+ if (ex <= ax && ey >= ay) {
268
+ zeroWidth = 0;
269
+ zeroHeight = 0;
270
+ } else {
271
+ zeroWidth = 1;
272
+ zeroHeight = 1;
273
+ }
274
+ } else if (graphRotation === 135) {
275
+ if (ex <= ax) {
276
+ zeroWidth = 0;
277
+ zeroHeight = 0;
278
+ } else {
279
+ zeroWidth = 1;
280
+ zeroHeight = 1;
281
+ }
282
+ } else if ((graphRotation > 135 && graphRotation <= 180) || (graphRotation >= -180 && graphRotation < -135)) {
283
+ if (ex <= ax && ey <= ay) {
284
+ zeroWidth = 0;
285
+ zeroHeight = 0;
286
+ } else {
287
+ zeroWidth = 1;
288
+ zeroHeight = 1;
289
+ }
290
+ } else if (graphRotation === -135) {
291
+ if (ey <= ay) {
292
+ zeroWidth = 0;
293
+ zeroHeight = 0;
294
+ } else {
295
+ zeroWidth = 1;
296
+ zeroHeight = 1;
297
+ }
298
+ } else if (graphRotation > -135 && graphRotation < -45) {
299
+ if (ex >= ax && ey <= ay) {
300
+ zeroWidth = 0;
301
+ zeroHeight = 0;
302
+ } else {
303
+ zeroWidth = 1;
304
+ zeroHeight = 1;
305
+ }
306
+ } else if (graphRotation === -45) {
307
+ if (ex >= ax) {
308
+ zeroWidth = 0;
309
+ zeroHeight = 0;
310
+ } else {
311
+ zeroWidth = 1;
312
+ zeroHeight = 1;
313
+ }
314
+ }
315
+ break;
316
+ case 'top-right':
317
+ if (graphRotation > -45 && graphRotation < 45) {
318
+ if (ex <= ax && ey >= ay) {
319
+ zeroWidth = 0;
320
+ zeroHeight = 0;
321
+ } else {
322
+ zeroWidth = 1;
323
+ zeroHeight = 1;
324
+ }
325
+ } else if (graphRotation === 45) {
326
+ if (ex <= ax) {
327
+ zeroWidth = 0;
328
+ zeroHeight = 0;
329
+ } else {
330
+ zeroWidth = 1;
331
+ zeroHeight = 1;
332
+ }
333
+ } else if (graphRotation > 45 && graphRotation < 135) {
334
+ if (ex <= ax && ey <= ay) {
335
+ zeroWidth = 0;
336
+ zeroHeight = 0;
337
+ } else {
338
+ zeroWidth = 1;
339
+ zeroHeight = 1;
340
+ }
341
+ } else if (graphRotation === 135) {
342
+ if (ey <= ay) {
343
+ zeroWidth = 0;
344
+ zeroHeight = 0;
345
+ } else {
346
+ zeroWidth = 1;
347
+ zeroHeight = 1;
348
+ }
349
+ } else if ((graphRotation > 135 && graphRotation <= 180) || (graphRotation >= -180 && graphRotation < -135)) {
350
+ if (ex >= ax && ey <= ay) {
351
+ zeroWidth = 0;
352
+ zeroHeight = 0;
353
+ } else {
354
+ zeroWidth = 1;
355
+ zeroHeight = 1;
356
+ }
357
+ } else if (graphRotation === -135) {
358
+ if (ex >= ax) {
359
+ zeroWidth = 0;
360
+ zeroHeight = 0;
361
+ } else {
362
+ zeroWidth = 1;
363
+ zeroHeight = 1;
364
+ }
365
+ } else if (graphRotation > -135 && graphRotation < -45) {
366
+ if (ex >= ax && ey >= ay) {
367
+ zeroWidth = 0;
368
+ zeroHeight = 0;
369
+ } else {
370
+ zeroWidth = 1;
371
+ zeroHeight = 1;
372
+ }
373
+ } else if (graphRotation === -45) {
374
+ if (ey >= ay) {
375
+ zeroWidth = 0;
376
+ zeroHeight = 0;
377
+ } else {
378
+ zeroWidth = 1;
379
+ zeroHeight = 1;
380
+ }
381
+ }
382
+ break;
383
+ case 'bottom-left':
384
+ if (graphRotation > -45 && graphRotation < 45) {
385
+ if (ex >= ax && ey <= ay) {
386
+ zeroWidth = 0;
387
+ zeroHeight = 0;
388
+ } else {
389
+ zeroWidth = 1;
390
+ zeroHeight = 1;
391
+ }
392
+ } else if (graphRotation === 45) {
393
+ if (ex >= ax) {
394
+ zeroWidth = 0;
395
+ zeroHeight = 0;
396
+ } else {
397
+ zeroWidth = 1;
398
+ zeroHeight = 1;
399
+ }
400
+ } else if (graphRotation > 45 && graphRotation < 135) {
401
+ if (ex >= ax && ey >= ay) {
402
+ zeroWidth = 0;
403
+ zeroHeight = 0;
404
+ } else {
405
+ zeroWidth = 1;
406
+ zeroHeight = 1;
407
+ }
408
+ } else if (graphRotation === 135) {
409
+ if (ey >= ay) {
410
+ zeroWidth = 0;
411
+ zeroHeight = 0;
412
+ } else {
413
+ zeroWidth = 1;
414
+ zeroHeight = 1;
415
+ }
416
+ } else if ((graphRotation > 135 && graphRotation <= 180) || (graphRotation >= -180 && graphRotation < -135)) {
417
+ if (ex <= ax && ey >= ay) {
418
+ zeroWidth = 0;
419
+ zeroHeight = 0;
420
+ } else {
421
+ zeroWidth = 1;
422
+ zeroHeight = 1;
423
+ }
424
+ } else if (graphRotation === -135) {
425
+ if (ex <= ax) {
426
+ zeroWidth = 0;
427
+ zeroHeight = 0;
428
+ } else {
429
+ zeroWidth = 1;
430
+ zeroHeight = 1;
431
+ }
432
+ } else if (graphRotation > -135 && graphRotation < -45) {
433
+ if (ex <= ax && ey <= ay) {
434
+ zeroWidth = 0;
435
+ zeroHeight = 0;
436
+ } else {
437
+ zeroWidth = 1;
438
+ zeroHeight = 1;
439
+ }
440
+ } else if (graphRotation === -45) {
441
+ if (ey <= ay) {
442
+ zeroWidth = 0;
443
+ zeroHeight = 0;
444
+ } else {
445
+ zeroWidth = 1;
446
+ zeroHeight = 1;
447
+ }
448
+ }
449
+ break;
450
+ case 'bottom-right':
451
+ if (graphRotation > -45 && graphRotation < 45) {
452
+ if (ex <= ax && ey <= ay) {
453
+ zeroWidth = 0;
454
+ zeroHeight = 0;
455
+ } else {
456
+ zeroWidth = 1;
457
+ zeroHeight = 1;
458
+ }
459
+ } else if (graphRotation === 45) {
460
+ if (ey <= ay) {
461
+ zeroWidth = 0;
462
+ zeroHeight = 0;
463
+ } else {
464
+ zeroWidth = 1;
465
+ zeroHeight = 1;
466
+ }
467
+ } else if (graphRotation > 45 && graphRotation < 135) {
468
+ if (ex >= ax && ey <= ay) {
469
+ zeroWidth = 0;
470
+ zeroHeight = 0;
471
+ } else {
472
+ zeroWidth = 1;
473
+ zeroHeight = 1;
474
+ }
475
+ } else if (graphRotation === 135) {
476
+ if (ex >= ax) {
477
+ zeroWidth = 0;
478
+ zeroHeight = 0;
479
+ } else {
480
+ zeroWidth = 1;
481
+ zeroHeight = 1;
482
+ }
483
+ } else if ((graphRotation > 135 && graphRotation <= 180) || (graphRotation >= -180 && graphRotation < -135)) {
484
+ if (ex >= ax && ey >= ay) {
485
+ zeroWidth = 0;
486
+ zeroHeight = 0;
487
+ } else {
488
+ zeroWidth = 1;
489
+ zeroHeight = 1;
490
+ }
491
+ } else if (graphRotation === -135) {
492
+ if (ey >= ay) {
493
+ zeroWidth = 0;
494
+ zeroHeight = 0;
495
+ } else {
496
+ zeroWidth = 1;
497
+ zeroHeight = 1;
498
+ }
499
+ } else if (graphRotation > -135 && graphRotation < -45) {
500
+ if (ex <= ax && ey >= ay) {
501
+ zeroWidth = 0;
502
+ zeroHeight = 0;
503
+ } else {
504
+ zeroWidth = 1;
505
+ zeroHeight = 1;
506
+ }
507
+ } else if (graphRotation === -45) {
508
+ if (ex <= ax) {
509
+ zeroWidth = 0;
510
+ zeroHeight = 0;
511
+ } else {
512
+ zeroWidth = 1;
513
+ zeroHeight = 1;
514
+ }
515
+ }
516
+ break;
517
+ }
518
+ if (/-?(left|right)$/.test(adjustType)) {
519
+ graph.width(Math.max(2, graphSnap.width() * r1 * zeroWidth));
520
+ }
521
+ if (/^(top|bottom)-?/.test(adjustType)) {
522
+ graph.height(Math.max(2, graphSnap.height() * r1 * zeroHeight));
523
+ }
524
+ }
525
+ {
526
+ const [graphWidth, graphHeight] = [graph.width() * graph.scaleX(), graph.height() * graph.scaleY()];
527
+ const cos = Math.cos((graphRotation * Math.PI) / 180);
528
+ const sin = Math.sin((graphRotation * Math.PI) / 180);
529
+ const tan = Math.tan((graphRotation * Math.PI) / 180);
530
+ switch (adjustType) {
531
+ case 'top':
532
+ graph.x(ax - (graphWidth / 2 - graphHeight * tan) * cos);
533
+ if (graphRotation !== 90 && graphRotation !== -90) {
534
+ graph.y(ay - (graphHeight / cos + (graphWidth / 2 - graphHeight * tan) * sin));
535
+ }
536
+ break;
537
+ case 'bottom': // 无需处理
538
+ break;
539
+ case 'left':
540
+ if ([90, -90].includes(graphRotation)) {
541
+ graph.y(ay - graphWidth);
542
+ } else if (Math.abs(graphRotation) === 180) {
543
+ graph.x(ax + graphWidth);
544
+ } else {
545
+ const v1 = graphHeight / 2 / cos;
546
+ const v2 = v1 * sin;
547
+ const v3 = graphWidth - v2;
548
+ const v4 = v3 * sin;
549
+ graph.x(ax - v3 * cos);
550
+ graph.y(ay - (v1 + v4));
551
+ }
552
+ break;
553
+ case 'right': // 无需处理
554
+ break;
555
+ case 'top-left':
556
+ graph.x(ax - (graphWidth - graphHeight * tan) * cos);
557
+ graph.y(ay - (graphWidth * sin + graphHeight * cos));
558
+ break;
559
+ case 'top-right':
560
+ graph.x(ax + graphHeight * sin);
561
+ graph.y(ay - graphHeight * cos);
562
+ break;
563
+ case 'bottom-left':
564
+ graph.x(ax - graphWidth * cos);
565
+ graph.y(ay - graphWidth * sin);
566
+ break;
567
+ case 'bottom-right': // 无需处理
568
+ break;
569
+ }
570
+ }
571
+ }
572
+ const [graphWidth, graphHeight] = [graph.width(), graph.height()];
573
+ // 更新 圆/椭圆 大小
574
+ circle.x(graphWidth / 2);
575
+ circle.radiusX(graphWidth / 2);
576
+ circle.y(graphHeight / 2);
577
+ circle.radiusY(graphHeight / 2);
578
+ // 更新 调整点 的 锚点 位置
579
+ Circle.updateAnchorShadows(graph, anchors);
580
+ // 更新 图形 的 连接点 的 锚点位置
581
+ Circle.updateLinkAnchorShadows(graph, linkAnchors);
582
+ const stageState = render.getStageState();
583
+ // 更新 调整点 位置
584
+ for (const anchor of anchors) {
585
+ for (const { shape } of anchorAndShadows) {
586
+ if (shape) {
587
+ if (shape.attrs.anchor?.adjustType === anchor.attrs.adjustType) {
588
+ const anchorShadow = graph.find(`.anchor`).find((o) => o.attrs.adjustType === anchor.attrs.adjustType);
589
+ if (anchorShadow) {
590
+ shape.position({
591
+ x: render.toStageValue(anchorShadow.getAbsolutePosition().x - stageState.x),
592
+ y: render.toStageValue(anchorShadow.getAbsolutePosition().y - stageState.y)
593
+ });
594
+ shape.rotation(graph.getAbsoluteRotation());
595
+ }
596
+ }
597
+ }
598
+ }
599
+ }
600
+ render.redraw([GraphDraw.name, LinkDraw.name, PreviewDraw.name]); // 重绘
601
+ }
602
+ BaseGraph.adjust(render, graph, graphSnap, adjustShape, anchorAndShadows, startPoint, endPoint, hoverRect);
603
+ }
604
+
605
+ /**
606
+ * 提供给 GraphDraw draw 使用
607
+ */
608
+ static override draw(graph: Konva.Group, render: Render, adjustAnchor?: GraphAnchor) {
609
+ const { anchorAndShadows } = super.draw(graph, render, adjustAnchor);
610
+ return Circle.createAnchorShapes(render, graph, anchorAndShadows, adjustAnchor);
611
+ }
612
+
613
+ /**
614
+ * 默认图形大小
615
+ */
616
+ static size = 100;
617
+
618
+ /**
619
+ * 圆/椭圆 对应的 Konva 实例
620
+ */
621
+ private circle: Konva.Ellipse;
622
+
623
+ constructor(render: Render, dropPoint: Konva.Vector2d) {
624
+ super(render, dropPoint, {
625
+ type: "Circle",
626
+ anchors: [
627
+ { adjustType: 'top' },
628
+ { adjustType: 'bottom' },
629
+ { adjustType: 'left' },
630
+ { adjustType: 'right' },
631
+ { adjustType: 'top-left' },
632
+ { adjustType: 'top-right' },
633
+ { adjustType: 'bottom-left' },
634
+ { adjustType: 'bottom-right' }
635
+ ].map((o) => ({ adjustType: o.adjustType })),
636
+ linkAnchors: [
637
+ { x: 0, y: 0, alias: 'top', direction: 'top' },
638
+ { x: 0, y: 0, alias: 'bottom', direction: 'bottom' },
639
+ { x: 0, y: 0, alias: 'left', direction: 'left' },
640
+ { x: 0, y: 0, alias: 'right', direction: 'right' },
641
+ { x: 0, y: 0, alias: 'center' }
642
+ ] as AssetInfoPoint[]
643
+ });
644
+ this.circle = new Konva.Ellipse({
645
+ name: 'graph',
646
+ x: 0,
647
+ y: 0,
648
+ radiusX: 0,
649
+ radiusY: 0,
650
+ stroke: this.render.getPageSettings().stroke,
651
+ strokeWidth: this.render.getPageSettings().strokeWidth
652
+ });
653
+ this.group.add(this.circle);
654
+ this.group.position(this.dropPoint); // 鼠标按下位置 作为起点
655
+ }
656
+
657
+ // 实现:拖动进行时
658
+ override drawMove(point: Konva.Vector2d): void {
659
+ // 鼠标拖动偏移量
660
+ let offsetX = point.x - this.dropPoint.x,
661
+ offsetY = point.y - this.dropPoint.y;
662
+ if (offsetX < 1) offsetX = 1;
663
+ if (offsetY < 1) offsetY = 1;
664
+ // 半径
665
+ const radiusX = offsetX / 2, radiusY = offsetY / 2;
666
+ // 圆/椭圆 位置大小
667
+ this.circle.x(radiusX);
668
+ this.circle.y(radiusY);
669
+ this.circle.radiusX(radiusX);
670
+ this.circle.radiusY(radiusY);
671
+ this.group.size({ width: offsetX, height: offsetY });
672
+ Circle.updateAnchorShadows(this.group, this.anchorShadows);
673
+ Circle.updateLinkAnchorShadows(this.group, this.linkAnchorShadows);
674
+ this.render.redraw([GraphDraw.name, LinkDraw.name, PreviewDraw.name]);
675
+ }
676
+
677
+ // 实现:拖动结束
678
+ override drawEnd(): void {
679
+ if (this.circle.radiusX() <= 1 && this.circle.radiusY() <= 1) {
680
+ const width = Circle.size, height = width;
681
+ const radiusX = Circle.size / 2, radiusY = radiusX;
682
+ this.circle.x(radiusX);
683
+ this.circle.y(radiusY);
684
+ this.circle.radiusX(radiusX - this.circle.strokeWidth());
685
+ this.circle.radiusY(radiusY - this.circle.strokeWidth());
686
+ this.group.size({ width, height });
687
+ // 更新 图形 的 调整点 的 锚点位置
688
+ Circle.updateAnchorShadows(this.group, this.anchorShadows);
689
+ // 更新 图形 的 连接点 的 锚点位置
690
+ Circle.updateLinkAnchorShadows(this.group, this.linkAnchorShadows);
691
+ // 对齐线清除
692
+ this.render.attractTool.alignLinesClear();
693
+ // 更新历史
694
+ this.render.updateHistory();
695
+ // 重绘
696
+ this.render.redraw([GraphDraw.name, LinkDraw.name, PreviewDraw.name]);
697
+ }
698
+ super.drawEnd();
699
+ }
700
+ }