@underverse-ui/underverse 2.0.23 → 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/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  extractImageSrcsFromHtml,
5
5
  normalizeImageUrl,
6
6
  prepareUEditorContentForSave
7
- } from "./chunk-AEMS6WGX.js";
7
+ } from "./chunk-HGOTCQXL.js";
8
8
  import {
9
9
  EmojiPicker_default
10
10
  } from "./chunk-F7MX3XXK.js";
package/dist/ueditor.cjs CHANGED
@@ -20918,6 +20918,22 @@ init_table_dom_utils();
20918
20918
  init_table_dom_utils();
20919
20919
  var FALLBACK_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
20920
20920
  var FALLBACK_TABLE_COLUMN_WIDTH = 160;
20921
+ function isTableCellElement(element) {
20922
+ const realm = element?.ownerDocument?.defaultView;
20923
+ return Boolean(realm && element instanceof realm.HTMLTableCellElement);
20924
+ }
20925
+ function isTableRowElement(element) {
20926
+ const realm = element?.ownerDocument?.defaultView;
20927
+ return Boolean(realm && element instanceof realm.HTMLTableRowElement);
20928
+ }
20929
+ function isTableElement(element) {
20930
+ const realm = element?.ownerDocument?.defaultView;
20931
+ return Boolean(realm && element instanceof realm.HTMLTableElement);
20932
+ }
20933
+ function isHTMLElement(element) {
20934
+ const realm = element?.ownerDocument?.defaultView;
20935
+ return Boolean(realm && element instanceof realm.HTMLElement);
20936
+ }
20921
20937
  function getVisibleTableBounds(layout) {
20922
20938
  const left = Math.max(layout.tableLeft, layout.wrapperLeft);
20923
20939
  const top = Math.max(layout.tableTop, layout.wrapperTop);
@@ -20942,23 +20958,23 @@ function parsePixelMetric(value) {
20942
20958
  }
20943
20959
  function getPrimaryCell(table) {
20944
20960
  const cell = table.querySelector("th,td");
20945
- return cell instanceof HTMLTableCellElement ? cell : null;
20961
+ return isTableCellElement(cell) ? cell : null;
20946
20962
  }
20947
20963
  function getLastCell(table) {
20948
20964
  const lastRow = table.rows.item(table.rows.length - 1);
20949
- if (!(lastRow instanceof HTMLTableRowElement)) return null;
20965
+ if (!isTableRowElement(lastRow)) return null;
20950
20966
  const cell = lastRow.cells.item(lastRow.cells.length - 1);
20951
- return cell instanceof HTMLTableCellElement ? cell : null;
20967
+ return isTableCellElement(cell) ? cell : null;
20952
20968
  }
20953
20969
  function getCellFromTarget(target) {
20954
20970
  const element = resolveEventElement(target);
20955
20971
  if (!element) return null;
20956
20972
  const directCell = element.closest("th,td");
20957
- if (directCell instanceof HTMLTableCellElement) {
20973
+ if (isTableCellElement(directCell)) {
20958
20974
  return directCell;
20959
20975
  }
20960
20976
  const table = element.closest("table");
20961
- if (table instanceof HTMLTableElement) {
20977
+ if (isTableElement(table)) {
20962
20978
  return getPrimaryCell(table);
20963
20979
  }
20964
20980
  return null;
@@ -21004,7 +21020,7 @@ function buildLogicalColumnMetrics({
21004
21020
  const visualColumns = [];
21005
21021
  if (firstRow) {
21006
21022
  for (const tableCell of Array.from(firstRow.cells)) {
21007
- if (!(tableCell instanceof HTMLTableCellElement)) continue;
21023
+ if (!isTableCellElement(tableCell)) continue;
21008
21024
  const cellPos = editor.view.posAtDOM(tableCell, 0);
21009
21025
  const relativeCellPos = getCellRelativePosFromDomPos(map, tableInfo.start, cellPos);
21010
21026
  if (relativeCellPos == null) continue;
@@ -21061,7 +21077,8 @@ function buildLogicalRowMetrics({
21061
21077
  seenCellPositions.add(relativeCellPos);
21062
21078
  const cellMapRect = map.findCell(relativeCellPos);
21063
21079
  const cellDom = editor.view.nodeDOM(tableInfo.start + relativeCellPos);
21064
- const tableCell = cellDom instanceof HTMLTableCellElement ? cellDom : null;
21080
+ const cellCandidate = cellDom;
21081
+ const tableCell = isTableCellElement(cellCandidate) ? cellCandidate : null;
21065
21082
  if (tableCell) {
21066
21083
  const cellRect = tableCell.getBoundingClientRect();
21067
21084
  const start = cellRect.height > 0 ? cellRect.top - surfaceRect.top + surface.scrollTop : tableTop + cellMapRect.top * fallbackHeight;
@@ -21111,14 +21128,14 @@ function getTableCellTextSelectionRange(editor, cellPos) {
21111
21128
  function buildTableControlLayout(editor, surface, cell) {
21112
21129
  const row = cell.closest("tr");
21113
21130
  const table = cell.closest("table");
21114
- if (!(row instanceof HTMLTableRowElement) || !(table instanceof HTMLTableElement)) {
21131
+ if (!isTableRowElement(row) || !isTableElement(table)) {
21115
21132
  return null;
21116
21133
  }
21117
- const rows = Array.from(table.rows).filter((item) => item instanceof HTMLTableRowElement);
21134
+ const rows = Array.from(table.rows).filter(isTableRowElement);
21118
21135
  const cornerCell = getLastCell(table);
21119
21136
  const cellPos = editor.view.posAtDOM(cell, 0);
21120
21137
  const tableInfo = findTableInfo(editor, cellPos);
21121
- if (rows.length === 0 || !tableInfo || !(cornerCell instanceof HTMLTableCellElement)) {
21138
+ if (rows.length === 0 || !tableInfo || !isTableCellElement(cornerCell)) {
21122
21139
  return null;
21123
21140
  }
21124
21141
  const map = TableMap4.get(tableInfo.node);
@@ -21129,7 +21146,7 @@ function buildTableControlLayout(editor, surface, cell) {
21129
21146
  const explicitRowHeights = rows.map((tableRow) => parsePixelMetric(tableRow.getAttribute("data-row-height")) ?? parsePixelMetric(tableRow.style.height));
21130
21147
  const explicitTableHeight = explicitRowHeights.every((height) => height !== null) ? explicitRowHeights.reduce((sum, height) => sum + height, 0) : null;
21131
21148
  const wrapperElement = table.closest(".tableWrapper");
21132
- const wrapper = wrapperElement instanceof HTMLElement ? wrapperElement : null;
21149
+ const wrapper = isHTMLElement(wrapperElement) ? wrapperElement : null;
21133
21150
  const wrapperRect = wrapper?.getBoundingClientRect() ?? tableRect;
21134
21151
  const tableLeft = tableRect.left - surfaceRect.left + surface.scrollLeft;
21135
21152
  const tableTop = tableRect.top - surfaceRect.top + surface.scrollTop;
@@ -21198,6 +21215,10 @@ var COLUMN_HANDLE_HOVER_HEIGHT = 28;
21198
21215
  var ADD_COLUMN_HOVER_WIDTH = 24;
21199
21216
  var ADD_ROW_HOVER_HEIGHT = 24;
21200
21217
  var HANDLE_HOVER_RADIUS = 14;
21218
+ function isHTMLElement2(element) {
21219
+ const realm = element?.ownerDocument?.defaultView;
21220
+ return Boolean(realm && element instanceof realm.HTMLElement);
21221
+ }
21201
21222
  var DEFAULT_TABLE_HOVER_STATE = {
21202
21223
  menuVisible: false,
21203
21224
  addColumnVisible: false,
@@ -21225,8 +21246,8 @@ function buildTableHoverState({
21225
21246
  const directTableMenu = targetElement?.closest?.("[data-table-control='table-menu']");
21226
21247
  const directAddColumn = targetElement?.closest?.("[data-table-control='add-column']");
21227
21248
  const directAddRow = targetElement?.closest?.("[data-table-control='add-row']");
21228
- const directRowHandleIndex = directRowHandle instanceof HTMLElement && relativeX <= layout.tableLeft ? Number.parseInt(directRowHandle.dataset.rowHandleIndex ?? "", 10) : Number.NaN;
21229
- const directColumnHandleIndex = directColumnHandle instanceof HTMLElement && relativeY <= layout.tableTop ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
21249
+ const directRowHandleIndex = isHTMLElement2(directRowHandle) && relativeX <= layout.tableLeft ? Number.parseInt(directRowHandle.dataset.rowHandleIndex ?? "", 10) : Number.NaN;
21250
+ const directColumnHandleIndex = isHTMLElement2(directColumnHandle) && relativeY <= layout.tableTop ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
21230
21251
  const visibleBounds = getVisibleTableBounds(layout);
21231
21252
  const rowRailTop = layout.wrapperTop + layout.wrapperHeight;
21232
21253
  const isMouseInTable = relativeX >= layout.tableLeft && relativeX <= layout.tableLeft + layout.tableWidth && relativeY >= layout.tableTop && relativeY <= layout.tableTop + layout.tableHeight;