@atlaskit/editor-plugin-table 7.3.6 → 7.3.8
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 +14 -0
- package/dist/cjs/event-handlers.js +50 -25
- package/dist/cjs/nodeviews/TableResizer.js +1 -0
- package/dist/cjs/nodeviews/TableRow.js +25 -83
- package/dist/cjs/pm-plugins/main.js +1 -0
- package/dist/cjs/ui/FloatingInsertButton/index.js +8 -6
- package/dist/cjs/ui/common-styles.js +2 -2
- package/dist/es2019/event-handlers.js +29 -0
- package/dist/es2019/nodeviews/TableResizer.js +1 -0
- package/dist/es2019/nodeviews/TableRow.js +27 -87
- package/dist/es2019/pm-plugins/main.js +2 -1
- package/dist/es2019/ui/FloatingInsertButton/index.js +8 -6
- package/dist/es2019/ui/common-styles.js +2 -1
- package/dist/esm/event-handlers.js +49 -24
- package/dist/esm/nodeviews/TableResizer.js +1 -0
- package/dist/esm/nodeviews/TableRow.js +26 -84
- package/dist/esm/pm-plugins/main.js +2 -1
- package/dist/esm/ui/FloatingInsertButton/index.js +8 -6
- package/dist/esm/ui/common-styles.js +2 -2
- package/dist/types/event-handlers.d.ts +1 -0
- package/dist/types/nodeviews/TableRow.d.ts +0 -1
- package/dist/types-ts4.5/event-handlers.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/TableRow.d.ts +0 -1
- package/package.json +6 -6
- package/src/event-handlers.ts +36 -0
- package/src/nodeviews/TableResizer.tsx +1 -0
- package/src/nodeviews/TableRow.ts +32 -106
- package/src/pm-plugins/main.ts +2 -0
- package/src/ui/FloatingInsertButton/index.tsx +11 -8
- package/src/ui/common-styles.ts +2 -4
|
@@ -2,14 +2,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import debounce from 'lodash/debounce';
|
|
3
3
|
import throttle from 'lodash/throttle';
|
|
4
4
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
5
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
8
6
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
9
7
|
import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
|
|
10
8
|
import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
|
|
11
9
|
import { TableCssClassName as ClassName, TableCssClassName } from '../types';
|
|
12
|
-
import {
|
|
10
|
+
import { stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
|
|
13
11
|
import { getTop, getTree } from '../utils/dom';
|
|
14
12
|
import { supportedHeaderRow } from '../utils/nodes';
|
|
15
13
|
import TableNodeView from './TableNodeViewBase';
|
|
@@ -244,92 +242,34 @@ export default class TableRow extends TableNodeView {
|
|
|
244
242
|
});
|
|
245
243
|
}
|
|
246
244
|
createIntersectionObserver() {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
entries.forEach(entry => {
|
|
255
|
-
const {
|
|
256
|
-
target,
|
|
257
|
-
isIntersecting,
|
|
258
|
-
boundingClientRect
|
|
259
|
-
} = entry;
|
|
260
|
-
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
261
|
-
const targetKey = target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
262
|
-
// Cache the latest sentinel information
|
|
263
|
-
this.sentinelData[targetKey] = {
|
|
264
|
-
isIntersecting,
|
|
265
|
-
boundingClientRect,
|
|
266
|
-
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
267
|
-
};
|
|
268
|
-
// Keep the other sentinels rootBounds in sync with this latest one
|
|
269
|
-
this.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
270
|
-
});
|
|
271
|
-
this.refreshStickyState();
|
|
272
|
-
}, {
|
|
273
|
-
threshold: 0,
|
|
274
|
-
root: this.editorScrollableElement
|
|
275
|
-
});
|
|
276
|
-
} else {
|
|
277
|
-
this.intersectionObserver = new IntersectionObserver((entries, _) => {
|
|
278
|
-
const tree = getTree(this.dom);
|
|
279
|
-
if (!tree) {
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
245
|
+
this.intersectionObserver = new IntersectionObserver((entries, _) => {
|
|
246
|
+
var _this$editorScrollabl2, _this$editorScrollabl3;
|
|
247
|
+
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
248
|
+
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
249
|
+
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
250
|
+
const rootBounds = (_this$editorScrollabl2 = this.editorScrollableElement) === null || _this$editorScrollabl2 === void 0 ? void 0 : (_this$editorScrollabl3 = _this$editorScrollabl2.getBoundingClientRect) === null || _this$editorScrollabl3 === void 0 ? void 0 : _this$editorScrollabl3.call(_this$editorScrollabl2);
|
|
251
|
+
entries.forEach(entry => {
|
|
282
252
|
const {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP)) {
|
|
299
|
-
var _entry$rootBounds2;
|
|
300
|
-
const sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
|
|
301
|
-
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
302
|
-
var _entry$rootBounds3;
|
|
303
|
-
tree && this.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
|
|
304
|
-
this.lastStickyTimestamp = Date.now();
|
|
305
|
-
} else {
|
|
306
|
-
table && this.makeRowHeaderNotSticky(table);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
|
|
310
|
-
var _entry$rootBounds4;
|
|
311
|
-
const sentinelIsAboveScrollArea = entry.boundingClientRect.top - this.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
|
|
312
|
-
if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
313
|
-
// Not a perfect solution, but need to this code specific for FireFox ED-19177
|
|
314
|
-
if (browser.gecko) {
|
|
315
|
-
if (this.lastStickyTimestamp && Date.now() - this.lastStickyTimestamp > STICKY_HEADER_TOGGLE_TOLERANCE_MS) {
|
|
316
|
-
this.makeRowHeaderNotSticky(table);
|
|
317
|
-
}
|
|
318
|
-
} else {
|
|
319
|
-
this.makeRowHeaderNotSticky(table);
|
|
320
|
-
}
|
|
321
|
-
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
322
|
-
var _entry$rootBounds5;
|
|
323
|
-
tree && this.makeHeaderRowSticky(tree, entry === null || entry === void 0 ? void 0 : (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
|
|
324
|
-
this.lastStickyTimestamp = Date.now();
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return;
|
|
328
|
-
});
|
|
329
|
-
}, {
|
|
330
|
-
root: this.editorScrollableElement
|
|
253
|
+
target,
|
|
254
|
+
isIntersecting,
|
|
255
|
+
boundingClientRect
|
|
256
|
+
} = entry;
|
|
257
|
+
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
258
|
+
const targetKey = target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
259
|
+
// Cache the latest sentinel information
|
|
260
|
+
this.sentinelData[targetKey] = {
|
|
261
|
+
isIntersecting,
|
|
262
|
+
boundingClientRect,
|
|
263
|
+
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
264
|
+
};
|
|
265
|
+
// Keep the other sentinels rootBounds in sync with this latest one
|
|
266
|
+
this.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
331
267
|
});
|
|
332
|
-
|
|
268
|
+
this.refreshStickyState();
|
|
269
|
+
}, {
|
|
270
|
+
threshold: 0,
|
|
271
|
+
root: this.editorScrollableElement
|
|
272
|
+
});
|
|
333
273
|
}
|
|
334
274
|
refreshStickyState() {
|
|
335
275
|
const tree = getTree(this.dom);
|
|
@@ -10,7 +10,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
10
10
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
11
11
|
import { stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
12
12
|
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
13
|
-
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
|
|
13
|
+
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleMouseUp, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
|
|
14
14
|
import { createTableView } from '../nodeviews/table';
|
|
15
15
|
import TableCell from '../nodeviews/TableCell';
|
|
16
16
|
import TableRow from '../nodeviews/TableRow';
|
|
@@ -270,6 +270,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
270
270
|
mouseout: whenTableInFocus(handleMouseOut),
|
|
271
271
|
mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
|
|
272
272
|
mouseenter: handleMouseEnter,
|
|
273
|
+
mouseup: whenTableInFocus(handleMouseUp),
|
|
273
274
|
click: withCellTracking(whenTableInFocus(handleClick))
|
|
274
275
|
},
|
|
275
276
|
handleTripleClick
|
|
@@ -58,12 +58,15 @@ export class FloatingInsertButton extends React.Component {
|
|
|
58
58
|
if (tr.selection instanceof CellSelection && (tr.selection.isColSelection() || tr.selection.isRowSelection())) {
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
|
-
const
|
|
62
|
-
if (!
|
|
61
|
+
const tablePos = findTable(tr.selection);
|
|
62
|
+
if (!tablePos) {
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
|
|
66
|
+
// the tableNode props is not always latest (when you type some text in a cell, it's not updated yet)
|
|
67
|
+
// we need to get the latest one by calling findTable(tr.selection)
|
|
68
|
+
const cellPosition = this.getCellPosition(type, tablePos === null || tablePos === void 0 ? void 0 : tablePos.node);
|
|
69
|
+
if (!cellPosition) {
|
|
67
70
|
return null;
|
|
68
71
|
}
|
|
69
72
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
@@ -128,9 +131,8 @@ export class FloatingInsertButton extends React.Component {
|
|
|
128
131
|
hasStickyHeaders: this.props.hasStickyHeaders || false
|
|
129
132
|
}));
|
|
130
133
|
}
|
|
131
|
-
getCellPosition(type) {
|
|
134
|
+
getCellPosition(type, tableNode) {
|
|
132
135
|
const {
|
|
133
|
-
tableNode,
|
|
134
136
|
insertColumnButtonIndex,
|
|
135
137
|
insertRowButtonIndex
|
|
136
138
|
} = this.props;
|
|
@@ -165,7 +165,7 @@ const tableStickyHeaderFirefoxFixStyle = () => {
|
|
|
165
165
|
This fixes a bug which occurs in firefox when the first row becomes sticky.
|
|
166
166
|
see https://product-fabric.atlassian.net/browse/ED-19177
|
|
167
167
|
*/
|
|
168
|
-
if (browser.gecko
|
|
168
|
+
if (browser.gecko) {
|
|
169
169
|
return css`
|
|
170
170
|
.${ClassName.TABLE_STICKY} > tbody::before {
|
|
171
171
|
content: '';
|
|
@@ -628,6 +628,7 @@ export const tableStyles = props => {
|
|
|
628
628
|
height: 4px;
|
|
629
629
|
width: 4px;
|
|
630
630
|
border-radius: 50%;
|
|
631
|
+
pointer-events: none;
|
|
631
632
|
}
|
|
632
633
|
}
|
|
633
634
|
|
|
@@ -138,6 +138,31 @@ export var handleMouseOver = function handleMouseOver(view, mouseEvent) {
|
|
|
138
138
|
}
|
|
139
139
|
return false;
|
|
140
140
|
};
|
|
141
|
+
export var handleMouseUp = function handleMouseUp(view, mouseEvent) {
|
|
142
|
+
if (!getBooleanFF('platform.editor.table.insert-last-column-btn-stays-in-place')) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
if (!(mouseEvent instanceof MouseEvent)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
var state = view.state,
|
|
149
|
+
dispatch = view.dispatch;
|
|
150
|
+
var _getPluginState2 = getPluginState(state),
|
|
151
|
+
insertColumnButtonIndex = _getPluginState2.insertColumnButtonIndex,
|
|
152
|
+
tableNode = _getPluginState2.tableNode,
|
|
153
|
+
tableRef = _getPluginState2.tableRef;
|
|
154
|
+
if (insertColumnButtonIndex !== undefined && tableRef && tableRef.parentElement && tableNode) {
|
|
155
|
+
var _TableMap$get = TableMap.get(tableNode),
|
|
156
|
+
width = _TableMap$get.width;
|
|
157
|
+
var newInsertColumnButtonIndex = insertColumnButtonIndex + 1;
|
|
158
|
+
if (width === newInsertColumnButtonIndex) {
|
|
159
|
+
var tableWidth = tableRef.clientWidth;
|
|
160
|
+
tableRef.parentElement.scrollTo(tableWidth, 0);
|
|
161
|
+
return showInsertColumnButton(newInsertColumnButtonIndex)(state, dispatch);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
};
|
|
141
166
|
|
|
142
167
|
// Ignore any `mousedown` `event` from control and numbered column buttons
|
|
143
168
|
// PM end up changing selection during shift selection if not prevented
|
|
@@ -165,8 +190,8 @@ export var handleMouseOut = function handleMouseOut(view, mouseEvent) {
|
|
|
165
190
|
var _state2 = view.state,
|
|
166
191
|
_dispatch3 = view.dispatch;
|
|
167
192
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
168
|
-
var
|
|
169
|
-
isKeyboardResize =
|
|
193
|
+
var _getPluginState3 = getPluginState(_state2),
|
|
194
|
+
isKeyboardResize = _getPluginState3.isKeyboardResize;
|
|
170
195
|
if (isKeyboardResize) {
|
|
171
196
|
// no need to hide decoration if column resizing started by keyboard
|
|
172
197
|
return false;
|
|
@@ -181,8 +206,8 @@ export var handleMouseOut = function handleMouseOut(view, mouseEvent) {
|
|
|
181
206
|
export var handleMouseEnter = function handleMouseEnter(view, mouseEvent) {
|
|
182
207
|
var state = view.state,
|
|
183
208
|
dispatch = view.dispatch;
|
|
184
|
-
var
|
|
185
|
-
isTableHovered =
|
|
209
|
+
var _getPluginState4 = getPluginState(state),
|
|
210
|
+
isTableHovered = _getPluginState4.isTableHovered;
|
|
186
211
|
if (!isTableHovered) {
|
|
187
212
|
return setTableHovered(true)(state, dispatch);
|
|
188
213
|
}
|
|
@@ -194,11 +219,11 @@ export var handleMouseLeave = function handleMouseLeave(view, event) {
|
|
|
194
219
|
}
|
|
195
220
|
var state = view.state,
|
|
196
221
|
dispatch = view.dispatch;
|
|
197
|
-
var
|
|
198
|
-
insertColumnButtonIndex =
|
|
199
|
-
insertRowButtonIndex =
|
|
200
|
-
isDragAndDropEnabled =
|
|
201
|
-
isTableHovered =
|
|
222
|
+
var _getPluginState5 = getPluginState(state),
|
|
223
|
+
insertColumnButtonIndex = _getPluginState5.insertColumnButtonIndex,
|
|
224
|
+
insertRowButtonIndex = _getPluginState5.insertRowButtonIndex,
|
|
225
|
+
isDragAndDropEnabled = _getPluginState5.isDragAndDropEnabled,
|
|
226
|
+
isTableHovered = _getPluginState5.isTableHovered;
|
|
202
227
|
if (isTableHovered) {
|
|
203
228
|
if (isDragAndDropEnabled) {
|
|
204
229
|
var _getDragDropPluginSta = getDragDropPluginState(state),
|
|
@@ -231,9 +256,9 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
231
256
|
if (isColumnControlsDecorations(element) || isDragColumnFloatingInsertDot(element)) {
|
|
232
257
|
var state = view.state,
|
|
233
258
|
dispatch = view.dispatch;
|
|
234
|
-
var
|
|
235
|
-
insertColumnButtonIndex =
|
|
236
|
-
isDragAndDropEnabled =
|
|
259
|
+
var _getPluginState6 = getPluginState(state),
|
|
260
|
+
insertColumnButtonIndex = _getPluginState6.insertColumnButtonIndex,
|
|
261
|
+
isDragAndDropEnabled = _getPluginState6.isDragAndDropEnabled;
|
|
237
262
|
var _getColumnOrRowIndex9 = getColumnOrRowIndex(element),
|
|
238
263
|
_getColumnOrRowIndex10 = _slicedToArray(_getColumnOrRowIndex9, 2),
|
|
239
264
|
startIndex = _getColumnOrRowIndex10[0],
|
|
@@ -246,8 +271,8 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
246
271
|
if (isRowControlsButton(element) || isDragRowFloatingInsertDot(element)) {
|
|
247
272
|
var _state3 = view.state,
|
|
248
273
|
_dispatch4 = view.dispatch;
|
|
249
|
-
var
|
|
250
|
-
insertRowButtonIndex =
|
|
274
|
+
var _getPluginState7 = getPluginState(_state3),
|
|
275
|
+
insertRowButtonIndex = _getPluginState7.insertRowButtonIndex;
|
|
251
276
|
var _getColumnOrRowIndex11 = getColumnOrRowIndex(element),
|
|
252
277
|
_getColumnOrRowIndex12 = _slicedToArray(_getColumnOrRowIndex11, 2),
|
|
253
278
|
_startIndex3 = _getColumnOrRowIndex12[0],
|
|
@@ -262,9 +287,9 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
262
287
|
if (_positionColumn !== null) {
|
|
263
288
|
var _state4 = view.state,
|
|
264
289
|
_dispatch5 = view.dispatch;
|
|
265
|
-
var
|
|
266
|
-
resizeHandleColumnIndex =
|
|
267
|
-
resizeHandleRowIndex =
|
|
290
|
+
var _getPluginState8 = getPluginState(_state4),
|
|
291
|
+
resizeHandleColumnIndex = _getPluginState8.resizeHandleColumnIndex,
|
|
292
|
+
resizeHandleRowIndex = _getPluginState8.resizeHandleRowIndex;
|
|
268
293
|
var isKeyboardResize = getBooleanFF('platform.editor.a11y-column-resizing_emcvz') ? getPluginState(_state4).isKeyboardResize : false;
|
|
269
294
|
var tableCell = closestElement(element, 'td, th');
|
|
270
295
|
var cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
@@ -341,8 +366,8 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
|
|
|
341
366
|
if (isTableSelected) {
|
|
342
367
|
tr = removeTable(tr);
|
|
343
368
|
} else if (tr.selection.isRowSelection()) {
|
|
344
|
-
var
|
|
345
|
-
isHeaderRowRequired =
|
|
369
|
+
var _getPluginState9 = getPluginState(newState),
|
|
370
|
+
isHeaderRowRequired = _getPluginState9.pluginConfig.isHeaderRowRequired;
|
|
346
371
|
tr = deleteRows(rect, isHeaderRowRequired)(tr);
|
|
347
372
|
} else if (tr.selection.isColSelection()) {
|
|
348
373
|
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView)(tr);
|
|
@@ -354,8 +379,8 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
|
|
|
354
379
|
return tr;
|
|
355
380
|
};
|
|
356
381
|
export var isTableInFocus = function isTableInFocus(view) {
|
|
357
|
-
var
|
|
358
|
-
return !!((
|
|
382
|
+
var _getPluginState10, _getResizePluginState;
|
|
383
|
+
return !!((_getPluginState10 = getPluginState(view.state)) !== null && _getPluginState10 !== void 0 && _getPluginState10.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
359
384
|
};
|
|
360
385
|
export var whenTableInFocus = function whenTableInFocus(eventHandler, elementContentRects) {
|
|
361
386
|
return function (view, mouseEvent) {
|
|
@@ -369,9 +394,9 @@ var trackCellLocation = function trackCellLocation(view, mouseEvent) {
|
|
|
369
394
|
var _tableElement$dataset;
|
|
370
395
|
var target = mouseEvent.target;
|
|
371
396
|
var maybeTableCell = isElementInTableCell(target);
|
|
372
|
-
var
|
|
373
|
-
tableNode =
|
|
374
|
-
tableRef =
|
|
397
|
+
var _getPluginState11 = getPluginState(view.state),
|
|
398
|
+
tableNode = _getPluginState11.tableNode,
|
|
399
|
+
tableRef = _getPluginState11.tableRef;
|
|
375
400
|
var tableElement = closestElement(target, 'table');
|
|
376
401
|
|
|
377
402
|
// hover will only trigger if target localId is the same with selected localId
|
|
@@ -376,6 +376,7 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
376
376
|
snap: guidelineSnaps,
|
|
377
377
|
handlePositioning: "adjacent",
|
|
378
378
|
isHandleVisible: isTableSelected,
|
|
379
|
+
needExtendedResizeZone: !isTableSelected,
|
|
379
380
|
appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
|
|
380
381
|
handleHighlight: "shadow",
|
|
381
382
|
handleTooltipContent: getBooleanFF('platform.editor.a11y-table-resizing_uapcv') ? function (_ref3) {
|
|
@@ -10,14 +10,12 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
10
10
|
import debounce from 'lodash/debounce';
|
|
11
11
|
import throttle from 'lodash/throttle';
|
|
12
12
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
13
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
14
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
13
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
16
14
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
17
15
|
import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
|
|
18
16
|
import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
|
|
19
17
|
import { TableCssClassName as ClassName, TableCssClassName } from '../types';
|
|
20
|
-
import {
|
|
18
|
+
import { stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
|
|
21
19
|
import { getTop, getTree } from '../utils/dom';
|
|
22
20
|
import { supportedHeaderRow } from '../utils/nodes';
|
|
23
21
|
import TableNodeView from './TableNodeViewBase';
|
|
@@ -273,88 +271,32 @@ var TableRow = /*#__PURE__*/function (_ref) {
|
|
|
273
271
|
key: "createIntersectionObserver",
|
|
274
272
|
value: function createIntersectionObserver() {
|
|
275
273
|
var _this4 = this;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
_this4.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
297
|
-
});
|
|
298
|
-
_this4.refreshStickyState();
|
|
299
|
-
}, {
|
|
300
|
-
threshold: 0,
|
|
301
|
-
root: this.editorScrollableElement
|
|
302
|
-
});
|
|
303
|
-
} else {
|
|
304
|
-
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
305
|
-
var tree = getTree(_this4.dom);
|
|
306
|
-
if (!tree) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
var table = tree.table;
|
|
310
|
-
if (table.rows.length < 2) {
|
|
311
|
-
// ED-19307 - When there's only one row in a table the top & bottom sentinels become inverted. This creates some nasty visiblity
|
|
312
|
-
// toggling side-effects because the intersection observers gets confused.
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
entries.forEach(function (entry) {
|
|
316
|
-
var _entry$rootBounds;
|
|
317
|
-
var target = entry.target;
|
|
318
|
-
|
|
319
|
-
// if the rootBounds has 0 height, e.g. confluence preview mode, we do nothing.
|
|
320
|
-
if (((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.height) === 0) {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP)) {
|
|
324
|
-
var _entry$rootBounds2;
|
|
325
|
-
var sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
|
|
326
|
-
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
327
|
-
var _entry$rootBounds3;
|
|
328
|
-
tree && _this4.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
|
|
329
|
-
_this4.lastStickyTimestamp = Date.now();
|
|
330
|
-
} else {
|
|
331
|
-
table && _this4.makeRowHeaderNotSticky(table);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
|
|
335
|
-
var _entry$rootBounds4;
|
|
336
|
-
var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this4.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
|
|
337
|
-
if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
338
|
-
// Not a perfect solution, but need to this code specific for FireFox ED-19177
|
|
339
|
-
if (browser.gecko) {
|
|
340
|
-
if (_this4.lastStickyTimestamp && Date.now() - _this4.lastStickyTimestamp > STICKY_HEADER_TOGGLE_TOLERANCE_MS) {
|
|
341
|
-
_this4.makeRowHeaderNotSticky(table);
|
|
342
|
-
}
|
|
343
|
-
} else {
|
|
344
|
-
_this4.makeRowHeaderNotSticky(table);
|
|
345
|
-
}
|
|
346
|
-
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
347
|
-
var _entry$rootBounds5;
|
|
348
|
-
tree && _this4.makeHeaderRowSticky(tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
|
|
349
|
-
_this4.lastStickyTimestamp = Date.now();
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
return;
|
|
353
|
-
});
|
|
354
|
-
}, {
|
|
355
|
-
root: this.editorScrollableElement
|
|
274
|
+
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
275
|
+
var _this4$editorScrollab, _this4$editorScrollab2;
|
|
276
|
+
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
277
|
+
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
278
|
+
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
279
|
+
var rootBounds = (_this4$editorScrollab = _this4.editorScrollableElement) === null || _this4$editorScrollab === void 0 || (_this4$editorScrollab2 = _this4$editorScrollab.getBoundingClientRect) === null || _this4$editorScrollab2 === void 0 ? void 0 : _this4$editorScrollab2.call(_this4$editorScrollab);
|
|
280
|
+
entries.forEach(function (entry) {
|
|
281
|
+
var target = entry.target,
|
|
282
|
+
isIntersecting = entry.isIntersecting,
|
|
283
|
+
boundingClientRect = entry.boundingClientRect;
|
|
284
|
+
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
285
|
+
var targetKey = target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
286
|
+
// Cache the latest sentinel information
|
|
287
|
+
_this4.sentinelData[targetKey] = {
|
|
288
|
+
isIntersecting: isIntersecting,
|
|
289
|
+
boundingClientRect: boundingClientRect,
|
|
290
|
+
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
291
|
+
};
|
|
292
|
+
// Keep the other sentinels rootBounds in sync with this latest one
|
|
293
|
+
_this4.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
356
294
|
});
|
|
357
|
-
|
|
295
|
+
_this4.refreshStickyState();
|
|
296
|
+
}, {
|
|
297
|
+
threshold: 0,
|
|
298
|
+
root: this.editorScrollableElement
|
|
299
|
+
});
|
|
358
300
|
}
|
|
359
301
|
}, {
|
|
360
302
|
key: "refreshStickyState",
|
|
@@ -13,7 +13,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
13
13
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
14
14
|
import { stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
15
15
|
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
16
|
-
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
|
|
16
|
+
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleMouseUp, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
|
|
17
17
|
import { createTableView } from '../nodeviews/table';
|
|
18
18
|
import TableCell from '../nodeviews/TableCell';
|
|
19
19
|
import TableRow from '../nodeviews/TableRow';
|
|
@@ -273,6 +273,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
273
273
|
mouseout: whenTableInFocus(handleMouseOut),
|
|
274
274
|
mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
|
|
275
275
|
mouseenter: handleMouseEnter,
|
|
276
|
+
mouseup: whenTableInFocus(handleMouseUp),
|
|
276
277
|
click: withCellTracking(whenTableInFocus(handleClick))
|
|
277
278
|
},
|
|
278
279
|
handleTripleClick: handleTripleClick
|
|
@@ -68,12 +68,15 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
68
68
|
if (tr.selection instanceof CellSelection && (tr.selection.isColSelection() || tr.selection.isRowSelection())) {
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
|
-
var
|
|
72
|
-
if (!
|
|
71
|
+
var tablePos = findTable(tr.selection);
|
|
72
|
+
if (!tablePos) {
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
|
|
76
|
+
// the tableNode props is not always latest (when you type some text in a cell, it's not updated yet)
|
|
77
|
+
// we need to get the latest one by calling findTable(tr.selection)
|
|
78
|
+
var cellPosition = this.getCellPosition(type, tablePos === null || tablePos === void 0 ? void 0 : tablePos.node);
|
|
79
|
+
if (!cellPosition) {
|
|
77
80
|
return null;
|
|
78
81
|
}
|
|
79
82
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
@@ -140,9 +143,8 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
140
143
|
}
|
|
141
144
|
}, {
|
|
142
145
|
key: "getCellPosition",
|
|
143
|
-
value: function getCellPosition(type) {
|
|
146
|
+
value: function getCellPosition(type, tableNode) {
|
|
144
147
|
var _this$props2 = this.props,
|
|
145
|
-
tableNode = _this$props2.tableNode,
|
|
146
148
|
insertColumnButtonIndex = _this$props2.insertColumnButtonIndex,
|
|
147
149
|
insertRowButtonIndex = _this$props2.insertRowButtonIndex;
|
|
148
150
|
var tableMap = TableMap.get(tableNode);
|