@knotx/plugins-minimap 0.4.11 → 0.4.13

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.
Files changed (3) hide show
  1. package/README.en.md +406 -0
  2. package/README.md +399 -4
  3. package/package.json +10 -10
package/README.en.md ADDED
@@ -0,0 +1,406 @@
1
+ # @knotx/plugins-minimap
2
+
3
+ Minimap plugin that provides canvas navigation functionality for KnotX.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @knotx/plugins-minimap
9
+ ```
10
+
11
+ ## Overview
12
+
13
+ The Minimap plugin provides minimap functionality for KnotX, allowing users to quickly navigate in large canvases. This plugin is built on the `interactjs` library and provides zoom, pan, viewport control, and other features.
14
+
15
+ ## Implementation Principle
16
+
17
+ The core implementation principles of the Minimap plugin:
18
+
19
+ 1. **Node Mapping**: Maps nodes on the canvas to the minimap scale
20
+ 2. **Viewport Synchronization**: Real-time synchronization of viewport state between main canvas and minimap
21
+ 3. **Interaction Control**: Supports dragging and clicking on the minimap for navigation
22
+ 4. **Zoom Control**: Provides zoom buttons and reset functionality
23
+
24
+ ## Dependencies
25
+
26
+ ### Core Dependencies
27
+ - `@knotx/core`: Provides base plugin architecture
28
+ - `@knotx/decorators`: Provides decorator support
29
+ - `interactjs`: Provides interaction functionality
30
+ - `@interactjs/actions`: InteractJS action modules
31
+ - `@interactjs/core`: InteractJS core module
32
+ - `@interactjs/modifiers`: InteractJS modifier modules
33
+ - `@interactjs/types`: InteractJS type definitions
34
+ - `rxjs`: Provides reactive programming support
35
+
36
+ ### Plugin Dependencies
37
+ - `@knotx/plugins-canvas`: Retrieves canvas transform state and container information
38
+
39
+ ## API Documentation
40
+
41
+ ### Main Classes
42
+
43
+ #### Minimap
44
+
45
+ The main class of the Minimap plugin, extending `BasePlugin`.
46
+
47
+ ```typescript
48
+ export class Minimap extends BasePlugin<'minimap', MinimapConfig> {
49
+ name = 'minimap' as const
50
+ }
51
+ ```
52
+
53
+ ### Configuration Options
54
+
55
+ #### MinimapConfig
56
+
57
+ ```typescript
58
+ export interface MinimapConfig {
59
+ /** Minimap width */
60
+ width?: number
61
+ /** Minimap height */
62
+ height?: number
63
+ /** Node color */
64
+ nodeColor?: string | ((node: Node) => string)
65
+ /** Viewport area background color */
66
+ maskColor?: string
67
+ /** Viewport area border color */
68
+ viewBoxColor?: string
69
+ /** Show minimap control buttons */
70
+ showControls?: boolean
71
+ /** Whether zoomable */
72
+ zoomable?: boolean
73
+ /** Whether pannable */
74
+ pannable?: boolean
75
+ /** Padding from container */
76
+ padding?: number
77
+ /** Node border radius */
78
+ nodeBorderRadius?: number
79
+ /** Node stroke width */
80
+ nodeStrokeWidth?: number
81
+ /** Node stroke color */
82
+ nodeStrokeColor?: string | ((node: Node) => string)
83
+ /** Zoom step */
84
+ zoomStep?: number
85
+ }
86
+ ```
87
+
88
+ ### Default Configuration
89
+
90
+ ```typescript
91
+ const defaultProps: Required<Omit<MinimapConfig, 'nodeColor' | 'nodeStrokeColor'>> = {
92
+ width: 200,
93
+ height: 150,
94
+ maskColor: 'rgba(240, 240, 240, 0.6)',
95
+ viewBoxColor: '#4752E6',
96
+ showControls: true,
97
+ zoomable: true,
98
+ pannable: true,
99
+ padding: 12,
100
+ nodeBorderRadius: 2,
101
+ nodeStrokeWidth: 1,
102
+ zoomStep: 0.2,
103
+ }
104
+ ```
105
+
106
+ ## Usage Examples
107
+
108
+ ### Basic Usage
109
+
110
+ ```typescript
111
+ import { Minimap } from '@knotx/plugins-minimap'
112
+
113
+ const engine = new Engine({
114
+ plugins: [Minimap],
115
+ pluginConfig: {
116
+ minimap: {
117
+ width: 200,
118
+ height: 150,
119
+ },
120
+ },
121
+ })
122
+ ```
123
+
124
+ ### Custom Styling
125
+
126
+ ```typescript
127
+ const engine = new Engine({
128
+ plugins: [Minimap],
129
+ pluginConfig: {
130
+ minimap: {
131
+ width: 250,
132
+ height: 180,
133
+ nodeColor: '#4A90E2',
134
+ maskColor: 'rgba(255, 255, 255, 0.8)',
135
+ viewBoxColor: '#FF6B6B',
136
+ nodeBorderRadius: 4,
137
+ nodeStrokeWidth: 2,
138
+ nodeStrokeColor: '#333',
139
+ },
140
+ },
141
+ })
142
+ ```
143
+
144
+ ### Dynamic Node Colors
145
+
146
+ ```typescript
147
+ const engine = new Engine({
148
+ plugins: [Minimap],
149
+ pluginConfig: {
150
+ minimap: {
151
+ nodeColor: (node) => {
152
+ // Return different colors based on node type
153
+ switch (node.type) {
154
+ case 'start':
155
+ return '#4CAF50'
156
+ case 'end':
157
+ return '#F44336'
158
+ case 'process':
159
+ return '#2196F3'
160
+ default:
161
+ return '#9E9E9E'
162
+ }
163
+ },
164
+ nodeStrokeColor: (node) => {
165
+ return node.selected ? '#FF9800' : 'transparent'
166
+ },
167
+ },
168
+ },
169
+ })
170
+ ```
171
+
172
+ ### Disable Control Buttons
173
+
174
+ ```typescript
175
+ const engine = new Engine({
176
+ plugins: [Minimap],
177
+ pluginConfig: {
178
+ minimap: {
179
+ showControls: false,
180
+ zoomable: false,
181
+ pannable: true,
182
+ },
183
+ },
184
+ })
185
+ ```
186
+
187
+ ### Custom Size and Position
188
+
189
+ ```typescript
190
+ const engine = new Engine({
191
+ plugins: [Minimap],
192
+ pluginConfig: {
193
+ minimap: {
194
+ width: 300,
195
+ height: 200,
196
+ padding: 20,
197
+ zoomStep: 0.3,
198
+ },
199
+ },
200
+ })
201
+ ```
202
+
203
+ ## Advanced Features
204
+
205
+ ### Integration with Canvas Plugin
206
+
207
+ ```typescript
208
+ import { Canvas } from '@knotx/plugins-canvas'
209
+ import { Minimap } from '@knotx/plugins-minimap'
210
+
211
+ const engine = new Engine({
212
+ plugins: [Canvas, Minimap],
213
+ pluginConfig: {
214
+ canvas: {
215
+ minScale: 0.1,
216
+ maxScale: 3,
217
+ },
218
+ minimap: {
219
+ width: 200,
220
+ height: 150,
221
+ },
222
+ },
223
+ })
224
+ ```
225
+
226
+ ### Listening to Minimap Interactions
227
+
228
+ ```typescript
229
+ class MinimapInteractionPlugin extends BasePlugin {
230
+ @inject.canvas.transform()
231
+ transform!: CanvasTransformState
232
+
233
+ @subscribe.canvas.transform()
234
+ onTransformChange(transform: CanvasTransformState) {
235
+ console.log('Canvas transform changed:', transform)
236
+ // Minimap will automatically sync transform state
237
+ }
238
+ }
239
+ ```
240
+
241
+ ### Custom Minimap Behavior
242
+
243
+ ```typescript
244
+ class CustomMinimapPlugin extends BasePlugin {
245
+ @inject.minimap.config()
246
+ minimapConfig!: MinimapConfig
247
+
248
+ @OnInit
249
+ init() {
250
+ // Dynamically adjust minimap configuration
251
+ this.minimapConfig.nodeColor = (node) => {
252
+ const isImportant = node.data?.important
253
+ return isImportant ? '#FF5722' : '#607D8B'
254
+ }
255
+ }
256
+ }
257
+ ```
258
+
259
+ ## Style Customization
260
+
261
+ ### CSS Class Names
262
+
263
+ The minimap provides the following CSS class names for style customization:
264
+
265
+ ```css
266
+ .knotx-minimap {
267
+ /* Minimap container */
268
+ border: 1px solid #ddd;
269
+ border-radius: 4px;
270
+ background: #fff;
271
+ }
272
+
273
+ .knotx-minimap__svg {
274
+ /* SVG container */
275
+ cursor: crosshair;
276
+ }
277
+
278
+ .knotx-minimap__controls {
279
+ /* Control buttons container */
280
+ display: flex;
281
+ gap: 4px;
282
+ margin-top: 8px;
283
+ }
284
+
285
+ .knotx-minimap__button {
286
+ /* Control buttons */
287
+ padding: 4px 8px;
288
+ border: 1px solid #ccc;
289
+ background: #f5f5f5;
290
+ cursor: pointer;
291
+ }
292
+
293
+ .knotx-minimap__button:hover {
294
+ background: #e0e0e0;
295
+ }
296
+
297
+ .knotx-minimap__button:disabled {
298
+ opacity: 0.5;
299
+ cursor: not-allowed;
300
+ }
301
+ ```
302
+
303
+ ### Custom Style Example
304
+
305
+ ```typescript
306
+ const engine = new Engine({
307
+ plugins: [Minimap],
308
+ pluginConfig: {
309
+ minimap: {
310
+ width: 200,
311
+ height: 150,
312
+ // Custom viewport color
313
+ viewBoxColor: '#FF6B6B',
314
+ // Custom mask color
315
+ maskColor: 'rgba(255, 107, 107, 0.1)',
316
+ },
317
+ },
318
+ })
319
+ ```
320
+
321
+ ## Performance Optimization
322
+
323
+ ### Node Rendering Optimization
324
+
325
+ ```typescript
326
+ const engine = new Engine({
327
+ plugins: [Minimap],
328
+ pluginConfig: {
329
+ minimap: {
330
+ // Use fixed color to avoid function call overhead
331
+ nodeColor: '#4A90E2',
332
+ nodeStrokeColor: 'transparent',
333
+ // Reduce border radius for better rendering performance
334
+ nodeBorderRadius: 0,
335
+ },
336
+ },
337
+ })
338
+ ```
339
+
340
+ ### Interaction Optimization
341
+
342
+ ```typescript
343
+ const engine = new Engine({
344
+ plugins: [Minimap],
345
+ pluginConfig: {
346
+ minimap: {
347
+ // Smaller zoom step for smoother experience
348
+ zoomStep: 0.1,
349
+ // Appropriate size balancing performance and usability
350
+ width: 180,
351
+ height: 120,
352
+ },
353
+ },
354
+ })
355
+ ```
356
+
357
+ ## File Directory Structure
358
+
359
+ ```
360
+ packages/plugins-minimap/
361
+ ├── src/
362
+ │ ├── minimap.tsx # Main implementation file
363
+ │ └── index.ts # Export file
364
+ ├── dist/ # Build output directory
365
+ ├── package.json # Package configuration
366
+ ├── build.config.ts # Build configuration
367
+ ├── tsconfig.json # TypeScript configuration
368
+ ├── eslint.config.mjs # ESLint configuration
369
+ └── CHANGELOG.md # Changelog
370
+ ```
371
+
372
+ ### Core Files Description
373
+
374
+ - **minimap.tsx**: Contains the main implementation of the Minimap plugin, including node mapping, viewport synchronization, and interaction control
375
+ - **index.ts**: Exports the Minimap class and related type definitions
376
+
377
+ ## Best Practices
378
+
379
+ ### User Experience
380
+
381
+ 1. **Appropriate Size**: Choose suitable minimap size based on application layout
382
+ 2. **Clear Visual Feedback**: Use high-contrast colors to distinguish different elements
383
+ 3. **Smooth Interactions**: Configure zoom steps and animation effects appropriately
384
+
385
+ ### Performance Optimization
386
+
387
+ 1. **Fixed Colors**: Use fixed colors instead of dynamic functions for large numbers of nodes
388
+ 2. **Simplified Styles**: Reduce unnecessary visual effects to improve rendering performance
389
+ 3. **Reasonable Size**: Adjust minimap size based on node count
390
+
391
+ ### Development and Debugging
392
+
393
+ 1. **Monitor State Changes**: Listen to transform state changes during development
394
+ 2. **Test Interactions**: Ensure proper synchronization between minimap and main canvas
395
+ 3. **Verify Boundaries**: Test extreme zoom and pan scenarios
396
+
397
+ ## Notes
398
+
399
+ 1. **Dependencies**: Ensure Canvas plugin is loaded before Minimap plugin
400
+ 2. **Performance Considerations**: With many nodes, minimap rendering may impact performance
401
+ 3. **Responsive Design**: Consider minimap display on different screen sizes
402
+ 4. **Browser Compatibility**: Depends on SVG and modern JavaScript features
403
+
404
+ ## License
405
+
406
+ MIT
package/README.md CHANGED
@@ -1,11 +1,406 @@
1
- Install
1
+ # @knotx/plugins-minimap
2
+
3
+ 小地图插件,为 KnotX 提供画布导航功能。
4
+
5
+ ## 安装
2
6
 
3
7
  ```bash
