@underverse-ui/underverse 1.0.102 → 1.0.104
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/api-reference.json +1 -1
- package/dist/index.cjs +234 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +228 -149
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23109,7 +23109,7 @@ function useLocale2() {
|
|
|
23109
23109
|
}
|
|
23110
23110
|
|
|
23111
23111
|
// src/components/UEditor/UEditor.tsx
|
|
23112
|
-
import
|
|
23112
|
+
import React76, { useEffect as useEffect36, useImperativeHandle as useImperativeHandle3, useMemo as useMemo24, useRef as useRef33 } from "react";
|
|
23113
23113
|
import { useEditor, EditorContent } from "@tiptap/react";
|
|
23114
23114
|
|
|
23115
23115
|
// src/components/UEditor/extensions.ts
|
|
@@ -31962,47 +31962,210 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
|
|
|
31962
31962
|
);
|
|
31963
31963
|
|
|
31964
31964
|
// src/components/UEditor/use-table-interactions.ts
|
|
31965
|
-
import
|
|
31965
|
+
import React75, { useEffect as useEffect35, useRef as useRef32 } from "react";
|
|
31966
|
+
|
|
31967
|
+
// src/components/UEditor/use-table-row-resize.ts
|
|
31968
|
+
import React74, { useRef as useRef31 } from "react";
|
|
31969
|
+
function useTableRowResize({
|
|
31970
|
+
editor,
|
|
31971
|
+
setHoveredTableCell,
|
|
31972
|
+
clearHoveredTableCell,
|
|
31973
|
+
showRowGuide,
|
|
31974
|
+
clearAllTableResizeHover,
|
|
31975
|
+
scheduleTableLayoutSync
|
|
31976
|
+
}) {
|
|
31977
|
+
const commitFrameRef = useRef31(null);
|
|
31978
|
+
const stateRef = useRef31(null);
|
|
31979
|
+
const commitPreview = React74.useCallback(() => {
|
|
31980
|
+
if (!editor) return;
|
|
31981
|
+
const state = stateRef.current;
|
|
31982
|
+
if (!state) return;
|
|
31983
|
+
const nextHeight = state.pendingHeight;
|
|
31984
|
+
if (nextHeight === state.previewHeight) {
|
|
31985
|
+
document.body.style.cursor = "row-resize";
|
|
31986
|
+
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
31987
|
+
scheduleTableLayoutSync();
|
|
31988
|
+
return;
|
|
31989
|
+
}
|
|
31990
|
+
state.previewHeight = nextHeight;
|
|
31991
|
+
const tr = editor.view.state.tr;
|
|
31992
|
+
tr.setNodeMarkup(state.rowPos, void 0, {
|
|
31993
|
+
...state.rowNode.attrs,
|
|
31994
|
+
rowHeight: nextHeight
|
|
31995
|
+
});
|
|
31996
|
+
tr.setMeta("addToHistory", false);
|
|
31997
|
+
editor.view.dispatch(tr);
|
|
31998
|
+
state.rowNode = editor.view.state.doc.nodeAt(state.rowPos) ?? state.rowNode;
|
|
31999
|
+
const refreshedRow = state.tableElement.rows.item(state.rowElement.rowIndex);
|
|
32000
|
+
if (refreshedRow instanceof HTMLTableRowElement) {
|
|
32001
|
+
state.rowElement = refreshedRow;
|
|
32002
|
+
const refreshedCell = refreshedRow.cells.item(state.cellIndex);
|
|
32003
|
+
if (refreshedCell instanceof HTMLTableCellElement) {
|
|
32004
|
+
state.cellElement = refreshedCell;
|
|
32005
|
+
}
|
|
32006
|
+
}
|
|
32007
|
+
document.body.style.cursor = "row-resize";
|
|
32008
|
+
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
32009
|
+
scheduleTableLayoutSync();
|
|
32010
|
+
}, [editor, scheduleTableLayoutSync, showRowGuide]);
|
|
32011
|
+
const scheduleCommit = React74.useCallback(() => {
|
|
32012
|
+
if (commitFrameRef.current !== null) return;
|
|
32013
|
+
commitFrameRef.current = window.requestAnimationFrame(() => {
|
|
32014
|
+
commitFrameRef.current = null;
|
|
32015
|
+
commitPreview();
|
|
32016
|
+
});
|
|
32017
|
+
}, [commitPreview]);
|
|
32018
|
+
const syncActiveGuide = React74.useCallback(() => {
|
|
32019
|
+
const state = stateRef.current;
|
|
32020
|
+
if (!state) return false;
|
|
32021
|
+
setHoveredTableCell(state.cellElement);
|
|
32022
|
+
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
32023
|
+
return true;
|
|
32024
|
+
}, [setHoveredTableCell, showRowGuide]);
|
|
32025
|
+
const isResizing = React74.useCallback(() => stateRef.current !== null, []);
|
|
32026
|
+
const beginResize = React74.useCallback((event, table, row, cell) => {
|
|
32027
|
+
if (!editor || !isRowResizeHotspot(cell, event.clientX, event.clientY)) {
|
|
32028
|
+
return false;
|
|
32029
|
+
}
|
|
32030
|
+
setHoveredTableCell(cell);
|
|
32031
|
+
const rowInfo = findTableRowNodeInfo(editor.view, row);
|
|
32032
|
+
if (!rowInfo) return false;
|
|
32033
|
+
const startHeight = row.getBoundingClientRect().height;
|
|
32034
|
+
stateRef.current = {
|
|
32035
|
+
rowElement: row,
|
|
32036
|
+
tableElement: table,
|
|
32037
|
+
cellElement: cell,
|
|
32038
|
+
cellIndex: cell.cellIndex,
|
|
32039
|
+
rowPos: rowInfo.pos,
|
|
32040
|
+
rowNode: rowInfo.node,
|
|
32041
|
+
startY: event.clientY,
|
|
32042
|
+
startHeight,
|
|
32043
|
+
previewHeight: startHeight,
|
|
32044
|
+
pendingHeight: startHeight
|
|
32045
|
+
};
|
|
32046
|
+
showRowGuide(table, row, cell);
|
|
32047
|
+
document.body.style.cursor = "row-resize";
|
|
32048
|
+
event.preventDefault();
|
|
32049
|
+
event.stopPropagation();
|
|
32050
|
+
return true;
|
|
32051
|
+
}, [editor, setHoveredTableCell, showRowGuide]);
|
|
32052
|
+
const handlePointerMove = React74.useCallback((event) => {
|
|
32053
|
+
const state = stateRef.current;
|
|
32054
|
+
if (!state) return;
|
|
32055
|
+
const nextHeight = Math.max(
|
|
32056
|
+
MIN_TABLE_ROW_HEIGHT,
|
|
32057
|
+
Math.round(state.startHeight + (event.clientY - state.startY))
|
|
32058
|
+
);
|
|
32059
|
+
if (nextHeight === state.pendingHeight) {
|
|
32060
|
+
document.body.style.cursor = "row-resize";
|
|
32061
|
+
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
32062
|
+
return;
|
|
32063
|
+
}
|
|
32064
|
+
state.pendingHeight = nextHeight;
|
|
32065
|
+
document.body.style.cursor = "row-resize";
|
|
32066
|
+
scheduleCommit();
|
|
32067
|
+
}, [scheduleCommit, showRowGuide]);
|
|
32068
|
+
const handlePointerUp = React74.useCallback((event) => {
|
|
32069
|
+
if (!editor) return;
|
|
32070
|
+
const state = stateRef.current;
|
|
32071
|
+
if (!state) return;
|
|
32072
|
+
const nextHeight = Math.max(
|
|
32073
|
+
MIN_TABLE_ROW_HEIGHT,
|
|
32074
|
+
Math.round(state.startHeight + (event.clientY - state.startY))
|
|
32075
|
+
);
|
|
32076
|
+
state.pendingHeight = nextHeight;
|
|
32077
|
+
if (commitFrameRef.current !== null) {
|
|
32078
|
+
window.cancelAnimationFrame(commitFrameRef.current);
|
|
32079
|
+
commitFrameRef.current = null;
|
|
32080
|
+
}
|
|
32081
|
+
commitPreview();
|
|
32082
|
+
const latestState = stateRef.current ?? state;
|
|
32083
|
+
const rowNode = editor.view.state.doc.nodeAt(latestState.rowPos) ?? latestState.rowNode;
|
|
32084
|
+
if (rowNode.attrs.rowHeight !== nextHeight) {
|
|
32085
|
+
const tr = editor.view.state.tr;
|
|
32086
|
+
tr.setNodeMarkup(latestState.rowPos, void 0, {
|
|
32087
|
+
...rowNode.attrs,
|
|
32088
|
+
rowHeight: nextHeight
|
|
32089
|
+
});
|
|
32090
|
+
editor.view.dispatch(tr);
|
|
32091
|
+
}
|
|
32092
|
+
stateRef.current = null;
|
|
32093
|
+
document.body.style.cursor = "";
|
|
32094
|
+
clearHoveredTableCell();
|
|
32095
|
+
clearAllTableResizeHover();
|
|
32096
|
+
scheduleTableLayoutSync();
|
|
32097
|
+
}, [clearAllTableResizeHover, clearHoveredTableCell, commitPreview, editor, scheduleTableLayoutSync]);
|
|
32098
|
+
const cancelResize = React74.useCallback(() => {
|
|
32099
|
+
if (!stateRef.current) return;
|
|
32100
|
+
if (commitFrameRef.current !== null) {
|
|
32101
|
+
window.cancelAnimationFrame(commitFrameRef.current);
|
|
32102
|
+
commitFrameRef.current = null;
|
|
32103
|
+
}
|
|
32104
|
+
stateRef.current = null;
|
|
32105
|
+
document.body.style.cursor = "";
|
|
32106
|
+
clearHoveredTableCell();
|
|
32107
|
+
clearAllTableResizeHover();
|
|
32108
|
+
scheduleTableLayoutSync();
|
|
32109
|
+
}, [clearAllTableResizeHover, clearHoveredTableCell, scheduleTableLayoutSync]);
|
|
32110
|
+
const cleanup = React74.useCallback(() => {
|
|
32111
|
+
if (commitFrameRef.current !== null) {
|
|
32112
|
+
window.cancelAnimationFrame(commitFrameRef.current);
|
|
32113
|
+
commitFrameRef.current = null;
|
|
32114
|
+
}
|
|
32115
|
+
stateRef.current = null;
|
|
32116
|
+
document.body.style.cursor = "";
|
|
32117
|
+
}, []);
|
|
32118
|
+
return {
|
|
32119
|
+
beginResize,
|
|
32120
|
+
cancelResize,
|
|
32121
|
+
cleanup,
|
|
32122
|
+
handlePointerMove,
|
|
32123
|
+
handlePointerUp,
|
|
32124
|
+
isResizing,
|
|
32125
|
+
syncActiveGuide
|
|
32126
|
+
};
|
|
32127
|
+
}
|
|
32128
|
+
|
|
32129
|
+
// src/components/UEditor/use-table-interactions.ts
|
|
31966
32130
|
function useUEditorTableInteractions(editor) {
|
|
31967
|
-
const editorContentRef =
|
|
31968
|
-
const tableColumnGuideRef =
|
|
31969
|
-
const tableRowGuideRef =
|
|
31970
|
-
const activeTableCellHighlightRef =
|
|
31971
|
-
const hoveredTableCellRef =
|
|
31972
|
-
const activeTableCellRef =
|
|
31973
|
-
const
|
|
31974
|
-
const
|
|
31975
|
-
const
|
|
31976
|
-
const setEditorResizeCursor = React74.useCallback((cursor) => {
|
|
32131
|
+
const editorContentRef = useRef32(null);
|
|
32132
|
+
const tableColumnGuideRef = useRef32(null);
|
|
32133
|
+
const tableRowGuideRef = useRef32(null);
|
|
32134
|
+
const activeTableCellHighlightRef = useRef32(null);
|
|
32135
|
+
const hoveredTableCellRef = useRef32(null);
|
|
32136
|
+
const activeTableCellRef = useRef32(null);
|
|
32137
|
+
const suppressActiveCellHighlightRef = useRef32(false);
|
|
32138
|
+
const tableLayoutSyncFrameRef = useRef32(null);
|
|
32139
|
+
const setEditorResizeCursor = React75.useCallback((cursor) => {
|
|
31977
32140
|
const proseMirror = editorContentRef.current?.querySelector(".ProseMirror");
|
|
31978
32141
|
if (proseMirror) {
|
|
31979
32142
|
proseMirror.style.cursor = cursor;
|
|
31980
32143
|
}
|
|
31981
32144
|
}, []);
|
|
31982
|
-
const hideColumnGuide =
|
|
32145
|
+
const hideColumnGuide = React75.useCallback(() => {
|
|
31983
32146
|
editorContentRef.current?.classList.remove("resize-cursor");
|
|
31984
32147
|
const guide = tableColumnGuideRef.current;
|
|
31985
32148
|
if (guide) {
|
|
31986
32149
|
guide.style.opacity = "0";
|
|
31987
32150
|
}
|
|
31988
32151
|
}, []);
|
|
31989
|
-
const hideRowGuide =
|
|
32152
|
+
const hideRowGuide = React75.useCallback(() => {
|
|
31990
32153
|
editorContentRef.current?.classList.remove("resize-row-cursor");
|
|
31991
32154
|
const guide = tableRowGuideRef.current;
|
|
31992
32155
|
if (guide) {
|
|
31993
32156
|
guide.style.opacity = "0";
|
|
31994
32157
|
}
|
|
31995
32158
|
}, []);
|
|
31996
|
-
const clearAllTableResizeHover =
|
|
32159
|
+
const clearAllTableResizeHover = React75.useCallback(() => {
|
|
31997
32160
|
setEditorResizeCursor("");
|
|
31998
32161
|
hideColumnGuide();
|
|
31999
32162
|
hideRowGuide();
|
|
32000
32163
|
}, [hideColumnGuide, hideRowGuide, setEditorResizeCursor]);
|
|
32001
|
-
const updateActiveCellHighlight =
|
|
32164
|
+
const updateActiveCellHighlight = React75.useCallback((cell) => {
|
|
32002
32165
|
const surface = editorContentRef.current;
|
|
32003
32166
|
const highlight = activeTableCellHighlightRef.current;
|
|
32004
32167
|
if (!highlight) return;
|
|
32005
|
-
if (!surface || !cell) {
|
|
32168
|
+
if (suppressActiveCellHighlightRef.current || !surface || !cell) {
|
|
32006
32169
|
highlight.style.display = "none";
|
|
32007
32170
|
return;
|
|
32008
32171
|
}
|
|
@@ -32013,7 +32176,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32013
32176
|
highlight.style.width = `${metrics.width}px`;
|
|
32014
32177
|
highlight.style.height = `${metrics.height}px`;
|
|
32015
32178
|
}, []);
|
|
32016
|
-
const scheduleTableLayoutSync =
|
|
32179
|
+
const scheduleTableLayoutSync = React75.useCallback(() => {
|
|
32017
32180
|
if (tableLayoutSyncFrameRef.current !== null) return;
|
|
32018
32181
|
tableLayoutSyncFrameRef.current = window.requestAnimationFrame(() => {
|
|
32019
32182
|
tableLayoutSyncFrameRef.current = null;
|
|
@@ -32021,22 +32184,22 @@ function useUEditorTableInteractions(editor) {
|
|
|
32021
32184
|
editorContentRef.current?.dispatchEvent(new CustomEvent(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT));
|
|
32022
32185
|
});
|
|
32023
32186
|
}, [updateActiveCellHighlight]);
|
|
32024
|
-
const setActiveTableCell =
|
|
32187
|
+
const setActiveTableCell = React75.useCallback((cell) => {
|
|
32025
32188
|
if (activeTableCellRef.current === cell) return;
|
|
32026
32189
|
activeTableCellRef.current = cell;
|
|
32027
32190
|
updateActiveCellHighlight(activeTableCellRef.current);
|
|
32028
32191
|
}, [updateActiveCellHighlight]);
|
|
32029
|
-
const clearActiveTableCell =
|
|
32192
|
+
const clearActiveTableCell = React75.useCallback(() => {
|
|
32030
32193
|
activeTableCellRef.current = null;
|
|
32031
32194
|
updateActiveCellHighlight(null);
|
|
32032
32195
|
}, [updateActiveCellHighlight]);
|
|
32033
|
-
const setHoveredTableCell =
|
|
32196
|
+
const setHoveredTableCell = React75.useCallback((cell) => {
|
|
32034
32197
|
hoveredTableCellRef.current = cell;
|
|
32035
32198
|
}, []);
|
|
32036
|
-
const clearHoveredTableCell =
|
|
32199
|
+
const clearHoveredTableCell = React75.useCallback(() => {
|
|
32037
32200
|
hoveredTableCellRef.current = null;
|
|
32038
32201
|
}, []);
|
|
32039
|
-
const showColumnGuide =
|
|
32202
|
+
const showColumnGuide = React75.useCallback((table, row, cell) => {
|
|
32040
32203
|
const surface = editorContentRef.current;
|
|
32041
32204
|
const guide = tableColumnGuideRef.current;
|
|
32042
32205
|
if (!surface || !guide) return;
|
|
@@ -32049,7 +32212,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32049
32212
|
surface.classList.add("resize-cursor");
|
|
32050
32213
|
setEditorResizeCursor("col-resize");
|
|
32051
32214
|
}, [setEditorResizeCursor]);
|
|
32052
|
-
const showRowGuide =
|
|
32215
|
+
const showRowGuide = React75.useCallback((table, row, cell) => {
|
|
32053
32216
|
const surface = editorContentRef.current;
|
|
32054
32217
|
const guide = tableRowGuideRef.current;
|
|
32055
32218
|
if (!surface || !guide) return;
|
|
@@ -32062,46 +32225,23 @@ function useUEditorTableInteractions(editor) {
|
|
|
32062
32225
|
surface.classList.add("resize-row-cursor");
|
|
32063
32226
|
setEditorResizeCursor("row-resize");
|
|
32064
32227
|
}, [setEditorResizeCursor]);
|
|
32065
|
-
const
|
|
32066
|
-
|
|
32067
|
-
|
|
32068
|
-
|
|
32069
|
-
|
|
32070
|
-
|
|
32071
|
-
|
|
32072
|
-
|
|
32073
|
-
|
|
32074
|
-
|
|
32075
|
-
|
|
32076
|
-
|
|
32077
|
-
|
|
32078
|
-
|
|
32079
|
-
|
|
32080
|
-
|
|
32081
|
-
|
|
32082
|
-
tr.setMeta("addToHistory", false);
|
|
32083
|
-
editor.view.dispatch(tr);
|
|
32084
|
-
state.rowNode = editor.view.state.doc.nodeAt(state.rowPos) ?? state.rowNode;
|
|
32085
|
-
const refreshedRow = state.tableElement.rows.item(state.rowElement.rowIndex);
|
|
32086
|
-
if (refreshedRow instanceof HTMLTableRowElement) {
|
|
32087
|
-
state.rowElement = refreshedRow;
|
|
32088
|
-
const refreshedCell = refreshedRow.cells.item(state.cellIndex);
|
|
32089
|
-
if (refreshedCell instanceof HTMLTableCellElement) {
|
|
32090
|
-
state.cellElement = refreshedCell;
|
|
32091
|
-
}
|
|
32092
|
-
}
|
|
32093
|
-
document.body.style.cursor = "row-resize";
|
|
32094
|
-
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
32095
|
-
scheduleTableLayoutSync();
|
|
32096
|
-
}, [editor, scheduleTableLayoutSync, showRowGuide]);
|
|
32097
|
-
const scheduleRowResizeCommit = React74.useCallback(() => {
|
|
32098
|
-
if (rowResizeCommitFrameRef.current !== null) return;
|
|
32099
|
-
rowResizeCommitFrameRef.current = window.requestAnimationFrame(() => {
|
|
32100
|
-
rowResizeCommitFrameRef.current = null;
|
|
32101
|
-
commitRowResizePreview();
|
|
32102
|
-
});
|
|
32103
|
-
}, [commitRowResizePreview]);
|
|
32104
|
-
const syncActiveTableCellFromSelection = React74.useCallback(() => {
|
|
32228
|
+
const {
|
|
32229
|
+
beginResize,
|
|
32230
|
+
cancelResize,
|
|
32231
|
+
cleanup: cleanupRowResize,
|
|
32232
|
+
handlePointerMove: handleRowResizePointerMove,
|
|
32233
|
+
handlePointerUp: handleRowResizePointerUp,
|
|
32234
|
+
isResizing: isRowResizing,
|
|
32235
|
+
syncActiveGuide: syncActiveRowResizeGuide
|
|
32236
|
+
} = useTableRowResize({
|
|
32237
|
+
editor,
|
|
32238
|
+
setHoveredTableCell,
|
|
32239
|
+
clearHoveredTableCell,
|
|
32240
|
+
showRowGuide,
|
|
32241
|
+
clearAllTableResizeHover,
|
|
32242
|
+
scheduleTableLayoutSync
|
|
32243
|
+
});
|
|
32244
|
+
const syncActiveTableCellFromSelection = React75.useCallback(() => {
|
|
32105
32245
|
if (!editor) return;
|
|
32106
32246
|
setActiveTableCell(getSelectionTableCell(editor.view));
|
|
32107
32247
|
}, [editor, setActiveTableCell]);
|
|
@@ -32126,10 +32266,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32126
32266
|
updateActiveCellHighlight(activeTableCellRef.current);
|
|
32127
32267
|
};
|
|
32128
32268
|
const handleEditorMouseMove = (event) => {
|
|
32129
|
-
|
|
32130
|
-
if (activeRowResize) {
|
|
32131
|
-
setHoveredTableCell(activeRowResize.cellElement);
|
|
32132
|
-
showRowGuide(activeRowResize.tableElement, activeRowResize.rowElement, activeRowResize.cellElement);
|
|
32269
|
+
if (syncActiveRowResizeGuide()) {
|
|
32133
32270
|
return;
|
|
32134
32271
|
}
|
|
32135
32272
|
const target = resolveEventElement(event.target);
|
|
@@ -32167,7 +32304,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32167
32304
|
};
|
|
32168
32305
|
const handleEditorMouseLeave = () => {
|
|
32169
32306
|
clearHoveredTableCell();
|
|
32170
|
-
if (!
|
|
32307
|
+
if (!isRowResizing()) {
|
|
32171
32308
|
clearAllTableResizeHover();
|
|
32172
32309
|
}
|
|
32173
32310
|
};
|
|
@@ -32188,87 +32325,31 @@ function useUEditorTableInteractions(editor) {
|
|
|
32188
32325
|
const row = cell.closest("tr");
|
|
32189
32326
|
const table = cell.closest("table");
|
|
32190
32327
|
if (!(row instanceof HTMLTableRowElement) || !(table instanceof HTMLTableElement)) return;
|
|
32191
|
-
if (
|
|
32192
|
-
|
|
32328
|
+
if (beginResize(event, table, row, cell)) {
|
|
32329
|
+
suppressActiveCellHighlightRef.current = true;
|
|
32330
|
+
updateActiveCellHighlight(null);
|
|
32193
32331
|
}
|
|
32194
|
-
setHoveredTableCell(cell);
|
|
32195
|
-
const rowInfo = findTableRowNodeInfo(editor.view, row);
|
|
32196
|
-
if (!rowInfo) return;
|
|
32197
|
-
const startHeight = row.getBoundingClientRect().height;
|
|
32198
|
-
rowResizeStateRef.current = {
|
|
32199
|
-
rowElement: row,
|
|
32200
|
-
tableElement: table,
|
|
32201
|
-
cellElement: cell,
|
|
32202
|
-
cellIndex: cell.cellIndex,
|
|
32203
|
-
rowPos: rowInfo.pos,
|
|
32204
|
-
rowNode: rowInfo.node,
|
|
32205
|
-
startY: event.clientY,
|
|
32206
|
-
startHeight,
|
|
32207
|
-
previewHeight: startHeight,
|
|
32208
|
-
pendingHeight: startHeight
|
|
32209
|
-
};
|
|
32210
|
-
showRowGuide(table, row, cell);
|
|
32211
|
-
document.body.style.cursor = "row-resize";
|
|
32212
|
-
event.preventDefault();
|
|
32213
|
-
event.stopPropagation();
|
|
32214
32332
|
};
|
|
32215
32333
|
const handlePointerMove = (event) => {
|
|
32216
|
-
|
|
32217
|
-
if (!state) return;
|
|
32218
|
-
const nextHeight = Math.max(
|
|
32219
|
-
MIN_TABLE_ROW_HEIGHT,
|
|
32220
|
-
Math.round(state.startHeight + (event.clientY - state.startY))
|
|
32221
|
-
);
|
|
32222
|
-
if (nextHeight === state.pendingHeight) {
|
|
32223
|
-
document.body.style.cursor = "row-resize";
|
|
32224
|
-
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
32225
|
-
return;
|
|
32226
|
-
}
|
|
32227
|
-
state.pendingHeight = nextHeight;
|
|
32228
|
-
document.body.style.cursor = "row-resize";
|
|
32229
|
-
scheduleRowResizeCommit();
|
|
32334
|
+
handleRowResizePointerMove(event);
|
|
32230
32335
|
};
|
|
32231
32336
|
const handlePointerUp = (event) => {
|
|
32232
|
-
const
|
|
32233
|
-
|
|
32234
|
-
|
|
32235
|
-
|
|
32236
|
-
|
|
32237
|
-
|
|
32238
|
-
state.pendingHeight = nextHeight;
|
|
32239
|
-
if (rowResizeCommitFrameRef.current !== null) {
|
|
32240
|
-
window.cancelAnimationFrame(rowResizeCommitFrameRef.current);
|
|
32241
|
-
rowResizeCommitFrameRef.current = null;
|
|
32242
|
-
}
|
|
32243
|
-
commitRowResizePreview();
|
|
32244
|
-
const latestState = rowResizeStateRef.current ?? state;
|
|
32245
|
-
const rowNode = editor.view.state.doc.nodeAt(latestState.rowPos) ?? latestState.rowNode;
|
|
32246
|
-
if (rowNode.attrs.rowHeight !== nextHeight) {
|
|
32247
|
-
const tr = editor.view.state.tr;
|
|
32248
|
-
tr.setNodeMarkup(latestState.rowPos, void 0, {
|
|
32249
|
-
...rowNode.attrs,
|
|
32250
|
-
rowHeight: nextHeight
|
|
32337
|
+
const wasRowResizing = isRowResizing();
|
|
32338
|
+
handleRowResizePointerUp(event);
|
|
32339
|
+
if (wasRowResizing) {
|
|
32340
|
+
suppressActiveCellHighlightRef.current = false;
|
|
32341
|
+
requestAnimationFrame(() => {
|
|
32342
|
+
updateActiveCellHighlight(activeTableCellRef.current);
|
|
32251
32343
|
});
|
|
32252
|
-
editor.view.dispatch(tr);
|
|
32253
32344
|
}
|
|
32254
|
-
rowResizeStateRef.current = null;
|
|
32255
|
-
document.body.style.cursor = "";
|
|
32256
|
-
clearHoveredTableCell();
|
|
32257
|
-
clearAllTableResizeHover();
|
|
32258
|
-
scheduleTableLayoutSync();
|
|
32259
32345
|
};
|
|
32260
32346
|
const handleWindowBlur = () => {
|
|
32261
|
-
const
|
|
32262
|
-
|
|
32263
|
-
if (
|
|
32264
|
-
|
|
32265
|
-
|
|
32347
|
+
const wasRowResizing = isRowResizing();
|
|
32348
|
+
cancelResize();
|
|
32349
|
+
if (wasRowResizing) {
|
|
32350
|
+
suppressActiveCellHighlightRef.current = false;
|
|
32351
|
+
updateActiveCellHighlight(activeTableCellRef.current);
|
|
32266
32352
|
}
|
|
32267
|
-
rowResizeStateRef.current = null;
|
|
32268
|
-
document.body.style.cursor = "";
|
|
32269
|
-
clearHoveredTableCell();
|
|
32270
|
-
clearAllTableResizeHover();
|
|
32271
|
-
scheduleTableLayoutSync();
|
|
32272
32353
|
};
|
|
32273
32354
|
proseMirror.addEventListener("mousemove", handleEditorMouseMove);
|
|
32274
32355
|
proseMirror.addEventListener("mouseleave", handleEditorMouseLeave);
|
|
@@ -32311,17 +32392,14 @@ function useUEditorTableInteractions(editor) {
|
|
|
32311
32392
|
window.cancelAnimationFrame(tableLayoutSyncFrameRef.current);
|
|
32312
32393
|
tableLayoutSyncFrameRef.current = null;
|
|
32313
32394
|
}
|
|
32314
|
-
|
|
32315
|
-
|
|
32316
|
-
rowResizeCommitFrameRef.current = null;
|
|
32317
|
-
}
|
|
32395
|
+
cleanupRowResize();
|
|
32396
|
+
suppressActiveCellHighlightRef.current = false;
|
|
32318
32397
|
document.body.style.cursor = "";
|
|
32319
32398
|
clearActiveTableCell();
|
|
32320
32399
|
clearHoveredTableCell();
|
|
32321
32400
|
clearAllTableResizeHover();
|
|
32322
|
-
rowResizeStateRef.current = null;
|
|
32323
32401
|
};
|
|
32324
|
-
}, [clearActiveTableCell, clearAllTableResizeHover, clearHoveredTableCell,
|
|
32402
|
+
}, [beginResize, cancelResize, cleanupRowResize, clearActiveTableCell, clearAllTableResizeHover, clearHoveredTableCell, editor, handleRowResizePointerMove, handleRowResizePointerUp, hideColumnGuide, hideRowGuide, isRowResizing, showColumnGuide, showRowGuide, syncActiveRowResizeGuide, syncActiveTableCellFromSelection, updateActiveCellHighlight]);
|
|
32325
32403
|
return {
|
|
32326
32404
|
editorContentRef,
|
|
32327
32405
|
tableColumnGuideRef,
|
|
@@ -32332,7 +32410,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32332
32410
|
|
|
32333
32411
|
// src/components/UEditor/UEditor.tsx
|
|
32334
32412
|
import { jsx as jsx83, jsxs as jsxs71 } from "react/jsx-runtime";
|
|
32335
|
-
var UEditor =
|
|
32413
|
+
var UEditor = React76.forwardRef(({
|
|
32336
32414
|
content = "",
|
|
32337
32415
|
onChange,
|
|
32338
32416
|
onHtmlChange,
|
|
@@ -32363,8 +32441,8 @@ var UEditor = React75.forwardRef(({
|
|
|
32363
32441
|
}, ref) => {
|
|
32364
32442
|
const t = useSmartTranslations("UEditor");
|
|
32365
32443
|
const effectivePlaceholder = placeholder ?? t("placeholder");
|
|
32366
|
-
const inFlightPrepareRef =
|
|
32367
|
-
const lastAppliedContentRef =
|
|
32444
|
+
const inFlightPrepareRef = useRef33(null);
|
|
32445
|
+
const lastAppliedContentRef = useRef33(content ?? "");
|
|
32368
32446
|
const extensions = useMemo24(
|
|
32369
32447
|
() => buildUEditorExtensions({
|
|
32370
32448
|
placeholder: effectivePlaceholder,
|
|
@@ -32534,6 +32612,7 @@ var UEditor = React75.forwardRef(({
|
|
|
32534
32612
|
{
|
|
32535
32613
|
ref: activeTableCellHighlightRef,
|
|
32536
32614
|
"aria-hidden": "true",
|
|
32615
|
+
"data-ueditor-active-cell-highlight": "",
|
|
32537
32616
|
className: "pointer-events-none hidden absolute z-20 rounded-[2px] border-2 border-primary bg-primary/10 transition-[left,top,width,height] duration-100"
|
|
32538
32617
|
}
|
|
32539
32618
|
),
|