@underverse-ui/underverse 1.0.102 → 1.0.103
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 +219 -158
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +213 -152
- 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,43 +31962,205 @@ 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 tableLayoutSyncFrameRef =
|
|
31974
|
-
const
|
|
31975
|
-
const rowResizeStateRef = useRef31(null);
|
|
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 tableLayoutSyncFrameRef = useRef32(null);
|
|
32138
|
+
const setEditorResizeCursor = React75.useCallback((cursor) => {
|
|
31977
32139
|
const proseMirror = editorContentRef.current?.querySelector(".ProseMirror");
|
|
31978
32140
|
if (proseMirror) {
|
|
31979
32141
|
proseMirror.style.cursor = cursor;
|
|
31980
32142
|
}
|
|
31981
32143
|
}, []);
|
|
31982
|
-
const hideColumnGuide =
|
|
32144
|
+
const hideColumnGuide = React75.useCallback(() => {
|
|
31983
32145
|
editorContentRef.current?.classList.remove("resize-cursor");
|
|
31984
32146
|
const guide = tableColumnGuideRef.current;
|
|
31985
32147
|
if (guide) {
|
|
31986
32148
|
guide.style.opacity = "0";
|
|
31987
32149
|
}
|
|
31988
32150
|
}, []);
|
|
31989
|
-
const hideRowGuide =
|
|
32151
|
+
const hideRowGuide = React75.useCallback(() => {
|
|
31990
32152
|
editorContentRef.current?.classList.remove("resize-row-cursor");
|
|
31991
32153
|
const guide = tableRowGuideRef.current;
|
|
31992
32154
|
if (guide) {
|
|
31993
32155
|
guide.style.opacity = "0";
|
|
31994
32156
|
}
|
|
31995
32157
|
}, []);
|
|
31996
|
-
const clearAllTableResizeHover =
|
|
32158
|
+
const clearAllTableResizeHover = React75.useCallback(() => {
|
|
31997
32159
|
setEditorResizeCursor("");
|
|
31998
32160
|
hideColumnGuide();
|
|
31999
32161
|
hideRowGuide();
|
|
32000
32162
|
}, [hideColumnGuide, hideRowGuide, setEditorResizeCursor]);
|
|
32001
|
-
const updateActiveCellHighlight =
|
|
32163
|
+
const updateActiveCellHighlight = React75.useCallback((cell) => {
|
|
32002
32164
|
const surface = editorContentRef.current;
|
|
32003
32165
|
const highlight = activeTableCellHighlightRef.current;
|
|
32004
32166
|
if (!highlight) return;
|
|
@@ -32013,7 +32175,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32013
32175
|
highlight.style.width = `${metrics.width}px`;
|
|
32014
32176
|
highlight.style.height = `${metrics.height}px`;
|
|
32015
32177
|
}, []);
|
|
32016
|
-
const scheduleTableLayoutSync =
|
|
32178
|
+
const scheduleTableLayoutSync = React75.useCallback(() => {
|
|
32017
32179
|
if (tableLayoutSyncFrameRef.current !== null) return;
|
|
32018
32180
|
tableLayoutSyncFrameRef.current = window.requestAnimationFrame(() => {
|
|
32019
32181
|
tableLayoutSyncFrameRef.current = null;
|
|
@@ -32021,22 +32183,22 @@ function useUEditorTableInteractions(editor) {
|
|
|
32021
32183
|
editorContentRef.current?.dispatchEvent(new CustomEvent(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT));
|
|
32022
32184
|
});
|
|
32023
32185
|
}, [updateActiveCellHighlight]);
|
|
32024
|
-
const setActiveTableCell =
|
|
32186
|
+
const setActiveTableCell = React75.useCallback((cell) => {
|
|
32025
32187
|
if (activeTableCellRef.current === cell) return;
|
|
32026
32188
|
activeTableCellRef.current = cell;
|
|
32027
32189
|
updateActiveCellHighlight(activeTableCellRef.current);
|
|
32028
32190
|
}, [updateActiveCellHighlight]);
|
|
32029
|
-
const clearActiveTableCell =
|
|
32191
|
+
const clearActiveTableCell = React75.useCallback(() => {
|
|
32030
32192
|
activeTableCellRef.current = null;
|
|
32031
32193
|
updateActiveCellHighlight(null);
|
|
32032
32194
|
}, [updateActiveCellHighlight]);
|
|
32033
|
-
const setHoveredTableCell =
|
|
32195
|
+
const setHoveredTableCell = React75.useCallback((cell) => {
|
|
32034
32196
|
hoveredTableCellRef.current = cell;
|
|
32035
32197
|
}, []);
|
|
32036
|
-
const clearHoveredTableCell =
|
|
32198
|
+
const clearHoveredTableCell = React75.useCallback(() => {
|
|
32037
32199
|
hoveredTableCellRef.current = null;
|
|
32038
32200
|
}, []);
|
|
32039
|
-
const showColumnGuide =
|
|
32201
|
+
const showColumnGuide = React75.useCallback((table, row, cell) => {
|
|
32040
32202
|
const surface = editorContentRef.current;
|
|
32041
32203
|
const guide = tableColumnGuideRef.current;
|
|
32042
32204
|
if (!surface || !guide) return;
|
|
@@ -32049,7 +32211,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32049
32211
|
surface.classList.add("resize-cursor");
|
|
32050
32212
|
setEditorResizeCursor("col-resize");
|
|
32051
32213
|
}, [setEditorResizeCursor]);
|
|
32052
|
-
const showRowGuide =
|
|
32214
|
+
const showRowGuide = React75.useCallback((table, row, cell) => {
|
|
32053
32215
|
const surface = editorContentRef.current;
|
|
32054
32216
|
const guide = tableRowGuideRef.current;
|
|
32055
32217
|
if (!surface || !guide) return;
|
|
@@ -32062,46 +32224,23 @@ function useUEditorTableInteractions(editor) {
|
|
|
32062
32224
|
surface.classList.add("resize-row-cursor");
|
|
32063
32225
|
setEditorResizeCursor("row-resize");
|
|
32064
32226
|
}, [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(() => {
|
|
32227
|
+
const {
|
|
32228
|
+
beginResize,
|
|
32229
|
+
cancelResize,
|
|
32230
|
+
cleanup: cleanupRowResize,
|
|
32231
|
+
handlePointerMove: handleRowResizePointerMove,
|
|
32232
|
+
handlePointerUp: handleRowResizePointerUp,
|
|
32233
|
+
isResizing: isRowResizing,
|
|
32234
|
+
syncActiveGuide: syncActiveRowResizeGuide
|
|
32235
|
+
} = useTableRowResize({
|
|
32236
|
+
editor,
|
|
32237
|
+
setHoveredTableCell,
|
|
32238
|
+
clearHoveredTableCell,
|
|
32239
|
+
showRowGuide,
|
|
32240
|
+
clearAllTableResizeHover,
|
|
32241
|
+
scheduleTableLayoutSync
|
|
32242
|
+
});
|
|
32243
|
+
const syncActiveTableCellFromSelection = React75.useCallback(() => {
|
|
32105
32244
|
if (!editor) return;
|
|
32106
32245
|
setActiveTableCell(getSelectionTableCell(editor.view));
|
|
32107
32246
|
}, [editor, setActiveTableCell]);
|
|
@@ -32126,10 +32265,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32126
32265
|
updateActiveCellHighlight(activeTableCellRef.current);
|
|
32127
32266
|
};
|
|
32128
32267
|
const handleEditorMouseMove = (event) => {
|
|
32129
|
-
|
|
32130
|
-
if (activeRowResize) {
|
|
32131
|
-
setHoveredTableCell(activeRowResize.cellElement);
|
|
32132
|
-
showRowGuide(activeRowResize.tableElement, activeRowResize.rowElement, activeRowResize.cellElement);
|
|
32268
|
+
if (syncActiveRowResizeGuide()) {
|
|
32133
32269
|
return;
|
|
32134
32270
|
}
|
|
32135
32271
|
const target = resolveEventElement(event.target);
|
|
@@ -32167,7 +32303,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32167
32303
|
};
|
|
32168
32304
|
const handleEditorMouseLeave = () => {
|
|
32169
32305
|
clearHoveredTableCell();
|
|
32170
|
-
if (!
|
|
32306
|
+
if (!isRowResizing()) {
|
|
32171
32307
|
clearAllTableResizeHover();
|
|
32172
32308
|
}
|
|
32173
32309
|
};
|
|
@@ -32188,87 +32324,16 @@ function useUEditorTableInteractions(editor) {
|
|
|
32188
32324
|
const row = cell.closest("tr");
|
|
32189
32325
|
const table = cell.closest("table");
|
|
32190
32326
|
if (!(row instanceof HTMLTableRowElement) || !(table instanceof HTMLTableElement)) return;
|
|
32191
|
-
|
|
32192
|
-
return;
|
|
32193
|
-
}
|
|
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();
|
|
32327
|
+
beginResize(event, table, row, cell);
|
|
32214
32328
|
};
|
|
32215
32329
|
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();
|
|
32330
|
+
handleRowResizePointerMove(event);
|
|
32230
32331
|
};
|
|
32231
32332
|
const handlePointerUp = (event) => {
|
|
32232
|
-
|
|
32233
|
-
if (!state) return;
|
|
32234
|
-
const nextHeight = Math.max(
|
|
32235
|
-
MIN_TABLE_ROW_HEIGHT,
|
|
32236
|
-
Math.round(state.startHeight + (event.clientY - state.startY))
|
|
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
|
|
32251
|
-
});
|
|
32252
|
-
editor.view.dispatch(tr);
|
|
32253
|
-
}
|
|
32254
|
-
rowResizeStateRef.current = null;
|
|
32255
|
-
document.body.style.cursor = "";
|
|
32256
|
-
clearHoveredTableCell();
|
|
32257
|
-
clearAllTableResizeHover();
|
|
32258
|
-
scheduleTableLayoutSync();
|
|
32333
|
+
handleRowResizePointerUp(event);
|
|
32259
32334
|
};
|
|
32260
32335
|
const handleWindowBlur = () => {
|
|
32261
|
-
|
|
32262
|
-
if (!state) return;
|
|
32263
|
-
if (rowResizeCommitFrameRef.current !== null) {
|
|
32264
|
-
window.cancelAnimationFrame(rowResizeCommitFrameRef.current);
|
|
32265
|
-
rowResizeCommitFrameRef.current = null;
|
|
32266
|
-
}
|
|
32267
|
-
rowResizeStateRef.current = null;
|
|
32268
|
-
document.body.style.cursor = "";
|
|
32269
|
-
clearHoveredTableCell();
|
|
32270
|
-
clearAllTableResizeHover();
|
|
32271
|
-
scheduleTableLayoutSync();
|
|
32336
|
+
cancelResize();
|
|
32272
32337
|
};
|
|
32273
32338
|
proseMirror.addEventListener("mousemove", handleEditorMouseMove);
|
|
32274
32339
|
proseMirror.addEventListener("mouseleave", handleEditorMouseLeave);
|
|
@@ -32311,17 +32376,13 @@ function useUEditorTableInteractions(editor) {
|
|
|
32311
32376
|
window.cancelAnimationFrame(tableLayoutSyncFrameRef.current);
|
|
32312
32377
|
tableLayoutSyncFrameRef.current = null;
|
|
32313
32378
|
}
|
|
32314
|
-
|
|
32315
|
-
window.cancelAnimationFrame(rowResizeCommitFrameRef.current);
|
|
32316
|
-
rowResizeCommitFrameRef.current = null;
|
|
32317
|
-
}
|
|
32379
|
+
cleanupRowResize();
|
|
32318
32380
|
document.body.style.cursor = "";
|
|
32319
32381
|
clearActiveTableCell();
|
|
32320
32382
|
clearHoveredTableCell();
|
|
32321
32383
|
clearAllTableResizeHover();
|
|
32322
|
-
rowResizeStateRef.current = null;
|
|
32323
32384
|
};
|
|
32324
|
-
}, [clearActiveTableCell, clearAllTableResizeHover, clearHoveredTableCell,
|
|
32385
|
+
}, [beginResize, cancelResize, cleanupRowResize, clearActiveTableCell, clearAllTableResizeHover, clearHoveredTableCell, editor, handleRowResizePointerMove, handleRowResizePointerUp, hideColumnGuide, hideRowGuide, isRowResizing, showColumnGuide, showRowGuide, syncActiveRowResizeGuide, syncActiveTableCellFromSelection, updateActiveCellHighlight]);
|
|
32325
32386
|
return {
|
|
32326
32387
|
editorContentRef,
|
|
32327
32388
|
tableColumnGuideRef,
|
|
@@ -32332,7 +32393,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32332
32393
|
|
|
32333
32394
|
// src/components/UEditor/UEditor.tsx
|
|
32334
32395
|
import { jsx as jsx83, jsxs as jsxs71 } from "react/jsx-runtime";
|
|
32335
|
-
var UEditor =
|
|
32396
|
+
var UEditor = React76.forwardRef(({
|
|
32336
32397
|
content = "",
|
|
32337
32398
|
onChange,
|
|
32338
32399
|
onHtmlChange,
|
|
@@ -32363,8 +32424,8 @@ var UEditor = React75.forwardRef(({
|
|
|
32363
32424
|
}, ref) => {
|
|
32364
32425
|
const t = useSmartTranslations("UEditor");
|
|
32365
32426
|
const effectivePlaceholder = placeholder ?? t("placeholder");
|
|
32366
|
-
const inFlightPrepareRef =
|
|
32367
|
-
const lastAppliedContentRef =
|
|
32427
|
+
const inFlightPrepareRef = useRef33(null);
|
|
32428
|
+
const lastAppliedContentRef = useRef33(content ?? "");
|
|
32368
32429
|
const extensions = useMemo24(
|
|
32369
32430
|
() => buildUEditorExtensions({
|
|
32370
32431
|
placeholder: effectivePlaceholder,
|