power-link 2.0.2 → 2.0.3

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 (2) hide show
  1. package/README.md +21 -9
  2. package/package.json +4 -3
package/README.md CHANGED
@@ -157,6 +157,7 @@ Register a node for connection.
157
157
  - `id` (String): Unique identifier for the node
158
158
  - `element` (HTMLElement): DOM element of the node
159
159
  - `options` (Object): Node configuration
160
+ - `label` (String): Node name/label (optional)
160
161
  - `dotPositions` (String | Array): Connection dot positions
161
162
  - `'both'`: Both left and right dots
162
163
  - `'left'`: Only left dot (string format)
@@ -172,6 +173,7 @@ Register a node for connection.
172
173
 
173
174
  ```javascript
174
175
  connector.registerNode("myNode", element, {
176
+ label: "My Node",
175
177
  dotPositions: ["right"],
176
178
  info: {
177
179
  id: "123",
@@ -408,8 +410,8 @@ connector.updateAllConnections(); // Refresh all connection lines
408
410
  Export the current topology (nodes, connections, and view state) as a JSON object.
409
411
 
410
412
  **Returns:** ExportData object containing:
411
- - `nodes`: Array of node data (id, x, y, info, dotPositions)
412
- - `connections`: Array of connection data (from, to, fromDot, toDot)
413
+ - `nodes`: Array of node data (id, label, x, y, info, dotPositions)
414
+ - `connections`: Array of connection data (from, fromLabel, fromInfo, to, toLabel, toInfo, fromDot, toDot)
413
415
  - `viewState`: Current view state (scale, translateX, translateY)
414
416
 
415
417
  **Example:**
@@ -419,11 +421,20 @@ const data = connector.export();
419
421
  console.log(data);
420
422
  // {
421
423
  // nodes: [
422
- // { id: 'node1', x: 100, y: 100, info: {...}, dotPositions: ['right'] },
423
- // { id: 'node2', x: 400, y: 100, info: {...}, dotPositions: ['left'] }
424
+ // { id: 'node1', label: 'Node 1', x: 100, y: 100, info: {...}, dotPositions: ['right'] },
425
+ // { id: 'node2', label: 'Node 2', x: 400, y: 100, info: {...}, dotPositions: ['left'] }
424
426
  // ],
425
427
  // connections: [
426
- // { from: 'node1', to: 'node2', fromDot: 'right', toDot: 'left' }
428
+ // {
429
+ // from: 'node1',
430
+ // fromLabel: 'Node 1',
431
+ // fromInfo: {...},
432
+ // to: 'node2',
433
+ // toLabel: 'Node 2',
434
+ // toInfo: {...},
435
+ // fromDot: 'right',
436
+ // toDot: 'left'
437
+ // }
427
438
  // ],
428
439
  // viewState: { scale: 1, translateX: 0, translateY: 0 }
429
440
  // }
@@ -1004,10 +1015,11 @@ let connector = null;
1004
1015
 
1005
1016
  const saveTopology = () => {
1006
1017
  const data = connector.export();
1007
- // Merge custom fields (label, type, etc.) if needed
1018
+ // label is now included in export() by default
1019
+ // Merge other custom fields (type, etc.) if needed
1008
1020
  data.nodes = data.nodes.map(exportNode => {
1009
1021
  const origin = nodes.value.find(n => n.id === exportNode.id);
1010
- return { ...exportNode, label: origin?.label, type: origin?.type };
1022
+ return { ...exportNode, type: origin?.type };
1011
1023
  });
1012
1024
  localStorage.setItem('topology', JSON.stringify(data));
1013
1025
  };
@@ -1054,8 +1066,8 @@ const loadTopology = async () => {
1054
1066
 
1055
1067
  **What's Included in Export:**
1056
1068
 
1057
- - **Nodes**: ID, position (x, y), custom info, dot positions
1058
- - **Connections**: Source/target nodes, dot positions
1069
+ - **Nodes**: ID, label (node name), position (x, y), custom info, dot positions
1070
+ - **Connections**: Source/target nodes, source/target labels, source/target info, dot positions
1059
1071
  - **View State**: Current zoom level and pan position (scale, translateX, translateY)
1060
1072
 
1061
1073
  **Benefits:**
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "power-link",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "A pure TypeScript visual node connector for creating draggable connections between nodes. Framework-agnostic and easy to use",
5
5
  "author": {
6
6
  "name": "Lin Ji Man",
7
7
  "email": "Temman_lin@qq.com"
8
8
  },
9
9
  "keywords": [
10
- "power-link",
11
10
  "connector",
12
11
  "node-link",
13
12
  "visual-connector",
14
13
  "drag-line",
15
- "bezier-curve"
14
+ "bezier-curve",
15
+ "high-customization",
16
+ "flow-chart"
16
17
  ],
17
18
  "license": "MIT",
18
19
  "homepage": "https://tem-man.github.io/power-link",