@atlaskit/editor-plugin-table 14.2.7 → 14.3.0

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 (33) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +24 -65
  3. package/dist/cjs/nodeviews/table.js +14 -128
  4. package/dist/cjs/pm-plugins/utils/analytics.js +33 -1
  5. package/dist/cjs/tablePlugin.js +50 -13
  6. package/dist/cjs/ui/DragHandle/index.js +21 -8
  7. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -18
  8. package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -2
  9. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +1 -18
  10. package/dist/cjs/ui/TableFloatingControls/index.js +3 -45
  11. package/dist/es2019/nodeviews/TableComponent.js +18 -62
  12. package/dist/es2019/nodeviews/table.js +14 -129
  13. package/dist/es2019/pm-plugins/utils/analytics.js +32 -0
  14. package/dist/es2019/tablePlugin.js +39 -1
  15. package/dist/es2019/ui/DragHandle/index.js +15 -5
  16. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -19
  17. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -2
  18. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +2 -19
  19. package/dist/es2019/ui/TableFloatingControls/index.js +5 -47
  20. package/dist/esm/nodeviews/TableComponent.js +24 -65
  21. package/dist/esm/nodeviews/table.js +14 -128
  22. package/dist/esm/pm-plugins/utils/analytics.js +32 -0
  23. package/dist/esm/tablePlugin.js +50 -13
  24. package/dist/esm/ui/DragHandle/index.js +20 -7
  25. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -19
  26. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -2
  27. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +2 -19
  28. package/dist/esm/ui/TableFloatingControls/index.js +5 -47
  29. package/dist/types/pm-plugins/utils/analytics.d.ts +2 -0
  30. package/dist/types/ui/DragHandle/index.d.ts +1 -4
  31. package/dist/types-ts4.5/pm-plugins/utils/analytics.d.ts +2 -0
  32. package/dist/types-ts4.5/ui/DragHandle/index.d.ts +1 -4
  33. package/package.json +10 -22
@@ -11,7 +11,6 @@ var _react = _interopRequireWildcard(require("react"));
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
12
  var _editorTables = require("@atlaskit/editor-tables");
13
13
  var _utils = require("@atlaskit/editor-tables/utils");
14
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
14
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
16
15
  var _commands = require("../../../pm-plugins/commands");
17
16
  var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
@@ -166,23 +165,7 @@ var DragControls = exports.DragControls = function DragControls(_ref) {
166
165
  pointerEvents: 'none'
167
166
  },
168
167
  "data-testid": "table-floating-row-".concat(isHover ? rowIndex : selectedRowIndexes[0], "-drag-handle")
169
- }, (0, _platformFeatureFlags.fg)('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandleWithSharedState, {
170
- isDragMenuTarget: !isHover,
171
- direction: "row",
172
- tableLocalId: currentNodeLocalId,
173
- indexes: indexes,
174
- forceDefaultHandle: !isHover,
175
- previewWidth: tableWidth,
176
- previewHeight: previewHeight,
177
- appearance: appearance,
178
- hoveredCell: hoveredCell,
179
- onClick: handleClick,
180
- onMouseOver: handleMouseOver,
181
- onMouseOut: handleMouseOut,
182
- toggleDragMenu: toggleDragMenuHandler,
183
- editorView: editorView,
184
- api: api
185
- }) : /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
168
+ }, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
186
169
  isDragMenuTarget: !isHover,
187
170
  direction: "row",
188
171
  tableLocalId: currentNodeLocalId,
@@ -13,11 +13,9 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
13
  var _commands = require("../../pm-plugins/commands");
14
14
  var _nodes = require("../../pm-plugins/utils/nodes");
15
15
  var _types = require("../../types");
16
- var _ClassicCornerControls = require("./CornerControls/ClassicCornerControls");
17
16
  var _DragCornerControls = require("./CornerControls/DragCornerControls");
18
17
  var _FloatingControlsWithSelection = require("./FloatingControlsWithSelection");
19
18
  var _NumberColumn = _interopRequireDefault(require("./NumberColumn"));
20
- var _ClassicControls = require("./RowControls/ClassicControls");
21
19
  var _DragControls = require("./RowControls/DragControls");
22
20
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
23
21
  // Row controls
