@underverse-ui/underverse 2.0.26 → 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,6 +1,6 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "2.0.26",
3
+ "version": "2.0.28",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 263,
6
6
  "exports": [
@@ -2775,6 +2775,24 @@ var COLUMN_RESIZE_LINE_THICKNESS = 2;
2775
2775
  var ROW_RESIZE_LINE_THICKNESS = 2;
2776
2776
  var UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
2777
2777
  var isRowResizingGlobal = { active: false };
2778
+ function isCrossRealmNode(value) {
2779
+ return Boolean(value && typeof value === "object" && value.nodeType != null);
2780
+ }
2781
+ function isCrossRealmElement(value) {
2782
+ return isCrossRealmNode(value) && value.nodeType === 1 && typeof value.closest === "function";
2783
+ }
2784
+ function isCrossRealmHTMLElement(value) {
2785
+ return isCrossRealmElement(value) && typeof value.style === "object";
2786
+ }
2787
+ function isCrossRealmTable(value) {
2788
+ return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TABLE" && "rows" in value;
2789
+ }
2790
+ function isCrossRealmTableRow(value) {
2791
+ return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TR" && "cells" in value;
2792
+ }
2793
+ function isCrossRealmTableCell(value) {
2794
+ return isCrossRealmElement(value) && ["TD", "TH"].includes(String(value.tagName).toUpperCase()) && "cellIndex" in value;
2795
+ }
2778
2796
  var TABLE_RESIZE_HIT_ZONE = 5;
2779
2797
  function findTableRowNodeInfo(view, rowElement) {
2780
2798
  const firstCell = rowElement.querySelector("th,td");
@@ -2793,10 +2811,8 @@ function findTableRowNodeInfo(view, rowElement) {
2793
2811
  return null;
2794
2812
  }
2795
2813
  function resolveEventElement(target) {
2796
- const ownerDocument = target?.ownerDocument;
2797
- const realm = ownerDocument?.defaultView;
2798
- if (realm && target instanceof realm.Element) return target;
2799
- if (realm && target instanceof realm.Node) return target.parentElement;
2814
+ if (isCrossRealmElement(target)) return target;
2815
+ if (isCrossRealmNode(target)) return target.parentElement;
2800
2816
  return null;
2801
2817
  }
2802
2818
  function isPointOverRenderedText(root, clientX, clientY) {
@@ -2891,24 +2907,28 @@ function isRowResizeHotspot(cell, clientX, clientY) {
2891
2907
  }
2892
2908
  function getRelativeBoundaryMetrics(surface, table, row, cell) {
2893
2909
  const surfaceRect = surface.getBoundingClientRect();
2910
+ const originLeft = surfaceRect.left + surface.clientLeft;
2911
+ const originTop = surfaceRect.top + surface.clientTop;
2894
2912
  const tableRect = table.getBoundingClientRect();
2895
2913
  const rowRect = row.getBoundingClientRect();
2896
2914
  const cellRect = cell.getBoundingClientRect();
2897
2915
  return {
2898
- left: tableRect.left - surfaceRect.left + surface.scrollLeft,
2899
- top: tableRect.top - surfaceRect.top + surface.scrollTop,
2916
+ left: tableRect.left - originLeft + surface.scrollLeft,
2917
+ top: tableRect.top - originTop + surface.scrollTop,
2900
2918
  width: tableRect.width,
2901
2919
  height: tableRect.height,
2902
- rowBottom: rowRect.bottom - surfaceRect.top + surface.scrollTop,
2903
- columnRight: cellRect.right - surfaceRect.left + surface.scrollLeft
2920
+ rowBottom: rowRect.bottom - originTop + surface.scrollTop,
2921
+ columnRight: cellRect.right - originLeft + surface.scrollLeft
2904
2922
  };
2905
2923
  }
2906
2924
  function getRelativeCellMetrics(surface, cell) {
2907
2925
  const surfaceRect = surface.getBoundingClientRect();
2926
+ const originLeft = surfaceRect.left + surface.clientLeft;
2927
+ const originTop = surfaceRect.top + surface.clientTop;
2908
2928
  const cellRect = cell.getBoundingClientRect();
2909
2929
  return {
2910
- left: cellRect.left - surfaceRect.left + surface.scrollLeft,
2911
- top: cellRect.top - surfaceRect.top + surface.scrollTop,
2930
+ left: cellRect.left - originLeft + surface.scrollLeft,
2931
+ top: cellRect.top - originTop + surface.scrollTop,
2912
2932
  width: cellRect.width,
2913
2933
  height: cellRect.height
2914
2934
  };
@@ -2921,6 +2941,8 @@ function getRelativeSelectedCellsMetrics(surface) {
2921
2941
  return null;
2922
2942
  }
2923
2943
  const surfaceRect = surface.getBoundingClientRect();
2944
+ const originLeft = surfaceRect.left + surface.clientLeft;
2945
+ const originTop = surfaceRect.top + surface.clientTop;
2924
2946
  let left = Number.POSITIVE_INFINITY;
2925
2947
  let top = Number.POSITIVE_INFINITY;
2926
2948
  let right = Number.NEGATIVE_INFINITY;
@@ -2933,8 +2955,8 @@ function getRelativeSelectedCellsMetrics(surface) {
2933
2955
  bottom = Math.max(bottom, rect.bottom);
2934
2956
  });
2935
2957
  return {
2936
- left: left - surfaceRect.left + surface.scrollLeft,
2937
- top: top - surfaceRect.top + surface.scrollTop,
2958
+ left: left - originLeft + surface.scrollLeft,
2959
+ top: top - originTop + surface.scrollTop,
2938
2960
  width: right - left,
2939
2961
  height: bottom - top
2940
2962
  };
@@ -2973,8 +2995,8 @@ function applyTableAlignment(editor, tableAlign, anchorPos) {
2973
2995
  const domAtTable = editor.view.domAtPos(Math.min(tableInfo.pos + 1, editor.state.doc.content.size)).node;
2974
2996
  const domAtTableElement = resolveEventElement(domAtTable);
2975
2997
  const tableDom = editor.view.nodeDOM(tableInfo.pos);
2976
- const tableElement = domAtTableElement?.closest?.("table") ?? (tableDom instanceof HTMLTableElement ? tableDom : tableDom instanceof HTMLElement ? tableDom.querySelector("table") : null) ?? (editor.view.dom.querySelectorAll("table").length === 1 ? editor.view.dom.querySelector("table") : null);
2977
- if (tableElement instanceof HTMLTableElement) {
2998
+ const tableElement = domAtTableElement?.closest?.("table") ?? (isCrossRealmTable(tableDom) ? tableDom : isCrossRealmHTMLElement(tableDom) ? tableDom.querySelector("table") : null) ?? (editor.view.dom.querySelectorAll("table").length === 1 ? editor.view.dom.querySelector("table") : null);
2999
+ if (isCrossRealmTable(tableElement)) {
2978
3000
  tableElement.style.tableLayout = "fixed";
2979
3001
  if (tableElement.style.width === "max-content") {
2980
3002
  tableElement.style.removeProperty("width");
@@ -4756,6 +4778,12 @@ export {
4756
4778
  ROW_RESIZE_LINE_THICKNESS,
4757
4779
  UEDITOR_TABLE_LAYOUT_CHANGE_EVENT,
4758
4780
  isRowResizingGlobal,
4781
+ isCrossRealmNode,
4782
+ isCrossRealmElement,
4783
+ isCrossRealmHTMLElement,
4784
+ isCrossRealmTable,
4785
+ isCrossRealmTableRow,
4786
+ isCrossRealmTableCell,
4759
4787
  findTableRowNodeInfo,
4760
4788
  resolveEventElement,
4761
4789
  isPointOverRenderedText,
@@ -4801,4 +4829,4 @@ export {
4801
4829
  EditorToolbar,
4802
4830
  UEDITOR_PROSEMIRROR_CLASS_NAME
4803
4831
  };
4804
- //# sourceMappingURL=chunk-OJF3XRN7.js.map
4832
+ //# sourceMappingURL=chunk-KTOXCD6J.js.map