@underverse-ui/underverse 2.0.27 → 2.0.28

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getPanelBorderRadiusClass,
3
3
  useUnderverseUIConfig
4
- } from "./chunk-BDRCOIYR.js";
4
+ } from "./chunk-KTOXCD6J.js";
5
5
  import {
6
6
  cn,
7
7
  useGlobalI18n
@@ -196,4 +196,4 @@ var Modal_default = Modal;
196
196
  export {
197
197
  Modal_default
198
198
  };
199
- //# sourceMappingURL=chunk-HVJ3R6LP.js.map
199
+ //# sourceMappingURL=chunk-Y4X6CAZY.js.map
package/dist/index.cjs CHANGED
@@ -6131,24 +6131,28 @@ function isRowResizeHotspot(cell, clientX, clientY) {
6131
6131
  }
6132
6132
  function getRelativeBoundaryMetrics(surface, table, row, cell) {
6133
6133
  const surfaceRect = surface.getBoundingClientRect();
6134
+ const originLeft = surfaceRect.left + surface.clientLeft;
6135
+ const originTop = surfaceRect.top + surface.clientTop;
6134
6136
  const tableRect = table.getBoundingClientRect();
6135
6137
  const rowRect = row.getBoundingClientRect();
6136
6138
  const cellRect = cell.getBoundingClientRect();
6137
6139
  return {
6138
- left: tableRect.left - surfaceRect.left + surface.scrollLeft,
6139
- top: tableRect.top - surfaceRect.top + surface.scrollTop,
6140
+ left: tableRect.left - originLeft + surface.scrollLeft,
6141
+ top: tableRect.top - originTop + surface.scrollTop,
6140
6142
  width: tableRect.width,
6141
6143
  height: tableRect.height,
6142
- rowBottom: rowRect.bottom - surfaceRect.top + surface.scrollTop,
6143
- columnRight: cellRect.right - surfaceRect.left + surface.scrollLeft
6144
+ rowBottom: rowRect.bottom - originTop + surface.scrollTop,
6145
+ columnRight: cellRect.right - originLeft + surface.scrollLeft
6144
6146
  };
6145
6147
  }
6146
6148
  function getRelativeCellMetrics(surface, cell) {
6147
6149
  const surfaceRect = surface.getBoundingClientRect();
6150
+ const originLeft = surfaceRect.left + surface.clientLeft;
6151
+ const originTop = surfaceRect.top + surface.clientTop;
6148
6152
  const cellRect = cell.getBoundingClientRect();
6149
6153
  return {
6150
- left: cellRect.left - surfaceRect.left + surface.scrollLeft,
6151
- top: cellRect.top - surfaceRect.top + surface.scrollTop,
6154
+ left: cellRect.left - originLeft + surface.scrollLeft,
6155
+ top: cellRect.top - originTop + surface.scrollTop,
6152
6156
  width: cellRect.width,
6153
6157
  height: cellRect.height
6154
6158
  };
@@ -6161,6 +6165,8 @@ function getRelativeSelectedCellsMetrics(surface) {
6161
6165
  return null;
6162
6166
  }
6163
6167
  const surfaceRect = surface.getBoundingClientRect();
6168
+ const originLeft = surfaceRect.left + surface.clientLeft;
6169
+ const originTop = surfaceRect.top + surface.clientTop;
6164
6170
  let left = Number.POSITIVE_INFINITY;
6165
6171
  let top = Number.POSITIVE_INFINITY;
6166
6172
  let right = Number.NEGATIVE_INFINITY;
@@ -6173,8 +6179,8 @@ function getRelativeSelectedCellsMetrics(surface) {
6173
6179
  bottom = Math.max(bottom, rect.bottom);
6174
6180
  });
6175
6181
  return {
6176
- left: left - surfaceRect.left + surface.scrollLeft,
6177
- top: top - surfaceRect.top + surface.scrollTop,
6182
+ left: left - originLeft + surface.scrollLeft,
6183
+ top: top - originTop + surface.scrollTop,
6178
6184
  width: right - left,
6179
6185
  height: bottom - top
6180
6186
  };
@@ -45565,7 +45571,7 @@ function buildLogicalColumnMetrics({
45565
45571
  if (relativeCellPos == null) continue;
45566
45572
  const cellMapRect = map.findCell(relativeCellPos);
45567
45573
  const cellRect = tableCell.getBoundingClientRect();
45568
- const cellStart = cellRect.width > 0 ? cellRect.left - surfaceRect.left + surface.scrollLeft : tableLeft + cellMapRect.left * fallbackWidth;
45574
+ const cellStart = cellRect.width > 0 ? cellRect.left - surfaceRect.left - surface.clientLeft + surface.scrollLeft : tableLeft + cellMapRect.left * fallbackWidth;
45569
45575
  const size = metricOrFallback(cellRect.width, fallbackWidth * Math.max(1, cellMapRect.right - cellMapRect.left));
45570
45576
  visualColumns.push({
45571
45577
  index: cellMapRect.left,
@@ -45620,7 +45626,7 @@ function buildLogicalRowMetrics({
45620
45626
  const tableCell = isTableCellElement(cellCandidate) ? cellCandidate : null;
45621
45627
  if (tableCell) {
45622
45628
  const cellRect = tableCell.getBoundingClientRect();
45623
- const start = cellRect.height > 0 ? cellRect.top - surfaceRect.top + surface.scrollTop : tableTop + cellMapRect.top * fallbackHeight;
45629
+ const start = cellRect.height > 0 ? cellRect.top - surfaceRect.top - surface.clientTop + surface.scrollTop : tableTop + cellMapRect.top * fallbackHeight;
45624
45630
  const size = metricOrFallback(cellRect.height, fallbackHeight * Math.max(1, cellMapRect.bottom - cellMapRect.top));
45625
45631
  visualRows.push({
45626
45632
  index: cellMapRect.top,
@@ -45637,7 +45643,7 @@ function buildLogicalRowMetrics({
45637
45643
  return rows.map((tableRow, index) => {
45638
45644
  const rowRect = tableRow.getBoundingClientRect();
45639
45645
  const anchorCell = tableRow.cells.item(0) ?? cornerCell;
45640
- const start = rowRect.height > 0 ? rowRect.top - surfaceRect.top + surface.scrollTop : tableTop + index * fallbackHeight;
45646
+ const start = rowRect.height > 0 ? rowRect.top - surfaceRect.top - surface.clientTop + surface.scrollTop : tableTop + index * fallbackHeight;
45641
45647
  const size = metricOrFallback(rowRect.height, fallbackHeight);
45642
45648
  return {
45643
45649
  index,
@@ -45679,6 +45685,8 @@ function buildTableControlLayout(editor, surface, cell) {
45679
45685
  }
45680
45686
  const map = TableMap4.get(tableInfo.node);
45681
45687
  const surfaceRect = surface.getBoundingClientRect();
45688
+ const surfaceOriginLeft = surfaceRect.left + surface.clientLeft;
45689
+ const surfaceOriginTop = surfaceRect.top + surface.clientTop;
45682
45690
  const tableRect = table.getBoundingClientRect();
45683
45691
  const explicitColumnWidths = Array.from(table.querySelectorAll("colgroup > col")).slice(0, map.width).map((column) => parsePixelMetric(column.style.width));
45684
45692
  const explicitTableWidth = parsePixelMetric(table.style.width) ?? (explicitColumnWidths.length === map.width && explicitColumnWidths.every((width) => width !== null) ? explicitColumnWidths.reduce((sum, width) => sum + width, 0) : null);
@@ -45687,14 +45695,14 @@ function buildTableControlLayout(editor, surface, cell) {
45687
45695
  const wrapperElement = table.closest(".tableWrapper");
45688
45696
  const wrapper = isHTMLElement(wrapperElement) ? wrapperElement : null;
45689
45697
  const wrapperRect = wrapper?.getBoundingClientRect() ?? tableRect;
45690
- const tableLeft = tableRect.left - surfaceRect.left + surface.scrollLeft;
45691
- const tableTop = tableRect.top - surfaceRect.top + surface.scrollTop;
45698
+ const tableLeft = tableRect.left - surfaceOriginLeft + surface.scrollLeft;
45699
+ const tableTop = tableRect.top - surfaceOriginTop + surface.scrollTop;
45692
45700
  const tableWidth = metricOrFallback(tableRect.width, explicitTableWidth ?? FALLBACK_TABLE_COLUMN_WIDTH * map.width);
45693
45701
  const tableHeight = metricOrFallback(tableRect.height, explicitTableHeight ?? FALLBACK_TABLE_ROW_HEIGHT * rows.length);
45694
45702
  const avgRowHeight = metricOrFallback(tableHeight / rows.length, FALLBACK_TABLE_ROW_HEIGHT);
45695
45703
  const avgColumnWidth = metricOrFallback(tableWidth / map.width, FALLBACK_TABLE_COLUMN_WIDTH);
45696
- const wrapperLeft = wrapperRect.left - surfaceRect.left + surface.scrollLeft;
45697
- const wrapperTop = wrapperRect.top - surfaceRect.top + surface.scrollTop;
45704
+ const wrapperLeft = wrapperRect.left - surfaceOriginLeft + surface.scrollLeft;
45705
+ const wrapperTop = wrapperRect.top - surfaceOriginTop + surface.scrollTop;
45698
45706
  const wrapperWidth = metricOrFallback(wrapperRect.width, tableWidth);
45699
45707
  const wrapperHeight = metricOrFallback(wrapperRect.height, tableHeight);
45700
45708
  const viewportWidth = metricOrFallback(wrapper?.clientWidth ?? wrapperRect.width, tableWidth);
@@ -45776,8 +45784,8 @@ function buildTableHoverState({
45776
45784
  return DEFAULT_TABLE_HOVER_STATE;
45777
45785
  }
45778
45786
  const surfaceRect = surface.getBoundingClientRect();
45779
- const relativeX = event.clientX - surfaceRect.left + surface.scrollLeft;
45780
- const relativeY = event.clientY - surfaceRect.top + surface.scrollTop;
45787
+ const relativeX = event.clientX - surfaceRect.left - surface.clientLeft + surface.scrollLeft;
45788
+ const relativeY = event.clientY - surfaceRect.top - surface.clientTop + surface.scrollTop;
45781
45789
  const targetElement = resolveEventElement(event.target);
45782
45790
  const directRowHandle = targetElement?.closest?.("[data-row-handle-index]");
45783
45791
  const directColumnHandle = targetElement?.closest?.("[data-column-handle-index]");
@@ -46685,6 +46693,7 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
46685
46693
  surface.addEventListener(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, scheduleCurrentLayoutRefresh);
46686
46694
  if (!editorWindow) return void 0;
46687
46695
  const unsubscribeResize = subscribeSharedGlobalEvent(editorWindow, "resize", scheduleCurrentLayoutRefresh);
46696
+ const unsubscribeWindowScroll = subscribeSharedGlobalEvent(editorWindow, "scroll", scheduleCurrentLayoutRefresh, { passive: true });
46688
46697
  editor.on("selectionUpdate", scheduleSyncFromSelection);
46689
46698
  editor.on("update", scheduleCurrentLayoutRefresh);
46690
46699
  syncFromSelection();
@@ -46700,6 +46709,7 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
46700
46709
  surface.removeEventListener("scroll", scheduleCurrentLayoutRefresh, scrollListenerOptions);
46701
46710
  surface.removeEventListener(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, scheduleCurrentLayoutRefresh);
46702
46711
  unsubscribeResize();
46712
+ unsubscribeWindowScroll();
46703
46713
  editor.off("selectionUpdate", scheduleSyncFromSelection);
46704
46714
  editor.off("update", scheduleCurrentLayoutRefresh);
46705
46715
  };