@underverse-ui/underverse 2.0.31 → 2.0.33

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/api-reference.json +9 -2
  3. package/dist/{EmojiPicker-ISJ6RXYG.js → EmojiPicker-6H52Q4YE.js} +4 -4
  4. package/dist/{chunk-ZP7F4ZD7.js → chunk-6FAHXNDQ.js} +5 -1
  5. package/dist/chunk-6FAHXNDQ.js.map +1 -0
  6. package/dist/{chunk-57BKIC6J.js → chunk-FQVWYDKP.js} +40 -21
  7. package/dist/chunk-FQVWYDKP.js.map +1 -0
  8. package/dist/{chunk-S4UHFRL3.js → chunk-L73HBI6E.js} +3 -3
  9. package/dist/{chunk-37MHVJMV.js → chunk-OTPC2OTQ.js} +20 -10
  10. package/dist/chunk-OTPC2OTQ.js.map +1 -0
  11. package/dist/{chunk-2P7TSXEE.js → chunk-UHUKUI5S.js} +3 -3
  12. package/dist/{chunk-5W63IHIN.js → chunk-W3QTP2DM.js} +2 -2
  13. package/dist/index.cjs +53 -23
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +9 -1
  16. package/dist/index.d.ts +9 -1
  17. package/dist/index.js +6 -6
  18. package/dist/index.js.map +1 -1
  19. package/dist/{menu-bar-DPCNNUX5.js → menu-bar-HZBBRX42.js} +4 -4
  20. package/dist/ueditor.cjs +53 -23
  21. package/dist/ueditor.cjs.map +1 -1
  22. package/dist/ueditor.d.cts +4 -1
  23. package/dist/ueditor.d.ts +4 -1
  24. package/dist/ueditor.js +4 -4
  25. package/package.json +1 -1
  26. package/dist/chunk-37MHVJMV.js.map +0 -1
  27. package/dist/chunk-57BKIC6J.js.map +0 -1
  28. package/dist/chunk-ZP7F4ZD7.js.map +0 -1
  29. /package/dist/{EmojiPicker-ISJ6RXYG.js.map → EmojiPicker-6H52Q4YE.js.map} +0 -0
  30. /package/dist/{chunk-S4UHFRL3.js.map → chunk-L73HBI6E.js.map} +0 -0
  31. /package/dist/{chunk-2P7TSXEE.js.map → chunk-UHUKUI5S.js.map} +0 -0
  32. /package/dist/{chunk-5W63IHIN.js.map → chunk-W3QTP2DM.js.map} +0 -0
  33. /package/dist/{menu-bar-DPCNNUX5.js.map → menu-bar-HZBBRX42.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EmojiGridButton
3
- } from "./chunk-5W63IHIN.js";
3
+ } from "./chunk-W3QTP2DM.js";
4
4
  import {
5
5
  EMOJI_LIST
6
6
  } from "./chunk-4TYW5K4J.js";
@@ -9,7 +9,7 @@ import {
9
9
  cn,
10
10
  formControlOutlineClass,
11
11
  useSmartTranslations
12
- } from "./chunk-ZP7F4ZD7.js";
12
+ } from "./chunk-6FAHXNDQ.js";
13
13
 
14
14
  // src/components/EmojiPicker.tsx
15
15
  import { useEffect, useMemo, useRef, useState } from "react";
@@ -205,4 +205,4 @@ export {
205
205
  EmojiPicker,
206
206
  EmojiPicker_default
207
207
  };
208
- //# sourceMappingURL=chunk-S4UHFRL3.js.map
208
+ //# sourceMappingURL=chunk-L73HBI6E.js.map
@@ -11,7 +11,7 @@ import {
11
11
  setRefValue,
12
12
  useSmartTranslations,
13
13
  useUEditorPortalContainerGetter
14
- } from "./chunk-ZP7F4ZD7.js";
14
+ } from "./chunk-6FAHXNDQ.js";
15
15
 
16
16
  // src/contexts/UnderverseConfigContext.tsx
17
17
  import * as React from "react";
