@flowgram.ai/minimap-plugin 0.4.6 → 0.4.8
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 +163 -158
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +155 -159
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { CSSProperties } from 'react';
|
|
2
2
|
import { Rectangle, IPoint, Disposable } from '@flowgram.ai/utils';
|
|
3
3
|
import * as _flowgram_ai_core from '@flowgram.ai/core';
|
|
4
|
-
import { Layer } from '@flowgram.ai/core';
|
|
4
|
+
import { Layer, PlaygroundConfigEntity } from '@flowgram.ai/core';
|
|
5
|
+
import { FlowNodeTransformData, FlowDocumentTransformerEntity } from '@flowgram.ai/document';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
@@ -34,11 +35,9 @@ interface MinimapInactiveStyle {
|
|
|
34
35
|
interface MinimapServiceOptions {
|
|
35
36
|
canvasStyle: Partial<MinimapCanvasStyle>;
|
|
36
37
|
canvasClassName: string;
|
|
37
|
-
enableInactiveDebounce: boolean;
|
|
38
|
-
enableActiveDebounce: boolean;
|
|
39
38
|
enableDisplayAllNodes: boolean;
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
activeThrottleTime: number;
|
|
40
|
+
inactiveThrottleTime: number;
|
|
42
41
|
}
|
|
43
42
|
interface MinimapLayerOptions {
|
|
44
43
|
disableLayer?: boolean;
|
|
@@ -66,7 +65,6 @@ interface MinimapRenderContext {
|
|
|
66
65
|
|
|
67
66
|
declare class FlowMinimapService {
|
|
68
67
|
private readonly document;
|
|
69
|
-
private readonly entityManager;
|
|
70
68
|
private readonly playgroundConfig;
|
|
71
69
|
readonly canvas: HTMLCanvasElement;
|
|
72
70
|
readonly context2D: CanvasRenderingContext2D;
|
|
@@ -75,29 +73,29 @@ declare class FlowMinimapService {
|
|
|
75
73
|
private options;
|
|
76
74
|
private toDispose;
|
|
77
75
|
private initialized;
|
|
76
|
+
private visible;
|
|
78
77
|
private isDragging;
|
|
79
78
|
private style;
|
|
80
79
|
private dragStart?;
|
|
81
80
|
constructor();
|
|
82
81
|
init(options?: Partial<MinimapServiceOptions>): void;
|
|
83
82
|
dispose(): void;
|
|
83
|
+
setVisible(visible: boolean): void;
|
|
84
84
|
setActivate(activate: boolean): void;
|
|
85
85
|
onActive: (callback: (activated: boolean) => void) => Disposable;
|
|
86
86
|
private initStyle;
|
|
87
|
-
private
|
|
87
|
+
private setThrottle;
|
|
88
88
|
/**
|
|
89
89
|
* 触发渲染
|
|
90
90
|
*/
|
|
91
|
-
|
|
91
|
+
render: () => void;
|
|
92
92
|
private _render;
|
|
93
93
|
private createRenderContext;
|
|
94
94
|
private renderCanvas;
|
|
95
95
|
private calculateScaleAndOffset;
|
|
96
|
-
private get
|
|
97
|
-
private nodeTransforms;
|
|
96
|
+
private get transformVisibles();
|
|
98
97
|
private renderRect;
|
|
99
98
|
private viewRect;
|
|
100
|
-
private mountListener;
|
|
101
99
|
/** 计算画布坐标系下的矩形 */
|
|
102
100
|
private rectOnCanvas;
|
|
103
101
|
private isPointInRect;
|
|
@@ -118,7 +116,7 @@ declare class FlowMinimapService {
|
|
|
118
116
|
*/
|
|
119
117
|
|
|
120
118
|
interface MinimapProps {
|
|
121
|
-
service
|
|
119
|
+
service?: FlowMinimapService;
|
|
122
120
|
panelStyles?: CSSProperties;
|
|
123
121
|
containerStyles?: CSSProperties;
|
|
124
122
|
inactiveStyle?: Partial<MinimapInactiveStyle>;
|
|
@@ -144,6 +142,9 @@ declare const createMinimapPlugin: _flowgram_ai_core.PluginCreator<CreateMinimap
|
|
|
144
142
|
declare class FlowMinimapLayer extends Layer<MinimapLayerOptions> {
|
|
145
143
|
static type: string;
|
|
146
144
|
private readonly service;
|
|
145
|
+
transformDatas: FlowNodeTransformData[];
|
|
146
|
+
configEntity: PlaygroundConfigEntity;
|
|
147
|
+
readonly documentTransformer: FlowDocumentTransformerEntity;
|
|
147
148
|
readonly node: HTMLElement;
|
|
148
149
|
private readonly className;
|
|
149
150
|
constructor();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { CSSProperties } from 'react';
|
|
2
2
|
import { Rectangle, IPoint, Disposable } from '@flowgram.ai/utils';
|
|
3
3
|
import * as _flowgram_ai_core from '@flowgram.ai/core';
|
|
4
|
-
import { Layer } from '@flowgram.ai/core';
|
|
4
|
+
import { Layer, PlaygroundConfigEntity } from '@flowgram.ai/core';
|
|
5
|
+
import { FlowNodeTransformData, FlowDocumentTransformerEntity } from '@flowgram.ai/document';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
@@ -34,11 +35,9 @@ interface MinimapInactiveStyle {
|
|
|
34
35
|
interface MinimapServiceOptions {
|
|
35
36
|
canvasStyle: Partial<MinimapCanvasStyle>;
|
|
36
37
|
canvasClassName: string;
|
|
37
|
-
enableInactiveDebounce: boolean;
|
|
38
|
-
enableActiveDebounce: boolean;
|
|
39
38
|
enableDisplayAllNodes: boolean;
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
activeThrottleTime: number;
|
|
40
|
+
inactiveThrottleTime: number;
|
|
42
41
|
}
|
|
43
42
|
interface MinimapLayerOptions {
|
|
44
43
|
disableLayer?: boolean;
|
|
@@ -66,7 +65,6 @@ interface MinimapRenderContext {
|
|
|
66
65
|
|
|
67
66
|
declare class FlowMinimapService {
|
|
68
67
|
private readonly document;
|
|
69
|
-
private readonly entityManager;
|
|
70
68
|
private readonly playgroundConfig;
|
|
71
69
|
readonly canvas: HTMLCanvasElement;
|
|
72
70
|
readonly context2D: CanvasRenderingContext2D;
|
|
@@ -75,29 +73,29 @@ declare class FlowMinimapService {
|
|
|
75
73
|
private options;
|
|
76
74
|
private toDispose;
|
|
77
75
|
private initialized;
|
|
76
|
+
private visible;
|
|
78
77
|
private isDragging;
|
|
79
78
|
private style;
|
|
80
79
|
private dragStart?;
|
|
81
80
|
constructor();
|
|
82
81
|
init(options?: Partial<MinimapServiceOptions>): void;
|
|
83
82
|
dispose(): void;
|
|
83
|
+
setVisible(visible: boolean): void;
|
|
84
84
|
setActivate(activate: boolean): void;
|
|
85
85
|
onActive: (callback: (activated: boolean) => void) => Disposable;
|
|
86
86
|
private initStyle;
|
|
87
|
-
private
|
|
87
|
+
private setThrottle;
|
|
88
88
|
/**
|
|
89
89
|
* 触发渲染
|
|
90
90
|
*/
|
|
91
|
-
|
|
91
|
+
render: () => void;
|
|
92
92
|
private _render;
|
|
93
93
|
private createRenderContext;
|
|
94
94
|
private renderCanvas;
|
|
95
95
|
private calculateScaleAndOffset;
|
|
96
|
-
private get
|
|
97
|
-
private nodeTransforms;
|
|
96
|
+
private get transformVisibles();
|
|
98
97
|
private renderRect;
|
|
99
98
|
private viewRect;
|
|
100
|
-
private mountListener;
|
|
101
99
|
/** 计算画布坐标系下的矩形 */
|
|
102
100
|
private rectOnCanvas;
|
|
103
101
|
private isPointInRect;
|
|
@@ -118,7 +116,7 @@ declare class FlowMinimapService {
|
|
|
118
116
|
*/
|
|
119
117
|
|
|
120
118
|
interface MinimapProps {
|
|
121
|
-
service
|
|
119
|
+
service?: FlowMinimapService;
|
|
122
120
|
panelStyles?: CSSProperties;
|
|
123
121
|
containerStyles?: CSSProperties;
|
|
124
122
|
inactiveStyle?: Partial<MinimapInactiveStyle>;
|
|
@@ -144,6 +142,9 @@ declare const createMinimapPlugin: _flowgram_ai_core.PluginCreator<CreateMinimap
|
|
|
144
142
|
declare class FlowMinimapLayer extends Layer<MinimapLayerOptions> {
|
|
145
143
|
static type: string;
|
|
146
144
|
private readonly service;
|
|
145
|
+
transformDatas: FlowNodeTransformData[];
|
|
146
|
+
configEntity: PlaygroundConfigEntity;
|
|
147
|
+
readonly documentTransformer: FlowDocumentTransformerEntity;
|
|
147
148
|
readonly node: HTMLElement;
|
|
148
149
|
private readonly className;
|
|
149
150
|
constructor();
|
package/dist/index.js
CHANGED
|
@@ -50,129 +50,10 @@ module.exports = __toCommonJS(src_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
|
-
boxSizing: "border-box",
|
|
149
|
-
padding: 8,
|
|
150
|
-
...panelStyles
|
|
151
|
-
},
|
|
152
|
-
"data-flow-editor-selectable": "false",
|
|
153
|
-
ref: panelRef,
|
|
154
|
-
onMouseEnter: () => {
|
|
155
|
-
service.setActivate(true);
|
|
156
|
-
},
|
|
157
|
-
onMouseLeave: () => {
|
|
158
|
-
service.setActivate(false);
|
|
159
|
-
},
|
|
160
|
-
onTouchStartCapture: () => {
|
|
161
|
-
service.setActivate(true);
|
|
162
|
-
},
|
|
163
|
-
onTouchEndCapture: () => {
|
|
164
|
-
service.setActivate(false);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// src/create-plugin.ts
|
|
172
|
-
var import_core3 = require("@flowgram.ai/core");
|
|
53
|
+
var import_core2 = require("@flowgram.ai/core");
|
|
173
54
|
|
|
174
55
|
// src/service.ts
|
|
175
|
-
var
|
|
56
|
+
var import_lodash_es = require("lodash-es");
|
|
176
57
|
var import_inversify = require("inversify");
|
|
177
58
|
var import_utils = require("@flowgram.ai/utils");
|
|
178
59
|
var import_document = require("@flowgram.ai/document");
|
|
@@ -263,9 +144,42 @@ var MinimapDraw;
|
|
|
263
144
|
};
|
|
264
145
|
})(MinimapDraw || (MinimapDraw = {}));
|
|
265
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
|
+
|
|
266
179
|
// src/service.ts
|
|
267
180
|
var FlowMinimapService = class {
|
|
268
181
|
constructor() {
|
|
182
|
+
this.visible = false;
|
|
269
183
|
this.onActive = (callback) => {
|
|
270
184
|
this.onActiveCallbacks.add(callback);
|
|
271
185
|
return {
|
|
@@ -367,12 +281,8 @@ var FlowMinimapService = class {
|
|
|
367
281
|
init(options) {
|
|
368
282
|
this.options = MinimapDefaultOptions;
|
|
369
283
|
Object.assign(this.options, options);
|
|
370
|
-
this.
|
|
371
|
-
enableDebounce: this.options.enableInactiveDebounce,
|
|
372
|
-
debounceTime: this.options.inactiveDebounceTime
|
|
373
|
-
});
|
|
284
|
+
this.setThrottle(this.options.inactiveThrottleTime);
|
|
374
285
|
this.initStyle();
|
|
375
|
-
this.mountListener();
|
|
376
286
|
}
|
|
377
287
|
dispose() {
|
|
378
288
|
this.toDispose.dispose();
|
|
@@ -380,6 +290,9 @@ var FlowMinimapService = class {
|
|
|
380
290
|
this.activated = false;
|
|
381
291
|
this.removeEventListeners();
|
|
382
292
|
}
|
|
293
|
+
setVisible(visible) {
|
|
294
|
+
this.visible = visible;
|
|
295
|
+
}
|
|
383
296
|
setActivate(activate) {
|
|
384
297
|
if (activate === this.activated) {
|
|
385
298
|
return;
|
|
@@ -389,16 +302,10 @@ var FlowMinimapService = class {
|
|
|
389
302
|
}
|
|
390
303
|
this.activated = activate;
|
|
391
304
|
if (activate) {
|
|
392
|
-
this.
|
|
393
|
-
enableDebounce: this.options.enableActiveDebounce,
|
|
394
|
-
debounceTime: this.options.activeDebounceTime
|
|
395
|
-
});
|
|
305
|
+
this.setThrottle(this.options.activeThrottleTime);
|
|
396
306
|
this.addEventListeners();
|
|
397
307
|
} else {
|
|
398
|
-
this.
|
|
399
|
-
enableDebounce: this.options.enableInactiveDebounce,
|
|
400
|
-
debounceTime: this.options.inactiveDebounceTime
|
|
401
|
-
});
|
|
308
|
+
this.setThrottle(this.options.inactiveThrottleTime);
|
|
402
309
|
this.removeEventListeners();
|
|
403
310
|
}
|
|
404
311
|
this.render();
|
|
@@ -418,24 +325,19 @@ var FlowMinimapService = class {
|
|
|
418
325
|
this.canvas.height = this.style.canvasHeight;
|
|
419
326
|
this.canvas.style.borderRadius = this.style.canvasBorderRadius ? `${this.style.canvasBorderRadius}px` : "unset";
|
|
420
327
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
if (enableDebounce) {
|
|
424
|
-
this.render = (0, import_lodash.debounce)(this._render, debounceTime);
|
|
425
|
-
} else {
|
|
426
|
-
this.render = this._render;
|
|
427
|
-
}
|
|
328
|
+
setThrottle(throttleTime) {
|
|
329
|
+
this.render = (0, import_lodash_es.throttle)(this._render, throttleTime);
|
|
428
330
|
}
|
|
429
331
|
_render() {
|
|
430
|
-
if (!this.initialized) {
|
|
332
|
+
if (!this.initialized || !this.visible) {
|
|
431
333
|
return;
|
|
432
334
|
}
|
|
433
335
|
const renderContext = this.createRenderContext();
|
|
434
336
|
this.renderCanvas(renderContext);
|
|
435
337
|
}
|
|
436
338
|
createRenderContext() {
|
|
437
|
-
const { canvas, context2D
|
|
438
|
-
const nodeTransforms = this.
|
|
339
|
+
const { canvas, context2D } = this;
|
|
340
|
+
const nodeTransforms = this.transformVisibles;
|
|
439
341
|
const nodeRects = nodeTransforms.map((transform) => transform.bounds);
|
|
440
342
|
const viewRect = this.viewRect();
|
|
441
343
|
const renderRect = this.renderRect(nodeRects).withPadding({
|
|
@@ -515,8 +417,13 @@ var FlowMinimapService = class {
|
|
|
515
417
|
};
|
|
516
418
|
return { scale, offset };
|
|
517
419
|
}
|
|
518
|
-
get
|
|
519
|
-
|
|
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;
|
|
520
427
|
if (node.hidden) return false;
|
|
521
428
|
if (node.flowNodeType === import_document2.FlowNodeBaseType.ROOT) return;
|
|
522
429
|
if (!this.options.enableDisplayAllNodes && node.parent && node.parent.flowNodeType !== import_document2.FlowNodeBaseType.ROOT)
|
|
@@ -524,9 +431,6 @@ var FlowMinimapService = class {
|
|
|
524
431
|
return true;
|
|
525
432
|
});
|
|
526
433
|
}
|
|
527
|
-
nodeTransforms(nodes) {
|
|
528
|
-
return nodes.map((node) => node.getData(import_document.FlowNodeTransformData)).filter(Boolean);
|
|
529
|
-
}
|
|
530
434
|
renderRect(rects) {
|
|
531
435
|
return import_utils.Rectangle.enlarge(rects);
|
|
532
436
|
}
|
|
@@ -534,10 +438,6 @@ var FlowMinimapService = class {
|
|
|
534
438
|
const { width, height, scrollX, scrollY, zoom } = this.playgroundConfig.config;
|
|
535
439
|
return new import_utils.Rectangle(scrollX / zoom, scrollY / zoom, width / zoom, height / zoom);
|
|
536
440
|
}
|
|
537
|
-
mountListener() {
|
|
538
|
-
const entityManagerDisposer = this.entityManager.onEntityChange(() => this.render());
|
|
539
|
-
this.toDispose.push(entityManagerDisposer);
|
|
540
|
-
}
|
|
541
441
|
/** 计算画布坐标系下的矩形 */
|
|
542
442
|
rectOnCanvas(params) {
|
|
543
443
|
const { rect, scale, offset } = params;
|
|
@@ -580,9 +480,6 @@ var FlowMinimapService = class {
|
|
|
580
480
|
__decorateClass([
|
|
581
481
|
(0, import_inversify.inject)(import_document3.FlowDocument)
|
|
582
482
|
], FlowMinimapService.prototype, "document", 2);
|
|
583
|
-
__decorateClass([
|
|
584
|
-
(0, import_inversify.inject)(import_core.EntityManager)
|
|
585
|
-
], FlowMinimapService.prototype, "entityManager", 2);
|
|
586
483
|
__decorateClass([
|
|
587
484
|
(0, import_inversify.inject)(import_core.PlaygroundConfigEntity)
|
|
588
485
|
], FlowMinimapService.prototype, "playgroundConfig", 2);
|
|
@@ -590,12 +487,99 @@ FlowMinimapService = __decorateClass([
|
|
|
590
487
|
(0, import_inversify.injectable)()
|
|
591
488
|
], FlowMinimapService);
|
|
592
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
|
+
|
|
593
576
|
// src/layer.tsx
|
|
594
577
|
var import_react2 = __toESM(require("react"));
|
|
595
578
|
var import_inversify2 = require("inversify");
|
|
596
|
-
var import_core2 = require("@flowgram.ai/core");
|
|
597
579
|
var import_utils2 = require("@flowgram.ai/utils");
|
|
598
|
-
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 {
|
|
599
583
|
constructor() {
|
|
600
584
|
super();
|
|
601
585
|
this.className = "gedit-minimap-layer gedit-playground-layer";
|
|
@@ -603,6 +587,9 @@ var FlowMinimapLayer = class extends import_core2.Layer {
|
|
|
603
587
|
this.node.style.zIndex = "9999";
|
|
604
588
|
}
|
|
605
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();
|
|
606
593
|
if (this.options.disableLayer) {
|
|
607
594
|
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null);
|
|
608
595
|
}
|
|
@@ -621,12 +608,21 @@ FlowMinimapLayer.type = "FlowMinimapLayer";
|
|
|
621
608
|
__decorateClass([
|
|
622
609
|
(0, import_inversify2.inject)(FlowMinimapService)
|
|
623
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);
|
|
624
620
|
FlowMinimapLayer = __decorateClass([
|
|
625
621
|
(0, import_inversify2.injectable)()
|
|
626
622
|
], FlowMinimapLayer);
|
|
627
623
|
|
|
628
624
|
// src/create-plugin.ts
|
|
629
|
-
var createMinimapPlugin = (0,
|
|
625
|
+
var createMinimapPlugin = (0, import_core4.definePluginCreator)({
|
|
630
626
|
onBind: ({ bind }) => {
|
|
631
627
|
bind(FlowMinimapService).toSelf().inSingletonScope();
|
|
632
628
|
},
|