@atlaskit/editor-plugin-table 10.0.0 → 10.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 10.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#116320](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116320)
8
+ [`53a3a2613a2ea`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/53a3a2613a2ea) -
9
+ ED-26488 disable table dnd in live pages
10
+
11
+ ### Patch Changes
12
+
13
+ - [#117960](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117960)
14
+ [`0e8738357b54c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0e8738357b54c) -
15
+ [ux] ED-26725 Bugfix to bring back the blue highlighted border when resizing columns in nested
16
+ tables
17
+ - Updated dependencies
18
+
3
19
  ## 10.0.0
4
20
 
5
21
  ### Major Changes
@@ -29,11 +29,13 @@ var TableComponentWithSharedState = exports.TableComponentWithSharedState = func
29
29
  forwardRef = _ref.forwardRef,
30
30
  allowTableAlignment = _ref.allowTableAlignment,
31
31
  allowTableResizing = _ref.allowTableResizing;
32
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'table', 'media', 'selection']),
32
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'table', 'media', 'selection', 'editorViewMode']),
33
33
  widthState = _useSharedPluginState.widthState,
34
34
  tableState = _useSharedPluginState.tableState,
35
35
  mediaState = _useSharedPluginState.mediaState,
36
- selectionState = _useSharedPluginState.selectionState;
36
+ selectionState = _useSharedPluginState.selectionState,
37
+ editorViewModeState = _useSharedPluginState.editorViewModeState;
38
+ var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
37
39
  if (!tableState) {
38
40
  return null;
39
41
  }
@@ -73,7 +75,7 @@ var TableComponentWithSharedState = exports.TableComponentWithSharedState = func
73
75
  allowControls: allowControls,
74
76
  isHeaderRowEnabled: isHeaderRowEnabled,
75
77
  isHeaderColumnEnabled: isHeaderColumnEnabled,
76
- isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
78
+ isDragAndDropEnabled: (options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled) && !isLivePageViewMode,
77
79
  isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
78
80
  allowTableAlignment: allowTableAlignment,
79
81
  allowTableResizing: allowTableResizing,
@@ -17,6 +17,7 @@ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
17
17
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
18
18
  var _tableMap = require("@atlaskit/editor-tables/table-map");
19
19
  var _utils3 = require("@atlaskit/editor-tables/utils");
20
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
21
  var _commands = require("../pm-plugins/commands");
21
22
  var _pluginFactory = require("../pm-plugins/drag-and-drop/plugin-factory");
22
23
  var _pluginFactory2 = require("../pm-plugins/plugin-factory");
@@ -157,8 +158,14 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, m
157
158
  var nearestTable = (0, _utils.closestElement)(target, 'table');
158
159
  var nestedTable = (0, _utils2.findParentNodeOfTypeClosestToPos)(state.doc.resolve(state.selection.from), [state.schema.nodes.table]);
159
160
  var parentTable = (0, _utils2.findParentNodeOfTypeClosestToPos)(state.doc.resolve((nestedTable === null || nestedTable === void 0 ? void 0 : nestedTable.pos) || 0), [state.schema.nodes.table]);
160
- if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
161
- return (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch);
161
+ if ((0, _platformFeatureFlags.fg)('platform_editor_nested_tables_resize_border_fix')) {
162
+ if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId) && ((0, _dom.isCell)(target) || (0, _dom.isCornerButton)(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
163
+ return (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch);
164
+ }
165
+ } else {
166
+ if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
167
+ return (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch);
168
+ }
162
169
  }
163
170
  } else if (((0, _dom.isCell)(target) || (0, _dom.isCornerButton)(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
164
171
  return (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch);
@@ -28,8 +28,10 @@ export const TableComponentWithSharedState = ({
28
28
  widthState,
29
29
  tableState,
30
30
  mediaState,
31
- selectionState
32
- } = useSharedPluginState(api, ['width', 'table', 'media', 'selection']);
31
+ selectionState,
32
+ editorViewModeState
33
+ } = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']);
34
+ const isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
33
35
  if (!tableState) {
34
36
  return null;
35
37
  }
@@ -70,7 +72,7 @@ export const TableComponentWithSharedState = ({
70
72
  allowControls: allowControls,
71
73
  isHeaderRowEnabled: isHeaderRowEnabled,
72
74
  isHeaderColumnEnabled: isHeaderColumnEnabled,
73
- isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
75
+ isDragAndDropEnabled: (options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled) && !isLivePageViewMode,
74
76
  isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
75
77
  allowTableAlignment: allowTableAlignment,
76
78
  allowTableResizing: allowTableResizing,
@@ -7,6 +7,7 @@ import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/u
7
7
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
8
8
  import { TableMap } from '@atlaskit/editor-tables/table-map';
9
9
  import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, setTableHovered, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from '../pm-plugins/commands';
11
12
  import { getPluginState as getDragDropPluginState } from '../pm-plugins/drag-and-drop/plugin-factory';
12
13
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -148,8 +149,14 @@ export const handleMouseOver = (view, mouseEvent) => {
148
149
  const nearestTable = closestElement(target, 'table');
149
150
  const nestedTable = findParentNodeOfTypeClosestToPos(state.doc.resolve(state.selection.from), [state.schema.nodes.table]);
150
151
  const parentTable = findParentNodeOfTypeClosestToPos(state.doc.resolve((nestedTable === null || nestedTable === void 0 ? void 0 : nestedTable.pos) || 0), [state.schema.nodes.table]);
151
- if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
152
- return hideInsertColumnOrRowButton()(state, dispatch);
152
+ if (fg('platform_editor_nested_tables_resize_border_fix')) {
153
+ if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId) && (isCell(target) || isCornerButton(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
154
+ return hideInsertColumnOrRowButton()(state, dispatch);
155
+ }
156
+ } else {
157
+ if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
158
+ return hideInsertColumnOrRowButton()(state, dispatch);
159
+ }
153
160
  }
154
161
  } else if ((isCell(target) || isCornerButton(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
155
162
  return hideInsertColumnOrRowButton()(state, dispatch);
@@ -23,11 +23,13 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
23
23
  forwardRef = _ref.forwardRef,
24
24
  allowTableAlignment = _ref.allowTableAlignment,
25
25
  allowTableResizing = _ref.allowTableResizing;
26
- var _useSharedPluginState = useSharedPluginState(api, ['width', 'table', 'media', 'selection']),
26
+ var _useSharedPluginState = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']),
27
27
  widthState = _useSharedPluginState.widthState,
28
28
  tableState = _useSharedPluginState.tableState,
29
29
  mediaState = _useSharedPluginState.mediaState,
30
- selectionState = _useSharedPluginState.selectionState;
30
+ selectionState = _useSharedPluginState.selectionState,
31
+ editorViewModeState = _useSharedPluginState.editorViewModeState;
32
+ var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
31
33
  if (!tableState) {
32
34
  return null;
33
35
  }
@@ -67,7 +69,7 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
67
69
  allowControls: allowControls,
68
70
  isHeaderRowEnabled: isHeaderRowEnabled,
69
71
  isHeaderColumnEnabled: isHeaderColumnEnabled,
70
- isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
72
+ isDragAndDropEnabled: (options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled) && !isLivePageViewMode,
71
73
  isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
72
74
  allowTableAlignment: allowTableAlignment,
73
75
  allowTableResizing: allowTableResizing,
@@ -8,6 +8,7 @@ import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/u
8
8
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
9
9
  import { TableMap } from '@atlaskit/editor-tables/table-map';
10
10
  import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, setTableHovered, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from '../pm-plugins/commands';
12
13
  import { getPluginState as getDragDropPluginState } from '../pm-plugins/drag-and-drop/plugin-factory';
13
14
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -148,8 +149,14 @@ export var handleMouseOver = function handleMouseOver(view, mouseEvent) {
148
149
  var nearestTable = closestElement(target, 'table');
149
150
  var nestedTable = findParentNodeOfTypeClosestToPos(state.doc.resolve(state.selection.from), [state.schema.nodes.table]);
150
151
  var parentTable = findParentNodeOfTypeClosestToPos(state.doc.resolve((nestedTable === null || nestedTable === void 0 ? void 0 : nestedTable.pos) || 0), [state.schema.nodes.table]);
151
- if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
152
- return hideInsertColumnOrRowButton()(state, dispatch);
152
+ if (fg('platform_editor_nested_tables_resize_border_fix')) {
153
+ if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId) && (isCell(target) || isCornerButton(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
154
+ return hideInsertColumnOrRowButton()(state, dispatch);
155
+ }
156
+ } else {
157
+ if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
158
+ return hideInsertColumnOrRowButton()(state, dispatch);
159
+ }
153
160
  }
154
161
  } else if ((isCell(target) || isCornerButton(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
155
162
  return hideInsertColumnOrRowButton()(state, dispatch);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "10.0.0",
3
+ "version": "10.1.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -28,9 +28,9 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^47.2.1",
31
- "@atlaskit/button": "^21.0.0",
31
+ "@atlaskit/button": "^21.1.0",
32
32
  "@atlaskit/custom-steps": "^0.10.0",
33
- "@atlaskit/editor-common": "^100.0.0",
33
+ "@atlaskit/editor-common": "^100.1.0",
34
34
  "@atlaskit/editor-palette": "2.0.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^2.0.0",
@@ -51,9 +51,9 @@
51
51
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
52
52
  "@atlaskit/primitives": "^14.0.0",
53
53
  "@atlaskit/theme": "^17.0.0",
54
- "@atlaskit/tmp-editor-statsig": "^3.0.0",
54
+ "@atlaskit/tmp-editor-statsig": "^3.1.0",
55
55
  "@atlaskit/toggle": "^15.0.0",
56
- "@atlaskit/tokens": "^4.0.0",
56
+ "@atlaskit/tokens": "^4.1.0",
57
57
  "@atlaskit/tooltip": "^20.0.0",
58
58
  "@babel/runtime": "^7.0.0",
59
59
  "@emotion/react": "^11.7.1",
@@ -167,6 +167,9 @@
167
167
  },
168
168
  "platform_editor_nested_tables_bodied_extension_fix": {
169
169
  "type": "boolean"
170
+ },
171
+ "platform_editor_nested_tables_resize_border_fix": {
172
+ "type": "boolean"
170
173
  }
171
174
  }
172
175
  }
@@ -51,12 +51,10 @@ export const TableComponentWithSharedState = ({
51
51
  allowTableAlignment,
52
52
  allowTableResizing,
53
53
  }: TableComponentWithSharedStateProps) => {
54
- const { widthState, tableState, mediaState, selectionState } = useSharedPluginState(api, [
55
- 'width',
56
- 'table',
57
- 'media',
58
- 'selection',
59
- ]);
54
+ const { widthState, tableState, mediaState, selectionState, editorViewModeState } =
55
+ useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']);
56
+
57
+ const isLivePageViewMode = editorViewModeState?.mode === 'view';
60
58
 
61
59
  if (!tableState) {
62
60
  return null;
@@ -108,7 +106,7 @@ export const TableComponentWithSharedState = ({
108
106
  allowControls={allowControls}
109
107
  isHeaderRowEnabled={isHeaderRowEnabled}
110
108
  isHeaderColumnEnabled={isHeaderColumnEnabled}
111
- isDragAndDropEnabled={options?.isDragAndDropEnabled}
109
+ isDragAndDropEnabled={options?.isDragAndDropEnabled && !isLivePageViewMode}
112
110
  isTableScalingEnabled={options?.isTableScalingEnabled}
113
111
  allowTableAlignment={allowTableAlignment}
114
112
  allowTableResizing={allowTableResizing}
@@ -25,6 +25,7 @@ import {
25
25
  getSelectionRect,
26
26
  removeTable,
27
27
  } from '@atlaskit/editor-tables/utils';
28
+ import { fg } from '@atlaskit/platform-feature-flags';
28
29
 
29
30
  import {
30
31
  addResizeHandleDecorations,
@@ -239,8 +240,18 @@ export const handleMouseOver = (view: EditorView, mouseEvent: Event): boolean =>
239
240
  state.schema.nodes.table,
240
241
  ]);
241
242
 
242
- if (nearestTable?.dataset.tableLocalId !== parentTable?.node.attrs.localId) {
243
- return hideInsertColumnOrRowButton()(state, dispatch);
243
+ if (fg('platform_editor_nested_tables_resize_border_fix')) {
244
+ if (
245
+ nearestTable?.dataset.tableLocalId !== parentTable?.node.attrs.localId &&
246
+ (isCell(target) || isCornerButton(target)) &&
247
+ (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')
248
+ ) {
249
+ return hideInsertColumnOrRowButton()(state, dispatch);
250
+ }
251
+ } else {
252
+ if (nearestTable?.dataset.tableLocalId !== parentTable?.node.attrs.localId) {
253
+ return hideInsertColumnOrRowButton()(state, dispatch);
254
+ }
244
255
  }
245
256
  } else if (
246
257
  (isCell(target) || isCornerButton(target)) &&