@@ -111,7 +109,7 @@ var TableFloatingControls = exports.TableFloatingControls = function TableFloati
111
109
  updateCellHoverLocation: updateCellHoverLocation,
112
110
  stickyTop: stickyTop,
113
111
  isDragAndDropEnabled: isDragAndDropEnabled
114
- }) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (0, _platformFeatureFlags.fg)('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shouldShowCornerControls && /*#__PURE__*/_react.default.createElement(_DragCornerControls.DragCornerControlsWithSelection, {
112
+ }) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shouldShowCornerControls && /*#__PURE__*/_react.default.createElement(_DragCornerControls.DragCornerControlsWithSelection, {
115
113
  editorView: editorView,
116
114
  tableRef: tableRef,
117
115
  isInDanger: isInDanger,
@@ -135,29 +133,7 @@ var TableFloatingControls = exports.TableFloatingControls = function TableFloati
135
133
  selectRows: _selectRows,
136
134
  updateCellHoverLocation: updateCellHoverLocation,
137
135
  api: api
138
- })) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shouldShowCornerControls && /*#__PURE__*/_react.default.createElement(_DragCornerControls.DragCornerControls, {
139
- editorView: editorView,
140
- tableRef: tableRef,
141
- isInDanger: isInDanger,
142
- isResizing: isResizing
143
- }), /*#__PURE__*/_react.default.createElement(_DragControls.DragControls, {
144
- tableRef: tableRef,
145
- tableNode: tableNode,
146
- hoveredCell: hoveredCell,
147
- isTableHovered: isTableHovered,
148
- editorView: editorView,
149
- tableActive: tableActive,
150
- isInDanger: isInDanger,
151
- isResizing: isResizing
152
- // Ignored via go/ees005
153
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
154
- ,
155
- tableWidth: tableWrapperWidth,
156
- hoverRows: _hoverRows,
157
- selectRow: _selectRow,
158
- selectRows: _selectRows,
159
- updateCellHoverLocation: updateCellHoverLocation
160
- }))) : (0, _platformFeatureFlags.fg)('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/_react.default.createElement(_FloatingControlsWithSelection.FloatingControlsWithSelection, {
136
+ })) : /*#__PURE__*/_react.default.createElement(_FloatingControlsWithSelection.FloatingControlsWithSelection, {
161
137
  editorView: editorView,
162
138
  tableRef: tableRef,
163
139
  isInDanger: isInDanger,
@@ -170,25 +146,7 @@ var TableFloatingControls = exports.TableFloatingControls = function TableFloati
170
146
  hoverRows: _hoverRows,
171
147
  selectRow: _selectRow,
172
148
  api: api
173
- }) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ClassicCornerControls.CornerControls, {
174
- editorView: editorView,
175
- tableRef: tableRef,
176
- isInDanger: isInDanger,
177
- isResizing: isResizing,
178
- isHeaderRowEnabled: isHeaderRowEnabled,
179
- isHeaderColumnEnabled: isHeaderColumnEnabled,
180
- hoveredRows: hoveredRows,
181
- stickyTop: tableActive ? stickyTop : undefined
182
- }), /*#__PURE__*/_react.default.createElement(_ClassicControls.RowControls, {
183
- editorView: editorView,
184
- tableRef: tableRef,
185
- hoverRows: _hoverRows,
186
- hoveredRows: hoveredRows,
187
- isInDanger: isInDanger,
188
- isResizing: isResizing,
189
- selectRow: _selectRow,
190
- stickyTop: tableActive ? stickyTop : undefined
191
- })))))
149
+ }))))
192
150
  );
193
151
  };
194
152
  var _default = exports.default = TableFloatingControls;
@@ -19,7 +19,6 @@ import UFOLoadHold from '@atlaskit/react-ufo/load-hold';
19
19
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
20
  import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
21
21
  import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils/autoscrollers';
22
- import { getPluginState } from '../pm-plugins/plugin-factory';
23
22
  import { pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers/plugin-key';
24
23
  import { findStickyHeaderForTable } from '../pm-plugins/sticky-headers/util';
25
24
  import { META_KEYS } from '../pm-plugins/table-analytics';
@@ -503,14 +502,8 @@ class TableComponent extends React.Component {
503
502
  this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
504
503
  passive: true
505
504
  });
