@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
|
@@ -32,9 +32,10 @@ var _stickyHeaders = require("../pm-plugins/sticky-headers");
|
|
|
32
32
|
var _tableAnalytics = require("../pm-plugins/table-analytics");
|
|
33
33
|
var _utils4 = require("../pm-plugins/table-resizing/utils");
|
|
34
34
|
var _colgroup = require("../pm-plugins/table-resizing/utils/colgroup");
|
|
35
|
+
var _consts = require("../pm-plugins/table-resizing/utils/consts");
|
|
35
36
|
var _dom = require("../pm-plugins/table-resizing/utils/dom");
|
|
36
37
|
var _types = require("../types");
|
|
37
|
-
var
|
|
38
|
+
var _consts2 = require("../ui/consts");
|
|
38
39
|
var _TableFloatingColumnControls = _interopRequireDefault(require("../ui/TableFloatingColumnControls"));
|
|
39
40
|
var _TableFloatingControls = _interopRequireDefault(require("../ui/TableFloatingControls"));
|
|
40
41
|
var _utils5 = require("../utils");
|
|
@@ -42,6 +43,9 @@ var _ExternalDropTargets = require("./ExternalDropTargets");
|
|
|
42
43
|
var _OverflowShadowsObserver = require("./OverflowShadowsObserver");
|
|
43
44
|
var _TableContainer = require("./TableContainer");
|
|
44
45
|
var _TableStickyScrollbar = require("./TableStickyScrollbar");
|
|
46
|
+
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; } } }; }
|
|
47
|
+
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); }
|
|
48
|
+
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; }
|
|
45
49
|
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; }
|
|
46
50
|
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) { (0, _defineProperty3.default)(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; }
|
|
47
51
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
@@ -51,6 +55,12 @@ var isIE11 = _utils.browser.ie_version === 11;
|
|
|
51
55
|
// componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
|
|
52
56
|
// To make sure we capture the last update, we use setTimeout.
|
|
53
57
|
var initialOverflowCaptureTimeroutDelay = 300;
|
|
58
|
+
|
|
59
|
+
// This is a hard switch for controlling whether the overflow analytics should be dispatched. There has been 6months of data
|
|
60
|
+
// already collected which we could use but have not. This has been disabled rather then removed entirely in the event that
|
|
61
|
+
// the current collected data becomes stale and we want to start collecting fresh data again in future.
|
|
62
|
+
// PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
|
|
63
|
+
var isOverflowAnalyticsEnabled = false;
|
|
54
64
|
var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
55
65
|
(0, _inherits2.default)(TableComponent, _React$Component);
|
|
56
66
|
var _super = _createSuper(TableComponent);
|
|
@@ -62,7 +72,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
62
72
|
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "state", (_defineProperty2 = {
|
|
63
73
|
scroll: 0,
|
|
64
74
|
parentWidth: undefined
|
|
65
|
-
}, (0, _defineProperty3.default)(_defineProperty2, _types.ShadowEvent.SHOW_BEFORE_SHADOW, false), (0, _defineProperty3.default)(_defineProperty2, _types.ShadowEvent.SHOW_AFTER_SHADOW, false), _defineProperty2));
|
|
75
|
+
}, (0, _defineProperty3.default)(_defineProperty2, _types.ShadowEvent.SHOW_BEFORE_SHADOW, false), (0, _defineProperty3.default)(_defineProperty2, _types.ShadowEvent.SHOW_AFTER_SHADOW, false), (0, _defineProperty3.default)(_defineProperty2, "tableWrapperWidth", undefined), (0, _defineProperty3.default)(_defineProperty2, "tableWrapperHeight", undefined), _defineProperty2));
|
|
66
76
|
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "updateShadowState", function (shadowKey, value) {
|
|
67
77
|
if (_this.state[shadowKey] === value) {
|
|
68
78
|
return;
|
|
@@ -176,7 +186,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
176
186
|
getPos = _this$props2.getPos,
|
|
177
187
|
containerWidth = _this$props2.containerWidth,
|
|
178
188
|
options = _this$props2.options,
|
|
179
|
-
|
|
189
|
+
isTableScalingEnabled = _this$props2.isTableScalingEnabled;
|
|
180
190
|
var node = getNode();
|
|
181
191
|
var state = view.state,
|
|
182
192
|
dispatch = view.dispatch;
|
|
@@ -187,16 +197,13 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
187
197
|
var domAtPos = view.domAtPos.bind(view);
|
|
188
198
|
var width = containerWidth.width;
|
|
189
199
|
_this.scaleTableDebounced.cancel();
|
|
190
|
-
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
191
|
-
_getEditorFeatureFlag2 = _getEditorFeatureFlag.tablePreserveWidth,
|
|
192
|
-
tablePreserveWidth = _getEditorFeatureFlag2 === void 0 ? false : _getEditorFeatureFlag2;
|
|
193
200
|
var tr = (0, _utils4.scaleTable)(_this.table, _objectSpread(_objectSpread({}, scaleOptions), {}, {
|
|
194
201
|
node: node,
|
|
195
202
|
prevNode: _this.node || node,
|
|
196
203
|
start: pos + 1,
|
|
197
204
|
containerWidth: width,
|
|
198
205
|
previousContainerWidth: _this.containerWidth.width || width
|
|
199
|
-
}, options), domAtPos,
|
|
206
|
+
}, options), domAtPos, isTableScalingEnabled)(state.tr);
|
|
200
207
|
dispatch(tr);
|
|
201
208
|
});
|
|
202
209
|
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "setTimerToSendInitialOverflowCaptured", function (isOverflowing) {
|
|
@@ -297,6 +304,29 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
297
304
|
_this.layoutSize = _this.tableNodeLayoutSize(_this.node, _containerWidth.width, {
|
|
298
305
|
isFullWidthModeEnabled: isFullWidthModeEnabled
|
|
299
306
|
});
|
|
307
|
+
_this.resizeObserver = new ResizeObserver(function (entries) {
|
|
308
|
+
var _iterator = _createForOfIteratorHelper(entries),
|
|
309
|
+
_step;
|
|
310
|
+
try {
|
|
311
|
+
var _loop = function _loop() {
|
|
312
|
+
var entry = _step.value;
|
|
313
|
+
_this.setState(function (prev) {
|
|
314
|
+
var _entry$contentRect, _entry$contentRect2;
|
|
315
|
+
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), {}, {
|
|
316
|
+
tableWrapperWidth: entry.contentRect.width,
|
|
317
|
+
tableWrapperHeight: entry.contentRect.height
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
322
|
+
_loop();
|
|
323
|
+
}
|
|
324
|
+
} catch (err) {
|
|
325
|
+
_iterator.e(err);
|
|
326
|
+
} finally {
|
|
327
|
+
_iterator.f();
|
|
328
|
+
}
|
|
329
|
+
});
|
|
300
330
|
|
|
301
331
|
// Disable inline table editing and resizing controls in Firefox
|
|
302
332
|
// https://github.com/ProseMirror/prosemirror/issues/432
|
|
@@ -318,13 +348,17 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
318
348
|
options = _this$props7.options,
|
|
319
349
|
isDragAndDropEnabled = _this$props7.isDragAndDropEnabled,
|
|
320
350
|
getNode = _this$props7.getNode,
|
|
321
|
-
getEditorFeatureFlags = _this$props7.getEditorFeatureFlags
|
|
351
|
+
getEditorFeatureFlags = _this$props7.getEditorFeatureFlags,
|
|
352
|
+
isTableScalingEnabled = _this$props7.isTableScalingEnabled;
|
|
353
|
+
if (isTableScalingEnabled) {
|
|
354
|
+
this.handleColgroupUpdates(true);
|
|
355
|
+
}
|
|
322
356
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
323
357
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
324
358
|
passive: true
|
|
325
359
|
});
|
|
326
|
-
var
|
|
327
|
-
stickyScrollbar =
|
|
360
|
+
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
361
|
+
stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
|
|
328
362
|
if (stickyScrollbar) {
|
|
329
363
|
if (this.table) {
|
|
330
364
|
this.stickyScrollbar = new _TableStickyScrollbar.TableStickyScrollbar(this.wrapper, this.props.view);
|
|
@@ -352,12 +386,15 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
352
386
|
this.onStickyState(currentStickyState);
|
|
353
387
|
}
|
|
354
388
|
eventDispatcher.on(_stickyHeaders.pluginKey.key, this.onStickyState);
|
|
355
|
-
|
|
356
|
-
|
|
389
|
+
if (isOverflowAnalyticsEnabled) {
|
|
390
|
+
var initialIsOveflowing = this.state[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
391
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
392
|
+
}
|
|
357
393
|
}
|
|
358
394
|
}, {
|
|
359
395
|
key: "componentWillUnmount",
|
|
360
396
|
value: function componentWillUnmount() {
|
|
397
|
+
var _this$resizeObserver;
|
|
361
398
|
var _this$props8 = this.props,
|
|
362
399
|
allowColumnResizing = _this$props8.allowColumnResizing,
|
|
363
400
|
eventDispatcher = _this$props8.eventDispatcher,
|
|
@@ -370,8 +407,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
370
407
|
if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
|
|
371
408
|
this.dragAndDropCleanupFn();
|
|
372
409
|
}
|
|
373
|
-
|
|
374
|
-
|
|
410
|
+
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 || _this$resizeObserver.disconnect();
|
|
411
|
+
var _getEditorFeatureFlag2 = getEditorFeatureFlags(),
|
|
412
|
+
stickyScrollbar = _getEditorFeatureFlag2.stickyScrollbar;
|
|
375
413
|
if (stickyScrollbar) {
|
|
376
414
|
if (this.stickyScrollbar) {
|
|
377
415
|
this.stickyScrollbar.dispose();
|
|
@@ -398,23 +436,21 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
398
436
|
}, {
|
|
399
437
|
key: "handleColgroupUpdates",
|
|
400
438
|
value: function handleColgroupUpdates() {
|
|
401
|
-
var
|
|
402
|
-
|
|
439
|
+
var _this$containerWidth;
|
|
440
|
+
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
403
441
|
var _this$props9 = this.props,
|
|
404
442
|
getNode = _this$props9.getNode,
|
|
405
443
|
containerWidth = _this$props9.containerWidth,
|
|
406
444
|
isResizing = _this$props9.isResizing,
|
|
407
445
|
view = _this$props9.view,
|
|
408
|
-
getPos = _this$props9.getPos
|
|
409
|
-
|
|
410
|
-
if (!tableRef) {
|
|
446
|
+
getPos = _this$props9.getPos;
|
|
447
|
+
if (!this.table) {
|
|
411
448
|
return;
|
|
412
449
|
}
|
|
413
|
-
var TABLE_MARGIN = 76;
|
|
414
450
|
|
|
415
451
|
// Remove any widths styles after resizing preview is completed
|
|
416
|
-
|
|
417
|
-
var tableRenderWidth = containerWidth.width -
|
|
452
|
+
this.table.style.width = '';
|
|
453
|
+
var tableRenderWidth = containerWidth.width - _consts.TABLE_EDITOR_MARGIN;
|
|
418
454
|
var tableNode = getNode();
|
|
419
455
|
var start = getPos() || 0;
|
|
420
456
|
var depth = view.state.doc.resolve(start).depth;
|
|
@@ -424,17 +460,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
424
460
|
return;
|
|
425
461
|
}
|
|
426
462
|
var tableNodeWidth = tableNode.attrs.width;
|
|
427
|
-
var tableColumnWidths = (0, _utils.calcTableColumnWidths)(tableNode);
|
|
428
463
|
var shouldTableScale = tableRenderWidth < tableNodeWidth;
|
|
429
|
-
var isTableColumnWidthsSame = false;
|
|
430
|
-
if (this.tableColumnWidths) {
|
|
431
|
-
isTableColumnWidthsSame = tableColumnWidths === null || tableColumnWidths === void 0 ? void 0 : tableColumnWidths.every(function (width, index) {
|
|
432
|
-
return width === _this2.tableColumnWidths[index];
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
464
|
var containerWidthValue = containerWidth.width;
|
|
436
465
|
var isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
437
|
-
if (shouldTableScale && !isResizing &&
|
|
466
|
+
if (force || shouldTableScale && !isResizing && isWidthChanged) {
|
|
438
467
|
var resizeState = (0, _utils4.getResizeState)({
|
|
439
468
|
minWidth: _utils4.COLUMN_MIN_WIDTH,
|
|
440
469
|
maxSize: tableRenderWidth,
|
|
@@ -442,20 +471,17 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
442
471
|
tableRef: this.table,
|
|
443
472
|
start: start,
|
|
444
473
|
domAtPos: view.domAtPos,
|
|
445
|
-
|
|
474
|
+
isTableScalingEnabled: true
|
|
446
475
|
});
|
|
447
|
-
|
|
448
|
-
(0, _utils4.updateColgroup)(resizeState, _this2.table, true);
|
|
449
|
-
});
|
|
450
|
-
this.tableColumnWidths = tableColumnWidths;
|
|
451
|
-
this.containerWidth = containerWidth;
|
|
476
|
+
(0, _utils4.updateColgroup)(resizeState, this.table, tableNode, true);
|
|
452
477
|
}
|
|
478
|
+
this.containerWidth = containerWidth;
|
|
453
479
|
}
|
|
454
480
|
}, {
|
|
455
481
|
key: "componentDidUpdate",
|
|
456
482
|
value: function componentDidUpdate(_, prevState) {
|
|
457
483
|
var _this$wrapper,
|
|
458
|
-
|
|
484
|
+
_this2 = this;
|
|
459
485
|
var _this$props10 = this.props,
|
|
460
486
|
view = _this$props10.view,
|
|
461
487
|
getNode = _this$props10.getNode,
|
|
@@ -463,14 +489,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
463
489
|
allowColumnResizing = _this$props10.allowColumnResizing,
|
|
464
490
|
isResizing = _this$props10.isResizing,
|
|
465
491
|
options = _this$props10.options,
|
|
466
|
-
|
|
492
|
+
isTableScalingEnabled = _this$props10.isTableScalingEnabled;
|
|
467
493
|
var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
|
|
468
494
|
isInDanger = _getPluginState.isInDanger;
|
|
469
|
-
var _getEditorFeatureFlag5 = getEditorFeatureFlags(),
|
|
470
|
-
_getEditorFeatureFlag6 = _getEditorFeatureFlag5.tablePreserveWidth,
|
|
471
|
-
tablePreserveWidth = _getEditorFeatureFlag6 === void 0 ? false : _getEditorFeatureFlag6;
|
|
472
495
|
var table = (0, _utils2.findTable)(view.state.selection);
|
|
473
|
-
if (
|
|
496
|
+
if (isTableScalingEnabled) {
|
|
474
497
|
this.handleColgroupUpdates();
|
|
475
498
|
}
|
|
476
499
|
if (isInDanger && !table) {
|
|
@@ -482,7 +505,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
482
505
|
// that happens when a table is nested in expand and expand's width is
|
|
483
506
|
// changed via breakout button
|
|
484
507
|
window.requestAnimationFrame(function () {
|
|
485
|
-
|
|
508
|
+
_this2.overflowShadowsObserver = new _OverflowShadowsObserver.OverflowShadowsObserver(_this2.updateShadowState, _this2.table, _this2.wrapper);
|
|
486
509
|
});
|
|
487
510
|
} else {
|
|
488
511
|
this.overflowShadowsObserver = new _OverflowShadowsObserver.OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
|
|
@@ -507,38 +530,48 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
507
530
|
var _view = this.props.view;
|
|
508
531
|
var shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || (0, _utils5.tablesHaveDifferentNoOfColumns)(currentTable, previousTable) && isResizing;
|
|
509
532
|
if (shouldRecreateResizeCols) {
|
|
510
|
-
(0, _utils4.insertColgroupFromNode)(this.table, currentTable,
|
|
533
|
+
(0, _utils4.insertColgroupFromNode)(this.table, currentTable, isTableScalingEnabled);
|
|
511
534
|
}
|
|
512
535
|
(0, _dom.updateControls)()(_view.state);
|
|
513
536
|
}
|
|
514
537
|
this.handleTableResizingDebounced();
|
|
515
538
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
539
|
+
if (isOverflowAnalyticsEnabled) {
|
|
540
|
+
var newIsOverflowing = this.state[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
541
|
+
var prevIsOverflowing = prevState[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
542
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
543
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
544
|
+
}
|
|
545
|
+
if (!this.isInitialOverflowSent) {
|
|
546
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
547
|
+
}
|
|
548
|
+
if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
|
|
549
|
+
var _this$state2;
|
|
550
|
+
var _this$props$view = this.props.view,
|
|
551
|
+
dispatch = _this$props$view.dispatch,
|
|
552
|
+
tr = _this$props$view.state.tr;
|
|
553
|
+
dispatch(tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
554
|
+
isOverflowing: newIsOverflowing,
|
|
555
|
+
wasOverflowing: prevIsOverflowing,
|
|
556
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
557
|
+
width: this.node.attrs.width || 0,
|
|
558
|
+
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
559
|
+
}));
|
|
560
|
+
}
|
|
520
561
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
var _this$
|
|
527
|
-
|
|
528
|
-
tr = _this$props$view.state.tr;
|
|
529
|
-
dispatch(tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
530
|
-
isOverflowing: newIsOverflowing,
|
|
531
|
-
wasOverflowing: prevIsOverflowing,
|
|
532
|
-
editorWidth: this.props.containerWidth.width || 0,
|
|
533
|
-
width: this.node.attrs.width || 0,
|
|
534
|
-
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
535
|
-
}));
|
|
562
|
+
}
|
|
563
|
+
}, {
|
|
564
|
+
key: "observeTable",
|
|
565
|
+
value: function observeTable(table) {
|
|
566
|
+
if (table) {
|
|
567
|
+
var _this$resizeObserver2;
|
|
568
|
+
(_this$resizeObserver2 = this.resizeObserver) === null || _this$resizeObserver2 === void 0 || _this$resizeObserver2.observe(table);
|
|
536
569
|
}
|
|
537
570
|
}
|
|
538
571
|
}, {
|
|
539
572
|
key: "render",
|
|
540
573
|
value: function render() {
|
|
541
|
-
var
|
|
574
|
+
var _this3 = this,
|
|
542
575
|
_classnames;
|
|
543
576
|
var _this$props11 = this.props,
|
|
544
577
|
view = _this$props11.view,
|
|
@@ -555,7 +588,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
555
588
|
getPos = _this$props11.getPos,
|
|
556
589
|
pluginInjectionApi = _this$props11.pluginInjectionApi,
|
|
557
590
|
isDragAndDropEnabled = _this$props11.isDragAndDropEnabled,
|
|
558
|
-
getEditorFeatureFlags = _this$props11.getEditorFeatureFlags
|
|
591
|
+
getEditorFeatureFlags = _this$props11.getEditorFeatureFlags,
|
|
592
|
+
isTableScalingEnabled = _this$props11.isTableScalingEnabled;
|
|
559
593
|
var _this$state3 = this.state,
|
|
560
594
|
showBeforeShadow = _this$state3.showBeforeShadow,
|
|
561
595
|
showAfterShadow = _this$state3.showAfterShadow;
|
|
@@ -589,7 +623,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
589
623
|
,
|
|
590
624
|
selection: view.state.selection,
|
|
591
625
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
592
|
-
stickyHeader: this.state.stickyHeader
|
|
626
|
+
stickyHeader: this.state.stickyHeader,
|
|
627
|
+
tableWrapperWidth: this.state.tableWrapperWidth
|
|
593
628
|
});
|
|
594
629
|
var tableContainerWidth = (0, _nodeWidth.getTableContainerWidth)(node);
|
|
595
630
|
var colControls = isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_TableFloatingColumnControls.default, {
|
|
@@ -613,9 +648,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
613
648
|
tableContainerWidth: tableContainerWidth,
|
|
614
649
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
615
650
|
getScrollOffset: function getScrollOffset() {
|
|
616
|
-
var
|
|
617
|
-
return ((
|
|
618
|
-
}
|
|
651
|
+
var _this3$wrapper;
|
|
652
|
+
return ((_this3$wrapper = _this3.wrapper) === null || _this3$wrapper === void 0 ? void 0 : _this3$wrapper.scrollLeft) || 0;
|
|
653
|
+
},
|
|
654
|
+
tableWrapperHeight: this.state.tableWrapperHeight
|
|
619
655
|
}) : null;
|
|
620
656
|
var shadowPadding = allowControls && tableActive ? -_editorSharedStyles.akEditorTableToolbarSize : _styles.tableMarginSides;
|
|
621
657
|
var shadowStyle = (0, _memoizeOne.default)(function (visible) {
|
|
@@ -637,9 +673,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
637
673
|
}
|
|
638
674
|
var isNested = (0, _utils5.isTableNested)(view.state, tablePos);
|
|
639
675
|
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;
|
|
640
|
-
var
|
|
641
|
-
stickyScrollbar =
|
|
642
|
-
tablePreserveWidth = _getEditorFeatureFlag7.tablePreserveWidth;
|
|
676
|
+
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
677
|
+
stickyScrollbar = _getEditorFeatureFlag3.stickyScrollbar;
|
|
643
678
|
return /*#__PURE__*/_react.default.createElement(_TableContainer.TableContainer, {
|
|
644
679
|
className: (0, _classnames2.default)(_types.TableCssClassName.TABLE_CONTAINER, (_classnames = {}, (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.WITH_CONTROLS, allowControls && tableActive), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.HOVERED_DELETE_BUTTON, isInDanger), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.TABLE_SELECTED, (0, _utils2.isTableSelected)(view.state.selection)), _classnames)),
|
|
645
680
|
editorView: view,
|
|
@@ -650,9 +685,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
650
685
|
isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
|
|
651
686
|
isNested: isNested,
|
|
652
687
|
pluginInjectionApi: pluginInjectionApi,
|
|
688
|
+
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
653
689
|
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
|
|
654
690
|
isResizing: isResizing,
|
|
655
|
-
|
|
691
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
656
692
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
657
693
|
className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
658
694
|
"data-testid": "sticky-sentinel-top"
|
|
@@ -663,12 +699,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
663
699
|
editorView: view,
|
|
664
700
|
node: node,
|
|
665
701
|
getScrollOffset: function getScrollOffset() {
|
|
666
|
-
var
|
|
667
|
-
return ((
|
|
702
|
+
var _this3$wrapper2;
|
|
703
|
+
return ((_this3$wrapper2 = _this3.wrapper) === null || _this3$wrapper2 === void 0 ? void 0 : _this3$wrapper2.scrollLeft) || 0;
|
|
668
704
|
},
|
|
669
705
|
getTableWrapperWidth: function getTableWrapperWidth() {
|
|
670
|
-
var
|
|
671
|
-
return ((
|
|
706
|
+
var _this3$wrapper3;
|
|
707
|
+
return ((_this3$wrapper3 = _this3.wrapper) === null || _this3$wrapper3 === void 0 ? void 0 : _this3$wrapper3.clientWidth) || 760;
|
|
672
708
|
}
|
|
673
709
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
674
710
|
style: shadowStyle(showBeforeShadow),
|
|
@@ -683,13 +719,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
683
719
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
684
720
|
className: (0, _classnames2.default)(_types.TableCssClassName.TABLE_NODE_WRAPPER),
|
|
685
721
|
ref: function ref(elem) {
|
|
686
|
-
|
|
722
|
+
_this3.wrapper = elem;
|
|
687
723
|
if (elem) {
|
|
688
|
-
|
|
724
|
+
_this3.props.contentDOM(elem);
|
|
689
725
|
var tableElement = elem.querySelector('table');
|
|
690
|
-
if (tableElement !==
|
|
691
|
-
|
|
692
|
-
|
|
726
|
+
if (tableElement !== _this3.table) {
|
|
727
|
+
_this3.table = tableElement;
|
|
728
|
+
_this3.createShadowSentinels(_this3.table);
|
|
729
|
+
_this3.observeTable(_this3.table);
|
|
693
730
|
}
|
|
694
731
|
}
|
|
695
732
|
}
|
|
@@ -712,7 +749,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
712
749
|
}), this.state.stickyHeader && /*#__PURE__*/_react.default.createElement("div", {
|
|
713
750
|
style: {
|
|
714
751
|
position: 'absolute',
|
|
715
|
-
right: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? "".concat((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ?
|
|
752
|
+
right: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? "".concat((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.increase-shadow-visibility_lh89r') ? _consts2.tableOverflowShadowWidthWide : _consts2.tableOverflowShadowWidth, "px") : '-2px'
|
|
716
753
|
}
|
|
717
754
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
718
755
|
className: "".concat(_types.TableCssClassName.TABLE_RIGHT_SHADOW, " ").concat(_types.TableCssClassName.TABLE_STICKY_SHADOW),
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.TableContainer = exports.ResizableTableContainer = exports.InnerContainer = void 0;
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
13
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
@@ -54,9 +55,14 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
54
55
|
tableRef = _ref2.tableRef,
|
|
55
56
|
isResizing = _ref2.isResizing,
|
|
56
57
|
pluginInjectionApi = _ref2.pluginInjectionApi,
|
|
57
|
-
|
|
58
|
+
isTableScalingEnabled = _ref2.isTableScalingEnabled,
|
|
59
|
+
tableWrapperHeight = _ref2.tableWrapperHeight;
|
|
58
60
|
var containerRef = (0, _react.useRef)(null);
|
|
59
61
|
var tableWidthRef = (0, _react.useRef)(_editorSharedStyles.akEditorDefaultLayoutWidth);
|
|
62
|
+
var _useState = (0, _react.useState)(false),
|
|
63
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
64
|
+
resizing = _useState2[0],
|
|
65
|
+
setIsResizing = _useState2[1];
|
|
60
66
|
var updateContainerHeight = (0, _react.useCallback)(function (height) {
|
|
61
67
|
var _containerRef$current;
|
|
62
68
|
// current StickyHeader State is not stable to be fetch.
|
|
@@ -64,31 +70,24 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
64
70
|
// consistently fetch and refactor below
|
|
65
71
|
var stickyHeaders = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getElementsByClassName('pm-table-sticky');
|
|
66
72
|
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
67
|
-
var _containerRef$current2;
|
|
68
73
|
// when starting to drag, we need to keep the original space,
|
|
69
74
|
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
70
75
|
// 1px is border width but collapse make it 0.5.
|
|
71
76
|
// -- When sticky header appear, we should add first row height but reduce
|
|
72
77
|
// collapsed border
|
|
73
|
-
|
|
78
|
+
return typeof height === 'number' ? "".concat(height + 40.5, "px") : 'auto';
|
|
74
79
|
} else {
|
|
75
|
-
var _containerRef$
|
|
76
|
-
var stickyHeaderHeight = ((_containerRef$
|
|
77
|
-
|
|
80
|
+
var _containerRef$current2;
|
|
81
|
+
var stickyHeaderHeight = ((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
|
|
82
|
+
return typeof height === 'number' ? "".concat(height + stickyHeaderHeight + 39.5, "px") : 'auto';
|
|
78
83
|
}
|
|
79
84
|
}, []);
|
|
80
|
-
var resizeObserverRef = (0, _react.useRef)(new ResizeObserver(function (entries) {
|
|
81
|
-
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
82
|
-
}));
|
|
83
85
|
var onResizeStart = (0, _react.useCallback)(function () {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
}, [tableRef]);
|
|
86
|
+
setIsResizing(true);
|
|
87
|
+
}, []);
|
|
88
88
|
var onResizeStop = (0, _react.useCallback)(function () {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, [updateContainerHeight]);
|
|
89
|
+
setIsResizing(false);
|
|
90
|
+
}, []);
|
|
92
91
|
var updateWidth = (0, _react.useCallback)(function (width) {
|
|
93
92
|
if (!containerRef.current) {
|
|
94
93
|
return;
|
|
@@ -118,7 +117,7 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
118
117
|
}, [pluginInjectionApi]);
|
|
119
118
|
var tableWidth = (0, _nodeWidth.getTableContainerWidth)(node);
|
|
120
119
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
121
|
-
var responsiveContainerWidth =
|
|
120
|
+
var responsiveContainerWidth = isTableScalingEnabled ? containerWidth - _editorSharedStyles.akEditorGutterPadding * 2 - _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - _editorSharedStyles.akEditorGutterPadding * 2 - _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide;
|
|
122
121
|
var width = Math.min(tableWidth, responsiveContainerWidth);
|
|
123
122
|
if (!isResizing) {
|
|
124
123
|
tableWidthRef.current = width;
|
|
@@ -136,7 +135,7 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
136
135
|
displayGuideline: displayGuideline,
|
|
137
136
|
attachAnalyticsEvent: attachAnalyticsEvent,
|
|
138
137
|
displayGapCursor: displayGapCursor,
|
|
139
|
-
|
|
138
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
140
139
|
};
|
|
141
140
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.resizing-table-height-improvement')) {
|
|
142
141
|
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
@@ -151,7 +150,8 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
151
150
|
}
|
|
152
151
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
153
152
|
style: {
|
|
154
|
-
width: tableWidthRef.current
|
|
153
|
+
width: tableWidthRef.current,
|
|
154
|
+
height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto'
|
|
155
155
|
},
|
|
156
156
|
className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
|
|
157
157
|
ref: containerRef
|
|
@@ -173,9 +173,10 @@ var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
|
|
|
173
173
|
getPos = _ref3.getPos,
|
|
174
174
|
tableRef = _ref3.tableRef,
|
|
175
175
|
isNested = _ref3.isNested,
|
|
176
|
+
tableWrapperHeight = _ref3.tableWrapperHeight,
|
|
176
177
|
isResizing = _ref3.isResizing,
|
|
177
178
|
pluginInjectionApi = _ref3.pluginInjectionApi,
|
|
178
|
-
|
|
179
|
+
isTableScalingEnabled = _ref3.isTableScalingEnabled;
|
|
179
180
|
if (isTableResizingEnabled && !isNested) {
|
|
180
181
|
return /*#__PURE__*/_react.default.createElement(ResizableTableContainer, {
|
|
181
182
|
className: className,
|
|
@@ -184,9 +185,10 @@ var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
|
|
|
184
185
|
editorView: editorView,
|
|
185
186
|
getPos: getPos,
|
|
186
187
|
tableRef: tableRef,
|
|
188
|
+
tableWrapperHeight: tableWrapperHeight,
|
|
187
189
|
isResizing: isResizing,
|
|
188
190
|
pluginInjectionApi: pluginInjectionApi,
|
|
189
|
-
|
|
191
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
190
192
|
}, children);
|
|
191
193
|
}
|
|
192
194
|
var tableWidth = isBreakoutEnabled ? (0, _styles.calcTableWidth)(node.attrs.layout, editorWidth) : 'inherit';
|
|
@@ -65,7 +65,7 @@ var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
|
65
65
|
};
|
|
66
66
|
var getResizerMinWidth = function getResizerMinWidth(node) {
|
|
67
67
|
var currentColumnCount = (0, _utils3.getColgroupChildrenLength)(node);
|
|
68
|
-
var minColumnWidth =
|
|
68
|
+
var minColumnWidth = Math.min(3, currentColumnCount) * _utils3.COLUMN_MIN_WIDTH;
|
|
69
69
|
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
70
70
|
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
71
71
|
return minColumnWidth + 1;
|
|
@@ -98,7 +98,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
98
98
|
displayGuideline = _ref.displayGuideline,
|
|
99
99
|
attachAnalyticsEvent = _ref.attachAnalyticsEvent,
|
|
100
100
|
displayGapCursor = _ref.displayGapCursor,
|
|
101
|
-
|
|
101
|
+
isTableScalingEnabled = _ref.isTableScalingEnabled;
|
|
102
102
|
var currentGap = (0, _react.useRef)(0);
|
|
103
103
|
// track resizing state - use ref over state to avoid re-render
|
|
104
104
|
var isResizing = (0, _react.useRef)(false);
|
|
@@ -145,15 +145,15 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
145
145
|
keys = _ref2.keys;
|
|
146
146
|
if (gap !== currentGap.current) {
|
|
147
147
|
currentGap.current = gap;
|
|
148
|
-
var visibleGuidelines = getVisibleGuidelines(
|
|
148
|
+
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth) : _guidelines.defaultGuidelines, containerWidth);
|
|
149
149
|
displayGuideline((0, _guideline.getGuidelinesWithHighlights)(gap, _consts.TABLE_SNAP_GAP, keys, visibleGuidelines));
|
|
150
150
|
}
|
|
151
|
-
}, [
|
|
151
|
+
}, [isTableScalingEnabled, containerWidth, displayGuideline]);
|
|
152
152
|
var guidelineSnaps = (0, _react.useMemo)(function () {
|
|
153
153
|
return snappingEnabled ? {
|
|
154
|
-
x:
|
|
154
|
+
x: isTableScalingEnabled ? (0, _snapping.defaultTablePreserveSnappingWidths)(containerWidth) : _snapping.defaultSnappingWidths
|
|
155
155
|
} : undefined;
|
|
156
|
-
}, [snappingEnabled,
|
|
156
|
+
}, [snappingEnabled, isTableScalingEnabled, containerWidth]);
|
|
157
157
|
(0, _react.useEffect)(function () {
|
|
158
158
|
return function () {
|
|
159
159
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
@@ -183,12 +183,12 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
183
183
|
name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
184
184
|
});
|
|
185
185
|
dispatch(tr);
|
|
186
|
-
var visibleGuidelines = getVisibleGuidelines(
|
|
186
|
+
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth) : _guidelines.defaultGuidelines, containerWidth);
|
|
187
187
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
188
188
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
189
189
|
onResizeStart();
|
|
190
190
|
}
|
|
191
|
-
}, [startMeasure, editorView, displayGapCursor,
|
|
191
|
+
}, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
192
192
|
var handleResize = (0, _react.useCallback)(function (originalState, delta) {
|
|
193
193
|
countFrames();
|
|
194
194
|
var newWidth = originalState.width + delta.width;
|
|
@@ -206,11 +206,11 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
206
206
|
prevNode: node,
|
|
207
207
|
start: pos + 1,
|
|
208
208
|
parentWidth: newWidth
|
|
209
|
-
}, editorView.domAtPos.bind(editorView),
|
|
210
|
-
updateActiveGuidelines((0, _snapping.findClosestSnap)(newWidth,
|
|
209
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled);
|
|
210
|
+
updateActiveGuidelines((0, _snapping.findClosestSnap)(newWidth, isTableScalingEnabled ? (0, _snapping.defaultTablePreserveSnappingWidths)(containerWidth) : _snapping.defaultSnappingWidths, isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth) : _guidelines.defaultGuidelines, _consts.TABLE_HIGHLIGHT_GAP, _consts.TABLE_HIGHLIGHT_TOLERANCE));
|
|
211
211
|
updateWidth(newWidth);
|
|
212
212
|
return newWidth;
|
|
213
|
-
}, [countFrames,
|
|
213
|
+
}, [countFrames, isTableScalingEnabled, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
|
|
214
214
|
var scheduleResize = (0, _react.useMemo)(function () {
|
|
215
215
|
return (0, _rafSchd.default)(handleResize);
|
|
216
216
|
}, [handleResize]);
|
|
@@ -246,7 +246,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
246
246
|
prevNode: node,
|
|
247
247
|
start: pos + 1,
|
|
248
248
|
parentWidth: newWidth
|
|
249
|
-
}, editorView.domAtPos.bind(editorView),
|
|
249
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled)(tr);
|
|
250
250
|
var scaledNode = tr.doc.nodeAt(pos);
|
|
251
251
|
(_attachAnalyticsEvent2 = attachAnalyticsEvent((0, _analytics2.generateResizedPayload)({
|
|
252
252
|
originalNode: node,
|
|
@@ -264,7 +264,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
264
264
|
onResizeStop();
|
|
265
265
|
}
|
|
266
266
|
return newWidth;
|
|
267
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop,
|
|
267
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled]);
|
|
268
268
|
var handleTableSizeChangeOnKeypress = (0, _react.useCallback)(function (step) {
|
|
269
269
|
var newWidth = width + step;
|
|
270
270
|
if (newWidth > maxWidth || newWidth < resizerMinWidth) {
|