4
- pnpm add interactjs @knotx/plugins-canvas @knotx/core @knotx/decorators @knotx/utils
8
+ npm install @knotx/plugins-minimap
9
+ ```
10
+
11
+ ## 概述
12
+
13
+ Minimap 插件为 KnotX 提供了小地图功能,允许用户在大型画布中快速导航。该插件基于 `interactjs` 库实现,提供了缩放、平移、视窗控制等功能。
14
+
15
+ ## 实现原理
16
+
17
+ Minimap 插件的核心实现原理:
18
+
19
+ 1. **节点映射**:将画布上的节点映射到小地图的比例尺中
20
+ 2. **视窗同步**:实时同步主画布和小地图的视窗状态
21
+ 3. **交互控制**:支持在小地图上拖拽和点击进行导航
22
+ 4. **缩放控制**:提供缩放按钮和重置功能
23
+
24
+ ## 依赖关系
25
+
26
+ ### 核心依赖
27
+ - `@knotx/core`:提供基础插件架构
28
+ - `@knotx/decorators`:提供装饰器支持
29
+ - `interactjs`:提供交互功能
30
+ - `@interactjs/actions`:InteractJS 动作模块
31
+ - `@interactjs/core`:InteractJS 核心模块
32
+ - `@interactjs/modifiers`:InteractJS 修饰器模块
33
+ - `@interactjs/types`:InteractJS 类型定义
34
+ - `rxjs`:提供响应式编程支持
35
+
36
+ ### 插件依赖
37
+ - `@knotx/plugins-canvas`:获取画布变换状态和容器信息
38
+
39
+ ## API 文档
40
+
41
+ ### 主要类
42
+
43
+ #### Minimap
44
+
45
+ 小地图插件的主要类,继承自 `BasePlugin`。
46
+
47
+ ```typescript
48
+ export class Minimap extends BasePlugin<'minimap', MinimapConfig> {
49
+ name = 'minimap' as const
50
+ }
51
+ ```
52
+
53
+ ### 配置选项
54
+
55
+ #### MinimapConfig
56
+
57
+ ```typescript
58
+ export interface MinimapConfig {
59
+ /** 小地图宽度 */
60
+ width?: number
61
+ /** 小地图高度 */
62
+ height?: number
63
+ /** 节点颜色 */
64
+ nodeColor?: string | ((node: Node) => string)
65
+ /** 视图区域背景颜色 */
66
+ maskColor?: string
67
+ /** 视图区域边框颜色 */
68
+ viewBoxColor?: string
69
+ /** 显示小地图控制按钮 */
70
+ showControls?: boolean
71
+ /** 是否可缩放 */
72
+ zoomable?: boolean
73
+ /** 是否可平移 */
74
+ pannable?: boolean
75
+ /** 与容器的内边距 */
76
+ padding?: number
77
+ /** 节点圆角 */
78
+ nodeBorderRadius?: number
79
+ /** 节点描边宽度 */
80
+ nodeStrokeWidth?: number
81
+ /** 节点描边颜色 */
82
+ nodeStrokeColor?: string | ((node: Node) => string)
83
+ /** 缩放步长 */
84
+ zoomStep?: number
85
+ }
86
+ ```
87
+
88
+ ### 默认配置
89
+
90
+ ```typescript
91
+ const defaultProps: Required<Omit<MinimapConfig, 'nodeColor' | 'nodeStrokeColor'>> = {
92
+ width: 200,
93
+ height: 150,
94
+ maskColor: 'rgba(240, 240, 240, 0.6)',
95
+ viewBoxColor: '#4752E6',
96
+ showControls: true,
97
+ zoomable: true,
98
+ pannable: true,
99
+ padding: 12,
100
+ nodeBorderRadius: 2,
101
+ nodeStrokeWidth: 1,
102
+ zoomStep: 0.2,
103
+ }
104
+ ```
105
+
106
+ ## 使用示例
107
+
108
+ ### 基本用法
109
+
110
+ ```typescript
111
+ import { Minimap } from '@knotx/plugins-minimap'
112
+
113
+ const engine = new Engine({
114
+ plugins: [Minimap],
115
+ pluginConfig: {
116
+ minimap: {
117
+ width: 200,
118
+ height: 150,
119
+ },
120
+ },
121
+ })
122
+ ```
123
+
124
+ ### 自定义样式
125
+
126
+ ```typescript
127
+ const engine = new Engine({
128
+ plugins: [Minimap],
129
+ pluginConfig: {
130
+ minimap: {
131
+ width: 250,
132
+ height: 180,
133
+ nodeColor: '#4A90E2',
134
+ maskColor: 'rgba(255, 255, 255, 0.8)',
135
+ viewBoxColor: '#FF6B6B',
136
+ nodeBorderRadius: 4,
137
+ nodeStrokeWidth: 2,
138
+ nodeStrokeColor: '#333',
139
+ },
140
+ },
141
+ })
142
+ ```
143
+
144
+ ### 动态节点颜色
145
+
146
+ ```typescript
147
+ const engine = new Engine({
148
+ plugins: [Minimap],
149
+ pluginConfig: {
150
+ minimap: {
151
+ nodeColor: (node) => {
152
+ // 根据节点类型返回不同颜色
153
+ switch (node.type) {
154
+ case 'start':
155
+ return '#4CAF50'
156
+ case 'end':
157
+ return '#F44336'
158
+ case 'process':
159
+ return '#2196F3'
160
+ default:
161
+ return '#9E9E9E'
162
+ }
163
+ },
164
+ nodeStrokeColor: (node) => {
165
+ return node.selected ? '#FF9800' : 'transparent'
166
+ },
167
+ },
168
+ },
169
+ })
170
+ ```
171
+
172
+ ### 禁用控制按钮
173
+
174
+ ```typescript
175
+ const engine = new Engine({
176
+ plugins: [Minimap],
177
+ pluginConfig: {
178
+ minimap: {
179
+ showControls: false,
180
+ zoomable: false,
181
+ pannable: true,
182
+ },
183
+ },
184
+ })
5
185
  ```
6
186
 
7
- Usage
187
+ ### 自定义尺寸和位置
8
188
 
9
- ```tsx
189
+ ```typescript
190
+ const engine = new Engine({
191
+ plugins: [Minimap],
192
+ pluginConfig: {
193
+ minimap: {
194
+ width: 300,
195
+ height: 200,
196
+ padding: 20,
197
+ zoomStep: 0.3,
198
+ },
199
+ },
200
+ })
201
+ ```
202
+
203
+ ## 高级功能
204
+
205
+ ### 与 Canvas 插件集成
206
+
207
+ ```typescript
208
+ import { Canvas } from '@knotx/plugins-canvas'
10
209
  import { Minimap } from '@knotx/plugins-minimap'
210
+
211
+ const engine = new Engine({
212
+ plugins: [Canvas, Minimap],
213
+ pluginConfig: {
214
+ canvas: {
215
+ minScale: 0.1,
216
+ maxScale: 3,
217
+ },
218
+ minimap: {
219
+ width: 200,
220
+ height: 150,
221
+ },
222
+ },
223
+ })
224
+ ```
225
+
226
+ ### 监听小地图交互
227
+
228
+ ```typescript
229
+ class MinimapInteractionPlugin extends BasePlugin {
230
+ @inject.canvas.transform()
231
+ transform!: CanvasTransformState
232
+
233
+ @subscribe.canvas.transform()
234
+ onTransformChange(transform: CanvasTransformState) {
235
+ console.log('Canvas transform changed:', transform)
236
+ // 小地图会自动同步变换状态
237
+ }
238
+ }
239
+ ```
240
+
241
+ ### 自定义小地图行为
242
+
243
+ ```typescript
244
+ class CustomMinimapPlugin extends BasePlugin {
245
+ @inject.minimap.config()
246
+ minimapConfig!: MinimapConfig
247
+
248
+ @OnInit
249
+ init() {
250
+ // 动态调整小地图配置
251
+ this.minimapConfig.nodeColor = (node) => {
252
+ const isImportant = node.data?.important
253
+ return isImportant ? '#FF5722' : '#607D8B'
254
+ }
255
+ }
256
+ }
257
+ ```
258
+
259
+ ## 样式自定义
260
+
261
+ ### CSS 类名
262
+
263
+ 小地图提供了以下 CSS 类名用于样式自定义:
264
+
265
+ ```css
266
+ .knotx-minimap {
267
+ /* 小地图容器 */
268
+ border: 1px solid #ddd;
269
+ border-radius: 4px;
270
+ background: #fff;
271
+ }
272
+
273
+ .knotx-minimap__svg {
274
+ /* SVG 容器 */
275
+ cursor: crosshair;
276
+ }
277
+
278
+ .knotx-minimap__controls {
279
+ /* 控制按钮容器 */
280
+ display: flex;
281
+ gap: 4px;
282
+ margin-top: 8px;
283
+ }
284
+
285
+ .knotx-minimap__button {
286
+ /* 控制按钮 */
287
+ padding: 4px 8px;
288
+ border: 1px solid #ccc;
289
+ background: #f5f5f5;
290
+ cursor: pointer;
291
+ }
292
+
293
+ .knotx-minimap__button:hover {
294
+ background: #e0e0e0;
295
+ }
296
+
297
+ .knotx-minimap__button:disabled {
298
+ opacity: 0.5;
299
+ cursor: not-allowed;
300
+ }
301
+ ```
302
+
303
+ ### 自定义样式示例
304
+
305
+ ```typescript
306
+ const engine = new Engine({
307
+ plugins: [Minimap],
308
+ pluginConfig: {
309
+ minimap: {
310
+ width: 200,
311
+ height: 150,
312
+ // 自定义视窗颜色
313
+ viewBoxColor: '#FF6B6B',
314
+ // 自定义蒙版颜色
315
+ maskColor: 'rgba(255, 107, 107, 0.1)',
316
+ },
317
+ },
318
+ })
319
+ ```
320
+
321
+ ## 性能优化
322
+
323
+ ### 节点渲染优化
324
+
325
+ ```typescript
326
+ const engine = new Engine({
327
+ plugins: [Minimap],
328
+ pluginConfig: {
329
+ minimap: {
330
+ // 使用固定颜色避免函数调用开销
331
+ nodeColor: '#4A90E2',
332
+ nodeStrokeColor: 'transparent',
333
+ // 减少圆角以提高渲染性能
334
+ nodeBorderRadius: 0,
335
+ },
336
+ },
337
+ })
338
+ ```
339
+
340
+ ### 交互优化
341
+
342
+ ```typescript
343
+ const engine = new Engine({
344
+ plugins: [Minimap],
345
+ pluginConfig: {
346
+ minimap: {
347
+ // 较小的缩放步长提供更平滑的体验
348
+ zoomStep: 0.1,
349
+ // 合适的尺寸平衡性能和可用性
350
+ width: 180,
351
+ height: 120,
352
+ },
353
+ },
354
+ })
11
355
  ```
