@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,7 +1,7 @@
1
1
  import {
2
2
  EmojiGridButton,
3
3
  formatEmojiCountLabel
4
- } from "./chunk-5W63IHIN.js";
4
+ } from "./chunk-W3QTP2DM.js";
5
5
  import {
6
6
  COLUMN_RESIZE_LINE_THICKNESS,
7
7
  CellBgColorIcon,
@@ -72,6 +72,7 @@ import {
72
72
  isRowResizeHotspot,
73
73
  isRowResizingGlobal,
74
74
  isSafeUEditorUrl,
75
+ isValidProseMirrorPosition,
75
76
  mergeTableCellsPreservingColumnWidths,
76
77
  moveResponsiveColumnRatio,
77
78
  normalizeColumnRatios,
@@ -93,7 +94,7 @@ import {
93
94
  sanitizeUEditorUrl,
94
95
  useEditorColors,
95
96
  useSharedEditorUiRenderState
96
- } from "./chunk-37MHVJMV.js";
97
+ } from "./chunk-OTPC2OTQ.js";
97
98
  import {
98
99
  Tooltip,
99
100
  UEditorPortalProvider,
@@ -103,7 +104,7 @@ import {
103
104
  resolveUEditorPortalContainer,
104
105
  useSmartTranslations,
105
106
  useUEditorPortalContainerGetter
106
- } from "./chunk-ZP7F4ZD7.js";
107
+ } from "./chunk-6FAHXNDQ.js";
107
108
 
108
109
  // src/components/UEditor/prepare-content-for-save.ts
109
110
  var MIME_EXTENSION_MAP = {
@@ -556,7 +557,7 @@ import { NodeViewWrapper, NodeViewContent } from "@tiptap/react";
556
557
  import React from "react";
557
558
  import { jsx } from "react/jsx-runtime";
558
559
  var LazyBaseEmojiPicker = React.lazy(async () => {
559
- const { EmojiPicker: EmojiPicker2 } = await import("./EmojiPicker-ISJ6RXYG.js");
560
+ const { EmojiPicker: EmojiPicker2 } = await import("./EmojiPicker-6H52Q4YE.js");
560
561
  return { default: EmojiPicker2 };
561
562
  });
562
563
  var EmojiPicker = ({ onSelect }) => {
@@ -6102,6 +6103,7 @@ function getBubbleMenuPosition({
6102
6103
  end,
6103
6104
  menuSize,
6104
6105
  viewport,
6106
+ preferredPlacement = "auto",
6105
6107
  offset = 16,
6106
6108
  padding = 8
6107
6109
  }) {
@@ -6109,7 +6111,7 @@ function getBubbleMenuPosition({
6109
6111
  const selectionBottom = Math.max(start.bottom, end.bottom);
6110
6112
  const spaceAbove = selectionTop - offset - padding;
6111
6113
  const spaceBelow = viewport.height - padding - selectionBottom - offset;
6112
- const placement = menuSize.height <= spaceAbove || spaceAbove >= spaceBelow ? "top" : "bottom";
6114
+ const placement = preferredPlacement === "auto" ? menuSize.height <= spaceAbove || spaceAbove >= spaceBelow ? "top" : "bottom" : preferredPlacement;
6113
6115
  const halfWidth = menuSize.width / 2;
6114
6116
  const minLeft = padding + halfWidth;
6115
6117
  const maxLeft = viewport.width - padding - halfWidth;
@@ -7013,6 +7015,7 @@ var LinkPreviewContent = ({ editor, onEdit }) => {
7013
7015
  };
7014
7016
  var CustomBubbleMenu = ({
7015
7017
  editor,
7018
+ placement = "auto",
7016
7019
  fontSizes,
7017
7020
  lineHeights
7018
7021
  }) => {
@@ -7106,6 +7109,7 @@ var CustomBubbleMenu = ({
7106
7109
  width: editorWindow?.innerWidth ?? window.innerWidth,
7107
7110
  height: editorWindow?.innerHeight ?? window.innerHeight
7108
7111
  },
7112
+ preferredPlacement: placement,
7109
7113
  offset: BUBBLE_MENU_OFFSET
7110
7114
  }));
7111
7115
  if (keepOpenRef.current) {
@@ -7152,7 +7156,7 @@ var CustomBubbleMenu = ({
7152
7156
  editorWindow?.removeEventListener("resize", schedulePositionUpdate);
7153
7157
  editorWindow?.removeEventListener("scroll", schedulePositionUpdate, true);
7154
7158
  };
7155
- }, [editor, editorDocument, editorWindow]);
7159
+ }, [editor, editorDocument, editorWindow, placement]);
7156
7160
  useEffect5(() => {
7157
7161
  if (!isVisible || !portalWindow?.ResizeObserver) return;
7158
7162
  const menu = menuRef.current;
@@ -7206,6 +7210,7 @@ var CustomBubbleMenu = ({
7206
7210
  {
7207
7211
  ref: menuRef,
7208
7212
  "data-popover": true,
7213
+ "data-placement": position.placement,
7209
7214
  className: "fixed z-[99999] flex rounded-xl border border-border/40 bg-card text-card-foreground shadow-lg backdrop-blur-sm overflow-hidden animate-in fade-in-0 zoom-in-95",
7210
7215
  style: {
7211
7216
  top: `${position.top}px`,
@@ -11540,6 +11545,7 @@ import {
11540
11545
  ArrowRight as ArrowRight2,
11541
11546
  ArrowUp,
11542
11547
  Copy as Copy2,
11548
+ Minimize2,
11543
11549
  Paintbrush,
11544
11550
  Table as TableIcon,
11545
11551
  Trash2 as Trash22
@@ -11606,6 +11612,7 @@ function getCellFromTarget(target) {
11606
11612
  return null;
11607
11613
  }
11608
11614
  function findTableInfo(editor, pos) {
11615
+ if (!isValidProseMirrorPosition(editor.state.doc, pos)) return null;
11609
11616
  const $pos = editor.state.doc.resolve(pos);
11610
11617
  for (let depth = $pos.depth; depth > 0; depth -= 1) {
11611
11618
  const node = $pos.node(depth);
@@ -11648,6 +11655,7 @@ function buildLogicalColumnMetrics({
11648
11655
  for (const tableCell of Array.from(firstRow.cells)) {
11649
11656
  if (!isTableCellElement(tableCell)) continue;
11650
11657
  const cellPos = editor.view.posAtDOM(tableCell, 0);
11658
+ if (!isValidProseMirrorPosition(editor.state.doc, cellPos)) continue;
11651
11659
  const relativeCellPos = getCellRelativePosFromDomPos(map, tableInfo.start, cellPos);
11652
11660
  if (relativeCellPos == null) continue;
11653
11661
  const cellMapRect = map.findCell(relativeCellPos);
@@ -11721,18 +11729,20 @@ function buildLogicalRowMetrics({
11721
11729
  if (visualRows.length > 0) {
11722
11730
  return visualRows.sort((a, b) => a.index - b.index);
11723
11731
  }
11724
- return rows.map((tableRow, index) => {
11732
+ return rows.flatMap((tableRow, index) => {
11725
11733
  const rowRect = tableRow.getBoundingClientRect();
11726
11734
  const anchorCell = tableRow.cells.item(0) ?? cornerCell;
11727
11735
  const start = rowRect.height > 0 ? rowRect.top - surfaceRect.top - surface.clientTop + surface.scrollTop : tableTop + index * fallbackHeight;
11728
11736
  const size = metricOrFallback(rowRect.height, fallbackHeight);
11729
- return {
11737
+ const cellPos = editor.view.posAtDOM(anchorCell, 0);
11738
+ if (!isValidProseMirrorPosition(editor.state.doc, cellPos)) return [];
11739
+ return [{
11730
11740
  index,
11731
- cellPos: editor.view.posAtDOM(anchorCell, 0),
11741
+ cellPos,
11732
11742
  start,
11733
11743
  size,
11734
11744
  center: start + size / 2
11735
- };
11745
+ }];
11736
11746
  });
11737
11747
  }
11738
11748
  function getTableCellTextSelectionRange(editor, cellPos) {
@@ -11752,6 +11762,7 @@ function getTableCellTextSelectionRange(editor, cellPos) {
11752
11762
  return from !== null && to !== null && from < to ? { from, to } : null;
11753
11763
  }
11754
11764
  function buildTableControlLayout(editor, surface, cell) {
11765
+ if (!editor.view.dom.contains(cell)) return null;
11755
11766
  const row = cell.closest("tr");
11756
11767
  const table = cell.closest("table");
11757
11768
  if (!isTableRowElement(row) || !isTableElement(table)) {
@@ -11760,6 +11771,7 @@ function buildTableControlLayout(editor, surface, cell) {
11760
11771
  const rows = Array.from(table.rows).filter(isTableRowElement);
11761
11772
  const cornerCell = getLastCell(table);
11762
11773
  const cellPos = editor.view.posAtDOM(cell, 0);
11774
+ if (!isValidProseMirrorPosition(editor.state.doc, cellPos)) return null;
11763
11775
  const tableInfo = findTableInfo(editor, cellPos);
11764
11776
  if (rows.length === 0 || !tableInfo || !isTableCellElement(cornerCell)) {
11765
11777
  return null;
@@ -12703,7 +12715,7 @@ function getSelectedCell(editor) {
12703
12715
  const browserSelection = editorWindow?.getSelection();
12704
12716
  const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
12705
12717
  const anchorCell = anchorElement?.closest?.("th,td");
12706
- if (isCrossRealmTableCell(anchorCell)) {
12718
+ if (isCrossRealmTableCell(anchorCell) && editor.view.dom.contains(anchorCell)) {
12707
12719
  return anchorCell;
12708
12720
  }
12709
12721
  const domAtPos = editor.view.domAtPos(editor.state.selection.from);
@@ -13013,8 +13025,8 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
13013
13025
  updateTableResizePreview(pendingDimensions);
13014
13026
  setDocumentCursor(editorDocument, edge === "both" ? "nwse-resize" : "ew-resize");
13015
13027
  }, [editor, editorDocument, updateTableResizePreview]);
13016
- const fitTableToEditorWidth = React11.useCallback((event) => {
13017
- if (event.button !== 0 || dragStateRef.current) return;
13028
+ const fitTableToEditorWidth = React11.useCallback(() => {
13029
+ if (dragStateRef.current) return;
13018
13030
  const activeLayout = layoutRef.current;
13019
13031
  if (!activeLayout) return;
13020
13032
  const snapshot = createTableSizeSnapshot(
@@ -13025,8 +13037,6 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
13025
13037
  activeLayout.viewportWidth
13026
13038
  );
13027
13039
  if (!snapshot) return;
13028
- event.preventDefault();
13029
- event.stopPropagation();
13030
13040
  const didResize = applyTableSize(editor, snapshot, {
13031
13041
  width: Math.round(activeLayout.viewportWidth),
13032
13042
  height: snapshot.startHeight,
@@ -13414,6 +13424,11 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
13414
13424
  icon: Paintbrush,
13415
13425
  onClick: openCellInspector
13416
13426
  }] : [],
13427
+ {
13428
+ label: t("tableMenu.fitToEditorWidth"),
13429
+ icon: Minimize2,
13430
+ onClick: fitTableToEditorWidth
13431
+ },
13417
13432
  {
13418
13433
  label: t("tableMenu.alignLeft"),
13419
13434
  icon: AlignLeft2,
@@ -13478,7 +13493,7 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
13478
13493
  destructive: true
13479
13494
  }
13480
13495
  ];
13481
- }, [editor, layout, openCellInspector, runAtActiveCell, showCellInspector, t]);
13496
+ }, [editor, fitTableToEditorWidth, layout, openCellInspector, runAtActiveCell, showCellInspector, t]);
13482
13497
  const getRowHandleMenuItems = React11.useCallback((rowHandle) => [
13483
13498
  {
13484
13499
  label: t("tableMenu.addRowBefore"),
@@ -14171,12 +14186,12 @@ function getFormulaEditingTableContext(view) {
14171
14186
  if (!getCellText2(node).startsWith("=")) return null;
14172
14187
  const cellPos = $from.before(depth);
14173
14188
  const cellDom = view.nodeDOM(cellPos);
14174
- if (!(cellDom instanceof HTMLTableCellElement)) return null;
14189
+ if (!isCrossRealmTableCell(cellDom) || !view.dom.contains(cellDom)) return null;
14175
14190
  const tableDepth = depth - 2;
14176
14191
  const tableNode = tableDepth > 0 ? $from.node(tableDepth) : null;
14177
14192
  if (!tableNode || tableNode.type.name !== "table") return null;
14178
14193
  const tableDom = cellDom.closest("table");
14179
- if (!(tableDom instanceof HTMLTableElement)) return null;
14194
+ if (!isCrossRealmTable(tableDom) || !view.dom.contains(tableDom)) return null;
14180
14195
  const tableMap = TableMap4.get(tableNode);
14181
14196
  const tableStart = $from.start(tableDepth);
14182
14197
  const formulaCellRect = tableMap.findCell(cellPos - tableStart);
@@ -14248,6 +14263,7 @@ function getReferenceInsertionPrefix(view, cellContentStart, insertionPos) {
14248
14263
  return isInsideFunctionArguments && followsReference ? "," : "";
14249
14264
  }
14250
14265
  function findTableForPos(view, pos) {
14266
+ if (!isValidProseMirrorPosition(view.state.doc, pos)) return null;
14251
14267
  const $pos = view.state.doc.resolve(pos);
14252
14268
  for (let depth = $pos.depth; depth > 0; depth -= 1) {
14253
14269
  const node = $pos.node(depth);
@@ -14276,8 +14292,9 @@ function getCellRelativePosFromDomPos2(map, tableStart, domPos) {
14276
14292
  function getFormulaTableCellInfo(view, target, tablePos) {
14277
14293
  const element = resolveEventElement(target);
14278
14294
  const cell = element?.closest?.("th,td");
14279
- if (!(cell instanceof HTMLTableCellElement)) return null;
14295
+ if (!isCrossRealmTableCell(cell) || !view.dom.contains(cell)) return null;
14280
14296
  const domPos = view.posAtDOM(cell, 0);
14297
+ if (!isValidProseMirrorPosition(view.state.doc, domPos)) return null;
14281
14298
  const tableInfo = findTableForPos(view, domPos);
14282
14299
  if (!tableInfo || tableInfo.pos !== tablePos) return null;
14283
14300
  const map = TableMap4.get(tableInfo.node);
@@ -14936,7 +14953,7 @@ function useWideTableLayout(editor, enabled, widthBoundaryRef, editorShellRef, e
14936
14953
  // src/components/UEditor/UEditor.tsx
14937
14954
  import { jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
14938
14955
  var LazyMenuBar = React17.lazy(async () => {
14939
- const { MenuBar } = await import("./menu-bar-DPCNNUX5.js");
14956
+ const { MenuBar } = await import("./menu-bar-HZBBRX42.js");
14940
14957
  return { default: MenuBar };
14941
14958
  });
14942
14959
  var UEditor = React17.forwardRef(({
@@ -14963,6 +14980,7 @@ var UEditor = React17.forwardRef(({
14963
14980
  autofocus = false,
14964
14981
  showToolbar = true,
14965
14982
  showBubbleMenu = true,
14983
+ bubbleMenuPlacement = "auto",
14966
14984
  showFloatingMenu = false,
14967
14985
  showCharacterCount = true,
14968
14986
  showFooter = true,
@@ -15322,6 +15340,7 @@ var UEditor = React17.forwardRef(({
15322
15340
  CustomBubbleMenu,
15323
15341
  {
15324
15342
  editor,
15343
+ placement: bubbleMenuPlacement,
15325
15344
  fontSizes,
15326
15345
  lineHeights
15327
15346
  }
@@ -15429,4 +15448,4 @@ export {
15429
15448
  prepareUEditorContentForSave,
15430
15449
  UEditor_default
15431
15450
  };
15432
- //# sourceMappingURL=chunk-57BKIC6J.js.map
15451
+ //# sourceMappingURL=chunk-FQVWYDKP.js.map