@ctzhian/tiptap 1.13.9 → 2.0.0
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/dist/Editor/demo.js +1 -1
- package/dist/Editor/index.js +17 -0
- package/dist/component/CustomBubbleMenu/index.js +1 -1
- package/dist/component/CustomDragHandle/index.js +3 -59
- package/dist/component/Icons/delete-back-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/delete-back-2-line-icon.js +13 -0
- package/dist/component/Menu/index.js +5 -1
- package/dist/contants/enums.d.ts +9 -0
- package/dist/contants/enums.js +61 -1
- package/dist/extension/component/TableCellHandleMenu/index.d.ts +9 -0
- package/dist/extension/component/TableCellHandleMenu/index.js +443 -0
- package/dist/extension/component/TableExtendButton/TableExtendButton.css +30 -0
- package/dist/extension/component/TableExtendButton/index.d.ts +23 -0
- package/dist/extension/component/TableExtendButton/index.js +201 -0
- package/dist/extension/component/TableExtendButton/use-table-extend-row-column.d.ts +15 -0
- package/dist/extension/component/TableExtendButton/use-table-extend-row-column.js +87 -0
- package/dist/extension/component/TableHandle/TableHandleMenu.css +36 -0
- package/dist/extension/component/TableHandle/TableHandleMenu.d.ts +17 -0
- package/dist/extension/component/TableHandle/TableHandleMenu.js +685 -0
- package/dist/extension/component/TableHandle/index.d.ts +28 -0
- package/dist/extension/component/TableHandle/index.js +93 -0
- package/dist/extension/component/TableHandle/use-table-handle-positioning.d.ts +40 -0
- package/dist/extension/component/TableHandle/use-table-handle-positioning.js +193 -0
- package/dist/extension/component/TableHandle/use-table-handle-state.d.ts +22 -0
- package/dist/extension/component/TableHandle/use-table-handle-state.js +45 -0
- package/dist/extension/component/TableSelectionOverlay/index.d.ts +16 -0
- package/dist/extension/component/TableSelectionOverlay/index.js +460 -0
- package/dist/extension/component/UploadProgress/index.d.ts +1 -1
- package/dist/extension/node/FileHandler.d.ts +1 -1
- package/dist/extension/node/Table.js +226 -43
- package/dist/extension/node/TableHandler/create-image.d.ts +9 -0
- package/dist/extension/node/TableHandler/create-image.js +235 -0
- package/dist/extension/node/TableHandler/index.d.ts +15 -0
- package/dist/extension/node/TableHandler/index.js +33 -0
- package/dist/extension/node/TableHandler/plugin.d.ts +49 -0
- package/dist/extension/node/TableHandler/plugin.js +1030 -0
- package/dist/index.css +29 -10
- package/dist/type/index.d.ts +2 -0
- package/dist/util/table-utils.d.ts +161 -0
- package/dist/util/table-utils.js +605 -0
- package/package.json +2 -1
- package/dist/extension/component/Table/ContextMenu.d.ts +0 -11
- package/dist/extension/component/Table/ContextMenu.js +0 -186
- package/dist/extension/component/Table/TableContextMenuPlugin.d.ts +0 -9
- package/dist/extension/component/Table/TableContextMenuPlugin.js +0 -336
- package/dist/extension/component/Table/index.d.ts +0 -2
- package/dist/extension/component/Table/index.js +0 -2
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { FloatingPortal } from '@floating-ui/react';
|
|
8
|
+
import { Box } from '@mui/material';
|
|
9
|
+
import { TableMap } from '@tiptap/pm/tables';
|
|
10
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
11
|
+
import { AddLineIcon } from "../../../component/Icons/add-line-icon";
|
|
12
|
+
import { EMPTY_CELL_HEIGHT, EMPTY_CELL_WIDTH, countEmptyColumnsFromEnd, countEmptyRowsFromEnd, marginRound, runPreservingCursor, selectLastCell } from "../../../util/table-utils";
|
|
13
|
+
import { useTableHandleState } from "../TableHandle/use-table-handle-state";
|
|
14
|
+
import "./TableExtendButton.css";
|
|
15
|
+
import { useTableExtendRowColumnButtonsPositioning } from "./use-table-extend-row-column";
|
|
16
|
+
/**
|
|
17
|
+
* Simplified button component for extending/reducing table dimensions
|
|
18
|
+
*/
|
|
19
|
+
export var TableExtendRowColumnButton = function TableExtendRowColumnButton(_ref) {
|
|
20
|
+
var providedEditor = _ref.editor,
|
|
21
|
+
onMouseDown = _ref.onMouseDown,
|
|
22
|
+
onMouseUp = _ref.onMouseUp,
|
|
23
|
+
orientation = _ref.orientation;
|
|
24
|
+
var editor = providedEditor;
|
|
25
|
+
var state = useTableHandleState({
|
|
26
|
+
editor: editor
|
|
27
|
+
});
|
|
28
|
+
var isRowOrientation = orientation === 'row';
|
|
29
|
+
var movedRef = useRef(false);
|
|
30
|
+
var _useState = useState(null),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
dragState = _useState2[0],
|
|
33
|
+
setDragState = _useState2[1];
|
|
34
|
+
var startDrag = useCallback(function (ev) {
|
|
35
|
+
if (!state) return;
|
|
36
|
+
var dims = TableMap.get(state.block);
|
|
37
|
+
movedRef.current = false;
|
|
38
|
+
setDragState({
|
|
39
|
+
startPos: isRowOrientation ? ev.clientY : ev.clientX,
|
|
40
|
+
originalHeight: dims.height,
|
|
41
|
+
originalWidth: dims.width
|
|
42
|
+
});
|
|
43
|
+
onMouseDown();
|
|
44
|
+
ev.preventDefault();
|
|
45
|
+
}, [state, isRowOrientation, onMouseDown]);
|
|
46
|
+
var handleClick = useCallback(function () {
|
|
47
|
+
if (movedRef.current || !editor || !state) return;
|
|
48
|
+
runPreservingCursor(editor, function () {
|
|
49
|
+
selectLastCell(editor, state.block, state.blockPos, orientation);
|
|
50
|
+
if (isRowOrientation) {
|
|
51
|
+
editor.commands.addRowAfter();
|
|
52
|
+
} else {
|
|
53
|
+
editor.commands.addColumnAfter();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}, [editor, isRowOrientation, orientation, state]);
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
if (!dragState || !editor || !state) return;
|
|
59
|
+
var handleMove = function handleMove(ev) {
|
|
60
|
+
movedRef.current = true;
|
|
61
|
+
var currentPos = isRowOrientation ? ev.clientY : ev.clientX;
|
|
62
|
+
var diff = currentPos - dragState.startPos;
|
|
63
|
+
var cellSize = isRowOrientation ? EMPTY_CELL_HEIGHT : EMPTY_CELL_WIDTH;
|
|
64
|
+
var currentDims = TableMap.get(state.block);
|
|
65
|
+
var currentCount = isRowOrientation ? currentDims.height : currentDims.width;
|
|
66
|
+
var originalCount = isRowOrientation ? dragState.originalHeight : dragState.originalWidth;
|
|
67
|
+
var newCount = Math.max(1, originalCount + marginRound(diff / cellSize, 0.3));
|
|
68
|
+
var delta = newCount - currentCount;
|
|
69
|
+
if (delta === 0) return;
|
|
70
|
+
|
|
71
|
+
// Add rows/columns
|
|
72
|
+
if (delta > 0) {
|
|
73
|
+
runPreservingCursor(editor, function () {
|
|
74
|
+
selectLastCell(editor, state.block, state.blockPos, orientation);
|
|
75
|
+
for (var i = 0; i < delta; i++) {
|
|
76
|
+
if (isRowOrientation) {
|
|
77
|
+
editor.commands.addRowAfter();
|
|
78
|
+
} else {
|
|
79
|
+
editor.commands.addColumnAfter();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
// Remove rows/columns - but only if they're empty
|
|
85
|
+
else {
|
|
86
|
+
runPreservingCursor(editor, function () {
|
|
87
|
+
var absDelta = Math.abs(delta);
|
|
88
|
+
var emptyCount = isRowOrientation ? countEmptyRowsFromEnd(editor, state.blockPos) : countEmptyColumnsFromEnd(editor, state.blockPos);
|
|
89
|
+
|
|
90
|
+
// Only remove up to the number of empty cells, and keep at least 1
|
|
91
|
+
var safeToRemove = Math.min(absDelta, emptyCount, currentCount - 1);
|
|
92
|
+
selectLastCell(editor, state.block, state.blockPos, orientation);
|
|
93
|
+
for (var i = 0; i < safeToRemove; i++) {
|
|
94
|
+
if (isRowOrientation) {
|
|
95
|
+
editor.commands.deleteRow();
|
|
96
|
+
} else {
|
|
97
|
+
editor.commands.deleteColumn();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var handleUp = function handleUp() {
|
|
104
|
+
setDragState(null);
|
|
105
|
+
onMouseUp();
|
|
106
|
+
};
|
|
107
|
+
window.addEventListener('mousemove', handleMove);
|
|
108
|
+
window.addEventListener('mouseup', handleUp);
|
|
109
|
+
return function () {
|
|
110
|
+
window.removeEventListener('mousemove', handleMove);
|
|
111
|
+
window.removeEventListener('mouseup', handleUp);
|
|
112
|
+
};
|
|
113
|
+
}, [dragState, editor, isRowOrientation, orientation, onMouseUp, state]);
|
|
114
|
+
if (!(editor !== null && editor !== void 0 && editor.isEditable)) return null;
|
|
115
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
116
|
+
component: "button",
|
|
117
|
+
className: "tiptap-table-extend-row-column-button ".concat(isRowOrientation ? 'tiptap-table-row-end-add-remove' : 'tiptap-table-column-end-add-remove', " ").concat(dragState ? 'editing' : ''),
|
|
118
|
+
onClick: handleClick,
|
|
119
|
+
onMouseDown: startDrag,
|
|
120
|
+
type: "button",
|
|
121
|
+
"aria-label": isRowOrientation ? 'Add or remove rows' : 'Add or remove columns',
|
|
122
|
+
sx: {
|
|
123
|
+
border: 'none',
|
|
124
|
+
display: 'flex',
|
|
125
|
+
alignItems: 'center',
|
|
126
|
+
justifyContent: 'center',
|
|
127
|
+
backgroundColor: 'var(--mui-palette-background-paper3)',
|
|
128
|
+
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
129
|
+
padding: 0,
|
|
130
|
+
cursor: 'pointer',
|
|
131
|
+
'&.tiptap-table-row-end-add-remove': {
|
|
132
|
+
width: '100%',
|
|
133
|
+
height: '0.75rem'
|
|
134
|
+
},
|
|
135
|
+
'&.tiptap-table-column-end-add-remove': {
|
|
136
|
+
width: '0.75rem'
|
|
137
|
+
},
|
|
138
|
+
'&:hover': {
|
|
139
|
+
backgroundColor: 'var(--mui-palette-primary-main)',
|
|
140
|
+
'& .MuiSvgIcon-root': {
|
|
141
|
+
color: 'var(--mui-palette-common-white)'
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}, /*#__PURE__*/React.createElement(AddLineIcon, {
|
|
146
|
+
sx: {
|
|
147
|
+
width: '1rem',
|
|
148
|
+
height: '1rem',
|
|
149
|
+
flexShrink: 0,
|
|
150
|
+
color: 'var(--mui-palette-text-disabled)'
|
|
151
|
+
}
|
|
152
|
+
}));
|
|
153
|
+
};
|
|
154
|
+
export var TableExtendRowColumnButtons = function TableExtendRowColumnButtons(_ref2) {
|
|
155
|
+
var _state$showAddOrRemov, _state$showAddOrRemov2, _state$referencePosTa, _state$referencePosLa, _state$referencePosLa2;
|
|
156
|
+
var providedEditor = _ref2.editor,
|
|
157
|
+
onMouseDown = _ref2.onMouseDown,
|
|
158
|
+
onMouseUp = _ref2.onMouseUp;
|
|
159
|
+
var editor = providedEditor;
|
|
160
|
+
var state = useTableHandleState({
|
|
161
|
+
editor: editor
|
|
162
|
+
});
|
|
163
|
+
var _useTableExtendRowCol = useTableExtendRowColumnButtonsPositioning((_state$showAddOrRemov = state === null || state === void 0 ? void 0 : state.showAddOrRemoveColumnsButton) !== null && _state$showAddOrRemov !== void 0 ? _state$showAddOrRemov : false, (_state$showAddOrRemov2 = state === null || state === void 0 ? void 0 : state.showAddOrRemoveRowsButton) !== null && _state$showAddOrRemov2 !== void 0 ? _state$showAddOrRemov2 : false, (_state$referencePosTa = state === null || state === void 0 ? void 0 : state.referencePosTable) !== null && _state$referencePosTa !== void 0 ? _state$referencePosTa : null, (_state$referencePosLa = state === null || state === void 0 ? void 0 : state.referencePosLastRow) !== null && _state$referencePosLa !== void 0 ? _state$referencePosLa : null, (_state$referencePosLa2 = state === null || state === void 0 ? void 0 : state.referencePosLastCol) !== null && _state$referencePosLa2 !== void 0 ? _state$referencePosLa2 : null),
|
|
164
|
+
columnButton = _useTableExtendRowCol.columnButton,
|
|
165
|
+
rowButton = _useTableExtendRowCol.rowButton;
|
|
166
|
+
var handleDown = useCallback(function () {
|
|
167
|
+
if (!editor) return;
|
|
168
|
+
editor.commands.freezeHandles();
|
|
169
|
+
onMouseDown === null || onMouseDown === void 0 || onMouseDown();
|
|
170
|
+
}, [editor, onMouseDown]);
|
|
171
|
+
var handleUp = useCallback(function () {
|
|
172
|
+
if (!editor) return;
|
|
173
|
+
editor.commands.unfreezeHandles();
|
|
174
|
+
onMouseUp === null || onMouseUp === void 0 || onMouseUp();
|
|
175
|
+
}, [editor, onMouseUp]);
|
|
176
|
+
if (!state) return null;
|
|
177
|
+
|
|
178
|
+
// Insert into .table-controls container (widgetContainer)
|
|
179
|
+
var rootElement = state.widgetContainer || document.body;
|
|
180
|
+
return /*#__PURE__*/React.createElement(FloatingPortal, {
|
|
181
|
+
root: rootElement
|
|
182
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
183
|
+
ref: rowButton.ref,
|
|
184
|
+
style: rowButton.style
|
|
185
|
+
}, /*#__PURE__*/React.createElement(TableExtendRowColumnButton, {
|
|
186
|
+
editor: editor,
|
|
187
|
+
orientation: "row",
|
|
188
|
+
block: state.block,
|
|
189
|
+
onMouseDown: handleDown,
|
|
190
|
+
onMouseUp: handleUp
|
|
191
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
192
|
+
ref: columnButton.ref,
|
|
193
|
+
style: columnButton.style
|
|
194
|
+
}, /*#__PURE__*/React.createElement(TableExtendRowColumnButton, {
|
|
195
|
+
editor: editor,
|
|
196
|
+
orientation: "column",
|
|
197
|
+
block: state.block,
|
|
198
|
+
onMouseDown: handleDown,
|
|
199
|
+
onMouseUp: handleUp
|
|
200
|
+
})));
|
|
201
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface TableExtendRowColumnButtonPositionResult {
|
|
3
|
+
isMounted: boolean;
|
|
4
|
+
ref: (node: HTMLElement | null) => void;
|
|
5
|
+
style: React.CSSProperties;
|
|
6
|
+
}
|
|
7
|
+
interface TableExtendRowColumnButtonsPositioningResult {
|
|
8
|
+
rowButton: TableExtendRowColumnButtonPositionResult;
|
|
9
|
+
columnButton: TableExtendRowColumnButtonPositionResult;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Hook for managing positioning of both row and column extend buttons
|
|
13
|
+
*/
|
|
14
|
+
export declare function useTableExtendRowColumnButtonsPositioning(showAddOrRemoveColumnsButton: boolean, showAddOrRemoveRowsButton: boolean, referencePosTable: DOMRect | null, referencePosLastRow: DOMRect | null, referencePosLastCol: DOMRect | null): TableExtendRowColumnButtonsPositioningResult;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { offset, size, useFloating, useTransitionStyles } from '@floating-ui/react';
|
|
8
|
+
import { useEffect, useMemo } from 'react';
|
|
9
|
+
var ORIENTATION_CONFIG = {
|
|
10
|
+
row: {
|
|
11
|
+
placement: 'bottom',
|
|
12
|
+
sizeProperty: 'width'
|
|
13
|
+
},
|
|
14
|
+
column: {
|
|
15
|
+
placement: 'right',
|
|
16
|
+
sizeProperty: 'height'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Custom hook for positioning extend buttons using Floating UI React
|
|
22
|
+
*/
|
|
23
|
+
function useTableExtendRowColumnButtonPosition(orientation, show, referencePosTable) {
|
|
24
|
+
var config = ORIENTATION_CONFIG[orientation];
|
|
25
|
+
var _useFloating = useFloating({
|
|
26
|
+
open: show,
|
|
27
|
+
placement: config.placement,
|
|
28
|
+
middleware: [offset(4), size({
|
|
29
|
+
apply: function apply(_ref) {
|
|
30
|
+
var rects = _ref.rects,
|
|
31
|
+
elements = _ref.elements;
|
|
32
|
+
var floating = elements.floating;
|
|
33
|
+
if (!floating) return;
|
|
34
|
+
|
|
35
|
+
// Apply size based on orientation
|
|
36
|
+
var sizeValue = "".concat(rects.reference[config.sizeProperty], "px");
|
|
37
|
+
floating.style[config.sizeProperty] = sizeValue;
|
|
38
|
+
}
|
|
39
|
+
})]
|
|
40
|
+
}),
|
|
41
|
+
refs = _useFloating.refs,
|
|
42
|
+
update = _useFloating.update,
|
|
43
|
+
context = _useFloating.context,
|
|
44
|
+
floatingStyles = _useFloating.floatingStyles;
|
|
45
|
+
var _useTransitionStyles = useTransitionStyles(context),
|
|
46
|
+
isMounted = _useTransitionStyles.isMounted,
|
|
47
|
+
styles = _useTransitionStyles.styles;
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
if (!referencePosTable) {
|
|
50
|
+
refs.setReference(null);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Create a virtual element that always returns the latest rect values
|
|
55
|
+
// This ensures autoUpdate can detect changes when scrolling
|
|
56
|
+
refs.setReference({
|
|
57
|
+
getBoundingClientRect: function getBoundingClientRect() {
|
|
58
|
+
// Always use the latest value from closure
|
|
59
|
+
return referencePosTable || new DOMRect();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
update();
|
|
63
|
+
}, [referencePosTable, refs, update]);
|
|
64
|
+
return useMemo(function () {
|
|
65
|
+
return {
|
|
66
|
+
isMounted: isMounted,
|
|
67
|
+
ref: refs.setFloating,
|
|
68
|
+
style: _objectSpread(_objectSpread({
|
|
69
|
+
display: 'flex'
|
|
70
|
+
}, styles), floatingStyles)
|
|
71
|
+
};
|
|
72
|
+
}, [floatingStyles, isMounted, refs.setFloating, styles]);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Hook for managing positioning of both row and column extend buttons
|
|
77
|
+
*/
|
|
78
|
+
export function useTableExtendRowColumnButtonsPositioning(showAddOrRemoveColumnsButton, showAddOrRemoveRowsButton, referencePosTable, referencePosLastRow, referencePosLastCol) {
|
|
79
|
+
var rowButton = useTableExtendRowColumnButtonPosition('row', showAddOrRemoveRowsButton, referencePosLastRow || referencePosTable);
|
|
80
|
+
var columnButton = useTableExtendRowColumnButtonPosition('column', showAddOrRemoveColumnsButton, referencePosLastCol || referencePosTable);
|
|
81
|
+
return useMemo(function () {
|
|
82
|
+
return {
|
|
83
|
+
rowButton: rowButton,
|
|
84
|
+
columnButton: columnButton
|
|
85
|
+
};
|
|
86
|
+
}, [rowButton, columnButton]);
|
|
87
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.tiptap-table-handle-menu {
|
|
2
|
+
border: none;
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
background-color: var(--mui-palette-background-paper3);
|
|
7
|
+
border-radius: var(--mui-shape-borderRadius);
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.tiptap-table-handle-menu:hover {
|
|
12
|
+
background-color: var(--mui-palette-primary-main);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.tiptap-table-handle-menu:hover .tiptap-button-icon {
|
|
16
|
+
color: var(--mui-palette-common-white);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.tiptap-table-handle-menu.menu-opened {
|
|
20
|
+
background-color: var(--mui-palette-primary-main);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tiptap-table-handle-menu.is-dragging {
|
|
24
|
+
cursor: grabbing;
|
|
25
|
+
background-color: var(--mui-palette-primary-main);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.tiptap-table-handle-menu.row {
|
|
29
|
+
width: 0.75rem;
|
|
30
|
+
height: var(--table-handle-ref-height);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.tiptap-table-handle-menu.column {
|
|
34
|
+
height: 0.75rem;
|
|
35
|
+
width: var(--table-handle-ref-width);
|
|
36
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Node } from '@tiptap/pm/model';
|
|
2
|
+
import type { Editor } from '@tiptap/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import type { Orientation } from '../../../util/table-utils';
|
|
5
|
+
import './TableHandleMenu.css';
|
|
6
|
+
interface TableHandleMenuProps {
|
|
7
|
+
editor?: Editor | null;
|
|
8
|
+
orientation: Orientation;
|
|
9
|
+
index?: number;
|
|
10
|
+
tableNode?: Node;
|
|
11
|
+
tablePos?: number;
|
|
12
|
+
onToggleOtherHandle?: (visible: boolean) => void;
|
|
13
|
+
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
dragStart?: (e: React.DragEvent) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const TableHandleMenu: ({ editor, orientation, index, tableNode, tablePos, onToggleOtherHandle, onOpenChange, dragStart, }: TableHandleMenuProps) => React.JSX.Element | null;
|
|
17
|
+
export {};
|