@flowgram-vue/renderer 0.2.0
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/LICENSE +22 -0
- package/dist/index.cjs +2933 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +721 -0
- package/dist/index.js +2918 -0
- package/dist/index.js.map +1 -0
- package/index.module.less +167 -0
- package/package.json +64 -0
- package/src/components/Adder.ts +107 -0
- package/src/components/BranchDraggableRenderer.ts +77 -0
- package/src/components/Collapse.ts +87 -0
- package/src/components/CollapseAdder.ts +94 -0
- package/src/components/CustomLine.ts +35 -0
- package/src/components/LabelsRenderer.ts +162 -0
- package/src/components/LinesRenderer.ts +99 -0
- package/src/components/MarkerActivatedArrow.ts +44 -0
- package/src/components/MarkerArrow.ts +44 -0
- package/src/components/RoundedTurningLine.ts +165 -0
- package/src/components/StraightLine.ts +31 -0
- package/src/components/utils.ts +295 -0
- package/src/entities/README.md +3 -0
- package/src/entities/flow-drag-entity.ts +267 -0
- package/src/entities/flow-select-config-entity.ts +114 -0
- package/src/entities/index.ts +8 -0
- package/src/entities/selector-box-config-entity.ts +88 -0
- package/src/env.d.ts +10 -0
- package/src/flow-renderer-container-module.ts +14 -0
- package/src/flow-renderer-contribution.ts +12 -0
- package/src/flow-renderer-registry.ts +155 -0
- package/src/flow-renderer-resize-observer.ts +56 -0
- package/src/hooks/use-base-color.ts +26 -0
- package/src/index.ts +16 -0
- package/src/layer-vue-provide.ts +44 -0
- package/src/layers/flow-context-menu-layer.ts +153 -0
- package/src/layers/flow-debug-layer.ts +227 -0
- package/src/layers/flow-drag-layer.ts +413 -0
- package/src/layers/flow-labels-layer.ts +100 -0
- package/src/layers/flow-lines-layer.ts +111 -0
- package/src/layers/flow-nodes-content-layer.ts +155 -0
- package/src/layers/flow-nodes-transform-layer.ts +151 -0
- package/src/layers/flow-scroll-bar-layer.ts +401 -0
- package/src/layers/flow-scroll-limit-layer.ts +36 -0
- package/src/layers/flow-selector-bounds-layer.ts +191 -0
- package/src/layers/flow-selector-box-layer.ts +244 -0
- package/src/layers/index.ts +16 -0
- package/src/utils/element.ts +36 -0
- package/src/utils/find-selected-nodes.ts +80 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/scroll-bar-events.ts +13 -0
- package/src/utils/scroll-limit.ts +58 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2933 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('@flowgram-vue/utils');
|
|
4
|
+
var document$1 = require('@flowgram-vue/document');
|
|
5
|
+
var core = require('@flowgram-vue/core');
|
|
6
|
+
var lodashEs = require('lodash-es');
|
|
7
|
+
var inversify = require('inversify');
|
|
8
|
+
var vue = require('vue');
|
|
9
|
+
var i18n = require('@flowgram-vue/i18n');
|
|
10
|
+
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
14
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
15
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
16
|
+
if (decorator = decorators[i])
|
|
17
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
18
|
+
if (kind && result) __defProp(target, key, result);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var BASE_DEFAULT_COLOR = "#BBBFC4";
|
|
22
|
+
var BASE_DEFAULT_ACTIVATED_COLOR = "#82A7FC";
|
|
23
|
+
function getBaseColor(options) {
|
|
24
|
+
return {
|
|
25
|
+
baseColor: options?.constants?.[document$1.ConstantKeys.BASE_COLOR] || BASE_DEFAULT_COLOR,
|
|
26
|
+
baseActivatedColor: options?.constants?.[document$1.ConstantKeys.BASE_ACTIVATED_COLOR] || BASE_DEFAULT_ACTIVATED_COLOR
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function useBaseColor() {
|
|
30
|
+
const options = core.useService(document$1.FlowDocumentOptions);
|
|
31
|
+
return getBaseColor(options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/components/utils.ts
|
|
35
|
+
var DEFAULT_LINE_ATTRS = {
|
|
36
|
+
stroke: BASE_DEFAULT_COLOR,
|
|
37
|
+
fill: "transparent",
|
|
38
|
+
strokeLinecap: "round",
|
|
39
|
+
strokeLinejoin: "round"
|
|
40
|
+
};
|
|
41
|
+
var DEFAULT_RADIUS = document$1.DEFAULT_SPACING[document$1.DefaultSpacingKey.ROUNDED_LINE_RADIUS];
|
|
42
|
+
var DEFAULT_LABEL_ACTIVATE_HEIGHT = 32;
|
|
43
|
+
function getHorizontalVertices(line, xRadius = 16, yRadius = 20) {
|
|
44
|
+
const { from, to, type } = line || {};
|
|
45
|
+
const deltaY = Math.abs(to.y - from.y);
|
|
46
|
+
const deltaX = Math.abs(to.x - from.x);
|
|
47
|
+
const radiusXCount = deltaX / xRadius;
|
|
48
|
+
const radiusYCount = deltaY / yRadius;
|
|
49
|
+
let res = [];
|
|
50
|
+
if (radiusXCount < 1) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
switch (type) {
|
|
54
|
+
case document$1.FlowTransitionLineEnum.DIVERGE_LINE:
|
|
55
|
+
case document$1.FlowTransitionLineEnum.DRAGGING_LINE:
|
|
56
|
+
if (radiusXCount <= 1) {
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
x: to.x,
|
|
60
|
+
y: from.y,
|
|
61
|
+
radiusX: deltaX
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
res = [
|
|
66
|
+
{
|
|
67
|
+
x: from.x + yRadius,
|
|
68
|
+
y: from.y
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
x: from.x + yRadius,
|
|
72
|
+
y: to.y
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
if (radiusXCount < 2) {
|
|
76
|
+
const firstRadius = deltaX - yRadius;
|
|
77
|
+
res = [
|
|
78
|
+
{
|
|
79
|
+
x: from.x + firstRadius,
|
|
80
|
+
y: from.y,
|
|
81
|
+
// 第一个圆角收缩 y 半径
|
|
82
|
+
radiusX: firstRadius
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
x: from.x + firstRadius,
|
|
86
|
+
y: to.y
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
if (radiusYCount < 2) {
|
|
91
|
+
res[0].moveY = deltaY / 2;
|
|
92
|
+
res[1].moveY = deltaY / 2;
|
|
93
|
+
}
|
|
94
|
+
return res;
|
|
95
|
+
case document$1.FlowTransitionLineEnum.MERGE_LINE:
|
|
96
|
+
if (radiusXCount < 2) {
|
|
97
|
+
return [
|
|
98
|
+
{
|
|
99
|
+
x: to.x,
|
|
100
|
+
y: from.y
|
|
101
|
+
}
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
res = [
|
|
105
|
+
{
|
|
106
|
+
x: to.x - yRadius,
|
|
107
|
+
y: from.y
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
x: to.x - yRadius,
|
|
111
|
+
y: to.y
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
if (radiusYCount < 2) {
|
|
115
|
+
res[0].moveY = deltaY / 2;
|
|
116
|
+
res[1].moveY = deltaY / 2;
|
|
117
|
+
}
|
|
118
|
+
return res;
|
|
119
|
+
}
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
function getVertices(line, xRadius = 16, yRadius = 20) {
|
|
123
|
+
const { from, to, type } = line || {};
|
|
124
|
+
const deltaY = Math.abs(to.y - from.y);
|
|
125
|
+
const deltaX = Math.abs(to.x - from.x);
|
|
126
|
+
const radiusYCount = deltaY / yRadius;
|
|
127
|
+
const radiusXCount = deltaX / xRadius;
|
|
128
|
+
let res = [];
|
|
129
|
+
if (radiusYCount < 1) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
switch (type) {
|
|
133
|
+
case document$1.FlowTransitionLineEnum.DIVERGE_LINE:
|
|
134
|
+
case document$1.FlowTransitionLineEnum.DRAGGING_LINE:
|
|
135
|
+
if (radiusYCount <= 1) {
|
|
136
|
+
return [
|
|
137
|
+
{
|
|
138
|
+
x: to.x,
|
|
139
|
+
y: from.y,
|
|
140
|
+
radiusY: deltaY
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
res = [
|
|
145
|
+
{
|
|
146
|
+
x: from.x,
|
|
147
|
+
y: from.y + yRadius
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
x: to.x,
|
|
151
|
+
y: from.y + yRadius
|
|
152
|
+
}
|
|
153
|
+
];
|
|
154
|
+
if (radiusYCount < 2) {
|
|
155
|
+
const firstRadius = deltaY - yRadius;
|
|
156
|
+
res = [
|
|
157
|
+
{
|
|
158
|
+
x: from.x,
|
|
159
|
+
y: from.y + firstRadius,
|
|
160
|
+
// 第一个圆角收缩 y 半径
|
|
161
|
+
radiusY: firstRadius
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
x: to.x,
|
|
165
|
+
y: from.y + firstRadius
|
|
166
|
+
}
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
if (radiusXCount < 2) {
|
|
170
|
+
res[0].moveX = deltaX / 2;
|
|
171
|
+
res[1].moveX = deltaX / 2;
|
|
172
|
+
}
|
|
173
|
+
return res;
|
|
174
|
+
case document$1.FlowTransitionLineEnum.MERGE_LINE:
|
|
175
|
+
if (radiusYCount < 2) {
|
|
176
|
+
return [
|
|
177
|
+
{
|
|
178
|
+
x: from.x,
|
|
179
|
+
y: to.y
|
|
180
|
+
}
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
res = [
|
|
184
|
+
{
|
|
185
|
+
x: from.x,
|
|
186
|
+
y: to.y - yRadius
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
x: to.x,
|
|
190
|
+
y: to.y - yRadius
|
|
191
|
+
}
|
|
192
|
+
];
|
|
193
|
+
if (radiusXCount < 2) {
|
|
194
|
+
res[0].moveX = deltaX / 2;
|
|
195
|
+
res[1].moveX = deltaX / 2;
|
|
196
|
+
}
|
|
197
|
+
return res;
|
|
198
|
+
}
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
function getTransitionLabelHoverWidth(data) {
|
|
202
|
+
const { isVertical } = data.entity;
|
|
203
|
+
if (isVertical) {
|
|
204
|
+
const nextWidth = data.entity.next?.firstChild && !data.entity.next.isInlineBlocks ? data.entity.next.firstChild.getData(document$1.FlowNodeTransformData).size.width : data.entity.next?.getData(document$1.FlowNodeTransformData).size.width;
|
|
205
|
+
const maxWidth = Math.max(
|
|
206
|
+
data.entity.getData(document$1.FlowNodeTransformData)?.size.width ?? document$1.DEFAULT_SPACING[document$1.DefaultSpacingKey.HOVER_AREA_WIDTH],
|
|
207
|
+
nextWidth || 0
|
|
208
|
+
);
|
|
209
|
+
return maxWidth;
|
|
210
|
+
}
|
|
211
|
+
if (data.transform.next) {
|
|
212
|
+
return data.transform.next.inputPoint.x - data.transform.outputPoint.x;
|
|
213
|
+
}
|
|
214
|
+
return DEFAULT_LABEL_ACTIVATE_HEIGHT;
|
|
215
|
+
}
|
|
216
|
+
function getTransitionLabelHoverHeight(data) {
|
|
217
|
+
const { isVertical } = data.entity;
|
|
218
|
+
if (isVertical) {
|
|
219
|
+
if (data.transform.next) {
|
|
220
|
+
return data.transform.next.inputPoint.y - data.transform.outputPoint.y;
|
|
221
|
+
}
|
|
222
|
+
return DEFAULT_LABEL_ACTIVATE_HEIGHT;
|
|
223
|
+
}
|
|
224
|
+
const nextHeight = data.entity.next?.firstChild && !data.entity.next.isInlineBlocks ? data.entity.next.firstChild.getData(document$1.FlowNodeTransformData).size.height : data.entity.next?.getData(document$1.FlowNodeTransformData).size.height;
|
|
225
|
+
const maxHeight = Math.max(
|
|
226
|
+
data.entity.getData(document$1.FlowNodeTransformData)?.size.height || 280,
|
|
227
|
+
nextHeight || 0
|
|
228
|
+
);
|
|
229
|
+
return maxHeight;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/entities/flow-drag-entity.ts
|
|
233
|
+
var BRANCH_HOVER_HEIGHT = 64;
|
|
234
|
+
var SCROLL_DELTA = 4;
|
|
235
|
+
var SCROLL_INTERVAL = 20;
|
|
236
|
+
var SCROLL_BOUNDING = 20;
|
|
237
|
+
var EDITOR_LEFT_BAR_WIDTH = 60;
|
|
238
|
+
var FlowDragEntity = class extends core.ConfigEntity {
|
|
239
|
+
constructor(conf) {
|
|
240
|
+
super(conf);
|
|
241
|
+
this.containerX = 0;
|
|
242
|
+
this.containerY = 0;
|
|
243
|
+
this.playgroundConfigEntity = this.entityManager.getEntity(
|
|
244
|
+
core.PlaygroundConfigEntity,
|
|
245
|
+
true
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
get hasScroll() {
|
|
249
|
+
return Boolean(this._scrollXInterval || this._scrollYInterval);
|
|
250
|
+
}
|
|
251
|
+
isCollision(transition, rect, isBranch) {
|
|
252
|
+
const scale = this.playgroundConfigEntity.finalScale || 0;
|
|
253
|
+
if (isBranch) {
|
|
254
|
+
return this.isBranchCollision(transition, rect, scale);
|
|
255
|
+
}
|
|
256
|
+
return this.isNodeCollision(transition, rect, scale);
|
|
257
|
+
}
|
|
258
|
+
// 检测节点维度碰撞方法
|
|
259
|
+
isNodeCollision(transition, rect, scale) {
|
|
260
|
+
const { labels } = transition;
|
|
261
|
+
const { isVertical } = transition.entity;
|
|
262
|
+
const hasCollision = labels.some((label) => {
|
|
263
|
+
if (!label || ![
|
|
264
|
+
document$1.FlowTransitionLabelEnum.ADDER_LABEL,
|
|
265
|
+
document$1.FlowTransitionLabelEnum.COLLAPSE_ADDER_LABEL
|
|
266
|
+
].includes(label.type)) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
const hoverWidth = isVertical ? transition.transform.bounds.width : DEFAULT_LABEL_ACTIVATE_HEIGHT;
|
|
270
|
+
const hoverHeight = isVertical ? DEFAULT_LABEL_ACTIVATE_HEIGHT : transition.transform.bounds.height;
|
|
271
|
+
const labelRect = new utils.Rectangle(
|
|
272
|
+
(label.offset.x - hoverWidth / 2) * scale,
|
|
273
|
+
(label.offset.y - hoverHeight / 2) * scale,
|
|
274
|
+
hoverWidth * scale,
|
|
275
|
+
hoverHeight * scale
|
|
276
|
+
);
|
|
277
|
+
return utils.Rectangle.intersects(labelRect, rect);
|
|
278
|
+
});
|
|
279
|
+
return {
|
|
280
|
+
hasCollision,
|
|
281
|
+
// 节点不关心 offsetType
|
|
282
|
+
labelOffsetType: void 0
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
// 检测分支维度碰撞
|
|
286
|
+
isBranchCollision(transition, rect, scale) {
|
|
287
|
+
const { labels } = transition;
|
|
288
|
+
const { isVertical } = transition.entity;
|
|
289
|
+
let labelOffsetType = document$1.LABEL_SIDE_TYPE.NORMAL_BRANCH;
|
|
290
|
+
const hasCollision = labels.some((label) => {
|
|
291
|
+
if (!label || label.type !== document$1.FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
const hoverHeight = isVertical ? BRANCH_HOVER_HEIGHT : label.width || 0;
|
|
295
|
+
const hoverWidth = isVertical ? label.width || 0 : BRANCH_HOVER_HEIGHT;
|
|
296
|
+
const labelRect = new utils.Rectangle(
|
|
297
|
+
(label.offset.x - hoverWidth / 2) * scale,
|
|
298
|
+
(label.offset.y - hoverHeight / 2) * scale,
|
|
299
|
+
hoverWidth * scale,
|
|
300
|
+
hoverHeight * scale
|
|
301
|
+
);
|
|
302
|
+
const collision = utils.Rectangle.intersects(labelRect, rect);
|
|
303
|
+
if (collision) {
|
|
304
|
+
labelOffsetType = label.props.side;
|
|
305
|
+
}
|
|
306
|
+
return collision;
|
|
307
|
+
});
|
|
308
|
+
return {
|
|
309
|
+
hasCollision,
|
|
310
|
+
labelOffsetType
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
_startScrollX(origin, added) {
|
|
314
|
+
if (this._scrollXInterval) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const interval = window.setInterval(() => {
|
|
318
|
+
const current = this._scrollXInterval;
|
|
319
|
+
if (!current) return;
|
|
320
|
+
const scrollX = current.origin = added ? current.origin + SCROLL_DELTA : current.origin - SCROLL_DELTA;
|
|
321
|
+
this.playgroundConfigEntity.updateConfig({
|
|
322
|
+
scrollX
|
|
323
|
+
});
|
|
324
|
+
const playgroundConfig = this.playgroundConfigEntity.config;
|
|
325
|
+
if (playgroundConfig?.scrollX === scrollX) {
|
|
326
|
+
if (added) {
|
|
327
|
+
this.containerX += SCROLL_DELTA;
|
|
328
|
+
} else {
|
|
329
|
+
this.containerX -= SCROLL_DELTA;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}, SCROLL_INTERVAL);
|
|
333
|
+
this._scrollXInterval = { interval, origin };
|
|
334
|
+
}
|
|
335
|
+
_stopScrollX() {
|
|
336
|
+
if (this._scrollXInterval) {
|
|
337
|
+
clearInterval(this._scrollXInterval.interval);
|
|
338
|
+
this._scrollXInterval = void 0;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
_startScrollY(origin, added) {
|
|
342
|
+
if (this._scrollYInterval) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const interval = window.setInterval(() => {
|
|
346
|
+
const current = this._scrollYInterval;
|
|
347
|
+
if (!current) return;
|
|
348
|
+
const scrollY = current.origin = added ? current.origin + SCROLL_DELTA : current.origin - SCROLL_DELTA;
|
|
349
|
+
this.playgroundConfigEntity.updateConfig({
|
|
350
|
+
scrollY
|
|
351
|
+
});
|
|
352
|
+
const playgroundConfig = this.playgroundConfigEntity.config;
|
|
353
|
+
if (playgroundConfig?.scrollY === scrollY) {
|
|
354
|
+
if (added) {
|
|
355
|
+
this.containerY += SCROLL_DELTA;
|
|
356
|
+
} else {
|
|
357
|
+
this.containerY -= SCROLL_DELTA;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}, SCROLL_INTERVAL);
|
|
361
|
+
this._scrollYInterval = { interval, origin };
|
|
362
|
+
}
|
|
363
|
+
_stopScrollY() {
|
|
364
|
+
if (this._scrollYInterval) {
|
|
365
|
+
clearInterval(this._scrollYInterval.interval);
|
|
366
|
+
this._scrollYInterval = void 0;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
stopAllScroll() {
|
|
370
|
+
this._stopScrollX();
|
|
371
|
+
this._stopScrollY();
|
|
372
|
+
}
|
|
373
|
+
scrollDirection(e, x, y) {
|
|
374
|
+
const playgroundConfig = this.playgroundConfigEntity.config;
|
|
375
|
+
const currentScrollX = playgroundConfig.scrollX;
|
|
376
|
+
const currentScrollY = playgroundConfig.scrollY;
|
|
377
|
+
this.containerX = x;
|
|
378
|
+
this.containerY = y;
|
|
379
|
+
const clientRect = this.playgroundConfigEntity.playgroundDomNode.getBoundingClientRect();
|
|
380
|
+
const mouseToBottom = playgroundConfig.height + clientRect.y - e.clientY;
|
|
381
|
+
if (mouseToBottom < SCROLL_BOUNDING) {
|
|
382
|
+
this._startScrollY(currentScrollY, true);
|
|
383
|
+
return 1 /* BOTTOM */;
|
|
384
|
+
}
|
|
385
|
+
const mouseToTop = e.clientY - clientRect.y;
|
|
386
|
+
if (mouseToTop < SCROLL_BOUNDING) {
|
|
387
|
+
this._startScrollY(currentScrollY, false);
|
|
388
|
+
return 0 /* TOP */;
|
|
389
|
+
}
|
|
390
|
+
this._stopScrollY();
|
|
391
|
+
const mouseToRight = playgroundConfig.width + clientRect.x - e.clientX;
|
|
392
|
+
if (mouseToRight < SCROLL_BOUNDING) {
|
|
393
|
+
this._startScrollX(currentScrollX, true);
|
|
394
|
+
return 3 /* RIGHT */;
|
|
395
|
+
}
|
|
396
|
+
const mouseToLeft = e.clientX - clientRect.x;
|
|
397
|
+
if (mouseToLeft < SCROLL_BOUNDING + EDITOR_LEFT_BAR_WIDTH) {
|
|
398
|
+
this._startScrollX(currentScrollX, false);
|
|
399
|
+
return 2 /* LEFT */;
|
|
400
|
+
}
|
|
401
|
+
this._stopScrollX();
|
|
402
|
+
return void 0;
|
|
403
|
+
}
|
|
404
|
+
dispose() {
|
|
405
|
+
this.toDispose.dispose();
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
FlowDragEntity.type = "FlowDragEntity";
|
|
409
|
+
function getNodePath(node) {
|
|
410
|
+
const path = [node];
|
|
411
|
+
node = node.parent;
|
|
412
|
+
while (node) {
|
|
413
|
+
path.push(node);
|
|
414
|
+
node = node.parent;
|
|
415
|
+
}
|
|
416
|
+
return path.reverse();
|
|
417
|
+
}
|
|
418
|
+
function findRealEntity(entity) {
|
|
419
|
+
while (entity.originParent) {
|
|
420
|
+
entity = entity.originParent;
|
|
421
|
+
}
|
|
422
|
+
return entity;
|
|
423
|
+
}
|
|
424
|
+
function findSelectedNodes(nodes) {
|
|
425
|
+
if (nodes.length === 0) return [];
|
|
426
|
+
const nodePathList = nodes.map((n) => getNodePath(n));
|
|
427
|
+
const minLength = Math.min(...nodePathList.map((n) => n.length));
|
|
428
|
+
let index = 0;
|
|
429
|
+
let selectedItems = [];
|
|
430
|
+
while (index < minLength) {
|
|
431
|
+
selectedItems = lodashEs.uniq(nodePathList.map((p) => p[index]));
|
|
432
|
+
if (selectedItems.length > 1) {
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
index += 1;
|
|
436
|
+
}
|
|
437
|
+
return lodashEs.uniq(selectedItems.map((item) => findRealEntity(item)));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// src/entities/flow-select-config-entity.ts
|
|
441
|
+
var BOUNDS_PADDING_DEFAULT = 10;
|
|
442
|
+
var FlowSelectConfigEntity = class extends core.ConfigEntity {
|
|
443
|
+
constructor() {
|
|
444
|
+
super(...arguments);
|
|
445
|
+
this.boundsPadding = BOUNDS_PADDING_DEFAULT;
|
|
446
|
+
}
|
|
447
|
+
getDefaultConfig() {
|
|
448
|
+
return {
|
|
449
|
+
selectedNodes: []
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
get selectedNodes() {
|
|
453
|
+
return this.config.selectedNodes;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* 选中节点
|
|
457
|
+
* @param nodes
|
|
458
|
+
*/
|
|
459
|
+
set selectedNodes(nodes) {
|
|
460
|
+
nodes = findSelectedNodes(nodes);
|
|
461
|
+
if (nodes.length !== this.config.selectedNodes.length || nodes.some((n) => !this.config.selectedNodes.includes(n))) {
|
|
462
|
+
this.config.selectedNodes.forEach((oldNode) => {
|
|
463
|
+
if (!nodes.includes(oldNode)) {
|
|
464
|
+
oldNode.getData(document$1.FlowNodeRenderData).activated = false;
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
nodes.forEach((node) => {
|
|
468
|
+
node.getData(document$1.FlowNodeRenderData).activated = true;
|
|
469
|
+
});
|
|
470
|
+
if (utils.Compare.isArrayShallowChanged(this.config.selectedNodes, nodes)) {
|
|
471
|
+
this.updateConfig({
|
|
472
|
+
selectedNodes: nodes
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* 清除选中节点
|
|
479
|
+
*/
|
|
480
|
+
clearSelectedNodes() {
|
|
481
|
+
if (this.config.selectedNodes.length === 0) return;
|
|
482
|
+
this.config.selectedNodes.forEach((node) => {
|
|
483
|
+
node.getData(document$1.FlowNodeRenderData).activated = false;
|
|
484
|
+
});
|
|
485
|
+
this.updateConfig({
|
|
486
|
+
selectedNodes: []
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* 通过选择框选中节点
|
|
491
|
+
* @param rect
|
|
492
|
+
* @param transforms
|
|
493
|
+
*/
|
|
494
|
+
selectFromBounds(rect, transforms) {
|
|
495
|
+
const selectedNodes = [];
|
|
496
|
+
transforms.forEach((transform) => {
|
|
497
|
+
if (utils.Rectangle.intersects(rect, transform.bounds)) {
|
|
498
|
+
if (transform.entity.originParent) {
|
|
499
|
+
selectedNodes.push(transform.entity.originParent);
|
|
500
|
+
} else {
|
|
501
|
+
selectedNodes.push(transform.entity);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
this.selectedNodes = selectedNodes;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* 获取选中节点外围的最大边框
|
|
509
|
+
*/
|
|
510
|
+
getSelectedBounds() {
|
|
511
|
+
const nodes = this.selectedNodes;
|
|
512
|
+
if (nodes.length === 0) {
|
|
513
|
+
return utils.Rectangle.EMPTY;
|
|
514
|
+
}
|
|
515
|
+
return utils.Rectangle.enlarge(nodes.map((n) => n.getData(document$1.FlowNodeTransformData).bounds)).pad(
|
|
516
|
+
this.boundsPadding
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
FlowSelectConfigEntity.type = "FlowSelectConfigEntity";
|
|
521
|
+
var SelectorBoxConfigEntity = class extends core.ConfigEntity {
|
|
522
|
+
get dragInfo() {
|
|
523
|
+
return this.config;
|
|
524
|
+
}
|
|
525
|
+
setDragInfo(info) {
|
|
526
|
+
this.updateConfig(info);
|
|
527
|
+
}
|
|
528
|
+
get disabled() {
|
|
529
|
+
return this.config && !!this.config.disabled;
|
|
530
|
+
}
|
|
531
|
+
set disabled(disabled) {
|
|
532
|
+
this.updateConfig({
|
|
533
|
+
disabled
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
get isStart() {
|
|
537
|
+
return this.dragInfo.isStart;
|
|
538
|
+
}
|
|
539
|
+
get isMoving() {
|
|
540
|
+
return this.dragInfo.isMoving;
|
|
541
|
+
}
|
|
542
|
+
get position() {
|
|
543
|
+
const { dragInfo } = this;
|
|
544
|
+
return {
|
|
545
|
+
x: dragInfo.startPos.x < dragInfo.endPos.x ? dragInfo.startPos.x : dragInfo.endPos.x,
|
|
546
|
+
y: dragInfo.startPos.y < dragInfo.endPos.y ? dragInfo.startPos.y : dragInfo.endPos.y
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
get size() {
|
|
550
|
+
const { dragInfo } = this;
|
|
551
|
+
return {
|
|
552
|
+
width: Math.abs(dragInfo.startPos.x - dragInfo.endPos.x),
|
|
553
|
+
height: Math.abs(dragInfo.startPos.y - dragInfo.endPos.y)
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
get collapsed() {
|
|
557
|
+
const { size } = this;
|
|
558
|
+
return size.width === 0 && size.height === 0;
|
|
559
|
+
}
|
|
560
|
+
collapse() {
|
|
561
|
+
this.setDragInfo({
|
|
562
|
+
...this.dragInfo,
|
|
563
|
+
isMoving: false,
|
|
564
|
+
isStart: false
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
toRectangle(scale) {
|
|
568
|
+
const { position, size } = this;
|
|
569
|
+
return new utils.Rectangle(
|
|
570
|
+
position.x / scale,
|
|
571
|
+
position.y / scale,
|
|
572
|
+
size.width / scale,
|
|
573
|
+
size.height / scale
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
SelectorBoxConfigEntity.type = "SelectorBoxConfigEntity";
|
|
578
|
+
var isHidden = (dom) => {
|
|
579
|
+
if (!dom || lodashEs.isNil(dom?.offsetParent)) {
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
const style = window.getComputedStyle(dom);
|
|
583
|
+
if (style?.display === "none") {
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
return false;
|
|
587
|
+
};
|
|
588
|
+
var isRectInit = (rect) => {
|
|
589
|
+
if (!rect) {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
if (rect.bottom === 0 && rect.height === 0 && rect.left === 0 && rect.right === 0 && rect.top === 0 && rect.width === 0 && rect.x === 0 && rect.y === 0) {
|
|
593
|
+
return false;
|
|
594
|
+
}
|
|
595
|
+
return true;
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
// src/flow-renderer-resize-observer.ts
|
|
599
|
+
var FlowRendererResizeObserver = class {
|
|
600
|
+
/**
|
|
601
|
+
* 监听元素 size,并同步到 transform
|
|
602
|
+
* @param el
|
|
603
|
+
* @param transform
|
|
604
|
+
*/
|
|
605
|
+
observe(el, transform) {
|
|
606
|
+
const observer = new ResizeObserver((entries) => {
|
|
607
|
+
window.requestAnimationFrame(() => {
|
|
608
|
+
if (!Array.isArray(entries) || !entries.length) {
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const entry = entries[0];
|
|
612
|
+
const { contentRect, target } = entry;
|
|
613
|
+
const isContentRectInit = isRectInit(contentRect);
|
|
614
|
+
const isLeaveDOMTree = !target.parentNode;
|
|
615
|
+
const isHiddenElement = isHidden(target.parentNode);
|
|
616
|
+
if (isContentRectInit && !isLeaveDOMTree && !isHiddenElement) {
|
|
617
|
+
transform.size = {
|
|
618
|
+
width: Math.round(contentRect.width * 10) / 10,
|
|
619
|
+
height: Math.round(contentRect.height * 10) / 10
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
observer.observe(el);
|
|
625
|
+
return utils.Disposable.create(() => {
|
|
626
|
+
observer.unobserve(el);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
FlowRendererResizeObserver = __decorateClass([
|
|
631
|
+
inversify.injectable()
|
|
632
|
+
], FlowRendererResizeObserver);
|
|
633
|
+
|
|
634
|
+
// src/layers/flow-nodes-transform-layer.ts
|
|
635
|
+
exports.FlowNodesTransformLayer = class FlowNodesTransformLayer extends core.Layer {
|
|
636
|
+
constructor() {
|
|
637
|
+
super(...arguments);
|
|
638
|
+
this.node = utils.domUtils.createDivWithClass("gedit-flow-nodes-layer");
|
|
639
|
+
// onViewportChange() {
|
|
640
|
+
// this.throttleUpdate()
|
|
641
|
+
// }
|
|
642
|
+
// throttleUpdate = throttle(() => {
|
|
643
|
+
// this.renderCache.getFromCache().forEach((cache) => cache.updateBounds())
|
|
644
|
+
// }, 100)
|
|
645
|
+
this.renderCache = utils.Cache.create(
|
|
646
|
+
(transform) => {
|
|
647
|
+
const { renderState } = transform;
|
|
648
|
+
const { node } = renderState;
|
|
649
|
+
const { entity } = transform;
|
|
650
|
+
node.id = entity.id;
|
|
651
|
+
let resizeDispose;
|
|
652
|
+
const append = () => {
|
|
653
|
+
if (resizeDispose) return;
|
|
654
|
+
this.renderElement.appendChild(node);
|
|
655
|
+
if (!entity.getNodeMeta().autoResizeDisable) {
|
|
656
|
+
resizeDispose = this.resizeObserver.observe(node, transform);
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
const dispose = () => {
|
|
660
|
+
if (!resizeDispose) return;
|
|
661
|
+
if (node.parentElement) {
|
|
662
|
+
this.renderElement.removeChild(node);
|
|
663
|
+
}
|
|
664
|
+
resizeDispose.dispose();
|
|
665
|
+
resizeDispose = void 0;
|
|
666
|
+
};
|
|
667
|
+
append();
|
|
668
|
+
return {
|
|
669
|
+
dispose,
|
|
670
|
+
updateBounds: () => {
|
|
671
|
+
const { bounds } = transform;
|
|
672
|
+
const rawX = parseFloat(node.style.left);
|
|
673
|
+
const rawY = parseFloat(node.style.top);
|
|
674
|
+
if (!this.isCoordEqual(rawX, bounds.x) || !this.isCoordEqual(rawY, bounds.y)) {
|
|
675
|
+
node.style.left = `${bounds.x}px`;
|
|
676
|
+
node.style.top = `${bounds.y}px`;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
get transformVisibles() {
|
|
684
|
+
return this.document.getRenderDatas(document$1.FlowNodeTransformData, false);
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* 监听缩放,目前采用整体缩放
|
|
688
|
+
* @param scale
|
|
689
|
+
*/
|
|
690
|
+
onZoom(scale) {
|
|
691
|
+
this.node.style.transform = `scale(${scale})`;
|
|
692
|
+
}
|
|
693
|
+
dispose() {
|
|
694
|
+
this.renderCache.dispose();
|
|
695
|
+
super.dispose();
|
|
696
|
+
}
|
|
697
|
+
isCoordEqual(a, b) {
|
|
698
|
+
const browserCoordEpsilon = 0.05;
|
|
699
|
+
return Math.abs(a - b) < browserCoordEpsilon;
|
|
700
|
+
}
|
|
701
|
+
onReady() {
|
|
702
|
+
this.node.style.zIndex = "10";
|
|
703
|
+
}
|
|
704
|
+
get visibeBounds() {
|
|
705
|
+
return this.transformVisibles.map((transform) => transform.bounds);
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* 更新节点的 bounds 数据
|
|
709
|
+
*/
|
|
710
|
+
updateNodesBounds() {
|
|
711
|
+
this.renderCache.getMoreByItems(this.transformVisibles).forEach((render) => render.updateBounds());
|
|
712
|
+
}
|
|
713
|
+
autorun() {
|
|
714
|
+
if (this.documentTransformer.loading) return;
|
|
715
|
+
this.documentTransformer.refresh();
|
|
716
|
+
this.updateNodesBounds();
|
|
717
|
+
}
|
|
718
|
+
get renderElement() {
|
|
719
|
+
if (typeof this.options.renderElement === "function") {
|
|
720
|
+
const element = this.options.renderElement();
|
|
721
|
+
if (element) {
|
|
722
|
+
return element;
|
|
723
|
+
}
|
|
724
|
+
} else if (typeof this.options.renderElement !== "undefined") {
|
|
725
|
+
return this.options.renderElement;
|
|
726
|
+
}
|
|
727
|
+
return this.node;
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
__decorateClass([
|
|
731
|
+
inversify.inject(document$1.FlowDocument)
|
|
732
|
+
], exports.FlowNodesTransformLayer.prototype, "document", 2);
|
|
733
|
+
__decorateClass([
|
|
734
|
+
inversify.inject(FlowRendererResizeObserver)
|
|
735
|
+
], exports.FlowNodesTransformLayer.prototype, "resizeObserver", 2);
|
|
736
|
+
__decorateClass([
|
|
737
|
+
core.observeEntity(document$1.FlowDocumentTransformerEntity)
|
|
738
|
+
], exports.FlowNodesTransformLayer.prototype, "documentTransformer", 2);
|
|
739
|
+
__decorateClass([
|
|
740
|
+
core.observeEntityDatas(document$1.FlowNodeEntity, document$1.FlowNodeTransformData)
|
|
741
|
+
], exports.FlowNodesTransformLayer.prototype, "_transforms", 2);
|
|
742
|
+
exports.FlowNodesTransformLayer = __decorateClass([
|
|
743
|
+
inversify.injectable()
|
|
744
|
+
], exports.FlowNodesTransformLayer);
|
|
745
|
+
var LayerVueProvide = vue.defineComponent({
|
|
746
|
+
name: "LayerVueProvide",
|
|
747
|
+
props: {
|
|
748
|
+
factory: {
|
|
749
|
+
type: Object,
|
|
750
|
+
required: true
|
|
751
|
+
}
|
|
752
|
+
},
|
|
753
|
+
setup(props) {
|
|
754
|
+
const factory = props.factory;
|
|
755
|
+
vue.provide(core.PlaygroundVueContainerKey, factory);
|
|
756
|
+
try {
|
|
757
|
+
vue.provide(core.PlaygroundVueRefKey, factory.get(core.Playground));
|
|
758
|
+
} catch {
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
render() {
|
|
762
|
+
return this.$slots.default?.();
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
function wrapLayerRender(factory, children) {
|
|
766
|
+
return vue.h(LayerVueProvide, { factory }, () => children);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// src/flow-renderer-contribution.ts
|
|
770
|
+
var FlowRendererContribution = /* @__PURE__ */ Symbol("FlowRendererContribution");
|
|
771
|
+
|
|
772
|
+
// src/flow-renderer-registry.ts
|
|
773
|
+
var FlowRendererComponentType = /* @__PURE__ */ ((FlowRendererComponentType2) => {
|
|
774
|
+
FlowRendererComponentType2[FlowRendererComponentType2["VUE"] = 0] = "VUE";
|
|
775
|
+
FlowRendererComponentType2[FlowRendererComponentType2["DOM"] = 1] = "DOM";
|
|
776
|
+
FlowRendererComponentType2[FlowRendererComponentType2["TEXT"] = 2] = "TEXT";
|
|
777
|
+
return FlowRendererComponentType2;
|
|
778
|
+
})(FlowRendererComponentType || {});
|
|
779
|
+
var FlowRendererKey = /* @__PURE__ */ ((FlowRendererKey2) => {
|
|
780
|
+
FlowRendererKey2["NODE_RENDER"] = "node-render";
|
|
781
|
+
FlowRendererKey2["ADDER"] = "adder";
|
|
782
|
+
FlowRendererKey2["COLLAPSE"] = "collapse";
|
|
783
|
+
FlowRendererKey2["BRANCH_ADDER"] = "branch-adder";
|
|
784
|
+
FlowRendererKey2["TRY_CATCH_COLLAPSE"] = "try-catch-collapse";
|
|
785
|
+
FlowRendererKey2["DRAG_NODE"] = "drag-node";
|
|
786
|
+
FlowRendererKey2["DRAGGABLE_ADDER"] = "draggable-adder";
|
|
787
|
+
FlowRendererKey2["DRAG_HIGHLIGHT_ADDER"] = "drag-highlight-adder";
|
|
788
|
+
FlowRendererKey2["DRAG_BRANCH_HIGHLIGHT_ADDER"] = "drag-branch-highlight-adder";
|
|
789
|
+
FlowRendererKey2["SELECTOR_BOX_POPOVER"] = "selector-box-popover";
|
|
790
|
+
FlowRendererKey2["CONTEXT_MENU_POPOVER"] = "context-menu-popover";
|
|
791
|
+
FlowRendererKey2["SUB_CANVAS"] = "sub-canvas";
|
|
792
|
+
FlowRendererKey2["SLOT_ADDER"] = "slot-adder";
|
|
793
|
+
FlowRendererKey2["SLOT_LABEL"] = "slot-label";
|
|
794
|
+
FlowRendererKey2["SLOT_COLLAPSE"] = "slot-collapse";
|
|
795
|
+
FlowRendererKey2["ARROW_RENDERER"] = "arrow-renderer";
|
|
796
|
+
FlowRendererKey2["MARKER_ARROW"] = "marker-arrow";
|
|
797
|
+
FlowRendererKey2["MARKER_ACTIVATE_ARROW"] = "marker-active-arrow";
|
|
798
|
+
return FlowRendererKey2;
|
|
799
|
+
})(FlowRendererKey || {});
|
|
800
|
+
var FlowTextKey = /* @__PURE__ */ ((FlowTextKey2) => {
|
|
801
|
+
FlowTextKey2["LOOP_END_TEXT"] = "loop-end-text";
|
|
802
|
+
FlowTextKey2["LOOP_TRAVERSE_TEXT"] = "loop-traverse-text";
|
|
803
|
+
FlowTextKey2["LOOP_WHILE_TEXT"] = "loop-while-text";
|
|
804
|
+
FlowTextKey2["TRY_START_TEXT"] = "try-start-text";
|
|
805
|
+
FlowTextKey2["TRY_END_TEXT"] = "try-end-text";
|
|
806
|
+
FlowTextKey2["CATCH_TEXT"] = "catch-text";
|
|
807
|
+
return FlowTextKey2;
|
|
808
|
+
})(FlowTextKey || {});
|
|
809
|
+
var FlowRendererCommandCategory = /* @__PURE__ */ ((FlowRendererCommandCategory2) => {
|
|
810
|
+
FlowRendererCommandCategory2["SELECTOR_BOX"] = "SELECTOR_BOX";
|
|
811
|
+
return FlowRendererCommandCategory2;
|
|
812
|
+
})(FlowRendererCommandCategory || {});
|
|
813
|
+
exports.FlowRendererRegistry = class FlowRendererRegistry {
|
|
814
|
+
constructor() {
|
|
815
|
+
this.componentsMap = /* @__PURE__ */ new Map();
|
|
816
|
+
this.textMap = /* @__PURE__ */ new Map();
|
|
817
|
+
this.contribs = [];
|
|
818
|
+
}
|
|
819
|
+
init() {
|
|
820
|
+
this.contribs.forEach((contrib) => contrib.registerRenderer?.(this));
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* 注册 组件数据
|
|
824
|
+
*/
|
|
825
|
+
registerRendererComponents(renderKey, comp) {
|
|
826
|
+
this.componentsMap.set(renderKey, comp);
|
|
827
|
+
}
|
|
828
|
+
registerVueComponent(renderKey, renderer) {
|
|
829
|
+
this.componentsMap.set(renderKey, {
|
|
830
|
+
type: 0 /* VUE */,
|
|
831
|
+
renderer
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* 注册文案
|
|
836
|
+
*/
|
|
837
|
+
registerText(configs) {
|
|
838
|
+
Object.entries(configs).forEach(([key, value]) => {
|
|
839
|
+
this.textMap.set(key, value);
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
getText(textKey) {
|
|
843
|
+
return i18n.I18n.t(textKey, { defaultValue: "" }) || this.textMap.get(textKey);
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* TODO: support memo
|
|
847
|
+
*/
|
|
848
|
+
getRendererComponent(renderKey) {
|
|
849
|
+
const comp = this.componentsMap.get(renderKey);
|
|
850
|
+
if (!comp) {
|
|
851
|
+
throw new Error(`Unknown render key ${renderKey}`);
|
|
852
|
+
}
|
|
853
|
+
return comp;
|
|
854
|
+
}
|
|
855
|
+
tryToGetRendererComponent(renderKey) {
|
|
856
|
+
return this.componentsMap.get(renderKey);
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* 注册画布层
|
|
860
|
+
*/
|
|
861
|
+
registerLayers(...layerRegistries) {
|
|
862
|
+
layerRegistries.forEach((layer) => this.pipeline.registerLayer(layer));
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* 根据配置注册画布
|
|
866
|
+
* @param layerRegistry
|
|
867
|
+
* @param options
|
|
868
|
+
*/
|
|
869
|
+
registerLayer(layerRegistry, options) {
|
|
870
|
+
this.pipeline.registerLayer(layerRegistry, options);
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
__decorateClass([
|
|
874
|
+
inversify.multiInject(FlowRendererContribution),
|
|
875
|
+
inversify.optional()
|
|
876
|
+
], exports.FlowRendererRegistry.prototype, "contribs", 2);
|
|
877
|
+
__decorateClass([
|
|
878
|
+
inversify.inject(core.PipelineRegistry)
|
|
879
|
+
], exports.FlowRendererRegistry.prototype, "pipeline", 2);
|
|
880
|
+
exports.FlowRendererRegistry = __decorateClass([
|
|
881
|
+
inversify.injectable()
|
|
882
|
+
], exports.FlowRendererRegistry);
|
|
883
|
+
|
|
884
|
+
// src/layers/flow-nodes-content-layer.ts
|
|
885
|
+
exports.FlowNodesContentLayer = class FlowNodesContentLayer extends core.Layer {
|
|
886
|
+
constructor() {
|
|
887
|
+
super(...arguments);
|
|
888
|
+
this.renderMemoCache = /* @__PURE__ */ new WeakMap();
|
|
889
|
+
this.node = utils.domUtils.createDivWithClass("gedit-flow-nodes-layer");
|
|
890
|
+
this.vuePortals = utils.Cache.create(
|
|
891
|
+
(data) => {
|
|
892
|
+
const { node, entity } = data;
|
|
893
|
+
const { config } = this;
|
|
894
|
+
const PortalRenderer = this.getPortalRenderer(data);
|
|
895
|
+
const Portal = vue.defineComponent({
|
|
896
|
+
name: "FlowNodePortal",
|
|
897
|
+
setup() {
|
|
898
|
+
vue.provide(core.PlaygroundEntityContextKey, entity);
|
|
899
|
+
vue.onMounted(() => {
|
|
900
|
+
if (!entity.getNodeMeta().autoResizeDisable && node.clientWidth && node.clientHeight) {
|
|
901
|
+
const transform = entity.getData(document$1.FlowNodeTransformData);
|
|
902
|
+
if (transform)
|
|
903
|
+
transform.size = {
|
|
904
|
+
width: node.clientWidth,
|
|
905
|
+
height: node.clientHeight
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
});
|
|
909
|
+
return () => vue.h(vue.Teleport, { to: node }, [
|
|
910
|
+
vue.h(PortalRenderer, {
|
|
911
|
+
node: entity,
|
|
912
|
+
version: data?.version,
|
|
913
|
+
activated: data?.activated,
|
|
914
|
+
readonly: config.readonly,
|
|
915
|
+
disabled: config.disabled
|
|
916
|
+
})
|
|
917
|
+
]);
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
return {
|
|
921
|
+
id: node.id || entity.id,
|
|
922
|
+
dispose: () => {
|
|
923
|
+
},
|
|
924
|
+
Portal
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
);
|
|
928
|
+
}
|
|
929
|
+
get renderStatesVisible() {
|
|
930
|
+
return this.document.getRenderDatas(document$1.FlowNodeRenderData, false);
|
|
931
|
+
}
|
|
932
|
+
getPortalRenderer(data) {
|
|
933
|
+
const meta = data.entity.getNodeMeta();
|
|
934
|
+
const renderer = this.rendererRegistry.getRendererComponent(
|
|
935
|
+
meta.renderKey || "node-render" /* NODE_RENDER */
|
|
936
|
+
);
|
|
937
|
+
const vueRenderer = renderer.renderer;
|
|
938
|
+
let memoCache = this.renderMemoCache.get(vueRenderer);
|
|
939
|
+
if (!memoCache) {
|
|
940
|
+
memoCache = vueRenderer;
|
|
941
|
+
this.renderMemoCache.set(vueRenderer, memoCache);
|
|
942
|
+
}
|
|
943
|
+
return memoCache;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* 监听缩放,目前采用整体缩放
|
|
947
|
+
* @param scale
|
|
948
|
+
*/
|
|
949
|
+
onZoom(scale) {
|
|
950
|
+
this.node.style.transform = `scale(${scale})`;
|
|
951
|
+
}
|
|
952
|
+
dispose() {
|
|
953
|
+
this.vuePortals.dispose();
|
|
954
|
+
super.dispose();
|
|
955
|
+
}
|
|
956
|
+
onReady() {
|
|
957
|
+
this.node.style.zIndex = "10";
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* 监听readonly和 disabled 状态 并刷新layer, 并刷新节点
|
|
961
|
+
*/
|
|
962
|
+
onReadonlyOrDisabledChange() {
|
|
963
|
+
this.render();
|
|
964
|
+
}
|
|
965
|
+
getPortals() {
|
|
966
|
+
return this.vuePortals.getMoreByItems(this.renderStatesVisible);
|
|
967
|
+
}
|
|
968
|
+
render() {
|
|
969
|
+
if (this.documentTransformer.loading) return null;
|
|
970
|
+
this.documentTransformer.refresh();
|
|
971
|
+
return wrapLayerRender(
|
|
972
|
+
this.playgroundContainer,
|
|
973
|
+
vue.h(
|
|
974
|
+
vue.Fragment,
|
|
975
|
+
null,
|
|
976
|
+
this.getPortals().map((portal) => vue.h(portal.Portal, { key: portal.id }))
|
|
977
|
+
)
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
__decorateClass([
|
|
982
|
+
inversify.inject(document$1.FlowDocument)
|
|
983
|
+
], exports.FlowNodesContentLayer.prototype, "document", 2);
|
|
984
|
+
__decorateClass([
|
|
985
|
+
inversify.inject(exports.FlowRendererRegistry)
|
|
986
|
+
], exports.FlowNodesContentLayer.prototype, "rendererRegistry", 2);
|
|
987
|
+
__decorateClass([
|
|
988
|
+
inversify.inject(core.PlaygroundContainerFactory)
|
|
989
|
+
], exports.FlowNodesContentLayer.prototype, "playgroundContainer", 2);
|
|
990
|
+
__decorateClass([
|
|
991
|
+
core.observeEntity(document$1.FlowDocumentTransformerEntity)
|
|
992
|
+
], exports.FlowNodesContentLayer.prototype, "documentTransformer", 2);
|
|
993
|
+
__decorateClass([
|
|
994
|
+
core.observeEntityDatas(document$1.FlowNodeEntity, document$1.FlowNodeRenderData)
|
|
995
|
+
], exports.FlowNodesContentLayer.prototype, "_renderStates", 2);
|
|
996
|
+
exports.FlowNodesContentLayer = __decorateClass([
|
|
997
|
+
inversify.injectable()
|
|
998
|
+
], exports.FlowNodesContentLayer);
|
|
999
|
+
var StraightLine = vue.defineComponent({
|
|
1000
|
+
name: "StraightLine",
|
|
1001
|
+
inheritAttrs: false,
|
|
1002
|
+
setup(_, { attrs }) {
|
|
1003
|
+
const line = attrs;
|
|
1004
|
+
const { baseColor, baseActivatedColor } = useBaseColor();
|
|
1005
|
+
return () => {
|
|
1006
|
+
const { from, to, activated, style } = line;
|
|
1007
|
+
return vue.h("path", {
|
|
1008
|
+
"data-line-id": line.lineId,
|
|
1009
|
+
d: `M ${from.x} ${from.y} L ${to.x} ${to.y}`,
|
|
1010
|
+
...DEFAULT_LINE_ATTRS,
|
|
1011
|
+
stroke: activated ? baseActivatedColor : baseColor,
|
|
1012
|
+
style
|
|
1013
|
+
});
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
var StraightLine_default = StraightLine;
|
|
1018
|
+
var MARK_ARROW_ID = "$marker_arrow$";
|
|
1019
|
+
var MarkerArrow = vue.defineComponent({
|
|
1020
|
+
name: "MarkerArrow",
|
|
1021
|
+
props: {
|
|
1022
|
+
id: {
|
|
1023
|
+
type: String,
|
|
1024
|
+
required: true
|
|
1025
|
+
}
|
|
1026
|
+
},
|
|
1027
|
+
setup(props) {
|
|
1028
|
+
const { baseColor } = useBaseColor();
|
|
1029
|
+
return () => vue.h(
|
|
1030
|
+
"marker",
|
|
1031
|
+
{
|
|
1032
|
+
"data-line-id": props.id,
|
|
1033
|
+
id: props.id || MARK_ARROW_ID,
|
|
1034
|
+
markerWidth: "11",
|
|
1035
|
+
markerHeight: "14",
|
|
1036
|
+
refX: "10",
|
|
1037
|
+
refY: "7",
|
|
1038
|
+
orient: "auto"
|
|
1039
|
+
},
|
|
1040
|
+
[
|
|
1041
|
+
vue.h("path", {
|
|
1042
|
+
d: "M9.6 5.2C10.8 6.1 10.8 7.9 9.6 8.8L3.6 13.3C2.11672 14.4125 0 13.3541 0 11.5L0 2.5C0 0.645898 2.11672 -0.412461 3.6 0.7L9.6 5.2Z",
|
|
1043
|
+
fill: baseColor
|
|
1044
|
+
})
|
|
1045
|
+
]
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
var MarkerArrow_default = MarkerArrow;
|
|
1050
|
+
var MARK_ACTIVATED_ARROW_ID = "$marker_arrow_activated$";
|
|
1051
|
+
var MarkerActivatedArrow = vue.defineComponent({
|
|
1052
|
+
name: "MarkerActivatedArrow",
|
|
1053
|
+
props: {
|
|
1054
|
+
id: {
|
|
1055
|
+
type: String,
|
|
1056
|
+
default: void 0
|
|
1057
|
+
}
|
|
1058
|
+
},
|
|
1059
|
+
setup(props) {
|
|
1060
|
+
const { baseActivatedColor } = useBaseColor();
|
|
1061
|
+
return () => vue.h(
|
|
1062
|
+
"marker",
|
|
1063
|
+
{
|
|
1064
|
+
"data-line-id": props.id,
|
|
1065
|
+
id: props.id || MARK_ACTIVATED_ARROW_ID,
|
|
1066
|
+
markerWidth: "11",
|
|
1067
|
+
markerHeight: "14",
|
|
1068
|
+
refX: "10",
|
|
1069
|
+
refY: "7",
|
|
1070
|
+
orient: "auto"
|
|
1071
|
+
},
|
|
1072
|
+
[
|
|
1073
|
+
vue.h("path", {
|
|
1074
|
+
d: "M9.6 5.2C10.8 6.1 10.8 7.9 9.6 8.8L3.6 13.3C2.11672 14.4125 0 13.3541 0 11.5L0 2.5C0 0.645898 2.11672 -0.412461 3.6 0.7L9.6 5.2Z",
|
|
1075
|
+
fill: baseActivatedColor
|
|
1076
|
+
})
|
|
1077
|
+
]
|
|
1078
|
+
);
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
1081
|
+
var MarkerActivatedArrow_default = MarkerActivatedArrow;
|
|
1082
|
+
|
|
1083
|
+
// src/components/RoundedTurningLine.ts
|
|
1084
|
+
var MarkerDefs = vue.defineComponent({
|
|
1085
|
+
name: "MarkerDefs",
|
|
1086
|
+
props: {
|
|
1087
|
+
id: { type: String, required: true },
|
|
1088
|
+
activated: { type: Boolean, default: false }
|
|
1089
|
+
},
|
|
1090
|
+
setup(props) {
|
|
1091
|
+
const container = vue.inject(core.PlaygroundVueContainerKey, null);
|
|
1092
|
+
return () => {
|
|
1093
|
+
const renderRegistry = container?.get?.(exports.FlowRendererRegistry);
|
|
1094
|
+
const ArrowRenderer = renderRegistry?.tryToGetRendererComponent(
|
|
1095
|
+
props.activated ? "marker-active-arrow" /* MARKER_ACTIVATE_ARROW */ : "marker-arrow" /* MARKER_ARROW */
|
|
1096
|
+
);
|
|
1097
|
+
if (ArrowRenderer) {
|
|
1098
|
+
return vue.h(ArrowRenderer.renderer, { id: props.id, activated: props.activated });
|
|
1099
|
+
}
|
|
1100
|
+
if (props.activated) {
|
|
1101
|
+
return vue.h("defs", null, [vue.h(MarkerActivatedArrow_default, { id: props.id })]);
|
|
1102
|
+
}
|
|
1103
|
+
return vue.h("defs", null, [vue.h(MarkerArrow_default, { id: props.id })]);
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
var RoundedTurningLine = vue.defineComponent({
|
|
1108
|
+
name: "RoundedTurningLine",
|
|
1109
|
+
inheritAttrs: false,
|
|
1110
|
+
setup(_, { attrs }) {
|
|
1111
|
+
const props = attrs;
|
|
1112
|
+
const { baseActivatedColor, baseColor } = useBaseColor();
|
|
1113
|
+
const realVertices = vue.computed(() => {
|
|
1114
|
+
const { vertices, xRadius, yRadius } = props;
|
|
1115
|
+
return vertices || (props.isHorizontal ? getHorizontalVertices(props, xRadius, yRadius) : getVertices(props, xRadius, yRadius));
|
|
1116
|
+
});
|
|
1117
|
+
const middleStr = vue.computed(() => {
|
|
1118
|
+
const { radius = DEFAULT_RADIUS, from, to } = props;
|
|
1119
|
+
const vertices = realVertices.value;
|
|
1120
|
+
return vertices.map((point, idx) => {
|
|
1121
|
+
const prev = vertices[idx - 1] || from;
|
|
1122
|
+
const next = vertices[idx + 1] || to;
|
|
1123
|
+
const prevDelta = { x: Math.abs(prev.x - point.x), y: Math.abs(prev.y - point.y) };
|
|
1124
|
+
const nextDelta = { x: Math.abs(next.x - point.x), y: Math.abs(next.y - point.y) };
|
|
1125
|
+
const isRightAngleX = prevDelta.x === 0 && nextDelta.y === 0;
|
|
1126
|
+
const isRightAngleY = prevDelta.y === 0 && nextDelta.x === 0;
|
|
1127
|
+
const isRightAngle = isRightAngleX || isRightAngleY;
|
|
1128
|
+
if (!isRightAngle) {
|
|
1129
|
+
console.error(`vertex ${point.x},${point.y} is not right angle`);
|
|
1130
|
+
}
|
|
1131
|
+
const inPoint = new utils.Point().copyFrom(point);
|
|
1132
|
+
const outPoint = new utils.Point().copyFrom(point);
|
|
1133
|
+
const radiusX = lodashEs.isNil(point.radiusX) ? radius : point.radiusX;
|
|
1134
|
+
const radiusY = lodashEs.isNil(point.radiusY) ? radius : point.radiusY;
|
|
1135
|
+
let rx = radiusX;
|
|
1136
|
+
let ry = radiusY;
|
|
1137
|
+
if (isRightAngleX) {
|
|
1138
|
+
ry = Math.min(prevDelta.y, radiusY);
|
|
1139
|
+
const moveY = lodashEs.isNil(point.moveY) ? ry : point.moveY;
|
|
1140
|
+
inPoint.y += from.y < point.y ? -moveY : +moveY;
|
|
1141
|
+
rx = Math.min(nextDelta.x, radiusX);
|
|
1142
|
+
const moveX = lodashEs.isNil(point.moveX) ? rx : point.moveX;
|
|
1143
|
+
outPoint.x += to.x < point.x ? -moveX : +moveX;
|
|
1144
|
+
}
|
|
1145
|
+
if (isRightAngleY) {
|
|
1146
|
+
rx = Math.min(prevDelta.x, radiusX);
|
|
1147
|
+
const moveX = lodashEs.isNil(point.moveX) ? rx : point.moveX;
|
|
1148
|
+
inPoint.x += from.x < point.x ? -moveX : +moveX;
|
|
1149
|
+
ry = Math.min(nextDelta.y, radiusY);
|
|
1150
|
+
const moveY = lodashEs.isNil(point.moveY) ? ry : point.moveY;
|
|
1151
|
+
outPoint.y += to.y < point.y ? -moveY : +moveY;
|
|
1152
|
+
}
|
|
1153
|
+
if (point.radiusOverflow === "truncate") {
|
|
1154
|
+
rx = radiusX;
|
|
1155
|
+
ry = radiusY;
|
|
1156
|
+
}
|
|
1157
|
+
const crossProduct = (point.x - inPoint.x) * (outPoint.y - inPoint.y) - (point.y - inPoint.y) * (outPoint.x - inPoint.x);
|
|
1158
|
+
const isClockWise = crossProduct > 0;
|
|
1159
|
+
return `L ${inPoint.x} ${inPoint.y} A ${rx} ${ry} 0 0 ${isClockWise ? 1 : 0} ${outPoint.x} ${outPoint.y}`;
|
|
1160
|
+
}).join(" ");
|
|
1161
|
+
});
|
|
1162
|
+
return () => {
|
|
1163
|
+
const { hide, from, to, arrow, activated, style } = props;
|
|
1164
|
+
if (hide) {
|
|
1165
|
+
return null;
|
|
1166
|
+
}
|
|
1167
|
+
const pathStr = `M ${from.x} ${from.y} ${middleStr.value} L ${to.x} ${to.y}`;
|
|
1168
|
+
const markerId = activated ? `${MARK_ACTIVATED_ARROW_ID}${props.lineId}` : `${MARK_ARROW_ID}${props.lineId}`;
|
|
1169
|
+
return [
|
|
1170
|
+
arrow ? vue.h(MarkerDefs, { id: markerId, activated }) : null,
|
|
1171
|
+
vue.h("path", {
|
|
1172
|
+
"data-line-id": props.lineId,
|
|
1173
|
+
d: pathStr,
|
|
1174
|
+
...DEFAULT_LINE_ATTRS,
|
|
1175
|
+
stroke: activated ? baseActivatedColor : baseColor,
|
|
1176
|
+
...arrow ? {
|
|
1177
|
+
markerEnd: `url(#${markerId})`
|
|
1178
|
+
} : {},
|
|
1179
|
+
style
|
|
1180
|
+
})
|
|
1181
|
+
];
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
var RoundedTurningLine_default = RoundedTurningLine;
|
|
1186
|
+
var CustomLine = vue.defineComponent({
|
|
1187
|
+
name: "CustomLine",
|
|
1188
|
+
inheritAttrs: false,
|
|
1189
|
+
setup(_, { attrs }) {
|
|
1190
|
+
return () => {
|
|
1191
|
+
const props = attrs;
|
|
1192
|
+
const { renderKey, rendererRegistry, ...line } = props;
|
|
1193
|
+
if (!renderKey) {
|
|
1194
|
+
return null;
|
|
1195
|
+
}
|
|
1196
|
+
const renderer = rendererRegistry.getRendererComponent(renderKey);
|
|
1197
|
+
if (!renderer) {
|
|
1198
|
+
return null;
|
|
1199
|
+
}
|
|
1200
|
+
return vue.h(renderer.renderer, { lineId: props.lineId, ...line });
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1204
|
+
var CustomLine_default = CustomLine;
|
|
1205
|
+
|
|
1206
|
+
// src/components/LinesRenderer.ts
|
|
1207
|
+
function createLines(props) {
|
|
1208
|
+
const { data, rendererRegistry, linesSave, dragService } = props;
|
|
1209
|
+
const { lines, entity } = data || {};
|
|
1210
|
+
const radius = document$1.getDefaultSpacing(entity, document$1.DefaultSpacingKey.ROUNDED_LINE_RADIUS);
|
|
1211
|
+
const xRadius = document$1.getDefaultSpacing(entity, document$1.DefaultSpacingKey.ROUNDED_LINE_X_RADIUS);
|
|
1212
|
+
const yRadius = document$1.getDefaultSpacing(entity, document$1.DefaultSpacingKey.ROUNDED_LINE_Y_RADIUS);
|
|
1213
|
+
const renderLine = (line, index) => {
|
|
1214
|
+
const { renderData } = data;
|
|
1215
|
+
const { isVertical } = data.entity;
|
|
1216
|
+
const { lineActivated } = renderData || {};
|
|
1217
|
+
const draggingLineHide = (line.type === document$1.FlowTransitionLineEnum.DRAGGING_LINE || line.isDraggingLine) && !dragService.isDroppableBranch(data.entity, line.side);
|
|
1218
|
+
const draggingLineActivated = (line.type === document$1.FlowTransitionLineEnum.DRAGGING_LINE || line.isDraggingLine) && data.entity?.id === dragService.dropNodeId && line.side === dragService.labelSide;
|
|
1219
|
+
switch (line.type) {
|
|
1220
|
+
case document$1.FlowTransitionLineEnum.STRAIGHT_LINE:
|
|
1221
|
+
return vue.h(StraightLine_default, {
|
|
1222
|
+
key: `${data.entity.id}_${index}`,
|
|
1223
|
+
lineId: data.entity.id,
|
|
1224
|
+
activated: lineActivated,
|
|
1225
|
+
...line
|
|
1226
|
+
});
|
|
1227
|
+
case document$1.FlowTransitionLineEnum.DIVERGE_LINE:
|
|
1228
|
+
case document$1.FlowTransitionLineEnum.DRAGGING_LINE:
|
|
1229
|
+
case document$1.FlowTransitionLineEnum.MERGE_LINE:
|
|
1230
|
+
case document$1.FlowTransitionLineEnum.ROUNDED_LINE:
|
|
1231
|
+
return vue.h(RoundedTurningLine_default, {
|
|
1232
|
+
key: `${data.entity.id}_${index}`,
|
|
1233
|
+
lineId: data.entity.id,
|
|
1234
|
+
isHorizontal: !isVertical,
|
|
1235
|
+
activated: lineActivated || draggingLineActivated,
|
|
1236
|
+
radius,
|
|
1237
|
+
...line,
|
|
1238
|
+
xRadius,
|
|
1239
|
+
yRadius,
|
|
1240
|
+
hide: draggingLineHide
|
|
1241
|
+
});
|
|
1242
|
+
case document$1.FlowTransitionLineEnum.CUSTOM_LINE:
|
|
1243
|
+
return vue.h(CustomLine_default, {
|
|
1244
|
+
key: `${data.entity.id}_${index}`,
|
|
1245
|
+
lineId: data.entity.id,
|
|
1246
|
+
...line,
|
|
1247
|
+
rendererRegistry
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
return void 0;
|
|
1251
|
+
};
|
|
1252
|
+
lines.forEach((line, index) => {
|
|
1253
|
+
const bounds = utils.Rectangle.createRectangleWithTwoPoints(line.from, line.to).pad(10);
|
|
1254
|
+
if (props.isViewportVisible(bounds)) {
|
|
1255
|
+
const vnode = renderLine(line, index);
|
|
1256
|
+
if (vnode) linesSave.push(vnode);
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
// src/layers/flow-lines-layer.ts
|
|
1262
|
+
exports.FlowLinesLayer = class FlowLinesLayer extends core.Layer {
|
|
1263
|
+
constructor() {
|
|
1264
|
+
super(...arguments);
|
|
1265
|
+
this.node = utils.domUtils.createDivWithClass("gedit-flow-lines-layer");
|
|
1266
|
+
/**
|
|
1267
|
+
* 可视区域变化
|
|
1268
|
+
*/
|
|
1269
|
+
this.onViewportChange = lodashEs.throttle(() => {
|
|
1270
|
+
this.render();
|
|
1271
|
+
}, 100);
|
|
1272
|
+
}
|
|
1273
|
+
get transitions() {
|
|
1274
|
+
return this.document.getRenderDatas(document$1.FlowNodeTransitionData);
|
|
1275
|
+
}
|
|
1276
|
+
onZoom() {
|
|
1277
|
+
const svgContainer = this.node.querySelector("svg.flow-lines-container");
|
|
1278
|
+
svgContainer?.setAttribute?.("viewBox", this.viewBox);
|
|
1279
|
+
}
|
|
1280
|
+
onReady() {
|
|
1281
|
+
this.node.style.zIndex = "1";
|
|
1282
|
+
}
|
|
1283
|
+
get viewBox() {
|
|
1284
|
+
const ratio = 1e3 / this.config.finalScale;
|
|
1285
|
+
return `0 0 ${ratio} ${ratio}`;
|
|
1286
|
+
}
|
|
1287
|
+
render() {
|
|
1288
|
+
const allLines = [];
|
|
1289
|
+
const isViewportVisible = this.config.isViewportVisible.bind(this.config);
|
|
1290
|
+
if (this.documentTransformer.loading) return null;
|
|
1291
|
+
this.documentTransformer.refresh();
|
|
1292
|
+
this.transitions.forEach((transition) => {
|
|
1293
|
+
createLines({
|
|
1294
|
+
data: transition,
|
|
1295
|
+
rendererRegistry: this.rendererRegistry,
|
|
1296
|
+
isViewportVisible,
|
|
1297
|
+
linesSave: allLines,
|
|
1298
|
+
dragService: this.dragService
|
|
1299
|
+
});
|
|
1300
|
+
});
|
|
1301
|
+
const { activateLines = [], normalLines = [] } = lodashEs.groupBy(
|
|
1302
|
+
allLines,
|
|
1303
|
+
(line) => line.props?.activated ? "activateLines" : "normalLines"
|
|
1304
|
+
);
|
|
1305
|
+
const resultLines = [...normalLines, ...activateLines];
|
|
1306
|
+
return wrapLayerRender(
|
|
1307
|
+
this.playgroundContainer,
|
|
1308
|
+
vue.h(
|
|
1309
|
+
"svg",
|
|
1310
|
+
{
|
|
1311
|
+
class: "flow-lines-container",
|
|
1312
|
+
width: "1000",
|
|
1313
|
+
height: "1000",
|
|
1314
|
+
overflow: "visible",
|
|
1315
|
+
viewBox: this.viewBox,
|
|
1316
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1317
|
+
},
|
|
1318
|
+
resultLines
|
|
1319
|
+
)
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
__decorateClass([
|
|
1324
|
+
inversify.inject(document$1.FlowDocument)
|
|
1325
|
+
], exports.FlowLinesLayer.prototype, "document", 2);
|
|
1326
|
+
__decorateClass([
|
|
1327
|
+
inversify.inject(document$1.FlowDragService)
|
|
1328
|
+
], exports.FlowLinesLayer.prototype, "dragService", 2);
|
|
1329
|
+
__decorateClass([
|
|
1330
|
+
inversify.inject(exports.FlowRendererRegistry)
|
|
1331
|
+
], exports.FlowLinesLayer.prototype, "rendererRegistry", 2);
|
|
1332
|
+
__decorateClass([
|
|
1333
|
+
inversify.inject(core.PlaygroundContainerFactory)
|
|
1334
|
+
], exports.FlowLinesLayer.prototype, "playgroundContainer", 2);
|
|
1335
|
+
__decorateClass([
|
|
1336
|
+
core.observeEntity(document$1.FlowDocumentTransformerEntity)
|
|
1337
|
+
], exports.FlowLinesLayer.prototype, "documentTransformer", 2);
|
|
1338
|
+
__decorateClass([
|
|
1339
|
+
core.observeEntity(document$1.FlowRendererStateEntity)
|
|
1340
|
+
], exports.FlowLinesLayer.prototype, "flowRenderState", 2);
|
|
1341
|
+
__decorateClass([
|
|
1342
|
+
core.observeEntityDatas(document$1.FlowNodeEntity, document$1.FlowNodeTransitionData)
|
|
1343
|
+
], exports.FlowLinesLayer.prototype, "_transitions", 2);
|
|
1344
|
+
exports.FlowLinesLayer = __decorateClass([
|
|
1345
|
+
inversify.injectable()
|
|
1346
|
+
], exports.FlowLinesLayer);
|
|
1347
|
+
var Collapse = vue.defineComponent({
|
|
1348
|
+
name: "Collapse",
|
|
1349
|
+
inheritAttrs: false,
|
|
1350
|
+
setup(_, { attrs }) {
|
|
1351
|
+
const hoverActivated = vue.ref(false);
|
|
1352
|
+
return () => {
|
|
1353
|
+
const props = attrs;
|
|
1354
|
+
const {
|
|
1355
|
+
data,
|
|
1356
|
+
rendererRegistry,
|
|
1357
|
+
forceVisible,
|
|
1358
|
+
hoverHeight = getTransitionLabelHoverHeight(data),
|
|
1359
|
+
hoverWidth = getTransitionLabelHoverWidth(data),
|
|
1360
|
+
wrapperStyle,
|
|
1361
|
+
...restProps
|
|
1362
|
+
} = props;
|
|
1363
|
+
const { activateNode } = restProps;
|
|
1364
|
+
const activateData = activateNode?.getData(document$1.FlowNodeRenderData);
|
|
1365
|
+
const handleMouseEnter = () => {
|
|
1366
|
+
hoverActivated.value = true;
|
|
1367
|
+
activateData?.toggleMouseEnter();
|
|
1368
|
+
};
|
|
1369
|
+
const handleMouseLeave = () => {
|
|
1370
|
+
hoverActivated.value = false;
|
|
1371
|
+
activateData?.toggleMouseLeave();
|
|
1372
|
+
};
|
|
1373
|
+
const collapseOpener = rendererRegistry.getRendererComponent("collapse" /* COLLAPSE */);
|
|
1374
|
+
const node = data.entity;
|
|
1375
|
+
const child = vue.h(collapseOpener.renderer, {
|
|
1376
|
+
node,
|
|
1377
|
+
collapseNode: node,
|
|
1378
|
+
...restProps,
|
|
1379
|
+
hoverActivated: hoverActivated.value
|
|
1380
|
+
});
|
|
1381
|
+
const isChildVisible = data.collapsed || activateData?.hovered || hoverActivated.value || forceVisible;
|
|
1382
|
+
return vue.h(
|
|
1383
|
+
"div",
|
|
1384
|
+
{
|
|
1385
|
+
class: "flow-canvas-collapse",
|
|
1386
|
+
onMouseenter: handleMouseEnter,
|
|
1387
|
+
onMouseleave: handleMouseLeave,
|
|
1388
|
+
style: {
|
|
1389
|
+
width: `${hoverWidth}px`,
|
|
1390
|
+
height: `${hoverHeight}px`,
|
|
1391
|
+
display: "flex",
|
|
1392
|
+
justifyContent: "center",
|
|
1393
|
+
alignItems: "center",
|
|
1394
|
+
...wrapperStyle
|
|
1395
|
+
}
|
|
1396
|
+
},
|
|
1397
|
+
[isChildVisible ? child : null]
|
|
1398
|
+
);
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
});
|
|
1402
|
+
var Collapse_default = Collapse;
|
|
1403
|
+
var getFlowRenderKey = (node, { dragService }) => {
|
|
1404
|
+
if (dragService && dragService.dragging && dragService.isDroppableNode(node)) {
|
|
1405
|
+
if (dragService.dropNodeId === node.id) {
|
|
1406
|
+
return "drag-highlight-adder" /* DRAG_HIGHLIGHT_ADDER */;
|
|
1407
|
+
}
|
|
1408
|
+
return "draggable-adder" /* DRAGGABLE_ADDER */;
|
|
1409
|
+
}
|
|
1410
|
+
return "adder" /* ADDER */;
|
|
1411
|
+
};
|
|
1412
|
+
var Adder = vue.defineComponent({
|
|
1413
|
+
name: "Adder",
|
|
1414
|
+
inheritAttrs: false,
|
|
1415
|
+
setup(_, { attrs }) {
|
|
1416
|
+
const props = attrs;
|
|
1417
|
+
const hoverActivated = vue.ref(false);
|
|
1418
|
+
const dragService = core.useService(document$1.FlowDragService);
|
|
1419
|
+
const handleMouseEnter = () => {
|
|
1420
|
+
hoverActivated.value = true;
|
|
1421
|
+
};
|
|
1422
|
+
const handleMouseLeave = () => {
|
|
1423
|
+
hoverActivated.value = false;
|
|
1424
|
+
};
|
|
1425
|
+
return () => {
|
|
1426
|
+
const {
|
|
1427
|
+
data,
|
|
1428
|
+
rendererRegistry,
|
|
1429
|
+
hoverHeight = getTransitionLabelHoverHeight(data),
|
|
1430
|
+
hoverWidth = getTransitionLabelHoverWidth(data),
|
|
1431
|
+
...restProps
|
|
1432
|
+
} = props;
|
|
1433
|
+
const node = data.entity;
|
|
1434
|
+
const flowRenderKey = getFlowRenderKey(node, { dragService });
|
|
1435
|
+
const adder = rendererRegistry.getRendererComponent(flowRenderKey);
|
|
1436
|
+
const from = node;
|
|
1437
|
+
const to = data.entity.document.renderTree.getOriginInfo(node).next;
|
|
1438
|
+
const renderTo = node.next;
|
|
1439
|
+
const child = vue.h(adder.renderer, {
|
|
1440
|
+
node,
|
|
1441
|
+
from,
|
|
1442
|
+
to,
|
|
1443
|
+
renderTo,
|
|
1444
|
+
hoverActivated: hoverActivated.value,
|
|
1445
|
+
setHoverActivated: (v) => {
|
|
1446
|
+
hoverActivated.value = v;
|
|
1447
|
+
},
|
|
1448
|
+
hoverWidth,
|
|
1449
|
+
hoverHeight,
|
|
1450
|
+
...restProps
|
|
1451
|
+
});
|
|
1452
|
+
return vue.h(
|
|
1453
|
+
"div",
|
|
1454
|
+
{
|
|
1455
|
+
class: "flow-canvas-adder",
|
|
1456
|
+
"data-testid": "sdk.flowcanvas.line.adder",
|
|
1457
|
+
"data-from": from.id,
|
|
1458
|
+
"data-to": to?.id ?? "",
|
|
1459
|
+
onMouseenter: handleMouseEnter,
|
|
1460
|
+
onMouseleave: handleMouseLeave,
|
|
1461
|
+
style: {
|
|
1462
|
+
width: `${hoverWidth}px`,
|
|
1463
|
+
height: `${hoverHeight}px`,
|
|
1464
|
+
display: "flex",
|
|
1465
|
+
justifyContent: "center",
|
|
1466
|
+
alignItems: "center"
|
|
1467
|
+
}
|
|
1468
|
+
},
|
|
1469
|
+
[child]
|
|
1470
|
+
);
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
var Adder_default = Adder;
|
|
1475
|
+
|
|
1476
|
+
// src/components/CollapseAdder.ts
|
|
1477
|
+
var CollapseAdder = vue.defineComponent({
|
|
1478
|
+
name: "CollapseAdder",
|
|
1479
|
+
inheritAttrs: false,
|
|
1480
|
+
setup(_, { attrs }) {
|
|
1481
|
+
const hoverActivated = vue.ref(false);
|
|
1482
|
+
const handleMouseEnter = () => {
|
|
1483
|
+
hoverActivated.value = true;
|
|
1484
|
+
};
|
|
1485
|
+
const handleMouseLeave = () => {
|
|
1486
|
+
hoverActivated.value = false;
|
|
1487
|
+
};
|
|
1488
|
+
return () => {
|
|
1489
|
+
const props = attrs;
|
|
1490
|
+
const { data, activateNode } = props;
|
|
1491
|
+
const activateData = activateNode?.getData(document$1.FlowNodeRenderData);
|
|
1492
|
+
const isVertical = activateNode?.isVertical;
|
|
1493
|
+
const activated = activateData?.hovered || hoverActivated.value;
|
|
1494
|
+
if (isVertical) {
|
|
1495
|
+
return vue.h(
|
|
1496
|
+
"div",
|
|
1497
|
+
{
|
|
1498
|
+
class: "flow-canvas-collapse-adder",
|
|
1499
|
+
onMouseenter: handleMouseEnter,
|
|
1500
|
+
onMouseleave: handleMouseLeave
|
|
1501
|
+
},
|
|
1502
|
+
[
|
|
1503
|
+
activated || data.collapsed ? vue.h(Collapse_default, {
|
|
1504
|
+
...props,
|
|
1505
|
+
forceVisible: true,
|
|
1506
|
+
wrapperStyle: { alignItems: "flex-end" },
|
|
1507
|
+
hoverHeight: 20
|
|
1508
|
+
}) : null,
|
|
1509
|
+
!data.collapsed ? vue.h(Adder_default, { ...props, hoverHeight: activated ? 20 : 40, hoverActivated: activated }) : null
|
|
1510
|
+
]
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1513
|
+
return vue.h(
|
|
1514
|
+
"div",
|
|
1515
|
+
{
|
|
1516
|
+
class: "flow-canvas-collapse-adder",
|
|
1517
|
+
onMouseenter: handleMouseEnter,
|
|
1518
|
+
onMouseleave: handleMouseLeave,
|
|
1519
|
+
style: {
|
|
1520
|
+
display: data.collapsed ? "block" : "flex"
|
|
1521
|
+
}
|
|
1522
|
+
},
|
|
1523
|
+
[
|
|
1524
|
+
activated || data.collapsed ? vue.h(Collapse_default, {
|
|
1525
|
+
...props,
|
|
1526
|
+
forceVisible: true,
|
|
1527
|
+
wrapperStyle: { justifyContent: "flex-end" },
|
|
1528
|
+
hoverWidth: 20
|
|
1529
|
+
}) : null,
|
|
1530
|
+
!data.collapsed ? vue.h(Adder_default, { ...props, hoverWidth: activated ? 20 : 40, hoverActivated: activated }) : null
|
|
1531
|
+
]
|
|
1532
|
+
);
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
var CollapseAdder_default = CollapseAdder;
|
|
1537
|
+
var getFlowRenderKey2 = (node, { dragService, side }) => {
|
|
1538
|
+
if (dragService.isDragBranch && side && dragService.labelSide === side && dragService.isDroppableBranch(node, side)) {
|
|
1539
|
+
if (dragService.dropNodeId === node.id) {
|
|
1540
|
+
return "drag-branch-highlight-adder" /* DRAG_BRANCH_HIGHLIGHT_ADDER */;
|
|
1541
|
+
}
|
|
1542
|
+
return "draggable-adder" /* DRAGGABLE_ADDER */;
|
|
1543
|
+
}
|
|
1544
|
+
return "";
|
|
1545
|
+
};
|
|
1546
|
+
var BranchDraggableRenderer = vue.defineComponent({
|
|
1547
|
+
name: "BranchDraggableRenderer",
|
|
1548
|
+
inheritAttrs: false,
|
|
1549
|
+
setup(_, { attrs }) {
|
|
1550
|
+
const dragService = core.useService(document$1.FlowDragService);
|
|
1551
|
+
return () => {
|
|
1552
|
+
const props = attrs;
|
|
1553
|
+
const { data, rendererRegistry, side, ...restProps } = props;
|
|
1554
|
+
const node = data.entity;
|
|
1555
|
+
const flowRenderKey = getFlowRenderKey2(node, { side, dragService });
|
|
1556
|
+
if (!flowRenderKey) {
|
|
1557
|
+
return null;
|
|
1558
|
+
}
|
|
1559
|
+
const adder = rendererRegistry.getRendererComponent(flowRenderKey);
|
|
1560
|
+
const from = node;
|
|
1561
|
+
const to = data.entity.document.renderTree.getOriginInfo(node).next;
|
|
1562
|
+
const renderTo = node.next;
|
|
1563
|
+
const child = vue.h(adder.renderer, {
|
|
1564
|
+
node,
|
|
1565
|
+
from,
|
|
1566
|
+
to,
|
|
1567
|
+
renderTo,
|
|
1568
|
+
...restProps
|
|
1569
|
+
});
|
|
1570
|
+
return vue.h("div", { class: "flow-canvas-branch-draggable-adder" }, [child]);
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
});
|
|
1574
|
+
var BranchDraggableRenderer_default = BranchDraggableRenderer;
|
|
1575
|
+
|
|
1576
|
+
// src/components/LabelsRenderer.ts
|
|
1577
|
+
var TEXT_LABEL_STYLE = {
|
|
1578
|
+
fontSize: "12px",
|
|
1579
|
+
color: "#8F959E",
|
|
1580
|
+
textAlign: "center",
|
|
1581
|
+
whiteSpace: "nowrap",
|
|
1582
|
+
backgroundColor: "var(--g-editor-background)",
|
|
1583
|
+
lineHeight: "20px"
|
|
1584
|
+
};
|
|
1585
|
+
var LABEL_MAX_WIDTH = 150;
|
|
1586
|
+
var LABEL_MAX_HEIGHT = 60;
|
|
1587
|
+
function getLabelBounds(offset) {
|
|
1588
|
+
return new utils.Rectangle(
|
|
1589
|
+
offset.x - LABEL_MAX_WIDTH / 2,
|
|
1590
|
+
offset.y - LABEL_MAX_HEIGHT / 2,
|
|
1591
|
+
LABEL_MAX_WIDTH,
|
|
1592
|
+
LABEL_MAX_HEIGHT
|
|
1593
|
+
);
|
|
1594
|
+
}
|
|
1595
|
+
function createLabels(labelProps) {
|
|
1596
|
+
const { data, rendererRegistry, labelsSave, getLabelColor } = labelProps;
|
|
1597
|
+
const { labels, renderData } = data || {};
|
|
1598
|
+
const { activated } = renderData || {};
|
|
1599
|
+
const renderLabel = (label, index) => {
|
|
1600
|
+
const { offset, renderKey, props, rotate, origin, type } = label || {};
|
|
1601
|
+
const offsetX = offset.x;
|
|
1602
|
+
const offsetY = offset.y;
|
|
1603
|
+
let child = null;
|
|
1604
|
+
switch (type) {
|
|
1605
|
+
case document$1.FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL:
|
|
1606
|
+
child = vue.h(BranchDraggableRenderer_default, {
|
|
1607
|
+
labelId: label.labelId || labelProps.data.entity.id,
|
|
1608
|
+
rendererRegistry,
|
|
1609
|
+
data,
|
|
1610
|
+
...props
|
|
1611
|
+
});
|
|
1612
|
+
break;
|
|
1613
|
+
case document$1.FlowTransitionLabelEnum.ADDER_LABEL:
|
|
1614
|
+
child = vue.h(Adder_default, {
|
|
1615
|
+
labelId: label.labelId || labelProps.data.entity.id,
|
|
1616
|
+
rendererRegistry,
|
|
1617
|
+
data,
|
|
1618
|
+
...props
|
|
1619
|
+
});
|
|
1620
|
+
break;
|
|
1621
|
+
case document$1.FlowTransitionLabelEnum.COLLAPSE_LABEL:
|
|
1622
|
+
child = vue.h(Collapse_default, {
|
|
1623
|
+
labelId: label.labelId || labelProps.data.entity.id,
|
|
1624
|
+
rendererRegistry,
|
|
1625
|
+
data,
|
|
1626
|
+
...props
|
|
1627
|
+
});
|
|
1628
|
+
break;
|
|
1629
|
+
case document$1.FlowTransitionLabelEnum.COLLAPSE_ADDER_LABEL:
|
|
1630
|
+
child = vue.h(CollapseAdder_default, {
|
|
1631
|
+
labelId: label.labelId || labelProps.data.entity.id,
|
|
1632
|
+
rendererRegistry,
|
|
1633
|
+
data,
|
|
1634
|
+
...props
|
|
1635
|
+
});
|
|
1636
|
+
break;
|
|
1637
|
+
case document$1.FlowTransitionLabelEnum.TEXT_LABEL:
|
|
1638
|
+
if (!renderKey) {
|
|
1639
|
+
return null;
|
|
1640
|
+
}
|
|
1641
|
+
const text = rendererRegistry.getText(renderKey) || renderKey;
|
|
1642
|
+
child = vue.h(
|
|
1643
|
+
"div",
|
|
1644
|
+
{
|
|
1645
|
+
"data-label-id": label.labelId || labelProps.data.entity.id,
|
|
1646
|
+
style: {
|
|
1647
|
+
...TEXT_LABEL_STYLE,
|
|
1648
|
+
...props?.style,
|
|
1649
|
+
color: getLabelColor(activated),
|
|
1650
|
+
transform: rotate ? `rotate(${rotate})` : void 0
|
|
1651
|
+
}
|
|
1652
|
+
},
|
|
1653
|
+
text
|
|
1654
|
+
);
|
|
1655
|
+
break;
|
|
1656
|
+
case document$1.FlowTransitionLabelEnum.CUSTOM_LABEL:
|
|
1657
|
+
if (!renderKey) {
|
|
1658
|
+
return null;
|
|
1659
|
+
}
|
|
1660
|
+
try {
|
|
1661
|
+
const renderer = rendererRegistry.getRendererComponent(renderKey);
|
|
1662
|
+
child = vue.h(renderer.renderer, {
|
|
1663
|
+
node: data.entity,
|
|
1664
|
+
labelId: label.labelId || labelProps.data.entity.id,
|
|
1665
|
+
...props
|
|
1666
|
+
});
|
|
1667
|
+
} catch (err) {
|
|
1668
|
+
console.error(err);
|
|
1669
|
+
child = renderKey;
|
|
1670
|
+
}
|
|
1671
|
+
break;
|
|
1672
|
+
}
|
|
1673
|
+
const originX = typeof origin?.[0] === "number" ? origin?.[0] : 0.5;
|
|
1674
|
+
const originY = typeof origin?.[1] === "number" ? origin?.[1] : 0.5;
|
|
1675
|
+
return vue.h(
|
|
1676
|
+
"div",
|
|
1677
|
+
{
|
|
1678
|
+
key: `${data.entity.id}${index}`,
|
|
1679
|
+
"data-label-id": label.labelId || labelProps.data.entity.id,
|
|
1680
|
+
style: {
|
|
1681
|
+
position: "absolute",
|
|
1682
|
+
left: `${offsetX}px`,
|
|
1683
|
+
top: `${offsetY}px`,
|
|
1684
|
+
transform: `translate(-${originX * 100}%, -${originY * 100}%)`
|
|
1685
|
+
}
|
|
1686
|
+
},
|
|
1687
|
+
[child]
|
|
1688
|
+
);
|
|
1689
|
+
};
|
|
1690
|
+
labels.forEach((label, index) => {
|
|
1691
|
+
if (labelProps.isViewportVisible(getLabelBounds(label.offset))) {
|
|
1692
|
+
const vnode = renderLabel(label, index);
|
|
1693
|
+
if (vnode) labelsSave.push(vnode);
|
|
1694
|
+
}
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
// src/layers/flow-labels-layer.ts
|
|
1699
|
+
exports.FlowLabelsLayer = class FlowLabelsLayer extends core.Layer {
|
|
1700
|
+
constructor() {
|
|
1701
|
+
super(...arguments);
|
|
1702
|
+
this.node = utils.domUtils.createDivWithClass("gedit-flow-labels-layer");
|
|
1703
|
+
/**
|
|
1704
|
+
* 可视区域变化
|
|
1705
|
+
*/
|
|
1706
|
+
this.onViewportChange = lodashEs.throttle(() => {
|
|
1707
|
+
this.render();
|
|
1708
|
+
}, 100);
|
|
1709
|
+
}
|
|
1710
|
+
get transitions() {
|
|
1711
|
+
return this.document.getRenderDatas(document$1.FlowNodeTransitionData);
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* 监听缩放,目前采用整体缩放
|
|
1715
|
+
* @param scale
|
|
1716
|
+
*/
|
|
1717
|
+
onZoom(scale) {
|
|
1718
|
+
this.node.style.transform = `scale(${scale})`;
|
|
1719
|
+
}
|
|
1720
|
+
onReady() {
|
|
1721
|
+
this.node.style.zIndex = "9";
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* 监听readonly和 disabled 状态 并刷新layer, 并刷新
|
|
1725
|
+
*/
|
|
1726
|
+
onReadonlyOrDisabledChange() {
|
|
1727
|
+
this.render();
|
|
1728
|
+
}
|
|
1729
|
+
render() {
|
|
1730
|
+
const labels = [];
|
|
1731
|
+
if (this.documentTransformer?.loading) return null;
|
|
1732
|
+
this.documentTransformer?.refresh?.();
|
|
1733
|
+
const { baseActivatedColor, baseColor } = getBaseColor(this.documentOptions);
|
|
1734
|
+
const isViewportVisible = this.config.isViewportVisible.bind(this.config);
|
|
1735
|
+
this.transitions.forEach((transition) => {
|
|
1736
|
+
createLabels({
|
|
1737
|
+
data: transition,
|
|
1738
|
+
rendererRegistry: this.rendererRegistry,
|
|
1739
|
+
isViewportVisible,
|
|
1740
|
+
labelsSave: labels,
|
|
1741
|
+
getLabelColor: (activated) => activated ? baseActivatedColor : baseColor
|
|
1742
|
+
});
|
|
1743
|
+
});
|
|
1744
|
+
return wrapLayerRender(this.playgroundContainer, vue.h(vue.Fragment, null, labels));
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
__decorateClass([
|
|
1748
|
+
inversify.inject(document$1.FlowDocument)
|
|
1749
|
+
], exports.FlowLabelsLayer.prototype, "document", 2);
|
|
1750
|
+
__decorateClass([
|
|
1751
|
+
inversify.inject(exports.FlowRendererRegistry)
|
|
1752
|
+
], exports.FlowLabelsLayer.prototype, "rendererRegistry", 2);
|
|
1753
|
+
__decorateClass([
|
|
1754
|
+
inversify.inject(core.PlaygroundContainerFactory)
|
|
1755
|
+
], exports.FlowLabelsLayer.prototype, "playgroundContainer", 2);
|
|
1756
|
+
__decorateClass([
|
|
1757
|
+
inversify.optional(),
|
|
1758
|
+
inversify.inject(document$1.FlowDocumentOptions)
|
|
1759
|
+
], exports.FlowLabelsLayer.prototype, "documentOptions", 2);
|
|
1760
|
+
__decorateClass([
|
|
1761
|
+
core.observeEntity(document$1.FlowDocumentTransformerEntity)
|
|
1762
|
+
], exports.FlowLabelsLayer.prototype, "documentTransformer", 2);
|
|
1763
|
+
__decorateClass([
|
|
1764
|
+
core.observeEntity(document$1.FlowRendererStateEntity)
|
|
1765
|
+
], exports.FlowLabelsLayer.prototype, "flowRenderState", 2);
|
|
1766
|
+
__decorateClass([
|
|
1767
|
+
core.observeEntityDatas(document$1.FlowNodeEntity, document$1.FlowNodeTransitionData)
|
|
1768
|
+
], exports.FlowLabelsLayer.prototype, "_transitions", 2);
|
|
1769
|
+
exports.FlowLabelsLayer = __decorateClass([
|
|
1770
|
+
inversify.injectable()
|
|
1771
|
+
], exports.FlowLabelsLayer);
|
|
1772
|
+
var SCROLL_LIMIT_PADDING = -120;
|
|
1773
|
+
function getScrollViewport(scrollData, config) {
|
|
1774
|
+
const scale = config.finalScale;
|
|
1775
|
+
return new utils.Rectangle(
|
|
1776
|
+
scrollData.scrollX / scale,
|
|
1777
|
+
scrollData.scrollY / scale,
|
|
1778
|
+
config.config.width / scale,
|
|
1779
|
+
config.config.height / scale
|
|
1780
|
+
).pad(SCROLL_LIMIT_PADDING / scale, SCROLL_LIMIT_PADDING / scale);
|
|
1781
|
+
}
|
|
1782
|
+
function scrollLimit(scroll, boundsList, config, initScroll) {
|
|
1783
|
+
scroll = { ...scroll };
|
|
1784
|
+
const configData = config.config;
|
|
1785
|
+
const oldScroll = { scrollX: configData.scrollX, scrollY: configData.scrollY };
|
|
1786
|
+
if (boundsList.length === 0 || configData.width === 0 || configData.height === 0) return scroll;
|
|
1787
|
+
const viewport = getScrollViewport(scroll, config);
|
|
1788
|
+
const isVisible = boundsList.find((bounds) => utils.Rectangle.isViewportVisible(bounds, viewport));
|
|
1789
|
+
if (!isVisible) {
|
|
1790
|
+
const oldViewport = getScrollViewport(oldScroll, config);
|
|
1791
|
+
const isOldVisible = boundsList.find(
|
|
1792
|
+
(bounds) => utils.Rectangle.isViewportVisible(bounds, oldViewport)
|
|
1793
|
+
);
|
|
1794
|
+
if (!isOldVisible) {
|
|
1795
|
+
return initScroll();
|
|
1796
|
+
}
|
|
1797
|
+
return oldScroll;
|
|
1798
|
+
}
|
|
1799
|
+
return scroll;
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
// src/utils/scroll-bar-events.ts
|
|
1803
|
+
var ScrollBarEvents = /* @__PURE__ */ Symbol("ScrollBarEvents");
|
|
1804
|
+
|
|
1805
|
+
// src/layers/flow-debug-layer.ts
|
|
1806
|
+
var rgbTimes = 0;
|
|
1807
|
+
function randomColor(percent) {
|
|
1808
|
+
const max = Math.min(percent / 10 * 255, 255);
|
|
1809
|
+
rgbTimes += 1;
|
|
1810
|
+
const rgb = rgbTimes % 3;
|
|
1811
|
+
const random = () => Math.floor(Math.random() * max);
|
|
1812
|
+
return `rgb(${rgb === 0 ? random() : 0}, ${rgb === 1 ? random() : 0}, ${rgb === 2 ? random() : 0})`;
|
|
1813
|
+
}
|
|
1814
|
+
exports.FlowDebugLayer = class FlowDebugLayer extends core.Layer {
|
|
1815
|
+
constructor() {
|
|
1816
|
+
super(...arguments);
|
|
1817
|
+
this.node = document.createElement("div");
|
|
1818
|
+
this.viewport = utils.domUtils.createDivWithClass("gedit-flow-debug-bounds");
|
|
1819
|
+
this.boundsNodes = utils.domUtils.createDivWithClass("gedit-flow-debug-bounds");
|
|
1820
|
+
this.pointsNodes = utils.domUtils.createDivWithClass("gedit-flow-debug-points");
|
|
1821
|
+
this.versionNodes = utils.domUtils.createDivWithClass("gedit-flow-debug-versions gedit-hidden");
|
|
1822
|
+
/**
|
|
1823
|
+
* ?debug=xxxx, 则返回 xxxx
|
|
1824
|
+
*/
|
|
1825
|
+
this.filterKey = window.location.search.match(/debug=([^&]+)/)?.[1] || "";
|
|
1826
|
+
this.originLine = document.createElement("div");
|
|
1827
|
+
this.domCache = /* @__PURE__ */ new WeakMap();
|
|
1828
|
+
}
|
|
1829
|
+
get transforms() {
|
|
1830
|
+
return this.document.getRenderDatas(document$1.FlowNodeTransformData);
|
|
1831
|
+
}
|
|
1832
|
+
onReady() {
|
|
1833
|
+
this.node.style.zIndex = "20";
|
|
1834
|
+
utils.domUtils.setStyle(this.originLine, {
|
|
1835
|
+
position: "absolute",
|
|
1836
|
+
width: 1,
|
|
1837
|
+
height: "100%",
|
|
1838
|
+
left: this.pipelineNode.style.left,
|
|
1839
|
+
top: 0,
|
|
1840
|
+
borderLeft: "1px dashed rgba(255, 0, 0, 0.5)"
|
|
1841
|
+
});
|
|
1842
|
+
this.pipelineNode.parentElement.appendChild(this.originLine);
|
|
1843
|
+
this.node.appendChild(this.viewport);
|
|
1844
|
+
this.node.appendChild(this.versionNodes);
|
|
1845
|
+
this.node.appendChild(this.boundsNodes);
|
|
1846
|
+
this.node.appendChild(this.pointsNodes);
|
|
1847
|
+
this.renderScrollViewportBounds();
|
|
1848
|
+
}
|
|
1849
|
+
onScroll() {
|
|
1850
|
+
this.originLine.style.left = this.pipelineNode.style.left;
|
|
1851
|
+
this.renderScrollViewportBounds();
|
|
1852
|
+
}
|
|
1853
|
+
onResize() {
|
|
1854
|
+
this.renderScrollViewportBounds();
|
|
1855
|
+
}
|
|
1856
|
+
onZoom(scale) {
|
|
1857
|
+
this.node.style.transform = `scale(${scale})`;
|
|
1858
|
+
this.renderScrollViewportBounds();
|
|
1859
|
+
}
|
|
1860
|
+
createBounds(transform, color, depth) {
|
|
1861
|
+
if (this.filterKey && transform.key.indexOf(this.filterKey) === -1) return;
|
|
1862
|
+
let cache = this.domCache.get(transform);
|
|
1863
|
+
const { bounds, inputPoint, outputPoint } = transform;
|
|
1864
|
+
if (!cache) {
|
|
1865
|
+
const bbox = utils.domUtils.createDivWithClass("");
|
|
1866
|
+
const input = utils.domUtils.createDivWithClass("");
|
|
1867
|
+
const output = utils.domUtils.createDivWithClass("");
|
|
1868
|
+
const version = utils.domUtils.createDivWithClass("");
|
|
1869
|
+
bbox.title = transform.key;
|
|
1870
|
+
input.title = transform.key + "(input)";
|
|
1871
|
+
output.title = transform.key + "(output)";
|
|
1872
|
+
version.title = transform.key;
|
|
1873
|
+
this.boundsNodes.appendChild(bbox);
|
|
1874
|
+
this.pointsNodes.appendChild(input);
|
|
1875
|
+
this.pointsNodes.appendChild(output);
|
|
1876
|
+
this.versionNodes.appendChild(version);
|
|
1877
|
+
transform.onDispose(() => {
|
|
1878
|
+
bbox.remove();
|
|
1879
|
+
input.remove();
|
|
1880
|
+
output.remove();
|
|
1881
|
+
});
|
|
1882
|
+
cache = { bbox, input, output, version, color };
|
|
1883
|
+
this.domCache.set(transform, cache);
|
|
1884
|
+
}
|
|
1885
|
+
utils.domUtils.setStyle(cache.version, {
|
|
1886
|
+
position: "absolute",
|
|
1887
|
+
marginLeft: "-9px",
|
|
1888
|
+
marginTop: "-10px",
|
|
1889
|
+
borderRadius: 12,
|
|
1890
|
+
background: "#f54a45",
|
|
1891
|
+
padding: 4,
|
|
1892
|
+
color: "navajowhite",
|
|
1893
|
+
display: transform.renderState.hidden ? "none" : "block",
|
|
1894
|
+
zIndex: depth + 1e3,
|
|
1895
|
+
left: bounds.center.x,
|
|
1896
|
+
top: bounds.center.y
|
|
1897
|
+
});
|
|
1898
|
+
cache.version.innerHTML = transform.version.toString();
|
|
1899
|
+
utils.domUtils.setStyle(cache.input, {
|
|
1900
|
+
position: "absolute",
|
|
1901
|
+
width: 10,
|
|
1902
|
+
height: 10,
|
|
1903
|
+
marginLeft: -5,
|
|
1904
|
+
marginTop: -5,
|
|
1905
|
+
borderRadius: 5,
|
|
1906
|
+
left: inputPoint.x,
|
|
1907
|
+
top: inputPoint.y,
|
|
1908
|
+
opacity: 0.4,
|
|
1909
|
+
zIndex: depth,
|
|
1910
|
+
backgroundColor: cache.color,
|
|
1911
|
+
whiteSpace: "nowrap",
|
|
1912
|
+
overflow: "visible"
|
|
1913
|
+
});
|
|
1914
|
+
cache.input.innerHTML = `${inputPoint.x},${inputPoint.y}`;
|
|
1915
|
+
utils.domUtils.setStyle(cache.output, {
|
|
1916
|
+
position: "absolute",
|
|
1917
|
+
width: 10,
|
|
1918
|
+
height: 10,
|
|
1919
|
+
marginLeft: -5,
|
|
1920
|
+
marginTop: -5,
|
|
1921
|
+
borderRadius: 5,
|
|
1922
|
+
left: outputPoint.x,
|
|
1923
|
+
top: outputPoint.y,
|
|
1924
|
+
opacity: 0.4,
|
|
1925
|
+
zIndex: depth,
|
|
1926
|
+
backgroundColor: cache.color,
|
|
1927
|
+
whiteSpace: "nowrap",
|
|
1928
|
+
overflow: "visible"
|
|
1929
|
+
});
|
|
1930
|
+
cache.output.innerHTML = `${outputPoint.x},${outputPoint.y}`;
|
|
1931
|
+
utils.domUtils.setStyle(cache.bbox, {
|
|
1932
|
+
position: "absolute",
|
|
1933
|
+
width: bounds.width,
|
|
1934
|
+
height: bounds.height,
|
|
1935
|
+
left: bounds.left,
|
|
1936
|
+
top: bounds.top,
|
|
1937
|
+
opacity: `${depth / 30}`,
|
|
1938
|
+
backgroundColor: cache.color
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* 显示 viewport 可滚动区域
|
|
1943
|
+
*/
|
|
1944
|
+
renderScrollViewportBounds() {
|
|
1945
|
+
const viewportBounds = getScrollViewport(
|
|
1946
|
+
{
|
|
1947
|
+
scrollX: this.config.config.scrollX,
|
|
1948
|
+
scrollY: this.config.config.scrollY
|
|
1949
|
+
},
|
|
1950
|
+
this.config
|
|
1951
|
+
);
|
|
1952
|
+
utils.domUtils.setStyle(this.viewport, {
|
|
1953
|
+
position: "absolute",
|
|
1954
|
+
width: viewportBounds.width - 2,
|
|
1955
|
+
height: viewportBounds.height - 2,
|
|
1956
|
+
left: viewportBounds.left + 1,
|
|
1957
|
+
top: viewportBounds.top + 1,
|
|
1958
|
+
border: "1px solid rgba(200, 200, 255, 0.5)"
|
|
1959
|
+
});
|
|
1960
|
+
}
|
|
1961
|
+
autorun() {
|
|
1962
|
+
if (this.documentTransformer.loading) return;
|
|
1963
|
+
this.documentTransformer.refresh();
|
|
1964
|
+
let color = randomColor(0);
|
|
1965
|
+
this.document.traverse((entity, depth) => {
|
|
1966
|
+
const transform = entity.getData(document$1.FlowNodeTransformData);
|
|
1967
|
+
color = randomColor(depth);
|
|
1968
|
+
this.createBounds(transform, color, depth);
|
|
1969
|
+
});
|
|
1970
|
+
this.renderScrollViewportBounds();
|
|
1971
|
+
}
|
|
1972
|
+
};
|
|
1973
|
+
__decorateClass([
|
|
1974
|
+
inversify.inject(document$1.FlowDocument)
|
|
1975
|
+
], exports.FlowDebugLayer.prototype, "document", 2);
|
|
1976
|
+
__decorateClass([
|
|
1977
|
+
core.observeEntity(document$1.FlowDocumentTransformerEntity)
|
|
1978
|
+
], exports.FlowDebugLayer.prototype, "documentTransformer", 2);
|
|
1979
|
+
__decorateClass([
|
|
1980
|
+
core.observeEntityDatas(document$1.FlowNodeEntity, document$1.FlowNodeTransformData)
|
|
1981
|
+
], exports.FlowDebugLayer.prototype, "_transforms", 2);
|
|
1982
|
+
exports.FlowDebugLayer = __decorateClass([
|
|
1983
|
+
inversify.injectable()
|
|
1984
|
+
], exports.FlowDebugLayer);
|
|
1985
|
+
var BORDER_WIDTH = 2;
|
|
1986
|
+
var BLOCK_OFFSET = 11;
|
|
1987
|
+
var SCROLL_BAR_WIDTH = "7px";
|
|
1988
|
+
exports.FlowScrollBarLayer = class FlowScrollBarLayer extends core.Layer {
|
|
1989
|
+
constructor() {
|
|
1990
|
+
super(...arguments);
|
|
1991
|
+
// @observeEntity(FlowDocumentTransformerEntity) readonly documentTransformer: FlowDocumentTransformerEntity
|
|
1992
|
+
// 右滚动区域
|
|
1993
|
+
this.rightScrollBar = utils.domUtils.createDivWithClass("gedit-playground-scroll-right");
|
|
1994
|
+
// 右滚动条
|
|
1995
|
+
this.rightScrollBarBlock = utils.domUtils.createDivWithClass("gedit-playground-scroll-right-block");
|
|
1996
|
+
// 底滚动区域
|
|
1997
|
+
this.bottomScrollBar = utils.domUtils.createDivWithClass("gedit-playground-scroll-bottom");
|
|
1998
|
+
// 底滚动条
|
|
1999
|
+
this.bottomScrollBarBlock = utils.domUtils.createDivWithClass(
|
|
2000
|
+
"gedit-playground-scroll-bottom-block"
|
|
2001
|
+
);
|
|
2002
|
+
// 总滚动距离
|
|
2003
|
+
this.sum = 0;
|
|
2004
|
+
// 初始 x 轴滚动距离
|
|
2005
|
+
this.initialScrollX = 0;
|
|
2006
|
+
// 初始 y 轴滚动距离
|
|
2007
|
+
this.initialScrollY = 0;
|
|
2008
|
+
this.bottomGrabDragger = new core.PlaygroundDrag({
|
|
2009
|
+
onDragStart: (e) => {
|
|
2010
|
+
this.config.updateCursor("grabbing");
|
|
2011
|
+
this.sum = 0;
|
|
2012
|
+
this.initialScrollX = this.config.getViewport().x;
|
|
2013
|
+
this.onBoardingToast();
|
|
2014
|
+
},
|
|
2015
|
+
onDrag: (e) => {
|
|
2016
|
+
this.sum += e.movingDelta.x;
|
|
2017
|
+
this.playgroundConfigEntity.scroll(
|
|
2018
|
+
{
|
|
2019
|
+
scrollX: (this.initialScrollX + this.sum * this.viewportFullWidth / (this.clientViewportWidth - this.scrollBottomWidth)) * this.scale
|
|
2020
|
+
},
|
|
2021
|
+
false
|
|
2022
|
+
);
|
|
2023
|
+
},
|
|
2024
|
+
onDragEnd: (e) => {
|
|
2025
|
+
this.config.updateCursor("default");
|
|
2026
|
+
}
|
|
2027
|
+
});
|
|
2028
|
+
this.rightGrabDragger = new core.PlaygroundDrag({
|
|
2029
|
+
onDragStart: (e) => {
|
|
2030
|
+
this.config.updateCursor("grabbing");
|
|
2031
|
+
this.sum = 0;
|
|
2032
|
+
this.initialScrollY = this.config.getViewport().y;
|
|
2033
|
+
this.onBoardingToast();
|
|
2034
|
+
},
|
|
2035
|
+
onDrag: (e) => {
|
|
2036
|
+
this.sum += e.movingDelta.y;
|
|
2037
|
+
this.playgroundConfigEntity.scroll(
|
|
2038
|
+
{
|
|
2039
|
+
scrollY: (this.initialScrollY + this.sum * this.viewportFullHeight / (this.clientViewportHeight - this.scrollRightHeight)) * this.scale
|
|
2040
|
+
},
|
|
2041
|
+
false
|
|
2042
|
+
);
|
|
2043
|
+
},
|
|
2044
|
+
onDragEnd: (e) => {
|
|
2045
|
+
this.config.updateCursor("default");
|
|
2046
|
+
}
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
// 浏览器视图宽度
|
|
2050
|
+
get clientViewportWidth() {
|
|
2051
|
+
return this.viewportWidth * this.scale - BLOCK_OFFSET;
|
|
2052
|
+
}
|
|
2053
|
+
// 浏览器视图高度
|
|
2054
|
+
get clientViewportHeight() {
|
|
2055
|
+
return this.viewportHeight * this.scale - BLOCK_OFFSET;
|
|
2056
|
+
}
|
|
2057
|
+
// 视图的完整宽度
|
|
2058
|
+
get viewportFullWidth() {
|
|
2059
|
+
return this.mostLeft - this.mostRight;
|
|
2060
|
+
}
|
|
2061
|
+
// 视图的完整高度
|
|
2062
|
+
get viewportFullHeight() {
|
|
2063
|
+
return this.mostTop - this.mostBottom;
|
|
2064
|
+
}
|
|
2065
|
+
// 视图的可移动宽度
|
|
2066
|
+
get viewportMoveWidth() {
|
|
2067
|
+
return this.mostLeft - this.mostRight + this.width;
|
|
2068
|
+
}
|
|
2069
|
+
// 视图的可移动高度
|
|
2070
|
+
get viewportMoveHeight() {
|
|
2071
|
+
return this.mostTop - this.mostBottom + this.height;
|
|
2072
|
+
}
|
|
2073
|
+
getToLeft(scrollX) {
|
|
2074
|
+
return (scrollX - this.mostRight) / this.viewportMoveWidth * this.clientViewportWidth;
|
|
2075
|
+
}
|
|
2076
|
+
getToTop(scrollY) {
|
|
2077
|
+
return (scrollY - this.mostBottom) / this.viewportMoveHeight * this.clientViewportHeight;
|
|
2078
|
+
}
|
|
2079
|
+
clickRightScrollBar(e) {
|
|
2080
|
+
e.preventDefault();
|
|
2081
|
+
e.stopPropagation();
|
|
2082
|
+
const ratio = 1 - (e?.y || 0) / this.clientViewportHeight;
|
|
2083
|
+
const scrollY = (this.mostTop - this.viewportFullHeight * ratio) * this.scale;
|
|
2084
|
+
this.playgroundConfigEntity.scroll(
|
|
2085
|
+
{
|
|
2086
|
+
scrollY
|
|
2087
|
+
},
|
|
2088
|
+
false
|
|
2089
|
+
);
|
|
2090
|
+
}
|
|
2091
|
+
clickBottomScrollBar(e) {
|
|
2092
|
+
e.preventDefault();
|
|
2093
|
+
e.stopPropagation();
|
|
2094
|
+
const ratio = 1 - (e?.x || 0) / this.clientViewportWidth;
|
|
2095
|
+
const scrollX = (this.mostLeft - this.viewportFullWidth * ratio) * this.scale;
|
|
2096
|
+
this.playgroundConfigEntity.scroll(
|
|
2097
|
+
{
|
|
2098
|
+
scrollX
|
|
2099
|
+
},
|
|
2100
|
+
false
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
onBoardingToast() {
|
|
2104
|
+
this.events?.dragStart();
|
|
2105
|
+
}
|
|
2106
|
+
changeScrollBarVisibility(scrollBar, status) {
|
|
2107
|
+
const addClassName = status === "show" /* Show */ ? "gedit-playground-scroll-show" : "gedit-playground-scroll-hidden";
|
|
2108
|
+
const delClassName = status === "show" /* Show */ ? "gedit-playground-scroll-hidden" : "gedit-playground-scroll-show";
|
|
2109
|
+
utils.domUtils.addClass(scrollBar, addClassName);
|
|
2110
|
+
utils.domUtils.delClass(scrollBar, delClassName);
|
|
2111
|
+
}
|
|
2112
|
+
onReady() {
|
|
2113
|
+
if (!this.options.getBounds) {
|
|
2114
|
+
this.options = {
|
|
2115
|
+
getBounds: () => {
|
|
2116
|
+
const document2 = this.flowDocument;
|
|
2117
|
+
if (!document2) return utils.Rectangle.EMPTY;
|
|
2118
|
+
document2.transformer.refresh();
|
|
2119
|
+
return document2.root.getData(document$1.FlowNodeTransformData).bounds;
|
|
2120
|
+
},
|
|
2121
|
+
showScrollBars: "whenScrolling"
|
|
2122
|
+
};
|
|
2123
|
+
}
|
|
2124
|
+
this.pipelineNode.parentNode.appendChild(this.rightScrollBar);
|
|
2125
|
+
this.pipelineNode.parentNode.appendChild(this.rightScrollBarBlock);
|
|
2126
|
+
this.pipelineNode.parentNode.appendChild(this.bottomScrollBar);
|
|
2127
|
+
this.pipelineNode.parentNode.appendChild(this.bottomScrollBarBlock);
|
|
2128
|
+
this.rightScrollBar.onclick = this.clickRightScrollBar.bind(this);
|
|
2129
|
+
this.bottomScrollBar.onclick = this.clickBottomScrollBar.bind(this);
|
|
2130
|
+
if (this.options.showScrollBars === "whenScrolling") {
|
|
2131
|
+
this.rightScrollBar.addEventListener("mouseenter", (e) => {
|
|
2132
|
+
this.changeScrollBarVisibility(this.rightScrollBarBlock, "show" /* Show */);
|
|
2133
|
+
});
|
|
2134
|
+
this.rightScrollBar.addEventListener("mouseleave", (e) => {
|
|
2135
|
+
this.changeScrollBarVisibility(this.rightScrollBarBlock, "hidden" /* Hidden */);
|
|
2136
|
+
});
|
|
2137
|
+
this.bottomScrollBar.addEventListener("mouseenter", (e) => {
|
|
2138
|
+
this.changeScrollBarVisibility(this.bottomScrollBarBlock, "show" /* Show */);
|
|
2139
|
+
});
|
|
2140
|
+
this.bottomScrollBar.addEventListener("mouseleave", (e) => {
|
|
2141
|
+
this.changeScrollBarVisibility(this.bottomScrollBarBlock, "hidden" /* Hidden */);
|
|
2142
|
+
});
|
|
2143
|
+
}
|
|
2144
|
+
this.bottomScrollBarBlock.addEventListener("mousedown", (e) => {
|
|
2145
|
+
this.bottomGrabDragger.start(e.clientX, e.clientY);
|
|
2146
|
+
e.stopPropagation();
|
|
2147
|
+
});
|
|
2148
|
+
this.rightScrollBarBlock.addEventListener("mousedown", (e) => {
|
|
2149
|
+
this.rightGrabDragger.start(e.clientX, e.clientY);
|
|
2150
|
+
e.stopPropagation();
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2153
|
+
autorun() {
|
|
2154
|
+
if (this.hideTimeout) {
|
|
2155
|
+
clearTimeout(this.hideTimeout);
|
|
2156
|
+
}
|
|
2157
|
+
const viewportBounds = getScrollViewport(
|
|
2158
|
+
{
|
|
2159
|
+
scrollX: this.config.config.scrollX,
|
|
2160
|
+
scrollY: this.config.config.scrollY
|
|
2161
|
+
},
|
|
2162
|
+
this.config
|
|
2163
|
+
);
|
|
2164
|
+
const viewport = this.config.getViewport();
|
|
2165
|
+
this.viewportWidth = viewport.width;
|
|
2166
|
+
this.viewportHeight = viewport.height;
|
|
2167
|
+
const rootBounds = this.options.getBounds();
|
|
2168
|
+
this.width = rootBounds?.width || 0;
|
|
2169
|
+
this.height = rootBounds?.height || 0;
|
|
2170
|
+
const paddingLeftRight = (this.viewportWidth - viewportBounds.width) / 2 - BORDER_WIDTH;
|
|
2171
|
+
const paddingTopBottom = (this.viewportHeight - viewportBounds.height) / 2 - BORDER_WIDTH;
|
|
2172
|
+
const canvasTotalWidth = this.width + viewportBounds.width;
|
|
2173
|
+
const canvasTotalHeight = this.height + viewportBounds.height;
|
|
2174
|
+
const initialOffsetX = rootBounds.x;
|
|
2175
|
+
const initialOffsetY = rootBounds.y;
|
|
2176
|
+
this.mostLeft = this.width + initialOffsetX - paddingLeftRight;
|
|
2177
|
+
this.mostRight = this.mostLeft - canvasTotalWidth;
|
|
2178
|
+
this.mostTop = this.height + initialOffsetY - paddingTopBottom;
|
|
2179
|
+
this.mostBottom = this.mostTop - canvasTotalHeight;
|
|
2180
|
+
this.scale = this.config.finalScale;
|
|
2181
|
+
const calcViewportWidth = this.clientViewportWidth;
|
|
2182
|
+
const calcViewportHeight = this.clientViewportHeight;
|
|
2183
|
+
this.scrollBottomWidth = calcViewportWidth - calcViewportWidth * (this.mostLeft - this.mostRight) / this.viewportMoveWidth;
|
|
2184
|
+
this.scrollRightHeight = calcViewportHeight - calcViewportHeight * (this.mostTop - this.mostBottom) / this.viewportMoveHeight;
|
|
2185
|
+
const bottomBarToLeft = this.getToLeft(viewport.x);
|
|
2186
|
+
const rightBarToTop = this.getToTop(viewport.y);
|
|
2187
|
+
utils.domUtils.setStyle(this.rightScrollBarBlock, {
|
|
2188
|
+
right: 2,
|
|
2189
|
+
top: rightBarToTop,
|
|
2190
|
+
background: "#1F2329",
|
|
2191
|
+
zIndex: 10,
|
|
2192
|
+
height: this.scrollRightHeight,
|
|
2193
|
+
width: SCROLL_BAR_WIDTH
|
|
2194
|
+
});
|
|
2195
|
+
utils.domUtils.setStyle(this.bottomScrollBarBlock, {
|
|
2196
|
+
left: bottomBarToLeft,
|
|
2197
|
+
bottom: 2,
|
|
2198
|
+
background: "#1F2329",
|
|
2199
|
+
zIndex: 10,
|
|
2200
|
+
height: SCROLL_BAR_WIDTH,
|
|
2201
|
+
width: this.scrollBottomWidth
|
|
2202
|
+
});
|
|
2203
|
+
this.changeScrollBarVisibility(this.rightScrollBarBlock, "show" /* Show */);
|
|
2204
|
+
this.changeScrollBarVisibility(this.bottomScrollBarBlock, "show" /* Show */);
|
|
2205
|
+
if (this.options.showScrollBars === "whenScrolling") {
|
|
2206
|
+
this.hideTimeout = window.setTimeout(() => {
|
|
2207
|
+
this.changeScrollBarVisibility(this.rightScrollBarBlock, "hidden" /* Hidden */);
|
|
2208
|
+
this.changeScrollBarVisibility(this.bottomScrollBarBlock, "hidden" /* Hidden */);
|
|
2209
|
+
this.hideTimeout = void 0;
|
|
2210
|
+
}, 1e3);
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
__decorateClass([
|
|
2215
|
+
inversify.optional(),
|
|
2216
|
+
inversify.inject(ScrollBarEvents)
|
|
2217
|
+
], exports.FlowScrollBarLayer.prototype, "events", 2);
|
|
2218
|
+
__decorateClass([
|
|
2219
|
+
inversify.inject(document$1.FlowDocument),
|
|
2220
|
+
inversify.optional()
|
|
2221
|
+
], exports.FlowScrollBarLayer.prototype, "flowDocument", 2);
|
|
2222
|
+
__decorateClass([
|
|
2223
|
+
core.observeEntity(core.PlaygroundConfigEntity)
|
|
2224
|
+
], exports.FlowScrollBarLayer.prototype, "playgroundConfigEntity", 2);
|
|
2225
|
+
exports.FlowScrollBarLayer = __decorateClass([
|
|
2226
|
+
inversify.injectable()
|
|
2227
|
+
], exports.FlowScrollBarLayer);
|
|
2228
|
+
var DRAG_OFFSET = 10;
|
|
2229
|
+
var DEFAULT_DRAG_OFFSET_X = 8;
|
|
2230
|
+
var DEFAULT_DRAG_OFFSET_Y = 8;
|
|
2231
|
+
exports.FlowDragLayer = class FlowDragLayer extends core.Layer {
|
|
2232
|
+
constructor() {
|
|
2233
|
+
super(...arguments);
|
|
2234
|
+
this.disableDragScroll = false;
|
|
2235
|
+
this.dragOffset = {
|
|
2236
|
+
x: DEFAULT_DRAG_OFFSET_X,
|
|
2237
|
+
y: DEFAULT_DRAG_OFFSET_Y
|
|
2238
|
+
};
|
|
2239
|
+
this.containerRef = { current: null };
|
|
2240
|
+
this.draggingNodeMask = document.createElement("div");
|
|
2241
|
+
this._dragger = new core.PlaygroundDrag({
|
|
2242
|
+
onDrag: (e) => {
|
|
2243
|
+
this.handleMouseMove(e);
|
|
2244
|
+
},
|
|
2245
|
+
onDragEnd: () => {
|
|
2246
|
+
this.handleMouseUp();
|
|
2247
|
+
},
|
|
2248
|
+
stopGlobalEventNames: ["contextmenu"]
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
get transitions() {
|
|
2252
|
+
const result = [];
|
|
2253
|
+
this.document.traverse((entity) => {
|
|
2254
|
+
result.push(entity.getData(document$1.FlowNodeTransitionData));
|
|
2255
|
+
});
|
|
2256
|
+
return result;
|
|
2257
|
+
}
|
|
2258
|
+
get dragStartEntity() {
|
|
2259
|
+
return this.flowRenderStateEntity.getDragStartEntity();
|
|
2260
|
+
}
|
|
2261
|
+
set dragStartEntity(entity) {
|
|
2262
|
+
this.flowRenderStateEntity.setDragStartEntity(entity);
|
|
2263
|
+
}
|
|
2264
|
+
get dragEntities() {
|
|
2265
|
+
return this.flowRenderStateEntity.getDragEntities();
|
|
2266
|
+
}
|
|
2267
|
+
set dragEntities(entities) {
|
|
2268
|
+
this.flowRenderStateEntity.setDragEntities(entities);
|
|
2269
|
+
}
|
|
2270
|
+
isGrab() {
|
|
2271
|
+
const currentState = this.editorStateConfig.getCurrentState();
|
|
2272
|
+
return currentState === core.EditorState.STATE_GRAB;
|
|
2273
|
+
}
|
|
2274
|
+
setDraggingStatus(status) {
|
|
2275
|
+
if (this.flowDragService.nodeDragIdsWithChildren.length) {
|
|
2276
|
+
this.flowDragService.nodeDragIdsWithChildren.forEach((_id) => {
|
|
2277
|
+
const node = this.entityManager.getEntityById(_id);
|
|
2278
|
+
const data = node?.getData(document$1.FlowNodeRenderData);
|
|
2279
|
+
data.dragging = status;
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2282
|
+
this.flowRenderStateEntity.setDragging(status);
|
|
2283
|
+
}
|
|
2284
|
+
dragEnable(e) {
|
|
2285
|
+
return Math.abs(e.clientX - this.initialPosition.x) > DRAG_OFFSET || Math.abs(e.clientY - this.initialPosition.y) > DRAG_OFFSET;
|
|
2286
|
+
}
|
|
2287
|
+
handleMouseMove(event) {
|
|
2288
|
+
if ((this.dragJSON || this.dragStartEntity) && this.dragEnable(event)) {
|
|
2289
|
+
this.setDraggingStatus(true);
|
|
2290
|
+
const scale = this.playgroundConfigEntity.finalScale;
|
|
2291
|
+
if (this.containerRef.current) {
|
|
2292
|
+
const dragNode = this.containerRef.current.children?.[0];
|
|
2293
|
+
if (!dragNode) {
|
|
2294
|
+
return;
|
|
2295
|
+
}
|
|
2296
|
+
const clientBounds = this.playgroundConfigEntity.getClientBounds();
|
|
2297
|
+
const dragBlockX = event.clientX - (this.pipelineNode.offsetLeft || 0) - clientBounds.x - (dragNode.clientWidth - this.dragOffset.x) * scale;
|
|
2298
|
+
const dragBlockY = event.clientY - (this.pipelineNode.offsetTop || 0) - clientBounds.y - (dragNode.clientHeight - this.dragOffset.y) * scale;
|
|
2299
|
+
const isBranch = this.flowDragService.isDragBranch;
|
|
2300
|
+
const draggingRect = new utils.Rectangle(
|
|
2301
|
+
dragBlockX,
|
|
2302
|
+
dragBlockY,
|
|
2303
|
+
dragNode.clientWidth * scale,
|
|
2304
|
+
dragNode.clientHeight * scale
|
|
2305
|
+
);
|
|
2306
|
+
let side;
|
|
2307
|
+
const collisionTransition = this.transitions.find((transition) => {
|
|
2308
|
+
if (transition?.entity?.parent?.collapsed) {
|
|
2309
|
+
return false;
|
|
2310
|
+
}
|
|
2311
|
+
const { hasCollision, labelOffsetType } = this.flowDragConfigEntity.isCollision(
|
|
2312
|
+
transition,
|
|
2313
|
+
draggingRect,
|
|
2314
|
+
isBranch
|
|
2315
|
+
);
|
|
2316
|
+
side = labelOffsetType;
|
|
2317
|
+
return hasCollision;
|
|
2318
|
+
});
|
|
2319
|
+
if (collisionTransition && (isBranch ? this.flowDragService.isDroppableBranch(collisionTransition.entity, side) : this.flowDragService.isDroppableNode(collisionTransition.entity)) && (!this.options.canDrop || this.options.canDrop({
|
|
2320
|
+
dragNodes: this.dragEntities,
|
|
2321
|
+
dropNode: collisionTransition.entity,
|
|
2322
|
+
isBranch
|
|
2323
|
+
}))) {
|
|
2324
|
+
this.flowRenderStateEntity.setNodeDroppingId(collisionTransition.entity.id);
|
|
2325
|
+
} else {
|
|
2326
|
+
this.flowRenderStateEntity.setNodeDroppingId("");
|
|
2327
|
+
}
|
|
2328
|
+
this.flowRenderStateEntity.setDragLabelSide(side);
|
|
2329
|
+
this.containerRef.current.style.visibility = "visible";
|
|
2330
|
+
this.pipelineNode.parentElement.appendChild(this.draggingNodeMask);
|
|
2331
|
+
this.containerRef.current.style.left = `${dragBlockX + this.pipelineNode.offsetLeft + clientBounds.x + window.scrollX}px`;
|
|
2332
|
+
this.containerRef.current.style.top = `${dragBlockY + this.pipelineNode.offsetTop + clientBounds.y + window.scrollY}px`;
|
|
2333
|
+
this.containerRef.current.style.transformOrigin = "top left";
|
|
2334
|
+
this.containerRef.current.style.transform = `scale(${scale})`;
|
|
2335
|
+
if (!this.disableDragScroll) {
|
|
2336
|
+
this.flowDragConfigEntity.scrollDirection(event, dragBlockX, dragBlockY);
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
async handleMouseUp() {
|
|
2342
|
+
this.setDraggingStatus(false);
|
|
2343
|
+
if (this.dragStartEntity || this.dragJSON) {
|
|
2344
|
+
const activatedNodeId = this.flowDragService.dropNodeId;
|
|
2345
|
+
if (activatedNodeId) {
|
|
2346
|
+
if (this.flowDragService.isDragBranch) {
|
|
2347
|
+
if (this.dragJSON) {
|
|
2348
|
+
await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
|
|
2349
|
+
} else {
|
|
2350
|
+
this.flowDragService.dropBranch();
|
|
2351
|
+
}
|
|
2352
|
+
} else {
|
|
2353
|
+
if (this.dragJSON) {
|
|
2354
|
+
await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
|
|
2355
|
+
} else {
|
|
2356
|
+
this.flowDragService.dropNode();
|
|
2357
|
+
}
|
|
2358
|
+
this.selectConfigEntity.clearSelectedNodes();
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
this.flowRenderStateEntity.setNodeDroppingId("");
|
|
2362
|
+
this.flowRenderStateEntity.setDragLabelSide();
|
|
2363
|
+
this.flowRenderStateEntity.setIsBranch(false);
|
|
2364
|
+
this.dragStartEntity = void 0;
|
|
2365
|
+
this.dragEntities = [];
|
|
2366
|
+
this.flowDragConfigEntity.stopAllScroll();
|
|
2367
|
+
}
|
|
2368
|
+
this.disableDragScroll = false;
|
|
2369
|
+
this.dragJSON = void 0;
|
|
2370
|
+
if (this.containerRef.current) {
|
|
2371
|
+
this.containerRef.current.style.visibility = "hidden";
|
|
2372
|
+
if (this.pipelineNode.parentElement.contains(this.draggingNodeMask)) {
|
|
2373
|
+
this.pipelineNode.parentElement.removeChild(this.draggingNodeMask);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
/**
|
|
2378
|
+
* 开始拖拽事件
|
|
2379
|
+
* @param e
|
|
2380
|
+
*/
|
|
2381
|
+
async startDrag(e, {
|
|
2382
|
+
dragStartEntity: startEntityFromProps,
|
|
2383
|
+
dragEntities,
|
|
2384
|
+
dragJSON,
|
|
2385
|
+
isBranch,
|
|
2386
|
+
onCreateNode
|
|
2387
|
+
}, options) {
|
|
2388
|
+
if (this.isGrab() || this.config.disabled || this.config.readonly) {
|
|
2389
|
+
return;
|
|
2390
|
+
}
|
|
2391
|
+
this.disableDragScroll = Boolean(options?.disableDragScroll);
|
|
2392
|
+
this.dragJSON = dragJSON;
|
|
2393
|
+
this.onCreateNode = onCreateNode;
|
|
2394
|
+
this.flowRenderStateEntity.setIsBranch(Boolean(isBranch));
|
|
2395
|
+
this.dragOffset.x = options?.dragOffsetX || DEFAULT_DRAG_OFFSET_X;
|
|
2396
|
+
this.dragOffset.y = options?.dragOffsetY || DEFAULT_DRAG_OFFSET_Y;
|
|
2397
|
+
const type = startEntityFromProps?.flowNodeType || dragJSON?.type;
|
|
2398
|
+
const isIcon = type === document$1.FlowNodeBaseType.BLOCK_ICON;
|
|
2399
|
+
const isOrderIcon = type === document$1.FlowNodeBaseType.BLOCK_ORDER_ICON;
|
|
2400
|
+
const dragStartEntity = isIcon || isOrderIcon ? startEntityFromProps.parent : startEntityFromProps;
|
|
2401
|
+
if (dragStartEntity && !dragStartEntity.getData(document$1.FlowNodeRenderData).draggable) {
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
this.initialPosition = {
|
|
2405
|
+
x: e.clientX,
|
|
2406
|
+
y: e.clientY
|
|
2407
|
+
};
|
|
2408
|
+
this.dragStartEntity = dragStartEntity;
|
|
2409
|
+
this.dragEntities = dragEntities || (this.dragStartEntity ? [this.dragStartEntity] : []);
|
|
2410
|
+
return this._dragger.start(e.clientX, e.clientY);
|
|
2411
|
+
}
|
|
2412
|
+
onReady() {
|
|
2413
|
+
this.draggingNodeMask.style.width = "100%";
|
|
2414
|
+
this.draggingNodeMask.style.height = "100%";
|
|
2415
|
+
this.draggingNodeMask.style.position = "absolute";
|
|
2416
|
+
this.draggingNodeMask.classList.add("dragging-node");
|
|
2417
|
+
this.draggingNodeMask.style.zIndex = "99";
|
|
2418
|
+
this.draggingNodeMask.style.cursor = "pointer";
|
|
2419
|
+
this.dragNodeComp = this.rendererRegistry.getRendererComponent("drag-node" /* DRAG_NODE */);
|
|
2420
|
+
if (this.options.onDrop) {
|
|
2421
|
+
this.toDispose.push(this.flowDragService.onDrop(this.options.onDrop));
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
dispose() {
|
|
2425
|
+
this._dragger.dispose();
|
|
2426
|
+
super.dispose();
|
|
2427
|
+
}
|
|
2428
|
+
render() {
|
|
2429
|
+
const DragComp = this.dragNodeComp?.renderer;
|
|
2430
|
+
return wrapLayerRender(
|
|
2431
|
+
this.playgroundContainer,
|
|
2432
|
+
vue.h(vue.Teleport, { to: "body" }, [
|
|
2433
|
+
vue.h(
|
|
2434
|
+
"div",
|
|
2435
|
+
{
|
|
2436
|
+
ref: (el) => {
|
|
2437
|
+
this.containerRef.current = el || null;
|
|
2438
|
+
},
|
|
2439
|
+
style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
|
|
2440
|
+
onMouseenter: (e) => e.stopPropagation()
|
|
2441
|
+
},
|
|
2442
|
+
[
|
|
2443
|
+
DragComp ? vue.h(DragComp, {
|
|
2444
|
+
dragJSON: this.dragJSON,
|
|
2445
|
+
dragStart: this.dragStartEntity,
|
|
2446
|
+
dragNodes: this.dragEntities
|
|
2447
|
+
}) : null
|
|
2448
|
+
]
|
|
2449
|
+
)
|
|
2450
|
+
])
|
|
2451
|
+
);
|
|
2452
|
+
}
|
|
2453
|
+
};
|
|
2454
|
+
__decorateClass([
|
|
2455
|
+
inversify.inject(document$1.FlowDocument)
|
|
2456
|
+
], exports.FlowDragLayer.prototype, "document", 2);
|
|
2457
|
+
__decorateClass([
|
|
2458
|
+
inversify.inject(document$1.FlowDragService)
|
|
2459
|
+
], exports.FlowDragLayer.prototype, "flowDragService", 2);
|
|
2460
|
+
__decorateClass([
|
|
2461
|
+
inversify.inject(core.PlaygroundContainerFactory)
|
|
2462
|
+
], exports.FlowDragLayer.prototype, "playgroundContainer", 2);
|
|
2463
|
+
__decorateClass([
|
|
2464
|
+
core.observeEntityDatas(document$1.FlowNodeEntity, document$1.FlowNodeTransformData)
|
|
2465
|
+
], exports.FlowDragLayer.prototype, "transforms", 2);
|
|
2466
|
+
__decorateClass([
|
|
2467
|
+
core.observeEntity(core.EditorStateConfigEntity)
|
|
2468
|
+
], exports.FlowDragLayer.prototype, "editorStateConfig", 2);
|
|
2469
|
+
__decorateClass([
|
|
2470
|
+
core.observeEntity(core.PlaygroundConfigEntity)
|
|
2471
|
+
], exports.FlowDragLayer.prototype, "playgroundConfigEntity", 2);
|
|
2472
|
+
__decorateClass([
|
|
2473
|
+
core.observeEntity(FlowDragEntity)
|
|
2474
|
+
], exports.FlowDragLayer.prototype, "flowDragConfigEntity", 2);
|
|
2475
|
+
__decorateClass([
|
|
2476
|
+
core.observeEntity(document$1.FlowRendererStateEntity)
|
|
2477
|
+
], exports.FlowDragLayer.prototype, "flowRenderStateEntity", 2);
|
|
2478
|
+
__decorateClass([
|
|
2479
|
+
core.observeEntity(FlowSelectConfigEntity)
|
|
2480
|
+
], exports.FlowDragLayer.prototype, "selectConfigEntity", 2);
|
|
2481
|
+
__decorateClass([
|
|
2482
|
+
inversify.inject(exports.FlowRendererRegistry)
|
|
2483
|
+
], exports.FlowDragLayer.prototype, "rendererRegistry", 2);
|
|
2484
|
+
exports.FlowDragLayer = __decorateClass([
|
|
2485
|
+
inversify.injectable()
|
|
2486
|
+
], exports.FlowDragLayer);
|
|
2487
|
+
exports.FlowSelectorBoxLayer = class FlowSelectorBoxLayer extends core.Layer {
|
|
2488
|
+
constructor() {
|
|
2489
|
+
super(...arguments);
|
|
2490
|
+
this.node = utils.domUtils.createDivWithClass("gedit-selector-box-layer");
|
|
2491
|
+
/**
|
|
2492
|
+
* 选择框
|
|
2493
|
+
*/
|
|
2494
|
+
this.selectorBox = this.createDOMCache("gedit-selector-box");
|
|
2495
|
+
/**
|
|
2496
|
+
* 用于遮挡鼠标,避免触发 hover
|
|
2497
|
+
*/
|
|
2498
|
+
this.selectorBoxBlock = this.createDOMCache("gedit-selector-box-block");
|
|
2499
|
+
/**
|
|
2500
|
+
* 拖动选择框
|
|
2501
|
+
*/
|
|
2502
|
+
this.selectboxDragger = new core.PlaygroundDrag({
|
|
2503
|
+
onDragStart: (e) => {
|
|
2504
|
+
this.selectConfigEntity.clearSelectedNodes();
|
|
2505
|
+
const mousePos = this.playgroundConfigEntity.getPosFromMouseEvent(e);
|
|
2506
|
+
this.transformVisibles = this.flowDocument.getRenderDatas(document$1.FlowNodeTransformData, false).filter((transform) => {
|
|
2507
|
+
const { entity } = transform;
|
|
2508
|
+
if (entity.originParent) {
|
|
2509
|
+
return this.nodeSelectable(entity, mousePos) && this.nodeSelectable(entity.originParent, mousePos);
|
|
2510
|
+
}
|
|
2511
|
+
return this.nodeSelectable(entity, mousePos);
|
|
2512
|
+
});
|
|
2513
|
+
this.selectorBoxConfigEntity.setDragInfo(e);
|
|
2514
|
+
this.updateSelectorBox(this.selectorBoxConfigEntity);
|
|
2515
|
+
},
|
|
2516
|
+
onDrag: (e) => {
|
|
2517
|
+
this.selectorBoxConfigEntity.setDragInfo(e);
|
|
2518
|
+
this.selectConfigEntity.selectFromBounds(
|
|
2519
|
+
this.selectorBoxConfigEntity.toRectangle(this.playgroundConfigEntity.finalScale),
|
|
2520
|
+
this.transformVisibles
|
|
2521
|
+
);
|
|
2522
|
+
this.updateSelectorBox(this.selectorBoxConfigEntity);
|
|
2523
|
+
},
|
|
2524
|
+
onDragEnd: (e) => {
|
|
2525
|
+
this.selectorBoxConfigEntity.setDragInfo(e);
|
|
2526
|
+
this.transformVisibles.length = 0;
|
|
2527
|
+
this.updateSelectorBox(this.selectorBoxConfigEntity);
|
|
2528
|
+
}
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
onReady() {
|
|
2532
|
+
if (!this.options.canSelect) {
|
|
2533
|
+
this.options.canSelect = (e) => {
|
|
2534
|
+
const target = e.target;
|
|
2535
|
+
return target === this.pipelineNode || target === this.playgroundNode;
|
|
2536
|
+
};
|
|
2537
|
+
}
|
|
2538
|
+
this.toDispose.pushAll([
|
|
2539
|
+
this.selectConfigEntity.onConfigChanged(() => {
|
|
2540
|
+
this.selectionService.selection = this.selectConfigEntity.selectedNodes;
|
|
2541
|
+
}),
|
|
2542
|
+
this.selectionService.onSelectionChanged(() => {
|
|
2543
|
+
const selectedNodes = this.selectionService.selection.filter(
|
|
2544
|
+
(entity) => entity instanceof document$1.FlowNodeEntity
|
|
2545
|
+
);
|
|
2546
|
+
this.selectConfigEntity.selectedNodes = selectedNodes;
|
|
2547
|
+
})
|
|
2548
|
+
]);
|
|
2549
|
+
this.listenPlaygroundEvent(
|
|
2550
|
+
"mousedown",
|
|
2551
|
+
(e) => {
|
|
2552
|
+
if (!this.isEnabled()) return;
|
|
2553
|
+
if (this.options.canSelect && !this.options.canSelect(e, this.selectorBoxConfigEntity)) {
|
|
2554
|
+
return;
|
|
2555
|
+
}
|
|
2556
|
+
const currentState = this.editorStateConfig.getCurrentState();
|
|
2557
|
+
if (currentState === core.EditorState.STATE_MOUSE_FRIENDLY_SELECT) {
|
|
2558
|
+
this.selectConfigEntity.clearSelectedNodes();
|
|
2559
|
+
}
|
|
2560
|
+
this.selectboxDragger.start(e.clientX, e.clientY, this.config);
|
|
2561
|
+
return true;
|
|
2562
|
+
},
|
|
2563
|
+
core.PipelineLayerPriority.BASE_LAYER
|
|
2564
|
+
);
|
|
2565
|
+
}
|
|
2566
|
+
isEnabled() {
|
|
2567
|
+
const currentState = this.editorStateConfig.getCurrentState();
|
|
2568
|
+
const isMouseFriendly = currentState === core.EditorState.STATE_MOUSE_FRIENDLY_SELECT;
|
|
2569
|
+
return !this.config.disabled && !this.config.readonly && // 鼠标友好模式下,需要按下 shift 启动框选
|
|
2570
|
+
(isMouseFriendly && this.editorStateConfig.isPressingShift || currentState === core.EditorState.STATE_SELECT) && !this.selectorBoxConfigEntity.disabled;
|
|
2571
|
+
}
|
|
2572
|
+
/**
|
|
2573
|
+
* Destroy
|
|
2574
|
+
*/
|
|
2575
|
+
dispose() {
|
|
2576
|
+
this.selectorBox.dispose();
|
|
2577
|
+
this.selectorBoxBlock.dispose();
|
|
2578
|
+
super.dispose();
|
|
2579
|
+
}
|
|
2580
|
+
updateSelectorBox(selector) {
|
|
2581
|
+
const node = this.selectorBox.get();
|
|
2582
|
+
const block = this.selectorBoxBlock.get();
|
|
2583
|
+
if (!this.isEnabled() && selector.isMoving) {
|
|
2584
|
+
this.selectorBoxConfigEntity.collapse();
|
|
2585
|
+
}
|
|
2586
|
+
if (!this.isEnabled() || !selector.isMoving) {
|
|
2587
|
+
node.setStyle({
|
|
2588
|
+
display: "none"
|
|
2589
|
+
});
|
|
2590
|
+
block.setStyle({
|
|
2591
|
+
display: "none"
|
|
2592
|
+
});
|
|
2593
|
+
} else {
|
|
2594
|
+
node.setStyle({
|
|
2595
|
+
display: "block",
|
|
2596
|
+
left: selector.position.x,
|
|
2597
|
+
top: selector.position.y,
|
|
2598
|
+
width: selector.size.width,
|
|
2599
|
+
height: selector.size.height
|
|
2600
|
+
});
|
|
2601
|
+
block.setStyle({
|
|
2602
|
+
display: "block",
|
|
2603
|
+
left: selector.position.x - 10,
|
|
2604
|
+
top: selector.position.y - 10,
|
|
2605
|
+
width: selector.size.width + 20,
|
|
2606
|
+
height: selector.size.height + 20
|
|
2607
|
+
});
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
nodeSelectable(node, mousePos) {
|
|
2611
|
+
const selectable = node.getNodeMeta().selectable;
|
|
2612
|
+
if (typeof selectable === "function") {
|
|
2613
|
+
return selectable(node, mousePos);
|
|
2614
|
+
} else {
|
|
2615
|
+
return selectable;
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
// autorun(): void {
|
|
2619
|
+
// this.updateSelectorBox(this.selectorBoxConfigEntity);
|
|
2620
|
+
// }
|
|
2621
|
+
};
|
|
2622
|
+
__decorateClass([
|
|
2623
|
+
inversify.inject(document$1.FlowDocument)
|
|
2624
|
+
], exports.FlowSelectorBoxLayer.prototype, "flowDocument", 2);
|
|
2625
|
+
__decorateClass([
|
|
2626
|
+
inversify.inject(core.ContextMenuService)
|
|
2627
|
+
], exports.FlowSelectorBoxLayer.prototype, "contextMenuService", 2);
|
|
2628
|
+
__decorateClass([
|
|
2629
|
+
core.observeEntity(core.PlaygroundConfigEntity)
|
|
2630
|
+
], exports.FlowSelectorBoxLayer.prototype, "playgroundConfigEntity", 2);
|
|
2631
|
+
__decorateClass([
|
|
2632
|
+
inversify.inject(core.SelectionService)
|
|
2633
|
+
], exports.FlowSelectorBoxLayer.prototype, "selectionService", 2);
|
|
2634
|
+
__decorateClass([
|
|
2635
|
+
core.observeEntity(SelectorBoxConfigEntity)
|
|
2636
|
+
], exports.FlowSelectorBoxLayer.prototype, "selectorBoxConfigEntity", 2);
|
|
2637
|
+
__decorateClass([
|
|
2638
|
+
core.observeEntity(FlowSelectConfigEntity)
|
|
2639
|
+
], exports.FlowSelectorBoxLayer.prototype, "selectConfigEntity", 2);
|
|
2640
|
+
__decorateClass([
|
|
2641
|
+
core.observeEntity(core.EditorStateConfigEntity)
|
|
2642
|
+
], exports.FlowSelectorBoxLayer.prototype, "editorStateConfig", 2);
|
|
2643
|
+
exports.FlowSelectorBoxLayer = __decorateClass([
|
|
2644
|
+
inversify.injectable()
|
|
2645
|
+
], exports.FlowSelectorBoxLayer);
|
|
2646
|
+
exports.FlowSelectorBoundsLayer = class FlowSelectorBoundsLayer extends core.Layer {
|
|
2647
|
+
constructor() {
|
|
2648
|
+
super(...arguments);
|
|
2649
|
+
this.node = utils.domUtils.createDivWithClass("gedit-selector-bounds-layer");
|
|
2650
|
+
this.selectBoundsBackground = utils.domUtils.createDivWithClass("gedit-selector-bounds-background");
|
|
2651
|
+
}
|
|
2652
|
+
onReady() {
|
|
2653
|
+
this.node.style.zIndex = "20";
|
|
2654
|
+
const { firstChild } = this.pipelineNode;
|
|
2655
|
+
if (this.options.boundsPadding !== void 0) {
|
|
2656
|
+
this.flowSelectConfigEntity.boundsPadding = this.options.boundsPadding;
|
|
2657
|
+
}
|
|
2658
|
+
if (this.options.backgroundClassName) {
|
|
2659
|
+
this.selectBoundsBackground.classList.add(this.options.backgroundClassName);
|
|
2660
|
+
}
|
|
2661
|
+
const selectorBoundsLayer = utils.domUtils.createDivWithClass(
|
|
2662
|
+
"gedit-selector-bounds-background-layer gedit-playground-layer"
|
|
2663
|
+
);
|
|
2664
|
+
selectorBoundsLayer.appendChild(this.selectBoundsBackground);
|
|
2665
|
+
this.pipelineNode.insertBefore(selectorBoundsLayer, firstChild);
|
|
2666
|
+
}
|
|
2667
|
+
onZoom(scale) {
|
|
2668
|
+
this.node.style.transform = `scale(${scale})`;
|
|
2669
|
+
this.selectBoundsBackground.parentElement.style.transform = `scale(${scale})`;
|
|
2670
|
+
}
|
|
2671
|
+
onViewportChange() {
|
|
2672
|
+
this.render();
|
|
2673
|
+
}
|
|
2674
|
+
isEnabled() {
|
|
2675
|
+
const currentState = this.editorStateConfig.getCurrentState();
|
|
2676
|
+
return currentState === core.EditorState.STATE_SELECT;
|
|
2677
|
+
}
|
|
2678
|
+
render() {
|
|
2679
|
+
const {
|
|
2680
|
+
ignoreOneSelect,
|
|
2681
|
+
ignoreChildrenLength,
|
|
2682
|
+
SelectorBoxPopover: SelectorBoxPopoverFromOpts,
|
|
2683
|
+
disableBackground,
|
|
2684
|
+
CustomBoundsRenderer
|
|
2685
|
+
} = this.options;
|
|
2686
|
+
const bounds = this.flowSelectConfigEntity.getSelectedBounds();
|
|
2687
|
+
const selectedNodes = this.flowSelectConfigEntity.selectedNodes;
|
|
2688
|
+
const bg = this.selectBoundsBackground;
|
|
2689
|
+
const isDragging = !this.selectorBoxConfigEntity.isStart;
|
|
2690
|
+
if (bounds.width === 0 || bounds.height === 0 || ignoreOneSelect && selectedNodes.length === 1 && (ignoreChildrenLength || selectedNodes[0].childrenLength <= 1)) {
|
|
2691
|
+
utils.domUtils.setStyle(bg, {
|
|
2692
|
+
display: "none"
|
|
2693
|
+
});
|
|
2694
|
+
return null;
|
|
2695
|
+
}
|
|
2696
|
+
if (CustomBoundsRenderer) {
|
|
2697
|
+
return wrapLayerRender(
|
|
2698
|
+
this.playgroundContainer,
|
|
2699
|
+
vue.h(CustomBoundsRenderer, {
|
|
2700
|
+
bounds,
|
|
2701
|
+
config: this.config,
|
|
2702
|
+
flowSelectConfig: this.flowSelectConfigEntity,
|
|
2703
|
+
commandRegistry: this.commandRegistry
|
|
2704
|
+
})
|
|
2705
|
+
);
|
|
2706
|
+
}
|
|
2707
|
+
const style = {
|
|
2708
|
+
display: "block",
|
|
2709
|
+
left: `${bounds.left}px`,
|
|
2710
|
+
top: `${bounds.top}px`,
|
|
2711
|
+
width: `${bounds.width}px`,
|
|
2712
|
+
height: `${bounds.height}px`
|
|
2713
|
+
};
|
|
2714
|
+
if (!disableBackground) {
|
|
2715
|
+
utils.domUtils.setStyle(bg, {
|
|
2716
|
+
display: "block",
|
|
2717
|
+
left: bounds.left,
|
|
2718
|
+
top: bounds.top,
|
|
2719
|
+
width: bounds.width,
|
|
2720
|
+
height: bounds.height
|
|
2721
|
+
});
|
|
2722
|
+
}
|
|
2723
|
+
let foregroundClassName = "gedit-selector-bounds-foreground";
|
|
2724
|
+
if (this.options.foregroundClassName) {
|
|
2725
|
+
foregroundClassName += ` ${this.options.foregroundClassName}`;
|
|
2726
|
+
}
|
|
2727
|
+
const SelectorBoxPopover = SelectorBoxPopoverFromOpts || this.rendererRegistry.tryToGetRendererComponent("selector-box-popover" /* SELECTOR_BOX_POPOVER */)?.renderer;
|
|
2728
|
+
if (!isDragging || !SelectorBoxPopover) {
|
|
2729
|
+
return wrapLayerRender(
|
|
2730
|
+
this.playgroundContainer,
|
|
2731
|
+
vue.h("div", { class: foregroundClassName, style })
|
|
2732
|
+
);
|
|
2733
|
+
}
|
|
2734
|
+
return wrapLayerRender(
|
|
2735
|
+
this.playgroundContainer,
|
|
2736
|
+
vue.h(
|
|
2737
|
+
SelectorBoxPopover,
|
|
2738
|
+
{
|
|
2739
|
+
bounds,
|
|
2740
|
+
config: this.config,
|
|
2741
|
+
flowSelectConfig: this.flowSelectConfigEntity,
|
|
2742
|
+
commandRegistry: this.commandRegistry
|
|
2743
|
+
},
|
|
2744
|
+
() => vue.h("div", { class: foregroundClassName, style })
|
|
2745
|
+
)
|
|
2746
|
+
);
|
|
2747
|
+
}
|
|
2748
|
+
};
|
|
2749
|
+
__decorateClass([
|
|
2750
|
+
inversify.inject(exports.FlowRendererRegistry)
|
|
2751
|
+
], exports.FlowSelectorBoundsLayer.prototype, "rendererRegistry", 2);
|
|
2752
|
+
__decorateClass([
|
|
2753
|
+
inversify.inject(core.CommandRegistry)
|
|
2754
|
+
], exports.FlowSelectorBoundsLayer.prototype, "commandRegistry", 2);
|
|
2755
|
+
__decorateClass([
|
|
2756
|
+
inversify.inject(core.PlaygroundContainerFactory)
|
|
2757
|
+
], exports.FlowSelectorBoundsLayer.prototype, "playgroundContainer", 2);
|
|
2758
|
+
__decorateClass([
|
|
2759
|
+
core.observeEntity(FlowSelectConfigEntity)
|
|
2760
|
+
], exports.FlowSelectorBoundsLayer.prototype, "flowSelectConfigEntity", 2);
|
|
2761
|
+
__decorateClass([
|
|
2762
|
+
core.observeEntity(core.EditorStateConfigEntity)
|
|
2763
|
+
], exports.FlowSelectorBoundsLayer.prototype, "editorStateConfig", 2);
|
|
2764
|
+
__decorateClass([
|
|
2765
|
+
core.observeEntity(SelectorBoxConfigEntity)
|
|
2766
|
+
], exports.FlowSelectorBoundsLayer.prototype, "selectorBoxConfigEntity", 2);
|
|
2767
|
+
__decorateClass([
|
|
2768
|
+
core.observeEntityDatas(document$1.FlowNodeEntity, document$1.FlowNodeRenderData)
|
|
2769
|
+
], exports.FlowSelectorBoundsLayer.prototype, "renderStates", 2);
|
|
2770
|
+
__decorateClass([
|
|
2771
|
+
core.observeEntityDatas(document$1.FlowNodeEntity, document$1.FlowNodeTransformData)
|
|
2772
|
+
], exports.FlowSelectorBoundsLayer.prototype, "_transforms", 2);
|
|
2773
|
+
exports.FlowSelectorBoundsLayer = __decorateClass([
|
|
2774
|
+
inversify.injectable()
|
|
2775
|
+
], exports.FlowSelectorBoundsLayer);
|
|
2776
|
+
exports.FlowContextMenuLayer = class FlowContextMenuLayer extends core.Layer {
|
|
2777
|
+
constructor() {
|
|
2778
|
+
super(...arguments);
|
|
2779
|
+
this.node = utils.domUtils.createDivWithClass("gedit-context-menu-layer");
|
|
2780
|
+
this.nodeRef = { current: null };
|
|
2781
|
+
}
|
|
2782
|
+
isEnabled() {
|
|
2783
|
+
const currentState = this.editorStateConfig.getCurrentState();
|
|
2784
|
+
return !this.config.disabled && !this.config.readonly && currentState === core.EditorState.STATE_SELECT && !this.selectorBoxConfigEntity.disabled;
|
|
2785
|
+
}
|
|
2786
|
+
onReady() {
|
|
2787
|
+
this.node.style.zIndex = "30";
|
|
2788
|
+
this.node.style.display = "block";
|
|
2789
|
+
this.toDispose.pushAll([
|
|
2790
|
+
this.listenPlaygroundEvent(
|
|
2791
|
+
"contextmenu",
|
|
2792
|
+
(e) => {
|
|
2793
|
+
if (!this.isEnabled()) return;
|
|
2794
|
+
this.contextMenuService.rightPanelVisible = true;
|
|
2795
|
+
const bounds = this.flowSelectConfigEntity.getSelectedBounds();
|
|
2796
|
+
if (bounds.width === 0 || bounds.height === 0) {
|
|
2797
|
+
return;
|
|
2798
|
+
}
|
|
2799
|
+
e.stopPropagation();
|
|
2800
|
+
e.preventDefault();
|
|
2801
|
+
this.nodeRef.current?.setVisible(true);
|
|
2802
|
+
const clientBounds = this.playgroundConfigEntity.getClientBounds();
|
|
2803
|
+
const dragBlockX = e.clientX - (this.pipelineNode.offsetLeft || 0) - clientBounds.x;
|
|
2804
|
+
const dragBlockY = e.clientY - (this.pipelineNode.offsetTop || 0) - clientBounds.y;
|
|
2805
|
+
this.node.style.left = `${dragBlockX}px`;
|
|
2806
|
+
this.node.style.top = `${dragBlockY}px`;
|
|
2807
|
+
},
|
|
2808
|
+
core.PipelineLayerPriority.BASE_LAYER
|
|
2809
|
+
),
|
|
2810
|
+
this.listenPlaygroundEvent("mousedown", () => {
|
|
2811
|
+
this.nodeRef.current?.setVisible(false);
|
|
2812
|
+
this.contextMenuService.rightPanelVisible = false;
|
|
2813
|
+
})
|
|
2814
|
+
]);
|
|
2815
|
+
}
|
|
2816
|
+
onScroll() {
|
|
2817
|
+
this.nodeRef.current?.setVisible(false);
|
|
2818
|
+
}
|
|
2819
|
+
onZoom() {
|
|
2820
|
+
this.nodeRef.current?.setVisible(false);
|
|
2821
|
+
}
|
|
2822
|
+
/**
|
|
2823
|
+
* Destroy
|
|
2824
|
+
*/
|
|
2825
|
+
dispose() {
|
|
2826
|
+
super.dispose();
|
|
2827
|
+
}
|
|
2828
|
+
/**
|
|
2829
|
+
* 渲染工具栏
|
|
2830
|
+
*/
|
|
2831
|
+
renderCommandMenus() {
|
|
2832
|
+
return this.commandRegistry.commands.filter((cmd) => cmd.category === "SELECTOR_BOX" /* SELECTOR_BOX */).map((cmd) => {
|
|
2833
|
+
const CommandRenderer = this.rendererRegistry.getRendererComponent(
|
|
2834
|
+
cmd.icon || cmd.id
|
|
2835
|
+
)?.renderer;
|
|
2836
|
+
return vue.h(CommandRenderer, {
|
|
2837
|
+
key: cmd.id,
|
|
2838
|
+
command: cmd,
|
|
2839
|
+
isContextMenu: true,
|
|
2840
|
+
disabled: !this.commandRegistry.isEnabled(cmd.id),
|
|
2841
|
+
onClick: (e) => this.commandRegistry.executeCommand(cmd.id, e)
|
|
2842
|
+
});
|
|
2843
|
+
}).filter((c) => c);
|
|
2844
|
+
}
|
|
2845
|
+
render() {
|
|
2846
|
+
const SelectorBoxPopover = this.rendererRegistry.getRendererComponent(
|
|
2847
|
+
"context-menu-popover" /* CONTEXT_MENU_POPOVER */
|
|
2848
|
+
).renderer;
|
|
2849
|
+
return wrapLayerRender(
|
|
2850
|
+
this.playgroundContainer,
|
|
2851
|
+
vue.h(SelectorBoxPopover, {
|
|
2852
|
+
ref: (inst) => {
|
|
2853
|
+
this.nodeRef.current = inst;
|
|
2854
|
+
},
|
|
2855
|
+
content: this.renderCommandMenus()
|
|
2856
|
+
})
|
|
2857
|
+
);
|
|
2858
|
+
}
|
|
2859
|
+
};
|
|
2860
|
+
__decorateClass([
|
|
2861
|
+
inversify.inject(core.CommandRegistry)
|
|
2862
|
+
], exports.FlowContextMenuLayer.prototype, "commandRegistry", 2);
|
|
2863
|
+
__decorateClass([
|
|
2864
|
+
inversify.inject(exports.FlowRendererRegistry)
|
|
2865
|
+
], exports.FlowContextMenuLayer.prototype, "rendererRegistry", 2);
|
|
2866
|
+
__decorateClass([
|
|
2867
|
+
inversify.inject(core.ContextMenuService)
|
|
2868
|
+
], exports.FlowContextMenuLayer.prototype, "contextMenuService", 2);
|
|
2869
|
+
__decorateClass([
|
|
2870
|
+
inversify.inject(core.PlaygroundContainerFactory)
|
|
2871
|
+
], exports.FlowContextMenuLayer.prototype, "playgroundContainer", 2);
|
|
2872
|
+
__decorateClass([
|
|
2873
|
+
core.observeEntity(FlowSelectConfigEntity)
|
|
2874
|
+
], exports.FlowContextMenuLayer.prototype, "flowSelectConfigEntity", 2);
|
|
2875
|
+
__decorateClass([
|
|
2876
|
+
inversify.inject(core.SelectionService)
|
|
2877
|
+
], exports.FlowContextMenuLayer.prototype, "selectionService", 2);
|
|
2878
|
+
__decorateClass([
|
|
2879
|
+
core.observeEntity(core.PlaygroundConfigEntity)
|
|
2880
|
+
], exports.FlowContextMenuLayer.prototype, "playgroundConfigEntity", 2);
|
|
2881
|
+
__decorateClass([
|
|
2882
|
+
core.observeEntity(core.EditorStateConfigEntity)
|
|
2883
|
+
], exports.FlowContextMenuLayer.prototype, "editorStateConfig", 2);
|
|
2884
|
+
__decorateClass([
|
|
2885
|
+
core.observeEntity(SelectorBoxConfigEntity)
|
|
2886
|
+
], exports.FlowContextMenuLayer.prototype, "selectorBoxConfigEntity", 2);
|
|
2887
|
+
exports.FlowContextMenuLayer = __decorateClass([
|
|
2888
|
+
inversify.injectable()
|
|
2889
|
+
], exports.FlowContextMenuLayer);
|
|
2890
|
+
exports.FlowScrollLimitLayer = class FlowScrollLimitLayer extends core.Layer {
|
|
2891
|
+
getInitScroll() {
|
|
2892
|
+
return this.document.layout.getInitScroll(this.pipelineNode.getBoundingClientRect());
|
|
2893
|
+
}
|
|
2894
|
+
onReady() {
|
|
2895
|
+
const initScroll = () => this.getInitScroll();
|
|
2896
|
+
this.config.updateConfig(initScroll());
|
|
2897
|
+
this.config.addScrollLimit(
|
|
2898
|
+
(scroll) => scrollLimit(
|
|
2899
|
+
scroll,
|
|
2900
|
+
[this.document.root.getData(document$1.FlowNodeTransformData).bounds],
|
|
2901
|
+
this.config,
|
|
2902
|
+
initScroll
|
|
2903
|
+
)
|
|
2904
|
+
);
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
__decorateClass([
|
|
2908
|
+
inversify.inject(document$1.FlowDocument)
|
|
2909
|
+
], exports.FlowScrollLimitLayer.prototype, "document", 2);
|
|
2910
|
+
exports.FlowScrollLimitLayer = __decorateClass([
|
|
2911
|
+
inversify.injectable()
|
|
2912
|
+
], exports.FlowScrollLimitLayer);
|
|
2913
|
+
var FlowRendererContainerModule = new inversify.ContainerModule((bind) => {
|
|
2914
|
+
bind(exports.FlowRendererRegistry).toSelf().inSingletonScope();
|
|
2915
|
+
bind(FlowRendererResizeObserver).toSelf().inSingletonScope();
|
|
2916
|
+
});
|
|
2917
|
+
|
|
2918
|
+
exports.FlowDragEntity = FlowDragEntity;
|
|
2919
|
+
exports.FlowRendererCommandCategory = FlowRendererCommandCategory;
|
|
2920
|
+
exports.FlowRendererComponentType = FlowRendererComponentType;
|
|
2921
|
+
exports.FlowRendererContainerModule = FlowRendererContainerModule;
|
|
2922
|
+
exports.FlowRendererContribution = FlowRendererContribution;
|
|
2923
|
+
exports.FlowRendererKey = FlowRendererKey;
|
|
2924
|
+
exports.FlowSelectConfigEntity = FlowSelectConfigEntity;
|
|
2925
|
+
exports.FlowTextKey = FlowTextKey;
|
|
2926
|
+
exports.MARK_ACTIVATED_ARROW_ID = MARK_ACTIVATED_ARROW_ID;
|
|
2927
|
+
exports.MARK_ARROW_ID = MARK_ARROW_ID;
|
|
2928
|
+
exports.ScrollBarEvents = ScrollBarEvents;
|
|
2929
|
+
exports.SelectorBoxConfigEntity = SelectorBoxConfigEntity;
|
|
2930
|
+
exports.createLines = createLines;
|
|
2931
|
+
exports.useBaseColor = useBaseColor;
|
|
2932
|
+
//# sourceMappingURL=index.cjs.map
|
|
2933
|
+
//# sourceMappingURL=index.cjs.map
|