@underverse-ui/underverse 2.0.41 → 2.0.43

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.
@@ -32,7 +32,7 @@ import {
32
32
  trackEditorInsertionPosition,
33
33
  useDropdownMenuClose,
34
34
  useSharedEditorUiRenderState
35
- } from "./chunk-TVCZXO6G.js";
35
+ } from "./chunk-4IJ53MI3.js";
36
36
  import "./chunk-IW6FSDIT.js";
37
37
  import "./chunk-PNUDVGMI.js";
38
38
  import {
@@ -1147,4 +1147,4 @@ var MenuBar = ({
1147
1147
  export {
1148
1148
  MenuBar
1149
1149
  };
1150
- //# sourceMappingURL=menu-bar-67LDC7IR.js.map
1150
+ //# sourceMappingURL=menu-bar-SGKLM6IK.js.map
package/dist/ueditor.cjs CHANGED
@@ -4597,6 +4597,7 @@ var init_DatePicker = __esm({
4597
4597
  id,
4598
4598
  value,
4599
4599
  onChange,
4600
+ formatDate,
4600
4601
  placeholder,
4601
4602
  className,
4602
4603
  disabled = false,
@@ -4805,6 +4806,9 @@ var init_DatePicker = __esm({
4805
4806
  setIsOpen(false);
4806
4807
  };
4807
4808
  const formatDateDisplay = (date) => {
4809
+ if (formatDate) {
4810
+ return formatDate(date);
4811
+ }
4808
4812
  return date.toLocaleDateString(locale === "vi" ? "vi-VN" : "en-US", {
4809
4813
  day: "numeric",
4810
4814
  month: "long",
@@ -5264,6 +5268,7 @@ var init_DatePicker = __esm({
5264
5268
  startDate,
5265
5269
  endDate,
5266
5270
  onChange,
5271
+ formatDate,
5267
5272
  placeholder = "Select date range...",
5268
5273
  className,
5269
5274
  label,
@@ -5296,10 +5301,11 @@ var init_DatePicker = __esm({
5296
5301
  }, []);
5297
5302
  const getRangeString = React15.useCallback((s, e) => {
5298
5303
  if (!s) return "";
5299
- const startStr = formatDateShort(s, locale);
5304
+ const startStr = formatDate ? formatDate(s) : formatDateShort(s, locale);
5300
5305
  if (!e) return `${startStr} - `;
5301
- return `${startStr} - ${formatDateShort(e, locale)}`;
5302
- }, [locale]);
5306
+ const endStr = formatDate ? formatDate(e) : formatDateShort(e, locale);
5307
+ return `${startStr} - ${endStr}`;
5308
+ }, [locale, formatDate]);
5303
5309
  React15.useEffect(() => {
5304
5310
  setInputValue((currentInput) => {
5305
5311
  if (startDate) {
@@ -5843,7 +5849,7 @@ var init_DatePicker = __esm({
5843
5849
  )
5844
5850
  ] })
5845
5851
  ] });
5846
- const displayFormat = (date) => formatDateShort(date);
5852
+ const displayFormat = (date) => formatDate ? formatDate(date) : formatDateShort(date);
5847
5853
  const displayLabel = tempStart && tempEnd ? `${displayFormat(tempStart)} - ${displayFormat(tempEnd)}` : tempStart ? `${displayFormat(tempStart)} - ...` : placeholder;
5848
5854
  const effectiveError = localRequiredError;
5849
5855
  const autoId = (0, import_react19.useId)();
@@ -6165,6 +6171,209 @@ var init_table_width_model = __esm({
6165
6171
  }
6166
6172
  });
6167
6173
 
6174
+ // src/components/UEditor/table-dom-utils.ts
6175
+ function isCrossRealmNode(value) {
6176
+ return Boolean(value && typeof value === "object" && value.nodeType != null);
6177
+ }
6178
+ function isCrossRealmElement(value) {
6179
+ return isCrossRealmNode(value) && value.nodeType === 1 && typeof value.closest === "function";
6180
+ }
6181
+ function isCrossRealmHTMLElement(value) {
6182
+ return isCrossRealmElement(value) && typeof value.style === "object";
6183
+ }
6184
+ function isCrossRealmTable(value) {
6185
+ return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TABLE" && "rows" in value;
6186
+ }
6187
+ function isCrossRealmTableRow(value) {
6188
+ return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TR" && "cells" in value;
6189
+ }
6190
+ function isCrossRealmTableCell(value) {
6191
+ return isCrossRealmElement(value) && ["TD", "TH"].includes(String(value.tagName).toUpperCase()) && "cellIndex" in value;
6192
+ }
6193
+ function isValidProseMirrorPosition(doc, pos) {
6194
+ return Number.isInteger(pos) && pos >= 0 && pos <= doc.content.size;
6195
+ }
6196
+ function findTableRowNodeInfo(view, rowElement) {
6197
+ if (!view.dom.contains(rowElement)) return null;
6198
+ const firstCell = rowElement.querySelector("th,td");
6199
+ if (!isCrossRealmTableCell(firstCell) || !view.dom.contains(firstCell)) return null;
6200
+ const cellPos = view.posAtDOM(firstCell, 0);
6201
+ if (!isValidProseMirrorPosition(view.state.doc, cellPos)) return null;
6202
+ const $pos = view.state.doc.resolve(cellPos);
6203
+ for (let depth = $pos.depth; depth > 0; depth -= 1) {
6204
+ const node = $pos.node(depth);
6205
+ if (node.type.name === "tableRow") {
6206
+ return {
6207
+ pos: $pos.before(depth),
6208
+ node
6209
+ };
6210
+ }
6211
+ }
6212
+ return null;
6213
+ }
6214
+ function resolveEventElement(target) {
6215
+ if (isCrossRealmElement(target)) return target;
6216
+ if (isCrossRealmNode(target)) return target.parentElement;
6217
+ return null;
6218
+ }
6219
+ function isPointOverRenderedText(root, clientX, clientY) {
6220
+ const view = root.ownerDocument.defaultView;
6221
+ if (!view) return false;
6222
+ const walker = root.ownerDocument.createTreeWalker(root, view.NodeFilter.SHOW_TEXT);
6223
+ let textNode = walker.nextNode();
6224
+ while (textNode) {
6225
+ if (textNode.textContent?.length) {
6226
+ const range = root.ownerDocument.createRange();
6227
+ range.selectNodeContents(textNode);
6228
+ const textRects = Array.from(range.getClientRects());
6229
+ range.detach?.();
6230
+ if (textRects.some((rect) => clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom)) {
6231
+ return true;
6232
+ }
6233
+ }
6234
+ textNode = walker.nextNode();
6235
+ }
6236
+ return false;
6237
+ }
6238
+ function getSelectionTableCell(view) {
6239
+ const realm = view.dom.ownerDocument.defaultView;
6240
+ const browserSelection = realm?.getSelection();
6241
+ const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
6242
+ const anchorCell = anchorElement?.closest?.("th,td");
6243
+ if (isCrossRealmTableCell(anchorCell) && view.dom.contains(anchorCell)) {
6244
+ return anchorCell;
6245
+ }
6246
+ const { from } = view.state.selection;
6247
+ const domAtPos = view.domAtPos(from);
6248
+ const element = resolveEventElement(domAtPos.node);
6249
+ const cell = element?.closest?.("th,td");
6250
+ return isCrossRealmTableCell(cell) && view.dom.contains(cell) ? cell : null;
6251
+ }
6252
+ function resolveRowResizeTarget(cell, clientX, clientY) {
6253
+ const rect = cell.getBoundingClientRect();
6254
+ const row = cell.closest("tr");
6255
+ if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
6256
+ return null;
6257
+ }
6258
+ const distToBottom = Math.abs(clientY - rect.bottom);
6259
+ const distToTop = Math.abs(clientY - rect.top);
6260
+ const distToRight = Math.abs(clientX - rect.right);
6261
+ const distToLeft = Math.abs(clientX - rect.left);
6262
+ if (distToRight <= 3 || distToLeft <= 3) {
6263
+ return null;
6264
+ }
6265
+ if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
6266
+ return { row, cell };
6267
+ }
6268
+ if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
6269
+ const prevRow = row.previousElementSibling;
6270
+ if (isCrossRealmTableRow(prevRow)) {
6271
+ const cellIndex = cell.cellIndex;
6272
+ const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
6273
+ if (isCrossRealmTableCell(prevCell)) {
6274
+ return { row: prevRow, cell: prevCell };
6275
+ }
6276
+ }
6277
+ }
6278
+ return null;
6279
+ }
6280
+ function resolveColumnResizeTarget(cell, clientX, clientY) {
6281
+ const rect = cell.getBoundingClientRect();
6282
+ const row = cell.closest("tr");
6283
+ if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
6284
+ return null;
6285
+ }
6286
+ const distToRight = Math.abs(clientX - rect.right);
6287
+ const distToLeft = Math.abs(clientX - rect.left);
6288
+ const distToBottom = Math.abs(clientY - rect.bottom);
6289
+ const distToTop = Math.abs(clientY - rect.top);
6290
+ if (distToBottom <= 3 || distToTop <= 3) {
6291
+ return null;
6292
+ }
6293
+ if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
6294
+ return { row, cell };
6295
+ }
6296
+ if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
6297
+ const prevCell = cell.previousElementSibling;
6298
+ if (isCrossRealmTableCell(prevCell)) {
6299
+ return { row, cell: prevCell };
6300
+ }
6301
+ }
6302
+ return null;
6303
+ }
6304
+ function isRowResizeHotspot(cell, clientX, clientY) {
6305
+ return resolveRowResizeTarget(cell, clientX, clientY) !== null;
6306
+ }
6307
+ function getRelativeBoundaryMetrics(surface, table, row, cell) {
6308
+ const surfaceRect = surface.getBoundingClientRect();
6309
+ const originLeft = surfaceRect.left + surface.clientLeft;
6310
+ const originTop = surfaceRect.top + surface.clientTop;
6311
+ const tableRect = table.getBoundingClientRect();
6312
+ const rowRect = row.getBoundingClientRect();
6313
+ const cellRect = cell.getBoundingClientRect();
6314
+ return {
6315
+ left: tableRect.left - originLeft + surface.scrollLeft,
6316
+ top: tableRect.top - originTop + surface.scrollTop,
6317
+ width: tableRect.width,
6318
+ height: tableRect.height,
6319
+ rowBottom: rowRect.bottom - originTop + surface.scrollTop,
6320
+ columnRight: cellRect.right - originLeft + surface.scrollLeft
6321
+ };
6322
+ }
6323
+ function getRelativeCellMetrics(surface, cell) {
6324
+ const surfaceRect = surface.getBoundingClientRect();
6325
+ const originLeft = surfaceRect.left + surface.clientLeft;
6326
+ const originTop = surfaceRect.top + surface.clientTop;
6327
+ const cellRect = cell.getBoundingClientRect();
6328
+ return {
6329
+ left: cellRect.left - originLeft + surface.scrollLeft,
6330
+ top: cellRect.top - originTop + surface.scrollTop,
6331
+ width: cellRect.width,
6332
+ height: cellRect.height
6333
+ };
6334
+ }
6335
+ function getRelativeSelectedCellsMetrics(surface) {
6336
+ const selectedCells = Array.from(
6337
+ surface.querySelectorAll("td.selectedCell, th.selectedCell")
6338
+ );
6339
+ if (selectedCells.length === 0) {
6340
+ return null;
6341
+ }
6342
+ const surfaceRect = surface.getBoundingClientRect();
6343
+ const originLeft = surfaceRect.left + surface.clientLeft;
6344
+ const originTop = surfaceRect.top + surface.clientTop;
6345
+ let left = Number.POSITIVE_INFINITY;
6346
+ let top = Number.POSITIVE_INFINITY;
6347
+ let right = Number.NEGATIVE_INFINITY;
6348
+ let bottom = Number.NEGATIVE_INFINITY;
6349
+ selectedCells.forEach((cell) => {
6350
+ const rect = cell.getBoundingClientRect();
6351
+ left = Math.min(left, rect.left);
6352
+ top = Math.min(top, rect.top);
6353
+ right = Math.max(right, rect.right);
6354
+ bottom = Math.max(bottom, rect.bottom);
6355
+ });
6356
+ return {
6357
+ left: left - originLeft + surface.scrollLeft,
6358
+ top: top - originTop + surface.scrollTop,
6359
+ width: right - left,
6360
+ height: bottom - top
6361
+ };
6362
+ }
6363
+ var DEFAULT_TABLE_ROW_HEIGHT, MIN_TABLE_ROW_HEIGHT, COLUMN_RESIZE_LINE_THICKNESS, ROW_RESIZE_LINE_THICKNESS, UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, isRowResizingGlobal, TABLE_RESIZE_HIT_ZONE;
6364
+ var init_table_dom_utils = __esm({
6365
+ "src/components/UEditor/table-dom-utils.ts"() {
6366
+ "use strict";
6367
+ DEFAULT_TABLE_ROW_HEIGHT = 25;
6368
+ MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
6369
+ COLUMN_RESIZE_LINE_THICKNESS = 2;
6370
+ ROW_RESIZE_LINE_THICKNESS = 2;
6371
+ UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
6372
+ isRowResizingGlobal = { active: false };
6373
+ TABLE_RESIZE_HIT_ZONE = 5;
6374
+ }
6375
+ });
6376
+
6168
6377
  // src/components/UEditor/clipboard-tables.ts
6169
6378
  function getClipboardData(dataTransfer, type) {
6170
6379
  try {
@@ -6596,7 +6805,7 @@ function getClipboardCellText(node) {
6596
6805
  if (node.nodeType === Node.TEXT_NODE) {
6597
6806
  return node.textContent ?? "";
6598
6807
  }
6599
- if (!(node instanceof HTMLElement)) {
6808
+ if (!isCrossRealmHTMLElement(node)) {
6600
6809
  return "";
6601
6810
  }
6602
6811
  if (node.tagName === "BR") {
@@ -6613,7 +6822,7 @@ function getClipboardCellSegments(node, styleMap, inheritedMarks) {
6613
6822
  if (node.nodeType === Node.TEXT_NODE) {
6614
6823
  return [{ text: node.textContent ?? "", marks: inheritedMarks }];
6615
6824
  }
6616
- if (!(node instanceof HTMLElement)) {
6825
+ if (!isCrossRealmHTMLElement(node)) {
6617
6826
  return [];
6618
6827
  }
6619
6828
  if (node.tagName === "BR") {
@@ -6645,7 +6854,7 @@ function getHtmlTableRows(table, styleMap) {
6645
6854
  const rows = Array.from(table.querySelectorAll("tr")).map(
6646
6855
  (row) => ({
6647
6856
  attrs: getTableRowAttrs(row, getElementStyleDeclarations(row, styleMap)),
6648
- cells: Array.from(row.children).filter((cell) => cell instanceof HTMLTableCellElement).map((cell) => {
6857
+ cells: Array.from(row.children).filter((cell) => isCrossRealmTableCell(cell)).map((cell) => {
6649
6858
  const styles = getElementStyleDeclarations(cell, styleMap);
6650
6859
  const textColor = normalizeTextColorValue(styles.get("color")) ?? DEFAULT_HTML_TABLE_TEXT_COLOR;
6651
6860
  const inheritedMarks = [{ type: "textStyle", attrs: { color: textColor } }];
@@ -6828,7 +7037,7 @@ function getClipboardTableContent(dataTransfer) {
6828
7037
  const tables = sourceBody.querySelectorAll("table");
6829
7038
  if (tables.length !== 1 || hasMeaningfulContentOutsideTable(sourceBody)) return null;
6830
7039
  const table = tables[0];
6831
- if (!(table instanceof HTMLTableElement)) return null;
7040
+ if (!isCrossRealmTable(table)) return null;
6832
7041
  const storedWidthValue = table.getAttribute("data-table-width-bp");
6833
7042
  const storedOffsetValue = table.getAttribute("data-table-offset-bp");
6834
7043
  const storedWidthBp = Number(storedWidthValue);
@@ -6912,6 +7121,7 @@ var init_clipboard_tables = __esm({
6912
7121
  "src/components/UEditor/clipboard-tables.ts"() {
6913
7122
  "use strict";
6914
7123
  init_table_width_model();
7124
+ init_table_dom_utils();
6915
7125
  DEFAULT_HTML_TABLE_CELL_BACKGROUND_COLOR = "#ffffff";
6916
7126
  DEFAULT_HTML_TABLE_TEXT_COLOR = "#000000";
6917
7127
  BORDER_STYLES = /* @__PURE__ */ new Set([
@@ -7132,209 +7342,6 @@ var init_clipboard_images = __esm({
7132
7342
  }
7133
7343
  });
7134
7344
 
7135
- // src/components/UEditor/table-dom-utils.ts
7136
- function isCrossRealmNode(value) {
7137
- return Boolean(value && typeof value === "object" && value.nodeType != null);
7138
- }
7139
- function isCrossRealmElement(value) {
7140
- return isCrossRealmNode(value) && value.nodeType === 1 && typeof value.closest === "function";
7141
- }
7142
- function isCrossRealmHTMLElement(value) {
7143
- return isCrossRealmElement(value) && typeof value.style === "object";
7144
- }
7145
- function isCrossRealmTable(value) {
7146
- return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TABLE" && "rows" in value;
7147
- }
7148
- function isCrossRealmTableRow(value) {
7149
- return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TR" && "cells" in value;
7150
- }
7151
- function isCrossRealmTableCell(value) {
7152
- return isCrossRealmElement(value) && ["TD", "TH"].includes(String(value.tagName).toUpperCase()) && "cellIndex" in value;
7153
- }
7154
- function isValidProseMirrorPosition(doc, pos) {
7155
- return Number.isInteger(pos) && pos >= 0 && pos <= doc.content.size;
7156
- }
7157
- function findTableRowNodeInfo(view, rowElement) {
7158
- if (!view.dom.contains(rowElement)) return null;
7159
- const firstCell = rowElement.querySelector("th,td");
7160
- if (!isCrossRealmTableCell(firstCell) || !view.dom.contains(firstCell)) return null;
7161
- const cellPos = view.posAtDOM(firstCell, 0);
7162
- if (!isValidProseMirrorPosition(view.state.doc, cellPos)) return null;
7163
- const $pos = view.state.doc.resolve(cellPos);
7164
- for (let depth = $pos.depth; depth > 0; depth -= 1) {
7165
- const node = $pos.node(depth);
7166
- if (node.type.name === "tableRow") {
7167
- return {
7168
- pos: $pos.before(depth),
7169
- node
7170
- };
7171
- }
7172
- }
7173
- return null;
7174
- }
7175
- function resolveEventElement(target) {
7176
- if (isCrossRealmElement(target)) return target;
7177
- if (isCrossRealmNode(target)) return target.parentElement;
7178
- return null;
7179
- }
7180
- function isPointOverRenderedText(root, clientX, clientY) {
7181
- const view = root.ownerDocument.defaultView;
7182
- if (!view) return false;
7183
- const walker = root.ownerDocument.createTreeWalker(root, view.NodeFilter.SHOW_TEXT);
7184
- let textNode = walker.nextNode();
7185
- while (textNode) {
7186
- if (textNode.textContent?.length) {
7187
- const range = root.ownerDocument.createRange();
7188
- range.selectNodeContents(textNode);
7189
- const textRects = Array.from(range.getClientRects());
7190
- range.detach?.();
7191
- if (textRects.some((rect) => clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom)) {
7192
- return true;
7193
- }
7194
- }
7195
- textNode = walker.nextNode();
7196
- }
7197
- return false;
7198
- }
7199
- function getSelectionTableCell(view) {
7200
- const realm = view.dom.ownerDocument.defaultView;
7201
- const browserSelection = realm?.getSelection();
7202
- const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
7203
- const anchorCell = anchorElement?.closest?.("th,td");
7204
- if (isCrossRealmTableCell(anchorCell) && view.dom.contains(anchorCell)) {
7205
- return anchorCell;
7206
- }
7207
- const { from } = view.state.selection;
7208
- const domAtPos = view.domAtPos(from);
7209
- const element = resolveEventElement(domAtPos.node);
7210
- const cell = element?.closest?.("th,td");
7211
- return isCrossRealmTableCell(cell) && view.dom.contains(cell) ? cell : null;
7212
- }
7213
- function resolveRowResizeTarget(cell, clientX, clientY) {
7214
- const rect = cell.getBoundingClientRect();
7215
- const row = cell.closest("tr");
7216
- if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
7217
- return null;
7218
- }
7219
- const distToBottom = Math.abs(clientY - rect.bottom);
7220
- const distToTop = Math.abs(clientY - rect.top);
7221
- const distToRight = Math.abs(clientX - rect.right);
7222
- const distToLeft = Math.abs(clientX - rect.left);
7223
- if (distToRight <= 3 || distToLeft <= 3) {
7224
- return null;
7225
- }
7226
- if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
7227
- return { row, cell };
7228
- }
7229
- if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
7230
- const prevRow = row.previousElementSibling;
7231
- if (isCrossRealmTableRow(prevRow)) {
7232
- const cellIndex = cell.cellIndex;
7233
- const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
7234
- if (isCrossRealmTableCell(prevCell)) {
7235
- return { row: prevRow, cell: prevCell };
7236
- }
7237
- }
7238
- }
7239
- return null;
7240
- }
7241
- function resolveColumnResizeTarget(cell, clientX, clientY) {
7242
- const rect = cell.getBoundingClientRect();
7243
- const row = cell.closest("tr");
7244
- if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
7245
- return null;
7246
- }
7247
- const distToRight = Math.abs(clientX - rect.right);
7248
- const distToLeft = Math.abs(clientX - rect.left);
7249
- const distToBottom = Math.abs(clientY - rect.bottom);
7250
- const distToTop = Math.abs(clientY - rect.top);
7251
- if (distToBottom <= 3 || distToTop <= 3) {
7252
- return null;
7253
- }
7254
- if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
7255
- return { row, cell };
7256
- }
7257
- if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
7258
- const prevCell = cell.previousElementSibling;
7259
- if (isCrossRealmTableCell(prevCell)) {
7260
- return { row, cell: prevCell };
7261
- }
7262
- }
7263
- return null;
7264
- }
7265
- function isRowResizeHotspot(cell, clientX, clientY) {
7266
- return resolveRowResizeTarget(cell, clientX, clientY) !== null;
7267
- }
7268
- function getRelativeBoundaryMetrics(surface, table, row, cell) {
7269
- const surfaceRect = surface.getBoundingClientRect();
7270
- const originLeft = surfaceRect.left + surface.clientLeft;
7271
- const originTop = surfaceRect.top + surface.clientTop;
7272
- const tableRect = table.getBoundingClientRect();
7273
- const rowRect = row.getBoundingClientRect();
7274
- const cellRect = cell.getBoundingClientRect();
7275
- return {
7276
- left: tableRect.left - originLeft + surface.scrollLeft,
7277
- top: tableRect.top - originTop + surface.scrollTop,
7278
- width: tableRect.width,
7279
- height: tableRect.height,
7280
- rowBottom: rowRect.bottom - originTop + surface.scrollTop,
7281
- columnRight: cellRect.right - originLeft + surface.scrollLeft
7282
- };
7283
- }
7284
- function getRelativeCellMetrics(surface, cell) {
7285
- const surfaceRect = surface.getBoundingClientRect();
7286
- const originLeft = surfaceRect.left + surface.clientLeft;
7287
- const originTop = surfaceRect.top + surface.clientTop;
7288
- const cellRect = cell.getBoundingClientRect();
7289
- return {
7290
- left: cellRect.left - originLeft + surface.scrollLeft,
7291
- top: cellRect.top - originTop + surface.scrollTop,
7292
- width: cellRect.width,
7293
- height: cellRect.height
7294
- };
7295
- }
7296
- function getRelativeSelectedCellsMetrics(surface) {
7297
- const selectedCells = Array.from(
7298
- surface.querySelectorAll("td.selectedCell, th.selectedCell")
7299
- );
7300
- if (selectedCells.length === 0) {
7301
- return null;
7302
- }
7303
- const surfaceRect = surface.getBoundingClientRect();
7304
- const originLeft = surfaceRect.left + surface.clientLeft;
7305
- const originTop = surfaceRect.top + surface.clientTop;
7306
- let left = Number.POSITIVE_INFINITY;
7307
- let top = Number.POSITIVE_INFINITY;
7308
- let right = Number.NEGATIVE_INFINITY;
7309
- let bottom = Number.NEGATIVE_INFINITY;
7310
- selectedCells.forEach((cell) => {
7311
- const rect = cell.getBoundingClientRect();
7312
- left = Math.min(left, rect.left);
7313
- top = Math.min(top, rect.top);
7314
- right = Math.max(right, rect.right);
7315
- bottom = Math.max(bottom, rect.bottom);
7316
- });
7317
- return {
7318
- left: left - originLeft + surface.scrollLeft,
7319
- top: top - originTop + surface.scrollTop,
7320
- width: right - left,
7321
- height: bottom - top
7322
- };
7323
- }
7324
- var DEFAULT_TABLE_ROW_HEIGHT, MIN_TABLE_ROW_HEIGHT, COLUMN_RESIZE_LINE_THICKNESS, ROW_RESIZE_LINE_THICKNESS, UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, isRowResizingGlobal, TABLE_RESIZE_HIT_ZONE;
7325
- var init_table_dom_utils = __esm({
7326
- "src/components/UEditor/table-dom-utils.ts"() {
7327
- "use strict";
7328
- DEFAULT_TABLE_ROW_HEIGHT = 25;
7329
- MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
7330
- COLUMN_RESIZE_LINE_THICKNESS = 2;
7331
- ROW_RESIZE_LINE_THICKNESS = 2;
7332
- UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
7333
- isRowResizingGlobal = { active: false };
7334
- TABLE_RESIZE_HIT_ZONE = 5;
7335
- }
7336
- });
7337
-
7338
7345
  // src/components/UEditor/table-column-resize.ts
7339
7346
  function getColumnResizeMinWidth(configuredMinWidth) {
7340
7347
  const normalizedMinWidth = Number.isFinite(configuredMinWidth) && configuredMinWidth > 0 ? Math.round(configuredMinWidth) : MIN_RESIZED_TABLE_COLUMN_WIDTH;
@@ -13430,7 +13437,7 @@ function parsePixelWidth(value) {
13430
13437
  }
13431
13438
  function getDomColumnWidths(editor, rect) {
13432
13439
  const tableDom = editor.view.nodeDOM(rect.tableStart - 1);
13433
- if (!(tableDom instanceof HTMLTableElement)) return null;
13440
+ if (!isCrossRealmTable(tableDom)) return null;
13434
13441
  const cols = Array.from(tableDom.querySelectorAll("colgroup > col"));
13435
13442
  if (cols.length === 0) return null;
13436
13443
  const widths = [];
@@ -20609,7 +20616,7 @@ var UEditorTableRow = import_extension_table_row.TableRow.extend({
20609
20616
  rowHeight: {
20610
20617
  default: DEFAULT_TABLE_ROW_HEIGHT,
20611
20618
  parseHTML: (element) => {
20612
- if (!(element instanceof HTMLElement)) return null;
20619
+ if (!isCrossRealmHTMLElement(element)) return null;
20613
20620
  return parseRowHeight(element.getAttribute("data-row-height")) ?? parseRowHeight(element.style.height);
20614
20621
  },
20615
20622
  renderHTML: (attributes) => {
@@ -21142,7 +21149,7 @@ var UEditorTable = import_extension_table.Table.extend({
21142
21149
  textAlign: {
21143
21150
  default: null,
21144
21151
  parseHTML: (element) => {
21145
- if (!(element instanceof HTMLElement)) return null;
21152
+ if (!isCrossRealmHTMLElement(element)) return null;
21146
21153
  return parseTableAlign(element);
21147
21154
  },
21148
21155
  renderHTML: (attributes) => {
@@ -21156,7 +21163,7 @@ var UEditorTable = import_extension_table.Table.extend({
21156
21163
  widthMode: {
21157
21164
  default: "fixed",
21158
21165
  parseHTML: (element) => {
21159
- if (!(element instanceof HTMLElement)) return "fixed";
21166
+ if (!isCrossRealmHTMLElement(element)) return "fixed";
21160
21167
  return parseTableWidthMode(element);
21161
21168
  },
21162
21169
  renderHTML: (attributes) => {
@@ -21169,7 +21176,7 @@ var UEditorTable = import_extension_table.Table.extend({
21169
21176
  widthBp: {
21170
21177
  default: null,
21171
21178
  parseHTML: (element) => {
21172
- if (!(element instanceof HTMLElement) || parseTableWidthMode(element) !== "responsive") return null;
21179
+ if (!isCrossRealmHTMLElement(element) || parseTableWidthMode(element) !== "responsive") return null;
21173
21180
  const stored = Number(element.getAttribute("data-table-width-bp"));
21174
21181
  if (Number.isFinite(stored) && stored > 0) return clampResponsiveTableWidthBp(stored);
21175
21182
  return parsePercentageToBasisPoints(element.getAttribute("data-table-width") ?? element.style.width) ?? DEFAULT_RESPONSIVE_TABLE_WIDTH_BP;
@@ -21179,7 +21186,7 @@ var UEditorTable = import_extension_table.Table.extend({
21179
21186
  offsetBp: {
21180
21187
  default: null,
21181
21188
  parseHTML: (element) => {
21182
- if (!(element instanceof HTMLElement) || parseTableWidthMode(element) !== "responsive") return null;
21189
+ if (!isCrossRealmHTMLElement(element) || parseTableWidthMode(element) !== "responsive") return null;
21183
21190
  const storedValue = element.getAttribute("data-table-offset-bp");
21184
21191
  const stored = Number(storedValue);
21185
21192
  if (storedValue !== null && Number.isFinite(stored) && stored >= 0) return Math.round(stored);
@@ -21198,7 +21205,7 @@ var UEditorTable = import_extension_table.Table.extend({
21198
21205
  columnRatios: {
21199
21206
  default: null,
21200
21207
  parseHTML: (element) => {
21201
- if (!(element instanceof HTMLElement)) return null;
21208
+ if (!isCrossRealmHTMLElement(element)) return null;
21202
21209
  const storedRatios = parseColumnRatios(
21203
21210
  element.getAttribute("data-table-column-ratios") ?? element.getAttribute("data-column-ratios")
21204
21211
  );
@@ -21394,7 +21401,7 @@ var UEditorTable = import_extension_table.Table.extend({
21394
21401
  if (event.button !== 0) return false;
21395
21402
  const target = resolveEventElement(event.target);
21396
21403
  const cell = target?.closest("th,td");
21397
- if (cell instanceof HTMLElement && isRowResizeHotspot(cell, event.clientX, event.clientY)) {
21404
+ if (isCrossRealmHTMLElement(cell) && isRowResizeHotspot(cell, event.clientX, event.clientY)) {
21398
21405
  isRowResizingGlobal.active = true;
21399
21406
  return true;
21400
21407
  }
@@ -22305,6 +22312,7 @@ var TableFormulaRecalculation = import_core20.Extension.create({
22305
22312
  });
22306
22313
 
22307
22314
  // src/components/UEditor/extensions.ts
22315
+ init_table_dom_utils();
22308
22316
  function getFormulaStateAttributes(attributes) {
22309
22317
  const formula = attributes["data-formula"];
22310
22318
  if (!formula) {
@@ -22624,7 +22632,7 @@ var CustomBulletList = import_extension_bullet_list.BulletList.extend({
22624
22632
  bulletStyle: {
22625
22633
  default: "disc",
22626
22634
  parseHTML: (element) => {
22627
- if (!(element instanceof HTMLElement)) return "disc";
22635
+ if (!isCrossRealmHTMLElement(element)) return "disc";
22628
22636
  const dataStyle = element.getAttribute("data-bullet-style");
22629
22637
  if (dataStyle) return parseBulletStyle(dataStyle);
22630
22638
  const style = element.style.listStyleType;
@@ -26795,8 +26803,11 @@ function useUEditorTableInteractions(editor, editable = true) {
26795
26803
  (0, import_react44.useEffect)(() => {
26796
26804
  if (!editor || !editable) return void 0;
26797
26805
  const proseMirror = editor.view.dom;
26798
- const editorDocument = proseMirror.ownerDocument;
26799
- const editorWindow = editorDocument.defaultView;
26806
+ const editorDocument = editorContentRef.current?.ownerDocument ?? editor?.view.dom.ownerDocument ?? document;
26807
+ const editorWindow = editorDocument.defaultView ?? window;
26808
+ if (editor?.view && editor.view.root !== editorDocument) {
26809
+ editor.view.updateRoot();
26810
+ }
26800
26811
  if (!editorWindow) return void 0;
26801
26812
  const surface = editorContentRef.current;
26802
26813
  let selectionSyncFrameId = 0;