@atlaskit/editor-plugin-block-controls 2.13.23 → 2.13.24

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,13 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.13.24
4
+
5
+ ### Patch Changes
6
+
7
+ - [#168183](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/168183)
8
+ [`5d8ee46d0ab46`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5d8ee46d0ab46) -
9
+ Fix dragging issue of a layout column while layout is selected
10
+
3
11
  ## 2.13.23
4
12
 
5
13
  ### Patch Changes
@@ -95,6 +95,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
95
95
  setDragHandleSelected = _useState4[1];
96
96
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['featureFlags']),
97
97
  featureFlagsState = _useSharedPluginState.featureFlagsState;
98
+ var isLayoutColumn = nodeType === 'layoutColumn';
98
99
  (0, _react.useEffect)(function () {
99
100
  // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
100
101
  if (nodeType === 'blockCard') {
@@ -146,6 +147,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
146
147
  // but ensures the preview is generated correctly.
147
148
  var handleMouseDown = (0, _react.useCallback)(function () {
148
149
  var _api$core3;
150
+ if (!(isLayoutColumn && (0, _advancedLayoutsFlags.isPreRelease2)()) && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24885')) {
151
+ return undefined;
152
+ }
149
153
  api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
150
154
  var tr = _ref3.tr;
151
155
  var startPos = getPos();
@@ -156,12 +160,17 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
156
160
  if (!node) {
157
161
  return tr;
158
162
  }
159
- var $startPos = tr.doc.resolve(startPos + node.nodeSize);
160
- var selection = new _state.TextSelection($startPos);
163
+ var selection;
164
+ if (isLayoutColumn && (0, _advancedLayoutsFlags.isPreRelease2)()) {
165
+ selection = new _state.NodeSelection(tr.doc.resolve(startPos));
166
+ } else {
167
+ var $startPos = tr.doc.resolve(startPos + node.nodeSize);
168
+ selection = new _state.TextSelection($startPos);
169
+ }
161
170
  tr.setSelection(selection);
162
171
  return tr;
163
172
  });
164
- }, [api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos]);
173
+ }, [api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos, isLayoutColumn]);
165
174
  var handleKeyDown = (0, _react.useCallback)(function (e) {
166
175
  if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
167
176
  // allow user to use spacebar to select the node
@@ -282,7 +291,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
282
291
  }
283
292
  }
284
293
  var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
285
- var isLayoutColumn = nodeType === 'layoutColumn';
286
294
  if (supportsAnchor) {
287
295
  return {
288
296
  left: isEdgeCase ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : (0, _advancedLayoutsFlags.isPreRelease2)() && isLayoutColumn ? "calc((anchor(".concat(anchorName, " right) + anchor(").concat(anchorName, " left))/2 - ").concat(_consts.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType, parentNodeType), "px)"),
@@ -293,7 +301,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
293
301
  left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType),
294
302
  top: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_ed_23674') ? (0, _dragHandlePositions.getTopPosition)(dom, nodeType) : (0, _dragHandlePositions.getTopPosition)(dom)
295
303
  };
296
- }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos]);
304
+ }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos, isLayoutColumn]);
297
305
  var _useState5 = (0, _react.useState)({
298
306
  display: 'none'
299
307
  }),
@@ -409,13 +417,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
409
417
  // eslint-disable-next-line @atlaskit/design-system/no-html-button
