@atlaskit/editor-plugin-table 7.5.4 → 7.5.6
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 +13 -0
- package/dist/cjs/commands/column-resize.js +3 -3
- package/dist/cjs/commands/delete.js +2 -2
- package/dist/cjs/commands/insert.js +15 -15
- package/dist/cjs/commands-with-analytics.js +7 -7
- package/dist/cjs/event-handlers.js +27 -11
- package/dist/cjs/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/cjs/nodeviews/TableCell.js +5 -30
- package/dist/cjs/nodeviews/TableComponent.js +120 -83
- package/dist/cjs/nodeviews/TableContainer.js +23 -21
- package/dist/cjs/nodeviews/TableResizer.js +13 -13
- package/dist/cjs/nodeviews/table.js +9 -9
- package/dist/cjs/plugin.js +60 -59
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/cjs/pm-plugins/keymap.js +6 -8
- package/dist/cjs/pm-plugins/main.js +7 -24
- package/dist/cjs/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +11 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/cjs/pm-plugins/table-width.js +6 -2
- package/dist/cjs/toolbar.js +21 -21
- package/dist/cjs/transforms/column-width.js +4 -4
- package/dist/cjs/transforms/delete-columns.js +2 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +6 -6
- package/dist/cjs/ui/FloatingInsertButton/index.js +6 -7
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/cjs/ui/TableFloatingControls/index.js +113 -223
- package/dist/cjs/utils/column-controls.js +5 -5
- package/dist/cjs/utils/create.js +2 -5
- package/dist/cjs/utils/dom.js +13 -15
- package/dist/cjs/utils/drag-menu.js +4 -4
- package/dist/es2019/commands/column-resize.js +3 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +12 -12
- package/dist/es2019/commands-with-analytics.js +6 -6
- package/dist/es2019/event-handlers.js +27 -11
- package/dist/es2019/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/es2019/nodeviews/TableCell.js +1 -24
- package/dist/es2019/nodeviews/TableComponent.js +88 -63
- package/dist/es2019/nodeviews/TableContainer.js +20 -22
- package/dist/es2019/nodeviews/TableResizer.js +13 -13
- package/dist/es2019/nodeviews/table.js +9 -9
- package/dist/es2019/plugin.js +19 -20
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -6
- package/dist/es2019/pm-plugins/keymap.js +5 -8
- package/dist/es2019/pm-plugins/main.js +6 -23
- package/dist/es2019/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +3 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -13
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/es2019/pm-plugins/table-width.js +6 -2
- package/dist/es2019/toolbar.js +15 -15
- package/dist/es2019/transforms/column-width.js +5 -5
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +9 -12
- package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +5 -5
- package/dist/es2019/ui/FloatingInsertButton/index.js +5 -6
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -27
- package/dist/es2019/ui/TableFloatingControls/index.js +119 -193
- package/dist/es2019/utils/column-controls.js +6 -6
- package/dist/es2019/utils/create.js +2 -5
- package/dist/es2019/utils/dom.js +13 -15
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/esm/commands/column-resize.js +3 -3
- package/dist/esm/commands/delete.js +2 -2
- package/dist/esm/commands/insert.js +15 -15
- package/dist/esm/commands-with-analytics.js +7 -7
- package/dist/esm/event-handlers.js +27 -11
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/esm/nodeviews/TableCell.js +5 -30
- package/dist/esm/nodeviews/TableComponent.js +119 -82
- package/dist/esm/nodeviews/TableContainer.js +24 -22
- package/dist/esm/nodeviews/TableResizer.js +13 -13
- package/dist/esm/nodeviews/table.js +9 -9
- package/dist/esm/plugin.js +60 -59
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/esm/pm-plugins/keymap.js +6 -8
- package/dist/esm/pm-plugins/main.js +7 -24
- package/dist/esm/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +4 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -14
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/esm/pm-plugins/table-width.js +6 -2
- package/dist/esm/toolbar.js +21 -21
- package/dist/esm/transforms/column-width.js +5 -5
- package/dist/esm/transforms/delete-columns.js +2 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/esm/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -6
- package/dist/esm/ui/FloatingInsertButton/index.js +6 -7
- package/dist/esm/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/esm/ui/TableFloatingControls/index.js +113 -224
- package/dist/esm/utils/column-controls.js +6 -6
- package/dist/esm/utils/create.js +2 -5
- package/dist/esm/utils/dom.js +13 -15
- package/dist/esm/utils/drag-menu.js +4 -4
- package/dist/types/commands/column-resize.d.ts +1 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +7 -7
- package/dist/types/commands-with-analytics.d.ts +3 -3
- package/dist/types/event-handlers.d.ts +4 -5
- package/dist/types/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types/nodeviews/TableCell.d.ts +1 -5
- package/dist/types/nodeviews/TableComponent.d.ts +6 -3
- package/dist/types/nodeviews/TableContainer.d.ts +6 -4
- package/dist/types/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types/pm-plugins/table-width.d.ts +1 -2
- package/dist/types/toolbar.d.ts +2 -2
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/transforms/delete-columns.d.ts +1 -1
- package/dist/types/types.d.ts +1 -3
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types/utils/create.d.ts +1 -2
- package/dist/types/utils/dom.d.ts +10 -2
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +7 -7
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
- package/dist/types-ts4.5/event-handlers.d.ts +4 -5
- package/dist/types-ts4.5/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/TableCell.d.ts +1 -5
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +6 -3
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +6 -4
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -2
- package/dist/types-ts4.5/toolbar.d.ts +2 -2
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -3
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types-ts4.5/utils/create.d.ts +1 -2
- package/dist/types-ts4.5/utils/dom.d.ts +10 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +3 -4
- package/src/commands/column-resize.ts +4 -3
- package/src/commands/delete.ts +2 -2
- package/src/commands/insert.ts +15 -27
- package/src/commands-with-analytics.ts +6 -9
- package/src/event-handlers.ts +107 -105
- package/src/nodeviews/OverflowShadowsObserver.ts +32 -21
- package/src/nodeviews/TableCell.ts +0 -26
- package/src/nodeviews/TableComponent.tsx +107 -78
- package/src/nodeviews/TableContainer.tsx +26 -32
- package/src/nodeviews/TableResizer.tsx +15 -18
- package/src/nodeviews/table.tsx +6 -5
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +17 -32
- package/src/pm-plugins/drag-and-drop/plugin.ts +10 -15
- package/src/pm-plugins/keymap.ts +6 -13
- package/src/pm-plugins/main.ts +6 -25
- package/src/pm-plugins/sticky-headers/plugin.ts +2 -11
- package/src/pm-plugins/table-resizing/event-handlers.ts +6 -4
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +5 -2
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -13
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +14 -14
- package/src/pm-plugins/table-width.ts +4 -6
- package/src/toolbar.tsx +16 -19
- package/src/transforms/column-width.ts +7 -6
- package/src/transforms/delete-columns.ts +2 -2
- package/src/types.ts +1 -4
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -16
- package/src/ui/FloatingContextualMenu/index.tsx +0 -2
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -3
- package/src/ui/FloatingDragMenu/index.tsx +4 -8
- package/src/ui/FloatingInsertButton/index.tsx +11 -22
- package/src/ui/TableFloatingColumnControls/index.tsx +5 -29
- package/src/ui/TableFloatingControls/index.tsx +155 -241
- package/src/utils/column-controls.ts +5 -6
- package/src/utils/create.ts +2 -5
- package/src/utils/dom.ts +12 -19
- package/src/utils/drag-menu.ts +7 -12
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import rafSchedule from 'raf-schd';
|
|
2
3
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { browser, closestElement, isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -248,7 +249,10 @@ export var handleMouseLeave = function handleMouseLeave(view, event) {
|
|
|
248
249
|
}
|
|
249
250
|
return false;
|
|
250
251
|
};
|
|
251
|
-
|
|
252
|
+
|
|
253
|
+
// IMPORTANT: The mouse move handler has been setup with RAF schedule to avoid Reflows which will occur as some methods
|
|
254
|
+
// need to access the mouse event offset position and also the target clientWidth vallue.
|
|
255
|
+
var handleMouseMoveDebounce = rafSchedule(function (view, event, offsetX) {
|
|
252
256
|
if (!(event.target instanceof HTMLElement)) {
|
|
253
257
|
return false;
|
|
254
258
|
}
|
|
@@ -257,13 +261,12 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
257
261
|
var state = view.state,
|
|
258
262
|
dispatch = view.dispatch;
|
|
259
263
|
var _getPluginState6 = getPluginState(state),
|
|
260
|
-
insertColumnButtonIndex = _getPluginState6.insertColumnButtonIndex
|
|
261
|
-
isDragAndDropEnabled = _getPluginState6.isDragAndDropEnabled;
|
|
264
|
+
insertColumnButtonIndex = _getPluginState6.insertColumnButtonIndex;
|
|
262
265
|
var _getColumnOrRowIndex9 = getColumnOrRowIndex(element),
|
|
263
266
|
_getColumnOrRowIndex10 = _slicedToArray(_getColumnOrRowIndex9, 2),
|
|
264
267
|
startIndex = _getColumnOrRowIndex10[0],
|
|
265
268
|
endIndex = _getColumnOrRowIndex10[1];
|
|
266
|
-
var positionColumn = getMousePositionHorizontalRelativeByElement(event,
|
|
269
|
+
var positionColumn = getMousePositionHorizontalRelativeByElement(event, offsetX, undefined) === 'right' ? endIndex : startIndex;
|
|
267
270
|
if (positionColumn !== insertColumnButtonIndex) {
|
|
268
271
|
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
269
272
|
}
|
|
@@ -283,7 +286,7 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
283
286
|
}
|
|
284
287
|
}
|
|
285
288
|
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
286
|
-
var _positionColumn = getMousePositionHorizontalRelativeByElement(event,
|
|
289
|
+
var _positionColumn = getMousePositionHorizontalRelativeByElement(event, offsetX, RESIZE_HANDLE_AREA_DECORATION_GAP);
|
|
287
290
|
if (_positionColumn !== null) {
|
|
288
291
|
var _state4 = view.state,
|
|
289
292
|
_dispatch5 = view.dispatch;
|
|
@@ -308,6 +311,19 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
308
311
|
}
|
|
309
312
|
}
|
|
310
313
|
return false;
|
|
314
|
+
});
|
|
315
|
+
export var handleMouseMove = function handleMouseMove(view, event) {
|
|
316
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// NOTE: When accessing offsetX in gecko from a deferred callback, it will return 0. However it will be non-zero if accessed
|
|
321
|
+
// within the scope of it's initial mouse move handler. Also Chrome does return the correct value, however it could trigger
|
|
322
|
+
// a reflow. So for now this will just grab the offsetX value immediately for gecko and chrome will calculate later
|
|
323
|
+
// in the deferred callback handler.
|
|
324
|
+
// Bug Tracking: https://bugzilla.mozilla.org/show_bug.cgi?id=1882903
|
|
325
|
+
handleMouseMoveDebounce(view, event, browser.gecko ? event.offsetX : NaN);
|
|
326
|
+
return false;
|
|
311
327
|
};
|
|
312
328
|
export function handleTripleClick(view, pos) {
|
|
313
329
|
var state = view.state,
|
|
@@ -328,7 +344,7 @@ export function handleTripleClick(view, pos) {
|
|
|
328
344
|
return false;
|
|
329
345
|
}
|
|
330
346
|
export var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI, editorView) {
|
|
331
|
-
var
|
|
347
|
+
var isTableScalingEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
332
348
|
var oldSelection = oldState.tr.selection;
|
|
333
349
|
var tr = newState.tr;
|
|
334
350
|
if (oldSelection instanceof CellSelection) {
|
|
@@ -371,7 +387,7 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
|
|
|
371
387
|
isHeaderRowRequired = _getPluginState9.pluginConfig.isHeaderRowRequired;
|
|
372
388
|
tr = deleteRows(rect, isHeaderRowRequired)(tr);
|
|
373
389
|
} else if (tr.selection.isColSelection()) {
|
|
374
|
-
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView,
|
|
390
|
+
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView, isTableScalingEnabled)(tr);
|
|
375
391
|
}
|
|
376
392
|
}
|
|
377
393
|
}
|
|
@@ -383,12 +399,12 @@ export var isTableInFocus = function isTableInFocus(view) {
|
|
|
383
399
|
var _getPluginState10, _getResizePluginState;
|
|
384
400
|
return !!((_getPluginState10 = getPluginState(view.state)) !== null && _getPluginState10 !== void 0 && _getPluginState10.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
385
401
|
};
|
|
386
|
-
export var whenTableInFocus = function whenTableInFocus(eventHandler
|
|
402
|
+
export var whenTableInFocus = function whenTableInFocus(eventHandler) {
|
|
387
403
|
return function (view, mouseEvent) {
|
|
388
404
|
if (!isTableInFocus(view)) {
|
|
389
405
|
return false;
|
|
390
406
|
}
|
|
391
|
-
return eventHandler(view, mouseEvent
|
|
407
|
+
return eventHandler(view, mouseEvent);
|
|
392
408
|
};
|
|
393
409
|
};
|
|
394
410
|
var trackCellLocation = function trackCellLocation(view, mouseEvent) {
|
|
@@ -418,11 +434,11 @@ var trackCellLocation = function trackCellLocation(view, mouseEvent) {
|
|
|
418
434
|
}
|
|
419
435
|
hoverCell(htmlRowIndex, colIndex)(view.state, view.dispatch);
|
|
420
436
|
};
|
|
421
|
-
export var withCellTracking = function withCellTracking(eventHandler
|
|
437
|
+
export var withCellTracking = function withCellTracking(eventHandler) {
|
|
422
438
|
return function (view, mouseEvent) {
|
|
423
439
|
if (getPluginState(view.state).isDragAndDropEnabled && !getDragDropPluginState(view.state).isDragging) {
|
|
424
440
|
trackCellLocation(view, mouseEvent);
|
|
425
441
|
}
|
|
426
|
-
return eventHandler(view, mouseEvent
|
|
442
|
+
return eventHandler(view, mouseEvent);
|
|
427
443
|
};
|
|
428
444
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import rafSchedule from 'raf-schd';
|
|
4
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
6
7
|
import { tableInsertColumnButtonSize } from '../ui/consts';
|
|
@@ -42,8 +43,13 @@ export var OverflowShadowsObserver = /*#__PURE__*/function () {
|
|
|
42
43
|
});
|
|
43
44
|
_defineProperty(this, "observeShadowSentinels", function (isSticky) {
|
|
44
45
|
var _this$table, _this$table2;
|
|
46
|
+
if (_this.isSticky === isSticky) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
45
49
|
_this.isSticky = !!isSticky;
|
|
46
50
|
|
|
51
|
+
// reset height
|
|
52
|
+
_this.stickyRowHeight = 0;
|
|
47
53
|
// update sticky shadows
|
|
48
54
|
_this.updateStickyShadowsHeightIfChanged();
|
|
49
55
|
_this.leftShadowSentinel = (_this$table = _this.table) === null || _this$table === void 0 ? void 0 : _this$table.querySelector(".".concat(ClassName.TABLE_SHADOW_SENTINEL_LEFT));
|
|
@@ -60,8 +66,8 @@ export var OverflowShadowsObserver = /*#__PURE__*/function () {
|
|
|
60
66
|
* e.g. bounds on an IntersectionObserverEntry, otherwise proceed with
|
|
61
67
|
* reading it from sticky cell
|
|
62
68
|
*/
|
|
63
|
-
_defineProperty(this, "updateStickyShadows", function (stickyRowHeight) {
|
|
64
|
-
var _this$wrapper
|
|
69
|
+
_defineProperty(this, "updateStickyShadows", rafSchedule(function (stickyRowHeight) {
|
|
70
|
+
var _this$wrapper;
|
|
65
71
|
if (!_this.isSticky) {
|
|
66
72
|
return;
|
|
67
73
|
}
|
|
@@ -69,14 +75,21 @@ export var OverflowShadowsObserver = /*#__PURE__*/function () {
|
|
|
69
75
|
if (!stickyCell || !((_this$wrapper = _this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement)) {
|
|
70
76
|
return;
|
|
71
77
|
}
|
|
72
|
-
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
|
|
79
|
+
// Reflow Warning! - stickyCell.clientHeight
|
|
80
|
+
var newStickyRowHeight = stickyRowHeight || stickyCell.clientHeight + 1;
|
|
81
|
+
if (newStickyRowHeight !== _this.stickyRowHeight) {
|
|
82
|
+
var _this$wrapper2, _this$wrapper3;
|
|
83
|
+
_this.stickyRowHeight = newStickyRowHeight;
|
|
84
|
+
var heightStyleOrCompute = "".concat(newStickyRowHeight, "px");
|
|
85
|
+
// Use getElementsByClassName here for a live node list to capture
|
|
86
|
+
// sticky shadows
|
|
87
|
+
var liveRightShadows = (_this$wrapper2 = _this.wrapper) === null || _this$wrapper2 === void 0 || (_this$wrapper2 = _this$wrapper2.parentElement) === null || _this$wrapper2 === void 0 ? void 0 : _this$wrapper2.getElementsByClassName("".concat(ClassName.TABLE_RIGHT_SHADOW));
|
|
88
|
+
var liveLeftShadows = (_this$wrapper3 = _this.wrapper) === null || _this$wrapper3 === void 0 || (_this$wrapper3 = _this$wrapper3.parentElement) === null || _this$wrapper3 === void 0 ? void 0 : _this$wrapper3.getElementsByClassName("".concat(ClassName.TABLE_LEFT_SHADOW));
|
|
89
|
+
updateShadowListForStickyStyles(heightStyleOrCompute, liveLeftShadows);
|
|
90
|
+
updateShadowListForStickyStyles(heightStyleOrCompute, liveRightShadows);
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
80
93
|
this.updateShadowState = updateShadowState;
|
|
81
94
|
this.table = _table;
|
|
82
95
|
this.wrapper = wrapper;
|
|
@@ -92,11 +105,7 @@ export var OverflowShadowsObserver = /*#__PURE__*/function () {
|
|
|
92
105
|
if (!stickyCell) {
|
|
93
106
|
return;
|
|
94
107
|
}
|
|
95
|
-
|
|
96
|
-
if (newStickyRowHeight === this.stickyRowHeight) {
|
|
97
|
-
this.stickyRowHeight = newStickyRowHeight;
|
|
98
|
-
this.updateStickyShadows(this.stickyRowHeight);
|
|
99
|
-
}
|
|
108
|
+
this.updateStickyShadows();
|
|
100
109
|
}
|
|
101
110
|
}, {
|
|
102
111
|
key: "getStickyCell",
|
|
@@ -6,35 +6,17 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
8
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
-
import uuid from 'uuid';
|
|
10
9
|
import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
|
|
11
|
-
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
12
10
|
import TableNodeView from './TableNodeViewBase';
|
|
13
11
|
var DEFAULT_COL_SPAN = 1;
|
|
14
12
|
var DEFAULT_ROW_SPAN = 1;
|
|
15
13
|
var TableCell = /*#__PURE__*/function (_ref) {
|
|
16
14
|
_inherits(TableCell, _ref);
|
|
17
15
|
var _super = _createSuper(TableCell);
|
|
18
|
-
function TableCell(node, view, getPos, eventDispatcher
|
|
19
|
-
var _this;
|
|
16
|
+
function TableCell(node, view, getPos, eventDispatcher) {
|
|
20
17
|
_classCallCheck(this, TableCell);
|
|
21
|
-
|
|
22
|
-
_this.observer = observer;
|
|
23
|
-
var _getPluginState = getPluginState(view.state),
|
|
24
|
-
pluginConfig = _getPluginState.pluginConfig,
|
|
25
|
-
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
26
|
-
_this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
27
|
-
_this.isDragAndDropEnabled = !!isDragAndDropEnabled;
|
|
28
|
-
if (observer) {
|
|
29
|
-
_this.contentDOM.id = uuid();
|
|
30
|
-
observer.observe(_this.contentDOM);
|
|
31
|
-
}
|
|
32
|
-
return _this;
|
|
18
|
+
return _super.call(this, node, view, getPos, eventDispatcher);
|
|
33
19
|
}
|
|
34
|
-
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
|
|
37
|
-
// @ts-ignore
|
|
38
20
|
_createClass(TableCell, [{
|
|
39
21
|
key: "update",
|
|
40
22
|
value: function update(node) {
|
|
@@ -44,17 +26,10 @@ var TableCell = /*#__PURE__*/function (_ref) {
|
|
|
44
26
|
}
|
|
45
27
|
return didUpdate;
|
|
46
28
|
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "destroy",
|
|
49
|
-
value: function destroy() {
|
|
50
|
-
if (this.observer) {
|
|
51
|
-
this.observer.unobserve(this.contentDOM);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
29
|
}, {
|
|
55
30
|
key: "updateNodeView",
|
|
56
31
|
value: function updateNodeView(node) {
|
|
57
|
-
var
|
|
32
|
+
var _this = this;
|
|
58
33
|
if (this.node.type !== node.type) {
|
|
59
34
|
return false;
|
|
60
35
|
}
|
|
@@ -85,10 +60,10 @@ var TableCell = /*#__PURE__*/function (_ref) {
|
|
|
85
60
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
86
61
|
key = _ref5[0],
|
|
87
62
|
value = _ref5[1];
|
|
88
|
-
return
|
|
63
|
+
return _this.dom.setAttribute(key, value || '');
|
|
89
64
|
});
|
|
90
65
|
removedAttrs.forEach(function (key) {
|
|
91
|
-
return
|
|
66
|
+
return _this.dom.removeAttribute(key);
|
|
92
67
|
});
|
|
93
68
|
return true;
|
|
94
69
|
}
|