506
- if (fg('disable-sticky-scrollbar-for-nested-tables')) {
507
- if (this.table && !this.isNestedInTable) {
508
- this.stickyScrollbar = new TableStickyScrollbar(this.wrapper, this.props.view);
509
- }
510
- } else {
511
- if (this.table) {
512
- this.stickyScrollbar = new TableStickyScrollbar(this.wrapper, this.props.view);
513
- }
505
+ if (this.table && !this.isNestedInTable) {
506
+ this.stickyScrollbar = new TableStickyScrollbar(this.wrapper, this.props.view);
514
507
  }
515
508
  if (isDragAndDropEnabled) {
516
509
  this.dragAndDropCleanupFn = combine(...autoScrollerFactory({
@@ -775,16 +768,10 @@ class TableComponent extends React.Component {
775
768
  isTableScalingEnabled,
776
769
  // we could use options.isTableScalingEnabled here
777
770
  getPos,
778
- getEditorFeatureFlags
779
- } = this.props;
780
- let {
771
+ getEditorFeatureFlags,
781
772
  isInDanger
782
773
  } = this.props;
783
774
  const table = findTable(view.state.selection);
784
- if (!fg('platform_editor_table_use_shared_state_hook_fg')) {
785
- const pluginState = getPluginState(view.state);
786
- isInDanger = pluginState.isInDanger;
787
- }
788
775
  let shouldScale = false;
789
776
  let shouldHandleColgroupUpdates = false;
790
777
  const {
@@ -806,14 +793,21 @@ class TableComponent extends React.Component {
806
793
  if (shouldHandleColgroupUpdates) {
807
794
  this.handleColgroupUpdates();
808
795
  }
809
- if (isInDanger && !table) {
810
- clearHoverSelection()(view.state, view.dispatch);
796
+
797
+ // table is always defined so this never runs
798
+ if (!expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
799
+ if (isInDanger && !table) {
800
+ clearHoverSelection()(view.state, view.dispatch);
801
+ }
811
802
  }
812
803
  if ((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
813
804
  this.removeInlineTableWidth();
814
805
  }
815
806
  if ((_this$wrapper2 = this.wrapper) !== null && _this$wrapper2 !== void 0 && _this$wrapper2.parentElement && this.table && !this.overflowShadowsObserver) {
816
- if (this.props.isDragAndDropEnabled) {
807
+ // isDragAndDropEnabled will be false when the editorViewMode is 'live' and so the fix below is never triggered
808
+ // but the shadow observer must run async so its initial state is correct.
809
+ // note: when cleaning up platform_editor_table_drag_handle_hover entirely remove this nested if check incl. this.props.isDragAndDropEnabled
810
+ if (this.props.isDragAndDropEnabled || expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
817
811
  // requestAnimationFrame is used here to fix a race condition issue
818
812
  // that happens when a table is nested in expand and expand's width is
819
813
  // changed via breakout button
@@ -919,9 +913,7 @@ class TableComponent extends React.Component {
919
913
  // here we can use options.isTableScalingEnabled
920
914
  allowTableResizing,
921
915
  allowTableAlignment,
922
- selection
923
- } = this.props;
924
- let {
916
+ selection,
925
917
  isInDanger,
926
918
  hoveredRows,
927
919
  hoveredCell,
@@ -933,14 +925,6 @@ class TableComponent extends React.Component {
933
925
  showAfterShadow
934
926
  } = this.state;
935
927
  const node = getNode();
936
- if (!fg('platform_editor_table_use_shared_state_hook_fg')) {
937
- const pluginState = getPluginState(view.state);
938
- isInDanger = pluginState.isInDanger;
939
- hoveredRows = pluginState.hoveredRows;
940
- hoveredCell = pluginState.hoveredCell;
941
- isTableHovered = pluginState.isTableHovered;
942
- isWholeTableInDanger = pluginState.isWholeTableInDanger;
943
- }
944
928
  const tableRef = this.table || undefined;
945
929
  const headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
946
930
  const hasHeaderRow = containsHeaderRow(node);
@@ -1058,11 +1042,7 @@ class TableComponent extends React.Component {
1058
1042
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1059
1043
  className: ClassName.TABLE_STICKY_SENTINEL_TOP,
1060
1044
  "data-testid": "sticky-sentinel-top"
1061
- }), fg('disable-sticky-scrollbar-for-nested-tables') ? !this.isNestedInTable && /*#__PURE__*/React.createElement("div", {
1062
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1063
- className: ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
1064
- "data-testid": "sticky-scrollbar-sentinel-top"
1065
- }) : /*#__PURE__*/React.createElement("div", {
1045
+ }), !this.isNestedInTable && /*#__PURE__*/React.createElement("div", {
1066
1046
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1067
1047
  className: ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
1068
1048
  "data-testid": "sticky-scrollbar-sentinel-top"
@@ -1108,7 +1088,7 @@ class TableComponent extends React.Component {
1108
1088
  }
1109
1089
  }
1110
1090
  }
1111
- }, allowControls && colControls), fg('disable-sticky-scrollbar-for-nested-tables') ? !this.isNestedInTable ? /*#__PURE__*/React.createElement("div", {
1091
+ }, allowControls && colControls), !this.isNestedInTable ? /*#__PURE__*/React.createElement("div", {
1112
1092
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1113
1093
  className: ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
1114
1094
  "data-vc-nvs": "true",
@@ -1135,27 +1115,7 @@ class TableComponent extends React.Component {
1135
1115
  height: '100%'
1136
1116
  },
1137
1117
  "data-vc-nvs": "true"
1138
- }) : /*#__PURE__*/React.createElement("div", {
1139
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1140
- className: ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
1141
- style: {
1142
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1143
- height: "var(--ds-space-250, 20px)",
1144
- // MAX_BROWSER_SCROLLBAR_HEIGHT
1145
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1146
- display: 'none',
1147
- // prevent unwanted scroll during table resize without removing scrollbar container from the dom
1148
- width: isResizing ? "var(--ds-space-0, 0px)" : '100%'
1149
- },
1150
- "data-vc-nvs": "true"
1151
- }, /*#__PURE__*/React.createElement("div", {
1152
- style: {
1153
- width: tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth,
1154
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1155
- height: '100%'
1156
- },
1157
- "data-vc-nvs": "true"
1158
- })), /*#__PURE__*/React.createElement("div", {
1118
+ }), /*#__PURE__*/React.createElement("div", {
1159
1119
  contentEditable: false
1160
1120
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1161
1121
  ,
@@ -1182,11 +1142,7 @@ class TableComponent extends React.Component {
1182
1142
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1183
1143
  className: ClassName.TABLE_STICKY_SENTINEL_BOTTOM,
1184
1144
  "data-testid": "sticky-sentinel-bottom"
1185
- }), fg('disable-sticky-scrollbar-for-nested-tables') ? !this.isNestedInTable && /*#__PURE__*/React.createElement("div", {
1186
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1187
- className: ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM,
1188
- "data-testid": "sticky-scrollbar-sentinel-bottom"
1189
- }) : /*#__PURE__*/React.createElement("div", {
1145
+ }), !this.isNestedInTable && /*#__PURE__*/React.createElement("div", {
1190
1146
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1191
1147
  className: ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM,
1192
1148
  "data-testid": "sticky-scrollbar-sentinel-bottom"
@@ -2,20 +2,15 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
4
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
6
5
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
7
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
8
7
  import { TableMap } from '@atlaskit/editor-tables/table-map';
9
8
  import { fg } from '@atlaskit/platform-feature-flags';
10
9
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
10
  import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
12
- import { pluginKey as tableDragAndDropPluginKey } from '../pm-plugins/drag-and-drop/plugin-key';
13
11
  import { getPluginState } from '../pm-plugins/plugin-factory';
14
- import { pluginKey } from '../pm-plugins/plugin-key';
15
- import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizing/plugin-key';
16
12
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
17
13
  import { isTableNested } from '../pm-plugins/utils/nodes';
18
- import TableComponent from './TableComponent';
19
14
  import { TableComponentWithSharedState } from './TableComponentWithSharedState';
20
15
  import { tableNodeSpecWithFixedToDOM } from './toDOM';
21
16
  const tableAttributes = node => {
@@ -183,130 +178,20 @@ export default class TableView extends ReactNodeView {
183
178
  }
184
179
  }
185
180
  render(props, forwardRef) {
186
- var _props$pluginInjectio, _props$pluginInjectio2, _props$pluginInjectio3;
187
- if (fg('platform_editor_table_use_shared_state_hook_fg')) {
188
- return /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
189
- forwardRef: forwardRef,
190
- getNode: this.getNode,
191
- view: props.view,
192
- options: props.options,
193
- eventDispatcher: props.eventDispatcher,
194
- api: props.pluginInjectionApi,
195
- allowColumnResizing: props.allowColumnResizing,
196
- allowTableAlignment: props.allowTableAlignment,
197
- allowTableResizing: props.allowTableResizing,
198
- allowControls: props.allowControls,
199
- getPos: props.getPos,
200
- getEditorFeatureFlags: props.getEditorFeatureFlags,
201
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent
202
- });
203
- }
204
- // Please, do not copy or use this kind of code below
205
- // @ts-ignore
206
- const fakePluginKey = {
207
- key: 'widthPlugin$',
208
- getState: state => {
209
- // Ignored via go/ees005
210
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
211
- return state['widthPlugin$'];
212
- }
213
- };
214
-
215
- // Please, do not copy or use this kind of code below
216
- // @ts-ignore
217
- const fakeMediaPluginKey = {
218
- key: 'mediaPlugin$',
219
- getState: state => {
220
- // Ignored via go/ees005
221
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
222
- return state['mediaPlugin$'];
223
- }
224
- };
225
- return /*#__PURE__*/React.createElement(WithPluginState, {
226
- plugins: {
227
- pluginState: pluginKey,
228
- tableResizingPluginState: tableResizingPluginKey,
229
- tableWidthPluginState: tableWidthPluginKey,
230
- widthPlugin: fakePluginKey,
231
- mediaState: fakeMediaPluginKey,
232
- tableDragAndDropState: tableDragAndDropPluginKey,
233
- limitedModePlugin: (_props$pluginInjectio = props.pluginInjectionApi) === null || _props$pluginInjectio === void 0 ? void 0 : (_props$pluginInjectio2 = _props$pluginInjectio.limitedMode) === null || _props$pluginInjectio2 === void 0 ? void 0 : (_props$pluginInjectio3 = _props$pluginInjectio2.sharedState.currentState()) === null || _props$pluginInjectio3 === void 0 ? void 0 : _props$pluginInjectio3.limitedModePluginKey
234
- },
235
- editorView: props.view,
236
- render: pluginStates => {
237
- var _props$options, _pluginStates$limited, _pluginStates$limited2;
238
- const {
239
- tableResizingPluginState,
240
- tableWidthPluginState,
241
- pluginState,
242
- mediaState
243
- } = pluginStates;
244
- const containerWidth = props.getEditorContainerWidth();
245
- const isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
246
- const isResizing = Boolean((tableResizingPluginState === null || tableResizingPluginState === void 0 ? void 0 : tableResizingPluginState.dragging) || isTableResizing);
247
-
248
- /**
249
- * ED-19810
250
- * There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
251
- * directly to confluence since this bug is now in production.
252
- */
253
- let tablePos;
254
- try {
255
- tablePos = props.getPos ? props.getPos() : undefined;
256
- } catch (e) {
257
- tablePos = undefined;
258
- }
259
-
260
- // Ignored via go/ees005
261
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
262
- const tableActive = tablePos === pluginState.tablePos && !isTableResizing;
263
- return /*#__PURE__*/React.createElement(TableComponent, {
264
- view: props.view,
265
- allowColumnResizing: props.allowColumnResizing,
266
- eventDispatcher: props.eventDispatcher,
267
- getPos: props.getPos,
268
- isMediaFullscreen: mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen,
269
- options: props.options
270
- // Ignored via go/ees005
271
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
272
- // Ignored via go/ees005
273
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
274
- ,
275
- allowControls: pluginState.pluginConfig.allowControls
276
- // Ignored via go/ees005
277
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
278
- ,
279
- isHeaderRowEnabled: pluginState.isHeaderRowEnabled
280
- // Ignored via go/ees005
281
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
282
- ,
283
- isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled
284
- // Ignored via go/ees005
285
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
286
- ,
287
- isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
288
- isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled same as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
289
- ,
290
- allowTableAlignment: props.allowTableAlignment,
291
- allowTableResizing: props.allowTableResizing,
292
- tableActive: tableActive
293
- // Ignored via go/ees005
294
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
295
- ,
296
- ordering: pluginState.ordering,
297
- isResizing: isResizing,
298
- getNode: this.getNode
299
- // Ignored via go/ees005
300
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
301
- ,
302
- containerWidth: containerWidth,
303
- contentDOM: forwardRef,
304
- getEditorFeatureFlags: props.getEditorFeatureFlags,
305
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
306
- pluginInjectionApi: props.pluginInjectionApi,
307
- limitedMode: (_pluginStates$limited = (_pluginStates$limited2 = pluginStates.limitedModePlugin) === null || _pluginStates$limited2 === void 0 ? void 0 : _pluginStates$limited2.documentSizeBreachesThreshold) !== null && _pluginStates$limited !== void 0 ? _pluginStates$limited : false
308
- });
309
- }
181
+ return /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
182
+ forwardRef: forwardRef,
183
+ getNode: this.getNode,
184
+ view: props.view,
185
+ options: props.options,
186
+ eventDispatcher: props.eventDispatcher,
187
+ api: props.pluginInjectionApi,
188
+ allowColumnResizing: props.allowColumnResizing,
189
+ allowTableAlignment: props.allowTableAlignment,
190
+ allowTableResizing: props.allowTableResizing,
191
+ allowControls: props.allowControls,
192
+ getPos: props.getPos,
193
+ getEditorFeatureFlags: props.getEditorFeatureFlags,
194
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent
310
195
  });
311
196
  }
312
197
  viewShouldUpdate(nextNode) {
@@ -184,4 +184,36 @@ export const useMeasureFramerate = (config = {}) => {
184
184
  endMeasure,
185
185
  countFrames
186
186
  };
187
+ };
188
+ const tableContainerNodes = new Set(['layoutSection', 'layoutColumn', 'expand', 'nestedExpand', 'extension', 'bodiedExtension', 'multiBodiedExtension', 'extensionFrame', 'table', 'tableCell', 'tableHeader', 'tableRow']);
189
+ export const getWidthInfoPayload = (editorView, editorWidth) => {
190
+ const tablesInfo = [];
191
+ editorView.state.doc.nodesBetween(0, editorView.state.doc.content.size, (node, pos, parent) => {
192
+ if (!tableContainerNodes.has(node.type.name)) {
193
+ return false;
194
+ }
195
+ if (node.type.name === 'table') {
196
+ var _domAtPos$node;
197
+ const domAtPos = editorView.domAtPos(pos + 1);
198
+ const table = (_domAtPos$node = domAtPos.node) === null || _domAtPos$node === void 0 ? void 0 : _domAtPos$node.parentElement;
199
+ const isNestedTable = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableCell' || (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableHeader';
200
+ if (table instanceof HTMLTableElement) {
201
+ tablesInfo.push({
202
+ tableWidth: table.scrollWidth,
203
+ isNestedTable: isNestedTable,
204
+ hasScrollbar: table.parentElement ? (table === null || table === void 0 ? void 0 : table.parentElement.clientWidth) < table.scrollWidth : false
205
+ });
206
+ }
207
+ }
208
+ });
209
+ return {
210
+ action: TABLE_ACTION.TABLE_WIDTH_INFO,
211
+ actionSubject: ACTION_SUBJECT.TABLE,
212
+ attributes: {
213
+ editorWidth: editorWidth,
214
+ tableWidthInfo: tablesInfo,
215
+ mode: 'editor'
216
+ },
217
+ eventType: EVENT_TYPE.OPERATIONAL
218
+ };
187
219
  };
@@ -12,6 +12,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
12
12
  import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
13
13
  import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
16
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
17
  import { tableNodeSpecWithFixedToDOM } from './nodeviews/toDOM';
17
18
  import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
@@ -35,12 +36,16 @@ import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap'
35
36
  import { createPlugin as createSizeSelectorPlugin, pluginKey as sizeSelectorPluginKey } from './pm-plugins/table-size-selector';
36
37
  import { createPlugin as createTableWidthPlugin, pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
37
38
  import { createPlugin as createTableWidthInCommentFixPlugin } from './pm-plugins/table-width-in-comment-fix';
39
+ import { getWidthInfoPayload } from './pm-plugins/utils/analytics';
38
40
  import { createTableWithWidth } from './pm-plugins/utils/create';
39
41
  import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
40
42
  import { ContentComponent } from './ui/ContentComponent';
41
43
  import { getToolbarConfig } from './ui/toolbar';
42
44
  const defaultGetEditorFeatureFlags = () => ({});
43
45
 
46
+ // we want to calculate all the table widths (which causes reflows) after the editor has finished loading to mitigate performance impact
47
+ const TABLE_WIDTH_INFO_TIMEOUT = 10000;
48
+
44
49
  /**
45
50
  * Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
46
51
  * from `@atlaskit/editor-core`.
@@ -398,13 +403,46 @@ const tablePlugin = ({
398
403
  }) => createTableAnalyticsPlugin(dispatch, dispatchAnalyticsEvent)
399
404
  }, {
400
405
  name: 'tableGetEditorViewReferencePlugin',
401
- plugin: () => {
406
+ plugin: ({
407
+ dispatchAnalyticsEvent
408
+ }) => {
402
409
  return new SafePlugin({
403
410
  view: editorView => {
404
411
  editorViewRef.current = editorView;
412
+ let setTimeoutID;
413
+ let rafID;
414
+ let ricID;
415
+ if (expValEquals('platform_editor_editor_width_analytics', 'isEnabled', true)) {
416
+ // send statistics about the widths of the tables on the page for alerting
417
+ // only send this event once, after the editorView is first initialised
418
+ setTimeoutID = setTimeout(() => {
419
+ const requestIdleCallbackFn = () => {
420
+ var _api$width$sharedStat2;
421
+ const editorWidth = api === null || api === void 0 ? void 0 : (_api$width$sharedStat2 = api.width.sharedState.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width;
422
+ if (editorWidth && editorViewRef.current) {
423
+ dispatchAnalyticsEvent(getWidthInfoPayload(editorViewRef.current, editorWidth));
424
+ }
425
+ };
426
+ if (window && typeof window.requestIdleCallback === 'function') {
427
+ ricID = window.requestIdleCallback(requestIdleCallbackFn);
428
+ } else if (window && typeof window.requestAnimationFrame === 'function') {
429
+ // requestIdleCallback is not supported in safari, fallback to requestAnimationFrame
430
+ rafID = window.requestAnimationFrame(requestIdleCallbackFn);
431
+ }
432
+ }, TABLE_WIDTH_INFO_TIMEOUT);
433
+ }
405
434
  return {
406
435
  destroy: () => {
407
436
  editorViewRef.current = null;
437
+ if (setTimeoutID) {
438
+ clearTimeout(setTimeoutID);
439
+ }
440
+ if (rafID) {
441
+ window.cancelAnimationFrame(rafID);
442
+ }
443
+ if (ricID) {
444
+ window.cancelIdleCallback(ricID);
445
+ }
408
446
  }
409
447
  };
410
448
  }
@@ -59,6 +59,7 @@ const DragHandleComponent = ({
59
59
  const {
60
60
  isDragMenuOpen = false
61
61
  } = getDnDPluginState(state);
62
+ const [isHovered, setIsHovered] = useState(false);
62
63
  const isRow = direction === 'row';
63
64
  const isColumn = direction === 'column';
64
65
 
@@ -100,7 +101,7 @@ const DragHandleComponent = ({
100
101
  }, [indexes, selection, direction, hoveredCell]);
101
102
  const handleIconProps = {
102
103
  forceDefaultHandle,
103
- isHandleHovered: isColumnHandleHovered || isRowHandleHovered,
104
+ isHandleHovered: expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true) ? isHovered : isColumnHandleHovered || isRowHandleHovered,
104
105
  hasMergedCells
105
106
  };
106
107
  useEffect(() => {
@@ -212,10 +213,20 @@ const DragHandleComponent = ({
212
213
  "aria-haspopup": "menu"
213
214
  // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
214
215
  ,
215
- onMouseOver: onMouseOver
216
+ onMouseOver: e => {
217
+ if (expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
218
+ setIsHovered(true);
219
+ }
220
+ onMouseOver && onMouseOver(e);
221
+ }
216
222
  // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
217
223
  ,
218
- onMouseOut: onMouseOut,
224
+ onMouseOut: e => {
225
+ if (expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
226
+ setIsHovered(false);
227
+ }
228
+ onMouseOut && onMouseOut(e);
229
+ },
219
230
  onMouseUp: e => {
220
231
  // return focus to editor so copying table selections whilst still works, i cannot call e.preventDefault in a mousemove event as this stops dragstart events from firing
221
232
  // -> this is bad for a11y but is the current standard new copy/paste keyboard shortcuts should be introduced instead
@@ -298,5 +309,4 @@ const DragHandleComponentWithSharedState = ({
298
309
  hoveredRows: hoveredRows
299
310
  });
300
311
  };
301
- export const DragHandle = injectIntl(DragHandleComponent);
302
- export const DragHandleWithSharedState = injectIntl(DragHandleComponentWithSharedState);
312
+ export const DragHandle = injectIntl(DragHandleComponentWithSharedState);
@@ -6,13 +6,12 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
7
  import { CellSelection } from '@atlaskit/editor-tables';
8
8
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
9
- import { fg } from '@atlaskit/platform-feature-flags';
10
9
  import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../pm-plugins/commands';
11
10
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
12
11
  import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
13
12
  import { getSelectedColumnIndexes } from '../../../pm-plugins/utils/selection';
14
13
  import { TableCssClassName as ClassName } from '../../../types';
15
- import { DragHandle, DragHandleWithSharedState } from '../../DragHandle';
14
+ import { DragHandle } from '../../DragHandle';
16
15
  const getSelectedColumns = selection => {
17
16
  if (selection instanceof CellSelection && selection.isColSelection()) {
18
17
  const rect = getSelectionRect(selection);
@@ -173,23 +172,7 @@ export const ColumnControls = ({
173
172
  position: 'relative'
174
173
  },
175
174
  "data-testid": `table-floating-column-${isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0]}-drag-handle`
176
- }, fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(DragHandleWithSharedState, {
177
- isDragMenuTarget: !isHover,
178
- direction: "column",
179
- tableLocalId: localId || '',
180
- indexes: indexes,
181
- hoveredCell: hoveredCell,
182
- previewWidth: previewWidth,
183
- forceDefaultHandle: !isHover,
184
- previewHeight: previewHeight,
185
- appearance: appearance,
186
- onClick: handleClick,
187
- onMouseOver: handleMouseOver,
188
- onMouseOut: handleMouseOut,
189
- toggleDragMenu: toggleDragMenuHandler,
190
- editorView: editorView,
191
- api: api
192
- }) : /*#__PURE__*/React.createElement(DragHandle, {
175
+ }, /*#__PURE__*/React.createElement(DragHandle, {
193
176
  isDragMenuTarget: !isHover,
194
177
  direction: "column",
195
178
  tableLocalId: localId || '',
@@ -1,5 +1,4 @@
1
1
  import React, { useEffect, useMemo, useRef, useState } from 'react';
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
2
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
4
3
  import { getColumnsWidths } from '../../pm-plugins/utils/column-controls';
5
4
  import { containsHeaderColumn } from '../../pm-plugins/utils/nodes';
@@ -93,7 +92,7 @@ const TableFloatingColumnControls = ({
93
92
  isNumberColumnEnabled: isNumberColumnEnabled,
94
93
  isDragging: isDragging,
95
94
  getScrollOffset: getScrollOffset,
96
- api: fg('platform_editor_table_use_shared_state_hook_fg') ? api : undefined
95
+ api: api
97
96
  }), isDragging && /*#__PURE__*/React.createElement(ColumnDropTargets, {
98
97
  tableRef: tableRef,
99
98
  isHeaderSticky: (stickyHeader === null || stickyHeader === void 0 ? void 0 : stickyHeader.sticky) && hasHeaderRow,