410
418
  (0, _react2.jsx)("button", {
411
419
  type: "button",
412
- css: [dragHandleButtonStyles, (0, _advancedLayoutsFlags.isPreRelease2)() && nodeType === 'layoutColumn' && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
420
+ css: [dragHandleButtonStyles, (0, _advancedLayoutsFlags.isPreRelease2)() && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
413
421
  ref: buttonRef
414
422
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
415
423
  ,
416
424
  style: positionStyles,
417
425
  onClick: handleOnClick,
418
- onMouseDown: (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24885') ? undefined : handleMouseDown,
426
+ onMouseDown: handleMouseDown,
419
427
  onKeyDown: handleKeyDown,
420
428
  "data-testid": "block-ctrl-drag-handle"
421
429
  }, (0, _react2.jsx)(_dragHandler.default, {
@@ -10,7 +10,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
10
10
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
11
  import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
12
12
  import { blockControlsMessages } from '@atlaskit/editor-common/messages';
13
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
13
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
14
14
  import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
15
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
16
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
@@ -79,6 +79,7 @@ export const DragHandle = ({
79
79
  const {
80
80
  featureFlagsState
81
81
  } = useSharedPluginState(api, ['featureFlags']);
82
+ const isLayoutColumn = nodeType === 'layoutColumn';
82
83
  useEffect(() => {
83
84
  // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
84
85
  if (nodeType === 'blockCard') {
@@ -129,6 +130,9 @@ export const DragHandle = ({
129
130
  // but ensures the preview is generated correctly.
130
131
  const handleMouseDown = useCallback(() => {
131
132
  var _api$core3;
133
+ if (!(isLayoutColumn && isPreRelease2()) && fg('platform_editor_element_drag_and_drop_ed_24885')) {
134
+ return undefined;
135
+ }
132
136
  api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
133
137
  tr
134
138
  }) => {
@@ -140,12 +144,17 @@ export const DragHandle = ({
140
144
  if (!node) {
141
145
  return tr;
142
146
  }
143
- const $startPos = tr.doc.resolve(startPos + node.nodeSize);
144
- const selection = new TextSelection($startPos);
147
+ let selection;
148
+ if (isLayoutColumn && isPreRelease2()) {
149
+ selection = new NodeSelection(tr.doc.resolve(startPos));
150
+ } else {
151
+ const $startPos = tr.doc.resolve(startPos + node.nodeSize);
152
+ selection = new TextSelection($startPos);
153
+ }
145
154
  tr.setSelection(selection);
146
155
  return tr;
147
156
  });
148
- }, [api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos]);
157
+ }, [api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos, isLayoutColumn]);
149
158
  const handleKeyDown = useCallback(e => {
150
159
  if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
151
160
  // allow user to use spacebar to select the node
@@ -266,7 +275,6 @@ export const DragHandle = ({
266
275
  }
267
276
  }
268
277
  const isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
269
- const isLayoutColumn = nodeType === 'layoutColumn';
270
278
  if (supportsAnchor) {
271
279
  return {
272
280
  left: isEdgeCase ? `calc(anchor(${anchorName} start) + ${getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType)})` : isPreRelease2() && isLayoutColumn ? `calc((anchor(${anchorName} right) + anchor(${anchorName} left))/2 - ${DRAG_HANDLE_HEIGHT / 2}px)` : `calc(anchor(${anchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
@@ -277,7 +285,7 @@ export const DragHandle = ({
277
285
  left: isEdgeCase ? `calc(${(dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0}px + ${getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType)})` : getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType),
278
286
  top: fg('platform_editor_elements_dnd_ed_23674') ? getTopPosition(dom, nodeType) : getTopPosition(dom)
279
287
  };
280
- }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos]);
288
+ }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos, isLayoutColumn]);
281
289
  const [positionStyles, setPositionStyles] = useState({
282
290
  display: 'none'
283
291
  });
@@ -389,13 +397,13 @@ export const DragHandle = ({
389
397
  // eslint-disable-next-line @atlaskit/design-system/no-html-button
390
398
  jsx("button", {
391
399
  type: "button",
392
- css: [dragHandleButtonStyles, isPreRelease2() && nodeType === 'layoutColumn' && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
400
+ css: [dragHandleButtonStyles, isPreRelease2() && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
393
401
  ref: buttonRef
394
402
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
395
403
  ,
396
404
  style: positionStyles,
397
405
  onClick: handleOnClick,
398
- onMouseDown: fg('platform_editor_element_drag_and_drop_ed_24885') ? undefined : handleMouseDown,
406
+ onMouseDown: handleMouseDown,
399
407
  onKeyDown: handleKeyDown,
400
408
  "data-testid": "block-ctrl-drag-handle"
401
409
  }, jsx(DragHandlerIcon, {
@@ -12,7 +12,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
12
12
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
13
13
  import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
14
14
  import { blockControlsMessages } from '@atlaskit/editor-common/messages';
15
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
15
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
16
16
  import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
17
17
  import { fg } from '@atlaskit/platform-feature-flags';
18
18
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
@@ -86,6 +86,7 @@ export var DragHandle = function DragHandle(_ref) {
86
86
  setDragHandleSelected = _useState4[1];
87
87
  var _useSharedPluginState = useSharedPluginState(api, ['featureFlags']),
88
88
  featureFlagsState = _useSharedPluginState.featureFlagsState;
89
+ var isLayoutColumn = nodeType === 'layoutColumn';
89
90
  useEffect(function () {
90
91
  // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
91
92
  if (nodeType === 'blockCard') {
@@ -137,6 +138,9 @@ export var DragHandle = function DragHandle(_ref) {
137
138
  // but ensures the preview is generated correctly.
138
139
  var handleMouseDown = useCallback(function () {
139
140
  var _api$core3;
141
+ if (!(isLayoutColumn && isPreRelease2()) && fg('platform_editor_element_drag_and_drop_ed_24885')) {
142
+ return undefined;
143
+ }
140
144
  api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
141
145
  var tr = _ref3.tr;
142
146
  var startPos = getPos();
@@ -147,12 +151,17 @@ export var DragHandle = function DragHandle(_ref) {
147
151
  if (!node) {
148
152
  return tr;
149
153
  }
150
- var $startPos = tr.doc.resolve(startPos + node.nodeSize);
151
- var selection = new TextSelection($startPos);
154
+ var selection;
155
+ if (isLayoutColumn && isPreRelease2()) {
156
+ selection = new NodeSelection(tr.doc.resolve(startPos));
157
+ } else {
158
+ var $startPos = tr.doc.resolve(startPos + node.nodeSize);
159
+ selection = new TextSelection($startPos);
160
+ }
152
161
  tr.setSelection(selection);
153
162
  return tr;
154
163
  });
155
- }, [api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos]);
164
+ }, [api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos, isLayoutColumn]);
156
165
  var handleKeyDown = useCallback(function (e) {
157
166
  if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
158
167
  // allow user to use spacebar to select the node
@@ -273,7 +282,6 @@ export var DragHandle = function DragHandle(_ref) {
273
282
  }
274
283
  }
275
284
  var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
276
- var isLayoutColumn = nodeType === 'layoutColumn';
277
285
  if (supportsAnchor) {
278
286
  return {
279
287
  left: isEdgeCase ? "calc(anchor(".concat(anchorName, " start) + ").concat(getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : isPreRelease2() && isLayoutColumn ? "calc((anchor(".concat(anchorName, " right) + anchor(").concat(anchorName, " left))/2 - ").concat(DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(anchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType, parentNodeType), "px)"),
@@ -284,7 +292,7 @@ export var DragHandle = function DragHandle(_ref) {
284
292
  left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat(getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType),
285
293
  top: fg('platform_editor_elements_dnd_ed_23674') ? getTopPosition(dom, nodeType) : getTopPosition(dom)
286
294
  };
287
- }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos]);
295
+ }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos, isLayoutColumn]);
288
296
  var _useState5 = useState({
289
297
  display: 'none'
290
298
  }),
@@ -400,13 +408,13 @@ export var DragHandle = function DragHandle(_ref) {
400
408
  // eslint-disable-next-line @atlaskit/design-system/no-html-button
401
409
  jsx("button", {
402
410
  type: "button",
403
- css: [dragHandleButtonStyles, isPreRelease2() && nodeType === 'layoutColumn' && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
411
+ css: [dragHandleButtonStyles, isPreRelease2() && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
404
412
  ref: buttonRef
405
413
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
406
414
  ,
407
415
  style: positionStyles,
408
416
  onClick: handleOnClick,
409
- onMouseDown: fg('platform_editor_element_drag_and_drop_ed_24885') ? undefined : handleMouseDown,
417
+ onMouseDown: handleMouseDown,
410
418
  onKeyDown: handleKeyDown,
411
419
  "data-testid": "block-ctrl-drag-handle"
412
420
  }, jsx(DragHandlerIcon, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.13.23",
3
+ "version": "2.13.24",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^44.2.0",
34
- "@atlaskit/editor-common": "^95.4.0",
34
+ "@atlaskit/editor-common": "^95.6.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
@@ -41,14 +41,14 @@
41
41
  "@atlaskit/editor-prosemirror": "6.0.0",
42
42
  "@atlaskit/editor-shared-styles": "^3.2.0",
43
43
  "@atlaskit/editor-tables": "^2.8.0",
44
- "@atlaskit/icon": "^22.25.0",
44
+ "@atlaskit/icon": "^22.26.0",
45
45
  "@atlaskit/platform-feature-flags": "^0.3.0",
46
46
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
47
47
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
48
48
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
49
49
  "@atlaskit/primitives": "^13.2.0",
50
50
  "@atlaskit/theme": "^14.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^2.19.0",
51
+ "@atlaskit/tmp-editor-statsig": "^2.21.0",
52
52
  "@atlaskit/tokens": "^2.3.0",
53
53
  "@atlaskit/tooltip": "^18.9.0",
54
54
  "@babel/runtime": "^7.0.0",