@atlaskit/editor-plugin-block-controls 3.2.1 → 3.3.1

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,29 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 3.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#122490](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/122490)
8
+ [`6ec36bc622c47`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6ec36bc622c47) -
9
+ Check for undefined on root pos before inserting
10
+
11
+ ## 3.3.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#120928](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/120928)
16
+ [`01cb5ca9596cf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/01cb5ca9596cf) -
17
+ [ED-26316] Refactor checkTrActionType functions to be in it's own file to help with readability,
18
+ add check for safe insert count and update it in analytics event fired
19
+
20
+ ### Patch Changes
21
+
22
+ - [#121803](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/121803)
23
+ [`41a43b5d95052`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/41a43b5d95052) -
24
+ Fix logic for determining drag handle corresponding to selection, shortcuts
25
+ - Updated dependencies
26
+
3
27
  ## 3.2.1
4
28
 
5
29
  ### Patch Changes
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _selection = require("@atlaskit/editor-common/selection");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
13
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
14
  var _moveNode = require("./editor-commands/move-node");
14
15
  var _moveToLayout = require("./editor-commands/move-to-layout");
@@ -89,6 +90,15 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
89
90
  nodeType: nodeType
90
91
  }
91
92
  }));
93
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
94
+ var _api$metrics;
95
+ api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.handleIntentToStartEdit({
96
+ shouldStartTimer: false,
97
+ shouldPersistActiveSession: true
98
+ })({
99
+ tr: tr
100
+ });
101
+ }
92
102
  return tr;
93
103
  };
94
104
  },
@@ -93,6 +93,7 @@ var getFocusedHandle = function getFocusedHandle(state) {
93
93
  };
94
94
  var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, formatMessage) {
95
95
  return function (state) {
96
+ var _hoistedPos;
96
97
  var isParentNodeOfTypeLayout;
97
98
  var shouldEnableNestedDndA11y = (0, _experiments.editorExperiment)('nested-dnd', true);
98
99
  var selection = state.selection;
@@ -103,19 +104,26 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
103
104
  var expandedSelection = (0, _selection.expandSelectionBounds)(selection.$anchor, selection.$head);
104
105
  var expandedAnchor = expandedSelection.$anchor.pos;
105
106
  var expandedHead = expandedSelection.$head.pos;
106
- var currentNodePos = isMultiSelectEnabled && !getFocusedHandle(state) ? Math.min(expandedAnchor, expandedHead) : getCurrentNodePos(state);
107
+ var hoistedPos;
108
+ var from = Math.min(expandedAnchor, expandedHead);
109
+ // Nodes like lists nest within themselves, we need to find the top most position
110
+ if (isParentNodeOfTypeLayout && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1')) {
111
+ var LAYOUT_COL_DEPTH = 3;
112
+ hoistedPos = state.doc.resolve(from).before(LAYOUT_COL_DEPTH);
113
+ }
114
+ var currentNodePos = isMultiSelectEnabled && !getFocusedHandle(state) && !selection.empty ? (_hoistedPos = hoistedPos) !== null && _hoistedPos !== void 0 ? _hoistedPos : from : getCurrentNodePos(state);
107
115
  if (currentNodePos > -1) {
108
116
  var _state$doc$nodeAt;
109
- var $pos = state.doc.resolve(currentNodePos);
110
- var nodeAfterPos = isMultiSelectEnabled && !getFocusedHandle(state) ? Math.max(expandedAnchor, expandedHead) : $pos.posAtIndex($pos.index() + 1);
111
- var isTopLevelNode = $pos.depth === 0;
117
+ var $currentNodePos = state.doc.resolve(currentNodePos);
118
+ var nodeAfterPos = isMultiSelectEnabled && !getFocusedHandle(state) ? Math.max(expandedAnchor, expandedHead) : $currentNodePos.posAtIndex($currentNodePos.index() + 1);
119
+ var isTopLevelNode = $currentNodePos.depth === 0;
112
120
  var moveToPos = -1;
113
- var nodeIndex = $pos.index();
121
+ var nodeIndex = $currentNodePos.index();
114
122
  var isLayoutColumnSelected = selection instanceof _state.NodeSelection && selection.node.type.name === 'layoutColumn';
115
123
  if (direction === _consts.DIRECTION.LEFT && shouldEnableNestedDndA11y) {
116
124
  if (isTopLevelNode && (0, _experiments.editorExperiment)('advanced_layouts', true) && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_accessibility')) {
117
125
  var _api$core, _api$core2;
118
- var nodeBefore = $pos.nodeBefore;
126
+ var nodeBefore = $currentNodePos.nodeBefore;
119
127
  if (nodeBefore) {
120
128
  moveToPos = currentNodePos - nodeBefore.nodeSize;
121
129
  }
@@ -139,28 +147,28 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
139
147
  api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
140
148
  return true;
141
149
  } else if (isLayoutColumnSelected && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_accessibility')) {
142
- var _$pos$nodeBefore, _api$core3, _api$blockControls2;
143
- moveToPos = selection.from - (((_$pos$nodeBefore = $pos.nodeBefore) === null || _$pos$nodeBefore === void 0 ? void 0 : _$pos$nodeBefore.nodeSize) || 1);
150
+ var _$currentNodePos$node, _api$core3, _api$blockControls2;
151
+ moveToPos = selection.from - (((_$currentNodePos$node = $currentNodePos.nodeBefore) === null || _$currentNodePos$node === void 0 ? void 0 : _$currentNodePos$node.nodeSize) || 1);
144
152
  api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveToLayout(currentNodePos, moveToPos, {
145
153
  selectMovedNode: true
146
154
  }));
147
155
  return true;
148
156
  } else {
149
- if ($pos.depth < 2 || !isParentNodeOfTypeLayout) {
157
+ if ($currentNodePos.depth < 2 || !isParentNodeOfTypeLayout) {
150
158
  return false;
151
159
  }
152
160
 
153
161
  // get the previous layoutSection node
154
- var index = $pos.index($pos.depth - 1);
155
- var grandParent = $pos.node($pos.depth - 1);
162
+ var index = $currentNodePos.index($currentNodePos.depth - 1);
163
+ var grandParent = $currentNodePos.node($currentNodePos.depth - 1);
156
164
  var previousNode = grandParent ? grandParent.maybeChild(index - 1) : null;
157
- moveToPos = $pos.start() - ((previousNode === null || previousNode === void 0 ? void 0 : previousNode.nodeSize) || 1);
165
+ moveToPos = $currentNodePos.start() - ((previousNode === null || previousNode === void 0 ? void 0 : previousNode.nodeSize) || 1);
158
166
  }
159
167
  } else if (direction === _consts.DIRECTION.RIGHT && shouldEnableNestedDndA11y) {
160
168
  if (isTopLevelNode && (0, _experiments.editorExperiment)('advanced_layouts', true) && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_accessibility')) {
161
169
  var _api$core4, _api$core5;
162
- var endOfDoc = $pos.end();
163
- moveToPos = $pos.posAtIndex($pos.index() + 1);
170
+ var endOfDoc = $currentNodePos.end();
171
+ moveToPos = $currentNodePos.posAtIndex($currentNodePos.index() + 1);
164
172
  if (moveToPos >= endOfDoc) {
165
173
  return false;
166
174
  }
@@ -181,8 +189,8 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
181
189
  return true;
182
190
  } else if (isLayoutColumnSelected && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_accessibility')) {
183
191
  var _api$core6, _api$blockControls4;
184
- var _index = $pos.index($pos.depth);
185
- var parent = $pos.node($pos.depth);
192
+ var _index = $currentNodePos.index($currentNodePos.depth);
193
+ var parent = $currentNodePos.node($currentNodePos.depth);
186
194
  // get the next layoutColumn node
187
195
  var nextNode = parent ? parent.maybeChild(_index + 1) : null;
188
196
 
@@ -192,29 +200,29 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
192
200
  return true;
193
201
  }
194
202
  var moveToEnd = _index === parent.childCount - 2;
195
- moveToPos = moveToEnd ? $pos.before() : selection.to + ((nextNode === null || nextNode === void 0 ? void 0 : nextNode.nodeSize) || 1);
203
+ moveToPos = moveToEnd ? $currentNodePos.before() : selection.to + ((nextNode === null || nextNode === void 0 ? void 0 : nextNode.nodeSize) || 1);
196
204
  api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || (_api$blockControls4 = _api$blockControls4.commands) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.moveToLayout(currentNodePos, moveToPos, {
197
205
  moveToEnd: moveToEnd,
198
206
  selectMovedNode: true
199
207
  }));
200
208
  return true;
201
209
  } else {
202
- if ($pos.depth < 2 || !isParentNodeOfTypeLayout) {
210
+ if ($currentNodePos.depth < 2 || !isParentNodeOfTypeLayout) {
203
211
  return false;
204
212
  }
205
- moveToPos = $pos.after($pos.depth) + 1;
213
+ moveToPos = $currentNodePos.after($currentNodePos.depth) + 1;
206
214
  }
207
215
  } else if (direction === _consts.DIRECTION.UP) {
208
216
  if (isLayoutColumnSelected && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_accessibility')) {
209
- moveToPos = $pos.start() - 1;
217
+ moveToPos = $currentNodePos.start() - 1;
210
218
  } else {
211
- var _nodeBefore = $pos.depth > 1 && nodeIndex === 0 && shouldEnableNestedDndA11y ? $pos.node($pos.depth) : $pos.nodeBefore;
219
+ var _nodeBefore = $currentNodePos.depth > 1 && nodeIndex === 0 && shouldEnableNestedDndA11y ? $currentNodePos.node($currentNodePos.depth) : $currentNodePos.nodeBefore;
212
220
  if (_nodeBefore) {
213
221
  moveToPos = currentNodePos - _nodeBefore.nodeSize;
214
222
  }
215
223
  }
216
224
  } else {
217
- var _endOfDoc = $pos.end();
225
+ var _endOfDoc = $currentNodePos.end();
218
226
  if (nodeAfterPos > _endOfDoc) {
219
227
  return false;
220
228
  }
@@ -231,14 +239,23 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
231
239
  var nodeType = (_state$doc$nodeAt = state.doc.nodeAt(currentNodePos)) === null || _state$doc$nodeAt === void 0 ? void 0 : _state$doc$nodeAt.type.name;
232
240
 
233
241
  // only move the node if the destination is at the same depth, not support moving a nested node to a parent node
234
- var shouldMoveNode = (shouldEnableNestedDndA11y ? moveToPos > -1 && $pos.depth === state.doc.resolve(moveToPos).depth || nodeType === 'layoutColumn' : moveToPos > -1) || nodeType === 'layoutColumn' && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_accessibility');
242
+ var shouldMoveNode = (shouldEnableNestedDndA11y ? moveToPos > -1 && $currentNodePos.depth === state.doc.resolve(moveToPos).depth || nodeType === 'layoutColumn' : moveToPos > -1) || nodeType === 'layoutColumn' && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_accessibility');
243
+ var _expandSelectionBound = (0, _selection.expandSelectionBounds)($currentNodePos, selection.$to),
244
+ $newAnchor = _expandSelectionBound.$anchor,
245
+ $newHead = _expandSelectionBound.$head;
235
246
  if (shouldMoveNode) {
236
247
  var _api$core7;
237
248
  api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref4) {
238
249
  var tr = _ref4.tr;
239
- api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
240
- tr: tr
241
- });
250
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1')) {
251
+ api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
252
+ tr: tr
253
+ });
254
+ } else {
255
+ api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
256
+ tr: tr
257
+ });
258
+ }
242
259
  moveNode(api)(currentNodePos, moveToPos, _analytics.INPUT_METHOD.SHORTCUT, formatMessage)({
243
260
  tr: tr
244
261
  });
@@ -260,9 +277,15 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
260
277
  var _api$core9;
261
278
  api === null || api === void 0 || (_api$core9 = api.core) === null || _api$core9 === void 0 || _api$core9.actions.execute(function (_ref6) {
262
279
  var tr = _ref6.tr;
263
- api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
264
- tr: tr
265
- });
280
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1')) {
281
+ api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
282
+ tr: tr
283
+ });
284
+ } else {
285
+ api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
286
+ tr: tr
287
+ });
288
+ }
266
289
  tr.scrollIntoView();
267
290
  return tr;
268
291
  });
@@ -293,6 +316,12 @@ var moveNode = exports.moveNode = function moveNode(api) {
293
316
  var isMultiSelect = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true, {
294
317
  exposure: true
295
318
  });
319
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
320
+ var _api$metrics;
321
+ api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.setContentMoved()({
322
+ tr: tr
323
+ });
324
+ }
296
325
  var slicePosition = (0, _selection2.getSelectedSlicePosition)(start, tr, api);
297
326
  if (isMultiSelect) {
298
327
  sliceFrom = slicePosition.from;
@@ -319,6 +319,12 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
319
319
  if (!fromContentWithoutBreakout) {
320
320
  return tr;
321
321
  }
322
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
323
+ var _api$metrics;
324
+ api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.setContentMoved()({
325
+ tr: tr
326
+ });
327
+ }
322
328
  var isMultiSelect = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true);
323
329
  if (toNode.type === layoutSection) {
324
330
  var toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize - 1 : to + 1;
@@ -138,6 +138,12 @@ var destroyFn = function destroyFn(api, editorView) {
138
138
  })
139
139
  })(tr);
140
140
  }
141
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
142
+ var _api$metrics;
143
+ api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.startActiveSessionTimer()({
144
+ tr: tr
145
+ });
146
+ }
141
147
  return tr.setMeta(key, _objectSpread(_objectSpread({}, tr.getMeta(key)), {}, {
142
148
  isDragging: false,
143
149
  isPMDragging: false,
@@ -313,24 +319,23 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
313
319
  var oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (_activeNode3 = activeNode) === null || _activeNode3 === void 0 ? void 0 : _activeNode3.pos, (_activeNode4 = activeNode) === null || _activeNode4 === void 0 ? void 0 : _activeNode4.pos);
314
320
  decorations = decorations.remove(oldHandle);
315
321
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
316
- var _activeNode5, _activeNode6;
317
- var oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (_activeNode5 = activeNode) === null || _activeNode5 === void 0 ? void 0 : _activeNode5.rootPos, (_activeNode6 = activeNode) === null || _activeNode6 === void 0 ? void 0 : _activeNode6.rootPos);
322
+ var oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations);
318
323
  decorations = decorations.remove(oldQuickInsertButton);
319
324
  }
320
325
  } else if (api && shouldRecreateHandle) {
321
- var _activeNode7, _activeNode8;
322
- var _oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (_activeNode7 = activeNode) === null || _activeNode7 === void 0 ? void 0 : _activeNode7.pos, (_activeNode8 = activeNode) === null || _activeNode8 === void 0 ? void 0 : _activeNode8.pos);
326
+ var _activeNode5, _activeNode6;
327
+ var _oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (_activeNode5 = activeNode) === null || _activeNode5 === void 0 ? void 0 : _activeNode5.pos, (_activeNode6 = activeNode) === null || _activeNode6 === void 0 ? void 0 : _activeNode6.pos);
323
328
  decorations = decorations.remove(_oldHandle);
324
329
  var handleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.pos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.anchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.nodeType, nodeViewPortalProviderAPI, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.handleOptions);
325
330
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
326
- var _activeNode9, _activeNode10;
327
- var _oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (_activeNode9 = activeNode) === null || _activeNode9 === void 0 ? void 0 : _activeNode9.rootPos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.rootPos);
328
- decorations = decorations.remove(_oldQuickInsertButton);
329
- var quickInsertButton = (0, _decorationsQuickInsertButton.quickInsertButtonDecoration)(api, formatMessage, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootPos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.anchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.nodeType, nodeViewPortalProviderAPI, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootAnchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootNodeType);
330
- decorations = decorations.add(newState.doc, [handleDec, quickInsertButton]);
331
- } else {
332
- decorations = decorations.add(newState.doc, [handleDec]);
331
+ if ((latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootPos) !== undefined) {
332
+ var _oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations);
333
+ decorations = decorations.remove(_oldQuickInsertButton);
334
+ var quickInsertButton = (0, _decorationsQuickInsertButton.quickInsertButtonDecoration)(api, formatMessage, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootPos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.anchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.nodeType, nodeViewPortalProviderAPI, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootAnchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootNodeType);
335
+ decorations = decorations.add(newState.doc, [quickInsertButton]);
336
+ }
333
337
  }
338
+ decorations = decorations.add(newState.doc, [handleDec]);
334
339
  }
335
340
 
336
341
  // Drop targets may be missing when the node count is being changed during a drag
@@ -591,7 +596,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
591
596
  },
592
597
  handleDOMEvents: {
593
598
  drop: function drop(view, event) {
594
- var _pluginState, _pluginState2, _pluginState3, _event$target;
599
+ var _pluginState, _pluginState2, _pluginState3, _event$target, _event$target$closest;
595
600
  // Prevent native DnD from triggering if we are in drag
596
601
  var dispatch = view.dispatch,
597
602
  dragging = view.dragging,
@@ -600,6 +605,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
600
605
  var pluginState = key.getState(state);
601
606
  var dndDragCancelled = (_pluginState = pluginState) === null || _pluginState === void 0 ? void 0 : _pluginState.lastDragCancelled;
602
607
  if ((_pluginState2 = pluginState) !== null && _pluginState2 !== void 0 && _pluginState2.isPMDragging || dndDragCancelled && isMultiSelectEnabled) {
608
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
609
+ var _api$metrics2;
610
+ api === null || api === void 0 || (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 || _api$metrics2.commands.startActiveSessionTimer()({
611
+ tr: tr
612
+ });
613
+ }
603
614
  dispatch(tr.setMeta(key, _objectSpread(_objectSpread({}, tr.getMeta(key)), {}, {
604
615
  isPMDragging: false,
605
616
  lastDragCancelled: false
@@ -617,7 +628,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
617
628
  event.preventDefault();
618
629
  return false;
619
630
  }
620
- var nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('[data-drag-handler-anchor-name]');
631
+ var nodeElement = (_event$target = event.target) === null || _event$target === void 0 || (_event$target$closest = _event$target.closest) === null || _event$target$closest === void 0 ? void 0 : _event$target$closest.call(_event$target, '[data-drag-handler-anchor-name]');
621
632
  if (!nodeElement) {
622
633
  return false;
623
634
  }
@@ -663,9 +674,17 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
663
674
  var state = view.state,
664
675
  dispatch = view.dispatch;
665
676
  if ((_key$getState3 = key.getState(state)) !== null && _key$getState3 !== void 0 && _key$getState3.isPMDragging) {
666
- dispatch(state.tr.setMeta(key, _objectSpread(_objectSpread({}, state.tr.getMeta(key)), {}, {
677
+ var tr = state.tr;
678
+ tr.setMeta(key, _objectSpread(_objectSpread({}, state.tr.getMeta(key)), {}, {
667
679
  isPMDragging: false
668
- })));
680
+ }));
681
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
682
+ var _api$metrics3;
683
+ api === null || api === void 0 || (_api$metrics3 = api.metrics) === null || _api$metrics3 === void 0 || _api$metrics3.commands.startActiveSessionTimer()({
684
+ tr: tr
685
+ });
686
+ }
687
+ dispatch(tr);
669
688
  }
670
689
  },
671
690
  mouseover: function mouseover(view, event) {
@@ -8,6 +8,7 @@ var _selection = require("@atlaskit/editor-common/selection");
8
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _utils = require("@atlaskit/editor-prosemirror/utils");
10
10
  var _utils2 = require("@atlaskit/editor-tables/utils");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  var getInlineNodePos = exports.getInlineNodePos = function getInlineNodePos(tr, start, nodeSize) {
12
13
  var $startPos = tr.doc.resolve(start);
13
14
  // To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
@@ -59,6 +60,8 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
59
60
  // we need a quick way to make all child media nodes appear as selected without the need for a custom selection
60
61
  nodeName === 'mediaGroup') {
61
62
  return new _state.NodeSelection($startPos);
63
+ } else if (nodeName === 'taskList' && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1')) {
64
+ return _state.TextSelection.create(tr.doc, start, start + nodeSize);
62
65
  } else {
63
66
  var _getInlineNodePos = getInlineNodePos(tr, start, nodeSize),
64
67
  inlineNodePos = _getInlineNodePos.inlineNodePos,
@@ -104,21 +107,42 @@ var isHandleCorrelatedToSelection = exports.isHandleCorrelatedToSelection = func
104
107
  if (selection.empty) {
105
108
  return false;
106
109
  }
110
+ var nodeStart;
107
111
  var $selectionFrom = selection.$from;
108
- var selectionFrom = $selectionFrom.pos;
109
- var nodeStart = $selectionFrom.depth ? $selectionFrom.before() : selectionFrom;
110
- var $resolvedNodePos = state.doc.resolve(nodeStart);
111
- if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
112
- var parentNodeFindRes = (0, _utils.findParentNodeOfType)(state.schema.nodes['table'])(selection);
113
- var tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
114
- nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
115
- } else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
116
- nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
117
- } else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
118
- var listdepth = rootTaskListDepth($resolvedNodePos);
119
- nodeStart = $resolvedNodePos.before(listdepth);
120
- } else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
121
- nodeStart = $resolvedNodePos.before();
112
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1')) {
113
+ nodeStart = $selectionFrom.before($selectionFrom.sharedDepth(selection.to) + 1);
114
+ if (nodeStart === $selectionFrom.pos) {
115
+ nodeStart = $selectionFrom.depth ? $selectionFrom.before() : $selectionFrom.pos;
116
+ }
117
+ var $resolvedNodePos = state.doc.resolve(nodeStart);
118
+ if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
119
+ var parentNodeFindRes = (0, _utils.findParentNodeOfType)(state.schema.nodes['table'])(selection);
120
+ var tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
121
+ nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
122
+ } else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
123
+ nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
124
+ } else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
125
+ var listdepth = rootTaskListDepth($resolvedNodePos);
126
+ nodeStart = $resolvedNodePos.before(listdepth);
127
+ } else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
128
+ nodeStart = $resolvedNodePos.before();
129
+ }
130
+ } else {
131
+ var selectionFrom = $selectionFrom.pos;
132
+ nodeStart = $selectionFrom.depth ? $selectionFrom.before() : selectionFrom;
133
+ var _$resolvedNodePos = state.doc.resolve(nodeStart);
134
+ if (['tableRow', 'tableCell', 'tableHeader'].includes(_$resolvedNodePos.node().type.name)) {
135
+ var _parentNodeFindRes = (0, _utils.findParentNodeOfType)(state.schema.nodes['table'])(selection);
136
+ var _tablePos = _parentNodeFindRes === null || _parentNodeFindRes === void 0 ? void 0 : _parentNodeFindRes.pos;
137
+ nodeStart = typeof _tablePos === 'undefined' ? nodeStart : _tablePos;
138
+ } else if (['listItem'].includes(_$resolvedNodePos.node().type.name)) {
139
+ nodeStart = _$resolvedNodePos.before(rootListDepth(_$resolvedNodePos));
140
+ } else if (['taskList'].includes(_$resolvedNodePos.node().type.name)) {
141
+ var _listdepth = rootTaskListDepth(_$resolvedNodePos);
142
+ nodeStart = _$resolvedNodePos.before(_listdepth);
143
+ } else if (['blockquote'].includes(_$resolvedNodePos.node().type.name)) {
144
+ nodeStart = _$resolvedNodePos.before();
145
+ }
122
146
  }
123
147
  return Boolean(handlePos < selection.$to.pos && handlePos >= nodeStart);
124
148
  };
@@ -308,7 +308,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
308
308
  return tr;
309
309
  }
310
310
  var oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
311
- var newHandlePosCheck = handlePos >= (tr.selection.$from.depth ? tr.selection.$from.before() : tr.selection.from) && handlePos < tr.selection.to;
311
+ var newHandlePosCheck = (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos);
312
312
  if (!tr.selection.empty && ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
313
313
  var _api$blockControls4;
314
314
  api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.commands.setMultiSelectPositions()({
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
3
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import { moveNode } from './editor-commands/move-node';
6
7
  import { moveToLayout } from './editor-commands/move-to-layout';
@@ -80,6 +81,15 @@ export const blockControlsPlugin = ({
80
81
  nodeType
81
82
  }
82
83
  });
84
+ if (fg('platform_editor_ease_of_use_metrics')) {
85
+ var _api$metrics;
86
+ api === null || api === void 0 ? void 0 : (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.handleIntentToStartEdit({
87
+ shouldStartTimer: false,
88
+ shouldPersistActiveSession: true
89
+ })({
90
+ tr
91
+ });
92
+ }
83
93
  return tr;
84
94
  },
85
95
  setMultiSelectPositions: (anchor, head) => ({