@windoc/core 0.3.14 → 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.14";
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 */;
@@ -25496,42 +25484,6 @@ var imageMenus = [
25496
25484
  ];
25497
25485
 
25498
25486
  // src/core/contextmenu/menus/tableMenus.ts
25499
- var COLOR_PALETTE = [
25500
- { name: "Black", value: "#000000" },
25501
- { name: "Dark gray", value: "#444444" },
25502
- { name: "Gray", value: "#888888" },
25503
- { name: "Light gray", value: "#cccccc" },
25504
- { name: "White", value: "#ffffff" },
25505
- { name: "Red", value: "#ff0000" },
25506
- { name: "Orange", value: "#ff9900" },
25507
- { name: "Yellow", value: "#ffff00" },
25508
- { name: "Green", value: "#00aa00" },
25509
- { name: "Cyan", value: "#00aaff" },
25510
- { name: "Blue", value: "#0000ff" },
25511
- { name: "Purple", value: "#9900ff" },
25512
- { name: "Pink", value: "#ff00aa" },
25513
- { name: "Light red", value: "#ffcccc" },
25514
- { name: "Light orange", value: "#ffeecc" },
25515
- { name: "Light yellow", value: "#ffffcc" },
25516
- { name: "Light green", value: "#ccffcc" },
25517
- { name: "Light blue", value: "#ccecff" },
25518
- { name: "Light purple", value: "#eeccff" }
25519
- ];
25520
- function openNativeColorPicker(defaultColor, onSelect) {
25521
- const input2 = document.createElement("input");
25522
- input2.type = "color";
25523
- input2.value = defaultColor;
25524
- input2.style.cssText = "position:fixed;opacity:0;pointer-events:none;top:0;left:0;width:0;height:0";
25525
- document.body.appendChild(input2);
25526
- input2.addEventListener("change", () => {
25527
- onSelect(input2.value);
25528
- document.body.removeChild(input2);
25529
- });
25530
- input2.addEventListener("cancel", () => {
25531
- document.body.removeChild(input2);
25532
- });
25533
- input2.click();
25534
- }
25535
25487
  var {
25536
25488
  TABLE: {
25537
25489
  BORDER,
@@ -25562,8 +25514,6 @@ var {
25562
25514
  DELETE_TABLE,
25563
25515
  MERGE_CELL,
25564
25516
  CANCEL_MERGE_CELL,
25565
- TD_BG_COLOR,
25566
- TD_BORDER_COLOR,
25567
25517
  TD_PADDING,
25568
25518
  TD_PADDING_COMPACT,
25569
25519
  TD_PADDING_NORMAL,
@@ -25834,86 +25784,6 @@ var tableMenus = [
25834
25784
  command.executeCancelMergeTableCell();
25835
25785
  }
25836
25786
  },
25837
- {
25838
- key: TD_BG_COLOR,
25839
- i18nPath: "contextmenu.table.cellBackgroundColor",
25840
- icon: "td-bg-color",
25841
- when: (payload) => {
25842
- return !payload.isReadonly && payload.isInTable && payload.options.mode !== "form" /* FORM */;
25843
- },
25844
- childMenus: [
25845
- ...COLOR_PALETTE.map((c) => ({
25846
- key: `${TD_BG_COLOR}_${c.value}`,
25847
- name: c.name,
25848
- color: c.value,
25849
- when: () => true,
25850
- callback: (command) => {
25851
- command.executeTableTdBackgroundColor(c.value);
25852
- }
25853
- })),
25854
- {
25855
- isDivider: true
25856
- },
25857
- {
25858
- key: `${TD_BG_COLOR}_custom`,
25859
- name: "Custom color...",
25860
- when: () => true,
25861
- callback: (command) => {
25862
- openNativeColorPicker("#ffffff", (color) => {
25863
- command.executeTableTdBackgroundColor(color);
25864
- });
25865
- }
25866
- },
25867
- {
25868
- key: `${TD_BG_COLOR}_none`,
25869
- name: "No fill",
25870
- when: () => true,
25871
- callback: (command) => {
25872
- command.executeTableTdBackgroundColor("");
25873
- }
25874
- }
25875
- ]
25876
- },
25877
- {
25878
- key: TD_BORDER_COLOR,
25879
- i18nPath: "contextmenu.table.tdBorderColor",
25880
- icon: "td-border-color",
25881
- when: (payload) => {
25882
- return !payload.isReadonly && payload.isInTable && payload.options.mode !== "form" /* FORM */;
25883
- },
25884
- childMenus: [
25885
- ...COLOR_PALETTE.map((c) => ({
25886
- key: `${TD_BORDER_COLOR}_${c.value}`,
25887
- name: c.name,
25888
- color: c.value,
25889
- when: () => true,
25890
- callback: (command) => {
25891
- command.executeTableTdBorderColor(c.value);
25892
- }
25893
- })),
25894
- {
25895
- isDivider: true
25896
- },
25897
- {
25898
- key: `${TD_BORDER_COLOR}_custom`,
25899
- name: "Custom color...",
25900
- when: () => true,
25901
- callback: (command) => {
25902
- openNativeColorPicker("#000000", (color) => {
25903
- command.executeTableTdBorderColor(color);
25904
- });
25905
- }
25906
- },
25907
- {
25908
- key: `${TD_BORDER_COLOR}_reset`,
25909
- name: "Reset to default",
25910
- when: () => true,
25911
- callback: (command) => {
25912
- command.executeTableTdBorderColor("");
25913
- }
25914
- }
25915
- ]
25916
- },
25917
25787
  {
25918
25788
  key: TD_PADDING,
25919
25789
  i18nPath: "contextmenu.table.cellPadding",
@@ -26185,7 +26055,9 @@ var ContextMenu = class {
26185
26055
  const contextMenuWidth = contextmenuRect.width;
26186
26056
  const adjustLeft = left2 + contextMenuWidth > innerWidth ? left2 - contextMenuWidth : left2;
26187
26057
  contextMenuContainer.style.left = `${adjustLeft}px`;
26188
- const innerHeight = window.innerHeight;
26058
+ const footerEl = document.querySelector(".ce-editor-footer");
26059
+ const footerHeight = footerEl ? footerEl.offsetHeight : 0;
26060
+ const innerHeight = window.innerHeight - footerHeight;
26189
26061
  const contextMenuHeight = contextmenuRect.height;
26190
26062
  const adjustTop = top + contextMenuHeight > innerHeight ? top - contextMenuHeight : top;
26191
26063
  contextMenuContainer.style.top = `${adjustTop}px`;