@underverse-ui/underverse 2.0.31 → 2.0.32
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/CHANGELOG.md +10 -0
- package/api-reference.json +9 -2
- package/dist/{chunk-37MHVJMV.js → chunk-4TXHZS3S.js} +19 -9
- package/dist/chunk-4TXHZS3S.js.map +1 -0
- package/dist/{chunk-57BKIC6J.js → chunk-C4KZOMP3.js} +28 -13
- package/dist/chunk-C4KZOMP3.js.map +1 -0
- package/dist/{chunk-2P7TSXEE.js → chunk-RSSSQS2A.js} +2 -2
- package/dist/index.cjs +41 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{menu-bar-DPCNNUX5.js → menu-bar-GDDGHNNJ.js} +3 -3
- package/dist/ueditor.cjs +41 -18
- package/dist/ueditor.cjs.map +1 -1
- package/dist/ueditor.d.cts +4 -1
- package/dist/ueditor.d.ts +4 -1
- package/dist/ueditor.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-37MHVJMV.js.map +0 -1
- package/dist/chunk-57BKIC6J.js.map +0 -1
- /package/dist/{chunk-2P7TSXEE.js.map → chunk-RSSSQS2A.js.map} +0 -0
- /package/dist/{menu-bar-DPCNNUX5.js.map → menu-bar-GDDGHNNJ.js.map} +0 -0
|
@@ -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-
|
|
97
|
+
} from "./chunk-4TXHZS3S.js";
|
|
97
98
|
import {
|
|
98
99
|
Tooltip,
|
|
99
100
|
UEditorPortalProvider,
|
|
@@ -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`,
|
|
@@ -11606,6 +11611,7 @@ function getCellFromTarget(target) {
|
|
|
11606
11611
|
return null;
|
|
11607
11612
|
}
|
|
11608
11613
|
function findTableInfo(editor, pos) {
|
|
11614
|
+
if (!isValidProseMirrorPosition(editor.state.doc, pos)) return null;
|
|
11609
11615
|
const $pos = editor.state.doc.resolve(pos);
|
|
11610
11616
|
for (let depth = $pos.depth; depth > 0; depth -= 1) {
|
|
11611
11617
|
const node = $pos.node(depth);
|
|
@@ -11648,6 +11654,7 @@ function buildLogicalColumnMetrics({
|
|
|
11648
11654
|
for (const tableCell of Array.from(firstRow.cells)) {
|
|
11649
11655
|
if (!isTableCellElement(tableCell)) continue;
|
|
11650
11656
|
const cellPos = editor.view.posAtDOM(tableCell, 0);
|
|
11657
|
+
if (!isValidProseMirrorPosition(editor.state.doc, cellPos)) continue;
|
|
11651
11658
|
const relativeCellPos = getCellRelativePosFromDomPos(map, tableInfo.start, cellPos);
|
|
11652
11659
|
if (relativeCellPos == null) continue;
|
|
11653
11660
|
const cellMapRect = map.findCell(relativeCellPos);
|
|
@@ -11721,18 +11728,20 @@ function buildLogicalRowMetrics({
|
|
|
11721
11728
|
if (visualRows.length > 0) {
|
|
11722
11729
|
return visualRows.sort((a, b) => a.index - b.index);
|
|
11723
11730
|
}
|
|
11724
|
-
return rows.
|
|
11731
|
+
return rows.flatMap((tableRow, index) => {
|
|
11725
11732
|
const rowRect = tableRow.getBoundingClientRect();
|
|
11726
11733
|
const anchorCell = tableRow.cells.item(0) ?? cornerCell;
|
|
11727
11734
|
const start = rowRect.height > 0 ? rowRect.top - surfaceRect.top - surface.clientTop + surface.scrollTop : tableTop + index * fallbackHeight;
|
|
11728
11735
|
const size = metricOrFallback(rowRect.height, fallbackHeight);
|
|
11729
|
-
|
|
11736
|
+
const cellPos = editor.view.posAtDOM(anchorCell, 0);
|
|
11737
|
+
if (!isValidProseMirrorPosition(editor.state.doc, cellPos)) return [];
|
|
11738
|
+
return [{
|
|
11730
11739
|
index,
|
|
11731
|
-
cellPos
|
|
11740
|
+
cellPos,
|
|
11732
11741
|
start,
|
|
11733
11742
|
size,
|
|
11734
11743
|
center: start + size / 2
|
|
11735
|
-
};
|
|
11744
|
+
}];
|
|
11736
11745
|
});
|
|
11737
11746
|
}
|
|
11738
11747
|
function getTableCellTextSelectionRange(editor, cellPos) {
|
|
@@ -11752,6 +11761,7 @@ function getTableCellTextSelectionRange(editor, cellPos) {
|
|
|
11752
11761
|
return from !== null && to !== null && from < to ? { from, to } : null;
|
|
11753
11762
|
}
|
|
11754
11763
|
function buildTableControlLayout(editor, surface, cell) {
|
|
11764
|
+
if (!editor.view.dom.contains(cell)) return null;
|
|
11755
11765
|
const row = cell.closest("tr");
|
|
11756
11766
|
const table = cell.closest("table");
|
|
11757
11767
|
if (!isTableRowElement(row) || !isTableElement(table)) {
|
|
@@ -11760,6 +11770,7 @@ function buildTableControlLayout(editor, surface, cell) {
|
|
|
11760
11770
|
const rows = Array.from(table.rows).filter(isTableRowElement);
|
|
11761
11771
|
const cornerCell = getLastCell(table);
|
|
11762
11772
|
const cellPos = editor.view.posAtDOM(cell, 0);
|
|
11773
|
+
if (!isValidProseMirrorPosition(editor.state.doc, cellPos)) return null;
|
|
11763
11774
|
const tableInfo = findTableInfo(editor, cellPos);
|
|
11764
11775
|
if (rows.length === 0 || !tableInfo || !isTableCellElement(cornerCell)) {
|
|
11765
11776
|
return null;
|
|
@@ -12703,7 +12714,7 @@ function getSelectedCell(editor) {
|
|
|
12703
12714
|
const browserSelection = editorWindow?.getSelection();
|
|
12704
12715
|
const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
|
|
12705
12716
|
const anchorCell = anchorElement?.closest?.("th,td");
|
|
12706
|
-
if (isCrossRealmTableCell(anchorCell)) {
|
|
12717
|
+
if (isCrossRealmTableCell(anchorCell) && editor.view.dom.contains(anchorCell)) {
|
|
12707
12718
|
return anchorCell;
|
|
12708
12719
|
}
|
|
12709
12720
|
const domAtPos = editor.view.domAtPos(editor.state.selection.from);
|
|
@@ -14171,12 +14182,12 @@ function getFormulaEditingTableContext(view) {
|
|
|
14171
14182
|
if (!getCellText2(node).startsWith("=")) return null;
|
|
14172
14183
|
const cellPos = $from.before(depth);
|
|
14173
14184
|
const cellDom = view.nodeDOM(cellPos);
|
|
14174
|
-
if (!(cellDom
|
|
14185
|
+
if (!isCrossRealmTableCell(cellDom) || !view.dom.contains(cellDom)) return null;
|
|
14175
14186
|
const tableDepth = depth - 2;
|
|
14176
14187
|
const tableNode = tableDepth > 0 ? $from.node(tableDepth) : null;
|
|
14177
14188
|
if (!tableNode || tableNode.type.name !== "table") return null;
|
|
14178
14189
|
const tableDom = cellDom.closest("table");
|
|
14179
|
-
if (!(tableDom
|
|
14190
|
+
if (!isCrossRealmTable(tableDom) || !view.dom.contains(tableDom)) return null;
|
|
14180
14191
|
const tableMap = TableMap4.get(tableNode);
|
|
14181
14192
|
const tableStart = $from.start(tableDepth);
|
|
14182
14193
|
const formulaCellRect = tableMap.findCell(cellPos - tableStart);
|
|
@@ -14248,6 +14259,7 @@ function getReferenceInsertionPrefix(view, cellContentStart, insertionPos) {
|
|
|
14248
14259
|
return isInsideFunctionArguments && followsReference ? "," : "";
|
|
14249
14260
|
}
|
|
14250
14261
|
function findTableForPos(view, pos) {
|
|
14262
|
+
if (!isValidProseMirrorPosition(view.state.doc, pos)) return null;
|
|
14251
14263
|
const $pos = view.state.doc.resolve(pos);
|
|
14252
14264
|
for (let depth = $pos.depth; depth > 0; depth -= 1) {
|
|
14253
14265
|
const node = $pos.node(depth);
|
|
@@ -14276,8 +14288,9 @@ function getCellRelativePosFromDomPos2(map, tableStart, domPos) {
|
|
|
14276
14288
|
function getFormulaTableCellInfo(view, target, tablePos) {
|
|
14277
14289
|
const element = resolveEventElement(target);
|
|
14278
14290
|
const cell = element?.closest?.("th,td");
|
|
14279
|
-
if (!(cell
|
|
14291
|
+
if (!isCrossRealmTableCell(cell) || !view.dom.contains(cell)) return null;
|
|
14280
14292
|
const domPos = view.posAtDOM(cell, 0);
|
|
14293
|
+
if (!isValidProseMirrorPosition(view.state.doc, domPos)) return null;
|
|
14281
14294
|
const tableInfo = findTableForPos(view, domPos);
|
|
14282
14295
|
if (!tableInfo || tableInfo.pos !== tablePos) return null;
|
|
14283
14296
|
const map = TableMap4.get(tableInfo.node);
|
|
@@ -14936,7 +14949,7 @@ function useWideTableLayout(editor, enabled, widthBoundaryRef, editorShellRef, e
|
|
|
14936
14949
|
// src/components/UEditor/UEditor.tsx
|
|
14937
14950
|
import { jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
14938
14951
|
var LazyMenuBar = React17.lazy(async () => {
|
|
14939
|
-
const { MenuBar } = await import("./menu-bar-
|
|
14952
|
+
const { MenuBar } = await import("./menu-bar-GDDGHNNJ.js");
|
|
14940
14953
|
return { default: MenuBar };
|
|
14941
14954
|
});
|
|
14942
14955
|
var UEditor = React17.forwardRef(({
|
|
@@ -14963,6 +14976,7 @@ var UEditor = React17.forwardRef(({
|
|
|
14963
14976
|
autofocus = false,
|
|
14964
14977
|
showToolbar = true,
|
|
14965
14978
|
showBubbleMenu = true,
|
|
14979
|
+
bubbleMenuPlacement = "auto",
|
|
14966
14980
|
showFloatingMenu = false,
|
|
14967
14981
|
showCharacterCount = true,
|
|
14968
14982
|
showFooter = true,
|
|
@@ -15322,6 +15336,7 @@ var UEditor = React17.forwardRef(({
|
|
|
15322
15336
|
CustomBubbleMenu,
|
|
15323
15337
|
{
|
|
15324
15338
|
editor,
|
|
15339
|
+
placement: bubbleMenuPlacement,
|
|
15325
15340
|
fontSizes,
|
|
15326
15341
|
lineHeights
|
|
15327
15342
|
}
|
|
@@ -15429,4 +15444,4 @@ export {
|
|
|
15429
15444
|
prepareUEditorContentForSave,
|
|
15430
15445
|
UEditor_default
|
|
15431
15446
|
};
|
|
15432
|
-
//# sourceMappingURL=chunk-
|
|
15447
|
+
//# sourceMappingURL=chunk-C4KZOMP3.js.map
|