@flowgram.ai/minimap-plugin 0.1.0-alpha.3 → 0.1.0-alpha.30
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/dist/esm/index.js +192 -159
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +40 -14
- package/dist/index.d.ts +40 -14
- package/dist/index.js +187 -163
- package/dist/index.js.map +1 -1
- package/package.json +15 -18
package/dist/index.js
CHANGED
|
@@ -36,8 +36,8 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
// src/index.ts
|
|
39
|
-
var
|
|
40
|
-
__export(
|
|
39
|
+
var index_exports = {};
|
|
40
|
+
__export(index_exports, {
|
|
41
41
|
FlowMinimapLayer: () => FlowMinimapLayer,
|
|
42
42
|
FlowMinimapService: () => FlowMinimapService,
|
|
43
43
|
MinimapDefaultCanvasStyle: () => MinimapDefaultCanvasStyle,
|
|
@@ -46,126 +46,14 @@ __export(src_exports, {
|
|
|
46
46
|
MinimapRender: () => MinimapRender,
|
|
47
47
|
createMinimapPlugin: () => createMinimapPlugin
|
|
48
48
|
});
|
|
49
|
-
module.exports = __toCommonJS(
|
|
49
|
+
module.exports = __toCommonJS(index_exports);
|
|
50
50
|
|
|
51
51
|
// src/component.tsx
|
|
52
52
|
var import_react = __toESM(require("react"));
|
|
53
|
-
|
|
54
|
-
// src/constant.ts
|
|
55
|
-
var MinimapDefaultCanvasStyle = {
|
|
56
|
-
canvasWidth: 250,
|
|
57
|
-
canvasHeight: 250,
|
|
58
|
-
canvasPadding: 50,
|
|
59
|
-
canvasBackground: "rgba(242, 243, 245, 1)",
|
|
60
|
-
canvasBorderRadius: 10,
|
|
61
|
-
viewportBackground: "rgba(255, 255, 255, 1)",
|
|
62
|
-
viewportBorderRadius: 4,
|
|
63
|
-
viewportBorderColor: "rgba(6, 7, 9, 0.10)",
|
|
64
|
-
viewportBorderWidth: 1,
|
|
65
|
-
viewportBorderDashLength: void 0,
|
|
66
|
-
nodeColor: "rgba(0, 0, 0, 0.10)",
|
|
67
|
-
nodeBorderRadius: 2,
|
|
68
|
-
nodeBorderWidth: 0.145,
|
|
69
|
-
nodeBorderColor: "rgba(6, 7, 9, 0.10)",
|
|
70
|
-
overlayColor: "rgba(255, 255, 255, 0.55)"
|
|
71
|
-
};
|
|
72
|
-
var MinimapDefaultInactiveStyle = {
|
|
73
|
-
scale: 0.7,
|
|
74
|
-
opacity: 1,
|
|
75
|
-
translateX: 15,
|
|
76
|
-
translateY: 15
|
|
77
|
-
};
|
|
78
|
-
var MinimapDefaultOptions = {
|
|
79
|
-
canvasStyle: MinimapDefaultCanvasStyle,
|
|
80
|
-
canvasClassName: "gedit-minimap-canvas",
|
|
81
|
-
enableActiveDebounce: false,
|
|
82
|
-
enableInactiveDebounce: true,
|
|
83
|
-
enableDisplayAllNodes: false,
|
|
84
|
-
activeDebounceTime: 0,
|
|
85
|
-
inactiveDebounceTime: 5
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// src/component.tsx
|
|
89
|
-
var MinimapRender = (props) => {
|
|
90
|
-
const {
|
|
91
|
-
service,
|
|
92
|
-
panelStyles = {},
|
|
93
|
-
containerStyles = {},
|
|
94
|
-
inactiveStyle: customInactiveStyle = {}
|
|
95
|
-
} = props;
|
|
96
|
-
const inactiveStyle = {
|
|
97
|
-
...MinimapDefaultInactiveStyle,
|
|
98
|
-
...customInactiveStyle
|
|
99
|
-
};
|
|
100
|
-
const panelRef = (0, import_react.useRef)(null);
|
|
101
|
-
const [activated, setActivated] = (0, import_react.useState)(false);
|
|
102
|
-
(0, import_react.useEffect)(() => {
|
|
103
|
-
const canvasContainer = panelRef.current;
|
|
104
|
-
if (canvasContainer && service.canvas) {
|
|
105
|
-
canvasContainer.appendChild(service.canvas);
|
|
106
|
-
}
|
|
107
|
-
const disposer = service.onActive((activate) => {
|
|
108
|
-
setActivated(activate);
|
|
109
|
-
});
|
|
110
|
-
return () => {
|
|
111
|
-
disposer.dispose();
|
|
112
|
-
};
|
|
113
|
-
}, []);
|
|
114
|
-
const scale = activated ? 1 : inactiveStyle.scale;
|
|
115
|
-
const opacity = activated ? 1 : inactiveStyle.opacity;
|
|
116
|
-
const translateX = activated ? 0 : inactiveStyle.translateX;
|
|
117
|
-
const translateY = activated ? 0 : inactiveStyle.translateY;
|
|
118
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
119
|
-
"div",
|
|
120
|
-
{
|
|
121
|
-
className: "minimap-container",
|
|
122
|
-
style: {
|
|
123
|
-
position: "fixed",
|
|
124
|
-
right: 30,
|
|
125
|
-
bottom: 70,
|
|
126
|
-
transition: "all 0.3s ease",
|
|
127
|
-
// 添加过渡效果
|
|
128
|
-
transform: `scale(${scale}) translate(${translateX}px, ${translateY}px)`,
|
|
129
|
-
opacity,
|
|
130
|
-
transformOrigin: "bottom right",
|
|
131
|
-
// 设置变换的原点
|
|
132
|
-
...containerStyles
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
136
|
-
"div",
|
|
137
|
-
{
|
|
138
|
-
className: "minimap-panel",
|
|
139
|
-
style: {
|
|
140
|
-
display: "flex",
|
|
141
|
-
width: "100%",
|
|
142
|
-
height: "100%",
|
|
143
|
-
borderRadius: "10px",
|
|
144
|
-
backgroundColor: "rgba(255, 255, 255, 1)",
|
|
145
|
-
border: "0.572px solid rgba(6, 7, 9, 0.10)",
|
|
146
|
-
overflow: "hidden",
|
|
147
|
-
boxShadow: "0px 2.289px 6.867px 0px rgba(0, 0, 0, 0.08), 0px 4.578px 13.733px 0px rgba(0, 0, 0, 0.04)",
|
|
148
|
-
padding: 8,
|
|
149
|
-
...panelStyles
|
|
150
|
-
},
|
|
151
|
-
"data-flow-editor-selectable": "false",
|
|
152
|
-
ref: panelRef,
|
|
153
|
-
onMouseEnter: () => {
|
|
154
|
-
service.setActivate(true);
|
|
155
|
-
},
|
|
156
|
-
onMouseLeave: () => {
|
|
157
|
-
service.setActivate(false);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
)
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// src/create-plugin.ts
|
|
165
|
-
var import_core3 = require("@flowgram.ai/core");
|
|
53
|
+
var import_core2 = require("@flowgram.ai/core");
|
|
166
54
|
|
|
167
55
|
// src/service.ts
|
|
168
|
-
var
|
|
56
|
+
var import_lodash_es = require("lodash-es");
|
|
169
57
|
var import_inversify = require("inversify");
|
|
170
58
|
var import_utils = require("@flowgram.ai/utils");
|
|
171
59
|
var import_document = require("@flowgram.ai/document");
|
|
@@ -176,6 +64,7 @@ var import_core = require("@flowgram.ai/core");
|
|
|
176
64
|
// src/draw.ts
|
|
177
65
|
var MinimapDraw;
|
|
178
66
|
((MinimapDraw2) => {
|
|
67
|
+
const isRectValid = (rect) => rect.width > 0 && rect.height > 0;
|
|
179
68
|
MinimapDraw2.clear = (params) => {
|
|
180
69
|
const { canvas, context } = params;
|
|
181
70
|
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
@@ -187,12 +76,18 @@ var MinimapDraw;
|
|
|
187
76
|
};
|
|
188
77
|
MinimapDraw2.rectangle = (params) => {
|
|
189
78
|
const { context, rect, color } = params;
|
|
79
|
+
if (!isRectValid(rect)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
190
82
|
context.fillStyle = color;
|
|
191
83
|
context.fillRect(rect.x, rect.y, rect.width, rect.height);
|
|
192
84
|
};
|
|
193
85
|
MinimapDraw2.roundRectangle = (params) => {
|
|
194
86
|
const { context, rect, color, radius, borderColor, borderDashLength, borderWidth = 0 } = params;
|
|
195
87
|
const { x, y, width, height } = rect;
|
|
88
|
+
if (!isRectValid(rect)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
196
91
|
context.beginPath();
|
|
197
92
|
const drawRoundedRectPath = () => {
|
|
198
93
|
context.moveTo(x + radius, y);
|
|
@@ -223,6 +118,9 @@ var MinimapDraw;
|
|
|
223
118
|
};
|
|
224
119
|
MinimapDraw2.overlay = (params) => {
|
|
225
120
|
const { canvas, context, offset, scale, rect, color } = params;
|
|
121
|
+
if (!isRectValid(rect)) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
226
124
|
context.fillStyle = color;
|
|
227
125
|
context.fillRect(0, 0, canvas.width, (rect.y + offset.y) * scale);
|
|
228
126
|
context.fillRect(
|
|
@@ -246,9 +144,42 @@ var MinimapDraw;
|
|
|
246
144
|
};
|
|
247
145
|
})(MinimapDraw || (MinimapDraw = {}));
|
|
248
146
|
|
|
147
|
+
// src/constant.ts
|
|
148
|
+
var MinimapDefaultCanvasStyle = {
|
|
149
|
+
canvasWidth: 250,
|
|
150
|
+
canvasHeight: 250,
|
|
151
|
+
canvasPadding: 50,
|
|
152
|
+
canvasBackground: "rgba(242, 243, 245, 1)",
|
|
153
|
+
canvasBorderRadius: 10,
|
|
154
|
+
viewportBackground: "rgba(255, 255, 255, 1)",
|
|
155
|
+
viewportBorderRadius: 4,
|
|
156
|
+
viewportBorderColor: "rgba(6, 7, 9, 0.10)",
|
|
157
|
+
viewportBorderWidth: 1,
|
|
158
|
+
viewportBorderDashLength: void 0,
|
|
159
|
+
nodeColor: "rgba(0, 0, 0, 0.10)",
|
|
160
|
+
nodeBorderRadius: 2,
|
|
161
|
+
nodeBorderWidth: 0.145,
|
|
162
|
+
nodeBorderColor: "rgba(6, 7, 9, 0.10)",
|
|
163
|
+
overlayColor: "rgba(255, 255, 255, 0.55)"
|
|
164
|
+
};
|
|
165
|
+
var MinimapDefaultInactiveStyle = {
|
|
166
|
+
scale: 0.7,
|
|
167
|
+
opacity: 1,
|
|
168
|
+
translateX: 15,
|
|
169
|
+
translateY: 15
|
|
170
|
+
};
|
|
171
|
+
var MinimapDefaultOptions = {
|
|
172
|
+
canvasStyle: MinimapDefaultCanvasStyle,
|
|
173
|
+
canvasClassName: "gedit-minimap-canvas",
|
|
174
|
+
enableDisplayAllNodes: false,
|
|
175
|
+
activeThrottleTime: 0,
|
|
176
|
+
inactiveThrottleTime: 24
|
|
177
|
+
};
|
|
178
|
+
|
|
249
179
|
// src/service.ts
|
|
250
180
|
var FlowMinimapService = class {
|
|
251
181
|
constructor() {
|
|
182
|
+
this.visible = false;
|
|
252
183
|
this.onActive = (callback) => {
|
|
253
184
|
this.onActiveCallbacks.add(callback);
|
|
254
185
|
return {
|
|
@@ -264,14 +195,15 @@ var FlowMinimapService = class {
|
|
|
264
195
|
this.handleWheel = (event) => {
|
|
265
196
|
};
|
|
266
197
|
this.handleStartDrag = (event) => {
|
|
267
|
-
|
|
198
|
+
import_core.MouseTouchEvent.preventDefault(event);
|
|
268
199
|
event.stopPropagation();
|
|
269
200
|
const renderContext = this.createRenderContext();
|
|
270
201
|
const { viewRect, scale, offset } = renderContext;
|
|
271
202
|
const canvasRect = this.canvas.getBoundingClientRect();
|
|
203
|
+
const { clientX, clientY } = import_core.MouseTouchEvent.getEventCoord(event);
|
|
272
204
|
const mousePoint = {
|
|
273
|
-
x:
|
|
274
|
-
y:
|
|
205
|
+
x: clientX - canvasRect.left,
|
|
206
|
+
y: clientY - canvasRect.top
|
|
275
207
|
};
|
|
276
208
|
const viewRectOnCanvas = this.rectOnCanvas({
|
|
277
209
|
rect: viewRect,
|
|
@@ -285,16 +217,20 @@ var FlowMinimapService = class {
|
|
|
285
217
|
this.dragStart = mousePoint;
|
|
286
218
|
document.addEventListener("mousemove", this.handleDragging);
|
|
287
219
|
document.addEventListener("mouseup", this.handleEndDrag);
|
|
220
|
+
document.addEventListener("touchmove", this.handleDragging, { passive: false });
|
|
221
|
+
document.addEventListener("touchend", this.handleEndDrag);
|
|
222
|
+
document.addEventListener("touchcancel", this.handleEndDrag);
|
|
288
223
|
};
|
|
289
224
|
this.handleDragging = (event) => {
|
|
290
225
|
if (!this.isDragging || !this.dragStart) return;
|
|
291
|
-
|
|
226
|
+
import_core.MouseTouchEvent.preventDefault(event);
|
|
292
227
|
event.stopPropagation();
|
|
293
228
|
const renderContext = this.createRenderContext();
|
|
294
229
|
const { scale } = renderContext;
|
|
295
230
|
const canvasRect = this.canvas.getBoundingClientRect();
|
|
296
|
-
const
|
|
297
|
-
const
|
|
231
|
+
const { clientX, clientY } = import_core.MouseTouchEvent.getEventCoord(event);
|
|
232
|
+
const mouseX = clientX - canvasRect.left;
|
|
233
|
+
const mouseY = clientY - canvasRect.top;
|
|
298
234
|
const deltaX = (mouseX - this.dragStart.x) / scale;
|
|
299
235
|
const deltaY = (mouseY - this.dragStart.y) / scale;
|
|
300
236
|
this.updateScrollPosition(deltaX, deltaY);
|
|
@@ -302,10 +238,13 @@ var FlowMinimapService = class {
|
|
|
302
238
|
this.render();
|
|
303
239
|
};
|
|
304
240
|
this.handleEndDrag = (event) => {
|
|
305
|
-
|
|
241
|
+
import_core.MouseTouchEvent.preventDefault(event);
|
|
306
242
|
event.stopPropagation();
|
|
307
243
|
document.removeEventListener("mousemove", this.handleDragging);
|
|
308
244
|
document.removeEventListener("mouseup", this.handleEndDrag);
|
|
245
|
+
document.removeEventListener("touchmove", this.handleDragging);
|
|
246
|
+
document.removeEventListener("touchend", this.handleEndDrag);
|
|
247
|
+
document.removeEventListener("touchcancel", this.handleEndDrag);
|
|
309
248
|
this.isDragging = false;
|
|
310
249
|
this.dragStart = void 0;
|
|
311
250
|
this.setActivate(this.isMouseInCanvas(event));
|
|
@@ -342,12 +281,8 @@ var FlowMinimapService = class {
|
|
|
342
281
|
init(options) {
|
|
343
282
|
this.options = MinimapDefaultOptions;
|
|
344
283
|
Object.assign(this.options, options);
|
|
345
|
-
this.
|
|
346
|
-
enableDebounce: this.options.enableInactiveDebounce,
|
|
347
|
-
debounceTime: this.options.inactiveDebounceTime
|
|
348
|
-
});
|
|
284
|
+
this.setThrottle(this.options.inactiveThrottleTime);
|
|
349
285
|
this.initStyle();
|
|
350
|
-
this.mountListener();
|
|
351
286
|
}
|
|
352
287
|
dispose() {
|
|
353
288
|
this.toDispose.dispose();
|
|
@@ -355,6 +290,9 @@ var FlowMinimapService = class {
|
|
|
355
290
|
this.activated = false;
|
|
356
291
|
this.removeEventListeners();
|
|
357
292
|
}
|
|
293
|
+
setVisible(visible) {
|
|
294
|
+
this.visible = visible;
|
|
295
|
+
}
|
|
358
296
|
setActivate(activate) {
|
|
359
297
|
if (activate === this.activated) {
|
|
360
298
|
return;
|
|
@@ -364,16 +302,10 @@ var FlowMinimapService = class {
|
|
|
364
302
|
}
|
|
365
303
|
this.activated = activate;
|
|
366
304
|
if (activate) {
|
|
367
|
-
this.
|
|
368
|
-
enableDebounce: this.options.enableActiveDebounce,
|
|
369
|
-
debounceTime: this.options.activeDebounceTime
|
|
370
|
-
});
|
|
305
|
+
this.setThrottle(this.options.activeThrottleTime);
|
|
371
306
|
this.addEventListeners();
|
|
372
307
|
} else {
|
|
373
|
-
this.
|
|
374
|
-
enableDebounce: this.options.enableInactiveDebounce,
|
|
375
|
-
debounceTime: this.options.inactiveDebounceTime
|
|
376
|
-
});
|
|
308
|
+
this.setThrottle(this.options.inactiveThrottleTime);
|
|
377
309
|
this.removeEventListeners();
|
|
378
310
|
}
|
|
379
311
|
this.render();
|
|
@@ -393,24 +325,19 @@ var FlowMinimapService = class {
|
|
|
393
325
|
this.canvas.height = this.style.canvasHeight;
|
|
394
326
|
this.canvas.style.borderRadius = this.style.canvasBorderRadius ? `${this.style.canvasBorderRadius}px` : "unset";
|
|
395
327
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (enableDebounce) {
|
|
399
|
-
this.render = (0, import_lodash.debounce)(this._render, debounceTime);
|
|
400
|
-
} else {
|
|
401
|
-
this.render = this._render;
|
|
402
|
-
}
|
|
328
|
+
setThrottle(throttleTime) {
|
|
329
|
+
this.render = (0, import_lodash_es.throttle)(this._render, throttleTime);
|
|
403
330
|
}
|
|
404
331
|
_render() {
|
|
405
|
-
if (!this.initialized) {
|
|
332
|
+
if (!this.initialized || !this.visible) {
|
|
406
333
|
return;
|
|
407
334
|
}
|
|
408
335
|
const renderContext = this.createRenderContext();
|
|
409
336
|
this.renderCanvas(renderContext);
|
|
410
337
|
}
|
|
411
338
|
createRenderContext() {
|
|
412
|
-
const { canvas, context2D
|
|
413
|
-
const nodeTransforms = this.
|
|
339
|
+
const { canvas, context2D } = this;
|
|
340
|
+
const nodeTransforms = this.transformVisibles;
|
|
414
341
|
const nodeRects = nodeTransforms.map((transform) => transform.bounds);
|
|
415
342
|
const viewRect = this.viewRect();
|
|
416
343
|
const renderRect = this.renderRect(nodeRects).withPadding({
|
|
@@ -490,8 +417,13 @@ var FlowMinimapService = class {
|
|
|
490
417
|
};
|
|
491
418
|
return { scale, offset };
|
|
492
419
|
}
|
|
493
|
-
get
|
|
494
|
-
|
|
420
|
+
get transformVisibles() {
|
|
421
|
+
const transformVisible = this.document.getRenderDatas(
|
|
422
|
+
import_document.FlowNodeTransformData,
|
|
423
|
+
false
|
|
424
|
+
);
|
|
425
|
+
return transformVisible.filter((transform) => {
|
|
426
|
+
const node = transform.entity;
|
|
495
427
|
if (node.hidden) return false;
|
|
496
428
|
if (node.flowNodeType === import_document2.FlowNodeBaseType.ROOT) return;
|
|
497
429
|
if (!this.options.enableDisplayAllNodes && node.parent && node.parent.flowNodeType !== import_document2.FlowNodeBaseType.ROOT)
|
|
@@ -499,9 +431,6 @@ var FlowMinimapService = class {
|
|
|
499
431
|
return true;
|
|
500
432
|
});
|
|
501
433
|
}
|
|
502
|
-
nodeTransforms(nodes) {
|
|
503
|
-
return nodes.map((node) => node.getData(import_document.FlowNodeTransformData)).filter(Boolean);
|
|
504
|
-
}
|
|
505
434
|
renderRect(rects) {
|
|
506
435
|
return import_utils.Rectangle.enlarge(rects);
|
|
507
436
|
}
|
|
@@ -509,10 +438,6 @@ var FlowMinimapService = class {
|
|
|
509
438
|
const { width, height, scrollX, scrollY, zoom } = this.playgroundConfig.config;
|
|
510
439
|
return new import_utils.Rectangle(scrollX / zoom, scrollY / zoom, width / zoom, height / zoom);
|
|
511
440
|
}
|
|
512
|
-
mountListener() {
|
|
513
|
-
const entityManagerDisposer = this.entityManager.onEntityChange(() => this.render());
|
|
514
|
-
this.toDispose.push(entityManagerDisposer);
|
|
515
|
-
}
|
|
516
441
|
/** 计算画布坐标系下的矩形 */
|
|
517
442
|
rectOnCanvas(params) {
|
|
518
443
|
const { rect, scale, offset } = params;
|
|
@@ -530,16 +455,19 @@ var FlowMinimapService = class {
|
|
|
530
455
|
addEventListeners() {
|
|
531
456
|
this.canvas.addEventListener("wheel", this.handleWheel);
|
|
532
457
|
this.canvas.addEventListener("mousedown", this.handleStartDrag);
|
|
458
|
+
this.canvas.addEventListener("touchstart", this.handleStartDrag, { passive: false });
|
|
533
459
|
this.canvas.addEventListener("mousemove", this.handleCursor);
|
|
534
460
|
}
|
|
535
461
|
removeEventListeners() {
|
|
536
462
|
this.canvas.removeEventListener("wheel", this.handleWheel);
|
|
537
463
|
this.canvas.removeEventListener("mousedown", this.handleStartDrag);
|
|
464
|
+
this.canvas.removeEventListener("touchstart", this.handleStartDrag);
|
|
538
465
|
this.canvas.removeEventListener("mousemove", this.handleCursor);
|
|
539
466
|
}
|
|
540
467
|
isMouseInCanvas(event) {
|
|
541
468
|
const canvasRect = this.canvas.getBoundingClientRect();
|
|
542
|
-
|
|
469
|
+
const { clientX, clientY } = import_core.MouseTouchEvent.getEventCoord(event);
|
|
470
|
+
return clientX >= canvasRect.left && clientX <= canvasRect.right && clientY >= canvasRect.top && clientY <= canvasRect.bottom;
|
|
543
471
|
}
|
|
544
472
|
updateScrollPosition(deltaX, deltaY) {
|
|
545
473
|
const { scrollX, scrollY, zoom } = this.playgroundConfig.config;
|
|
@@ -552,9 +480,6 @@ var FlowMinimapService = class {
|
|
|
552
480
|
__decorateClass([
|
|
553
481
|
(0, import_inversify.inject)(import_document3.FlowDocument)
|
|
554
482
|
], FlowMinimapService.prototype, "document", 2);
|
|
555
|
-
__decorateClass([
|
|
556
|
-
(0, import_inversify.inject)(import_core.EntityManager)
|
|
557
|
-
], FlowMinimapService.prototype, "entityManager", 2);
|
|
558
483
|
__decorateClass([
|
|
559
484
|
(0, import_inversify.inject)(import_core.PlaygroundConfigEntity)
|
|
560
485
|
], FlowMinimapService.prototype, "playgroundConfig", 2);
|
|
@@ -562,12 +487,99 @@ FlowMinimapService = __decorateClass([
|
|
|
562
487
|
(0, import_inversify.injectable)()
|
|
563
488
|
], FlowMinimapService);
|
|
564
489
|
|
|
490
|
+
// src/component.tsx
|
|
491
|
+
var MinimapRender = (props) => {
|
|
492
|
+
const { panelStyles = {}, containerStyles = {}, inactiveStyle: customInactiveStyle = {} } = props;
|
|
493
|
+
const inactiveStyle = {
|
|
494
|
+
...MinimapDefaultInactiveStyle,
|
|
495
|
+
...customInactiveStyle
|
|
496
|
+
};
|
|
497
|
+
const playgroundContainer = (0, import_core2.usePlaygroundContainer)();
|
|
498
|
+
const service = props.service || playgroundContainer?.get(FlowMinimapService);
|
|
499
|
+
const panelRef = (0, import_react.useRef)(null);
|
|
500
|
+
const [activated, setActivated] = (0, import_react.useState)(false);
|
|
501
|
+
(0, import_react.useEffect)(() => {
|
|
502
|
+
const canvasContainer = panelRef.current;
|
|
503
|
+
if (canvasContainer && service.canvas) {
|
|
504
|
+
canvasContainer.appendChild(service.canvas);
|
|
505
|
+
}
|
|
506
|
+
const disposer = service.onActive((activate) => {
|
|
507
|
+
setActivated(activate);
|
|
508
|
+
});
|
|
509
|
+
service.setVisible(true);
|
|
510
|
+
service.render();
|
|
511
|
+
return () => {
|
|
512
|
+
disposer.dispose();
|
|
513
|
+
service.setVisible(false);
|
|
514
|
+
};
|
|
515
|
+
}, [service]);
|
|
516
|
+
const scale = activated ? 1 : inactiveStyle.scale;
|
|
517
|
+
const opacity = activated ? 1 : inactiveStyle.opacity;
|
|
518
|
+
const translateX = activated ? 0 : inactiveStyle.translateX;
|
|
519
|
+
const translateY = activated ? 0 : inactiveStyle.translateY;
|
|
520
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
521
|
+
"div",
|
|
522
|
+
{
|
|
523
|
+
className: "minimap-container",
|
|
524
|
+
style: {
|
|
525
|
+
position: "fixed",
|
|
526
|
+
right: 30,
|
|
527
|
+
bottom: 70,
|
|
528
|
+
transition: "all 0.3s ease",
|
|
529
|
+
// 添加过渡效果
|
|
530
|
+
transform: `scale(${scale}) translate(${translateX}px, ${translateY}px)`,
|
|
531
|
+
opacity,
|
|
532
|
+
transformOrigin: "bottom right",
|
|
533
|
+
// 设置变换的原点
|
|
534
|
+
...containerStyles
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
538
|
+
"div",
|
|
539
|
+
{
|
|
540
|
+
className: "minimap-panel",
|
|
541
|
+
style: {
|
|
542
|
+
display: "flex",
|
|
543
|
+
width: "100%",
|
|
544
|
+
height: "100%",
|
|
545
|
+
borderRadius: "10px",
|
|
546
|
+
backgroundColor: "rgba(255, 255, 255, 1)",
|
|
547
|
+
border: "0.572px solid rgba(6, 7, 9, 0.10)",
|
|
548
|
+
overflow: "hidden",
|
|
549
|
+
boxShadow: "0px 2.289px 6.867px 0px rgba(0, 0, 0, 0.08), 0px 4.578px 13.733px 0px rgba(0, 0, 0, 0.04)",
|
|
550
|
+
boxSizing: "border-box",
|
|
551
|
+
padding: 8,
|
|
552
|
+
...panelStyles
|
|
553
|
+
},
|
|
554
|
+
"data-flow-editor-selectable": "false",
|
|
555
|
+
ref: panelRef,
|
|
556
|
+
onMouseEnter: () => {
|
|
557
|
+
service.setActivate(true);
|
|
558
|
+
},
|
|
559
|
+
onMouseLeave: () => {
|
|
560
|
+
service.setActivate(false);
|
|
561
|
+
},
|
|
562
|
+
onTouchStartCapture: () => {
|
|
563
|
+
service.setActivate(true);
|
|
564
|
+
},
|
|
565
|
+
onTouchEndCapture: () => {
|
|
566
|
+
service.setActivate(false);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
)
|
|
570
|
+
);
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
// src/create-plugin.ts
|
|
574
|
+
var import_core4 = require("@flowgram.ai/core");
|
|
575
|
+
|
|
565
576
|
// src/layer.tsx
|
|
566
577
|
var import_react2 = __toESM(require("react"));
|
|
567
578
|
var import_inversify2 = require("inversify");
|
|
568
|
-
var import_core2 = require("@flowgram.ai/core");
|
|
569
579
|
var import_utils2 = require("@flowgram.ai/utils");
|
|
570
|
-
var
|
|
580
|
+
var import_document4 = require("@flowgram.ai/document");
|
|
581
|
+
var import_core3 = require("@flowgram.ai/core");
|
|
582
|
+
var FlowMinimapLayer = class extends import_core3.Layer {
|
|
571
583
|
constructor() {
|
|
572
584
|
super();
|
|
573
585
|
this.className = "gedit-minimap-layer gedit-playground-layer";
|
|
@@ -575,6 +587,9 @@ var FlowMinimapLayer = class extends import_core2.Layer {
|
|
|
575
587
|
this.node.style.zIndex = "9999";
|
|
576
588
|
}
|
|
577
589
|
render() {
|
|
590
|
+
if (this.documentTransformer.loading) return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null);
|
|
591
|
+
this.documentTransformer.refresh();
|
|
592
|
+
this.service.render();
|
|
578
593
|
if (this.options.disableLayer) {
|
|
579
594
|
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null);
|
|
580
595
|
}
|
|
@@ -593,12 +608,21 @@ FlowMinimapLayer.type = "FlowMinimapLayer";
|
|
|
593
608
|
__decorateClass([
|
|
594
609
|
(0, import_inversify2.inject)(FlowMinimapService)
|
|
595
610
|
], FlowMinimapLayer.prototype, "service", 2);
|
|
611
|
+
__decorateClass([
|
|
612
|
+
(0, import_core3.observeEntityDatas)(import_document4.FlowNodeEntity, import_document4.FlowNodeTransformData)
|
|
613
|
+
], FlowMinimapLayer.prototype, "transformDatas", 2);
|
|
614
|
+
__decorateClass([
|
|
615
|
+
(0, import_core3.observeEntity)(import_core3.PlaygroundConfigEntity)
|
|
616
|
+
], FlowMinimapLayer.prototype, "configEntity", 2);
|
|
617
|
+
__decorateClass([
|
|
618
|
+
(0, import_core3.observeEntity)(import_document4.FlowDocumentTransformerEntity)
|
|
619
|
+
], FlowMinimapLayer.prototype, "documentTransformer", 2);
|
|
596
620
|
FlowMinimapLayer = __decorateClass([
|
|
597
621
|
(0, import_inversify2.injectable)()
|
|
598
622
|
], FlowMinimapLayer);
|
|
599
623
|
|
|
600
624
|
// src/create-plugin.ts
|
|
601
|
-
var createMinimapPlugin = (0,
|
|
625
|
+
var createMinimapPlugin = (0, import_core4.definePluginCreator)({
|
|
602
626
|
onBind: ({ bind }) => {
|
|
603
627
|
bind(FlowMinimapService).toSelf().inSingletonScope();
|
|
604
628
|
},
|