@windoc/core 0.3.15 → 0.3.16

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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var version = "0.3.15";
2
+ var version = "0.3.16";
3
3
 
4
4
  // src/dataset/enum/Common.ts
5
5
  var MaxHeightRatio = /* @__PURE__ */ ((MaxHeightRatio2) => {
@@ -106,24 +106,6 @@ function debounce(func, delay) {
106
106
  }, delay);
107
107
  };
108
108
  }
109
- function throttle(func, delay) {
110
- let lastExecTime = 0;
111
- let timer;
112
- return function(...args) {
113
- const currentTime = Date.now();
114
- if (currentTime - lastExecTime >= delay) {
115
- window.clearTimeout(timer);
116
- func.apply(this, args);
117
- lastExecTime = currentTime;
118
- } else {
119
- window.clearTimeout(timer);
120
- timer = window.setTimeout(() => {
121
- func.apply(this, args);
122
- lastExecTime = currentTime;
123
- }, delay);
124
- }
125
- };
126
- }
127
109
  function deepCloneOmitKeys(obj, omitKeys) {
128
110
  if (!obj || typeof obj !== "object") {
129
111
  return obj;
@@ -6496,7 +6478,9 @@ var Cursor = class {
6496
6478
  const prePageY = pageNo * (this.draw.getHeight() + this.draw.getPageGap()) + this.container.getBoundingClientRect().top;
6497
6479
  const isUp = direction === "top" /* UP */;
6498
6480
  const x = leftBottom[0];
6499
- const y = isUp ? leftTop[1] + prePageY : leftBottom[1] + prePageY;
6481
+ const cursorTop = leftTop[1] + cursorPosition.ascent - cursorPosition.metrics.boundingBoxAscent;
6482
+ const cursorBottom = cursorTop + cursorPosition.metrics.boundingBoxAscent + cursorPosition.metrics.boundingBoxDescent;
6483
+ const y = isUp ? cursorTop + prePageY : cursorBottom + prePageY;
6500
6484
  const scrollContainer = findScrollContainer(this.container);
6501
6485
  const rect = {
6502
6486
  left: 0,
@@ -17766,28 +17750,27 @@ var ZoneTip = class {
17766
17750
  this._watchMouseMoveZoneChange(watchZones);
17767
17751
  }
17768
17752
  _watchMouseMoveZoneChange(watchZones) {
17769
- this.pageContainer.addEventListener(
17770
- "mousemove",
17771
- throttle((evt) => {
17772
- if (this.isDisableMouseMove || !this.draw.getIsPagingMode()) return;
17773
- if (!evt.offsetY) return;
17774
- if (evt.target instanceof HTMLCanvasElement) {
17775
- const mousemoveZone = this.zone.getZoneByY(evt.offsetY);
17776
- if (!watchZones.includes(mousemoveZone)) {
17777
- this._updateZoneTip(false);
17778
- return;
17779
- }
17780
- this.currentMoveZone = mousemoveZone;
17781
- this._updateZoneTip(
17782
- this.zone.getZone() === "main" /* MAIN */ && (mousemoveZone === "header" /* HEADER */ || mousemoveZone === "footer" /* FOOTER */),
17783
- evt.x,
17784
- evt.y
17785
- );
17786
- } else {
17787
- this._updateZoneTip(false);
17788
- }
17789
- }, 250)
17790
- );
17753
+ const showTip = debounce((evt) => {
17754
+ if (this.isDisableMouseMove || !this.draw.getIsPagingMode()) return;
17755
+ if (!(evt.target instanceof HTMLCanvasElement)) return;
17756
+ const mousemoveZone = this.zone.getZoneByY(evt.offsetY);
17757
+ if (!watchZones.includes(mousemoveZone)) return;
17758
+ this.currentMoveZone = mousemoveZone;
17759
+ this._updateZoneTip(
17760
+ this.zone.getZone() === "main" /* MAIN */ && (mousemoveZone === "header" /* HEADER */ || mousemoveZone === "footer" /* FOOTER */),
17761
+ evt.x,
17762
+ evt.y
17763
+ );
17764
+ }, 300);
17765
+ this.pageContainer.addEventListener("mousemove", (evt) => {
17766
+ if (this.isDisableMouseMove || !this.draw.getIsPagingMode()) return;
17767
+ if (!evt.offsetY) return;
17768
+ const mousemoveZone = this.zone.getZoneByY(evt.offsetY);
17769
+ if (!watchZones.includes(mousemoveZone)) {
17770
+ this._updateZoneTip(false);
17771
+ }
17772
+ showTip(evt);
17773
+ });
17791
17774
  this.pageContainer.addEventListener("mouseenter", () => {
17792
17775
  this.isDisableMouseMove = false;
17793
17776
  });
@@ -17810,7 +17793,12 @@ var ZoneTip = class {
17810
17793
  _updateZoneTip(visible, left2, top) {
17811
17794
  if (visible) {
17812
17795
  this.tipContainer.classList.add("show");
17813
- this.tipContainer.style.left = `${left2}px`;
17796
+ const tipWidth = this.tipContainer.offsetWidth;
17797
+ const clampedLeft = Math.min(
17798
+ left2 ?? 0,
17799
+ window.innerWidth - tipWidth - 10
17800
+ );
17801
+ this.tipContainer.style.left = `${clampedLeft}px`;
17814
17802
  this.tipContainer.style.top = `${top}px`;
17815
17803
  const options = this.draw.getOptions();
17816
17804
  const isHeader = this.currentMoveZone === "header" /* HEADER */;