@atlaskit/editor-plugin-table 27.0.6 → 27.0.7

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,16 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 27.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b53c8a7c458af`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b53c8a7c458af) -
8
+ Disable dragging table rows and columns while limited mode is active, behind the
9
+ platform_editor_table_limited_mode experiment. The row and column drag handles are no longer
10
+ registered as draggable, so no drag can start from them. The handles themselves still render and
11
+ still select the row/column and open its menu on click. Responds to limited mode being toggled
12
+ during a session.
13
+
3
14
  ## 27.0.6
4
15
 
5
16
  ### Patch Changes
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isDragAndDropDisabledInLimitedMode = void 0;
7
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
8
+ /**
9
+ * Limited mode strips expensive behaviour on very large documents, and dragging table rows and
10
+ * columns is one of those behaviours.
11
+ *
12
+ * This only covers *dragging*. The row and column drag handles keep rendering so that clicking one
13
+ * still selects the row/column and opens its menu.
14
+ *
15
+ * Limited mode can flip during a session — `false -> true` on any transaction as content loads, and
16
+ * `true -> false` on a `replaceDocument` transaction — so callers must re-evaluate at runtime rather
17
+ * than only when they first mount.
18
+ */
19
+ var isDragAndDropDisabledInLimitedMode = exports.isDragAndDropDisabledInLimitedMode = function isDragAndDropDisabledInLimitedMode(limitedModeEnabled) {
20
+ return !!limitedModeEnabled && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_table_limited_mode');
21
+ };
@@ -13,6 +13,7 @@ var _classnames2 = _interopRequireDefault(require("classnames"));
13
13
  var _reactDom = _interopRequireDefault(require("react-dom"));
14
14
  var _reactIntl = require("react-intl");
15
15
  var _browser = require("@atlaskit/editor-common/browser");
16
+ var _hooks = require("@atlaskit/editor-common/hooks");
16
17
  var _messages = require("@atlaskit/editor-common/messages");
17
18
  var _state = require("@atlaskit/editor-prosemirror/state");
18
19
  var _editorTables = require("@atlaskit/editor-tables");
@@ -22,6 +23,7 @@ var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/ele
22
23
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
23
24
  var _activeTableMenu = require("../../pm-plugins/commands/active-table-menu");
24
25
  var _pluginFactory = require("../../pm-plugins/drag-and-drop/plugin-factory");
26
+ var _limitedMode = require("../../pm-plugins/utils/limited-mode");
25
27
  var _mergedCells = require("../../pm-plugins/utils/merged-cells");
26
28
  var _types = require("../../types");
27
29
  var _consts = require("../consts");
@@ -66,6 +68,18 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
66
68
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
67
69
  isHovered = _useState4[0],
68
70
  setIsHovered = _useState4[1];
71
+
72
+ // Limited mode disables dragging rows and columns, but the handle itself keeps working as the
73
+ // selection and menu affordance. Subscribing here (rather than reading the plugin state once) means
74
+ // the effect below re-runs and un-registers the draggable if limited mode flips mid-session.
75
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['limitedMode'], function (states) {
76
+ var _states$limitedModeSt;
77
+ return {
78
+ limitedModeEnabled: (_states$limitedModeSt = states.limitedModeState) === null || _states$limitedModeSt === void 0 ? void 0 : _states$limitedModeSt.enabled
79
+ };
80
+ }),
81
+ limitedModeEnabled = _useSharedPluginState.limitedModeEnabled;
82
+ var isDraggingEnabled = !(0, _limitedMode.isDragAndDropDisabledInLimitedMode)(limitedModeEnabled);
69
83
  var isRow = direction === 'row';
70
84
  var isColumn = direction === 'column';
71
85
  var hasMergedCells = (0, _react.useMemo)(function () {
@@ -108,6 +122,12 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
108
122
  (0, _react.useEffect)(function () {
109
123
  var dragHandleDivRefCurrent = dragHandleDivRef.current;
110
124
  var browser = (0, _browser.getBrowserInfo)();
125
+
126
+ // Skipping the registration entirely (rather than returning false from `canDrag`) means the
127
+ // `draggable="true"` attribute is never added, so no drag can start from the handle at all.
128
+ if (!isDraggingEnabled) {
129
+ return;
130
+ }
111
131
  if (dragHandleDivRefCurrent) {
112
132
  return (0, _adapter.draggable)({
113
133
  element: dragHandleDivRefCurrent,
@@ -160,7 +180,7 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
160
180
  }
161
181
  });
162
182
  }
163
- }, [tableLocalId, direction, indexes, isRow, editorView.state.selection, hasMergedCells]);
183
+ }, [tableLocalId, direction, indexes, isRow, editorView.state.selection, hasMergedCells, isDraggingEnabled]);
164
184
  var showDragMenuAnchorId = isRow ? 'drag-handle-button-row' : 'drag-handle-button-column';
165
185
  var browser = (0, _browser.getBrowserInfo)();
166
186
 
@@ -0,0 +1,14 @@
1
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
2
+
3
+ /**
4
+ * Limited mode strips expensive behaviour on very large documents, and dragging table rows and
5
+ * columns is one of those behaviours.
6
+ *
7
+ * This only covers *dragging*. The row and column drag handles keep rendering so that clicking one
8
+ * still selects the row/column and opens its menu.
9
+ *
10
+ * Limited mode can flip during a session — `false -> true` on any transaction as content loads, and
11
+ * `true -> false` on a `replaceDocument` transaction — so callers must re-evaluate at runtime rather
12
+ * than only when they first mount.
13
+ */
14
+ export const isDragAndDropDisabledInLimitedMode = limitedModeEnabled => !!limitedModeEnabled && isExperimentEnabled('platform_editor_table_limited_mode');
@@ -5,6 +5,7 @@ import classnames from 'classnames';
5
5
  import ReactDOM from 'react-dom';
6
6
  import { injectIntl } from 'react-intl';
7
7
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
8
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
9
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
9
10
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
10
11
  import { findTable, TableMap } from '@atlaskit/editor-tables';
@@ -14,6 +15,7 @@ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/el
14
15
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
16
  import { closeActiveTableMenu } from '../../pm-plugins/commands/active-table-menu';
16
17
  import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
18
+ import { isDragAndDropDisabledInLimitedMode } from '../../pm-plugins/utils/limited-mode';
17
19
  import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugins/utils/merged-cells';
18
20
  import { TableCssClassName as ClassName } from '../../types';
19
21
  import { dragTableInsertColumnButtonSize } from '../consts';
@@ -53,6 +55,19 @@ const DragHandleComponent = ({
53
55
  isDragMenuOpen = false
54
56
  } = getDnDPluginState(state);
55
57
  const [isHovered, setIsHovered] = useState(false);
58
+
59
+ // Limited mode disables dragging rows and columns, but the handle itself keeps working as the
60
+ // selection and menu affordance. Subscribing here (rather than reading the plugin state once) means
61
+ // the effect below re-runs and un-registers the draggable if limited mode flips mid-session.
62
+ const {
63
+ limitedModeEnabled
64
+ } = useSharedPluginStateWithSelector(api, ['limitedMode'], states => {
65
+ var _states$limitedModeSt;
66
+ return {
67
+ limitedModeEnabled: (_states$limitedModeSt = states.limitedModeState) === null || _states$limitedModeSt === void 0 ? void 0 : _states$limitedModeSt.enabled
68
+ };
69
+ });
70
+ const isDraggingEnabled = !isDragAndDropDisabledInLimitedMode(limitedModeEnabled);
56
71
  const isRow = direction === 'row';
57
72
  const isColumn = direction === 'column';
58
73
  const hasMergedCells = useMemo(() => {
@@ -95,6 +110,12 @@ const DragHandleComponent = ({
95
110
  useEffect(() => {
96
111
  const dragHandleDivRefCurrent = dragHandleDivRef.current;
97
112
  const browser = getBrowserInfo();
113
+
114
+ // Skipping the registration entirely (rather than returning false from `canDrag`) means the
115
+ // `draggable="true"` attribute is never added, so no drag can start from the handle at all.
116
+ if (!isDraggingEnabled) {
117
+ return;
118
+ }
98
119
  if (dragHandleDivRefCurrent) {
99
120
  return draggable({
100
121
  element: dragHandleDivRefCurrent,
@@ -148,7 +169,7 @@ const DragHandleComponent = ({
148
169
  }
149
170
  });
150
171
  }
151
- }, [tableLocalId, direction, indexes, isRow, editorView.state.selection, hasMergedCells]);
172
+ }, [tableLocalId, direction, indexes, isRow, editorView.state.selection, hasMergedCells, isDraggingEnabled]);
152
173
  const showDragMenuAnchorId = isRow ? 'drag-handle-button-row' : 'drag-handle-button-column';
153
174
  const browser = getBrowserInfo();
154
175
 
@@ -0,0 +1,16 @@
1
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
2
+
3
+ /**
4
+ * Limited mode strips expensive behaviour on very large documents, and dragging table rows and
5
+ * columns is one of those behaviours.
6
+ *
7
+ * This only covers *dragging*. The row and column drag handles keep rendering so that clicking one
8
+ * still selects the row/column and opens its menu.
9
+ *
10
+ * Limited mode can flip during a session — `false -> true` on any transaction as content loads, and
11
+ * `true -> false` on a `replaceDocument` transaction — so callers must re-evaluate at runtime rather
12
+ * than only when they first mount.
13
+ */
14
+ export var isDragAndDropDisabledInLimitedMode = function isDragAndDropDisabledInLimitedMode(limitedModeEnabled) {
15
+ return !!limitedModeEnabled && isExperimentEnabled('platform_editor_table_limited_mode');
16
+ };
@@ -7,6 +7,7 @@ import classnames from 'classnames';
7
7
  import ReactDOM from 'react-dom';
8
8
  import { injectIntl } from 'react-intl';
9
9
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
10
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
10
11
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
11
12
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
12
13
  import { findTable, TableMap } from '@atlaskit/editor-tables';
@@ -16,6 +17,7 @@ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/el
16
17
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
17
18
  import { closeActiveTableMenu } from '../../pm-plugins/commands/active-table-menu';
18
19
  import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
20
+ import { isDragAndDropDisabledInLimitedMode } from '../../pm-plugins/utils/limited-mode';
19
21
  import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugins/utils/merged-cells';
20
22
  import { TableCssClassName as ClassName } from '../../types';
21
23
  import { dragTableInsertColumnButtonSize } from '../consts';
@@ -57,6 +59,18 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
57
59
  _useState4 = _slicedToArray(_useState3, 2),
58
60
  isHovered = _useState4[0],
59
61
  setIsHovered = _useState4[1];
62
+
63
+ // Limited mode disables dragging rows and columns, but the handle itself keeps working as the
64
+ // selection and menu affordance. Subscribing here (rather than reading the plugin state once) means
65
+ // the effect below re-runs and un-registers the draggable if limited mode flips mid-session.
66
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['limitedMode'], function (states) {
67
+ var _states$limitedModeSt;
68
+ return {
69
+ limitedModeEnabled: (_states$limitedModeSt = states.limitedModeState) === null || _states$limitedModeSt === void 0 ? void 0 : _states$limitedModeSt.enabled
70
+ };
71
+ }),
72
+ limitedModeEnabled = _useSharedPluginState.limitedModeEnabled;
73
+ var isDraggingEnabled = !isDragAndDropDisabledInLimitedMode(limitedModeEnabled);
60
74
  var isRow = direction === 'row';
61
75
  var isColumn = direction === 'column';
62
76
  var hasMergedCells = useMemo(function () {
@@ -99,6 +113,12 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
99
113
  useEffect(function () {
100
114
  var dragHandleDivRefCurrent = dragHandleDivRef.current;
101
115
  var browser = getBrowserInfo();
116
+
117
+ // Skipping the registration entirely (rather than returning false from `canDrag`) means the
118
+ // `draggable="true"` attribute is never added, so no drag can start from the handle at all.
119
+ if (!isDraggingEnabled) {
120
+ return;
121
+ }
102
122
  if (dragHandleDivRefCurrent) {
103
123
  return draggable({
104
124
  element: dragHandleDivRefCurrent,
@@ -151,7 +171,7 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
151
171
  }
152
172
  });
153
173
  }
154
- }, [tableLocalId, direction, indexes, isRow, editorView.state.selection, hasMergedCells]);
174
+ }, [tableLocalId, direction, indexes, isRow, editorView.state.selection, hasMergedCells, isDraggingEnabled]);
155
175
  var showDragMenuAnchorId = isRow ? 'drag-handle-button-row' : 'drag-handle-button-column';
156
176
  var browser = getBrowserInfo();
157
177
 
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Limited mode strips expensive behaviour on very large documents, and dragging table rows and
3
+ * columns is one of those behaviours.
4
+ *
5
+ * This only covers *dragging*. The row and column drag handles keep rendering so that clicking one
6
+ * still selects the row/column and opens its menu.
7
+ *
8
+ * Limited mode can flip during a session — `false -> true` on any transaction as content loads, and
9
+ * `true -> false` on a `replaceDocument` transaction — so callers must re-evaluate at runtime rather
10
+ * than only when they first mount.
11
+ */
12
+ export declare const isDragAndDropDisabledInLimitedMode: (limitedModeEnabled: boolean | undefined) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "27.0.6",
3
+ "version": "27.0.7",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@atlaskit/adf-schema": "^57.0.0",
24
- "@atlaskit/button": "^25.0.0",
24
+ "@atlaskit/button": "^25.1.0",
25
25
  "@atlaskit/custom-steps": "^1.0.0",
26
26
  "@atlaskit/editor-palette": "^3.4.0",
27
27
  "@atlaskit/editor-plugin-accessibility-utils": "^15.0.0",
@@ -68,7 +68,7 @@
68
68
  "uuid": "^3.1.0"
69
69
  },
70
70
  "peerDependencies": {
71
- "@atlaskit/editor-common": "^119.7.0",
71
+ "@atlaskit/editor-common": "^119.9.0",
72
72
  "react": "^18.2.0 || ^19.2.0",
73
73
  "react-dom": "^18.2.0 || ^19.2.0",
74
74
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"