@atlaskit/editor-plugin-table 7.6.3 → 7.6.4

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 (45) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/commands/misc.js +3 -2
  3. package/dist/cjs/nodeviews/TableContainer.js +32 -20
  4. package/dist/cjs/nodeviews/TableResizer.js +39 -27
  5. package/dist/cjs/plugin.js +2 -1
  6. package/dist/cjs/toolbar.js +5 -4
  7. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  8. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -3
  9. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +21 -28
  10. package/dist/cjs/utils/guidelines.js +1 -1
  11. package/dist/es2019/commands/misc.js +6 -2
  12. package/dist/es2019/nodeviews/TableContainer.js +17 -3
  13. package/dist/es2019/nodeviews/TableResizer.js +26 -16
  14. package/dist/es2019/plugin.js +2 -1
  15. package/dist/es2019/toolbar.js +5 -4
  16. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  17. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -3
  18. package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +20 -27
  19. package/dist/es2019/utils/guidelines.js +1 -1
  20. package/dist/esm/commands/misc.js +3 -2
  21. package/dist/esm/nodeviews/TableContainer.js +32 -20
  22. package/dist/esm/nodeviews/TableResizer.js +40 -28
  23. package/dist/esm/plugin.js +2 -1
  24. package/dist/esm/toolbar.js +5 -4
  25. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  26. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -3
  27. package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +21 -28
  28. package/dist/esm/utils/guidelines.js +1 -1
  29. package/dist/types/commands/misc.d.ts +2 -1
  30. package/dist/types/nodeviews/TableResizer.d.ts +3 -1
  31. package/dist/types/types.d.ts +6 -3
  32. package/dist/types-ts4.5/commands/misc.d.ts +2 -1
  33. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +3 -1
  34. package/dist/types-ts4.5/types.d.ts +6 -3
  35. package/package.json +2 -5
  36. package/src/commands/misc.ts +6 -3
  37. package/src/nodeviews/TableContainer.tsx +18 -3
  38. package/src/nodeviews/TableResizer.tsx +34 -20
  39. package/src/plugin.tsx +1 -0
  40. package/src/toolbar.tsx +20 -19
  41. package/src/types.ts +6 -2
  42. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +66 -112
  43. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -12
  44. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +19 -28
  45. package/src/utils/guidelines.ts +5 -4
@@ -8,17 +8,16 @@ import rafSchd from 'raf-schd';
8
8
  import { useIntl } from 'react-intl-next';
9
9
  import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
10
10
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
11
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
12
  import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
12
13
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
14
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
14
15
  import { browser } from '@atlaskit/editor-common/utils';
15
- import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
16
16
  import { findTable } from '@atlaskit/editor-tables/utils';
17
17
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
18
18
  import { updateWidthToWidest } from '../commands/misc';
19
- import { getPluginState } from '../pm-plugins/plugin-factory';
20
19
  import { META_KEYS } from '../pm-plugins/table-analytics';
21
- import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
20
+ import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
22
21
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
23
22
  import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
24
23
  import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
