tnx-shared 5.3.409 → 5.3.410

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.
@@ -50567,6 +50567,7 @@
50567
50567
  }
50568
50568
  this.hideWaitBox();
50569
50569
  this.show = false;
50570
+ this.onClose.next();
50570
50571
  return [2 /*return*/];
50571
50572
  }
50572
50573
  });
@@ -50579,11 +50580,33 @@
50579
50580
  var _a;
50580
50581
  var pdfViewer = (_a = window.PDFViewerApplication) === null || _a === void 0 ? void 0 : _a.pdfViewer;
50581
50582
  if (pdfViewer) {
50582
- // Add click listener to each page canvas
50583
- var container = document.querySelector('#viewerContainer');
50584
- container === null || container === void 0 ? void 0 : container.addEventListener('click', function (e) {
50585
- _this.handlePageClick(e, pdfViewer);
50583
+ // Lấy tất cả canvas elements
50584
+ var canvases = document.querySelectorAll('#viewerContainer canvas');
50585
+ canvases.forEach(function (canvas) {
50586
+ canvas.addEventListener('click', function (e) {
50587
+ _this.handlePageClick(e, pdfViewer);
50588
+ });
50586
50589
  });
50590
+ // Optional: Theo dõi khi có canvas mới được render (khi scroll PDF)
50591
+ var observer = new MutationObserver(function () {
50592
+ var newCanvases = document.querySelectorAll('#viewerContainer canvas');
50593
+ newCanvases.forEach(function (canvas) {
50594
+ // Kiểm tra nếu chưa có listener (tránh thêm duplicate)
50595
+ if (!canvas._hasClickListener) {
50596
+ canvas.addEventListener('click', function (e) {
50597
+ _this.handlePageClick(e, pdfViewer);
50598
+ });
50599
+ canvas._hasClickListener = true;
50600
+ }
50601
+ });
50602
+ });
50603
+ var container = document.querySelector('#viewerContainer');
50604
+ if (container) {
50605
+ observer.observe(container, {
50606
+ childList: true,
50607
+ subtree: true
50608
+ });
50609
+ }
50587
50610
  }
50588
50611
  }, 1000);
50589
50612
  };
@@ -50593,29 +50616,37 @@
50593
50616
  if (marker) {
50594
50617
  marker.remove();
50595
50618
  }
50596
- if (target.classList.contains('canvasWrapper') ||
50597
- target.tagName === 'CANVAS') {
50598
- // Get page number and coordinates
50619
+ if (target.tagName === 'CANVAS') {
50599
50620
  var pageDiv = target.closest('.page');
50600
50621
  var pageNumber = parseInt((pageDiv === null || pageDiv === void 0 ? void 0 : pageDiv.getAttribute('data-page-number')) || '1');
50601
- var rect = target.getBoundingClientRect();
50602
- var x = event.clientX - rect.left;
50603
- var y = event.clientY - rect.top;
50622
+ // Dùng offsetX/Y với scale adjustment
50623
+ var x = event.offsetX;
50624
+ var y = event.offsetY;
50625
+ // Điều chỉnh theo scale của canvas
50626
+ var scaleX = target.width / target.clientWidth;
50627
+ var scaleY = target.height / target.clientHeight;
50628
+ x = x * scaleX;
50629
+ y = y * scaleY;
50604
50630
  var WIDTH = this.model.data.width || 100;
50605
50631
  var HEIGHT = this.model.data.height || 100;
50606
- // Convert pixel sang point TRƯỚC
50632
+ // Convert pixel sang point
50607
50633
  var clickXPoint = this.pixelToPoint(x);
50608
50634
  var clickYPoint = this.pixelToPoint(y);
50609
50635
  var widthPoint = this.pixelToPoint(WIDTH);
50610
50636
  var heightPoint = this.pixelToPoint(HEIGHT);
50611
- // SAU ĐÓ mới tính toán như C#
50637
+ var canvasHeightPoint = this.pixelToPoint(target.height);
50638
+ // Chuyển đổi Y coordinate (PDF origin ở dưới)
50639
+ var pdfY = canvasHeightPoint - clickYPoint;
50612
50640
  var x1 = clickXPoint;
50613
- var y1 = clickYPoint - heightPoint;
50641
+ var y1 = pdfY - heightPoint;
50614
50642
  var x2 = clickXPoint + widthPoint;
50615
- var y2 = clickYPoint;
50616
- var rectangle = x1 + "," + y1 + "," + x2 + "," + y2;
50643
+ var y2 = pdfY;
50644
+ var rectangle = Math.floor(x1) + "," + Math.floor(y1) + "," + Math.floor(x2) + "," + Math.floor(y2);
50645
+ console.log('PDF Rectangle:', rectangle);
50646
+ console.log('==================');
50617
50647
  this.model.data.signatureLocation = rectangle;
50618
- this.createMarker(target, x, y, pageNumber);
50648
+ // Tạo marker với tọa độ đã điều chỉnh (nhưng hiển thị theo display size)
50649
+ this.createMarker(target, event.offsetX, event.offsetY, pageNumber);
50619
50650
  }
50620
50651
  };
50621
50652
  FileViewerComponent.prototype.createMarker = function (parent, x, y, page) {
@@ -50628,7 +50659,7 @@
50628
50659
  };
50629
50660
  FileViewerComponent.prototype.pixelToPoint = function (pixel, dpi) {
50630
50661
  if (dpi === void 0) { dpi = 96; }
50631
- return Math.round(pixel * 72 / dpi * 100); // Làm tròn 2 chữ số thập phân
50662
+ return pixel * 72 / dpi;
50632
50663
  };
50633
50664
  return FileViewerComponent;
50634
50665
  }(ComponentBase));