@atlaskit/editor-plugin-block-controls 1.4.27 → 1.4.29

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,28 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 1.4.29
4
+
5
+ ### Patch Changes
6
+
7
+ - [#113919](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113919)
8
+ [`b23ee751fde25`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b23ee751fde25) -
9
+ [ux] fix : the page is not scrolled down when click on the handle of a long node
10
+ - [#113848](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113848)
11
+ [`173e8cc6ecdb3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/173e8cc6ecdb3) -
12
+ ED-23779 fix undo caused wrong selector position
13
+
14
+ ## 1.4.28
15
+
16
+ ### Patch Changes
17
+
18
+ - [#113750](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113750)
19
+ [`f0bb95b1231d8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f0bb95b1231d8) -
20
+ [ux] Fix drag handle pos for block and embed card nodes
21
+ - [#114031](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/114031)
22
+ [`a9de475bcf1f7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a9de475bcf1f7) -
23
+ Highlight whole node when selecting decistion list via drag handle
24
+ - Updated dependencies
25
+
3
26
  ## 1.4.27
4
27
 
5
28
  ### Patch Changes
@@ -89,7 +89,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
89
89
  return initialState;
90
90
  },
91
91
  apply: function apply(tr, currentState, oldState, newState) {
92
- var _meta$activeNode, _meta$isDragging, _meta$editorHeight;
92
+ var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight;
93
93
  if (initialState.isDocSizeLimitEnabled && newState.doc.nodeSize > DRAG_AND_DROP_DOC_SIZE_LIMIT) {
94
94
  return initialState;
95
95
  }
@@ -123,7 +123,15 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
123
123
 
124
124
  // This is not targeted enough - it's trying to catch events like expand being set to breakout
125
125
  var maybeWidthUpdated = tr.docChanged && oldState.doc.nodeSize === newState.doc.nodeSize && !nodeCountChanged;
126
- var redrawDecorations = decorations === _view.DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || maybeWidthUpdated || nodeCountChanged || resizerMeta === false || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
126
+
127
+ // This addresses scenarios such as undoing table resizing,
128
+ // where a keyboard shortcut triggers a width change, and
129
+ // the node's actual width is then updated in a separate renderering cycle.
130
+ // The tr.meta.activeNode is triggered by the showDragHandleAt function during the mouse entry event
131
+ // (when the table node rerenders)
132
+ // The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
133
+ var maybeNodeWidthUpdated = (meta === null || meta === void 0 ? void 0 : meta.activeNode) && (meta === null || meta === void 0 || (_meta$activeNode = meta.activeNode) === null || _meta$activeNode === void 0 ? void 0 : _meta$activeNode.nodeType) === 'table' && meta.activeNode.anchorName === (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName);
134
+ var redrawDecorations = decorations === _view.DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || maybeWidthUpdated || nodeCountChanged || maybeNodeWidthUpdated || resizerMeta === false || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
127
135
 
128
136
  // Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
129
137
  if (redrawDecorations && !isResizerResizing && api) {
@@ -204,7 +212,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
204
212
  return {
205
213
  decorations: decorations,
206
214
  decorationState: decorationState,
207
- activeNode: isEmptyDoc ? null : (_meta$activeNode = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode !== void 0 ? _meta$activeNode : mappedActiveNodePos,
215
+ activeNode: isEmptyDoc ? null : (_meta$activeNode2 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode2 !== void 0 ? _meta$activeNode2 : mappedActiveNodePos,
208
216
  isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
209
217
  isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
210
218
  editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
@@ -248,15 +256,23 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
248
256
  var dom = editorView.dom;
249
257
 
250
258
  // Use ResizeObserver to observe height changes
251
- var resizeObserver = new ResizeObserver((0, _rafSchd.default)(function () {
252
- var editorHeight = dom.offsetHeight;
259
+ var resizeObserver = new ResizeObserver((0, _rafSchd.default)(function (entries) {
260
+ var editorHeight = entries[0].contentBoxSize[0].blockSize;
253
261
 
254
262
  // Update the plugin state when the height changes
255
263
  var pluginState = key.getState(editorView.state);
256
264
  if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDragging)) {
257
- editorView.dispatch(editorView.state.tr.setMeta(key, {
258
- editorHeight: editorHeight
259
- }));
265
+ var isResizerResizing = !!dom.querySelector('.is-resizing');
266
+ var transaction = editorView.state.tr;
267
+ if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.isResizerResizing) !== isResizerResizing) {
268
+ transaction.setMeta('is-resizer-resizing', isResizerResizing);
269
+ }
270
+ if (!isResizerResizing) {
271
+ transaction.setMeta(key, {
272
+ editorHeight: editorHeight
273
+ });
274
+ }
275
+ editorView.dispatch(transaction);
260
276
  }
261
277
  }));
262
278
 
@@ -3,10 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.dragHandleGap = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
6
+ exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
7
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
7
8
  var DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_HEIGHT = 24;
8
9
  var DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_WIDTH = 12;
9
10
  var DRAG_HANDLE_BORDER_RADIUS = exports.DRAG_HANDLE_BORDER_RADIUS = 4;
11
+ var DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_ZINDEX = _editorSharedStyles.akRichMediaResizeZIndex + _editorSharedStyles.akEditorUnitZIndex; //place above legacy resizer
12
+
10
13
  var nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
11
14
  var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType) {
12
15
  if (nodeTypeExcludeList.includes(nodeType)) {
@@ -40,7 +40,8 @@ var dragHandleButtonStyles = (0, _react2.css)({
40
40
  borderRadius: _consts.DRAG_HANDLE_BORDER_RADIUS,
41
41
  color: "var(--ds-icon, #44546F)",
42
42
  cursor: 'grab',
43
- zIndex: 2,
43
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
44
+ zIndex: _consts.DRAG_HANDLE_ZINDEX,
44
45
  '&:hover': {
45
46
  backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
46
47
  },
@@ -60,14 +61,35 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
60
61
  nodeType = _ref.nodeType;
61
62
  var start = getPos();
62
63
  var buttonRef = (0, _react.useRef)(null);
63
- var _useState = (0, _react.useState)(false),
64
+ var _useState = (0, _react.useState)(768),
64
65
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
65
- dragHandleSelected = _useState2[0],
66
- setDragHandleSelected = _useState2[1];
66
+ blockCardWidth = _useState2[0],
67
+ setBlockCardWidth = _useState2[1];
68
+ var _useState3 = (0, _react.useState)(false),
69
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
70
+ dragHandleSelected = _useState4[0],
71
+ setDragHandleSelected = _useState4[1];
67
72
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['featureFlags']),
68
73
  featureFlagsState = _useSharedPluginState.featureFlagsState;
74
+ (0, _react.useEffect)(function () {
75
+ // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
76
+ if (nodeType === 'blockCard') {
77
+ var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
78
+ var container = dom === null || dom === void 0 ? void 0 : dom.querySelector('.datasourceView-content-inner-wrap');
79
+ if (container) {
80
+ var resizeObserver = new ResizeObserver(function (entries) {
81
+ var width = entries[0].contentBoxSize[0].inlineSize;
82
+ setBlockCardWidth(width);
83
+ });
84
+ resizeObserver.observe(container);
85
+ return function () {
86
+ return resizeObserver.unobserve(container);
87
+ };
88
+ }
89
+ }
90
+ }, [anchorName, nodeType, view.dom]);
69
91
  var handleOnClick = (0, _react.useCallback)(function () {
70
- var _api$core, _api$core2;
92
+ var _api$core;
71
93
  setDragHandleSelected(!dragHandleSelected);
72
94
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
73
95
  var tr = _ref2.tr;
@@ -80,15 +102,15 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
80
102
  });
81
103
  return tr;
82
104
  });
83
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
84
- }, [start, api, dragHandleSelected, setDragHandleSelected, nodeType]);
105
+ view.focus();
106
+ }, [start, api, view, dragHandleSelected, setDragHandleSelected, nodeType]);
85
107
 
86
108
  // handleMouseDown required along with onClick to ensure the correct selection
87
109
  // is set immediately when the drag handle is clicked. Otherwise browser native
88
110
  // drag and drop can take over and cause unpredictable behaviour.
89
111
  var handleMouseDown = (0, _react.useCallback)(function () {
90
- var _api$core3, _api$core4;
91
- api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
112
+ var _api$core2;
113
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
92
114
  var tr = _ref3.tr;
93
115
  if (start === undefined) {
94
116
  return tr;
@@ -99,8 +121,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
99
121
  });
100
122
  return tr;
101
123
  });
102
- api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.focus();
103
- }, [start, api, nodeType]);
124
+ view.focus();
125
+ }, [start, api, view, nodeType]);
104
126
  (0, _react.useEffect)(function () {
105
127
  var element = buttonRef.current;
106
128
  if (!element) {
@@ -129,11 +151,11 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
129
151
  });
130
152
  },
131
153
  onDragStart: function onDragStart() {
132
- var _api$core5, _api$core6;
154
+ var _api$core3;
133
155
  if (start === undefined) {
134
156
  return;
135
157
  }
136
- api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
158
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref6) {
137
159
  var _api$blockControls, _api$analytics;
138
160
  var tr = _ref6.tr;
139
161
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setNodeDragged(start, anchorName, nodeType)({
@@ -141,6 +163,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
141
163
  });
142
164
  var resolvedMovingNode = tr.doc.resolve(start);
143
165
  var maybeNode = resolvedMovingNode.nodeAfter;
166
+ tr.setMeta('scrollIntoView', false);
144
167
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
145
168
  eventType: _analytics.EVENT_TYPE.UI,
146
169
  action: _analytics.ACTION.DRAGGED,
@@ -153,20 +176,34 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
153
176
  })(tr);
154
177
  return tr;
155
178
  });
156
- api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.focus();
179
+ view.focus();
157
180
  }
158
181
  });
159
- }, [api, start, view, anchorName, nodeType]);
182
+ }, [anchorName, api, nodeType, view, start]);
160
183
  var macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
161
184
  var positionStyles = (0, _react.useMemo)(function () {
162
185
  var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
163
186
  var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
164
- var hasResizer = anchorName.includes('table') || anchorName.includes('mediaSingle');
165
- var isExtension = anchorName.includes('extension') || anchorName.includes('bodiedExtension');
166
- var innerContainer = dom ? hasResizer ? dom.querySelector('.resizer-item') : isExtension ? dom.querySelector('.extension-container[data-layout]') : null : null;
187
+ var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
188
+ var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension';
189
+ var isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
190
+ var isEmbedCard = nodeType === 'embedCard';
191
+ var innerContainer = null;
192
+ if (dom) {
193
+ if (isEmbedCard) {
194
+ innerContainer = dom.querySelector('.rich-media-item');
195
+ } else if (hasResizer) {
196
+ innerContainer = dom.querySelector('.resizer-item');
197
+ } else if (isExtension) {
198
+ innerContainer = dom.querySelector('.extension-container[data-layout]');
199
+ } else if (isBlockCard) {
200
+ //specific to datasource blockCard
201
+ innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
202
+ }
203
+ }
167
204
  if (supportsAnchor) {
168
205
  return {
169
- left: hasResizer || isExtension ? (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType), "px)"),
206
+ left: hasResizer || isExtension || isBlockCard || isEmbedCard ? (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType), "px)"),
170
207
  top: anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
171
208
  };
172
209
  }
@@ -174,7 +211,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
174
211
  left: (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates),
175
212
  top: (0, _dragHandlePositions.getTopPosition)(dom)
176
213
  };
177
- }, [anchorName, view, nodeType, macroInteractionUpdates]);
214
+ }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates]);
178
215
  return (0, _react2.jsx)("button", {
179
216
  type: "button",
180
217
  css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
@@ -10,6 +10,7 @@ var _react = require("react");
10
10
  var _react2 = require("@emotion/react");
11
11
  var _bindEventListener = require("bind-event-listener");
12
12
  var _dragHandlePositions = require("../utils/drag-handle-positions");
13
+ var _consts = require("./consts");
13
14
  /** @jsx jsx */
14
15
 
15
16
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
@@ -22,7 +23,8 @@ var basicStyles = (0, _react2.css)({
22
23
  zIndex: -1
23
24
  });
24
25
  var mouseMoveWrapperStyles = (0, _react2.css)({
25
- zIndex: 1
26
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
27
+ zIndex: _consts.DRAG_HANDLE_ZINDEX
26
28
  });
27
29
  var MouseMoveWrapper = exports.MouseMoveWrapper = function MouseMoveWrapper(_ref) {
28
30
  var view = _ref.view,
@@ -11,7 +11,9 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
11
11
  var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
12
12
  var nodeSize = node ? node.nodeSize : 1;
13
13
  var $startPos = tr.doc.resolve(start);
14
- if (isNodeSelection) {
14
+
15
+ // decisionList node is not selectable, but we want to select the whole node not just text
16
+ if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
15
17
  return new _state.NodeSelection($startPos);
16
18
  } else {
17
19
  // To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
@@ -30,7 +32,7 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
30
32
  return true;
31
33
  });
32
34
  var inlineNodeDepth = inlineNodePos - start;
33
- return new _state.TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(start + nodeSize - inlineNodeDepth));
35
+ return new _state.TextSelection(tr.doc.resolve(start + nodeSize - inlineNodeDepth), tr.doc.resolve(inlineNodePos));
34
36
  }
35
37
  };
36
38
  var selectNode = exports.selectNode = function selectNode(tr, start, nodeType) {
@@ -83,7 +83,7 @@ export const createPlugin = api => {
83
83
  return initialState;
84
84
  },
85
85
  apply(tr, currentState, oldState, newState) {
86
- var _meta$activeNode, _meta$isDragging, _meta$editorHeight;
86
+ var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight;
87
87
  if (initialState.isDocSizeLimitEnabled && newState.doc.nodeSize > DRAG_AND_DROP_DOC_SIZE_LIMIT) {
88
88
  return initialState;
89
89
  }
@@ -116,7 +116,15 @@ export const createPlugin = api => {
116
116
 
117
117
  // This is not targeted enough - it's trying to catch events like expand being set to breakout
118
118
  const maybeWidthUpdated = tr.docChanged && oldState.doc.nodeSize === newState.doc.nodeSize && !nodeCountChanged;
119
- const redrawDecorations = decorations === DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || maybeWidthUpdated || nodeCountChanged || resizerMeta === false || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
119
+
120
+ // This addresses scenarios such as undoing table resizing,
121
+ // where a keyboard shortcut triggers a width change, and
122
+ // the node's actual width is then updated in a separate renderering cycle.
123
+ // The tr.meta.activeNode is triggered by the showDragHandleAt function during the mouse entry event
124
+ // (when the table node rerenders)
125
+ // The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
126
+ const maybeNodeWidthUpdated = (meta === null || meta === void 0 ? void 0 : meta.activeNode) && (meta === null || meta === void 0 ? void 0 : (_meta$activeNode = meta.activeNode) === null || _meta$activeNode === void 0 ? void 0 : _meta$activeNode.nodeType) === 'table' && meta.activeNode.anchorName === (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName);
127
+ const redrawDecorations = decorations === DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || maybeWidthUpdated || nodeCountChanged || maybeNodeWidthUpdated || resizerMeta === false || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
120
128
 
121
129
  // Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
122
130
  if (redrawDecorations && !isResizerResizing && api) {
@@ -197,7 +205,7 @@ export const createPlugin = api => {
197
205
  return {
198
206
  decorations,
199
207
  decorationState,
200
- activeNode: isEmptyDoc ? null : (_meta$activeNode = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode !== void 0 ? _meta$activeNode : mappedActiveNodePos,
208
+ activeNode: isEmptyDoc ? null : (_meta$activeNode2 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode2 !== void 0 ? _meta$activeNode2 : mappedActiveNodePos,
201
209
  isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
202
210
  isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
203
211
  editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
@@ -243,15 +251,23 @@ export const createPlugin = api => {
243
251
  const dom = editorView.dom;
244
252
 
245
253
  // Use ResizeObserver to observe height changes
246
- const resizeObserver = new ResizeObserver(rafSchedule(() => {
247
- const editorHeight = dom.offsetHeight;
254
+ const resizeObserver = new ResizeObserver(rafSchedule(entries => {
255
+ const editorHeight = entries[0].contentBoxSize[0].blockSize;
248
256
 
249
257
  // Update the plugin state when the height changes
250
258
  const pluginState = key.getState(editorView.state);
251
259
  if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDragging)) {
252
- editorView.dispatch(editorView.state.tr.setMeta(key, {
253
- editorHeight
254
- }));
260
+ const isResizerResizing = !!dom.querySelector('.is-resizing');
261
+ const transaction = editorView.state.tr;
262
+ if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.isResizerResizing) !== isResizerResizing) {
263
+ transaction.setMeta('is-resizer-resizing', isResizerResizing);
264
+ }
265
+ if (!isResizerResizing) {
266
+ transaction.setMeta(key, {
267
+ editorHeight
268
+ });
269
+ }
270
+ editorView.dispatch(transaction);
255
271
  }
256
272
  }));
257
273
 
@@ -1,6 +1,9 @@
1
+ import { akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
1
2
  export const DRAG_HANDLE_HEIGHT = 24;
2
3
  export const DRAG_HANDLE_WIDTH = 12;
3
4
  export const DRAG_HANDLE_BORDER_RADIUS = 4;
5
+ export const DRAG_HANDLE_ZINDEX = akRichMediaResizeZIndex + akEditorUnitZIndex; //place above legacy resizer
6
+
4
7
  const nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
5
8
  export const dragHandleGap = nodeType => {
6
9
  if (nodeTypeExcludeList.includes(nodeType)) {
@@ -11,7 +11,7 @@ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/el
11
11
  import { key } from '../pm-plugins/main';
12
12
  import { selectNode } from '../utils';
13
13
  import { getLeftPosition, getTopPosition } from '../utils/drag-handle-positions';
14
- import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, dragHandleGap } from './consts';
14
+ import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap } from './consts';
15
15
  import { dragPreview } from './drag-preview';
16
16
  const dragHandleButtonStyles = css({
17
17
  position: 'absolute',
@@ -31,7 +31,8 @@ const dragHandleButtonStyles = css({
31
31
  borderRadius: DRAG_HANDLE_BORDER_RADIUS,
32
32
  color: "var(--ds-icon, #44546F)",
33
33
  cursor: 'grab',
34
- zIndex: 2,
34
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
35
+ zIndex: DRAG_HANDLE_ZINDEX,
35
36
  '&:hover': {
36
37
  backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
37
38
  },
@@ -52,12 +53,28 @@ export const DragHandle = ({
52
53
  }) => {
53
54
  const start = getPos();
54
55
  const buttonRef = useRef(null);
56
+ const [blockCardWidth, setBlockCardWidth] = useState(768);
55
57
  const [dragHandleSelected, setDragHandleSelected] = useState(false);
56
58
  const {
57
59
  featureFlagsState
58
60
  } = useSharedPluginState(api, ['featureFlags']);
61
+ useEffect(() => {
62
+ // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
63
+ if (nodeType === 'blockCard') {
64
+ const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
65
+ const container = dom === null || dom === void 0 ? void 0 : dom.querySelector('.datasourceView-content-inner-wrap');
66
+ if (container) {
67
+ const resizeObserver = new ResizeObserver(entries => {
68
+ const width = entries[0].contentBoxSize[0].inlineSize;
69
+ setBlockCardWidth(width);
70
+ });
71
+ resizeObserver.observe(container);
72
+ return () => resizeObserver.unobserve(container);
73
+ }
74
+ }
75
+ }, [anchorName, nodeType, view.dom]);
59
76
  const handleOnClick = useCallback(() => {
60
- var _api$core, _api$core2;
77
+ var _api$core;
61
78
  setDragHandleSelected(!dragHandleSelected);
62
79
  api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
63
80
  tr
@@ -71,15 +88,15 @@ export const DragHandle = ({
71
88
  });
72
89
  return tr;
73
90
  });
74
- api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.focus();
75
- }, [start, api, dragHandleSelected, setDragHandleSelected, nodeType]);
91
+ view.focus();
92
+ }, [start, api, view, dragHandleSelected, setDragHandleSelected, nodeType]);
76
93
 
77
94
  // handleMouseDown required along with onClick to ensure the correct selection
78
95
  // is set immediately when the drag handle is clicked. Otherwise browser native
79
96
  // drag and drop can take over and cause unpredictable behaviour.
80
97
  const handleMouseDown = useCallback(() => {
81
- var _api$core3, _api$core4;
82
- api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
98
+ var _api$core2;
99
+ api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
83
100
  tr
84
101
  }) => {
85
102
  if (start === undefined) {
@@ -91,8 +108,8 @@ export const DragHandle = ({
91
108
  });
92
109
  return tr;
93
110
  });
94
- api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions.focus();
95
- }, [start, api, nodeType]);
111
+ view.focus();
112
+ }, [start, api, view, nodeType]);
96
113
  useEffect(() => {
97
114
  const element = buttonRef.current;
98
115
  if (!element) {
@@ -121,11 +138,11 @@ export const DragHandle = ({
121
138
  });
122
139
  },
123
140
  onDragStart() {
124
- var _api$core5, _api$core6;
141
+ var _api$core3;
125
142
  if (start === undefined) {
126
143
  return;
127
144
  }
128
- api === null || api === void 0 ? void 0 : (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions.execute(({
145
+ api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
129
146
  tr
130
147
  }) => {
131
148
  var _api$blockControls, _api$analytics;
@@ -134,6 +151,7 @@ export const DragHandle = ({
134
151
  });
135
152
  const resolvedMovingNode = tr.doc.resolve(start);
136
153
  const maybeNode = resolvedMovingNode.nodeAfter;
154
+ tr.setMeta('scrollIntoView', false);
137
155
  api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
138
156
  eventType: EVENT_TYPE.UI,
139
157
  action: ACTION.DRAGGED,
@@ -146,20 +164,34 @@ export const DragHandle = ({
146
164
  })(tr);
147
165
  return tr;
148
166
  });
149
- api === null || api === void 0 ? void 0 : (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions.focus();
167
+ view.focus();
150
168
  }
151
169
  });
152
- }, [api, start, view, anchorName, nodeType]);
170
+ }, [anchorName, api, nodeType, view, start]);
153
171
  const macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
154
172
  const positionStyles = useMemo(() => {
155
173
  const supportsAnchor = CSS.supports('top', `anchor(${anchorName} start)`) && CSS.supports('left', `anchor(${anchorName} start)`);
156
174
  const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
157
- const hasResizer = anchorName.includes('table') || anchorName.includes('mediaSingle');
158
- const isExtension = anchorName.includes('extension') || anchorName.includes('bodiedExtension');
159
- const innerContainer = dom ? hasResizer ? dom.querySelector('.resizer-item') : isExtension ? dom.querySelector('.extension-container[data-layout]') : null : null;
175
+ const hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
176
+ const isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension';
177
+ const isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
178
+ const isEmbedCard = nodeType === 'embedCard';
179
+ let innerContainer = null;
180
+ if (dom) {
181
+ if (isEmbedCard) {
182
+ innerContainer = dom.querySelector('.rich-media-item');
183
+ } else if (hasResizer) {
184
+ innerContainer = dom.querySelector('.resizer-item');
185
+ } else if (isExtension) {
186
+ innerContainer = dom.querySelector('.extension-container[data-layout]');
187
+ } else if (isBlockCard) {
188
+ //specific to datasource blockCard
189
+ innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
190
+ }
191
+ }
160
192
  if (supportsAnchor) {
161
193
  return {
162
- left: hasResizer || isExtension ? getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates) : `calc(anchor(${anchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType)}px)`,
194
+ left: hasResizer || isExtension || isBlockCard || isEmbedCard ? getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates) : `calc(anchor(${anchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType)}px)`,
163
195
  top: anchorName.includes('table') ? `calc(anchor(${anchorName} start) + ${DRAG_HANDLE_HEIGHT}px)` : `anchor(${anchorName} start)`
164
196
  };
165
197
  }
@@ -167,7 +199,7 @@ export const DragHandle = ({
167
199
  left: getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates),
168
200
  top: getTopPosition(dom)
169
201
  };
170
- }, [anchorName, view, nodeType, macroInteractionUpdates]);
202
+ }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates]);
171
203
  return jsx("button", {
172
204
  type: "button",
173
205
  css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
@@ -5,6 +5,7 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react
5
5
  import { css, jsx } from '@emotion/react';
6
6
  import { bind } from 'bind-event-listener';
7
7
  import { getTopPosition } from '../utils/drag-handle-positions';
8
+ import { DRAG_HANDLE_ZINDEX } from './consts';
8
9
  const basicStyles = css({
9
10
  position: 'absolute',
10
11
  width: '100%',
@@ -13,7 +14,8 @@ const basicStyles = css({
13
14
  zIndex: -1
14
15
  });
15
16
  const mouseMoveWrapperStyles = css({
16
- zIndex: 1
17
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
18
+ zIndex: DRAG_HANDLE_ZINDEX
17
19
  });
18
20
  export const MouseMoveWrapper = ({
19
21
  view,
@@ -5,7 +5,9 @@ export const getSelection = (tr, start) => {
5
5
  const isNodeSelection = node && NodeSelection.isSelectable(node);
6
6
  const nodeSize = node ? node.nodeSize : 1;
7
7
  const $startPos = tr.doc.resolve(start);
8
- if (isNodeSelection) {
8
+
9
+ // decisionList node is not selectable, but we want to select the whole node not just text
10
+ if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
9
11
  return new NodeSelection($startPos);
10
12
  } else {
11
13
  // To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
@@ -24,7 +26,7 @@ export const getSelection = (tr, start) => {
24
26
  return true;
25
27
  });
26
28
  const inlineNodeDepth = inlineNodePos - start;
27
- return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(start + nodeSize - inlineNodeDepth));
29
+ return new TextSelection(tr.doc.resolve(start + nodeSize - inlineNodeDepth), tr.doc.resolve(inlineNodePos));
28
30
  }
29
31
  };
30
32
  export const selectNode = (tr, start, nodeType) => {
@@ -82,7 +82,7 @@ export var createPlugin = function createPlugin(api) {
82
82
  return initialState;
83
83
  },
84
84
  apply: function apply(tr, currentState, oldState, newState) {
85
- var _meta$activeNode, _meta$isDragging, _meta$editorHeight;
85
+ var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight;
86
86
  if (initialState.isDocSizeLimitEnabled && newState.doc.nodeSize > DRAG_AND_DROP_DOC_SIZE_LIMIT) {
87
87
  return initialState;
88
88
  }
@@ -116,7 +116,15 @@ export var createPlugin = function createPlugin(api) {
116
116
 
117
117
  // This is not targeted enough - it's trying to catch events like expand being set to breakout
118
118
  var maybeWidthUpdated = tr.docChanged && oldState.doc.nodeSize === newState.doc.nodeSize && !nodeCountChanged;
119
- var redrawDecorations = decorations === DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || maybeWidthUpdated || nodeCountChanged || resizerMeta === false || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
119
+
120
+ // This addresses scenarios such as undoing table resizing,
121
+ // where a keyboard shortcut triggers a width change, and
122
+ // the node's actual width is then updated in a separate renderering cycle.
123
+ // The tr.meta.activeNode is triggered by the showDragHandleAt function during the mouse entry event
124
+ // (when the table node rerenders)
125
+ // The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
126
+ var maybeNodeWidthUpdated = (meta === null || meta === void 0 ? void 0 : meta.activeNode) && (meta === null || meta === void 0 || (_meta$activeNode = meta.activeNode) === null || _meta$activeNode === void 0 ? void 0 : _meta$activeNode.nodeType) === 'table' && meta.activeNode.anchorName === (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName);
127
+ var redrawDecorations = decorations === DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || maybeWidthUpdated || nodeCountChanged || maybeNodeWidthUpdated || resizerMeta === false || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
120
128
 
121
129
  // Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
122
130
  if (redrawDecorations && !isResizerResizing && api) {
@@ -197,7 +205,7 @@ export var createPlugin = function createPlugin(api) {
197
205
  return {
198
206
  decorations: decorations,
199
207
  decorationState: decorationState,
200
- activeNode: isEmptyDoc ? null : (_meta$activeNode = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode !== void 0 ? _meta$activeNode : mappedActiveNodePos,
208
+ activeNode: isEmptyDoc ? null : (_meta$activeNode2 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode2 !== void 0 ? _meta$activeNode2 : mappedActiveNodePos,
201
209
  isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
202
210
  isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
203
211
  editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
@@ -241,15 +249,23 @@ export var createPlugin = function createPlugin(api) {
241
249
  var dom = editorView.dom;
242
250
 
243
251
  // Use ResizeObserver to observe height changes
244
- var resizeObserver = new ResizeObserver(rafSchedule(function () {
245
- var editorHeight = dom.offsetHeight;
252
+ var resizeObserver = new ResizeObserver(rafSchedule(function (entries) {
253
+ var editorHeight = entries[0].contentBoxSize[0].blockSize;
246
254
 
247
255
  // Update the plugin state when the height changes
248
256
  var pluginState = key.getState(editorView.state);
249
257
  if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDragging)) {
250
- editorView.dispatch(editorView.state.tr.setMeta(key, {
251
- editorHeight: editorHeight
252
- }));
258
+ var isResizerResizing = !!dom.querySelector('.is-resizing');
259
+ var transaction = editorView.state.tr;
260
+ if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.isResizerResizing) !== isResizerResizing) {
261
+ transaction.setMeta('is-resizer-resizing', isResizerResizing);
262
+ }
263
+ if (!isResizerResizing) {
264
+ transaction.setMeta(key, {
265
+ editorHeight: editorHeight
266
+ });
267
+ }
268
+ editorView.dispatch(transaction);
253
269
  }
254
270
  }));
255
271
 
@@ -1,6 +1,9 @@
1
+ import { akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
1
2
  export var DRAG_HANDLE_HEIGHT = 24;
2
3
  export var DRAG_HANDLE_WIDTH = 12;
3
4
  export var DRAG_HANDLE_BORDER_RADIUS = 4;
5
+ export var DRAG_HANDLE_ZINDEX = akRichMediaResizeZIndex + akEditorUnitZIndex; //place above legacy resizer
6
+
4
7
  var nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
5
8
  export var dragHandleGap = function dragHandleGap(nodeType) {
6
9
  if (nodeTypeExcludeList.includes(nodeType)) {
@@ -12,7 +12,7 @@ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/el
12
12
  import { key } from '../pm-plugins/main';
13
13
  import { selectNode } from '../utils';
14
14
  import { getLeftPosition, getTopPosition } from '../utils/drag-handle-positions';
15
- import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, dragHandleGap } from './consts';
15
+ import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap } from './consts';
16
16
  import { dragPreview } from './drag-preview';
17
17
  var dragHandleButtonStyles = css({
18
18
  position: 'absolute',
@@ -32,7 +32,8 @@ var dragHandleButtonStyles = css({
32
32
  borderRadius: DRAG_HANDLE_BORDER_RADIUS,
33
33
  color: "var(--ds-icon, #44546F)",
34
34
  cursor: 'grab',
35
- zIndex: 2,
35
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
36
+ zIndex: DRAG_HANDLE_ZINDEX,
36
37
  '&:hover': {
37
38
  backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
38
39
  },
@@ -52,14 +53,35 @@ export var DragHandle = function DragHandle(_ref) {
52
53
  nodeType = _ref.nodeType;
53
54
  var start = getPos();
54
55
  var buttonRef = useRef(null);
55
- var _useState = useState(false),
56
+ var _useState = useState(768),
56
57
  _useState2 = _slicedToArray(_useState, 2),
57
- dragHandleSelected = _useState2[0],
58
- setDragHandleSelected = _useState2[1];
58
+ blockCardWidth = _useState2[0],
59
+ setBlockCardWidth = _useState2[1];
60
+ var _useState3 = useState(false),
61
+ _useState4 = _slicedToArray(_useState3, 2),
62
+ dragHandleSelected = _useState4[0],
63
+ setDragHandleSelected = _useState4[1];
59
64
  var _useSharedPluginState = useSharedPluginState(api, ['featureFlags']),
60
65
  featureFlagsState = _useSharedPluginState.featureFlagsState;
66
+ useEffect(function () {
67
+ // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
68
+ if (nodeType === 'blockCard') {
69
+ var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
70
+ var container = dom === null || dom === void 0 ? void 0 : dom.querySelector('.datasourceView-content-inner-wrap');
71
+ if (container) {
72
+ var resizeObserver = new ResizeObserver(function (entries) {
73
+ var width = entries[0].contentBoxSize[0].inlineSize;
74
+ setBlockCardWidth(width);
75
+ });
76
+ resizeObserver.observe(container);
77
+ return function () {
78
+ return resizeObserver.unobserve(container);
79
+ };
80
+ }
81
+ }
82
+ }, [anchorName, nodeType, view.dom]);
61
83
  var handleOnClick = useCallback(function () {
62
- var _api$core, _api$core2;
84
+ var _api$core;
63
85
  setDragHandleSelected(!dragHandleSelected);
64
86
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
65
87
  var tr = _ref2.tr;
@@ -72,15 +94,15 @@ export var DragHandle = function DragHandle(_ref) {
72
94
  });
73
95
  return tr;
74
96
  });
75
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
76
- }, [start, api, dragHandleSelected, setDragHandleSelected, nodeType]);
97
+ view.focus();
98
+ }, [start, api, view, dragHandleSelected, setDragHandleSelected, nodeType]);
77
99
 
78
100
  // handleMouseDown required along with onClick to ensure the correct selection
79
101
  // is set immediately when the drag handle is clicked. Otherwise browser native
80
102
  // drag and drop can take over and cause unpredictable behaviour.
81
103
  var handleMouseDown = useCallback(function () {
82
- var _api$core3, _api$core4;
83
- api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
104
+ var _api$core2;
105
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
84
106
  var tr = _ref3.tr;
85
107
  if (start === undefined) {
86
108
  return tr;
@@ -91,8 +113,8 @@ export var DragHandle = function DragHandle(_ref) {
91
113
  });
92
114
  return tr;
93
115
  });
94
- api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.focus();
95
- }, [start, api, nodeType]);
116
+ view.focus();
117
+ }, [start, api, view, nodeType]);
96
118
  useEffect(function () {
97
119
  var element = buttonRef.current;
98
120
  if (!element) {
@@ -121,11 +143,11 @@ export var DragHandle = function DragHandle(_ref) {
121
143
  });
122
144
  },
123
145
  onDragStart: function onDragStart() {
124
- var _api$core5, _api$core6;
146
+ var _api$core3;
125
147
  if (start === undefined) {
126
148
  return;
127
149
  }
128
- api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
150
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref6) {
129
151
  var _api$blockControls, _api$analytics;
130
152
  var tr = _ref6.tr;
131
153
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setNodeDragged(start, anchorName, nodeType)({
@@ -133,6 +155,7 @@ export var DragHandle = function DragHandle(_ref) {
133
155
  });
134
156
  var resolvedMovingNode = tr.doc.resolve(start);
135
157
  var maybeNode = resolvedMovingNode.nodeAfter;
158
+ tr.setMeta('scrollIntoView', false);
136
159
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
137
160
  eventType: EVENT_TYPE.UI,
138
161
  action: ACTION.DRAGGED,
@@ -145,20 +168,34 @@ export var DragHandle = function DragHandle(_ref) {
145
168
  })(tr);
146
169
  return tr;
147
170
  });
148
- api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.focus();
171
+ view.focus();
149
172
  }
150
173
  });
151
- }, [api, start, view, anchorName, nodeType]);
174
+ }, [anchorName, api, nodeType, view, start]);
152
175
  var macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
153
176
  var positionStyles = useMemo(function () {
154
177
  var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
155
178
  var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
156
- var hasResizer = anchorName.includes('table') || anchorName.includes('mediaSingle');
157
- var isExtension = anchorName.includes('extension') || anchorName.includes('bodiedExtension');
158
- var innerContainer = dom ? hasResizer ? dom.querySelector('.resizer-item') : isExtension ? dom.querySelector('.extension-container[data-layout]') : null : null;
179
+ var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
180
+ var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension';
181
+ var isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
182
+ var isEmbedCard = nodeType === 'embedCard';
183
+ var innerContainer = null;
184
+ if (dom) {
185
+ if (isEmbedCard) {
186
+ innerContainer = dom.querySelector('.rich-media-item');
187
+ } else if (hasResizer) {
188
+ innerContainer = dom.querySelector('.resizer-item');
189
+ } else if (isExtension) {
190
+ innerContainer = dom.querySelector('.extension-container[data-layout]');
191
+ } else if (isBlockCard) {
192
+ //specific to datasource blockCard
193
+ innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
194
+ }
195
+ }
159
196
  if (supportsAnchor) {
160
197
  return {
161
- left: hasResizer || isExtension ? getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType), "px)"),
198
+ left: hasResizer || isExtension || isBlockCard || isEmbedCard ? getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType), "px)"),
162
199
  top: anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
163
200
  };
164
201
  }
@@ -166,7 +203,7 @@ export var DragHandle = function DragHandle(_ref) {
166
203
  left: getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates),
167
204
  top: getTopPosition(dom)
168
205
  };
169
- }, [anchorName, view, nodeType, macroInteractionUpdates]);
206
+ }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates]);
170
207
  return jsx("button", {
171
208
  type: "button",
172
209
  css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
@@ -6,6 +6,7 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react
6
6
  import { css, jsx } from '@emotion/react';
7
7
  import { bind } from 'bind-event-listener';
8
8
  import { getTopPosition } from '../utils/drag-handle-positions';
9
+ import { DRAG_HANDLE_ZINDEX } from './consts';
9
10
  var basicStyles = css({
10
11
  position: 'absolute',
11
12
  width: '100%',
@@ -14,7 +15,8 @@ var basicStyles = css({
14
15
  zIndex: -1
15
16
  });
16
17
  var mouseMoveWrapperStyles = css({
17
- zIndex: 1
18
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
19
+ zIndex: DRAG_HANDLE_ZINDEX
18
20
  });
19
21
  export var MouseMoveWrapper = function MouseMoveWrapper(_ref) {
20
22
  var view = _ref.view,
@@ -5,7 +5,9 @@ export var getSelection = function getSelection(tr, start) {
5
5
  var isNodeSelection = node && NodeSelection.isSelectable(node);
6
6
  var nodeSize = node ? node.nodeSize : 1;
7
7
  var $startPos = tr.doc.resolve(start);
8
- if (isNodeSelection) {
8
+
9
+ // decisionList node is not selectable, but we want to select the whole node not just text
10
+ if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
9
11
  return new NodeSelection($startPos);
10
12
  } else {
11
13
  // To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
@@ -24,7 +26,7 @@ export var getSelection = function getSelection(tr, start) {
24
26
  return true;
25
27
  });
26
28
  var inlineNodeDepth = inlineNodePos - start;
27
- return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(start + nodeSize - inlineNodeDepth));
29
+ return new TextSelection(tr.doc.resolve(start + nodeSize - inlineNodeDepth), tr.doc.resolve(inlineNodePos));
28
30
  }
29
31
  };
30
32
  export var selectNode = function selectNode(tr, start, nodeType) {
@@ -1,4 +1,5 @@
1
1
  export declare const DRAG_HANDLE_HEIGHT = 24;
2
2
  export declare const DRAG_HANDLE_WIDTH = 12;
3
3
  export declare const DRAG_HANDLE_BORDER_RADIUS = 4;
4
+ export declare const DRAG_HANDLE_ZINDEX: number;
4
5
  export declare const dragHandleGap: (nodeType: string) => 12 | 8;
@@ -1,6 +1,6 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
- import { type EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { BlockControlsPlugin } from '../types';
5
5
  export declare const DragHandle: ({ view, api, getPos, anchorName, nodeType, }: {
6
6
  view: EditorView;
@@ -1,6 +1,6 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
- import { type EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { BlockControlsPlugin } from '../types';
5
5
  export declare const MouseMoveWrapper: ({ view, api, anchorName, nodeType, getPos, }: {
6
6
  view: EditorView;
@@ -1,4 +1,5 @@
1
1
  export declare const DRAG_HANDLE_HEIGHT = 24;
2
2
  export declare const DRAG_HANDLE_WIDTH = 12;
3
3
  export declare const DRAG_HANDLE_BORDER_RADIUS = 4;
4
+ export declare const DRAG_HANDLE_ZINDEX: number;
4
5
  export declare const dragHandleGap: (nodeType: string) => 12 | 8;
@@ -1,6 +1,6 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
- import { type EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { BlockControlsPlugin } from '../types';
5
5
  export declare const DragHandle: ({ view, api, getPos, anchorName, nodeType, }: {
6
6
  view: EditorView;
@@ -1,6 +1,6 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
- import { type EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { BlockControlsPlugin } from '../types';
5
5
  export declare const MouseMoveWrapper: ({ view, api, anchorName, nodeType, getPos, }: {
6
6
  view: EditorView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "1.4.27",
3
+ "version": "1.4.29",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,13 +31,14 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/adf-schema": "^36.10.7",
35
- "@atlaskit/editor-common": "^82.10.0",
36
- "@atlaskit/editor-plugin-analytics": "^1.2.3",
34
+ "@atlaskit/adf-schema": "^37.0.0",
35
+ "@atlaskit/editor-common": "^82.13.0",
36
+ "@atlaskit/editor-plugin-analytics": "^1.3.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.1.5",
38
38
  "@atlaskit/editor-plugin-feature-flags": "^1.1.0",
39
39
  "@atlaskit/editor-plugin-width": "^1.1.0",
40
40
  "@atlaskit/editor-prosemirror": "4.0.1",
41
+ "@atlaskit/editor-shared-styles": "^2.12.0",
41
42
  "@atlaskit/editor-tables": "^2.7.0",
42
43
  "@atlaskit/icon": "^22.4.0",
43
44
  "@atlaskit/platform-feature-flags": "^0.2.0",
@@ -45,7 +46,7 @@
45
46
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.3.0",
46
47
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
47
48
  "@atlaskit/theme": "^12.11.0",
48
- "@atlaskit/tokens": "^1.52.0",
49
+ "@atlaskit/tokens": "^1.53.0",
49
50
  "@babel/runtime": "^7.0.0",
50
51
  "@emotion/react": "^11.7.1",
51
52
  "bind-event-listener": "^3.0.0",