356
+
357
+ ## 文件目录结构
358
+
359
+ ```
360
+ packages/plugins-minimap/
361
+ ├── src/
362
+ │ ├── minimap.tsx # 主要实现文件
363
+ │ └── index.ts # 导出文件
364
+ ├── dist/ # 构建输出目录
365
+ ├── package.json # 包配置文件
366
+ ├── build.config.ts # 构建配置
367
+ ├── tsconfig.json # TypeScript 配置
368
+ ├── eslint.config.mjs # ESLint 配置
369
+ └── CHANGELOG.md # 更新日志
370
+ ```
371
+
372
+ ### 核心文件说明
373
+
374
+ - **minimap.tsx**:包含 Minimap 插件的主要实现,包括节点映射、视窗同步和交互控制
375
+ - **index.ts**:导出 Minimap 类和相关类型定义
376
+
377
+ ## 最佳实践
378
+
379
+ ### 用户体验
380
+
381
+ 1. **合适的尺寸**:根据应用布局选择合适的小地图尺寸
382
+ 2. **清晰的视觉反馈**:使用对比度高的颜色区分不同元素
383
+ 3. **平滑的交互**:合理配置缩放步长和动画效果
384
+
385
+ ### 性能优化
386
+
387
+ 1. **固定颜色**:对于大量节点,使用固定颜色而非动态函数
388
+ 2. **简化样式**:减少不必要的视觉效果以提高渲染性能
389
+ 3. **合理尺寸**:根据节点数量调整小地图尺寸
390
+
391
+ ### 开发调试
392
+
393
+ 1. **监听状态变化**:在开发阶段监听变换状态变化
394
+ 2. **测试交互**:确保小地图与主画布的同步正常
395
+ 3. **验证边界**:测试极端缩放和平移情况
396
+
397
+ ## 注意事项
398
+
399
+ 1. **依赖关系**:确保 Canvas 插件在 Minimap 插件之前加载
400
+ 2. **性能考虑**:大量节点时,小地图的渲染可能影响性能
401
+ 3. **响应式设计**:考虑在不同屏幕尺寸下的小地图显示
402
+ 4. **浏览器兼容性**:依赖 SVG 和现代 JavaScript 特性
403
+
404
+ ## 许可证
405
+
406
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knotx/plugins-minimap",
3
- "version": "0.4.11",
3
+ "version": "0.4.13",
4
4
  "description": "Minimap Plugin for Knotx",
