@underverse-ui/underverse 2.0.25 → 2.0.27

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.25",
3
+ "version": "2.0.27",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 263,
6
6
  "exports": [
@@ -41,6 +41,12 @@ import {
41
41
  getRelativeCellMetrics,
42
42
  getRelativeSelectedCellsMetrics,
43
43
  getSelectionTableCell,
44
+ isCrossRealmElement,
45
+ isCrossRealmHTMLElement,
46
+ isCrossRealmNode,
47
+ isCrossRealmTable,
48
+ isCrossRealmTableCell,
49
+ isCrossRealmTableRow,
44
50
  isPointOverRenderedText,
45
51
  isRowResizeHotspot,
46
52
  isRowResizingGlobal,
@@ -55,7 +61,7 @@ import {
55
61
  sanitizeUEditorUrl,
56
62
  useEditorColors,
57
63
  useSharedEditorUiRenderState
58
- } from "./chunk-OJF3XRN7.js";
64
+ } from "./chunk-BDRCOIYR.js";
59
65
  import {
60
66
  Tooltip,
61
67
  UEditorPortalProvider,
@@ -505,7 +511,7 @@ import { wrappingInputRule } from "@tiptap/core";
505
511
  import { ReactNodeViewRenderer as ReactNodeViewRenderer7 } from "@tiptap/react";
506
512
 
507
513
  // src/components/UEditor/callout.ts
508
- import { Node as Node2, mergeAttributes } from "@tiptap/core";
514
+ import { Node, mergeAttributes } from "@tiptap/core";
509
515
  import { ReactNodeViewRenderer } from "@tiptap/react";
510
516
 
511
517
  // src/components/UEditor/CalloutView.tsx
@@ -586,7 +592,7 @@ var CalloutView = ({ node, updateAttributes, selected }) => {
586
592
  };
587
593
 
588
594
  // src/components/UEditor/callout.ts
589
- var Callout = Node2.create({
595
+ var Callout = Node.create({
590
596
  name: "callout",
591
597
  group: "block",
592
598
  content: "block+",
@@ -642,7 +648,7 @@ var Callout = Node2.create({
642
648
  });
643
649
 
644
650
  // src/components/UEditor/bookmark.ts
645
- import { Node as Node3, mergeAttributes as mergeAttributes2 } from "@tiptap/core";
651
+ import { Node as Node2, mergeAttributes as mergeAttributes2 } from "@tiptap/core";
646
652
  import { ReactNodeViewRenderer as ReactNodeViewRenderer2 } from "@tiptap/react";
647
653
 
648
654
  // src/components/UEditor/BookmarkView.tsx
@@ -836,7 +842,7 @@ var BookmarkView = ({ node, updateAttributes, selected, editor }) => {
836
842
  // src/components/UEditor/bookmark.ts
837
843
  import { Plugin, PluginKey } from "@tiptap/pm/state";
838
844
  var URL_REGEX = /^(https?:\/\/[^\s]+)$/i;
839
- var Bookmark = Node3.create({
845
+ var Bookmark = Node2.create({
840
846
  name: "bookmark",
841
847
  group: "block",
842
848
  atom: true,
@@ -949,7 +955,7 @@ var Bookmark = Node3.create({
949
955
  });
950
956
 
951
957
  // src/components/UEditor/file-card.ts
952
- import { Node as Node4, mergeAttributes as mergeAttributes3 } from "@tiptap/core";
958
+ import { Node as Node3, mergeAttributes as mergeAttributes3 } from "@tiptap/core";
953
959
  import { ReactNodeViewRenderer as ReactNodeViewRenderer3 } from "@tiptap/react";
954
960
 
955
961
  // src/components/UEditor/FileCardView.tsx
@@ -1120,7 +1126,7 @@ var FileCardView = ({ node, selected, editor, updateAttributes }) => {
1120
1126
  };
1121
1127
 
1122
1128
  // src/components/UEditor/file-card.ts
1123
- var FileCard = Node4.create({
1129
+ var FileCard = Node3.create({
1124
1130
  name: "fileCard",
1125
1131
  group: "block",
1126
1132
  atom: true,
@@ -1210,7 +1216,7 @@ var FileCard = Node4.create({
1210
1216
  });
1211
1217
 
1212
1218
  // src/components/UEditor/form-checkbox.ts
1213
- import { Node as Node5, mergeAttributes as mergeAttributes4 } from "@tiptap/core";
1219
+ import { Node as Node4, mergeAttributes as mergeAttributes4 } from "@tiptap/core";
1214
1220
  import { ReactNodeViewRenderer as ReactNodeViewRenderer4 } from "@tiptap/react";
1215
1221
 
1216
1222
  // src/components/UEditor/FormCheckboxView.tsx
@@ -1272,7 +1278,7 @@ var FormCheckboxView = ({ node, updateAttributes, editor, selected }) => {
1272
1278
  };
1273
1279
 
1274
1280
  // src/components/UEditor/form-checkbox.ts
1275
- var FormCheckbox = Node5.create({
1281
+ var FormCheckbox = Node4.create({
1276
1282
  name: "formCheckbox",
1277
1283
  group: "inline",
1278
1284
  inline: true,
@@ -1365,7 +1371,7 @@ var FormCheckbox = Node5.create({
1365
1371
  });
1366
1372
 
1367
1373
  // src/components/UEditor/form-radio.ts
1368
- import { Node as Node6, mergeAttributes as mergeAttributes5 } from "@tiptap/core";
1374
+ import { Node as Node5, mergeAttributes as mergeAttributes5 } from "@tiptap/core";
1369
1375
  import { ReactNodeViewRenderer as ReactNodeViewRenderer5 } from "@tiptap/react";
1370
1376
 
1371
1377
  // src/components/UEditor/FormRadioView.tsx
@@ -1455,7 +1461,7 @@ var FormRadioView = ({ node, updateAttributes, editor, selected }) => {
1455
1461
  };
1456
1462
 
1457
1463
  // src/components/UEditor/form-radio.ts
1458
- var FormRadio = Node6.create({
1464
+ var FormRadio = Node5.create({
1459
1465
  name: "formRadio",
1460
1466
  group: "inline",
1461
1467
  inline: true,
@@ -3365,9 +3371,9 @@ function setColumnStyle(column, width) {
3365
3371
  column.style.minWidth = "";
3366
3372
  }
3367
3373
  function isTableColumnElement(node) {
3368
- return node instanceof HTMLElement && node.tagName.toLowerCase() === "col";
3374
+ return isCrossRealmElement(node) && String(node.tagName).toUpperCase() === "COL";
3369
3375
  }
3370
- function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue) {
3376
+ function updateDynamicColumns(node, colgroup, table, ownerDocument, overrideCol, overrideValue) {
3371
3377
  let totalWidth = 0;
3372
3378
  let nextDOM = colgroup.firstChild;
3373
3379
  const row = node.firstChild;
@@ -3378,7 +3384,7 @@ function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue)
3378
3384
  const rawWidth = overrideCol === col ? overrideValue : colwidth?.[spanIndex];
3379
3385
  const width = rawWidth ? Math.max(rawWidth, MIN_RESIZED_TABLE_COLUMN_WIDTH) : null;
3380
3386
  totalWidth += width ?? DEFAULT_TABLE_COLUMN_WIDTH;
3381
- const colElement = isTableColumnElement(nextDOM) ? nextDOM : colgroup.appendChild(document.createElement("col"));
3387
+ const colElement = isTableColumnElement(nextDOM) ? nextDOM : colgroup.appendChild(ownerDocument.createElement("col"));
3382
3388
  setColumnStyle(colElement, width);
3383
3389
  nextDOM = colElement.nextSibling;
3384
3390
  }
@@ -3398,23 +3404,25 @@ function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue)
3398
3404
  }
3399
3405
  }
3400
3406
  var UEditorTableView = class {
3401
- constructor(node) {
3407
+ constructor(node, _defaultColumnWidth, maybeView) {
3402
3408
  this.node = node;
3403
- this.dom = document.createElement("div");
3409
+ const view = maybeView ?? _defaultColumnWidth;
3410
+ const ownerDocument = view.dom.ownerDocument;
3411
+ this.dom = ownerDocument.createElement("div");
3404
3412
  this.dom.className = "tableWrapper";
3405
- this.table = this.dom.appendChild(document.createElement("table"));
3413
+ this.table = this.dom.appendChild(ownerDocument.createElement("table"));
3406
3414
  if (node.attrs.style) {
3407
3415
  this.table.style.cssText = node.attrs.style;
3408
3416
  }
3409
3417
  this.table.style.tableLayout = "fixed";
3410
- this.colgroup = this.table.appendChild(document.createElement("colgroup"));
3411
- updateDynamicColumns(node, this.colgroup, this.table);
3412
- this.contentDOM = this.table.appendChild(document.createElement("tbody"));
3418
+ this.colgroup = this.table.appendChild(ownerDocument.createElement("colgroup"));
3419
+ updateDynamicColumns(node, this.colgroup, this.table, ownerDocument);
3420
+ this.contentDOM = this.table.appendChild(ownerDocument.createElement("tbody"));
3413
3421
  }
3414
3422
  update(node) {
3415
3423
  if (node.type !== this.node.type) return false;
3416
3424
  this.node = node;
3417
- updateDynamicColumns(node, this.colgroup, this.table);
3425
+ updateDynamicColumns(node, this.colgroup, this.table, this.dom.ownerDocument);
3418
3426
  return true;
3419
3427
  }
3420
3428
  ignoreMutation(mutation) {
@@ -3436,7 +3444,7 @@ function getCurrentColWidth(view, cellPos, { colspan, colwidth }) {
3436
3444
  if (width) return width;
3437
3445
  const dom = view.domAtPos(cellPos);
3438
3446
  const cellElement = dom.node.childNodes[dom.offset];
3439
- let domWidth = cellElement instanceof HTMLElement ? cellElement.offsetWidth : 0;
3447
+ let domWidth = isCrossRealmHTMLElement(cellElement) ? cellElement.offsetWidth : 0;
3440
3448
  let parts = Math.max(1, colspan);
3441
3449
  if (colwidth) {
3442
3450
  for (let index = 0; index < colspan; index += 1) {
@@ -3449,14 +3457,14 @@ function getCurrentColWidth(view, cellPos, { colspan, colwidth }) {
3449
3457
  }
3450
3458
  return domWidth / Math.max(1, parts);
3451
3459
  }
3452
- function domCellAround(target) {
3453
- let node = target instanceof Node ? target : null;
3460
+ function domCellAround(view, target) {
3461
+ let node = isCrossRealmNode(target) ? target : null;
3454
3462
  while (node && node.nodeName !== "TD" && node.nodeName !== "TH") {
3455
- const element = node instanceof Element ? node : null;
3463
+ const element = isCrossRealmElement(node) ? node : null;
3456
3464
  if (element?.classList.contains("ProseMirror")) return null;
3457
3465
  node = node.parentNode;
3458
3466
  }
3459
- return node instanceof HTMLElement ? node : null;
3467
+ return isCrossRealmHTMLElement(node) ? node : null;
3460
3468
  }
3461
3469
  function edgeCell(view, event, side, handleWidth) {
3462
3470
  const offset = side === "right" ? -handleWidth : handleWidth;
@@ -3474,12 +3482,14 @@ function edgeCell(view, event, side, handleWidth) {
3474
3482
  return index % map.width === 0 ? -1 : start + map.map[index - 1];
3475
3483
  }
3476
3484
  var handleHoverTimer = null;
3485
+ var handleHoverWindow = null;
3477
3486
  var pendingHandleCell = -1;
3478
3487
  function clearHandleHoverTimer() {
3479
3488
  if (handleHoverTimer !== null) {
3480
- window.clearTimeout(handleHoverTimer);
3489
+ handleHoverWindow?.clearTimeout(handleHoverTimer);
3481
3490
  handleHoverTimer = null;
3482
3491
  }
3492
+ handleHoverWindow = null;
3483
3493
  pendingHandleCell = -1;
3484
3494
  }
3485
3495
  function updateHandle(view, value) {
@@ -3489,7 +3499,7 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
3489
3499
  if (!view.editable) return;
3490
3500
  const pluginState = columnResizingPluginKey.getState(view.state);
3491
3501
  if (!pluginState || pluginState.dragging) return;
3492
- const target = domCellAround(event.target);
3502
+ const target = domCellAround(view, event.target);
3493
3503
  let cell = -1;
3494
3504
  if (target) {
3495
3505
  const { left, right } = target.getBoundingClientRect();
@@ -3525,7 +3535,10 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
3525
3535
  if (pendingHandleCell === cell) return;
3526
3536
  clearHandleHoverTimer();
3527
3537
  pendingHandleCell = cell;
3528
- handleHoverTimer = window.setTimeout(() => {
3538
+ const ownerWindow = view.dom.ownerDocument.defaultView;
3539
+ if (!ownerWindow) return;
3540
+ handleHoverWindow = ownerWindow;
3541
+ handleHoverTimer = ownerWindow.setTimeout(() => {
3529
3542
  handleHoverTimer = null;
3530
3543
  pendingHandleCell = -1;
3531
3544
  updateHandle(view, cell);
@@ -3597,7 +3610,7 @@ function getTableElementAtCell(view, cell) {
3597
3610
  const $cell = view.state.doc.resolve(cell);
3598
3611
  let dom = view.domAtPos($cell.start(-1)).node;
3599
3612
  while (dom && dom.nodeName !== "TABLE") dom = dom.parentNode;
3600
- return dom instanceof HTMLTableElement ? dom : null;
3613
+ return isCrossRealmTable(dom) ? dom : null;
3601
3614
  }
3602
3615
  function showColumnResizeGhost(view, cell, dragging, width) {
3603
3616
  const table = getTableElementAtCell(view, cell);
@@ -3654,7 +3667,8 @@ function handleMouseDown(view, event, cellMinWidth) {
3654
3667
  event.preventDefault();
3655
3668
  return true;
3656
3669
  }
3657
- function handleDecorations(state, cell) {
3670
+ function handleDecorations(state, cell, ownerDocument) {
3671
+ if (!ownerDocument) return DecorationSet2.empty;
3658
3672
  const decorations = [];
3659
3673
  const $cell = state.doc.resolve(cell);
3660
3674
  const table = $cell.node(-1);
@@ -3671,7 +3685,7 @@ function handleDecorations(state, cell) {
3671
3685
  const cellNode = table.nodeAt(cellPos);
3672
3686
  if (!cellNode) continue;
3673
3687
  const pos = start + cellPos + cellNode.nodeSize - 1;
3674
- const dom = document.createElement("div");
3688
+ const dom = ownerDocument.createElement("div");
3675
3689
  dom.className = "column-resize-handle";
3676
3690
  if (columnResizingPluginKey.getState(state)?.dragging) {
3677
3691
  decorations.push(Decoration2.node(start + cellPos, start + cellPos + cellNode.nodeSize, { class: "column-resize-dragging" }));
@@ -3688,6 +3702,7 @@ function dynamicColumnResizing({
3688
3702
  View = UEditorTableView,
3689
3703
  lastColumnResizable = true
3690
3704
  } = {}) {
3705
+ let ownerDocument = null;
3691
3706
  const plugin = new Plugin3({
3692
3707
  key: columnResizingPluginKey,
3693
3708
  state: {
@@ -3695,7 +3710,10 @@ function dynamicColumnResizing({
3695
3710
  const nodeViews = plugin.spec.props?.nodeViews;
3696
3711
  const tableName = tableNodeTypes(state.schema).table.name;
3697
3712
  if (View && nodeViews) {
3698
- nodeViews[tableName] = (node, view) => new View(node, defaultCellMinWidth, view);
3713
+ nodeViews[tableName] = (node, view) => {
3714
+ ownerDocument = view.dom.ownerDocument;
3715
+ return new View(node, defaultCellMinWidth, view);
3716
+ };
3699
3717
  }
3700
3718
  return new ResizeState(-1, false);
3701
3719
  },
@@ -3720,7 +3738,7 @@ function dynamicColumnResizing({
3720
3738
  decorations: (state) => {
3721
3739
  const pluginState = columnResizingPluginKey.getState(state);
3722
3740
  if (pluginState && pluginState.activeHandle > -1) {
3723
- return handleDecorations(state, pluginState.activeHandle);
3741
+ return handleDecorations(state, pluginState.activeHandle, ownerDocument);
3724
3742
  }
3725
3743
  return void 0;
3726
3744
  },
@@ -8387,7 +8405,7 @@ var NodeRange = class {
8387
8405
  }
8388
8406
  };
8389
8407
  var emptyAttrs = /* @__PURE__ */ Object.create(null);
8390
- var Node7 = class _Node {
8408
+ var Node6 = class _Node {
8391
8409
  /**
8392
8410
  @internal
8393
8411
  */
@@ -8789,7 +8807,7 @@ var Node7 = class _Node {
8789
8807
  return node;
8790
8808
  }
8791
8809
  };
8792
- Node7.prototype.text = void 0;
8810
+ Node6.prototype.text = void 0;
8793
8811
  function wrapMarks(marks, str) {
8794
8812
  for (let i = marks.length - 1; i >= 0; i--)
8795
8813
  str = marks[i].type.name + "(" + str + ")";
@@ -11535,20 +11553,16 @@ import {
11535
11553
  var FALLBACK_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
11536
11554
  var FALLBACK_TABLE_COLUMN_WIDTH = 160;
11537
11555
  function isTableCellElement(element) {
11538
- const realm = element?.ownerDocument?.defaultView;
11539
- return Boolean(realm && element instanceof realm.HTMLTableCellElement);
11556
+ return isCrossRealmTableCell(element);
11540
11557
  }
11541
11558
  function isTableRowElement(element) {
11542
- const realm = element?.ownerDocument?.defaultView;
11543
- return Boolean(realm && element instanceof realm.HTMLTableRowElement);
11559
+ return isCrossRealmTableRow(element);
11544
11560
  }
11545
11561
  function isTableElement(element) {
11546
- const realm = element?.ownerDocument?.defaultView;
11547
- return Boolean(realm && element instanceof realm.HTMLTableElement);
11562
+ return isCrossRealmTable(element);
11548
11563
  }
11549
11564
  function isHTMLElement(element) {
11550
- const realm = element?.ownerDocument?.defaultView;
11551
- return Boolean(realm && element instanceof realm.HTMLElement);
11565
+ return isCrossRealmHTMLElement(element);
11552
11566
  }
11553
11567
  function getVisibleTableBounds(layout) {
11554
11568
  const left = Math.max(layout.tableLeft, layout.wrapperLeft);
@@ -11832,8 +11846,7 @@ var ADD_COLUMN_HOVER_WIDTH = 24;
11832
11846
  var ADD_ROW_HOVER_HEIGHT = 24;
11833
11847
  var HANDLE_HOVER_RADIUS = 14;
11834
11848
  function isHTMLElement2(element) {
11835
- const realm = element?.ownerDocument?.defaultView;
11836
- return Boolean(realm && element instanceof realm.HTMLElement);
11849
+ return isCrossRealmHTMLElement(element);
11837
11850
  }
11838
11851
  var DEFAULT_TABLE_HOVER_STATE = {
11839
11852
  menuVisible: false,
@@ -12325,7 +12338,7 @@ function TableResizeHandles({
12325
12338
  "data-table-resize-frame": "",
12326
12339
  "data-resizing": active ? "true" : "false",
12327
12340
  className: cn(
12328
- "pointer-events-none absolute z-[38] box-border border border-primary/55",
12341
+ "pointer-events-none absolute z-[38] box-border border border-transparent",
12329
12342
  active && "border-primary bg-primary/3"
12330
12343
  ),
12331
12344
  style: {
@@ -12552,7 +12565,7 @@ function getSelectedCell(editor) {
12552
12565
  const browserSelection = editorWindow?.getSelection();
12553
12566
  const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
12554
12567
  const anchorCell = anchorElement?.closest?.("th,td");
12555
- if (editorWindow && anchorCell instanceof editorWindow.HTMLTableCellElement) {
12568
+ if (isCrossRealmTableCell(anchorCell)) {
12556
12569
  return anchorCell;
12557
12570
  }
12558
12571
  const domAtPos = editor.view.domAtPos(editor.state.selection.from);
@@ -13615,12 +13628,12 @@ function useUEditorTableInteractions(editor, editable = true) {
13615
13628
  return;
13616
13629
  }
13617
13630
  const target = resolveEventElement(event.target);
13618
- if (!(target instanceof editorWindow.Element)) {
13631
+ if (!isCrossRealmElement(target)) {
13619
13632
  clearAllTableResizeHover();
13620
13633
  return;
13621
13634
  }
13622
13635
  const cell = target.closest("th,td");
13623
- if (!(cell instanceof editorWindow.HTMLElement)) {
13636
+ if (!isCrossRealmHTMLElement(cell)) {
13624
13637
  clearHoveredTableCell();
13625
13638
  clearAllTableResizeHover();
13626
13639
  return;
@@ -13628,7 +13641,7 @@ function useUEditorTableInteractions(editor, editable = true) {
13628
13641
  setHoveredTableCell(cell);
13629
13642
  const row = cell.closest("tr");
13630
13643
  const table = cell.closest("table");
13631
- if (!(row instanceof editorWindow.HTMLTableRowElement) || !(table instanceof editorWindow.HTMLTableElement)) {
13644
+ if (!isCrossRealmTableRow(row) || !isCrossRealmTable(table)) {
13632
13645
  clearHoveredTableCell();
13633
13646
  clearAllTableResizeHover();
13634
13647
  return;
@@ -13684,18 +13697,18 @@ function useUEditorTableInteractions(editor, editable = true) {
13684
13697
  const handleEditorMouseDown = (event) => {
13685
13698
  if (event.button !== 0) return;
13686
13699
  const target = resolveEventElement(event.target);
13687
- if (!(target instanceof editorWindow.Element)) {
13700
+ if (!isCrossRealmElement(target)) {
13688
13701
  clearActiveTableCell();
13689
13702
  return;
13690
13703
  }
13691
13704
  const cell = target.closest("th,td");
13692
- if (!(cell instanceof editorWindow.HTMLTableCellElement)) {
13705
+ if (!isCrossRealmTableCell(cell)) {
13693
13706
  clearActiveTableCell();
13694
13707
  return;
13695
13708
  }
13696
13709
  const row = cell.closest("tr");
13697
13710
  const table = cell.closest("table");
13698
- if (!(row instanceof editorWindow.HTMLTableRowElement) || !(table instanceof editorWindow.HTMLTableElement)) return;
13711
+ if (!isCrossRealmTableRow(row) || !isCrossRealmTable(table)) return;
13699
13712
  const rowTarget = resolveRowResizeTarget(cell, event.clientX, event.clientY);
13700
13713
  if (rowTarget) {
13701
13714
  event.preventDefault();
@@ -14525,7 +14538,7 @@ function useUEditorOutput({
14525
14538
  // src/components/UEditor/UEditor.tsx
14526
14539
  import { jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
14527
14540
  var LazyMenuBar = React15.lazy(async () => {
14528
- const { MenuBar } = await import("./menu-bar-4FM4Y273.js");
14541
+ const { MenuBar } = await import("./menu-bar-GKJEVLQU.js");
14529
14542
  return { default: MenuBar };
14530
14543
  });
14531
14544
  var UEditor = React15.forwardRef(({
@@ -14994,4 +15007,4 @@ export {
14994
15007
  prepareUEditorContentForSave,
14995
15008
  UEditor_default
14996
15009
  };
14997
- //# sourceMappingURL=chunk-XMAOZQJO.js.map
15010
+ //# sourceMappingURL=chunk-5ODK33CL.js.map