@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.
package/AGENTS.md CHANGED
@@ -5,6 +5,8 @@ This file is for coding agents and automation tools that need to use `@undervers
5
5
  ## Package Summary
6
6
 
7
7
  - Package: `@underverse-ui/underverse`
8
+ - Visibility: public on npm
9
+ - License: MIT
8
10
  - Runtime: React 18+ (supports Next.js and standalone React)
9
11
  - Main entry: `@underverse-ui/underverse`
10
12
  - Type definitions: `dist/index.d.ts`
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "2.0.22",
3
+ "version": "2.0.24",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 260,
6
6
  "exports": [
@@ -55,7 +55,7 @@ import {
55
55
  sanitizeUEditorUrl,
56
56
  useEditorColors,
57
57
  useSharedEditorUiRenderState
58
- } from "./chunk-LWAKD7EK.js";
58
+ } from "./chunk-O7AAN6W6.js";
59
59
  import {
60
60
  Tooltip,
61
61
  UEditorPortalProvider,
@@ -11534,6 +11534,22 @@ import {
11534
11534
  // src/components/UEditor/table-layout-model.ts
11535
11535
  var FALLBACK_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
11536
11536
  var FALLBACK_TABLE_COLUMN_WIDTH = 160;
11537
+ function isTableCellElement(element) {
11538
+ const realm = element?.ownerDocument?.defaultView;
11539
+ return Boolean(realm && element instanceof realm.HTMLTableCellElement);
11540
+ }
11541
+ function isTableRowElement(element) {
11542
+ const realm = element?.ownerDocument?.defaultView;
11543
+ return Boolean(realm && element instanceof realm.HTMLTableRowElement);
11544
+ }
11545
+ function isTableElement(element) {
11546
+ const realm = element?.ownerDocument?.defaultView;
11547
+ return Boolean(realm && element instanceof realm.HTMLTableElement);
11548
+ }
11549
+ function isHTMLElement(element) {
11550
+ const realm = element?.ownerDocument?.defaultView;
11551
+ return Boolean(realm && element instanceof realm.HTMLElement);
11552
+ }
11537
11553
  function getVisibleTableBounds(layout) {
11538
11554
  const left = Math.max(layout.tableLeft, layout.wrapperLeft);
11539
11555
  const top = Math.max(layout.tableTop, layout.wrapperTop);
@@ -11558,23 +11574,23 @@ function parsePixelMetric(value) {
11558
11574
  }
11559
11575
  function getPrimaryCell(table) {
11560
11576
  const cell = table.querySelector("th,td");
11561
- return cell instanceof HTMLTableCellElement ? cell : null;
11577
+ return isTableCellElement(cell) ? cell : null;
11562
11578
  }
11563
11579
  function getLastCell(table) {
11564
11580
  const lastRow = table.rows.item(table.rows.length - 1);
11565
- if (!(lastRow instanceof HTMLTableRowElement)) return null;
11581
+ if (!isTableRowElement(lastRow)) return null;
11566
11582
  const cell = lastRow.cells.item(lastRow.cells.length - 1);
11567
- return cell instanceof HTMLTableCellElement ? cell : null;
11583
+ return isTableCellElement(cell) ? cell : null;
11568
11584
  }
11569
11585
  function getCellFromTarget(target) {
11570
11586
  const element = resolveEventElement(target);
11571
11587
  if (!element) return null;
11572
11588
  const directCell = element.closest("th,td");
11573
- if (directCell instanceof HTMLTableCellElement) {
11589
+ if (isTableCellElement(directCell)) {
11574
11590
  return directCell;
11575
11591
  }
11576
11592
  const table = element.closest("table");
11577
- if (table instanceof HTMLTableElement) {
11593
+ if (isTableElement(table)) {
11578
11594
  return getPrimaryCell(table);
11579
11595
  }
11580
11596
  return null;
@@ -11620,7 +11636,7 @@ function buildLogicalColumnMetrics({
11620
11636
  const visualColumns = [];
11621
11637
  if (firstRow) {
11622
11638
  for (const tableCell of Array.from(firstRow.cells)) {
11623
- if (!(tableCell instanceof HTMLTableCellElement)) continue;
11639
+ if (!isTableCellElement(tableCell)) continue;
11624
11640
  const cellPos = editor.view.posAtDOM(tableCell, 0);
11625
11641
  const relativeCellPos = getCellRelativePosFromDomPos(map, tableInfo.start, cellPos);
11626
11642
  if (relativeCellPos == null) continue;
@@ -11677,7 +11693,8 @@ function buildLogicalRowMetrics({
11677
11693
  seenCellPositions.add(relativeCellPos);
11678
11694
  const cellMapRect = map.findCell(relativeCellPos);
11679
11695
  const cellDom = editor.view.nodeDOM(tableInfo.start + relativeCellPos);
11680
- const tableCell = cellDom instanceof HTMLTableCellElement ? cellDom : null;
11696
+ const cellCandidate = cellDom;
11697
+ const tableCell = isTableCellElement(cellCandidate) ? cellCandidate : null;
11681
11698
  if (tableCell) {
11682
11699
  const cellRect = tableCell.getBoundingClientRect();
11683
11700
  const start = cellRect.height > 0 ? cellRect.top - surfaceRect.top + surface.scrollTop : tableTop + cellMapRect.top * fallbackHeight;
@@ -11727,14 +11744,14 @@ function getTableCellTextSelectionRange(editor, cellPos) {
11727
11744
  function buildTableControlLayout(editor, surface, cell) {
11728
11745
  const row = cell.closest("tr");
11729
11746
  const table = cell.closest("table");
11730
- if (!(row instanceof HTMLTableRowElement) || !(table instanceof HTMLTableElement)) {
11747
+ if (!isTableRowElement(row) || !isTableElement(table)) {
11731
11748
  return null;
11732
11749
  }
11733
- const rows = Array.from(table.rows).filter((item) => item instanceof HTMLTableRowElement);
11750
+ const rows = Array.from(table.rows).filter(isTableRowElement);
11734
11751
  const cornerCell = getLastCell(table);
11735
11752
  const cellPos = editor.view.posAtDOM(cell, 0);
11736
11753
  const tableInfo = findTableInfo(editor, cellPos);
11737
- if (rows.length === 0 || !tableInfo || !(cornerCell instanceof HTMLTableCellElement)) {
11754
+ if (rows.length === 0 || !tableInfo || !isTableCellElement(cornerCell)) {
11738
11755
  return null;
11739
11756
  }
11740
11757
  const map = TableMap3.get(tableInfo.node);
@@ -11745,7 +11762,7 @@ function buildTableControlLayout(editor, surface, cell) {
11745
11762
  const explicitRowHeights = rows.map((tableRow) => parsePixelMetric(tableRow.getAttribute("data-row-height")) ?? parsePixelMetric(tableRow.style.height));
11746
11763
  const explicitTableHeight = explicitRowHeights.every((height) => height !== null) ? explicitRowHeights.reduce((sum, height) => sum + height, 0) : null;
11747
11764
  const wrapperElement = table.closest(".tableWrapper");
11748
- const wrapper = wrapperElement instanceof HTMLElement ? wrapperElement : null;
11765
+ const wrapper = isHTMLElement(wrapperElement) ? wrapperElement : null;
11749
11766
  const wrapperRect = wrapper?.getBoundingClientRect() ?? tableRect;
11750
11767
  const tableLeft = tableRect.left - surfaceRect.left + surface.scrollLeft;
11751
11768
  const tableTop = tableRect.top - surfaceRect.top + surface.scrollTop;
@@ -11814,6 +11831,10 @@ var COLUMN_HANDLE_HOVER_HEIGHT = 28;
11814
11831
  var ADD_COLUMN_HOVER_WIDTH = 24;
11815
11832
  var ADD_ROW_HOVER_HEIGHT = 24;
11816
11833
  var HANDLE_HOVER_RADIUS = 14;
11834
+ function isHTMLElement2(element) {
11835
+ const realm = element?.ownerDocument?.defaultView;
11836
+ return Boolean(realm && element instanceof realm.HTMLElement);
11837
+ }
11817
11838
  var DEFAULT_TABLE_HOVER_STATE = {
11818
11839
  menuVisible: false,
11819
11840
  addColumnVisible: false,
@@ -11841,8 +11862,8 @@ function buildTableHoverState({
11841
11862
  const directTableMenu = targetElement?.closest?.("[data-table-control='table-menu']");
11842
11863
  const directAddColumn = targetElement?.closest?.("[data-table-control='add-column']");
11843
11864
  const directAddRow = targetElement?.closest?.("[data-table-control='add-row']");
11844
- const directRowHandleIndex = directRowHandle instanceof HTMLElement && relativeX <= layout.tableLeft ? Number.parseInt(directRowHandle.dataset.rowHandleIndex ?? "", 10) : Number.NaN;
11845
- const directColumnHandleIndex = directColumnHandle instanceof HTMLElement && relativeY <= layout.tableTop ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
11865
+ const directRowHandleIndex = isHTMLElement2(directRowHandle) && relativeX <= layout.tableLeft ? Number.parseInt(directRowHandle.dataset.rowHandleIndex ?? "", 10) : Number.NaN;
11866
+ const directColumnHandleIndex = isHTMLElement2(directColumnHandle) && relativeY <= layout.tableTop ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
11846
11867
  const visibleBounds = getVisibleTableBounds(layout);
11847
11868
  const rowRailTop = layout.wrapperTop + layout.wrapperHeight;
11848
11869
  const isMouseInTable = relativeX >= layout.tableLeft && relativeX <= layout.tableLeft + layout.tableWidth && relativeY >= layout.tableTop && relativeY <= layout.tableTop + layout.tableHeight;
@@ -14504,7 +14525,7 @@ function useUEditorOutput({
14504
14525
  // src/components/UEditor/UEditor.tsx
14505
14526
  import { jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
14506
14527
  var LazyMenuBar = React15.lazy(async () => {
14507
- const { MenuBar } = await import("./menu-bar-5FG5RVXQ.js");
14528
+ const { MenuBar } = await import("./menu-bar-E7MNW6UC.js");
14508
14529
  return { default: MenuBar };
14509
14530
  });
14510
14531
  var UEditor = React15.forwardRef(({
@@ -14973,4 +14994,4 @@ export {
14973
14994
  prepareUEditorContentForSave,
14974
14995
  UEditor_default
14975
14996
  };
14976
- //# sourceMappingURL=chunk-EVY3BTAU.js.map
14997
+ //# sourceMappingURL=chunk-HGOTCQXL.js.map