@brggroup/share-lib 0.1.75 → 0.1.76

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.
@@ -11607,6 +11607,7 @@ class WorkflowEditorComponent extends BaseComponent {
11607
11607
  previewY = 0;
11608
11608
  /** điểm đang chọn để di chuyển */
11609
11609
  draggingPoint;
11610
+ pointClickTimer = 0;
11610
11611
  /** đang kéo chọn nhiều node */
11611
11612
  isSelecting = false;
11612
11613
  /** điểm bắt đầu kéo */
@@ -11766,12 +11767,17 @@ class WorkflowEditorComponent extends BaseComponent {
11766
11767
  });
11767
11768
  this.lstAction = [...lstAction];
11768
11769
  }
11770
+ if (this.selectedStage && this.selectedStage.IsTempId) {
11771
+ this.selectedStage = undefined;
11772
+ }
11769
11773
  this.ready = true;
11770
11774
  console.log('WorkflowEditorComponent afterInput');
11771
11775
  console.log('template', this.template);
11772
11776
  console.log('lstStage', this.lstStage);
11773
11777
  console.log('lstAction', this.lstAction);
11774
11778
  console.log('lstActionRef', this.lstActionRef);
11779
+ console.log('selectedStage', this.selectedStage);
11780
+ console.log('lstActionOfCurrentStage', this.lstActionOfCurrentStage);
11775
11781
  this.updateMiniMap();
11776
11782
  }
11777
11783
  onclickaction(action) {
@@ -12496,15 +12502,28 @@ class WorkflowEditorComponent extends BaseComponent {
12496
12502
  //#endregion
12497
12503
  //#region Point action
12498
12504
  onmousedownPoint(event, p) {
12499
- console.log('onmousedownPoint', p);
12500
12505
  event.stopPropagation();
12501
12506
  event.preventDefault();
12502
- if (!this.draggingPoint) {
12503
- this.draggingPoint = p;
12504
- }
12505
- else {
12507
+ const currentTime = new Date().getTime();
12508
+ // Nếu khoảng cách giữa 2 lần click < 300ms => Nhận diện là Double Click
12509
+ if (currentTime - this.pointClickTimer < 300) {
12510
+ // 1. Tìm đường nối (edge) đang chứa điểm này
12511
+ const activeEdge = this.hoverAction || this.hoverAction;
12512
+ // 2. Xóa điểm khỏi mảng points
12513
+ if (activeEdge && activeEdge.editorOption.points) {
12514
+ const index = activeEdge.editorOption.points.indexOf(p);
12515
+ if (index > -1) {
12516
+ activeEdge.editorOption.points.splice(index, 1);
12517
+ }
12518
+ }
12519
+ // 3. Reset trạng thái
12506
12520
  this.draggingPoint = undefined;
12521
+ this.pointClickTimer = 0;
12522
+ return;
12507
12523
  }
12524
+ // Nếu click 1 lần (Single Click) => Nhận diện là bắt đầu kéo (Drag)
12525
+ this.pointClickTimer = currentTime;
12526
+ this.draggingPoint = p;
12508
12527
  }
12509
12528
  onRightClickPoint(event, edge, index) {
12510
12529
  console.log('onRightClickPoint', edge, index);
@@ -12880,13 +12899,10 @@ class WorkflowEditorComponent extends BaseComponent {
12880
12899
  const pt = svg.createSVGPoint();
12881
12900
  pt.x = event.clientX;
12882
12901
  pt.y = event.clientY;
12902
+ // Áp dụng ma trận của SVG để quy đổi tọa độ màn hình -> tọa độ Canvas thực tế
12883
12903
  const result = pt.matrixTransform(svg.getScreenCTM().inverse());
12884
- if (preview) {
12885
- return { x: result.x, y: result.y };
12886
- }
12887
- else {
12888
- return { x: event.clientX, y: event.clientY };
12889
- }
12904
+ // Bỏ điều kiện preview, LUÔN LUÔN trả về tọa độ result (đã quy đổi theo zoom scale)
12905
+ return { x: result.x, y: result.y };
12890
12906
  }
12891
12907
  updateSelection() {
12892
12908
  if (!this.selectStart || !this.selectEnd)
@@ -18530,6 +18546,7 @@ class WF_Template_CombineEditorComponent extends BaseComponent {
18530
18546
  previewX = 0;
18531
18547
  previewY = 0;
18532
18548
  draggingPoint;
18549
+ pointClickTimer = 0;
18533
18550
  edgeClickTimer = null;
18534
18551
  CLICK_DELAY = 250;
18535
18552
  canvasRef;
@@ -19003,7 +19020,26 @@ class WF_Template_CombineEditorComponent extends BaseComponent {
19003
19020
  onmousedownPoint(event, p) {
19004
19021
  event.stopPropagation();
19005
19022
  event.preventDefault();
19006
- this.draggingPoint = this.draggingPoint ? undefined : p;
19023
+ const currentTime = new Date().getTime();
19024
+ // Nếu khoảng cách giữa 2 lần click < 300ms => Nhận diện là Double Click
19025
+ if (currentTime - this.pointClickTimer < 300) {
19026
+ // 1. Tìm đường nối (edge) đang chứa điểm này
19027
+ const activeEdge = this.hoverTemplateEdge || this.selectedTemplateEdge;
19028
+ // 2. Xóa điểm khỏi mảng points
19029
+ if (activeEdge && activeEdge.editorOption.points) {
19030
+ const index = activeEdge.editorOption.points.indexOf(p);
19031
+ if (index > -1) {
19032
+ activeEdge.editorOption.points.splice(index, 1);
19033
+ }
19034
+ }
19035
+ // 3. Reset trạng thái
19036
+ this.draggingPoint = undefined;
19037
+ this.pointClickTimer = 0;
19038
+ return;
19039
+ }
19040
+ // Nếu click 1 lần (Single Click) => Nhận diện là bắt đầu kéo (Drag)
19041
+ this.pointClickTimer = currentTime;
19042
+ this.draggingPoint = p;
19007
19043
  }
19008
19044
  onRightClickPoint(event, edge, index) {
19009
19045
  event.preventDefault();
@@ -19117,8 +19153,10 @@ class WF_Template_CombineEditorComponent extends BaseComponent {
19117
19153
  const pt = svg.createSVGPoint();
19118
19154
  pt.x = event.clientX;
19119
19155
  pt.y = event.clientY;
19156
+ // Áp dụng ma trận của SVG để quy đổi tọa độ màn hình -> tọa độ Canvas thực tế
19120
19157
  const result = pt.matrixTransform(svg.getScreenCTM().inverse());
19121
- return preview ? { x: result.x, y: result.y } : { x: event.clientX, y: event.clientY };
19158
+ // Bỏ điều kiện preview, LUÔN LUÔN trả về tọa độ result (đã quy đổi theo zoom scale)
19159
+ return { x: result.x, y: result.y };
19122
19160
  }
19123
19161
  snapPoint(p, event) {
19124
19162
  if (!this.snapToGrid || event?.altKey)