@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.
package/dist/index.cjs CHANGED
@@ -5513,6 +5513,7 @@ var init_DatePicker = __esm({
5513
5513
  id,
5514
5514
  value,
5515
5515
  onChange,
5516
+ formatDate: formatDate2,
5516
5517
  placeholder,
5517
5518
  className,
5518
5519
  disabled = false,
@@ -5721,6 +5722,9 @@ var init_DatePicker = __esm({
5721
5722
  setIsOpen(false);
5722
5723
  };
5723
5724
  const formatDateDisplay = (date) => {
5725
+ if (formatDate2) {
5726
+ return formatDate2(date);
5727
+ }
5724
5728
  return date.toLocaleDateString(locale === "vi" ? "vi-VN" : "en-US", {
5725
5729
  day: "numeric",
5726
5730
  month: "long",
@@ -6180,6 +6184,7 @@ var init_DatePicker = __esm({
6180
6184
  startDate,
6181
6185
  endDate,
6182
6186
  onChange,
6187
+ formatDate: formatDate2,
6183
6188
  placeholder = "Select date range...",
6184
6189
  className,
6185
6190
  label,
@@ -6212,10 +6217,11 @@ var init_DatePicker = __esm({
6212
6217
  }, []);
6213
6218
  const getRangeString = React35.useCallback((s, e) => {
6214
6219
  if (!s) return "";
6215
- const startStr = formatDateShort(s, locale);
6220
+ const startStr = formatDate2 ? formatDate2(s) : formatDateShort(s, locale);
6216
6221
  if (!e) return `${startStr} - `;
6217
- return `${startStr} - ${formatDateShort(e, locale)}`;
6218
- }, [locale]);
6222
+ const endStr = formatDate2 ? formatDate2(e) : formatDateShort(e, locale);
6223
+ return `${startStr} - ${endStr}`;
6224
+ }, [locale, formatDate2]);
6219
6225
  React35.useEffect(() => {
6220
6226
  setInputValue((currentInput) => {
6221
6227
  if (startDate) {
@@ -6759,7 +6765,7 @@ var init_DatePicker = __esm({
6759
6765
  )
6760
6766
  ] })
6761
6767
  ] });
6762
- const displayFormat = (date) => formatDateShort(date);
6768
+ const displayFormat = (date) => formatDate2 ? formatDate2(date) : formatDateShort(date);
6763
6769
  const displayLabel = tempStart && tempEnd ? `${displayFormat(tempStart)} - ${displayFormat(tempEnd)}` : tempStart ? `${displayFormat(tempStart)} - ...` : placeholder;
6764
6770
  const effectiveError = localRequiredError;
6765
6771
  const autoId = (0, import_react22.useId)();
@@ -7160,6 +7166,209 @@ var init_table_width_model = __esm({
7160
7166
  }
7161
7167
  });
7162
7168
 
7169
+ // src/components/UEditor/table-dom-utils.ts
7170
+ function isCrossRealmNode(value) {
7171
+ return Boolean(value && typeof value === "object" && value.nodeType != null);
7172
+ }
7173
+ function isCrossRealmElement(value) {
7174
+ return isCrossRealmNode(value) && value.nodeType === 1 && typeof value.closest === "function";
7175
+ }
7176
+ function isCrossRealmHTMLElement(value) {
7177
+ return isCrossRealmElement(value) && typeof value.style === "object";
7178
+ }
7179
+ function isCrossRealmTable(value) {
7180
+ return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TABLE" && "rows" in value;
7181
+ }
7182
+ function isCrossRealmTableRow(value) {
7183
+ return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TR" && "cells" in value;
7184
+ }
7185
+ function isCrossRealmTableCell(value) {
7186
+ return isCrossRealmElement(value) && ["TD", "TH"].includes(String(value.tagName).toUpperCase()) && "cellIndex" in value;
7187
+ }
7188
+ function isValidProseMirrorPosition(doc, pos) {
7189
+ return Number.isInteger(pos) && pos >= 0 && pos <= doc.content.size;
7190
+ }
7191
+ function findTableRowNodeInfo(view, rowElement) {
7192
+ if (!view.dom.contains(rowElement)) return null;
7193
+ const firstCell = rowElement.querySelector("th,td");
7194
+ if (!isCrossRealmTableCell(firstCell) || !view.dom.contains(firstCell)) return null;
7195
+ const cellPos = view.posAtDOM(firstCell, 0);
7196
+ if (!isValidProseMirrorPosition(view.state.doc, cellPos)) return null;
7197
+ const $pos = view.state.doc.resolve(cellPos);
7198
+ for (let depth = $pos.depth; depth > 0; depth -= 1) {
7199
+ const node = $pos.node(depth);
7200
+ if (node.type.name === "tableRow") {
7201
+ return {
7202
+ pos: $pos.before(depth),
7203
+ node
7204
+ };
7205
+ }
7206
+ }
7207
+ return null;
7208
+ }
7209
+ function resolveEventElement(target) {
7210
+ if (isCrossRealmElement(target)) return target;
7211
+ if (isCrossRealmNode(target)) return target.parentElement;
7212
+ return null;
7213
+ }
7214
+ function isPointOverRenderedText(root, clientX, clientY) {
7215
+ const view = root.ownerDocument.defaultView;
7216
+ if (!view) return false;
7217
+ const walker = root.ownerDocument.createTreeWalker(root, view.NodeFilter.SHOW_TEXT);
7218
+ let textNode = walker.nextNode();
7219
+ while (textNode) {
7220
+ if (textNode.textContent?.length) {
7221
+ const range = root.ownerDocument.createRange();
7222
+ range.selectNodeContents(textNode);
7223
+ const textRects = Array.from(range.getClientRects());
7224
+ range.detach?.();
7225
+ if (textRects.some((rect) => clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom)) {
7226
+ return true;
7227
+ }
7228
+ }
7229
+ textNode = walker.nextNode();
7230
+ }
7231
+ return false;
7232
+ }
7233
+ function getSelectionTableCell(view) {
7234
+ const realm = view.dom.ownerDocument.defaultView;
7235
+ const browserSelection = realm?.getSelection();
7236
+ const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
7237
+ const anchorCell = anchorElement?.closest?.("th,td");
7238
+ if (isCrossRealmTableCell(anchorCell) && view.dom.contains(anchorCell)) {
7239
+ return anchorCell;
7240
+ }
7241
+ const { from } = view.state.selection;
7242
+ const domAtPos = view.domAtPos(from);
7243
+ const element = resolveEventElement(domAtPos.node);
7244
+ const cell = element?.closest?.("th,td");
7245
+ return isCrossRealmTableCell(cell) && view.dom.contains(cell) ? cell : null;
7246
+ }
7247
+ function resolveRowResizeTarget(cell, clientX, clientY) {
7248
+ const rect = cell.getBoundingClientRect();
7249
+ const row = cell.closest("tr");
7250
+ if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
7251
+ return null;
7252
+ }
7253
+ const distToBottom = Math.abs(clientY - rect.bottom);
7254
+ const distToTop = Math.abs(clientY - rect.top);
7255
+ const distToRight = Math.abs(clientX - rect.right);
7256
+ const distToLeft = Math.abs(clientX - rect.left);
7257
+ if (distToRight <= 3 || distToLeft <= 3) {
7258
+ return null;
7259
+ }
7260
+ if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
7261
+ return { row, cell };
7262
+ }
7263
+ if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
7264
+ const prevRow = row.previousElementSibling;
7265
+ if (isCrossRealmTableRow(prevRow)) {
7266
+ const cellIndex = cell.cellIndex;
7267
+ const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
7268
+ if (isCrossRealmTableCell(prevCell)) {
7269
+ return { row: prevRow, cell: prevCell };
7270
+ }
7271
+ }
7272
+ }
7273
+ return null;
7274
+ }
7275
+ function resolveColumnResizeTarget(cell, clientX, clientY) {
7276
+ const rect = cell.getBoundingClientRect();
7277
+ const row = cell.closest("tr");
7278
+ if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
7279
+ return null;
7280
+ }
7281
+ const distToRight = Math.abs(clientX - rect.right);
7282
+ const distToLeft = Math.abs(clientX - rect.left);
7283
+ const distToBottom = Math.abs(clientY - rect.bottom);
7284
+ const distToTop = Math.abs(clientY - rect.top);
7285
+ if (distToBottom <= 3 || distToTop <= 3) {
7286
+ return null;
7287
+ }
7288
+ if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
7289
+ return { row, cell };
7290
+ }
7291
+ if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
7292
+ const prevCell = cell.previousElementSibling;
7293
+ if (isCrossRealmTableCell(prevCell)) {
7294
+ return { row, cell: prevCell };
7295
+ }
7296
+ }
7297
+ return null;
7298
+ }
7299
+ function isRowResizeHotspot(cell, clientX, clientY) {
7300
+ return resolveRowResizeTarget(cell, clientX, clientY) !== null;
7301
+ }
7302
+ function getRelativeBoundaryMetrics(surface, table, row, cell) {
7303
+ const surfaceRect = surface.getBoundingClientRect();
7304
+ const originLeft = surfaceRect.left + surface.clientLeft;
7305
+ const originTop = surfaceRect.top + surface.clientTop;
7306
+ const tableRect = table.getBoundingClientRect();
7307
+ const rowRect = row.getBoundingClientRect();
7308
+ const cellRect = cell.getBoundingClientRect();
7309
+ return {
7310
+ left: tableRect.left - originLeft + surface.scrollLeft,
7311
+ top: tableRect.top - originTop + surface.scrollTop,
7312
+ width: tableRect.width,
7313
+ height: tableRect.height,
7314
+ rowBottom: rowRect.bottom - originTop + surface.scrollTop,
7315
+ columnRight: cellRect.right - originLeft + surface.scrollLeft
7316
+ };
7317
+ }
7318
+ function getRelativeCellMetrics(surface, cell) {
7319
+ const surfaceRect = surface.getBoundingClientRect();
7320
+ const originLeft = surfaceRect.left + surface.clientLeft;
7321
+ const originTop = surfaceRect.top + surface.clientTop;
7322
+ const cellRect = cell.getBoundingClientRect();
7323
+ return {
7324
+ left: cellRect.left - originLeft + surface.scrollLeft,
7325
+ top: cellRect.top - originTop + surface.scrollTop,
7326
+ width: cellRect.width,
7327
+ height: cellRect.height
7328
+ };
7329
+ }
7330
+ function getRelativeSelectedCellsMetrics(surface) {
7331
+ const selectedCells = Array.from(
7332
+ surface.querySelectorAll("td.selectedCell, th.selectedCell")
7333
+ );
7334
+ if (selectedCells.length === 0) {
7335
+ return null;
7336
+ }
7337
+ const surfaceRect = surface.getBoundingClientRect();
7338
+ const originLeft = surfaceRect.left + surface.clientLeft;
7339
+ const originTop = surfaceRect.top + surface.clientTop;
7340
+ let left = Number.POSITIVE_INFINITY;
7341
+ let top = Number.POSITIVE_INFINITY;
7342
+ let right = Number.NEGATIVE_INFINITY;
7343
+ let bottom = Number.NEGATIVE_INFINITY;
7344
+ selectedCells.forEach((cell) => {
7345
+ const rect = cell.getBoundingClientRect();
7346
+ left = Math.min(left, rect.left);
7347
+ top = Math.min(top, rect.top);
7348
+ right = Math.max(right, rect.right);
7349
+ bottom = Math.max(bottom, rect.bottom);
7350
+ });
7351
+ return {
7352
+ left: left - originLeft + surface.scrollLeft,
7353
+ top: top - originTop + surface.scrollTop,
7354
+ width: right - left,
7355
+ height: bottom - top
7356
+ };
7357
+ }
7358
+ 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;
7359
+ var init_table_dom_utils = __esm({
7360
+ "src/components/UEditor/table-dom-utils.ts"() {
7361
+ "use strict";
7362
+ DEFAULT_TABLE_ROW_HEIGHT = 25;
7363
+ MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
7364
+ COLUMN_RESIZE_LINE_THICKNESS = 2;
7365
+ ROW_RESIZE_LINE_THICKNESS = 2;
7366
+ UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
7367
+ isRowResizingGlobal = { active: false };
7368
+ TABLE_RESIZE_HIT_ZONE = 5;
7369
+ }
7370
+ });
7371
+
7163
7372
  // src/components/UEditor/clipboard-tables.ts
