aldehyde 0.2.493 → 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/column-chart/index.js +2 -2
- package/lib/lowcode-components/column-chart/index.js.map +1 -1
- 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/line-bar-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/line-bar-chart/index.js +6 -2
- package/lib/lowcode-components/line-bar-chart/index.js.map +1 -1
- package/lib/lowcode-components/line-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/line-chart/index.js +6 -2
- package/lib/lowcode-components/line-chart/index.js.map +1 -1
- 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/column-chart/index.tsx +2 -2
- 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/line-bar-chart/index.tsx +5 -2
- package/src/aldehyde/lowcode-components/line-chart/index.tsx +5 -2
- 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,223 +1,223 @@
|
|
|
1
|
-
import { nanoid } from 'nanoid';
|
|
2
|
-
import Konva from 'konva';
|
|
3
|
-
import { Render } from '../index';
|
|
4
|
-
import { LinkDrawPoint, LinkDrawPair } from '../types';
|
|
5
|
-
import { LinkDraw, RulerDraw, PreviewDraw } from '../draws';
|
|
6
|
-
|
|
7
|
-
export class LinkTool {
|
|
8
|
-
|
|
9
|
-
private render: Render;
|
|
10
|
-
constructor(render: Render) {
|
|
11
|
-
this.render = render;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
pointsVisible(visible: boolean, group?: Konva.Group) {
|
|
15
|
-
if (!this.render.config.readonly) {
|
|
16
|
-
const start = group ?? this.render.layer;
|
|
17
|
-
// 查找深层 points
|
|
18
|
-
for (const asset of [
|
|
19
|
-
...(['asset', 'sub-asset'].includes(start.name()) ? [start] : []),
|
|
20
|
-
...start.find('.asset'),
|
|
21
|
-
...start.find('.sub-asset')
|
|
22
|
-
]) {
|
|
23
|
-
const points = (asset as Konva.Node).getAttr('points') ?? [];
|
|
24
|
-
asset.setAttrs({
|
|
25
|
-
points: points.map((o: any) => ({ ...o, visible }))
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
// 拐点操作中,此处不重绘
|
|
29
|
-
if (!(this.render.draws[LinkDraw.NAME] as LinkDraw)?.state.linkManualing) {
|
|
30
|
-
// 重绘
|
|
31
|
-
this.render.redraw([LinkDraw.NAME, RulerDraw.NAME, PreviewDraw.NAME]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
remove(target?: Konva.Line) {
|
|
37
|
-
const line = target ?? this.linkCurrent;
|
|
38
|
-
if (line) {
|
|
39
|
-
const { groupId, pointId, pairId } = line.getAttrs();
|
|
40
|
-
|
|
41
|
-
if (groupId && pointId && pairId) {
|
|
42
|
-
const group = this.render.layer.findOne(`#${groupId}`) as Konva.Group;
|
|
43
|
-
if (group) {
|
|
44
|
-
const points = (group.getAttr('points') ?? []) as LinkDrawPoint[];
|
|
45
|
-
const point = points.find((o) => o.id === pointId);
|
|
46
|
-
if (point) {
|
|
47
|
-
const pairIndex = (point.pairs ?? ([] as LinkDrawPair[])).findIndex((o) => o.id === pairId);
|
|
48
|
-
if (pairIndex > -1) {
|
|
49
|
-
const pair = point.pairs.splice(pairIndex, 1)[0];
|
|
50
|
-
|
|
51
|
-
if (group.attrs.manualPointsMap && group.attrs.manualPointsMap[pair.id]) {
|
|
52
|
-
group.setAttr('manualPointsMap', {
|
|
53
|
-
...group.attrs.manualPointsMap,
|
|
54
|
-
[pair.id]: undefined
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 重绘
|
|
59
|
-
this.render.redraw([
|
|
60
|
-
LinkDraw.NAME,
|
|
61
|
-
RulerDraw.NAME,
|
|
62
|
-
PreviewDraw.NAME
|
|
63
|
-
]);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 刷新 json 的 id、事件
|
|
72
|
-
jsonIdCover(assets: any[]) {
|
|
73
|
-
let deepAssets = [...assets];
|
|
74
|
-
const idMap = new Map();
|
|
75
|
-
|
|
76
|
-
while (deepAssets.length > 0) {
|
|
77
|
-
const asset = deepAssets.shift();
|
|
78
|
-
if (asset) {
|
|
79
|
-
if (Array.isArray(asset.attrs.points)) {
|
|
80
|
-
for (const point of asset.attrs.points) {
|
|
81
|
-
if (Array.isArray(point.pairs)) {
|
|
82
|
-
for (const pair of point.pairs) {
|
|
83
|
-
if (pair.from.groupId && !idMap.has(pair.from.groupId)) {
|
|
84
|
-
idMap.set(pair.from.groupId, 'g:' + nanoid());
|
|
85
|
-
}
|
|
86
|
-
if (pair.to.groupId && !idMap.has(pair.to.groupId)) {
|
|
87
|
-
idMap.set(pair.to.groupId, 'g:' + nanoid());
|
|
88
|
-
}
|
|
89
|
-
if (pair.from.pointId && !idMap.has(pair.from.pointId)) {
|
|
90
|
-
idMap.set(pair.from.pointId, 'p:' + nanoid());
|
|
91
|
-
}
|
|
92
|
-
if (pair.to.pointId && !idMap.has(pair.to.pointId)) {
|
|
93
|
-
idMap.set(pair.to.pointId, 'p:' + nanoid());
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (point.id) {
|
|
98
|
-
if (!idMap.has(point.id)) {
|
|
99
|
-
idMap.set(point.id, 'p:' + nanoid());
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (point.groupId) {
|
|
103
|
-
if (!idMap.has(point.groupId)) {
|
|
104
|
-
idMap.set(point.groupId, 'g:' + nanoid());
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (asset.attrs.id) {
|
|
110
|
-
if (!idMap.has(asset.attrs.id)) {
|
|
111
|
-
idMap.set(asset.attrs.id, 'n:' + nanoid());
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (Array.isArray(asset.children)) {
|
|
115
|
-
deepAssets.push(...asset.children);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
deepAssets = [...assets];
|
|
121
|
-
|
|
122
|
-
while (deepAssets.length > 0) {
|
|
123
|
-
const asset = deepAssets.shift();
|
|
124
|
-
if (asset) {
|
|
125
|
-
if (idMap.has(asset.attrs.id)) {
|
|
126
|
-
asset.attrs.id = idMap.get(asset.attrs.id);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (Array.isArray(asset.attrs.points)) {
|
|
130
|
-
for (const point of asset.attrs.points) {
|
|
131
|
-
if (Array.isArray(point.pairs)) {
|
|
132
|
-
for (const pair of point.pairs) {
|
|
133
|
-
pair.disabled = true;
|
|
134
|
-
if (pair.id) {
|
|
135
|
-
pair.id = 'pr:' + nanoid();
|
|
136
|
-
}
|
|
137
|
-
if (idMap.has(pair.from.groupId)) {
|
|
138
|
-
pair.from.groupId = idMap.get(pair.from.groupId);
|
|
139
|
-
}
|
|
140
|
-
if (idMap.has(pair.to.groupId)) {
|
|
141
|
-
pair.to.groupId = idMap.get(pair.to.groupId);
|
|
142
|
-
}
|
|
143
|
-
if (idMap.has(pair.from.pointId)) {
|
|
144
|
-
pair.from.pointId = idMap.get(pair.from.pointId);
|
|
145
|
-
}
|
|
146
|
-
if (idMap.has(pair.to.pointId)) {
|
|
147
|
-
pair.to.pointId = idMap.get(pair.to.pointId);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (idMap.has(point.id)) {
|
|
153
|
-
const anchor = asset.children.find((o: any) => o.attrs.id === point.id);
|
|
154
|
-
point.id = idMap.get(point.id);
|
|
155
|
-
if (anchor) {
|
|
156
|
-
anchor.attrs.id = point.id;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (idMap.has(point.groupId)) {
|
|
161
|
-
point.groupId = idMap.get(point.groupId);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (Array.isArray(asset.children)) {
|
|
167
|
-
deepAssets.push(...asset.children);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// 把深层 group 的 id 统一为顶层 group 的 id
|
|
174
|
-
groupIdCover(group: Konva.Group) {
|
|
175
|
-
const groupId = group.id();
|
|
176
|
-
const subGroups = group.find('.sub-asset') as Konva.Group[];
|
|
177
|
-
while (subGroups.length > 0) {
|
|
178
|
-
const subGroup = subGroups.shift() as Konva.Group | undefined;
|
|
179
|
-
if (subGroup) {
|
|
180
|
-
const points = subGroup.attrs.points;
|
|
181
|
-
if (Array.isArray(points)) {
|
|
182
|
-
for (const point of points) {
|
|
183
|
-
point.rawGroupId = point.groupId;
|
|
184
|
-
point.groupId = groupId;
|
|
185
|
-
for (const pair of point.pairs) {
|
|
186
|
-
pair.from.rawGroupId = pair.from.groupId;
|
|
187
|
-
pair.from.groupId = groupId;
|
|
188
|
-
pair.to.rawGroupId = pair.to.groupId;
|
|
189
|
-
pair.to.groupId = groupId;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
subGroups.push(...(subGroup.find('.sub-asset') as Konva.Group[]));
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// 选中连接线
|
|
199
|
-
linkCurrent: Konva.Line | undefined = undefined;
|
|
200
|
-
|
|
201
|
-
// 选中
|
|
202
|
-
select(link: Konva.Line) {
|
|
203
|
-
this.render.selectionTool.selectingClear();
|
|
204
|
-
this.linkCurrent = link;
|
|
205
|
-
this.render.emit('link-selection-change', this.linkCurrent);
|
|
206
|
-
// 重绘
|
|
207
|
-
this.render.redraw([
|
|
208
|
-
LinkDraw.NAME, // 更新连线
|
|
209
|
-
RulerDraw.NAME // 更新比例尺
|
|
210
|
-
]);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// 清空选中
|
|
214
|
-
selectingClear() {
|
|
215
|
-
this.linkCurrent = undefined;
|
|
216
|
-
this.render.emit('link-selection-change', undefined);
|
|
217
|
-
// 重绘
|
|
218
|
-
this.render.redraw([
|
|
219
|
-
LinkDraw.NAME, // 更新连线
|
|
220
|
-
RulerDraw.NAME
|
|
221
|
-
]);
|
|
222
|
-
}
|
|
1
|
+
import { nanoid } from 'nanoid';
|
|
2
|
+
import Konva from 'konva';
|
|
3
|
+
import { Render } from '../index';
|
|
4
|
+
import { LinkDrawPoint, LinkDrawPair } from '../types';
|
|
5
|
+
import { LinkDraw, RulerDraw, PreviewDraw } from '../draws';
|
|
6
|
+
|
|
7
|
+
export class LinkTool {
|
|
8
|
+
|
|
9
|
+
private render: Render;
|
|
10
|
+
constructor(render: Render) {
|
|
11
|
+
this.render = render;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
pointsVisible(visible: boolean, group?: Konva.Group) {
|
|
15
|
+
if (!this.render.config.readonly) {
|
|
16
|
+
const start = group ?? this.render.layer;
|
|
17
|
+
// 查找深层 points
|
|
18
|
+
for (const asset of [
|
|
19
|
+
...(['asset', 'sub-asset'].includes(start.name()) ? [start] : []),
|
|
20
|
+
...start.find('.asset'),
|
|
21
|
+
...start.find('.sub-asset')
|
|
22
|
+
]) {
|
|
23
|
+
const points = (asset as Konva.Node).getAttr('points') ?? [];
|
|
24
|
+
asset.setAttrs({
|
|
25
|
+
points: points.map((o: any) => ({ ...o, visible }))
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// 拐点操作中,此处不重绘
|
|
29
|
+
if (!(this.render.draws[LinkDraw.NAME] as LinkDraw)?.state.linkManualing) {
|
|
30
|
+
// 重绘
|
|
31
|
+
this.render.redraw([LinkDraw.NAME, RulerDraw.NAME, PreviewDraw.NAME]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
remove(target?: Konva.Line) {
|
|
37
|
+
const line = target ?? this.linkCurrent;
|
|
38
|
+
if (line) {
|
|
39
|
+
const { groupId, pointId, pairId } = line.getAttrs();
|
|
40
|
+
|
|
41
|
+
if (groupId && pointId && pairId) {
|
|
42
|
+
const group = this.render.layer.findOne(`#${groupId}`) as Konva.Group;
|
|
43
|
+
if (group) {
|
|
44
|
+
const points = (group.getAttr('points') ?? []) as LinkDrawPoint[];
|
|
45
|
+
const point = points.find((o) => o.id === pointId);
|
|
46
|
+
if (point) {
|
|
47
|
+
const pairIndex = (point.pairs ?? ([] as LinkDrawPair[])).findIndex((o) => o.id === pairId);
|
|
48
|
+
if (pairIndex > -1) {
|
|
49
|
+
const pair = point.pairs.splice(pairIndex, 1)[0];
|
|
50
|
+
|
|
51
|
+
if (group.attrs.manualPointsMap && group.attrs.manualPointsMap[pair.id]) {
|
|
52
|
+
group.setAttr('manualPointsMap', {
|
|
53
|
+
...group.attrs.manualPointsMap,
|
|
54
|
+
[pair.id]: undefined
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 重绘
|
|
59
|
+
this.render.redraw([
|
|
60
|
+
LinkDraw.NAME,
|
|
61
|
+
RulerDraw.NAME,
|
|
62
|
+
PreviewDraw.NAME
|
|
63
|
+
]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 刷新 json 的 id、事件
|
|
72
|
+
jsonIdCover(assets: any[]) {
|
|
73
|
+
let deepAssets = [...assets];
|
|
74
|
+
const idMap = new Map();
|
|
75
|
+
|
|
76
|
+
while (deepAssets.length > 0) {
|
|
77
|
+
const asset = deepAssets.shift();
|
|
78
|
+
if (asset) {
|
|
79
|
+
if (Array.isArray(asset.attrs.points)) {
|
|
80
|
+
for (const point of asset.attrs.points) {
|
|
81
|
+
if (Array.isArray(point.pairs)) {
|
|
82
|
+
for (const pair of point.pairs) {
|
|
83
|
+
if (pair.from.groupId && !idMap.has(pair.from.groupId)) {
|
|
84
|
+
idMap.set(pair.from.groupId, 'g:' + nanoid());
|
|
85
|
+
}
|
|
86
|
+
if (pair.to.groupId && !idMap.has(pair.to.groupId)) {
|
|
87
|
+
idMap.set(pair.to.groupId, 'g:' + nanoid());
|
|
88
|
+
}
|
|
89
|
+
if (pair.from.pointId && !idMap.has(pair.from.pointId)) {
|
|
90
|
+
idMap.set(pair.from.pointId, 'p:' + nanoid());
|
|
91
|
+
}
|
|
92
|
+
if (pair.to.pointId && !idMap.has(pair.to.pointId)) {
|
|
93
|
+
idMap.set(pair.to.pointId, 'p:' + nanoid());
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (point.id) {
|
|
98
|
+
if (!idMap.has(point.id)) {
|
|
99
|
+
idMap.set(point.id, 'p:' + nanoid());
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (point.groupId) {
|
|
103
|
+
if (!idMap.has(point.groupId)) {
|
|
104
|
+
idMap.set(point.groupId, 'g:' + nanoid());
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (asset.attrs.id) {
|
|
110
|
+
if (!idMap.has(asset.attrs.id)) {
|
|
111
|
+
idMap.set(asset.attrs.id, 'n:' + nanoid());
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (Array.isArray(asset.children)) {
|
|
115
|
+
deepAssets.push(...asset.children);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
deepAssets = [...assets];
|
|
121
|
+
|
|
122
|
+
while (deepAssets.length > 0) {
|
|
123
|
+
const asset = deepAssets.shift();
|
|
124
|
+
if (asset) {
|
|
125
|
+
if (idMap.has(asset.attrs.id)) {
|
|
126
|
+
asset.attrs.id = idMap.get(asset.attrs.id);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (Array.isArray(asset.attrs.points)) {
|
|
130
|
+
for (const point of asset.attrs.points) {
|
|
131
|
+
if (Array.isArray(point.pairs)) {
|
|
132
|
+
for (const pair of point.pairs) {
|
|
133
|
+
pair.disabled = true;
|
|
134
|
+
if (pair.id) {
|
|
135
|
+
pair.id = 'pr:' + nanoid();
|
|
136
|
+
}
|
|
137
|
+
if (idMap.has(pair.from.groupId)) {
|
|
138
|
+
pair.from.groupId = idMap.get(pair.from.groupId);
|
|
139
|
+
}
|
|
140
|
+
if (idMap.has(pair.to.groupId)) {
|
|
141
|
+
pair.to.groupId = idMap.get(pair.to.groupId);
|
|
142
|
+
}
|
|
143
|
+
if (idMap.has(pair.from.pointId)) {
|
|
144
|
+
pair.from.pointId = idMap.get(pair.from.pointId);
|
|
145
|
+
}
|
|
146
|
+
if (idMap.has(pair.to.pointId)) {
|
|
147
|
+
pair.to.pointId = idMap.get(pair.to.pointId);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (idMap.has(point.id)) {
|
|
153
|
+
const anchor = asset.children.find((o: any) => o.attrs.id === point.id);
|
|
154
|
+
point.id = idMap.get(point.id);
|
|
155
|
+
if (anchor) {
|
|
156
|
+
anchor.attrs.id = point.id;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (idMap.has(point.groupId)) {
|
|
161
|
+
point.groupId = idMap.get(point.groupId);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (Array.isArray(asset.children)) {
|
|
167
|
+
deepAssets.push(...asset.children);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 把深层 group 的 id 统一为顶层 group 的 id
|
|
174
|
+
groupIdCover(group: Konva.Group) {
|
|
175
|
+
const groupId = group.id();
|
|
176
|
+
const subGroups = group.find('.sub-asset') as Konva.Group[];
|
|
177
|
+
while (subGroups.length > 0) {
|
|
178
|
+
const subGroup = subGroups.shift() as Konva.Group | undefined;
|
|
179
|
+
if (subGroup) {
|
|
180
|
+
const points = subGroup.attrs.points;
|
|
181
|
+
if (Array.isArray(points)) {
|
|
182
|
+
for (const point of points) {
|
|
183
|
+
point.rawGroupId = point.groupId;
|
|
184
|
+
point.groupId = groupId;
|
|
185
|
+
for (const pair of point.pairs) {
|
|
186
|
+
pair.from.rawGroupId = pair.from.groupId;
|
|
187
|
+
pair.from.groupId = groupId;
|
|
188
|
+
pair.to.rawGroupId = pair.to.groupId;
|
|
189
|
+
pair.to.groupId = groupId;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
subGroups.push(...(subGroup.find('.sub-asset') as Konva.Group[]));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// 选中连接线
|
|
199
|
+
linkCurrent: Konva.Line | undefined = undefined;
|
|
200
|
+
|
|
201
|
+
// 选中
|
|
202
|
+
select(link: Konva.Line) {
|
|
203
|
+
this.render.selectionTool.selectingClear();
|
|
204
|
+
this.linkCurrent = link;
|
|
205
|
+
this.render.emit('link-selection-change', this.linkCurrent);
|
|
206
|
+
// 重绘
|
|
207
|
+
this.render.redraw([
|
|
208
|
+
LinkDraw.NAME, // 更新连线
|
|
209
|
+
RulerDraw.NAME // 更新比例尺
|
|
210
|
+
]);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// 清空选中
|
|
214
|
+
selectingClear() {
|
|
215
|
+
this.linkCurrent = undefined;
|
|
216
|
+
this.render.emit('link-selection-change', undefined);
|
|
217
|
+
// 重绘
|
|
218
|
+
this.render.redraw([
|
|
219
|
+
LinkDraw.NAME, // 更新连线
|
|
220
|
+
RulerDraw.NAME
|
|
221
|
+
]);
|
|
222
|
+
}
|
|
223
223
|
}
|