5
5
  "author": "boenfu",
6
6
  "license": "MIT",
@@ -29,8 +29,8 @@
29
29
  ],
30
30
  "peerDependencies": {
31
31
  "interactjs": "^1.10.27",
32
- "@knotx/jsx": "0.4.11",
33
- "@knotx/plugins-canvas": "0.4.11"
32
+ "@knotx/jsx": "0.4.13",
33
+ "@knotx/plugins-canvas": "0.4.13"
34
34
  },
35
35
  "dependencies": {
36
36
  "@interactjs/actions": "^1.10.27",
@@ -38,16 +38,16 @@
38
38
  "@interactjs/modifiers": "^1.10.27",
39
39
  "@interactjs/types": "^1.10.27",
40
40
  "rxjs": "^7.8.1",
41
- "@knotx/core": "0.4.11",
42
- "@knotx/decorators": "0.4.11"
41
+ "@knotx/core": "0.4.13",
42
+ "@knotx/decorators": "0.4.13"
43
43
  },
44
44
  "devDependencies": {
45
45
  "interactjs": "^1.10.27",
46
- "@knotx/build-config": "0.4.11",
47
- "@knotx/eslint-config": "0.4.11",
48
- "@knotx/jsx": "0.4.11",
49
- "@knotx/plugins-canvas": "0.4.11",
50
- "@knotx/typescript-config": "0.4.11"
46
+ "@knotx/build-config": "0.4.13",
47
+ "@knotx/eslint-config": "0.4.13",
48
+ "@knotx/jsx": "0.4.13",
49
+ "@knotx/plugins-canvas": "0.4.13",
50
+ "@knotx/typescript-config": "0.4.13"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "unbuild",