7164
7373
  function getClipboardData(dataTransfer, type) {
7165
7374
  try {
@@ -7591,7 +7800,7 @@ function getClipboardCellText(node) {
7591
7800
  if (node.nodeType === Node.TEXT_NODE) {
7592
7801
  return node.textContent ?? "";
7593
7802
  }
7594
- if (!(node instanceof HTMLElement)) {
7803
+ if (!isCrossRealmHTMLElement(node)) {
7595
7804
  return "";
7596
7805
  }
7597
7806
  if (node.tagName === "BR") {
@@ -7608,7 +7817,7 @@ function getClipboardCellSegments(node, styleMap, inheritedMarks) {
7608
7817
  if (node.nodeType === Node.TEXT_NODE) {
7609
7818
  return [{ text: node.textContent ?? "", marks: inheritedMarks }];
7610
7819
  }
7611
- if (!(node instanceof HTMLElement)) {
7820
+ if (!isCrossRealmHTMLElement(node)) {
7612
7821
  return [];
7613
7822
  }
7614
7823
  if (node.tagName === "BR") {
@@ -7640,7 +7849,7 @@ function getHtmlTableRows(table, styleMap) {
7640
7849
  const rows = Array.from(table.querySelectorAll("tr")).map(
7641
7850
  (row) => ({
7642
7851
  attrs: getTableRowAttrs(row, getElementStyleDeclarations(row, styleMap)),
7643
- cells: Array.from(row.children).filter((cell) => cell instanceof HTMLTableCellElement).map((cell) => {
7852
+ cells: Array.from(row.children).filter((cell) => isCrossRealmTableCell(cell)).map((cell) => {
7644
7853
  const styles = getElementStyleDeclarations(cell, styleMap);
7645
7854
  const textColor = normalizeTextColorValue(styles.get("color")) ?? DEFAULT_HTML_TABLE_TEXT_COLOR;
7646
7855
  const inheritedMarks = [{ type: "textStyle", attrs: { color: textColor } }];
@@ -7823,7 +8032,7 @@ function getClipboardTableContent(dataTransfer) {
7823
8032
  const tables = sourceBody.querySelectorAll("table");
7824
8033
  if (tables.length !== 1 || hasMeaningfulContentOutsideTable(sourceBody)) return null;
7825
8034
  const table = tables[0];
7826
- if (!(table instanceof HTMLTableElement)) return null;
8035
+ if (!isCrossRealmTable(table)) return null;
7827
8036
  const storedWidthValue = table.getAttribute("data-table-width-bp");
7828
8037
  const storedOffsetValue = table.getAttribute("data-table-offset-bp");
7829
8038
  const storedWidthBp = Number(storedWidthValue);
@@ -7907,6 +8116,7 @@ var init_clipboard_tables = __esm({
7907
8116
  "src/components/UEditor/clipboard-tables.ts"() {
7908
8117
  "use strict";
7909
8118
  init_table_width_model();
8119
+ init_table_dom_utils();
7910
8120
  DEFAULT_HTML_TABLE_CELL_BACKGROUND_COLOR = "#ffffff";
7911
8121
  DEFAULT_HTML_TABLE_TEXT_COLOR = "#000000";
7912
8122
  BORDER_STYLES = /* @__PURE__ */ new Set([
@@ -8127,209 +8337,6 @@ var init_clipboard_images = __esm({
8127
8337
  }
8128
8338
  });
8129
8339
 
8130
- // src/components/UEditor/table-dom-utils.ts
8131
- function isCrossRealmNode(value) {
8132
- return Boolean(value && typeof value === "object" && value.nodeType != null);
8133
- }
8134
- function isCrossRealmElement(value) {
8135
- return isCrossRealmNode(value) && value.nodeType === 1 && typeof value.closest === "function";
8136
- }
8137
- function isCrossRealmHTMLElement(value) {
8138
- return isCrossRealmElement(value) && typeof value.style === "object";
8139
- }
8140
- function isCrossRealmTable(value) {
8141
- return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TABLE" && "rows" in value;
8142
- }
8143
- function isCrossRealmTableRow(value) {
8144
- return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TR" && "cells" in value;
8145
- }
8146
- function isCrossRealmTableCell(value) {
8147
- return isCrossRealmElement(value) && ["TD", "TH"].includes(String(value.tagName).toUpperCase()) && "cellIndex" in value;
8148
- }
8149
- function isValidProseMirrorPosition(doc, pos) {
8150
- return Number.isInteger(pos) && pos >= 0 && pos <= doc.content.size;
8151
- }
8152
- function findTableRowNodeInfo(view, rowElement) {
8153
- if (!view.dom.contains(rowElement)) return null;
8154
- const firstCell = rowElement.querySelector("th,td");
8155
- if (!isCrossRealmTableCell(firstCell) || !view.dom.contains(firstCell)) return null;
8156
- const cellPos = view.posAtDOM(firstCell, 0);
8157
- if (!isValidProseMirrorPosition(view.state.doc, cellPos)) return null;
8158
- const $pos = view.state.doc.resolve(cellPos);
8159
- for (let depth = $pos.depth; depth > 0; depth -= 1) {
8160
- const node = $pos.node(depth);
8161
- if (node.type.name === "tableRow") {
8162
- return {
8163
- pos: $pos.before(depth),
8164
- node
8165
- };
8166
- }
8167
- }
8168
- return null;
8169
- }
8170
- function resolveEventElement(target) {
8171
- if (isCrossRealmElement(target)) return target;
8172
- if (isCrossRealmNode(target)) return target.parentElement;
8173
- return null;
8174
- }
8175
- function isPointOverRenderedText(root, clientX, clientY) {
8176
- const view = root.ownerDocument.defaultView;
8177
- if (!view) return false;
8178
- const walker = root.ownerDocument.createTreeWalker(root, view.NodeFilter.SHOW_TEXT);
8179
- let textNode = walker.nextNode();
8180
- while (textNode) {
8181
- if (textNode.textContent?.length) {
8182
- const range = root.ownerDocument.createRange();
8183
- range.selectNodeContents(textNode);
8184
- const textRects = Array.from(range.getClientRects());
8185
- range.detach?.();
8186
- if (textRects.some((rect) => clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom)) {
8187
- return true;
8188
- }
8189
- }
8190
- textNode = walker.nextNode();
8191
- }
8192
- return false;
8193
- }
8194
- function getSelectionTableCell(view) {
8195
- const realm = view.dom.ownerDocument.defaultView;
8196
- const browserSelection = realm?.getSelection();
8197
- const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
8198
- const anchorCell = anchorElement?.closest?.("th,td");
8199
- if (isCrossRealmTableCell(anchorCell) && view.dom.contains(anchorCell)) {
8200
- return anchorCell;
8201
- }
8202
- const { from } = view.state.selection;
8203
- const domAtPos = view.domAtPos(from);
8204
- const element = resolveEventElement(domAtPos.node);
8205
- const cell = element?.closest?.("th,td");
8206
- return isCrossRealmTableCell(cell) && view.dom.contains(cell) ? cell : null;
8207
- }
8208
- function resolveRowResizeTarget(cell, clientX, clientY) {
8209
- const rect = cell.getBoundingClientRect();
8210
- const row = cell.closest("tr");
8211
- if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
8212
- return null;
8213
- }
8214
- const distToBottom = Math.abs(clientY - rect.bottom);
8215
- const distToTop = Math.abs(clientY - rect.top);
8216
- const distToRight = Math.abs(clientX - rect.right);
8217
- const distToLeft = Math.abs(clientX - rect.left);
8218
- if (distToRight <= 3 || distToLeft <= 3) {
8219
- return null;
8220
- }
8221
- if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
8222
- return { row, cell };
8223
- }
8224
- if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
8225
- const prevRow = row.previousElementSibling;
8226
- if (isCrossRealmTableRow(prevRow)) {
8227
- const cellIndex = cell.cellIndex;
8228
- const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
8229
- if (isCrossRealmTableCell(prevCell)) {
8230
- return { row: prevRow, cell: prevCell };
8231
- }
8232
- }
8233
- }
8234
- return null;
8235
- }
8236
- function resolveColumnResizeTarget(cell, clientX, clientY) {
8237
- const rect = cell.getBoundingClientRect();
8238
- const row = cell.closest("tr");
8239
- if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
8240
- return null;
8241
- }
8242
- const distToRight = Math.abs(clientX - rect.right);
8243
- const distToLeft = Math.abs(clientX - rect.left);
8244
- const distToBottom = Math.abs(clientY - rect.bottom);
8245
- const distToTop = Math.abs(clientY - rect.top);
8246
- if (distToBottom <= 3 || distToTop <= 3) {
8247
- return null;
8248
- }
8249
- if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
8250
- return { row, cell };
8251
- }
8252
- if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
8253
- const prevCell = cell.previousElementSibling;
8254
- if (isCrossRealmTableCell(prevCell)) {
8255
- return { row, cell: prevCell };
8256
- }
8257
- }
8258
- return null;
8259
- }
8260
- function isRowResizeHotspot(cell, clientX, clientY) {
8261
- return resolveRowResizeTarget(cell, clientX, clientY) !== null;
8262
- }
8263
- function getRelativeBoundaryMetrics(surface, table, row, cell) {
8264
- const surfaceRect = surface.getBoundingClientRect();
8265
- const originLeft = surfaceRect.left + surface.clientLeft;
8266
- const originTop = surfaceRect.top + surface.clientTop;
8267
- const tableRect = table.getBoundingClientRect();
8268
- const rowRect = row.getBoundingClientRect();
8269
- const cellRect = cell.getBoundingClientRect();
8270
- return {
8271
- left: tableRect.left - originLeft + surface.scrollLeft,
8272
- top: tableRect.top - originTop + surface.scrollTop,
8273
- width: tableRect.width,
8274
- height: tableRect.height,
8275
- rowBottom: rowRect.bottom - originTop + surface.scrollTop,
8276
- columnRight: cellRect.right - originLeft + surface.scrollLeft
8277
- };
8278
- }
8279
- function getRelativeCellMetrics(surface, cell) {
8280
- const surfaceRect = surface.getBoundingClientRect();
8281
- const originLeft = surfaceRect.left + surface.clientLeft;
8282
- const originTop = surfaceRect.top + surface.clientTop;
8283
- const cellRect = cell.getBoundingClientRect();
8284
- return {
8285
- left: cellRect.left - originLeft + surface.scrollLeft,
8286
- top: cellRect.top - originTop + surface.scrollTop,
8287
- width: cellRect.width,
8288
- height: cellRect.height
8289
- };
8290
- }
8291
- function getRelativeSelectedCellsMetrics(surface) {
8292
- const selectedCells = Array.from(
8293
- surface.querySelectorAll("td.selectedCell, th.selectedCell")
8294
- );
8295
- if (selectedCells.length === 0) {
8296
- return null;
8297
- }
8298
- const surfaceRect = surface.getBoundingClientRect();
8299
- const originLeft = surfaceRect.left + surface.clientLeft;
8300
- const originTop = surfaceRect.top + surface.clientTop;
8301
- let left = Number.POSITIVE_INFINITY;
8302
- let top = Number.POSITIVE_INFINITY;
8303
- let right = Number.NEGATIVE_INFINITY;
8304
- let bottom = Number.NEGATIVE_INFINITY;
8305
- selectedCells.forEach((cell) => {
8306
- const rect = cell.getBoundingClientRect();
8307
- left = Math.min(left, rect.left);
8308
- top = Math.min(top, rect.top);
8309
- right = Math.max(right, rect.right);
8310
- bottom = Math.max(bottom, rect.bottom);
8311
- });
8312
- return {
8313
- left: left - originLeft + surface.scrollLeft,
8314
- top: top - originTop + surface.scrollTop,
8315
- width: right - left,
8316
- height: bottom - top
8317
- };
8318
- }
8319
- 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;
8320
- var init_table_dom_utils = __esm({
8321
- "src/components/UEditor/table-dom-utils.ts"() {
8322
- "use strict";
8323
- DEFAULT_TABLE_ROW_HEIGHT = 25;
8324
- MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
8325
- COLUMN_RESIZE_LINE_THICKNESS = 2;
8326
- ROW_RESIZE_LINE_THICKNESS = 2;
8327
- UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
8328
- isRowResizingGlobal = { active: false };
8329
- TABLE_RESIZE_HIT_ZONE = 5;
8330
- }
8331
- });
8332
-
8333
8340
  // src/components/UEditor/table-column-resize.ts
8334
8341
  function getColumnResizeMinWidth(configuredMinWidth) {
8335
8342
  const normalizedMinWidth = Number.isFinite(configuredMinWidth) && configuredMinWidth > 0 ? Math.round(configuredMinWidth) : MIN_RESIZED_TABLE_COLUMN_WIDTH;
@@ -14425,7 +14432,7 @@ function parsePixelWidth(value) {
14425
14432
  }
14426
14433
  function getDomColumnWidths(editor, rect) {
14427
14434
  const tableDom = editor.view.nodeDOM(rect.tableStart - 1);
14428
- if (!(tableDom instanceof HTMLTableElement)) return null;
14435
+ if (!isCrossRealmTable(tableDom)) return null;
14429
14436
  const cols = Array.from(tableDom.querySelectorAll("colgroup > col"));
14430
14437
  if (cols.length === 0) return null;
14431
14438
  const widths = [];
@@ -24573,6 +24580,7 @@ var LunarDatePicker = ({
24573
24580
  id,
24574
24581
  value,
24575
24582
  onChange,
24583
+ formatDate: formatDate2,
24576
24584
  placeholder,
24577
24585
  className,
24578
24586
  disabled = false,
@@ -24786,6 +24794,9 @@ var LunarDatePicker = ({
24786
24794
  };
24787
24795
  const formatDateDisplay = (date) => {
24788
24796
  if (!date) return "";
24797
+ if (formatDate2) {
24798
+ return formatDate2(date);
24799
+ }
24789
24800
  const formatStr = date.is_leap_month ? t("lunarLeapFormat") : t("lunarFormat");
24790
24801
  return formatStr.replace("{day}", String(date.day)).replace("{month}", String(date.month)).replace("{year}", String(date.year));
24791
24802
  };
@@ -25255,6 +25266,7 @@ var LunarDateRangePicker = ({
25255
25266
  startDate,
25256
25267
  endDate,
25257
25268
  onChange,
25269
+ formatDate: formatDate2,
25258
25270
  placeholder = "Select lunar date range...",
25259
25271
  className,
25260
25272
  label,
@@ -25698,6 +25710,9 @@ var LunarDateRangePicker = ({
25698
25710
  ] })
25699
25711
  ] });
25700
25712
  const displayFormat = (date) => {
25713
+ if (formatDate2) {
25714
+ return formatDate2(date);
25715
+ }
25701
25716
  const formatStr = date.is_leap_month ? t("lunarLeapFormat") : t("lunarFormat");
25702
25717
  return formatStr.replace("{day}", String(date.day)).replace("{month}", String(date.month)).replace("{year}", String(date.year));
25703
25718
  };
@@ -43671,7 +43686,7 @@ var UEditorTableRow = import_extension_table_row.TableRow.extend({
43671
43686
  rowHeight: {
43672
43687
  default: DEFAULT_TABLE_ROW_HEIGHT,
43673
43688
  parseHTML: (element) => {
43674
- if (!(element instanceof HTMLElement)) return null;
43689
+ if (!isCrossRealmHTMLElement(element)) return null;
43675
43690
  return parseRowHeight(element.getAttribute("data-row-height")) ?? parseRowHeight(element.style.height);
43676
43691
  },
43677
43692
  renderHTML: (attributes) => {
@@ -44204,7 +44219,7 @@ var UEditorTable = import_extension_table.Table.extend({
44204
44219
  textAlign: {
44205
44220
  default: null,
44206
44221
  parseHTML: (element) => {
44207
- if (!(element instanceof HTMLElement)) return null;
44222
+ if (!isCrossRealmHTMLElement(element)) return null;
44208
44223
  return parseTableAlign(element);
44209
44224
  },
44210
44225
  renderHTML: (attributes) => {
@@ -44218,7 +44233,7 @@ var UEditorTable = import_extension_table.Table.extend({
44218
44233
  widthMode: {
44219
44234
  default: "fixed",
44220
44235
  parseHTML: (element) => {
44221
- if (!(element instanceof HTMLElement)) return "fixed";
44236
+ if (!isCrossRealmHTMLElement(element)) return "fixed";
44222
44237
  return parseTableWidthMode(element);
44223
44238
  },
44224
44239
  renderHTML: (attributes) => {
@@ -44231,7 +44246,7 @@ var UEditorTable = import_extension_table.Table.extend({
44231
44246
  widthBp: {
44232
44247
  default: null,
44233
44248
  parseHTML: (element) => {
44234
- if (!(element instanceof HTMLElement) || parseTableWidthMode(element) !== "responsive") return null;
44249
+ if (!isCrossRealmHTMLElement(element) || parseTableWidthMode(element) !== "responsive") return null;
44235
44250
  const stored = Number(element.getAttribute("data-table-width-bp"));
44236
44251
  if (Number.isFinite(stored) && stored > 0) return clampResponsiveTableWidthBp(stored);
44237
44252
  return parsePercentageToBasisPoints(element.getAttribute("data-table-width") ?? element.style.width) ?? DEFAULT_RESPONSIVE_TABLE_WIDTH_BP;
@@ -44241,7 +44256,7 @@ var UEditorTable = import_extension_table.Table.extend({
44241
44256
  offsetBp: {
44242
44257
  default: null,
44243
44258
  parseHTML: (element) => {
44244
- if (!(element instanceof HTMLElement) || parseTableWidthMode(element) !== "responsive") return null;
44259
+ if (!isCrossRealmHTMLElement(element) || parseTableWidthMode(element) !== "responsive") return null;
44245
44260
  const storedValue = element.getAttribute("data-table-offset-bp");
44246
44261
  const stored = Number(storedValue);
44247
44262
  if (storedValue !== null && Number.isFinite(stored) && stored >= 0) return Math.round(stored);
@@ -44260,7 +44275,7 @@ var UEditorTable = import_extension_table.Table.extend({
44260
44275
  columnRatios: {
44261
44276
  default: null,
44262
44277
  parseHTML: (element) => {
44263
- if (!(element instanceof HTMLElement)) return null;
44278
+ if (!isCrossRealmHTMLElement(element)) return null;
44264
44279
  const storedRatios = parseColumnRatios(
44265
44280
  element.getAttribute("data-table-column-ratios") ?? element.getAttribute("data-column-ratios")
44266
44281
  );
@@ -44456,7 +44471,7 @@ var UEditorTable = import_extension_table.Table.extend({
44456
44471
  if (event.button !== 0) return false;
44457
44472
  const target = resolveEventElement(event.target);
44458
44473
  const cell = target?.closest("th,td");
44459
- if (cell instanceof HTMLElement && isRowResizeHotspot(cell, event.clientX, event.clientY)) {
44474
+ if (isCrossRealmHTMLElement(cell) && isRowResizeHotspot(cell, event.clientX, event.clientY)) {
44460
44475
  isRowResizingGlobal.active = true;
44461
44476
  return true;
44462
44477
  }
@@ -45367,6 +45382,7 @@ var TableFormulaRecalculation = import_core20.Extension.create({
45367
45382
  });
45368
45383
 
45369
45384
  // src/components/UEditor/extensions.ts
45385
+ init_table_dom_utils();
45370
45386
  function getFormulaStateAttributes(attributes) {
45371
45387
  const formula = attributes["data-formula"];
45372
45388
  if (!formula) {
@@ -45686,7 +45702,7 @@ var CustomBulletList = import_extension_bullet_list.BulletList.extend({
45686
45702
  bulletStyle: {
45687
45703
  default: "disc",
45688
45704
  parseHTML: (element) => {
45689
- if (!(element instanceof HTMLElement)) return "disc";
45705
+ if (!isCrossRealmHTMLElement(element)) return "disc";
45690
45706
  const dataStyle = element.getAttribute("data-bullet-style");
45691
45707
  if (dataStyle) return parseBulletStyle(dataStyle);
45692
45708
  const style = element.style.listStyleType;
@@ -49857,8 +49873,11 @@ function useUEditorTableInteractions(editor, editable = true) {
49857
49873
  (0, import_react83.useEffect)(() => {
49858
49874
  if (!editor || !editable) return void 0;
49859
49875
  const proseMirror = editor.view.dom;
49860
- const editorDocument = proseMirror.ownerDocument;
49861
- const editorWindow = editorDocument.defaultView;
49876
+ const editorDocument = editorContentRef.current?.ownerDocument ?? editor?.view.dom.ownerDocument ?? document;
49877
+ const editorWindow = editorDocument.defaultView ?? window;
49878
+ if (editor?.view && editor.view.root !== editorDocument) {
49879
+ editor.view.updateRoot();
49880
+ }
49862
49881
  if (!editorWindow) return void 0;
49863
49882
  const surface = editorContentRef.current;
49864
49883
  let selectionSyncFrameId = 0;