@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
|
@@ -6,6 +6,9 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
9
12
|
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; }
|
|
10
13
|
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; }
|
|
11
14
|
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); }; }
|
|
@@ -17,7 +20,7 @@ import rafSchedule from 'raf-schd';
|
|
|
17
20
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
18
21
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
19
22
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
20
|
-
import { browser,
|
|
23
|
+
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
21
24
|
import { MAX_BROWSER_SCROLLBAR_HEIGHT, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
22
25
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
23
26
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
@@ -29,6 +32,7 @@ import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '.
|
|
|
29
32
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
30
33
|
import { COLUMN_MIN_WIDTH, getLayoutSize, getResizeState, insertColgroupFromNode, scaleTable, updateColgroup } from '../pm-plugins/table-resizing/utils';
|
|
31
34
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
35
|
+
import { TABLE_EDITOR_MARGIN } from '../pm-plugins/table-resizing/utils/consts';
|
|
32
36
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
33
37
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
34
38
|
import { tableOverflowShadowWidth, tableOverflowShadowWidthWide } from '../ui/consts';
|
|
@@ -44,6 +48,12 @@ var isIE11 = browser.ie_version === 11;
|
|
|
44
48
|
// componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
|
|
45
49
|
// To make sure we capture the last update, we use setTimeout.
|
|
46
50
|
var initialOverflowCaptureTimeroutDelay = 300;
|
|
51
|
+
|
|
52
|
+
// This is a hard switch for controlling whether the overflow analytics should be dispatched. There has been 6months of data
|
|
53
|
+
// already collected which we could use but have not. This has been disabled rather then removed entirely in the event that
|
|
54
|
+
// the current collected data becomes stale and we want to start collecting fresh data again in future.
|
|
55
|
+
// PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
|
|
56
|
+
var isOverflowAnalyticsEnabled = false;
|
|
47
57
|
var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
48
58
|
_inherits(TableComponent, _React$Component);
|
|
49
59
|
var _super = _createSuper(TableComponent);
|
|
@@ -55,7 +65,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
55
65
|
_defineProperty(_assertThisInitialized(_this), "state", (_defineProperty2 = {
|
|
56
66
|
scroll: 0,
|
|
57
67
|
parentWidth: undefined
|
|
58
|
-
}, _defineProperty(_defineProperty2, ShadowEvent.SHOW_BEFORE_SHADOW, false), _defineProperty(_defineProperty2, ShadowEvent.SHOW_AFTER_SHADOW, false), _defineProperty2));
|
|
68
|
+
}, _defineProperty(_defineProperty2, ShadowEvent.SHOW_BEFORE_SHADOW, false), _defineProperty(_defineProperty2, ShadowEvent.SHOW_AFTER_SHADOW, false), _defineProperty(_defineProperty2, "tableWrapperWidth", undefined), _defineProperty(_defineProperty2, "tableWrapperHeight", undefined), _defineProperty2));
|
|
59
69
|
_defineProperty(_assertThisInitialized(_this), "updateShadowState", function (shadowKey, value) {
|
|
60
70
|
if (_this.state[shadowKey] === value) {
|
|
61
71
|
return;
|
|
@@ -169,7 +179,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
169
179
|
getPos = _this$props2.getPos,
|
|
170
180
|
containerWidth = _this$props2.containerWidth,
|
|
171
181
|
options = _this$props2.options,
|
|
172
|
-
|
|
182
|
+
isTableScalingEnabled = _this$props2.isTableScalingEnabled;
|
|
173
183
|
var node = getNode();
|
|
174
184
|
var state = view.state,
|
|
175
185
|
dispatch = view.dispatch;
|
|
@@ -180,16 +190,13 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
180
190
|
var domAtPos = view.domAtPos.bind(view);
|
|
181
191
|
var width = containerWidth.width;
|
|
182
192
|
_this.scaleTableDebounced.cancel();
|
|
183
|
-
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
184
|
-
_getEditorFeatureFlag2 = _getEditorFeatureFlag.tablePreserveWidth,
|
|
185
|
-
tablePreserveWidth = _getEditorFeatureFlag2 === void 0 ? false : _getEditorFeatureFlag2;
|
|
186
193
|
var tr = scaleTable(_this.table, _objectSpread(_objectSpread({}, scaleOptions), {}, {
|
|
187
194
|
node: node,
|
|
188
195
|
prevNode: _this.node || node,
|
|
189
196
|
start: pos + 1,
|
|
190
197
|
containerWidth: width,
|
|
191
198
|
previousContainerWidth: _this.containerWidth.width || width
|
|
192
|
-
}, options), domAtPos,
|
|
199
|
+
}, options), domAtPos, isTableScalingEnabled)(state.tr);
|
|
193
200
|
dispatch(tr);
|
|
194
201
|
});
|
|
195
202
|
_defineProperty(_assertThisInitialized(_this), "setTimerToSendInitialOverflowCaptured", function (isOverflowing) {
|
|
@@ -290,6 +297,29 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
290
297
|
_this.layoutSize = _this.tableNodeLayoutSize(_this.node, _containerWidth.width, {
|
|
291
298
|
isFullWidthModeEnabled: isFullWidthModeEnabled
|
|
292
299
|
});
|
|
300
|
+
_this.resizeObserver = new ResizeObserver(function (entries) {
|
|
301
|
+
var _iterator = _createForOfIteratorHelper(entries),
|
|
302
|
+
_step;
|
|
303
|
+
try {
|
|
304
|
+
var _loop = function _loop() {
|
|
305
|
+
var entry = _step.value;
|
|
306
|
+
_this.setState(function (prev) {
|
|
307
|
+
var _entry$contentRect, _entry$contentRect2;
|
|
308
|
+
return (prev === null || prev === void 0 ? void 0 : prev.tableWrapperWidth) === ((_entry$contentRect = entry.contentRect) === null || _entry$contentRect === void 0 ? void 0 : _entry$contentRect.width) && (prev === null || prev === void 0 ? void 0 : prev.tableWrapperHeight) === ((_entry$contentRect2 = entry.contentRect) === null || _entry$contentRect2 === void 0 ? void 0 : _entry$contentRect2.height) ? prev : _objectSpread(_objectSpread({}, prev), {}, {
|
|
309
|
+
tableWrapperWidth: entry.contentRect.width,
|
|
310
|
+
tableWrapperHeight: entry.contentRect.height
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
315
|
+
_loop();
|
|
316
|
+
}
|
|
317
|
+
} catch (err) {
|
|
318
|
+
_iterator.e(err);
|
|
319
|
+
} finally {
|
|
320
|
+
_iterator.f();
|
|
321
|
+
}
|
|
322
|
+
});
|
|
293
323
|
|
|
294
324
|
// Disable inline table editing and resizing controls in Firefox
|
|
295
325
|
// https://github.com/ProseMirror/prosemirror/issues/432
|
|
@@ -311,13 +341,17 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
311
341
|
options = _this$props7.options,
|
|
312
342
|
isDragAndDropEnabled = _this$props7.isDragAndDropEnabled,
|
|
313
343
|
getNode = _this$props7.getNode,
|
|
314
|
-
getEditorFeatureFlags = _this$props7.getEditorFeatureFlags
|
|
344
|
+
getEditorFeatureFlags = _this$props7.getEditorFeatureFlags,
|
|
345
|
+
isTableScalingEnabled = _this$props7.isTableScalingEnabled;
|
|
346
|
+
if (isTableScalingEnabled) {
|
|
347
|
+
this.handleColgroupUpdates(true);
|
|
348
|
+
}
|
|
315
349
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
316
350
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
317
351
|
passive: true
|
|
318
352
|
});
|
|
319
|
-
var
|
|
320
|
-
stickyScrollbar =
|
|
353
|
+
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
354
|
+
stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
|
|
321
355
|
if (stickyScrollbar) {
|
|
322
356
|
if (this.table) {
|
|
323
357
|
this.stickyScrollbar = new TableStickyScrollbar(this.wrapper, this.props.view);
|
|
@@ -345,12 +379,15 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
345
379
|
this.onStickyState(currentStickyState);
|
|
346
380
|
}
|
|
347
381
|
eventDispatcher.on(stickyHeadersPluginKey.key, this.onStickyState);
|
|
348
|
-
|
|
349
|
-
|
|
382
|
+
if (isOverflowAnalyticsEnabled) {
|
|
383
|
+
var initialIsOveflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
384
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
385
|
+
}
|
|
350
386
|
}
|
|
351
387
|
}, {
|
|
352
388
|
key: "componentWillUnmount",
|
|
353
389
|
value: function componentWillUnmount() {
|
|
390
|
+
var _this$resizeObserver;
|
|
354
391
|
var _this$props8 = this.props,
|
|
355
392
|
allowColumnResizing = _this$props8.allowColumnResizing,
|
|
356
393
|
eventDispatcher = _this$props8.eventDispatcher,
|
|
@@ -363,8 +400,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
363
400
|
if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
|
|
364
401
|
this.dragAndDropCleanupFn();
|
|
365
402
|
}
|
|
366
|
-
|
|
367
|
-
|
|
403
|
+
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 || _this$resizeObserver.disconnect();
|
|
404
|
+
var _getEditorFeatureFlag2 = getEditorFeatureFlags(),
|
|
405
|
+
stickyScrollbar = _getEditorFeatureFlag2.stickyScrollbar;
|
|
368
406
|
if (stickyScrollbar) {
|
|
369
407
|
if (this.stickyScrollbar) {
|
|
370
408
|
this.stickyScrollbar.dispose();
|
|
@@ -391,23 +429,21 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
391
429
|
}, {
|
|
392
430
|
key: "handleColgroupUpdates",
|
|
393
431
|
value: function handleColgroupUpdates() {
|
|
394
|
-
var
|
|
395
|
-
|
|
432
|
+
var _this$containerWidth;
|
|
433
|
+
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
396
434
|
var _this$props9 = this.props,
|
|
397
435
|
getNode = _this$props9.getNode,
|
|
398
436
|
containerWidth = _this$props9.containerWidth,
|
|
399
437
|
isResizing = _this$props9.isResizing,
|
|
400
438
|
view = _this$props9.view,
|
|
401
|
-
getPos = _this$props9.getPos
|
|
402
|
-
|
|
403
|
-
if (!tableRef) {
|
|
439
|
+
getPos = _this$props9.getPos;
|
|
440
|
+
if (!this.table) {
|
|
404
441
|
return;
|
|
405
442
|
}
|
|
406
|
-
var TABLE_MARGIN = 76;
|
|
407
443
|
|
|
408
444
|
// Remove any widths styles after resizing preview is completed
|
|
409
|
-
|
|
410
|
-
var tableRenderWidth = containerWidth.width -
|
|
445
|
+
this.table.style.width = '';
|
|
446
|
+
var tableRenderWidth = containerWidth.width - TABLE_EDITOR_MARGIN;
|
|
411
447
|
var tableNode = getNode();
|
|
412
448
|
var start = getPos() || 0;
|
|
413
449
|
var depth = view.state.doc.resolve(start).depth;
|
|
@@ -417,17 +453,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
417
453
|
return;
|
|
418
454
|
}
|
|
419
455
|
var tableNodeWidth = tableNode.attrs.width;
|
|
420
|
-
var tableColumnWidths = calcTableColumnWidths(tableNode);
|
|
421
456
|
var shouldTableScale = tableRenderWidth < tableNodeWidth;
|
|
422
|
-
var isTableColumnWidthsSame = false;
|
|
423
|
-
if (this.tableColumnWidths) {
|
|
424
|
-
isTableColumnWidthsSame = tableColumnWidths === null || tableColumnWidths === void 0 ? void 0 : tableColumnWidths.every(function (width, index) {
|
|
425
|
-
return width === _this2.tableColumnWidths[index];
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
457
|
var containerWidthValue = containerWidth.width;
|
|
429
458
|
var isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
430
|
-
if (shouldTableScale && !isResizing &&
|
|
459
|
+
if (force || shouldTableScale && !isResizing && isWidthChanged) {
|
|
431
460
|
var resizeState = getResizeState({
|
|
432
461
|
minWidth: COLUMN_MIN_WIDTH,
|
|
433
462
|
maxSize: tableRenderWidth,
|
|
@@ -435,20 +464,17 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
435
464
|
tableRef: this.table,
|
|
436
465
|
start: start,
|
|
437
466
|
domAtPos: view.domAtPos,
|
|
438
|
-
|
|
467
|
+
isTableScalingEnabled: true
|
|
439
468
|
});
|
|
440
|
-
|
|
441
|
-
updateColgroup(resizeState, _this2.table, true);
|
|
442
|
-
});
|
|
443
|
-
this.tableColumnWidths = tableColumnWidths;
|
|
444
|
-
this.containerWidth = containerWidth;
|
|
469
|
+
updateColgroup(resizeState, this.table, tableNode, true);
|
|
445
470
|
}
|
|
471
|
+
this.containerWidth = containerWidth;
|
|
446
472
|
}
|
|
447
473
|
}, {
|
|
448
474
|
key: "componentDidUpdate",
|
|
449
475
|
value: function componentDidUpdate(_, prevState) {
|
|
450
476
|
var _this$wrapper,
|
|
451
|
-
|
|
477
|
+
_this2 = this;
|
|
452
478
|
var _this$props10 = this.props,
|
|
453
479
|
view = _this$props10.view,
|
|
454
480
|
getNode = _this$props10.getNode,
|
|
@@ -456,14 +482,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
456
482
|
allowColumnResizing = _this$props10.allowColumnResizing,
|
|
457
483
|
isResizing = _this$props10.isResizing,
|
|
458
484
|
options = _this$props10.options,
|
|
459
|
-
|
|
485
|
+
isTableScalingEnabled = _this$props10.isTableScalingEnabled;
|
|
460
486
|
var _getPluginState = getPluginState(view.state),
|
|
461
487
|
isInDanger = _getPluginState.isInDanger;
|
|
462
|
-
var _getEditorFeatureFlag5 = getEditorFeatureFlags(),
|
|
463
|
-
_getEditorFeatureFlag6 = _getEditorFeatureFlag5.tablePreserveWidth,
|
|
464
|
-
tablePreserveWidth = _getEditorFeatureFlag6 === void 0 ? false : _getEditorFeatureFlag6;
|
|
465
488
|
var table = findTable(view.state.selection);
|
|
466
|
-
if (
|
|
489
|
+
if (isTableScalingEnabled) {
|
|
467
490
|
this.handleColgroupUpdates();
|
|
468
491
|
}
|
|
469
492
|
if (isInDanger && !table) {
|
|
@@ -475,7 +498,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
475
498
|
// that happens when a table is nested in expand and expand's width is
|
|
476
499
|
// changed via breakout button
|
|
477
500
|
window.requestAnimationFrame(function () {
|
|
478
|
-
|
|
501
|
+
_this2.overflowShadowsObserver = new OverflowShadowsObserver(_this2.updateShadowState, _this2.table, _this2.wrapper);
|
|
479
502
|
});
|
|
480
503
|
} else {
|
|
481
504
|
this.overflowShadowsObserver = new OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
|
|
@@ -500,38 +523,48 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
500
523
|
var _view = this.props.view;
|
|
501
524
|
var shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || tablesHaveDifferentNoOfColumns(currentTable, previousTable) && isResizing;
|
|
502
525
|
if (shouldRecreateResizeCols) {
|
|
503
|
-
insertColgroupFromNode(this.table, currentTable,
|
|
526
|
+
insertColgroupFromNode(this.table, currentTable, isTableScalingEnabled);
|
|
504
527
|
}
|
|
505
528
|
updateControls()(_view.state);
|
|
506
529
|
}
|
|
507
530
|
this.handleTableResizingDebounced();
|
|
508
531
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
532
|
+
if (isOverflowAnalyticsEnabled) {
|
|
533
|
+
var newIsOverflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
534
|
+
var prevIsOverflowing = prevState[ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
535
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
536
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
537
|
+
}
|
|
538
|
+
if (!this.isInitialOverflowSent) {
|
|
539
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
540
|
+
}
|
|
541
|
+
if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
|
|
542
|
+
var _this$state2;
|
|
543
|
+
var _this$props$view = this.props.view,
|
|
544
|
+
dispatch = _this$props$view.dispatch,
|
|
545
|
+
tr = _this$props$view.state.tr;
|
|
546
|
+
dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
547
|
+
isOverflowing: newIsOverflowing,
|
|
548
|
+
wasOverflowing: prevIsOverflowing,
|
|
549
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
550
|
+
width: this.node.attrs.width || 0,
|
|
551
|
+
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
552
|
+
}));
|
|
553
|
+
}
|
|
513
554
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
var _this$
|
|
520
|
-
|
|
521
|
-
tr = _this$props$view.state.tr;
|
|
522
|
-
dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
523
|
-
isOverflowing: newIsOverflowing,
|
|
524
|
-
wasOverflowing: prevIsOverflowing,
|
|
525
|
-
editorWidth: this.props.containerWidth.width || 0,
|
|
526
|
-
width: this.node.attrs.width || 0,
|
|
527
|
-
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
528
|
-
}));
|
|
555
|
+
}
|
|
556
|
+
}, {
|
|
557
|
+
key: "observeTable",
|
|
558
|
+
value: function observeTable(table) {
|
|
559
|
+
if (table) {
|
|
560
|
+
var _this$resizeObserver2;
|
|
561
|
+
(_this$resizeObserver2 = this.resizeObserver) === null || _this$resizeObserver2 === void 0 || _this$resizeObserver2.observe(table);
|
|
529
562
|
}
|
|
530
563
|
}
|
|
531
564
|
}, {
|
|
532
565
|
key: "render",
|
|
533
566
|
value: function render() {
|
|
534
|
-
var
|
|
567
|
+
var _this3 = this,
|
|
535
568
|
_classnames;
|
|
536
569
|
var _this$props11 = this.props,
|
|
537
570
|
view = _this$props11.view,
|
|
@@ -548,7 +581,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
548
581
|
getPos = _this$props11.getPos,
|
|
549
582
|
pluginInjectionApi = _this$props11.pluginInjectionApi,
|
|
550
583
|
isDragAndDropEnabled = _this$props11.isDragAndDropEnabled,
|
|
551
|
-
getEditorFeatureFlags = _this$props11.getEditorFeatureFlags
|
|
584
|
+
getEditorFeatureFlags = _this$props11.getEditorFeatureFlags,
|
|
585
|
+
isTableScalingEnabled = _this$props11.isTableScalingEnabled;
|
|
552
586
|
var _this$state3 = this.state,
|
|
553
587
|
showBeforeShadow = _this$state3.showBeforeShadow,
|
|
554
588
|
showAfterShadow = _this$state3.showAfterShadow;
|
|
@@ -582,7 +616,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
582
616
|
,
|
|
583
617
|
selection: view.state.selection,
|
|
584
618
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
585
|
-
stickyHeader: this.state.stickyHeader
|
|
619
|
+
stickyHeader: this.state.stickyHeader,
|
|
620
|
+
tableWrapperWidth: this.state.tableWrapperWidth
|
|
586
621
|
});
|
|
587
622
|
var tableContainerWidth = getTableContainerWidth(node);
|
|
588
623
|
var colControls = isDragAndDropEnabled ? /*#__PURE__*/React.createElement(TableFloatingColumnControls, {
|
|
@@ -606,9 +641,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
606
641
|
tableContainerWidth: tableContainerWidth,
|
|
607
642
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
608
643
|
getScrollOffset: function getScrollOffset() {
|
|
609
|
-
var
|
|
610
|
-
return ((
|
|
611
|
-
}
|
|
644
|
+
var _this3$wrapper;
|
|
645
|
+
return ((_this3$wrapper = _this3.wrapper) === null || _this3$wrapper === void 0 ? void 0 : _this3$wrapper.scrollLeft) || 0;
|
|
646
|
+
},
|
|
647
|
+
tableWrapperHeight: this.state.tableWrapperHeight
|
|
612
648
|
}) : null;
|
|
613
649
|
var shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
|
|
614
650
|
var shadowStyle = memoizeOne(function (visible) {
|
|
@@ -630,9 +666,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
630
666
|
}
|
|
631
667
|
var isNested = isTableNested(view.state, tablePos);
|
|
632
668
|
var topStickyShadowPosition = isDragAndDropEnabled ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2 : this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
|
|
633
|
-
var
|
|
634
|
-
stickyScrollbar =
|
|
635
|
-
tablePreserveWidth = _getEditorFeatureFlag7.tablePreserveWidth;
|
|
669
|
+
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
670
|
+
stickyScrollbar = _getEditorFeatureFlag3.stickyScrollbar;
|
|
636
671
|
return /*#__PURE__*/React.createElement(TableContainer, {
|
|
637
672
|
className: classnames(ClassName.TABLE_CONTAINER, (_classnames = {}, _defineProperty(_classnames, ClassName.WITH_CONTROLS, allowControls && tableActive), _defineProperty(_classnames, ClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), _defineProperty(_classnames, ClassName.HOVERED_DELETE_BUTTON, isInDanger), _defineProperty(_classnames, ClassName.TABLE_SELECTED, isTableSelected(view.state.selection)), _classnames)),
|
|
638
673
|
editorView: view,
|
|
@@ -643,9 +678,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
643
678
|
isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
|
|
644
679
|
isNested: isNested,
|
|
645
680
|
pluginInjectionApi: pluginInjectionApi,
|
|
681
|
+
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
646
682
|
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
|
|
647
683
|
isResizing: isResizing,
|
|
648
|
-
|
|
684
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
649
685
|
}, /*#__PURE__*/React.createElement("div", {
|
|
650
686
|
className: ClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
651
687
|
"data-testid": "sticky-sentinel-top"
|
|
@@ -656,12 +692,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
656
692
|
editorView: view,
|
|
657
693
|
node: node,
|
|
658
694
|
getScrollOffset: function getScrollOffset() {
|
|
659
|
-
var
|
|
660
|
-
return ((
|
|
695
|
+
var _this3$wrapper2;
|
|
696
|
+
return ((_this3$wrapper2 = _this3.wrapper) === null || _this3$wrapper2 === void 0 ? void 0 : _this3$wrapper2.scrollLeft) || 0;
|
|
661
697
|
},
|
|
662
698
|
getTableWrapperWidth: function getTableWrapperWidth() {
|
|
663
|
-
var
|
|
664
|
-
return ((
|
|
699
|
+
var _this3$wrapper3;
|
|
700
|
+
return ((_this3$wrapper3 = _this3.wrapper) === null || _this3$wrapper3 === void 0 ? void 0 : _this3$wrapper3.clientWidth) || 760;
|
|
665
701
|
}
|
|
666
702
|
}), /*#__PURE__*/React.createElement("div", {
|
|
667
703
|
style: shadowStyle(showBeforeShadow),
|
|
@@ -676,13 +712,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
676
712
|
}), /*#__PURE__*/React.createElement("div", {
|
|
677
713
|
className: classnames(ClassName.TABLE_NODE_WRAPPER),
|
|
678
714
|
ref: function ref(elem) {
|
|
679
|
-
|
|
715
|
+
_this3.wrapper = elem;
|
|
680
716
|
if (elem) {
|
|
681
|
-
|
|
717
|
+
_this3.props.contentDOM(elem);
|
|
682
718
|
var tableElement = elem.querySelector('table');
|
|
683
|
-
if (tableElement !==
|
|
684
|
-
|
|
685
|
-
|
|
719
|
+
if (tableElement !== _this3.table) {
|
|
720
|
+
_this3.table = tableElement;
|
|
721
|
+
_this3.createShadowSentinels(_this3.table);
|
|
722
|
+
_this3.observeTable(_this3.table);
|
|
686
723
|
}
|
|
687
724
|
}
|
|
688
725
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
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
4
|
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
|
-
import React, { forwardRef, useCallback, useRef } from 'react';
|
|
5
|
+
import React, { forwardRef, useCallback, useRef, useState } from 'react';
|
|
5
6
|
import classNames from 'classnames';
|
|
6
7
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
7
8
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
@@ -44,9 +45,14 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
44
45
|
tableRef = _ref2.tableRef,
|
|
45
46
|
isResizing = _ref2.isResizing,
|
|
46
47
|
pluginInjectionApi = _ref2.pluginInjectionApi,
|
|
47
|
-
|
|
48
|
+
isTableScalingEnabled = _ref2.isTableScalingEnabled,
|
|
49
|
+
tableWrapperHeight = _ref2.tableWrapperHeight;
|
|
48
50
|
var containerRef = useRef(null);
|
|
49
51
|
var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
52
|
+
var _useState = useState(false),
|
|
53
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
54
|
+
resizing = _useState2[0],
|
|
55
|
+
setIsResizing = _useState2[1];
|
|
50
56
|
var updateContainerHeight = useCallback(function (height) {
|
|
51
57
|
var _containerRef$current;
|
|
52
58
|
// current StickyHeader State is not stable to be fetch.
|
|
@@ -54,31 +60,24 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
54
60
|
// consistently fetch and refactor below
|
|
55
61
|
var stickyHeaders = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getElementsByClassName('pm-table-sticky');
|
|
56
62
|
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
57
|
-
var _containerRef$current2;
|
|
58
63
|
// when starting to drag, we need to keep the original space,
|
|
59
64
|
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
60
65
|
// 1px is border width but collapse make it 0.5.
|
|
61
66
|
// -- When sticky header appear, we should add first row height but reduce
|
|
62
67
|
// collapsed border
|
|
63
|
-
|
|
68
|
+
return typeof height === 'number' ? "".concat(height + 40.5, "px") : 'auto';
|
|
64
69
|
} else {
|
|
65
|
-
var _containerRef$
|
|
66
|
-
var stickyHeaderHeight = ((_containerRef$
|
|
67
|
-
|
|
70
|
+
var _containerRef$current2;
|
|
71
|
+
var stickyHeaderHeight = ((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
|
|
72
|
+
return typeof height === 'number' ? "".concat(height + stickyHeaderHeight + 39.5, "px") : 'auto';
|
|
68
73
|
}
|
|
69
74
|
}, []);
|
|
70
|
-
var resizeObserverRef = useRef(new ResizeObserver(function (entries) {
|
|
71
|
-
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
72
|
-
}));
|
|
73
75
|
var onResizeStart = useCallback(function () {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
}, [tableRef]);
|
|
76
|
+
setIsResizing(true);
|
|
77
|
+
}, []);
|
|
78
78
|
var onResizeStop = useCallback(function () {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, [updateContainerHeight]);
|
|
79
|
+
setIsResizing(false);
|
|
80
|
+
}, []);
|
|
82
81
|
var updateWidth = useCallback(function (width) {
|
|
83
82
|
if (!containerRef.current) {
|
|
84
83
|
return;
|
|
@@ -108,7 +107,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
108
107
|
}, [pluginInjectionApi]);
|
|
109
108
|
var tableWidth = getTableContainerWidth(node);
|
|
110
109
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
111
|
-
var responsiveContainerWidth =
|
|
110
|
+
var responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
|
|
112
111
|
var width = Math.min(tableWidth, responsiveContainerWidth);
|
|
113
112
|
if (!isResizing) {
|
|
114
113
|
tableWidthRef.current = width;
|
|
@@ -126,7 +125,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
126
125
|
displayGuideline: displayGuideline,
|
|
127
126
|
attachAnalyticsEvent: attachAnalyticsEvent,
|
|
128
127
|
displayGapCursor: displayGapCursor,
|
|
129
|
-
|
|
128
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
130
129
|
};
|
|
131
130
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
132
131
|
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
@@ -141,7 +140,8 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
141
140
|
}
|
|
142
141
|
}, /*#__PURE__*/React.createElement("div", {
|
|
143
142
|
style: {
|
|
144
|
-
width: tableWidthRef.current
|
|
143
|
+
width: tableWidthRef.current,
|
|
144
|
+
height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto'
|
|
145
145
|
},
|
|
146
146
|
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
147
147
|
ref: containerRef
|
|
@@ -163,9 +163,10 @@ export var TableContainer = function TableContainer(_ref3) {
|
|
|
163
163
|
getPos = _ref3.getPos,
|
|
164
164
|
tableRef = _ref3.tableRef,
|
|
165
165
|
isNested = _ref3.isNested,
|
|
166
|
+
tableWrapperHeight = _ref3.tableWrapperHeight,
|
|
166
167
|
isResizing = _ref3.isResizing,
|
|
167
168
|
pluginInjectionApi = _ref3.pluginInjectionApi,
|
|
168
|
-
|
|
169
|
+
isTableScalingEnabled = _ref3.isTableScalingEnabled;
|
|
169
170
|
if (isTableResizingEnabled && !isNested) {
|
|
170
171
|
return /*#__PURE__*/React.createElement(ResizableTableContainer, {
|
|
171
172
|
className: className,
|
|
@@ -174,9 +175,10 @@ export var TableContainer = function TableContainer(_ref3) {
|
|
|
174
175
|
editorView: editorView,
|
|
175
176
|
getPos: getPos,
|
|
176
177
|
tableRef: tableRef,
|
|
178
|
+
tableWrapperHeight: tableWrapperHeight,
|
|
177
179
|
isResizing: isResizing,
|
|
178
180
|
pluginInjectionApi: pluginInjectionApi,
|
|
179
|
-
|
|
181
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
180
182
|
}, children);
|
|
181
183
|
}
|
|
182
184
|
var tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
|
|
@@ -55,7 +55,7 @@ var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
|
55
55
|
};
|
|
56
56
|
var getResizerMinWidth = function getResizerMinWidth(node) {
|
|
57
57
|
var currentColumnCount = getColgroupChildrenLength(node);
|
|
58
|
-
var minColumnWidth =
|
|
58
|
+
var minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
|
|
59
59
|
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
60
60
|
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
61
61
|
return minColumnWidth + 1;
|
|
@@ -88,7 +88,7 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
88
88
|
displayGuideline = _ref.displayGuideline,
|
|
89
89
|
attachAnalyticsEvent = _ref.attachAnalyticsEvent,
|
|
90
90
|
displayGapCursor = _ref.displayGapCursor,
|
|
91
|
-
|
|
91
|
+
isTableScalingEnabled = _ref.isTableScalingEnabled;
|
|
92
92
|
var currentGap = useRef(0);
|
|
93
93
|
// track resizing state - use ref over state to avoid re-render
|
|
94
94
|
var isResizing = useRef(false);
|
|
@@ -135,15 +135,15 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
135
135
|
keys = _ref2.keys;
|
|
136
136
|
if (gap !== currentGap.current) {
|
|
137
137
|
currentGap.current = gap;
|
|
138
|
-
var visibleGuidelines = getVisibleGuidelines(
|
|
138
|
+
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
139
139
|
displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, visibleGuidelines));
|
|
140
140
|
}
|
|
141
|
-
}, [
|
|
141
|
+
}, [isTableScalingEnabled, containerWidth, displayGuideline]);
|
|
142
142
|
var guidelineSnaps = useMemo(function () {
|
|
143
143
|
return snappingEnabled ? {
|
|
144
|
-
x:
|
|
144
|
+
x: isTableScalingEnabled ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths
|
|
145
145
|
} : undefined;
|
|
146
|
-
}, [snappingEnabled,
|
|
146
|
+
}, [snappingEnabled, isTableScalingEnabled, containerWidth]);
|
|
147
147
|
useEffect(function () {
|
|
148
148
|
return function () {
|
|
149
149
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
@@ -173,12 +173,12 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
173
173
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
174
174
|
});
|
|
175
175
|
dispatch(tr);
|
|
176
|
-
var visibleGuidelines = getVisibleGuidelines(
|
|
176
|
+
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
177
177
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
178
178
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
179
179
|
onResizeStart();
|
|
180
180
|
}
|
|
181
|
-
}, [startMeasure, editorView, displayGapCursor,
|
|
181
|
+
}, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
182
182
|
var handleResize = useCallback(function (originalState, delta) {
|
|
183
183
|
countFrames();
|
|
184
184
|
var newWidth = originalState.width + delta.width;
|
|
@@ -196,11 +196,11 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
196
196
|
prevNode: node,
|
|
197
197
|
start: pos + 1,
|
|
198
198
|
parentWidth: newWidth
|
|
199
|
-
}, editorView.domAtPos.bind(editorView),
|
|
200
|
-
updateActiveGuidelines(findClosestSnap(newWidth,
|
|
199
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled);
|
|
200
|
+
updateActiveGuidelines(findClosestSnap(newWidth, isTableScalingEnabled ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths, isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
201
201
|
updateWidth(newWidth);
|
|
202
202
|
return newWidth;
|
|
203
|
-
}, [countFrames,
|
|
203
|
+
}, [countFrames, isTableScalingEnabled, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
|
|
204
204
|
var scheduleResize = useMemo(function () {
|
|
205
205
|
return rafSchd(handleResize);
|
|
206
206
|
}, [handleResize]);
|
|
@@ -236,7 +236,7 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
236
236
|
prevNode: node,
|
|
237
237
|
start: pos + 1,
|
|
238
238
|
parentWidth: newWidth
|
|
239
|
-
}, editorView.domAtPos.bind(editorView),
|
|
239
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled)(tr);
|
|
240
240
|
var scaledNode = tr.doc.nodeAt(pos);
|
|
241
241
|
(_attachAnalyticsEvent2 = attachAnalyticsEvent(generateResizedPayload({
|
|
242
242
|
originalNode: node,
|
|
@@ -254,7 +254,7 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
254
254
|
onResizeStop();
|
|
255
255
|
}
|
|
256
256
|
return newWidth;
|
|
257
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop,
|
|
257
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled]);
|
|
258
258
|
var handleTableSizeChangeOnKeypress = useCallback(function (step) {
|
|
259
259
|
var newWidth = width + step;
|
|
260
260
|
if (newWidth > maxWidth || newWidth < resizerMinWidth) {
|