@@ -91,28 +90,37 @@ export var TableResizer = function TableResizer(_ref) {
91
90
  attachAnalyticsEvent = _ref.attachAnalyticsEvent,
92
91
  displayGapCursor = _ref.displayGapCursor,
93
92
  isTableScalingEnabled = _ref.isTableScalingEnabled,
94
- isWholeTableInDanger = _ref.isWholeTableInDanger;
93
+ isWholeTableInDanger = _ref.isWholeTableInDanger,
94
+ pluginInjectionApi = _ref.pluginInjectionApi;
95
95
  var currentGap = useRef(0);
96
96
  // track resizing state - use ref over state to avoid re-render
97
97
  var isResizing = useRef(false);
98
98
  var areResizeMetaKeysPressed = useRef(false);
99
+ var _useState = useState(width),
100
+ _useState2 = _slicedToArray(_useState, 2),
101
+ localTableWidth = _useState2[0],
102
+ setLocalTableWidth = _useState2[1];
99
103
  var resizerRef = useRef(null);
104
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table']),
105
+ tableState = _useSharedPluginState.tableState;
106
+ var _ref2 = tableState,
107
+ widthToWidest = _ref2.widthToWidest;
100
108
 
101
109
  // used to reposition tooltip when table is resizing via keyboard
102
110
  var updateTooltip = React.useRef();
103
- var _useState = useState(false),
104
- _useState2 = _slicedToArray(_useState, 2),
105
- snappingEnabled = _useState2[0],
106
- setSnappingEnabled = _useState2[1];
111
+ var _useState3 = useState(false),
112
+ _useState4 = _slicedToArray(_useState3, 2),
113
+ snappingEnabled = _useState4[0],
114
+ setSnappingEnabled = _useState4[1];
107
115
 
108
116
  // we don't want to update aria-live region on each width change, it might provide bad experience for screen reader users
109
- var _useState3 = useState({
117
+ var _useState5 = useState({
110
118
  type: 'none',
111
119
  width: width
112
120
  }),
113
- _useState4 = _slicedToArray(_useState3, 2),
114
- screenReaderResizeInformation = _useState4[0],
115
- setScreenReaderResizeInformation = _useState4[1];
121
+ _useState6 = _slicedToArray(_useState5, 2),
122
+ screenReaderResizeInformation = _useState6[0],
123
+ setScreenReaderResizeInformation = _useState6[1];
116
124
  var _useIntl = useIntl(),
117
125
  formatMessage = _useIntl.formatMessage;
118
126
  var screenReaderResizeAnnouncerMessages = {
@@ -131,9 +139,9 @@ export var TableResizer = function TableResizer(_ref) {
131
139
  startMeasure = _useMeasureFramerate.startMeasure,
132
140
  endMeasure = _useMeasureFramerate.endMeasure,
133
141
  countFrames = _useMeasureFramerate.countFrames;
134
- var updateActiveGuidelines = useCallback(function (_ref2) {
135
- var gap = _ref2.gap,
136
- keys = _ref2.keys;
142
+ var updateActiveGuidelines = useCallback(function (_ref3) {
143
+ var gap = _ref3.gap,
144
+ keys = _ref3.keys;
137
145
  if (gap !== currentGap.current) {
138
146
  currentGap.current = gap;
139
147
  var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
@@ -181,7 +189,7 @@ export var TableResizer = function TableResizer(_ref) {
181
189
  }
182
190
  }, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
183
191
  var handleResize = useCallback(function (originalState, delta) {
184
- var _defaultGuidelinesFor;
192
+ var _node$attrs$localId, _node$attrs, _widestGuideline$posi;
185
193
  countFrames();
186
194
  var newWidth = originalState.width + delta.width;
187
195
  var pos;
@@ -206,25 +214,29 @@ export var TableResizer = function TableResizer(_ref) {
206
214
  // set the width of the table to 1800 pixels.
207
215
  var state = editorView.state,
208
216
  dispatch = editorView.dispatch;
209
- var widestGuideLineWidthString = (_defaultGuidelinesFor = defaultGuidelinesForPreserveTable(containerWidth)[16].key) === null || _defaultGuidelinesFor === void 0 || (_defaultGuidelinesFor = _defaultGuidelinesFor.match(/[\d]*[.]{0,1}[\d]+/g)) === null || _defaultGuidelinesFor === void 0 ? void 0 : _defaultGuidelinesFor.join('');
210
- var widestGuideLineWidth = parseInt(widestGuideLineWidthString || '', 10);
211
- var shouldUpdateWidthToWidest = !!(isTableScalingEnabled && defaultGuidelinesForPreserveTable(containerWidth).length === 17 && widestGuideLineWidth - newWidth <= 1);
212
- updateWidthToWidest(shouldUpdateWidthToWidest)(state, dispatch);
213
- updateWidth(shouldUpdateWidthToWidest ? akEditorFullWidthLayoutWidth : newWidth);
217
+ var currentTableNodeLocalId = (_node$attrs$localId = node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) !== null && _node$attrs$localId !== void 0 ? _node$attrs$localId : '';
218
+ var widestGuideline = defaultGuidelinesForPreserveTable(containerWidth).filter(function (guideline) {
219
+ return guideline.isFullWidth;
220
+ })[0];
221
+ var widestGuideLineWidth = widestGuideline ? (((_widestGuideline$posi = widestGuideline.position) === null || _widestGuideline$posi === void 0 ? void 0 : _widestGuideline$posi.x) || 0) * 2 : null;
222
+ var shouldUpdateWidthToWidest = !!(isTableScalingEnabled && widestGuideLineWidth && Math.abs(widestGuideLineWidth - newWidth) <= 1);
223
+ shouldUpdateWidthToWidest ? setLocalTableWidth(TABLE_MAX_WIDTH) : setLocalTableWidth(newWidth);
224
+ updateWidthToWidest(_defineProperty({}, currentTableNodeLocalId, shouldUpdateWidthToWidest))(state, dispatch);
225
+ updateWidth(shouldUpdateWidthToWidest ? TABLE_MAX_WIDTH : newWidth);
214
226
  return newWidth;
215
227
  }, [countFrames, isTableScalingEnabled, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
216
228
  var scheduleResize = useMemo(function () {
217
229
  return rafSchd(handleResize);
218
230
  }, [handleResize]);
219
231
  var handleResizeStop = useCallback(function (originalState, delta) {
232
+ var _node$attrs$localId2, _node$attrs2;
220
233
  isResizing.current = false;
221
234
  var newWidth = originalState.width + delta.width;
222
235
  var state = editorView.state,
223
236
  dispatch = editorView.dispatch;
224
237
  var pos = getPos();
225
- var _getPluginState = getPluginState(editorView.state),
226
- widthToWidest = _getPluginState.widthToWidest;
227
- newWidth = widthToWidest ? akEditorFullWidthLayoutWidth : newWidth;
238
+ var currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) !== null && _node$attrs$localId2 !== void 0 ? _node$attrs$localId2 : '';
239
+ newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? TABLE_MAX_WIDTH : newWidth;
228
240
  var tr = state.tr.setMeta(tableWidthPluginKey, {
229
241
  resizing: false
230
242
  });
@@ -269,7 +281,7 @@ export var TableResizer = function TableResizer(_ref) {
269
281
  onResizeStop();
270
282
  }
271
283
  return newWidth;
272
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled]);
284
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, widthToWidest]);
273
285
  var handleTableSizeChangeOnKeypress = useCallback(function (step) {
274
286
  var newWidth = width + step;
275
287
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -374,7 +386,7 @@ export var TableResizer = function TableResizer(_ref) {
374
386
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ResizerNext, {
375
387
  ref: resizerRef,
376
388
  enable: handles,
377
- width: width,
389
+ width: localTableWidth,
378
390
  handleAlignmentMethod: "sticky",
379
391
  handleSize: handleSize,
380
392
  handleStyles: handleStyles,
@@ -391,8 +403,8 @@ export var TableResizer = function TableResizer(_ref) {
391
403
  needExtendedResizeZone: !isTableSelected,
392
404
  appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
393
405
  handleHighlight: "shadow",
394
- handleTooltipContent: getBooleanFF('platform.editor.a11y-table-resizing_uapcv') ? function (_ref3) {
395
- var update = _ref3.update;
406
+ handleTooltipContent: getBooleanFF('platform.editor.a11y-table-resizing_uapcv') ? function (_ref4) {
407
+ var update = _ref4.update;
396
408
  updateTooltip.current = update;
397
409
  return /*#__PURE__*/React.createElement(ToolTipContent, {
398
410
  description: formatMessage(messages.resizeTable),
@@ -85,7 +85,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
85
85
  isWholeTableInDanger: tablePluginState.isWholeTableInDanger,
86
86
  // IMPORTANT: Need to continue to pass tableNode to control re-renders
87
87
  // TableComponent listens for node attribute changes to update colgroups
88
- tableNode: tablePluginState.tableNode
88
+ tableNode: tablePluginState.tableNode,
89
+ widthToWidest: tablePluginState.widthToWidest
89
90
  };
90
91
  },
91
92
  actions: {
@@ -15,7 +15,6 @@ import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType,
15
15
  import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
16
16
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
17
17
  import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
18
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
19
18
  import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
20
19
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
21
20
  import { getPluginState } from './pm-plugins/plugin-factory';
@@ -54,7 +53,7 @@ export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _
54
53
  disabled: !state.canCollapseTable,
55
54
  hidden: !config.allowCollapse
56
55
  }];
57
- if (state.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling')) {
56
+ if (state.isDragAndDropEnabled) {
58
57
  return {
59
58
  id: 'editor.table.tableOptions',
60
59
  type: 'dropdown',
@@ -290,6 +289,7 @@ export var getClosestSelectionOrTableRect = function getClosestSelectionOrTableR
290
289
  export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
291
290
  return function (config) {
292
291
  return function (state, intl) {
292
+ var _tableObject$node$att, _tableObject$node;
293
293
  var tableObject = findTable(state.selection);
294
294
  var pluginState = getPluginState(state);
295
295
  var resizeState = tableResizingPluginKey.getState(state);
@@ -299,7 +299,8 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
299
299
  var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
300
300
  var isTableScalingEnabled = pluginState.isTableScalingEnabled,
301
301
  widthToWidest = pluginState.widthToWidest;
302
- if (isTableScalingEnabled && isWidthResizing && widthToWidest) {
302
+ var currentTableNodeLocalId = (_tableObject$node$att = tableObject === null || tableObject === void 0 || (_tableObject$node = tableObject.node) === null || _tableObject$node === void 0 || (_tableObject$node = _tableObject$node.attrs) === null || _tableObject$node === void 0 ? void 0 : _tableObject$node.localId) !== null && _tableObject$node$att !== void 0 ? _tableObject$node$att : '';
303
+ if (isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
303
304
  var _getEditorFeatureFlag = getEditorFeatureFlags(),
304
305
  stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
305
306
  var nodeType = state.schema.nodes.table;
@@ -351,7 +352,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
351
352
  var cellItems;
352
353
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled);
353
354
  var columnSettingsItems;
354
- columnSettingsItems = pluginState.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
355
+ columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
355
356
  var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
356
357
 
357
358
  // Check if we need to show confirm dialog for delete button
@@ -80,11 +80,11 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
80
80
  var node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
81
81
  var background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
82
82
  return {
83
- content: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? formatMessage(messages.backgroundColor) : formatMessage(messages.cellBackground),
83
+ content: isDragAndDropEnabled ? formatMessage(messages.backgroundColor) : formatMessage(messages.cellBackground),
84
84
  value: {
85
85
  name: 'background'
86
86
  },
87
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
87
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
88
88
  css: elementBeforeIconStyles
89
89
  }, jsx(EditorBackgroundColorIcon, {
90
90
  label: formatMessage(messages.backgroundColor),
@@ -94,7 +94,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
94
94
  className: DropdownMenuSharedCssClassName.SUBMENU
95
95
  }, jsx("div", {
96
96
  css: cellColourPreviewStyles(background),
97
- className: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? ClassName.CONTEXTUAL_MENU_ICON_SMALL : ClassName.CONTEXTUAL_MENU_ICON
97
+ className: isDragAndDropEnabled ? ClassName.CONTEXTUAL_MENU_ICON_SMALL : ClassName.CONTEXTUAL_MENU_ICON
98
98
  }), isSubmenuOpen && jsx("div", {
99
99
  className: ClassName.CONTEXTUAL_SUBMENU,
100
100
  ref: _this.handleSubMenuRef
@@ -126,7 +126,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
126
126
  name: 'merge'
127
127
  },
128
128
  isDisabled: !canMergeCells(state.tr),
129
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
129
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
130
130
  css: elementBeforeIconStyles
131
131
  }, jsx(MergeCellsIcon, null)) : undefined
132
132
  }, {
@@ -135,7 +135,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
135
135
  name: 'split'
136
136
  },
137
137
  isDisabled: !splitCell(state),
138
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
138
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
139
139
  css: elementBeforeIconStyles
140
140
  }, jsx(SplitCellIcon, null)) : undefined
141
141
  }];
@@ -149,14 +149,14 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
149
149
  var _getPluginState3 = getPluginState(editorView.state),
150
150
  isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled;
151
151
  return {
152
- content: formatMessage(isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? messages.addColumnRight : messages.insertColumn),
152
+ content: formatMessage(isDragAndDropEnabled ? messages.addColumnRight : messages.insertColumn),
153
153
  value: {
154
154
  name: 'insert_column'
155
155
  },
156
156
  elemAfter: jsx("div", {
157
157
  css: shortcutStyle
158
158
  }, tooltip(addColumnAfter)),
159
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
159
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
160
160
  css: elementBeforeIconStyles
161
161
  }, jsx(AddColRightIcon, null)) : undefined
162
162
  };
@@ -168,14 +168,14 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
168
168
  var _getPluginState4 = getPluginState(editorView.state),
169
169
  isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled;
170
170
  return {
171
- content: formatMessage(isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? messages.addRowBelow : messages.insertRow),
171
+ content: formatMessage(isDragAndDropEnabled ? messages.addRowBelow : messages.insertRow),
172
172
  value: {
173
173
  name: 'insert_row'
174
174
  },
175
175
  elemAfter: jsx("div", {
176
176
  css: shortcutStyle
177
177
  }, tooltip(addRowAfter)),
178
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
178
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
179
179
  css: elementBeforeIconStyles
180
180
  }, jsx(AddRowBelowIcon, null)) : undefined
181
181
  };
@@ -203,7 +203,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
203
203
  elemAfter: jsx("div", {
204
204
  css: shortcutStyle
205
205
  }, tooltip(backspace)),
206
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
206
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
207
207
  css: elementBeforeIconStyles
208
208
  }, jsx(CrossCircleIcon, {
209
209
  label: formatMessage(messages.clearCells, {
@@ -229,7 +229,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
229
229
  value: {
230
230
  name: 'delete_column'
231
231
  },
232
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
232
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
233
233
  css: elementBeforeIconStyles
234
234
  }, jsx(RemoveIcon, {
235
235
  label: formatMessage(messages.removeColumns, {
@@ -255,7 +255,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
255
255
  value: {
256
256
  name: 'delete_row'
257
257
  },
258
- elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx("span", {
258
+ elemBefore: isDragAndDropEnabled ? jsx("span", {
259
259
  css: elementBeforeIconStyles
260
260
  }, jsx(RemoveIcon, {
261
261
  label: formatMessage(messages.removeRows, {
@@ -273,7 +273,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
273
273
  var _getPluginState8 = getPluginState(editorView.state),
274
274
  isDragAndDropEnabled = _getPluginState8.isDragAndDropEnabled,
275
275
  allowDistributeColumns = _getPluginState8.pluginConfig.allowDistributeColumns;
276
- if (allowDistributeColumns && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
276
+ if (allowDistributeColumns && !isDragAndDropEnabled) {
277
277
  var _newResizeState$chang;
278
278
  var _getPluginState9 = getPluginState(editorView.state),
279
279
  _getPluginState9$isTa = _getPluginState9.isTableScalingEnabled,
@@ -297,7 +297,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
297
297
  allowColumnSorting = _this$props9.allowColumnSorting;
298
298
  var _getPluginState10 = getPluginState(editorView.state),
299
299
  isDragAndDropEnabled = _getPluginState10.isDragAndDropEnabled;
300
- if (allowColumnSorting && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
300
+ if (allowColumnSorting && !isDragAndDropEnabled) {
301
301
  var hasMergedCellsInTable = getMergedCellsPositions(editorView.state.tr).length > 0;
302
302
  var warning = hasMergedCellsInTable ? {
303
303
  tooltipDescription: formatMessage(messages.canNotSortTable),
@@ -515,7 +515,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
515
515
  editorView = _this$props14.editorView;
516
516
  var _getPluginState14 = getPluginState(editorView.state),
517
517
  isDragAndDropEnabled = _getPluginState14.isDragAndDropEnabled;
518
- var items = isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
518
+ var items = isDragAndDropEnabled ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
519
519
  return jsx("div", {
520
520
  "data-testid": "table-cell-contextual-menu",
521
521
  onMouseLeave: this.closeSubmenu
@@ -538,7 +538,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
538
538
  fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth,
539
539
  boundariesElement: boundariesElement,
540
540
  offset: offset,
541
- section: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && getBooleanFF('platform.editor.menu.group-items') ? {
541
+ section: isDragAndDropEnabled && getBooleanFF('platform.editor.menu.group-items') ? {
542
542
  hasSeparator: true
543
543
  } : undefined
544
544
  }));
@@ -437,20 +437,20 @@ export var DragMenu = /*#__PURE__*/React.memo(function (_ref) {
437
437
  if (!menuItems) {
438
438
  return null;
439
439
  }
440
- if (allowBackgroundColor && getBooleanFF('platform.editor.table.new-cell-context-menu-styling')) {
440
+ if (allowBackgroundColor) {
441
441
  menuItems[0].items.unshift(createBackgroundColorMenuItem());
442
442
  }
443
443
 
444
444
  // If first row, add toggle for Header row, default is true
445
445
  // If first column, add toggle for Header column, default is false
446
- if (getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && index === 0) {
446
+ if (index === 0) {
447
447
  menuItems.push({
448
448
  items: [createHeaderRowColumnMenuItem(direction)]
449
449
  });
450
450
  }
451
451
 
452
452
  // All rows, add toggle for numbered rows, default is false
453
- if (getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && direction === 'row') {
453
+ if (direction === 'row') {
454
454
  index === 0 ? menuItems[menuItems.length - 1].items.push(createRowNumbersMenuItem()) : menuItems.push({
455
455
  items: [createRowNumbersMenuItem()]
456
456
  });
@@ -6,7 +6,6 @@ import { ArrowKeyNavigationProvider, ArrowKeyNavigationType, DropdownMenuItem }
6
6
  import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
7
7
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
8
8
  import { MenuGroup, Section } from '@atlaskit/menu';
9
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
9
  import { dragMenuDropdownWidth } from '../consts';
11
10
  var DropListWithOutsideListeners = withReactEditorViewOuterListeners(DropList);
12
11
  export var DropdownMenu = function DropdownMenu(_ref) {
@@ -118,39 +117,33 @@ export var DropdownMenu = function DropdownMenu(_ref) {
118
117
  // The logic below normalises the index value based on the number
119
118
  // of menu items with 2 focusable elements, and adjusts the index to ensure
120
119
  // the correct menu item is sent in onItemActivated callback
121
- if (getBooleanFF('platform.editor.table.new-cell-context-menu-styling')) {
122
- var keys = ['row_numbers', 'header_row', 'header_column'];
123
- var doubleItemCount = 0;
124
- var firstIndex = results.findIndex(function (value) {
125
- return keys.includes(value.key);
120
+ var keys = ['row_numbers', 'header_row', 'header_column'];
121
+ var doubleItemCount = 0;
122
+ var firstIndex = results.findIndex(function (value) {
123
+ return keys.includes(value.key);
124
+ });
125
+ if (firstIndex === -1 || index <= firstIndex) {
126
+ onItemActivated && onItemActivated({
127
+ item: results[index]
126
128
  });
127
- if (firstIndex === -1 || index <= firstIndex) {
129
+ return;
130
+ }
131
+ for (var i = firstIndex; i < results.length; i += 1) {
132
+ if (keys.includes(results[i].key)) {
133
+ doubleItemCount += 1;
134
+ }
135
+ if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
128
136
  onItemActivated && onItemActivated({
129
- item: results[index]
137
+ item: results[i]
130
138
  });
131
139
  return;
132
140
  }
133
- for (var i = firstIndex; i < results.length; i += 1) {
134
- if (keys.includes(results[i].key)) {
135
- doubleItemCount += 1;
136
- }
137
- if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
138
- onItemActivated && onItemActivated({
139
- item: results[i]
140
- });
141
- return;
142
- }
143
- if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
144
- onItemActivated && onItemActivated({
145
- item: results[i]
146
- });
147
- return;
148
- }
141
+ if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
142
+ onItemActivated && onItemActivated({
143
+ item: results[i]
144
+ });
145
+ return;
149
146
  }
150
- } else {
151
- onItemActivated && onItemActivated({
152
- item: results[index]
153
- });
154
147
  }
155
148
  }
156
149
  }, innerMenu())));
@@ -6,5 +6,5 @@ import { calculateDefaultSnappings, calculateDefaultTablePreserveSnappings } fro
6
6
  // If we don't do this then the guidelines will not align correctly to the edge of the table
7
7
  export var defaultGuidelines = createFixedGuidelinesFromLengths([0].concat(_toConsumableArray(calculateDefaultSnappings(-1))));
8
8
  export var defaultGuidelinesForPreserveTable = function defaultGuidelinesForPreserveTable(editorContainerWidth) {
9
- return createFixedGuidelinesFromLengths([0].concat(_toConsumableArray(calculateDefaultTablePreserveSnappings(-1, editorContainerWidth))));
9
+ return createFixedGuidelinesFromLengths([0].concat(_toConsumableArray(calculateDefaultTablePreserveSnappings(-1, editorContainerWidth))), undefined, true);
10
10
  };
@@ -3,6 +3,7 @@ import type { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror
3
3
  import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { WidthToWidest } from '../types';
6
7
  export declare const setEditorFocus: (editorHasFocus: boolean) => Command;
7
8
  export declare const setTableRef: (ref?: HTMLTableElement) => Command;
8
9
  export declare const setCellAttr: (name: string, value: any) => Command;
@@ -33,4 +34,4 @@ export declare const autoSizeTable: (view: EditorView, node: PMNode, table: HTML
33
34
  containerWidth: number;
34
35
  }) => boolean;
35
36
  export declare const addBoldInEmptyHeaderCells: (tableCellHeader: ContentNodeWithPos) => Command;
36
- export declare const updateWidthToWidest: (widthToWidest: boolean) => Command;
37
+ export declare const updateWidthToWidest: (widthToWidest: WidthToWidest) => Command;
@@ -4,6 +4,7 @@ import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
4
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
6
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
+ import type { PluginInjectionAPI } from '../types';
7
8
  interface TableResizerProps {
8
9
  width: number;
9
10
  maxWidth: number;
@@ -16,6 +17,7 @@ interface TableResizerProps {
16
17
  displayGuideline: (guideline: GuidelineConfig[]) => boolean;
17
18
  attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
18
19
  displayGapCursor: (toggle: boolean) => boolean;
20
+ pluginInjectionApi?: PluginInjectionAPI;
19
21
  isTableScalingEnabled?: boolean;
20
22
  isWholeTableInDanger?: boolean;
21
23
  }
@@ -23,5 +25,5 @@ export interface TableResizerImprovementProps extends TableResizerProps {
23
25
  onResizeStop?: () => void;
24
26
  onResizeStart?: () => void;
25
27
  }
26
- export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isWholeTableInDanger, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
28
+ export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isWholeTableInDanger, pluginInjectionApi, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
27
29
  export {};
@@ -26,7 +26,7 @@ export interface InsertRowOptions {
26
26
  moveCursorToInsertedRow: boolean;
27
27
  }
28
28
  export type PluginInjectionAPI = ExtractInjectionAPI<TablePlugin>;
29
- export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode'> & {
29
+ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
30
30
  isResizing: boolean;
31
31
  isTableResizing?: boolean;
32
32
  isWholeTableInDanger?: boolean;
@@ -60,6 +60,9 @@ export interface CellHoverMeta {
60
60
  colIndex?: number;
61
61
  rowIndex?: number;
62
62
  }
63
+ export interface WidthToWidest {
64
+ [tableLocalId: string]: boolean;
65
+ }
63
66
  export interface TablePluginState {
64
67
  editorHasFocus?: boolean;
65
68
  hoveredColumns: number[];
@@ -89,7 +92,7 @@ export interface TablePluginState {
89
92
  isKeyboardResize?: boolean;
90
93
  isTableCollapsed?: boolean;
91
94
  canCollapseTable?: boolean;
92
- widthToWidest?: boolean;
95
+ widthToWidest?: WidthToWidest;
93
96
  getIntl: () => IntlShape;
94
97
  isBreakoutEnabled?: boolean;
95
98
  wasFullWidthModeEnabled?: boolean;
@@ -178,7 +181,7 @@ export type TablePluginAction = {
178
181
  } | {
179
182
  type: 'UPDATE_TABLE_WIDTH_TO_WIDEST';
180
183
  data: {
181
- widthToWidest: boolean | undefined;
184
+ widthToWidest: WidthToWidest | undefined;
182
185
  };
183
186
  } | {
184
187
  type: 'REMOVE_RESIZE_HANDLE_DECORATIONS';
@@ -3,6 +3,7 @@ import type { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror
3
3
  import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { WidthToWidest } from '../types';
6
7
  export declare const setEditorFocus: (editorHasFocus: boolean) => Command;
7
8
  export declare const setTableRef: (ref?: HTMLTableElement) => Command;
8
9
  export declare const setCellAttr: (name: string, value: any) => Command;
@@ -33,4 +34,4 @@ export declare const autoSizeTable: (view: EditorView, node: PMNode, table: HTML
33
34
  containerWidth: number;
34
35
  }) => boolean;
35
36
  export declare const addBoldInEmptyHeaderCells: (tableCellHeader: ContentNodeWithPos) => Command;
36
- export declare const updateWidthToWidest: (widthToWidest: boolean) => Command;
37
+ export declare const updateWidthToWidest: (widthToWidest: WidthToWidest) => Command;
@@ -4,6 +4,7 @@ import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
4
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
6
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
+ import type { PluginInjectionAPI } from '../types';
7
8
  interface TableResizerProps {
8
9
  width: number;
9
10
  maxWidth: number;
@@ -16,6 +17,7 @@ interface TableResizerProps {
16
17
  displayGuideline: (guideline: GuidelineConfig[]) => boolean;
17
18
  attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
18
19
  displayGapCursor: (toggle: boolean) => boolean;
20
+ pluginInjectionApi?: PluginInjectionAPI;
19
21
  isTableScalingEnabled?: boolean;
20
22
  isWholeTableInDanger?: boolean;
21
23
  }
@@ -23,5 +25,5 @@ export interface TableResizerImprovementProps extends TableResizerProps {
23
25
  onResizeStop?: () => void;
24
26
  onResizeStart?: () => void;
25
27
  }
26
- export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isWholeTableInDanger, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
28
+ export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isWholeTableInDanger, pluginInjectionApi, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
27
29
  export {};
@@ -26,7 +26,7 @@ export interface InsertRowOptions {
26
26
  moveCursorToInsertedRow: boolean;
27
27
  }
28
28
  export type PluginInjectionAPI = ExtractInjectionAPI<TablePlugin>;
29
- export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode'> & {
29
+ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
30
30
  isResizing: boolean;
31
31
  isTableResizing?: boolean;
32
32
  isWholeTableInDanger?: boolean;
@@ -60,6 +60,9 @@ export interface CellHoverMeta {
60
60
  colIndex?: number;
61
61
  rowIndex?: number;
62
62
  }
63
+ export interface WidthToWidest {
64
+ [tableLocalId: string]: boolean;
65
+ }
63
66
  export interface TablePluginState {
64
67
  editorHasFocus?: boolean;
65
68
  hoveredColumns: number[];
@@ -89,7 +92,7 @@ export interface TablePluginState {
89
92
  isKeyboardResize?: boolean;
90
93
  isTableCollapsed?: boolean;
91
94
  canCollapseTable?: boolean;
92
- widthToWidest?: boolean;
95
+ widthToWidest?: WidthToWidest;
93
96
  getIntl: () => IntlShape;
94
97
  isBreakoutEnabled?: boolean;
95
98
  wasFullWidthModeEnabled?: boolean;
@@ -178,7 +181,7 @@ export type TablePluginAction = {
178
181
  } | {
179
182
  type: 'UPDATE_TABLE_WIDTH_TO_WIDEST';
180
183
  data: {
181
- widthToWidest: boolean | undefined;
184
+ widthToWidest: WidthToWidest | undefined;
182
185
  };
183
186
  } | {
184
187
  type: 'REMOVE_RESIZE_HANDLE_DECORATIONS';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.6.3",
3
+ "version": "7.6.4",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^35.7.0",
32
32
  "@atlaskit/custom-steps": "^0.0.16",
33
- "@atlaskit/editor-common": "^78.21.0",
33
+ "@atlaskit/editor-common": "^78.22.0",
34
34
  "@atlaskit/editor-palette": "1.5.3",
35
35
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
36
36
  "@atlaskit/editor-plugin-content-insertion": "^1.0.0",
@@ -128,9 +128,6 @@
128
128
  "platform.editor.a11y-table-resizing_uapcv": {
129
129
  "type": "boolean"
130
130
  },
131
- "platform.editor.table.new-cell-context-menu-styling": {
132
- "type": "boolean"
133
- },
134
131
  "platform.editor.a11y.table-selection_9uv33": {
135
132
  "type": "boolean"
136
133
  },