aldehyde 0.2.494 → 0.2.495
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/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +63 -63
- package/lib/draw-canvas-edit/components/asset-bar/index.less +35 -35
- package/lib/draw-canvas-edit/components/main-header/index.less +23 -23
- package/lib/layout2/page.d.ts +2 -1
- package/lib/layout2/page.d.ts.map +1 -1
- package/lib/layout2/page.js +19 -8
- package/lib/layout2/page.js.map +1 -1
- package/lib/layout2/type/layout-type.d.ts +1 -0
- package/lib/layout2/type/layout-type.d.ts.map +1 -1
- package/lib/lowcode-components/base-table/index.less +61 -61
- package/lib/lowcode-components/base-text/index.less +19 -19
- package/lib/lowcode-components/data-number/index.less +10 -10
- package/lib/lowcode-components/date-time/index.less +4 -4
- package/lib/lowcode-components/four-angle-glow-border/index.less +49 -49
- package/lib/lowcode-components/lowcode-view/component/font/FontGlobal.css +26 -26
- package/lib/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -13
- package/lib/lowcode-components/text-scroller/index.less +28 -28
- package/lib/module/ltmpl-table.d.ts +7 -0
- package/lib/module/ltmpl-table.d.ts.map +1 -1
- package/lib/module/ltmpl-table.js +12 -16
- package/lib/module/ltmpl-table.js.map +1 -1
- package/lib/routable/dtmpl-route.d.ts.map +1 -1
- package/lib/routable/dtmpl-route.js +8 -2
- package/lib/routable/dtmpl-route.js.map +1 -1
- package/lib/routable/import-route.d.ts.map +1 -1
- package/lib/routable/import-route.js +9 -1
- package/lib/routable/import-route.js.map +1 -1
- package/lib/routable/ltmpl-route.d.ts.map +1 -1
- package/lib/routable/ltmpl-route.js +13 -6
- package/lib/routable/ltmpl-route.js.map +1 -1
- package/lib/routable/splitview-ltmpl-route.d.ts.map +1 -1
- package/lib/routable/splitview-ltmpl-route.js +11 -10
- package/lib/routable/splitview-ltmpl-route.js.map +1 -1
- package/lib/routable/ttmpl-route.d.ts.map +1 -1
- package/lib/routable/ttmpl-route.js +9 -2
- package/lib/routable/ttmpl-route.js.map +1 -1
- package/lib/table/act-table.d.ts +1 -0
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js +31 -9
- package/lib/table/act-table.js.map +1 -1
- package/lib/table/page-chart.js +1 -1
- package/lib/table/page-chart.js.map +1 -1
- package/lib/table/row-table.d.ts +6 -0
- package/lib/table/row-table.d.ts.map +1 -1
- package/lib/table/row-table.js +21 -6
- package/lib/table/row-table.js.map +1 -1
- package/lib/tmpl/interface.d.ts +1 -0
- package/lib/tmpl/interface.d.ts.map +1 -1
- package/lib/tree/act-tree.d.ts +1 -0
- package/lib/tree/act-tree.d.ts.map +1 -1
- package/lib/tree/act-tree.js +6 -7
- package/lib/tree/act-tree.js.map +1 -1
- package/lib/tree/tree-utils.d.ts +1 -1
- package/lib/tree/tree-utils.d.ts.map +1 -1
- package/lib/tree/tree-utils.js +4 -4
- package/lib/tree/tree-utils.js.map +1 -1
- package/lib/units/index.d.ts +4 -0
- package/lib/units/index.d.ts.map +1 -1
- package/lib/units/index.js +10 -3
- package/lib/units/index.js.map +1 -1
- package/package.json +1 -1
- package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +63 -63
- package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.json +93 -93
- package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.less +35 -35
- package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.tsx +110 -110
- package/src/aldehyde/draw-canvas-edit/components/main-header/index.less +23 -23
- package/src/aldehyde/draw-canvas-edit/components/main-header/index.tsx +263 -263
- package/src/aldehyde/draw-canvas-edit/components/render/draws/index.ts +7 -7
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/base-graph.ts +241 -241
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/circle.ts +699 -699
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/curve.ts +500 -500
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/index.ts +5 -5
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/line.ts +493 -493
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/rect.ts +680 -680
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/drag-handlers.ts +68 -68
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/graph-handlers.ts +113 -113
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/index.ts +9 -9
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/key-move-handlers.ts +49 -49
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/link-handlers.ts +45 -45
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/shutcut-handlers.ts +45 -45
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/text-handlers.ts +81 -81
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/zoom-handlers.ts +59 -59
- package/src/aldehyde/draw-canvas-edit/components/render/tools/align-tool.ts +89 -89
- package/src/aldehyde/draw-canvas-edit/components/render/tools/asset-tool.ts +154 -154
- package/src/aldehyde/draw-canvas-edit/components/render/tools/link-tool.ts +222 -222
- package/src/aldehyde/draw-canvas-edit/components/render/tools/z-index-tool.ts +224 -224
- package/src/aldehyde/draw-canvas-edit/components/render/utils/a-star.ts +116 -116
- package/src/aldehyde/draw-canvas-edit/components/render/utils/bezier-scene-func.ts +72 -72
- package/src/aldehyde/draw-canvas-edit/components/setting-form/imag-upload.tsx +119 -119
- package/src/aldehyde/layout2/page.tsx +17 -9
- package/src/aldehyde/layout2/type/layout-type.ts +1 -0
- package/src/aldehyde/layout4/imgs/user.svg +26 -26
- package/src/aldehyde/lowcode-components/base-color-block/index.tsx +31 -31
- package/src/aldehyde/lowcode-components/base-table/index.less +61 -61
- package/src/aldehyde/lowcode-components/base-text/index.less +19 -19
- package/src/aldehyde/lowcode-components/data-number/index.less +10 -10
- package/src/aldehyde/lowcode-components/date-time/index.less +4 -4
- package/src/aldehyde/lowcode-components/date-time/index.tsx +64 -64
- package/src/aldehyde/lowcode-components/four-angle-glow-border/index.less +49 -49
- package/src/aldehyde/lowcode-components/four-angle-glow-border/index.tsx +53 -53
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-controller.ts +64 -64
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-definition.ts +77 -77
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-designer-loader.ts +36 -36
- package/src/aldehyde/lowcode-components/lowcode-view/component/component-container.tsx +91 -91
- package/src/aldehyde/lowcode-components/lowcode-view/component/font/FontGlobal.css +26 -26
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/controller.ts +36 -36
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/definition.ts +53 -53
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/index.tsx +15 -15
- package/src/aldehyde/lowcode-components/lowcode-view/component/layer-builder.tsx +98 -98
- package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -13
- package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.tsx +121 -121
- package/src/aldehyde/lowcode-components/placeholder-component/index.tsx +81 -81
- package/src/aldehyde/lowcode-components/text-scroller/index.less +28 -28
- package/src/aldehyde/lowcode-components/text-scroller/index.tsx +173 -173
- package/src/aldehyde/module/ltmpl-table.tsx +14 -15
- package/src/aldehyde/routable/dtmpl-route.tsx +14 -8
- package/src/aldehyde/routable/import-route.tsx +12 -5
- package/src/aldehyde/routable/ltmpl-route.tsx +14 -9
- package/src/aldehyde/routable/splitview-ltmpl-route.tsx +11 -8
- package/src/aldehyde/routable/ttmpl-route.tsx +13 -8
- package/src/aldehyde/table/act-table.tsx +28 -9
- package/src/aldehyde/table/page-chart.tsx +1 -1
- package/src/aldehyde/table/row-table.tsx +29 -6
- package/src/aldehyde/tmpl/interface.tsx +1 -0
- package/src/aldehyde/tree/act-tree.tsx +8 -6
- package/src/aldehyde/tree/tree-utils.tsx +4 -4
- package/src/aldehyde/units/index.tsx +11 -3
|
@@ -1,241 +1,241 @@
|
|
|
1
|
-
import Konva from 'konva';
|
|
2
|
-
import { nanoid } from 'nanoid';
|
|
3
|
-
import { Render } from '../index';
|
|
4
|
-
import { GraphAnchor, LinkDrawPoint, AssetInfoPoint, GraphType, AssetType } from '../types';
|
|
5
|
-
import { GraphDraw } from '../draws';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 图形类
|
|
9
|
-
* 实例主要用于新建图形时,含新建同时的大小拖动。
|
|
10
|
-
* 静态方法主要用于新建之后,通过 调整点 调整的逻辑定义
|
|
11
|
-
*/
|
|
12
|
-
export abstract class BaseGraph {
|
|
13
|
-
/**
|
|
14
|
-
* 更新 图形 的 调整点 的 锚点位置
|
|
15
|
-
* @param width 图形 的 宽度
|
|
16
|
-
* @param height 图形 的 高度
|
|
17
|
-
* @param rotate 图形 的 旋转角度
|
|
18
|
-
* @param anchorShadows 图形 的 调整点 的 锚点
|
|
19
|
-
*/
|
|
20
|
-
static updateAnchorShadows(graph: Konva.Group, anchorShadows: Konva.Circle[]) {
|
|
21
|
-
console.log('请实现 updateAnchorShadows');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 更新 图形 的 连接点 的 锚点位置
|
|
26
|
-
* @param width 图形 的 宽度
|
|
27
|
-
* @param height 图形 的 高度
|
|
28
|
-
* @param rotate 图形 的 旋转角度
|
|
29
|
-
* @param anchors 图形 的 调整点 的 锚点
|
|
30
|
-
*/
|
|
31
|
-
static updateLinkAnchorShadows(graph: Konva.Group, linkAnchorShadows: Konva.Circle[]) {
|
|
32
|
-
console.log('请实现 updateLinkAnchorShadows');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 生成 调整点
|
|
37
|
-
* @param render 渲染实例
|
|
38
|
-
* @param graph 图形
|
|
39
|
-
* @param anchorAndShadows 调整点 及其 锚点
|
|
40
|
-
* @param adjustAnchor 正在操作的 调整点
|
|
41
|
-
* @returns
|
|
42
|
-
*/
|
|
43
|
-
static createAnchorShapes(render: Render, graph: Konva.Group, anchorAndShadows: { anchor: GraphAnchor, anchorShadow: Konva.Circle, shape?: Konva.Shape }[], adjustAnchor: GraphAnchor) {
|
|
44
|
-
console.log('请实现 createAnchorShapes');
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 调整 图形
|
|
50
|
-
* @param render 渲染实例
|
|
51
|
-
* @param graph 图形
|
|
52
|
-
* @param graphSnap 图形 的 备份
|
|
53
|
-
* @param rect 当前 调整点
|
|
54
|
-
* @param rects 所有 调整点
|
|
55
|
-
* @param startPoint 鼠标按下位置
|
|
56
|
-
* @param endPoint 鼠标拖动位置
|
|
57
|
-
*/
|
|
58
|
-
static adjust(render: Render, graph: Konva.Group, graphSnap: Konva.Group, adjustShape: Konva.Shape, anchorAndShadows: { anchor: GraphAnchor; anchorShadow: Konva.Circle; shape?: Konva.Shape | undefined }[], startPoint: Konva.Vector2d, endPoint: Konva.Vector2d, hoverRect?: Konva.Rect, hoverSize?: { width: number; height: number }, hoverPos?: { x: number; y: number }) {
|
|
59
|
-
hoverRect?.position({
|
|
60
|
-
x: hoverPos?.x ?? 0,
|
|
61
|
-
y: hoverPos?.y ?? 0
|
|
62
|
-
});
|
|
63
|
-
hoverRect?.size({
|
|
64
|
-
width: hoverSize?.width ?? graph.width(),
|
|
65
|
-
height: hoverSize?.height ?? graph.height()
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static draw(graph: Konva.Group, render: Render, adjustAnchor?: GraphAnchor): { anchorAndShadows: { anchor: GraphAnchor; anchorShadow: Konva.Circle; shape?: Konva.Shape }[] } {
|
|
70
|
-
// 调整点 信息
|
|
71
|
-
const anchors = (graph.attrs.anchors ?? []) as GraphAnchor[];
|
|
72
|
-
// 调整点 锚点
|
|
73
|
-
const anchorShapes = graph.find(`.anchor`);
|
|
74
|
-
// 调整点 信息&锚点
|
|
75
|
-
const anchorAndShadows = anchors
|
|
76
|
-
.map((anchor) => ({
|
|
77
|
-
anchor,
|
|
78
|
-
anchorShadow: anchorShapes.find(
|
|
79
|
-
(shape) => shape.attrs.adjustType === anchor.adjustType
|
|
80
|
-
) as Konva.Circle
|
|
81
|
-
}))
|
|
82
|
-
.filter((o) => o.anchorShadow !== void 0);
|
|
83
|
-
return { anchorAndShadows };
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
protected render: Render;
|
|
87
|
-
group: Konva.Group;
|
|
88
|
-
// 占用区域,用于识别 hover 态
|
|
89
|
-
hoverRect: Konva.Rect;
|
|
90
|
-
id: string; // 就是 group 的id
|
|
91
|
-
/**
|
|
92
|
-
* 鼠标按下位置
|
|
93
|
-
*/
|
|
94
|
-
protected dropPoint: Konva.Vector2d = { x: 0, y: 0 };
|
|
95
|
-
/**
|
|
96
|
-
* 调整点 定义
|
|
97
|
-
*/
|
|
98
|
-
protected anchors: GraphAnchor[] = [];
|
|
99
|
-
/**
|
|
100
|
-
* 调整点 的 锚点
|
|
101
|
-
*/
|
|
102
|
-
protected anchorShadows: Konva.Circle[] = [];
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* 调整点 定义
|
|
106
|
-
*/
|
|
107
|
-
protected linkAnchors: LinkDrawPoint[] = [];
|
|
108
|
-
/**
|
|
109
|
-
* 连接点 的 锚点
|
|
110
|
-
*/
|
|
111
|
-
protected linkAnchorShadows: Konva.Circle[] = [];
|
|
112
|
-
|
|
113
|
-
constructor(
|
|
114
|
-
render: Render,
|
|
115
|
-
dropPoint: Konva.Vector2d,
|
|
116
|
-
config: {
|
|
117
|
-
anchors: GraphAnchor[]
|
|
118
|
-
linkAnchors: AssetInfoPoint[]
|
|
119
|
-
type: GraphType
|
|
120
|
-
}
|
|
121
|
-
) {
|
|
122
|
-
this.render = render;
|
|
123
|
-
this.dropPoint = dropPoint;
|
|
124
|
-
this.id = nanoid();
|
|
125
|
-
this.group = new Konva.Group({
|
|
126
|
-
id: this.id,
|
|
127
|
-
name: 'asset',
|
|
128
|
-
assetType: AssetType.Graph,
|
|
129
|
-
graphType: config.type,
|
|
130
|
-
draggable: true
|
|
131
|
-
});
|
|
132
|
-
this.hoverRect = new Konva.Rect({
|
|
133
|
-
name: 'hoverRect',
|
|
134
|
-
x: 0,
|
|
135
|
-
y: 0,
|
|
136
|
-
hitStrokeWidth: this.render.toStageValue(this.render.bgSize * 2 + 2)
|
|
137
|
-
});
|
|
138
|
-
// 调整点 定义
|
|
139
|
-
this.anchors = config.anchors.map((o) => ({
|
|
140
|
-
...o,
|
|
141
|
-
// 补充信息
|
|
142
|
-
name: 'anchor',
|
|
143
|
-
groupId: this.group.id(),
|
|
144
|
-
type: config.type
|
|
145
|
-
}));
|
|
146
|
-
// 记录在 group 中
|
|
147
|
-
this.group.setAttr('anchors', this.anchors);
|
|
148
|
-
// 新建 调整点 的 锚点
|
|
149
|
-
for (const anchor of this.anchors) {
|
|
150
|
-
const circle = new Konva.Circle({
|
|
151
|
-
adjustType: anchor.adjustType,
|
|
152
|
-
anchorType: anchor.type,
|
|
153
|
-
name: anchor.name,
|
|
154
|
-
radius: 0
|
|
155
|
-
});
|
|
156
|
-
this.anchorShadows.push(circle);
|
|
157
|
-
this.group.add(circle);
|
|
158
|
-
}
|
|
159
|
-
// 连接点 定义
|
|
160
|
-
this.linkAnchors = config.linkAnchors.map(
|
|
161
|
-
(o) =>
|
|
162
|
-
({
|
|
163
|
-
...o,
|
|
164
|
-
id: nanoid(),
|
|
165
|
-
groupId: this.group.id(),
|
|
166
|
-
visible: false,
|
|
167
|
-
pairs: [],
|
|
168
|
-
direction: o.direction,
|
|
169
|
-
alias: o.alias
|
|
170
|
-
}) as LinkDrawPoint
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
// 连接点信息
|
|
174
|
-
this.group.setAttrs({ points: this.linkAnchors });
|
|
175
|
-
// 新建 连接点 的 锚点
|
|
176
|
-
for (const point of this.linkAnchors) {
|
|
177
|
-
const circle = new Konva.Circle({
|
|
178
|
-
name: 'link-anchor',
|
|
179
|
-
id: point.id,
|
|
180
|
-
x: point.x,
|
|
181
|
-
y: point.y,
|
|
182
|
-
radius: this.render.toStageValue(1),
|
|
183
|
-
stroke: 'rgba(0,0,255,1)',
|
|
184
|
-
strokeWidth: this.render.toStageValue(2),
|
|
185
|
-
visible: false,
|
|
186
|
-
direction: point.direction,
|
|
187
|
-
alias: point.alias
|
|
188
|
-
});
|
|
189
|
-
this.linkAnchorShadows.push(circle);
|
|
190
|
-
this.group.add(circle);
|
|
191
|
-
}
|
|
192
|
-
this.render.layer.add(this.group);
|
|
193
|
-
this.render.redraw([GraphDraw.NAME]);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* 调整进行时
|
|
198
|
-
* @param point 鼠标位置 相对位置
|
|
199
|
-
*/
|
|
200
|
-
abstract drawMove(point: Konva.Vector2d): void;
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* 调整结束
|
|
204
|
-
*/
|
|
205
|
-
drawEnd(size?: { width: number; height: number }, pos?: { x: number; y: number }): void {
|
|
206
|
-
this.hoverRect?.position({ x: pos?.x ?? 0, y: pos?.y ?? 0 });
|
|
207
|
-
this.hoverRect.size({ width: size?.width ?? this.group.width(), height: size?.height ?? this.group.height() });
|
|
208
|
-
this.hoverRect.on('mouseenter', () => {
|
|
209
|
-
// 防止进入调整点,重复处理
|
|
210
|
-
if (!this.group.attrs.hoverAnchor) {
|
|
211
|
-
this.group.setAttr('hover', true);
|
|
212
|
-
this.render.redraw([GraphDraw.NAME]);
|
|
213
|
-
}
|
|
214
|
-
setTimeout(() => {
|
|
215
|
-
// 调整产生 redraw,导致离开调整点不触发其 mouseleave(进入其他元素区域除外)
|
|
216
|
-
// 在此静态补充“离开调整点”
|
|
217
|
-
// 不影响正常处理(调整点会不停 hoverAnchor = true)
|
|
218
|
-
this.group.setAttr('hoverAnchor', false);
|
|
219
|
-
})
|
|
220
|
-
// 显示 连接点
|
|
221
|
-
this.render.linkTool.pointsVisible(true, this.group);
|
|
222
|
-
})
|
|
223
|
-
this.hoverRect.on('mouseleave', () => {
|
|
224
|
-
// 延迟事件,使调整点的 mouseleave 优先
|
|
225
|
-
setTimeout(() => {
|
|
226
|
-
// 防止进入调整点,重复处理
|
|
227
|
-
// 补充 2,快速调整会漏掉
|
|
228
|
-
if (!this.group.attrs.hoverAnchor) {
|
|
229
|
-
this.group.setAttr('hover', false);
|
|
230
|
-
this.group.setAttr('hoverAnchor', false);
|
|
231
|
-
this.render.redraw([GraphDraw.NAME]);
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
// 隐藏 连接点
|
|
235
|
-
this.render.linkTool.pointsVisible(false, this.group);
|
|
236
|
-
// 隐藏 hover 框
|
|
237
|
-
this.group.findOne('#hoverRect')?.visible(false);
|
|
238
|
-
})
|
|
239
|
-
this.group.add(this.hoverRect);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
1
|
+
import Konva from 'konva';
|
|
2
|
+
import { nanoid } from 'nanoid';
|
|
3
|
+
import { Render } from '../index';
|
|
4
|
+
import { GraphAnchor, LinkDrawPoint, AssetInfoPoint, GraphType, AssetType } from '../types';
|
|
5
|
+
import { GraphDraw } from '../draws';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 图形类
|
|
9
|
+
* 实例主要用于新建图形时,含新建同时的大小拖动。
|
|
10
|
+
* 静态方法主要用于新建之后,通过 调整点 调整的逻辑定义
|
|
11
|
+
*/
|
|
12
|
+
export abstract class BaseGraph {
|
|
13
|
+
/**
|
|
14
|
+
* 更新 图形 的 调整点 的 锚点位置
|
|
15
|
+
* @param width 图形 的 宽度
|
|
16
|
+
* @param height 图形 的 高度
|
|
17
|
+
* @param rotate 图形 的 旋转角度
|
|
18
|
+
* @param anchorShadows 图形 的 调整点 的 锚点
|
|
19
|
+
*/
|
|
20
|
+
static updateAnchorShadows(graph: Konva.Group, anchorShadows: Konva.Circle[]) {
|
|
21
|
+
console.log('请实现 updateAnchorShadows');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 更新 图形 的 连接点 的 锚点位置
|
|
26
|
+
* @param width 图形 的 宽度
|
|
27
|
+
* @param height 图形 的 高度
|
|
28
|
+
* @param rotate 图形 的 旋转角度
|
|
29
|
+
* @param anchors 图形 的 调整点 的 锚点
|
|
30
|
+
*/
|
|
31
|
+
static updateLinkAnchorShadows(graph: Konva.Group, linkAnchorShadows: Konva.Circle[]) {
|
|
32
|
+
console.log('请实现 updateLinkAnchorShadows');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 生成 调整点
|
|
37
|
+
* @param render 渲染实例
|
|
38
|
+
* @param graph 图形
|
|
39
|
+
* @param anchorAndShadows 调整点 及其 锚点
|
|
40
|
+
* @param adjustAnchor 正在操作的 调整点
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
static createAnchorShapes(render: Render, graph: Konva.Group, anchorAndShadows: { anchor: GraphAnchor, anchorShadow: Konva.Circle, shape?: Konva.Shape }[], adjustAnchor: GraphAnchor) {
|
|
44
|
+
console.log('请实现 createAnchorShapes');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 调整 图形
|
|
50
|
+
* @param render 渲染实例
|
|
51
|
+
* @param graph 图形
|
|
52
|
+
* @param graphSnap 图形 的 备份
|
|
53
|
+
* @param rect 当前 调整点
|
|
54
|
+
* @param rects 所有 调整点
|
|
55
|
+
* @param startPoint 鼠标按下位置
|
|
56
|
+
* @param endPoint 鼠标拖动位置
|
|
57
|
+
*/
|
|
58
|
+
static adjust(render: Render, graph: Konva.Group, graphSnap: Konva.Group, adjustShape: Konva.Shape, anchorAndShadows: { anchor: GraphAnchor; anchorShadow: Konva.Circle; shape?: Konva.Shape | undefined }[], startPoint: Konva.Vector2d, endPoint: Konva.Vector2d, hoverRect?: Konva.Rect, hoverSize?: { width: number; height: number }, hoverPos?: { x: number; y: number }) {
|
|
59
|
+
hoverRect?.position({
|
|
60
|
+
x: hoverPos?.x ?? 0,
|
|
61
|
+
y: hoverPos?.y ?? 0
|
|
62
|
+
});
|
|
63
|
+
hoverRect?.size({
|
|
64
|
+
width: hoverSize?.width ?? graph.width(),
|
|
65
|
+
height: hoverSize?.height ?? graph.height()
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static draw(graph: Konva.Group, render: Render, adjustAnchor?: GraphAnchor): { anchorAndShadows: { anchor: GraphAnchor; anchorShadow: Konva.Circle; shape?: Konva.Shape }[] } {
|
|
70
|
+
// 调整点 信息
|
|
71
|
+
const anchors = (graph.attrs.anchors ?? []) as GraphAnchor[];
|
|
72
|
+
// 调整点 锚点
|
|
73
|
+
const anchorShapes = graph.find(`.anchor`);
|
|
74
|
+
// 调整点 信息&锚点
|
|
75
|
+
const anchorAndShadows = anchors
|
|
76
|
+
.map((anchor) => ({
|
|
77
|
+
anchor,
|
|
78
|
+
anchorShadow: anchorShapes.find(
|
|
79
|
+
(shape) => shape.attrs.adjustType === anchor.adjustType
|
|
80
|
+
) as Konva.Circle
|
|
81
|
+
}))
|
|
82
|
+
.filter((o) => o.anchorShadow !== void 0);
|
|
83
|
+
return { anchorAndShadows };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
protected render: Render;
|
|
87
|
+
group: Konva.Group;
|
|
88
|
+
// 占用区域,用于识别 hover 态
|
|
89
|
+
hoverRect: Konva.Rect;
|
|
90
|
+
id: string; // 就是 group 的id
|
|
91
|
+
/**
|
|
92
|
+
* 鼠标按下位置
|
|
93
|
+
*/
|
|
94
|
+
protected dropPoint: Konva.Vector2d = { x: 0, y: 0 };
|
|
95
|
+
/**
|
|
96
|
+
* 调整点 定义
|
|
97
|
+
*/
|
|
98
|
+
protected anchors: GraphAnchor[] = [];
|
|
99
|
+
/**
|
|
100
|
+
* 调整点 的 锚点
|
|
101
|
+
*/
|
|
102
|
+
protected anchorShadows: Konva.Circle[] = [];
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 调整点 定义
|
|
106
|
+
*/
|
|
107
|
+
protected linkAnchors: LinkDrawPoint[] = [];
|
|
108
|
+
/**
|
|
109
|
+
* 连接点 的 锚点
|
|
110
|
+
*/
|
|
111
|
+
protected linkAnchorShadows: Konva.Circle[] = [];
|
|
112
|
+
|
|
113
|
+
constructor(
|
|
114
|
+
render: Render,
|
|
115
|
+
dropPoint: Konva.Vector2d,
|
|
116
|
+
config: {
|
|
117
|
+
anchors: GraphAnchor[]
|
|
118
|
+
linkAnchors: AssetInfoPoint[]
|
|
119
|
+
type: GraphType
|
|
120
|
+
}
|
|
121
|
+
) {
|
|
122
|
+
this.render = render;
|
|
123
|
+
this.dropPoint = dropPoint;
|
|
124
|
+
this.id = nanoid();
|
|
125
|
+
this.group = new Konva.Group({
|
|
126
|
+
id: this.id,
|
|
127
|
+
name: 'asset',
|
|
128
|
+
assetType: AssetType.Graph,
|
|
129
|
+
graphType: config.type,
|
|
130
|
+
draggable: true
|
|
131
|
+
});
|
|
132
|
+
this.hoverRect = new Konva.Rect({
|
|
133
|
+
name: 'hoverRect',
|
|
134
|
+
x: 0,
|
|
135
|
+
y: 0,
|
|
136
|
+
hitStrokeWidth: this.render.toStageValue(this.render.bgSize * 2 + 2)
|
|
137
|
+
});
|
|
138
|
+
// 调整点 定义
|
|
139
|
+
this.anchors = config.anchors.map((o) => ({
|
|
140
|
+
...o,
|
|
141
|
+
// 补充信息
|
|
142
|
+
name: 'anchor',
|
|
143
|
+
groupId: this.group.id(),
|
|
144
|
+
type: config.type
|
|
145
|
+
}));
|
|
146
|
+
// 记录在 group 中
|
|
147
|
+
this.group.setAttr('anchors', this.anchors);
|
|
148
|
+
// 新建 调整点 的 锚点
|
|
149
|
+
for (const anchor of this.anchors) {
|
|
150
|
+
const circle = new Konva.Circle({
|
|
151
|
+
adjustType: anchor.adjustType,
|
|
152
|
+
anchorType: anchor.type,
|
|
153
|
+
name: anchor.name,
|
|
154
|
+
radius: 0
|
|
155
|
+
});
|
|
156
|
+
this.anchorShadows.push(circle);
|
|
157
|
+
this.group.add(circle);
|
|
158
|
+
}
|
|
159
|
+
// 连接点 定义
|
|
160
|
+
this.linkAnchors = config.linkAnchors.map(
|
|
161
|
+
(o) =>
|
|
162
|
+
({
|
|
163
|
+
...o,
|
|
164
|
+
id: nanoid(),
|
|
165
|
+
groupId: this.group.id(),
|
|
166
|
+
visible: false,
|
|
167
|
+
pairs: [],
|
|
168
|
+
direction: o.direction,
|
|
169
|
+
alias: o.alias
|
|
170
|
+
}) as LinkDrawPoint
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
// 连接点信息
|
|
174
|
+
this.group.setAttrs({ points: this.linkAnchors });
|
|
175
|
+
// 新建 连接点 的 锚点
|
|
176
|
+
for (const point of this.linkAnchors) {
|
|
177
|
+
const circle = new Konva.Circle({
|
|
178
|
+
name: 'link-anchor',
|
|
179
|
+
id: point.id,
|
|
180
|
+
x: point.x,
|
|
181
|
+
y: point.y,
|
|
182
|
+
radius: this.render.toStageValue(1),
|
|
183
|
+
stroke: 'rgba(0,0,255,1)',
|
|
184
|
+
strokeWidth: this.render.toStageValue(2),
|
|
185
|
+
visible: false,
|
|
186
|
+
direction: point.direction,
|
|
187
|
+
alias: point.alias
|
|
188
|
+
});
|
|
189
|
+
this.linkAnchorShadows.push(circle);
|
|
190
|
+
this.group.add(circle);
|
|
191
|
+
}
|
|
192
|
+
this.render.layer.add(this.group);
|
|
193
|
+
this.render.redraw([GraphDraw.NAME]);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 调整进行时
|
|
198
|
+
* @param point 鼠标位置 相对位置
|
|
199
|
+
*/
|
|
200
|
+
abstract drawMove(point: Konva.Vector2d): void;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 调整结束
|
|
204
|
+
*/
|
|
205
|
+
drawEnd(size?: { width: number; height: number }, pos?: { x: number; y: number }): void {
|
|
206
|
+
this.hoverRect?.position({ x: pos?.x ?? 0, y: pos?.y ?? 0 });
|
|
207
|
+
this.hoverRect.size({ width: size?.width ?? this.group.width(), height: size?.height ?? this.group.height() });
|
|
208
|
+
this.hoverRect.on('mouseenter', () => {
|
|
209
|
+
// 防止进入调整点,重复处理
|
|
210
|
+
if (!this.group.attrs.hoverAnchor) {
|
|
211
|
+
this.group.setAttr('hover', true);
|
|
212
|
+
this.render.redraw([GraphDraw.NAME]);
|
|
213
|
+
}
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
// 调整产生 redraw,导致离开调整点不触发其 mouseleave(进入其他元素区域除外)
|
|
216
|
+
// 在此静态补充“离开调整点”
|
|
217
|
+
// 不影响正常处理(调整点会不停 hoverAnchor = true)
|
|
218
|
+
this.group.setAttr('hoverAnchor', false);
|
|
219
|
+
})
|
|
220
|
+
// 显示 连接点
|
|
221
|
+
this.render.linkTool.pointsVisible(true, this.group);
|
|
222
|
+
})
|
|
223
|
+
this.hoverRect.on('mouseleave', () => {
|
|
224
|
+
// 延迟事件,使调整点的 mouseleave 优先
|
|
225
|
+
setTimeout(() => {
|
|
226
|
+
// 防止进入调整点,重复处理
|
|
227
|
+
// 补充 2,快速调整会漏掉
|
|
228
|
+
if (!this.group.attrs.hoverAnchor) {
|
|
229
|
+
this.group.setAttr('hover', false);
|
|
230
|
+
this.group.setAttr('hoverAnchor', false);
|
|
231
|
+
this.render.redraw([GraphDraw.NAME]);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
// 隐藏 连接点
|
|
235
|
+
this.render.linkTool.pointsVisible(false, this.group);
|
|
236
|
+
// 隐藏 hover 框
|
|
237
|
+
this.group.findOne('#hoverRect')?.visible(false);
|
|
238
|
+
})
|
|
239
|
+
this.group.add(this.hoverRect);
|
|
240
|
+
}
|
|
241
|
+
}
|