@basic-genomics/hivtrace-viz 1.2.2 → 1.2.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.
@@ -977,6 +977,30 @@
977
977
  }
978
978
  );
979
979
 
980
+ // 传递自定义上下文菜单项配置
981
+ var customContextMenuItems = options && options.customContextMenuItems;
982
+ if (customContextMenuItems && Array.isArray(customContextMenuItems) && customContextMenuItems.length > 0) {
983
+ user_graph.customContextMenuItems = customContextMenuItems;
984
+
985
+ // 设置菜单项点击回调,通过 postMessage 发送事件到宿主应用
986
+ user_graph.onCustomMenuItemClick = function (itemId, clusterInfo) {
987
+ window.parent.postMessage({
988
+ type: 'CUSTOM_MENU_CLICK',
989
+ itemId: itemId,
990
+ clusterInfo: {
991
+ cluster_id: clusterInfo.cluster_id,
992
+ node_count: clusterInfo.node_count,
993
+ cluster_size: clusterInfo.cluster_size,
994
+ position: { x: clusterInfo.x, y: clusterInfo.y },
995
+ state: { expanded: clusterInfo.expanded, fixed: clusterInfo.fixed },
996
+ node_ids: Array.isArray(clusterInfo.nodes)
997
+ ? clusterInfo.nodes.slice(0, 100).map(function (n) { return n.id; }).filter(Boolean)
998
+ : []
999
+ }
1000
+ }, '*');
1001
+ };
1002
+ }
1003
+
980
1004
  if (user_graph.is_empty()) {
981
1005
  HandleAppError(
982
1006
  "This network contains no clusters and cannot be displayed"
@@ -1368,6 +1392,31 @@
1368
1392
  // 直接替换数据
1369
1393
  user_graph.json = newGraph;
1370
1394
 
1395
+ // 更新自定义上下文菜单项(如果有变化)
1396
+ var customContextMenuItems = options && options.customContextMenuItems;
1397
+ if (customContextMenuItems && Array.isArray(customContextMenuItems) && customContextMenuItems.length > 0) {
1398
+ user_graph.customContextMenuItems = customContextMenuItems;
1399
+ // 确保回调已设置
1400
+ if (!user_graph.onCustomMenuItemClick) {
1401
+ user_graph.onCustomMenuItemClick = function (itemId, clusterInfo) {
1402
+ window.parent.postMessage({
1403
+ type: 'CUSTOM_MENU_CLICK',
1404
+ itemId: itemId,
1405
+ clusterInfo: {
1406
+ cluster_id: clusterInfo.cluster_id,
1407
+ node_count: clusterInfo.node_count,
1408
+ cluster_size: clusterInfo.cluster_size,
1409
+ position: { x: clusterInfo.x, y: clusterInfo.y },
1410
+ state: { expanded: clusterInfo.expanded, fixed: clusterInfo.fixed },
1411
+ node_ids: Array.isArray(clusterInfo.nodes)
1412
+ ? clusterInfo.nodes.slice(0, 100).map(function (n) { return n.id; }).filter(Boolean)
1413
+ : []
1414
+ }
1415
+ }, '*');
1416
+ };
1417
+ }
1418
+ }
1419
+
1371
1420
  // 执行必要的更新
1372
1421
  user_graph.update(false, 0.4);
1373
1422
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basic-genomics/hivtrace-viz",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "HIV-TRACE molecular transmission network visualization with React integration",
5
5
  "engines": {
6
6
  "node": ">=18"