@underverse-ui/underverse 2.0.22 → 2.0.24

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-LWAKD7EK.js";
4
+ } from "./chunk-O7AAN6W6.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-F6KCGIJX.js.map
199
+ //# sourceMappingURL=chunk-ZQWVWDGS.js.map
package/dist/index.cjs CHANGED
@@ -4391,7 +4391,7 @@ var init_Popover = __esm({
4391
4391
  const measuredHeight = positionerEl.offsetHeight;
4392
4392
  const contentRect = positionerEl.getBoundingClientRect();
4393
4393
  const contentBoxWidth = measuredWidth || contentRect.width;
4394
- const contentBoxHeight = Math.max(measuredHeight, contentRect.height, contentEl.scrollHeight);
4394
+ const contentBoxHeight = Math.max(measuredHeight, contentRect.height);
4395
4395
  const next = computePopoverPosition({
4396
4396
  triggerRect,
4397
4397
  contentSize: { width: contentBoxWidth, height: contentBoxHeight },
@@ -45357,6 +45357,22 @@ init_table_dom_utils();
45357
45357
  init_table_dom_utils();
45358
45358
  var FALLBACK_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
45359
45359
  var FALLBACK_TABLE_COLUMN_WIDTH = 160;
45360
+ function isTableCellElement(element) {
45361
+ const realm = element?.ownerDocument?.defaultView;
45362
+ return Boolean(realm && element instanceof realm.HTMLTableCellElement);
45363
+ }
45364
+ function isTableRowElement(element) {
45365
+ const realm = element?.ownerDocument?.defaultView;
45366
+ return Boolean(realm && element instanceof realm.HTMLTableRowElement);
45367
+ }
45368
+ function isTableElement(element) {
45369
+ const realm = element?.ownerDocument?.defaultView;
45370
+ return Boolean(realm && element instanceof realm.HTMLTableElement);
45371
+ }
45372
+ function isHTMLElement(element) {
45373
+ const realm = element?.ownerDocument?.defaultView;
45374
+ return Boolean(realm && element instanceof realm.HTMLElement);
45375
+ }
45360
45376
  function getVisibleTableBounds(layout) {
45361
45377
  const left = Math.max(layout.tableLeft, layout.wrapperLeft);
45362
45378
  const top = Math.max(layout.tableTop, layout.wrapperTop);
@@ -45381,23 +45397,23 @@ function parsePixelMetric(value) {
45381
45397
  }
45382
45398
  function getPrimaryCell(table) {
45383
45399
  const cell = table.querySelector("th,td");
45384
- return cell instanceof HTMLTableCellElement ? cell : null;
45400
+ return isTableCellElement(cell) ? cell : null;
45385
45401
  }
45386
45402
  function getLastCell(table) {
45387
45403
  const lastRow = table.rows.item(table.rows.length - 1);
45388
- if (!(lastRow instanceof HTMLTableRowElement)) return null;
45404
+ if (!isTableRowElement(lastRow)) return null;
45389
45405
  const cell = lastRow.cells.item(lastRow.cells.length - 1);
45390
- return cell instanceof HTMLTableCellElement ? cell : null;
45406
+ return isTableCellElement(cell) ? cell : null;
45391
45407
  }
45392
45408
  function getCellFromTarget(target) {
45393
45409
  const element = resolveEventElement(target);
45394
45410
  if (!element) return null;
45395
45411
  const directCell = element.closest("th,td");
45396
- if (directCell instanceof HTMLTableCellElement) {
45412
+ if (isTableCellElement(directCell)) {
45397
45413
  return directCell;
45398
45414
  }
45399
45415
  const table = element.closest("table");
45400
- if (table instanceof HTMLTableElement) {
45416
+ if (isTableElement(table)) {
45401
45417
  return getPrimaryCell(table);
45402
45418
  }
45403
45419
  return null;
@@ -45443,7 +45459,7 @@ function buildLogicalColumnMetrics({
45443
45459
  const visualColumns = [];
45444
45460
  if (firstRow) {
45445
45461
  for (const tableCell of Array.from(firstRow.cells)) {
45446
- if (!(tableCell instanceof HTMLTableCellElement)) continue;
45462
+ if (!isTableCellElement(tableCell)) continue;
45447
45463
  const cellPos = editor.view.posAtDOM(tableCell, 0);
45448
45464
  const relativeCellPos = getCellRelativePosFromDomPos(map, tableInfo.start, cellPos);
45449
45465
  if (relativeCellPos == null) continue;
@@ -45500,7 +45516,8 @@ function buildLogicalRowMetrics({
45500
45516
  seenCellPositions.add(relativeCellPos);
45501
45517
  const cellMapRect = map.findCell(relativeCellPos);
45502
45518
  const cellDom = editor.view.nodeDOM(tableInfo.start + relativeCellPos);
45503
- const tableCell = cellDom instanceof HTMLTableCellElement ? cellDom : null;
45519
+ const cellCandidate = cellDom;
45520
+ const tableCell = isTableCellElement(cellCandidate) ? cellCandidate : null;
45504
45521
  if (tableCell) {
45505
45522
  const cellRect = tableCell.getBoundingClientRect();
45506
45523
  const start = cellRect.height > 0 ? cellRect.top - surfaceRect.top + surface.scrollTop : tableTop + cellMapRect.top * fallbackHeight;
@@ -45550,14 +45567,14 @@ function getTableCellTextSelectionRange(editor, cellPos) {
45550
45567
  function buildTableControlLayout(editor, surface, cell) {
45551
45568
  const row = cell.closest("tr");
45552
45569
  const table = cell.closest("table");
45553
- if (!(row instanceof HTMLTableRowElement) || !(table instanceof HTMLTableElement)) {
45570
+ if (!isTableRowElement(row) || !isTableElement(table)) {
45554
45571
  return null;
45555
45572
  }
45556
- const rows = Array.from(table.rows).filter((item) => item instanceof HTMLTableRowElement);
45573
+ const rows = Array.from(table.rows).filter(isTableRowElement);
45557
45574
  const cornerCell = getLastCell(table);
45558
45575
  const cellPos = editor.view.posAtDOM(cell, 0);
45559
45576
  const tableInfo = findTableInfo(editor, cellPos);
45560
- if (rows.length === 0 || !tableInfo || !(cornerCell instanceof HTMLTableCellElement)) {
45577
+ if (rows.length === 0 || !tableInfo || !isTableCellElement(cornerCell)) {
45561
45578
  return null;
45562
45579
  }
45563
45580
  const map = TableMap4.get(tableInfo.node);
@@ -45568,7 +45585,7 @@ function buildTableControlLayout(editor, surface, cell) {
45568
45585
  const explicitRowHeights = rows.map((tableRow) => parsePixelMetric(tableRow.getAttribute("data-row-height")) ?? parsePixelMetric(tableRow.style.height));
45569
45586
  const explicitTableHeight = explicitRowHeights.every((height) => height !== null) ? explicitRowHeights.reduce((sum, height) => sum + height, 0) : null;
45570
45587
  const wrapperElement = table.closest(".tableWrapper");
45571
- const wrapper = wrapperElement instanceof HTMLElement ? wrapperElement : null;
45588
+ const wrapper = isHTMLElement(wrapperElement) ? wrapperElement : null;
45572
45589
  const wrapperRect = wrapper?.getBoundingClientRect() ?? tableRect;
45573
45590
  const tableLeft = tableRect.left - surfaceRect.left + surface.scrollLeft;
45574
45591
  const tableTop = tableRect.top - surfaceRect.top + surface.scrollTop;
@@ -45637,6 +45654,10 @@ var COLUMN_HANDLE_HOVER_HEIGHT = 28;
45637
45654
  var ADD_COLUMN_HOVER_WIDTH = 24;
45638
45655
  var ADD_ROW_HOVER_HEIGHT = 24;
45639
45656
  var HANDLE_HOVER_RADIUS = 14;
45657
+ function isHTMLElement2(element) {
45658
+ const realm = element?.ownerDocument?.defaultView;
45659
+ return Boolean(realm && element instanceof realm.HTMLElement);
45660
+ }
45640
45661
  var DEFAULT_TABLE_HOVER_STATE = {
45641
45662
  menuVisible: false,
45642
45663
  addColumnVisible: false,
@@ -45664,8 +45685,8 @@ function buildTableHoverState({
45664
45685
  const directTableMenu = targetElement?.closest?.("[data-table-control='table-menu']");
45665
45686
  const directAddColumn = targetElement?.closest?.("[data-table-control='add-column']");
45666
45687
  const directAddRow = targetElement?.closest?.("[data-table-control='add-row']");
45667
- const directRowHandleIndex = directRowHandle instanceof HTMLElement && relativeX <= layout.tableLeft ? Number.parseInt(directRowHandle.dataset.rowHandleIndex ?? "", 10) : Number.NaN;
45668
- const directColumnHandleIndex = directColumnHandle instanceof HTMLElement && relativeY <= layout.tableTop ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
45688
+ const directRowHandleIndex = isHTMLElement2(directRowHandle) && relativeX <= layout.tableLeft ? Number.parseInt(directRowHandle.dataset.rowHandleIndex ?? "", 10) : Number.NaN;
45689
+ const directColumnHandleIndex = isHTMLElement2(directColumnHandle) && relativeY <= layout.tableTop ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
45669
45690
  const visibleBounds = getVisibleTableBounds(layout);
45670
45691
  const rowRailTop = layout.wrapperTop + layout.wrapperHeight;
45671
45692
  const isMouseInTable = relativeX >= layout.tableLeft && relativeX <= layout.tableLeft + layout.tableWidth && relativeY >= layout.tableTop && relativeY <= layout.tableTop + layout.tableHeight;