@atlaskit/editor-plugin-table 1.2.0 → 1.2.2

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.
Files changed (107) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/cjs/i18n/en.js +43 -0
  3. package/dist/cjs/i18n/en_GB.js +43 -0
  4. package/dist/cjs/plugins/table/index.js +2 -1
  5. package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +13 -26
  6. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +18 -3
  7. package/dist/cjs/plugins/table/nodeviews/table.js +7 -0
  8. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +32 -17
  9. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
  10. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +3 -38
  11. package/dist/cjs/plugins/table/transforms/delete-rows.js +1 -1
  12. package/dist/cjs/plugins/table/transforms/index.js +3 -3
  13. package/dist/cjs/plugins/table/transforms/merge.js +39 -54
  14. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +16 -3
  15. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  16. package/dist/cjs/plugins/table/ui/common-styles.js +2 -2
  17. package/dist/cjs/plugins/table/utils/row-controls.js +3 -2
  18. package/dist/cjs/types/i18n.js +5 -0
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/i18n/en.js +36 -0
  21. package/dist/es2019/i18n/en_GB.js +36 -0
  22. package/dist/es2019/plugins/table/index.js +2 -1
  23. package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +13 -26
  24. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +22 -3
  25. package/dist/es2019/plugins/table/nodeviews/table.js +7 -0
  26. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +32 -17
  27. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
  28. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -37
  29. package/dist/es2019/plugins/table/transforms/delete-rows.js +2 -2
  30. package/dist/es2019/plugins/table/transforms/index.js +1 -1
  31. package/dist/es2019/plugins/table/transforms/merge.js +39 -43
  32. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +18 -4
  33. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  34. package/dist/es2019/plugins/table/ui/common-styles.js +21 -1
  35. package/dist/es2019/plugins/table/utils/row-controls.js +3 -2
  36. package/dist/es2019/types/i18n.js +1 -0
  37. package/dist/es2019/version.json +1 -1
  38. package/dist/esm/i18n/en.js +36 -0
  39. package/dist/esm/i18n/en_GB.js +36 -0
  40. package/dist/esm/plugins/table/index.js +2 -1
  41. package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +13 -26
  42. package/dist/esm/plugins/table/nodeviews/TableComponent.js +18 -3
  43. package/dist/esm/plugins/table/nodeviews/table.js +7 -0
  44. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +32 -17
  45. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
  46. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -35
  47. package/dist/esm/plugins/table/transforms/delete-rows.js +2 -2
  48. package/dist/esm/plugins/table/transforms/index.js +1 -1
  49. package/dist/esm/plugins/table/transforms/merge.js +38 -53
  50. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +17 -4
  51. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  52. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  53. package/dist/esm/plugins/table/utils/row-controls.js +3 -2
  54. package/dist/esm/types/i18n.js +1 -0
  55. package/dist/esm/version.json +1 -1
  56. package/dist/types/i18n/en.d.ts +35 -0
  57. package/dist/types/i18n/en_GB.d.ts +35 -0
  58. package/dist/types/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +4 -5
  59. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +1 -0
  60. package/dist/types/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +3 -3
  61. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +2 -2
  62. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -2
  63. package/dist/types/plugins/table/transforms/index.d.ts +1 -1
  64. package/dist/types/plugins/table/transforms/merge.d.ts +1 -1
  65. package/dist/types/plugins/table/types.d.ts +2 -0
  66. package/dist/types/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
  67. package/dist/types/plugins/table/ui/FloatingContextualMenu/index.d.ts +3 -2
  68. package/dist/types/types/i18n.d.ts +5 -0
  69. package/package.json +10 -9
  70. package/src/__tests__/integration/__fixtures__/table-and-paragraph-adf.ts +130 -0
  71. package/src/__tests__/integration/horizontal-scroll-shadows.ts +199 -0
  72. package/src/__tests__/integration/horizontal-scroll.ts +4 -9
  73. package/src/__tests__/integration/meta-arrowup-cursor-in-first-row.ts +4 -2
  74. package/src/__tests__/integration/sticky-header.ts +61 -1
  75. package/src/__tests__/unit/commands/insert.ts +8 -8
  76. package/src/__tests__/unit/commands/sort.ts +4 -0
  77. package/src/__tests__/unit/commands.ts +2 -0
  78. package/src/__tests__/unit/index.ts +2 -0
  79. package/src/__tests__/unit/keymap.ts +4 -2
  80. package/src/__tests__/unit/layout.ts +2 -0
  81. package/src/__tests__/unit/nodeviews/OverflowShadowsObserver.ts +20 -11
  82. package/src/__tests__/unit/nodeviews/cell.ts +14 -0
  83. package/src/__tests__/unit/pm-plugins/main-with-allow-collapse.ts +2 -0
  84. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +2 -2
  85. package/src/__tests__/unit/transforms/delete-rows.ts +45 -0
  86. package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
  87. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +1 -0
  88. package/src/__tests__/unit/utils/collapse.ts +4 -1
  89. package/src/i18n/en.ts +36 -0
  90. package/src/i18n/en_GB.ts +36 -0
  91. package/src/plugins/table/index.tsx +4 -0
  92. package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +24 -40
  93. package/src/plugins/table/nodeviews/TableComponent.tsx +20 -4
  94. package/src/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.ts +3 -3
  95. package/src/plugins/table/nodeviews/table.tsx +12 -0
  96. package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +40 -23
  97. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +1 -9
  98. package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +1 -57
  99. package/src/plugins/table/transforms/delete-rows.ts +2 -2
  100. package/src/plugins/table/transforms/index.ts +1 -1
  101. package/src/plugins/table/transforms/merge.ts +41 -43
  102. package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +21 -2
  103. package/src/plugins/table/ui/FloatingContextualMenu/index.tsx +8 -1
  104. package/src/plugins/table/ui/common-styles.ts +21 -0
  105. package/src/plugins/table/utils/row-controls.ts +3 -2
  106. package/src/types/i18n.ts +5 -0
  107. package/src/__tests__/integration/__fixtures__/table-and-paragraph-adf.json +0 -130
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 1.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ef830fdabfa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ef830fdabfa) - [ED-17294] Enable type checking for Preset plugins on unit tests
8
+ - [`b7f9b82ecd8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b7f9b82ecd8) - [ED-16109] Fix deleting rows with row above and below having merged cells
9
+ - [`7946da1848a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7946da1848a) - [ux] [ED-16668] Update table shadow intersection table to observe new shadow sentinels instead of first and last cell
10
+ - Updated dependencies
11
+
12
+ ## 1.2.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [`f07824eeccc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f07824eeccc) - ED-15647 fix undo when pasting table with resized column in expand
17
+ - [`924e8493f96`](https://bitbucket.org/atlassian/atlassian-frontend/commits/924e8493f96) - [ux] [ED-16418] Fixed issue where on resize the topPosEditorElement top position which determines the height of the sticky header would not update on window resize or other actions that may affect its height
18
+ - [`2f7fff7239d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2f7fff7239d) - [ux] [ED-17271] Sticky headers now listen for width changes in the parent scroll container
19
+ - [`2367ba14aa0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2367ba14aa0) - [ux] ED-16758 Added support for theme tokens in table cell background color.
20
+ - [`1f10173bdad`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1f10173bdad) - [ux] [ED-15686] Added sticky to floating contextual menu dropdown
21
+ - [`a5d7c8d0f1e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a5d7c8d0f1e) - [ux] Fix of the regression caused due to https://product-fabric.atlassian.net/browse/DTR-1313
22
+ - [`deef98920f4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/deef98920f4) - [ux] ED-16718 Table scroll troll - refactor nested expand logic back into editor-common
23
+ - [`1720ddc8076`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1720ddc8076) - [ux] ED-16725 Added support for semantic tooltip names for background color palette.
24
+ - [`454e652b2ed`](https://bitbucket.org/atlassian/atlassian-frontend/commits/454e652b2ed) - [ux] This change (TSLA-488) addresses a bug that occurs when changing the browser window size causes the
25
+ table margin to not be immediately updated for tables with active sticky headers. This change adds an
26
+ event listener for window resizing that updates the table margins.
27
+ - Updated dependencies
28
+
3
29
  ## 1.2.0
4
30
 
5
31
  ### Minor Changes
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /* prettier-ignore */
8
+ /**
9
+ * NOTE:
10
+ *
11
+ * This file is automatically generated by Traduki 2.0.
12
+ * DO NOT CHANGE IT BY HAND or your changes will be lost.
13
+ */
14
+ //
15
+ var _default = {
16
+ 'fabric.editor.canNotSortTable': "⚠️ You can't sort a table with merged cells",
17
+ 'fabric.editor.cellBackground': 'Cell background',
18
+ 'fabric.editor.cellOptions': 'Cell options',
19
+ 'fabric.editor.clearCells': 'Clear {0, plural, one {cell} other {cells}}',
20
+ 'fabric.editor.collapseTable': 'Collapse table',
21
+ 'fabric.editor.cornerControl': 'Highlight table',
22
+ 'fabric.editor.distributeColumns': 'Distribute columns',
23
+ 'fabric.editor.extension.confirmDeleteLinkedModalMessagePrefix': 'Deleting',
24
+ 'fabric.editor.extension.deleteElementTitle': 'Delete element',
25
+ 'fabric.editor.extension.sourceNoTitledName': 'this element',
26
+ 'fabric.editor.floatingToolbar.confirmModalCheckboxLabel': 'Also delete connected elements',
27
+ 'fabric.editor.headerColumn': 'Header column',
28
+ 'fabric.editor.headerRow': 'Header row',
29
+ 'fabric.editor.insertColumn': 'Insert column right',
30
+ 'fabric.editor.insertRow': 'Insert row below',
31
+ 'fabric.editor.mergeCells': 'Merge cells',
32
+ 'fabric.editor.numberedColumn': 'Numbered column',
33
+ 'fabric.editor.removeColumns': 'Delete {0, plural, one {column} other {columns}}',
34
+ 'fabric.editor.removeRows': 'Delete {0, plural, one {row} other {rows}}',
35
+ 'fabric.editor.rowControl': 'Highlight row',
36
+ 'fabric.editor.sortColumnASC': 'Sort column A → Z',
37
+ 'fabric.editor.sortColumnDESC': 'Sort column Z → A',
38
+ 'fabric.editor.splitCell': 'Split cell',
39
+ 'fabric.editor.tableOptions': 'Table options',
40
+ 'fabric.editor.tables.confirmDeleteLinkedModalMessage': 'Deleting {nodeName} will break anything connected to it.',
41
+ 'fabric.editor.tables.confirmDeleteLinkedModalOKButton': 'Delete'
42
+ };
43
+ exports.default = _default;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /* prettier-ignore */
8
+ /**
9
+ * NOTE:
10
+ *
11
+ * This file is automatically generated by Traduki 2.0.
12
+ * DO NOT CHANGE IT BY HAND or your changes will be lost.
13
+ */
14
+ //English (United Kingdom)
15
+ var _default = {
16
+ 'fabric.editor.canNotSortTable': "⚠️ You can't sort a table with merged cells",
17
+ 'fabric.editor.cellBackground': 'Cell background',
18
+ 'fabric.editor.cellOptions': 'Cell options',
19
+ 'fabric.editor.clearCells': 'Clear {0, plural, one {cell} other {cells}}',
20
+ 'fabric.editor.collapseTable': 'Collapse table',
21
+ 'fabric.editor.cornerControl': 'Highlight table',
22
+ 'fabric.editor.distributeColumns': 'Distribute columns',
23
+ 'fabric.editor.extension.confirmDeleteLinkedModalMessagePrefix': 'Deleting',
24
+ 'fabric.editor.extension.deleteElementTitle': 'Delete element',
25
+ 'fabric.editor.extension.sourceNoTitledName': 'this element',
26
+ 'fabric.editor.floatingToolbar.confirmModalCheckboxLabel': 'Also delete connected elements',
27
+ 'fabric.editor.headerColumn': 'Header column',
28
+ 'fabric.editor.headerRow': 'Header row',
29
+ 'fabric.editor.insertColumn': 'Insert column right',
30
+ 'fabric.editor.insertRow': 'Insert row below',
31
+ 'fabric.editor.mergeCells': 'Merge cells',
32
+ 'fabric.editor.numberedColumn': 'Numbered column',
33
+ 'fabric.editor.removeColumns': 'Delete {0, plural, one {column} other {columns}}',
34
+ 'fabric.editor.removeRows': 'Delete {0, plural, one {row} other {rows}}',
35
+ 'fabric.editor.rowControl': 'Highlight row',
36
+ 'fabric.editor.sortColumnASC': 'Sort column A → Z',
37
+ 'fabric.editor.sortColumnDESC': 'Sort column Z → A',
38
+ 'fabric.editor.splitCell': 'Split cell',
39
+ 'fabric.editor.tableOptions': 'Table options',
40
+ 'fabric.editor.tables.confirmDeleteLinkedModalMessage': 'Deleting {nodeName} will break anything connected to it.',
41
+ 'fabric.editor.tables.confirmDeleteLinkedModalOKButton': 'Delete'
42
+ };
43
+ exports.default = _default;
@@ -273,7 +273,8 @@ var tablesPlugin = function tablesPlugin(options) {
273
273
  isOpen: Boolean(isContextualMenuOpen),
274
274
  pluginConfig: pluginConfig,
275
275
  editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI,
276
- getEditorContainerWidth: defaultGetEditorContainerWidth
276
+ getEditorContainerWidth: defaultGetEditorContainerWidth,
277
+ getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
277
278
  }), allowControls && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
278
279
  editorView: editorView,
279
280
  selection: editorView.state.selection,
@@ -16,16 +16,9 @@ var OverflowShadowsObserver = /*#__PURE__*/function () {
16
16
  function OverflowShadowsObserver(updateShadowState, _table, wrapper) {
17
17
  var _this = this;
18
18
  (0, _classCallCheck2.default)(this, OverflowShadowsObserver);
19
- (0, _defineProperty2.default)(this, "firstCell", null);
20
- (0, _defineProperty2.default)(this, "lastCell", null);
21
- (0, _defineProperty2.default)(this, "getFirstCell", function (isSticky, hasHeaderRow) {
22
- var _this$table;
23
- return (_this$table = _this.table) === null || _this$table === void 0 ? void 0 : _this$table.querySelector(isSticky || !hasHeaderRow ? 'table tbody tr td' : 'table tbody tr th');
24
- });
25
- (0, _defineProperty2.default)(this, "getLastCell", function (isSticky, hasHeaderRow) {
26
- var _this$table2;
27
- return (_this$table2 = _this.table) === null || _this$table2 === void 0 ? void 0 : _this$table2.querySelector(isSticky || !hasHeaderRow ? 'table tbody tr td:last-child' : 'table tbody tr th:last-child');
28
- });
19
+ (0, _defineProperty2.default)(this, "leftShadowSentinel", null);
20
+ (0, _defineProperty2.default)(this, "rightShadowSentinel", null);
21
+ (0, _defineProperty2.default)(this, "shadowsObserved", false);
29
22
  (0, _defineProperty2.default)(this, "isSticky", false);
30
23
  (0, _defineProperty2.default)(this, "stickyRowHeight", 0);
31
24
  (0, _defineProperty2.default)(this, "init", function () {
@@ -39,11 +32,11 @@ var OverflowShadowsObserver = /*#__PURE__*/function () {
39
32
  if (!((_entry$rootBounds = entry.rootBounds) !== null && _entry$rootBounds !== void 0 && _entry$rootBounds.height) && !((_entry$rootBounds2 = entry.rootBounds) !== null && _entry$rootBounds2 !== void 0 && _entry$rootBounds2.width)) {
40
33
  return;
41
34
  }
42
- if (entry.target !== _this.firstCell && entry.target !== _this.lastCell) {
35
+ if (entry.target !== _this.leftShadowSentinel && entry.target !== _this.rightShadowSentinel) {
43
36
  return;
44
37
  }
45
38
  _this.updateStickyShadowsHeightIfChanged();
46
- _this.checkIntersectionEvent(entry, _this.firstCell === entry.target ? _types.ShadowEvent.SHOW_BEFORE_SHADOW : _types.ShadowEvent.SHOW_AFTER_SHADOW);
39
+ _this.checkIntersectionEvent(entry, _this.leftShadowSentinel === entry.target ? _types.ShadowEvent.SHOW_BEFORE_SHADOW : _types.ShadowEvent.SHOW_AFTER_SHADOW);
47
40
  };
48
41
  _this.tableIntersectionObserver = new IntersectionObserver(function (entries, _) {
49
42
  entries.forEach(function (entry) {
@@ -68,25 +61,19 @@ var OverflowShadowsObserver = /*#__PURE__*/function () {
68
61
  _this.updateShadowState(shadowKey, true);
69
62
  }
70
63
  });
71
- (0, _defineProperty2.default)(this, "observeCells", function (isSticky, hasHeaderRow) {
72
- var stickyChanged = !!isSticky !== _this.isSticky;
64
+ (0, _defineProperty2.default)(this, "observeShadowSentinels", function (isSticky) {
65
+ var _this$table, _this$table2;
73
66
  _this.isSticky = !!isSticky;
74
67
 
75
68
  // update sticky shadows
76
69
  _this.updateStickyShadowsHeightIfChanged();
77
- if (!stickyChanged) {
78
- var firstCell = _this.getFirstCell(isSticky, hasHeaderRow);
79
- var lastCell = _this.getLastCell(isSticky, hasHeaderRow);
80
- if (!firstCell || !lastCell || firstCell === _this.firstCell && lastCell === _this.lastCell) {
81
- return;
82
- }
83
- }
84
- _this.firstCell = _this.getFirstCell(isSticky, hasHeaderRow);
85
- _this.lastCell = _this.getLastCell(isSticky, hasHeaderRow);
86
- if (_this.tableIntersectionObserver && _this.firstCell && _this.lastCell) {
70
+ _this.leftShadowSentinel = (_this$table = _this.table) === null || _this$table === void 0 ? void 0 : _this$table.querySelector(".".concat(_types.TableCssClassName.TABLE_SHADOW_SENTINEL_LEFT));
71
+ _this.rightShadowSentinel = (_this$table2 = _this.table) === null || _this$table2 === void 0 ? void 0 : _this$table2.querySelector(".".concat(_types.TableCssClassName.TABLE_SHADOW_SENTINEL_RIGHT));
72
+ if (_this.tableIntersectionObserver && _this.leftShadowSentinel && _this.rightShadowSentinel && !_this.shadowsObserved) {
87
73
  _this.tableIntersectionObserver.disconnect();
88
- _this.tableIntersectionObserver.observe(_this.firstCell);
89
- _this.tableIntersectionObserver.observe(_this.lastCell);
74
+ _this.tableIntersectionObserver.observe(_this.leftShadowSentinel);
75
+ _this.tableIntersectionObserver.observe(_this.rightShadowSentinel);
76
+ _this.shadowsObserved = true;
90
77
  }
91
78
  });
92
79
  (0, _defineProperty2.default)(this, "updateStickyShadows", function (stickyRowHeight) {
@@ -32,7 +32,6 @@ var _utils4 = require("../utils");
32
32
  var _updateOverflowShadows = require("./update-overflow-shadows");
33
33
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
34
34
  var _OverflowShadowsObserver = require("./OverflowShadowsObserver");
35
- var _misc = require("../pm-plugins/table-resizing/utils/misc");
36
35
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
37
36
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty3.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
38
37
  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); }; }
@@ -65,6 +64,16 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
65
64
  }
66
65
  _this.setState((0, _defineProperty3.default)({}, shadowKey, value));
67
66
  });
67
+ (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "createShadowSentinels", function (table) {
68
+ if (table) {
69
+ var shadowSentinelLeft = document.createElement('span');
70
+ shadowSentinelLeft.className = _types.TableCssClassName.TABLE_SHADOW_SENTINEL_LEFT;
71
+ var shadowSentinelRight = document.createElement('span');
72
+ shadowSentinelRight.className = _types.TableCssClassName.TABLE_SHADOW_SENTINEL_RIGHT;
73
+ table.prepend(shadowSentinelLeft);
74
+ table.prepend(shadowSentinelRight);
75
+ }
76
+ });
68
77
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "onStickyState", function (state) {
69
78
  var _this$props$getEditor = _this.props.getEditorFeatureFlags(),
70
79
  tableOverflowShadowsOptimization = _this$props$getEditor.tableOverflowShadowsOptimization;
@@ -113,6 +122,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
113
122
  if (!tableOverflowShadowsOptimization) {
114
123
  _this.updateShadows();
115
124
  }
125
+ if (_this.wrapper.scrollLeft === 0) {
126
+ _this.setState((0, _defineProperty3.default)({}, _types.ShadowEvent.SHOW_BEFORE_SHADOW, false));
127
+ } else {
128
+ _this.setState((0, _defineProperty3.default)({}, _types.ShadowEvent.SHOW_BEFORE_SHADOW, true));
129
+ }
116
130
  });
117
131
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "handleTableResizing", function () {
118
132
  var _this$props = _this.props,
@@ -251,7 +265,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
251
265
  return;
252
266
  }
253
267
  var parentNodeWith = (0, _nodeWidth.getParentNodeWidth)(pos, state, containerWidth, options && options.isFullWidthModeEnabled);
254
- return (0, _misc.getParentWidthWithoutPadding)(parentNodeWith, pos, state);
268
+ return parentNodeWith;
255
269
  });
256
270
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "updateParentWidth", function (width) {
257
271
  _this.setState({
@@ -368,7 +382,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
368
382
  }
369
383
  if (this.overflowShadowsObserver) {
370
384
  var _this$state$stickyHea;
371
- this.overflowShadowsObserver.observeCells((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky, (0, _utils4.containsHeaderRow)(getNode()));
385
+ this.overflowShadowsObserver.observeShadowSentinels((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky);
372
386
  }
373
387
  }
374
388
  var currentTable = getNode();
@@ -496,6 +510,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
496
510
  var tableElement = elem.querySelector('table');
497
511
  if (tableElement !== _this2.table) {
498
512
  _this2.table = tableElement;
513
+ _this2.createShadowSentinels(_this2.table);
499
514
  }
500
515
  }
501
516
  }
@@ -179,6 +179,13 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
179
179
  if (type === 'selection' && (nodeName === null || nodeName === void 0 ? void 0 : nodeName.toUpperCase()) === 'DIV' && (firstChild === null || firstChild === void 0 ? void 0 : firstChild.nodeName.toUpperCase()) === 'TABLE') {
180
180
  return false;
181
181
  }
182
+
183
+ // ED-16668
184
+ // Do not remove this fixes an issue with windows firefox that relates to
185
+ // the addition of the shadow sentinels
186
+ if (type === 'selection' && (nodeName === null || nodeName === void 0 ? void 0 : nodeName.toUpperCase()) === 'TABLE' && ((firstChild === null || firstChild === void 0 ? void 0 : firstChild.nodeName.toUpperCase()) === 'COLGROUP' || (firstChild === null || firstChild === void 0 ? void 0 : firstChild.nodeName.toUpperCase()) === 'SPAN')) {
187
+ return false;
188
+ }
182
189
  return true;
183
190
  }
184
191
  }, {
@@ -188,7 +188,7 @@ var TableRowNodeView = /*#__PURE__*/function () {
188
188
  (0, _dom.syncStickyRowToTable)(tree.table);
189
189
  }, 0);
190
190
  });
191
- (0, _defineProperty2.default)(this, "onWidthPluginState", function () {
191
+ (0, _defineProperty2.default)(this, "updateStickyHeaderWidth", function () {
192
192
  // table width might have changed, sync that back to sticky row
193
193
  var tree = _this.tree;
194
194
  if (!tree) {
@@ -220,7 +220,7 @@ var TableRowNodeView = /*#__PURE__*/function () {
220
220
  // otherwise make it non-sticky
221
221
  return false;
222
222
  });
223
- (0, _defineProperty2.default)(this, "makeHeaderRowSticky", function (tree) {
223
+ (0, _defineProperty2.default)(this, "makeHeaderRowSticky", function (tree, scrollTop) {
224
224
  var _tbody$firstChild;
225
225
  // If header row height is more than 50% of viewport height don't do this
226
226
  if (_this.stickyRowHeight && _this.stickyRowHeight > window.innerHeight / 2) {
@@ -235,7 +235,10 @@ var TableRowNodeView = /*#__PURE__*/function () {
235
235
  return;
236
236
  }
237
237
  var currentTableTop = _this.getCurrentTableTop(tree);
238
- var domTop = currentTableTop > 0 ? _this.topPosEditorElement : _this.topPosEditorElement + currentTableTop;
238
+ if (!scrollTop) {
239
+ scrollTop = (0, _dom2.getTop)(_this.editorScrollableElement);
240
+ }
241
+ var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
239
242
  if (!_this.isSticky) {
240
243
  (0, _dom.syncStickyRowToTable)(table);
241
244
  _this.dom.classList.add('sticky');
@@ -342,7 +345,7 @@ var TableRowNodeView = /*#__PURE__*/function () {
342
345
  }
343
346
  this.topPosEditorElement = (0, _dom2.getTop)(this.editorScrollableElement);
344
347
  }
345
- this.eventDispatcher.on('widthPlugin', this.onWidthPluginState);
348
+ this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth);
346
349
  this.eventDispatcher.on(_pluginKey.pluginKey.key, this.onTablePluginState);
347
350
  this.listening = true;
348
351
  this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this));
@@ -370,7 +373,7 @@ var TableRowNodeView = /*#__PURE__*/function () {
370
373
  if (this.editorScrollableElement && !this.stickyHeadersOptimization) {
371
374
  this.editorScrollableElement.removeEventListener('scroll', this.onScroll);
372
375
  }
373
- this.eventDispatcher.off('widthPlugin', this.onWidthPluginState);
376
+ this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
374
377
  this.eventDispatcher.off(_pluginKey.pluginKey.key, this.onTablePluginState);
375
378
  this.listening = false;
376
379
  this.dom.removeEventListener('wheel', this.headerRowMouseScroll);
@@ -392,6 +395,9 @@ var TableRowNodeView = /*#__PURE__*/function () {
392
395
  return;
393
396
  }
394
397
  this.resizeObserver.observe(this.dom);
398
+ if (this.editorScrollableElement) {
399
+ this.resizeObserver.observe(this.editorScrollableElement);
400
+ }
395
401
  window.requestAnimationFrame(function () {
396
402
  var _this2$tree;
397
403
  // we expect tree to be defined after animation frame
@@ -422,14 +428,21 @@ var TableRowNodeView = /*#__PURE__*/function () {
422
428
  }
423
429
  var table = _this3.tree.table;
424
430
  entries.forEach(function (entry) {
425
- var newHeight = entry.contentRect ? entry.contentRect.height : entry.target.offsetHeight;
426
- if (_this3.sentinels.bottom &&
427
- // When the table header is sticky, it would be taller by a 1px (border-bottom),
428
- // So we adding this check to allow a 1px difference.
429
- Math.abs(newHeight - (_this3.stickyRowHeight || 0)) > _consts.stickyHeaderBorderBottomWidth) {
430
- _this3.stickyRowHeight = newHeight;
431
- _this3.sentinels.bottom.style.bottom = "".concat(_consts.tableScrollbarOffset + _consts.stickyRowOffsetTop + newHeight, "px");
432
- (0, _dom.updateStickyMargins)(table);
431
+ var _this3$editorScrollab;
432
+ // On resize of the parent scroll element we need to adjust the width
433
+ // of the sticky header
434
+ if (entry.target.className === ((_this3$editorScrollab = _this3.editorScrollableElement) === null || _this3$editorScrollab === void 0 ? void 0 : _this3$editorScrollab.className)) {
435
+ _this3.updateStickyHeaderWidth();
436
+ } else {
437
+ var newHeight = entry.contentRect ? entry.contentRect.height : entry.target.offsetHeight;
438
+ if (_this3.sentinels.bottom &&
439
+ // When the table header is sticky, it would be taller by a 1px (border-bottom),
440
+ // So we adding this check to allow a 1px difference.
441
+ Math.abs(newHeight - (_this3.stickyRowHeight || 0)) > _consts.stickyHeaderBorderBottomWidth) {
442
+ _this3.stickyRowHeight = newHeight;
443
+ _this3.sentinels.bottom.style.bottom = "".concat(_consts.tableScrollbarOffset + _consts.stickyRowOffsetTop + newHeight, "px");
444
+ (0, _dom.updateStickyMargins)(table);
445
+ }
433
446
  }
434
447
  });
435
448
  });
@@ -455,18 +468,20 @@ var TableRowNodeView = /*#__PURE__*/function () {
455
468
  var _entry$rootBounds2;
456
469
  var sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
457
470
  if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
458
- _this4.tree && _this4.makeHeaderRowSticky(_this4.tree);
471
+ var _entry$rootBounds3;
472
+ _this4.tree && _this4.makeHeaderRowSticky(_this4.tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
459
473
  } else {
460
474
  table && _this4.makeRowHeaderNotSticky(table);
461
475
  }
462
476
  }
463
477
  if (target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
464
- var _entry$rootBounds3;
465
- var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this4.dom.offsetHeight < (((_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top) || 0);
478
+ var _entry$rootBounds4;
479
+ var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this4.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
466
480
  if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
467
481
  _this4.makeRowHeaderNotSticky(table);
468
482
  } else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
469
- _this4.tree && _this4.makeHeaderRowSticky(_this4.tree);
483
+ var _entry$rootBounds5;
484
+ _this4.tree && _this4.makeHeaderRowSticky(_this4.tree, entry === null || entry === void 0 ? void 0 : (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
470
485
  }
471
486
  }
472
487
  });
@@ -15,7 +15,6 @@ var _commands = require("./commands");
15
15
  var _pluginFactory = require("./plugin-factory");
16
16
  var _utils3 = require("./utils");
17
17
  var _analytics = require("@atlaskit/editor-common/analytics");
18
- var _misc = require("./utils/misc");
19
18
  var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
20
19
  var state = view.state,
21
20
  dispatch = view.dispatch;
@@ -36,10 +35,7 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
36
35
  }
37
36
  var containerWidth = getEditorContainerWidth();
38
37
  var parentWidth = (0, _nodeWidth.getParentNodeWidth)(start, state, containerWidth);
39
-
40
- // TODO - refactor this logic into getParentNodeWidth() in editor-common [ED-16718]
41
- var parentActualWidth = (0, _misc.getParentWidthWithoutPadding)(parentWidth, start, state);
42
- var maxSize = parentActualWidth || (0, _utils3.getLayoutSize)(dom.getAttribute('data-layout'), containerWidth.width, {});
38
+ var maxSize = parentWidth || (0, _utils3.getLayoutSize)(dom.getAttribute('data-layout'), containerWidth.width, {});
43
39
  if (originalTable.attrs.isNumberColumnEnabled) {
44
40
  maxSize -= _editorSharedStyles.akEditorTableNumberColumnWidth;
45
41
  }
@@ -7,7 +7,7 @@ exports.currentColWidth = currentColWidth;
7
7
  exports.domCellAround = domCellAround;
8
8
  exports.getDefaultLayoutMaxWidth = getDefaultLayoutMaxWidth;
9
9
  exports.getLayoutSize = getLayoutSize;
10
- exports.getTableMaxWidth = exports.getParentWidthWithoutPadding = void 0;
10
+ exports.getTableMaxWidth = void 0;
11
11
  exports.pointsAtCell = pointsAtCell;
12
12
  exports.tableLayoutToSize = void 0;
13
13
  var _styles = require("@atlaskit/editor-common/styles");
@@ -15,8 +15,6 @@ var _ui = require("@atlaskit/editor-common/ui");
15
15
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
16
16
  var _utils = require("@atlaskit/editor-common/utils");
17
17
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
18
- var _constants = require("@atlaskit/theme/constants");
19
- var _prosemirrorUtils = require("prosemirror-utils");
20
18
  var tableLayoutToSize = {
21
19
  default: _editorSharedStyles.akEditorDefaultLayoutWidth,
22
20
  wide: _editorSharedStyles.akEditorWideLayoutWidth,
@@ -84,43 +82,10 @@ var getTableMaxWidth = function getTableMaxWidth(_ref2) {
84
82
  getEditorContainerWidth = _ref2.getEditorContainerWidth;
85
83
  var containerWidth = getEditorContainerWidth();
86
84
  var parentWidth = (0, _nodeWidth.getParentNodeWidth)(tableStart, state, containerWidth);
87
-
88
- // TODO - refactor this logic into getParentNodeWidth() in editor-common [ED-16718]
89
- var parentActualWidth = getParentWidthWithoutPadding(parentWidth, tableStart, state);
90
- var maxWidth = parentActualWidth || getLayoutSize(layout, containerWidth.width, {});
85
+ var maxWidth = parentWidth || getLayoutSize(layout, containerWidth.width, {});
91
86
  if (table.attrs.isNumberColumnEnabled) {
92
87
  maxWidth -= _editorSharedStyles.akEditorTableNumberColumnWidth;
93
88
  }
94
89
  return maxWidth;
95
90
  };
96
- exports.getTableMaxWidth = getTableMaxWidth;
97
- var getParentWidthWithoutPadding = function getParentWidthWithoutPadding(parentWidth, tableStartPos, state) {
98
- var node = getNestedParentNode(tableStartPos, state);
99
- if (!node) {
100
- return;
101
- }
102
- var schema = state.schema;
103
- if (node.type === schema.nodes.expand) {
104
- // padding
105
- parentWidth -= (0, _constants.gridSize)() * 2;
106
- // gutter offset
107
- parentWidth += (0, _constants.gridSize)() * 1.5 * 2;
108
- // padding right
109
- parentWidth -= (0, _constants.gridSize)();
110
- // padding left
111
- parentWidth -= (0, _constants.gridSize)() * 4 - (0, _constants.gridSize)() / 2;
112
- }
113
- return parentWidth;
114
- };
115
-
116
- // copy of getNestedParentNode() from packages/editor/editor-common/src/node-width/index.ts
117
- // to be removed later when we will move getParentWidthWithoutPadding() logic to editor-common
118
- exports.getParentWidthWithoutPadding = getParentWidthWithoutPadding;
119
- var getNestedParentNode = function getNestedParentNode(tablePos, state) {
120
- if (tablePos === undefined) {
121
- return null;
122
- }
123
- var $pos = state.doc.resolve(tablePos);
124
- var parent = (0, _prosemirrorUtils.findParentNodeOfTypeClosestToPos)($pos, [state.schema.nodes.bodiedExtension, state.schema.nodes.layoutSection, state.schema.nodes.expand]);
125
- return parent ? parent.node : null;
126
- };
91
+ exports.getTableMaxWidth = getTableMaxWidth;
@@ -114,7 +114,7 @@ var deleteRows = function deleteRows(rect) {
114
114
  })(tr);
115
115
  }
116
116
  var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
117
- var fixedTable = (0, _merge.removeEmptyColumns)(newTable);
117
+ var fixedTable = (0, _merge.mergeEmptyColumns)(newTable);
118
118
  if (fixedTable === null) {
119
119
  return (0, _metadata.setMeta)({
120
120
  type: 'DELETE_ROWS',
@@ -45,10 +45,10 @@ Object.defineProperty(exports, "mergeCells", {
45
45
  return _merge.mergeCells;
46
46
  }
47
47
  });
48
- Object.defineProperty(exports, "removeEmptyColumns", {
48
+ Object.defineProperty(exports, "mergeEmptyColumns", {
49
49
  enumerable: true,
50
50
  get: function get() {
51
- return _merge.removeEmptyColumns;
51
+ return _merge.mergeEmptyColumns;
52
52
  }
53
53
  });
54
54
  Object.defineProperty(exports, "replaceSelectedTable", {
@@ -69,8 +69,8 @@ Object.defineProperty(exports, "updateColumnWidths", {
69
69
  return _columnWidth.updateColumnWidths;
70
70
  }
71
71
  });
72
- var _merge = require("./merge");
73
72
  var _fixTables = require("./fix-tables");
73
+ var _merge = require("./merge");
74
74
  var _deleteColumns = require("./delete-columns");
75
75
  var _deleteRows = require("./delete-rows");
76
76
  var _columnWidth = require("./column-width");