@@ -3090,11 +3090,16 @@ function isCrossRealmTableRow(value) {
3090
3090
  function isCrossRealmTableCell(value) {
3091
3091
  return isCrossRealmElement(value) && ["TD", "TH"].includes(String(value.tagName).toUpperCase()) && "cellIndex" in value;
3092
3092
  }
3093
+ function isValidProseMirrorPosition(doc, pos) {
3094
+ return Number.isInteger(pos) && pos >= 0 && pos <= doc.content.size;
3095
+ }
3093
3096
  var TABLE_RESIZE_HIT_ZONE = 5;
3094
3097
  function findTableRowNodeInfo(view, rowElement) {
3098
+ if (!view.dom.contains(rowElement)) return null;
3095
3099
  const firstCell = rowElement.querySelector("th,td");
3096
- if (!firstCell) return null;
3100
+ if (!isCrossRealmTableCell(firstCell) || !view.dom.contains(firstCell)) return null;
3097
3101
  const cellPos = view.posAtDOM(firstCell, 0);
3102
+ if (!isValidProseMirrorPosition(view.state.doc, cellPos)) return null;
3098
3103
  const $pos = view.state.doc.resolve(cellPos);
3099
3104
  for (let depth = $pos.depth; depth > 0; depth -= 1) {
3100
3105
  const node = $pos.node(depth);
@@ -3136,14 +3141,14 @@ function getSelectionTableCell(view) {
3136
3141
  const browserSelection = realm?.getSelection();
3137
3142
  const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
3138
3143
  const anchorCell = anchorElement?.closest?.("th,td");
3139
- if (realm && anchorCell instanceof realm.HTMLElement) {
3144
+ if (isCrossRealmTableCell(anchorCell) && view.dom.contains(anchorCell)) {
3140
3145
  return anchorCell;
3141
3146
  }
3142
3147
  const { from } = view.state.selection;
3143
3148
  const domAtPos = view.domAtPos(from);
3144
3149
  const element = resolveEventElement(domAtPos.node);
3145
3150
  const cell = element?.closest?.("th,td");
3146
- return realm && cell instanceof realm.HTMLElement ? cell : null;
3151
+ return isCrossRealmTableCell(cell) && view.dom.contains(cell) ? cell : null;
3147
3152
  }
3148
3153
  function resolveRowResizeTarget(cell, clientX, clientY) {
3149
3154
  const rect = cell.getBoundingClientRect();
@@ -4327,18 +4332,22 @@ function getTableAnchorPos(editor) {
4327
4332
  const editorWindow = editorDocument.defaultView;
4328
4333
  const selectionAnchor = resolveEventElement(editorWindow?.getSelection()?.anchorNode ?? null);
4329
4334
  const selectionCell = selectionAnchor?.closest?.("th,td");
4330
- if (editorWindow && selectionCell instanceof editorWindow.HTMLTableCellElement && editor.view.dom.contains(selectionCell)) {
4331
- return editor.view.posAtDOM(selectionCell, 0) + 1;
4335
+ if (isCrossRealmTableCell(selectionCell) && editor.view.dom.contains(selectionCell)) {
4336
+ const cellPos2 = editor.view.posAtDOM(selectionCell, 0);
4337
+ return isValidProseMirrorPosition(editor.state.doc, cellPos2) && isValidProseMirrorPosition(editor.state.doc, cellPos2 + 1) ? cellPos2 + 1 : null;
4332
4338
  }
4333
4339
  const activeElement = editorWindow && editorDocument.activeElement instanceof editorWindow.Element ? editorDocument.activeElement : null;
4334
4340
  const activeCell = activeElement?.closest?.("th,td");
4335
- if (editorWindow && activeCell instanceof editorWindow.HTMLTableCellElement && editor.view.dom.contains(activeCell)) {
4336
- return editor.view.posAtDOM(activeCell, 0) + 1;
4341
+ if (isCrossRealmTableCell(activeCell) && editor.view.dom.contains(activeCell)) {
4342
+ const cellPos2 = editor.view.posAtDOM(activeCell, 0);
4343
+ return isValidProseMirrorPosition(editor.state.doc, cellPos2) && isValidProseMirrorPosition(editor.state.doc, cellPos2 + 1) ? cellPos2 + 1 : null;
4337
4344
  }
4338
4345
  const tables = editor.view.dom.querySelectorAll("table");
4339
4346
  if (tables.length !== 1) return null;
4340
4347
  const firstCell = tables[0]?.querySelector("th,td");
4341
- return editorWindow && firstCell instanceof editorWindow.HTMLTableCellElement ? editor.view.posAtDOM(firstCell, 0) + 1 : null;
4348
+ if (!isCrossRealmTableCell(firstCell) || !editor.view.dom.contains(firstCell)) return null;
4349
+ const cellPos = editor.view.posAtDOM(firstCell, 0);
4350
+ return isValidProseMirrorPosition(editor.state.doc, cellPos) && isValidProseMirrorPosition(editor.state.doc, cellPos + 1) ? cellPos + 1 : null;
4342
4351
  }
4343
4352
  var EDITOR_UI_ACTIVE_MARKS = [
4344
4353
  "blockquote",
@@ -5758,6 +5767,7 @@ export {
5758
5767
  isCrossRealmTable,
5759
5768
  isCrossRealmTableRow,
5760
5769
  isCrossRealmTableCell,
5770
+ isValidProseMirrorPosition,
5761
5771
  findTableRowNodeInfo,
5762
5772
  resolveEventElement,
5763
5773
  isPointOverRenderedText,
@@ -5817,4 +5827,4 @@ export {
5817
5827
  EditorToolbar,
5818
5828
  UEDITOR_PROSEMIRROR_CLASS_NAME
5819
5829
  };
5820
- //# sourceMappingURL=chunk-37MHVJMV.js.map
5830
+ //# sourceMappingURL=chunk-OTPC2OTQ.js.map