@atlaskit/editor-plugin-block-controls 2.14.1 → 2.14.3

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,22 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.14.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#169746](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169746)
8
+ [`5bfb485e85507`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5bfb485e85507) -
9
+ [ux] [ED-25925] After drag and drop to create a new layout or update an existing layout,
10
+ placecursor at the end of last node in the newly created column
11
+
12
+ ## 2.14.2
13
+
14
+ ### Patch Changes
15
+
16
+ - [#169716](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169716)
17
+ [`4fbd1fe0084b3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4fbd1fe0084b3) -
18
+ ED-25072 update and insert layout analytics.
19
+
3
20
  ## 2.14.1
4
21
 
5
22
  ### Patch Changes
@@ -20,6 +20,7 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
20
20
  var _main = require("../pm-plugins/main");
21
21
  var _utils4 = require("../pm-plugins/utils");
22
22
  var _consts = require("../pm-plugins/utils/consts");
23
+ var _fireAnalytics = require("../pm-plugins/utils/fire-analytics");
23
24
  var _getSelection = require("../pm-plugins/utils/getSelection");
24
25
  var _removeFromSource = require("../pm-plugins/utils/remove-from-source");
25
26
  var _validation = require("../pm-plugins/utils/validation");
@@ -160,7 +161,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
160
161
  var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _analytics.INPUT_METHOD.DRAG_AND_DROP;
161
162
  var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
162
163
  return function (_ref4) {
163
- var _node$nodeSize, _api$analytics;
164
+ var _node$nodeSize;
164
165
  var tr = _ref4.tr;
165
166
  var node = tr.doc.nodeAt(start);
166
167
  var resolvedNode = tr.doc.resolve(start);
@@ -169,11 +170,11 @@ var moveNode = exports.moveNode = function moveNode(api) {
169
170
  }
170
171
  var size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
171
172
  var end = start + size;
173
+ var $from = tr.doc.resolve(start);
172
174
  var mappedTo;
173
175
  if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
174
176
  var nodeCopy = tr.doc.slice(start, end, false); // cut the content
175
177
  var $to = tr.doc.resolve(to);
176
- var $from = tr.doc.resolve(start);
177
178
  var destType = $to.node().type;
178
179
  var destParent = $to.node($to.depth);
179
180
  var sourceNode = $from.nodeAfter;
@@ -217,19 +218,25 @@ var moveNode = exports.moveNode = function moveNode(api) {
217
218
  });
218
219
  api === null || api === void 0 || api.core.actions.focus();
219
220
  var $mappedTo = tr.doc.resolve(mappedTo);
220
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
221
- eventType: _analytics.EVENT_TYPE.TRACK,
222
- action: _analytics.ACTION.MOVED,
223
- actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
224
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
225
- attributes: _objectSpread({
226
- nodeDepth: resolvedNode.depth,
227
- nodeType: node.type.name,
228
- destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth
229
- }, (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') && {
230
- inputMethod: inputMethod
231
- })
232
- })(tr);
221
+ if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
222
+ (0, _fireAnalytics.fireMoveNodeAnalytics)(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
223
+ } else {
224
+ var _api$analytics;
225
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
226
+ eventType: _analytics.EVENT_TYPE.TRACK,
227
+ action: _analytics.ACTION.MOVED,
228
+ actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
229
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
230
+ attributes: _objectSpread({
231
+ nodeDepth: resolvedNode.depth,
232
+ nodeType: node.type.name,
233
+ destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
234
+ destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name
235
+ }, (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') && {
236
+ inputMethod: inputMethod
237
+ })
238
+ })(tr);
239
+ }
233
240
  if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
234
241
  var _api$accessibilityUti;
235
242
  var movedMessage = to > start ? _messages.blockControlsMessages.movedDown : _messages.blockControlsMessages.movedup;
@@ -4,9 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.moveToLayout = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
7
8
  var _model = require("@atlaskit/editor-prosemirror/model");
8
9
  var _state = require("@atlaskit/editor-prosemirror/state");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
11
  var _consts = require("../pm-plugins/utils/consts");
12
+ var _fireAnalytics = require("../pm-plugins/utils/fire-analytics");
10
13
  var _removeFromSource = require("../pm-plugins/utils/remove-from-source");
11
14
  var _updateColumnWidths = require("../pm-plugins/utils/update-column-widths");
12
15
  var _validation = require("../pm-plugins/utils/validation");
@@ -35,16 +38,29 @@ var createNewLayout = function createNewLayout(schema, layoutContents) {
35
38
  }
36
39
  return null;
37
40
  };
38
- var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr, isSameLayout) {
41
+ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr, $originalFrom, $originalTo, api) {
42
+ var isSameLayout = (0, _validation.isInSameLayout)($originalFrom, $originalTo);
39
43
  if (isSameLayout) {
44
+ var _$originalFrom$nodeAf;
40
45
  // reorder columns
41
46
  tr.delete(from, from + sourceNode.nodeSize);
42
47
  var mappedTo = tr.mapping.map(to);
43
- tr.insert(mappedTo, sourceNode).setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
48
+ tr.insert(mappedTo, sourceNode);
49
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
50
+ tr.setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
51
+ }
52
+ (0, _fireAnalytics.fireMoveNodeAnalytics)(tr, _analytics.INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
44
53
  } else if (toLayout.childCount < (0, _consts.maxLayoutColumnSupported)()) {
45
- insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
46
- var mappedFrom = tr.mapping.map(from);
47
- (0, _removeFromSource.removeFromSource)(tr, tr.doc.resolve(mappedFrom));
54
+ var _$originalFrom$nodeAf2;
55
+ if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
56
+ (0, _removeFromSource.removeFromSource)(tr, tr.doc.resolve(from));
57
+ insertToDestination(tr, tr.mapping.map(to), sourceNode, toLayout, tr.mapping.map(toLayoutPos));
58
+ } else {
59
+ insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
60
+ var mappedFrom = tr.mapping.map(from);
61
+ (0, _removeFromSource.removeFromSource)(tr, tr.doc.resolve(mappedFrom));
62
+ }
63
+ (0, _fireAnalytics.fireMoveNodeAnalytics)(tr, _analytics.INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
48
64
  }
49
65
  return tr;
50
66
  };
@@ -56,7 +72,10 @@ var insertToDestination = function insertToDestination(tr, to, sourceNode, toLay
56
72
  var content = layoutColumn.createChecked({
57
73
  width: newColumnWidth
58
74
  }, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
59
- tr.insert(to, content).setSelection(new _state.NodeSelection(tr.doc.resolve(to))).scrollIntoView();
75
+ tr.insert(to, content);
76
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
77
+ tr.setSelection(new _state.NodeSelection(tr.doc.resolve(to))).scrollIntoView();
78
+ }
60
79
  return tr;
61
80
  };
62
81
 
@@ -139,12 +158,12 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
139
158
  }
140
159
  if (toNode.type === layoutSection) {
141
160
  var toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize - 1 : to + 1;
142
- return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, (0, _validation.isInSameLayout)($from, $to));
161
+ return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, $from, $to, api);
143
162
  } else if (toNode.type === layoutColumn) {
144
163
  var toLayout = $to.parent;
145
164
  var toLayoutPos = to - $to.parentOffset - 1;
146
165
  var _toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize : to;
147
- return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, _toPos, tr, (0, _validation.isInSameLayout)($from, $to));
166
+ return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, _toPos, tr, $from, $to, api);
148
167
  } else {
149
168
  var toNodeWithoutBreakout = toNode;
150
169
 
@@ -164,10 +183,14 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
164
183
  if (newLayout) {
165
184
  tr = (0, _removeFromSource.removeFromSource)(tr, $from);
166
185
  var mappedTo = tr.mapping.map(to);
167
- tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout).setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
186
+ tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout);
187
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
188
+ tr.setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
189
+ }
168
190
  breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
169
191
  mode: breakoutMode
170
192
  })]);
193
+ (0, _fireAnalytics.fireInsertLayoutAnalytics)(tr, api);
171
194
  }
172
195
  return tr;
173
196
  }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fireMoveNodeAnalytics = exports.fireInsertLayoutAnalytics = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
8
+ var fireMoveNodeAnalytics = exports.fireMoveNodeAnalytics = function fireMoveNodeAnalytics(tr, inputMethod, fromDepth, fromNodeType, toDepth, toNodeType, isSameParent, api) {
9
+ var _api$analytics;
10
+ return api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.attachAnalyticsEvent({
11
+ eventType: _analytics.EVENT_TYPE.TRACK,
12
+ action: _analytics.ACTION.MOVED,
13
+ actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
14
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
15
+ attributes: {
16
+ nodeDepth: fromDepth,
17
+ nodeType: fromNodeType,
18
+ destinationNodeDepth: toDepth,
19
+ destinationNodeType: toNodeType,
20
+ isSameParent: isSameParent,
21
+ inputMethod: inputMethod
22
+ }
23
+ })(tr);
24
+ };
25
+ var fireInsertLayoutAnalytics = exports.fireInsertLayoutAnalytics = function fireInsertLayoutAnalytics(tr, api) {
26
+ var _api$analytics2;
27
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.attachAnalyticsEvent({
28
+ action: _analytics.ACTION.INSERTED,
29
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
30
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.LAYOUT,
31
+ attributes: {
32
+ inputMethod: _analytics.INPUT_METHOD.DRAG_AND_DROP
33
+ },
34
+ eventType: _analytics.EVENT_TYPE.TRACK
35
+ })(tr);
36
+ };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.updateSelection = exports.getInsertLayoutStep = void 0;
7
+ var _selection = require("@atlaskit/editor-common/selection");
8
+ var _state = require("@atlaskit/editor-prosemirror/state");
9
+ var _transform = require("@atlaskit/editor-prosemirror/transform");
10
+ var getInsertLayoutStep = exports.getInsertLayoutStep = function getInsertLayoutStep(tr) {
11
+ return tr.steps.find(function (step) {
12
+ var _step$slice$content$f;
13
+ return step instanceof _transform.ReplaceStep && ['layoutSection', 'layoutColumn'].includes(((_step$slice$content$f = step.slice.content.firstChild) === null || _step$slice$content$f === void 0 ? void 0 : _step$slice$content$f.type.name) || '');
14
+ });
15
+ };
16
+ var updateSelection = exports.updateSelection = function updateSelection(tr, to, insertAtRight) {
17
+ var _lastNode;
18
+ var $to = tr.doc.resolve(to);
19
+ var toNode = $to.nodeAfter;
20
+ var lastNode = toNode === null || toNode === void 0 ? void 0 : toNode.content.lastChild;
21
+ if (!toNode || !lastNode) {
22
+ return tr;
23
+ }
24
+ var offset = toNode.nodeSize;
25
+
26
+ // drop at the start of the layoutSection or to create a new layoutSection
27
+ if (toNode.type.name === 'layoutSection') {
28
+ if (insertAtRight) {
29
+ var _toNode$content$lastC;
30
+ lastNode = (_toNode$content$lastC = toNode.content.lastChild) === null || _toNode$content$lastC === void 0 ? void 0 : _toNode$content$lastC.lastChild;
31
+ offset = toNode.nodeSize - 1;
32
+ } else {
33
+ var _toNode$content$first, _toNode$content$first2;
34
+ lastNode = (_toNode$content$first = toNode.content.firstChild) === null || _toNode$content$first === void 0 ? void 0 : _toNode$content$first.lastChild;
35
+ offset = 1 + (((_toNode$content$first2 = toNode.content.firstChild) === null || _toNode$content$first2 === void 0 ? void 0 : _toNode$content$first2.nodeSize) || 0);
36
+ }
37
+ }
38
+ if (['paragraph', 'heading'].includes(((_lastNode = lastNode) === null || _lastNode === void 0 ? void 0 : _lastNode.type.name) || '')) {
39
+ tr.setSelection(_state.TextSelection.near(tr.doc.resolve(to + offset - 2)));
40
+ } else if (lastNode) {
41
+ tr.setSelection(new _selection.GapCursorSelection(tr.doc.resolve(to + offset - 1), _selection.Side.RIGHT));
42
+ }
43
+ return tr;
44
+ };
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  var _react = require("react");
11
11
  var _react2 = require("@emotion/react");
12
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
14
15
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
15
16
  var _colors = require("@atlaskit/theme/colors");
@@ -17,6 +18,7 @@ var _decorationsCommon = require("../pm-plugins/decorations-common");
17
18
  var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
18
19
  var _anchorUtils = require("../pm-plugins/utils/anchor-utils");
19
20
  var _dragTargetDebug = require("../pm-plugins/utils/drag-target-debug");
21
+ var _updateSelection = require("../pm-plugins/utils/update-selection");
20
22
  /**
21
23
  * @jsxRuntime classic
22
24
  * @jsx jsx
@@ -78,10 +80,32 @@ var DropTargetLayout = exports.DropTargetLayout = function DropTargetLayout(prop
78
80
  return;
79
81
  }
80
82
  var to = getPos();
83
+ var mappedTo;
81
84
  if (to !== undefined) {
82
- var _api$core, _api$blockControls2;
85
+ var _api$core;
83
86
  var from = activeNode.pos;
84
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.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(from, to));
87
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
88
+ var _api$blockControls2;
89
+ var tr = _ref2.tr;
90
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.moveToLayout(from, to)({
91
+ tr: tr
92
+ });
93
+ if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
94
+ var insertColumnStep = (0, _updateSelection.getInsertLayoutStep)(tr);
95
+ mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
96
+ }
97
+ return tr;
98
+ });
99
+ if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
100
+ var _api$core2;
101
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
102
+ var tr = _ref3.tr;
103
+ if (mappedTo !== undefined) {
104
+ (0, _updateSelection.updateSelection)(tr, mappedTo);
105
+ }
106
+ return tr;
107
+ });
108
+ }
85
109
  }
86
110
  }, [api, getPos, activeNode]);
87
111
  (0, _react.useEffect)(function () {
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  var _react = require("react");
11
11
  var _react2 = require("@emotion/react");
12
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
14
15
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
15
16
  var _colors = require("@atlaskit/theme/colors");
@@ -17,6 +18,7 @@ var _decorationsCommon = require("../pm-plugins/decorations-common");
17
18
  var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
18
19
  var _anchorUtils = require("../pm-plugins/utils/anchor-utils");
19
20
  var _dragTargetDebug = require("../pm-plugins/utils/drag-target-debug");
21
+ var _updateSelection = require("../pm-plugins/utils/update-selection");
20
22
  /* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
21
23
  /* eslint-disable @atlaskit/ui-styling-standard/no-unsafe-values */
22
24
  /**
@@ -188,16 +190,39 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
188
190
  return;
189
191
  }
190
192
  var toPos = getPos();
193
+ var mappedTo;
191
194
  if (activeNode && toPos !== undefined) {
192
- var _api$core, _api$blockControls2;
195
+ var _api$core;
193
196
  var start = activeNode.pos;
194
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.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(start, toPos, {
195
- moveToEnd: position === 'right'
196
- }));
197
+ var moveToEnd = position === 'right';
198
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
199
+ var _api$blockControls2;
200
+ var tr = _ref3.tr;
201
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.moveToLayout(start, toPos, {
202
+ moveToEnd: moveToEnd
203
+ })({
204
+ tr: tr
205
+ });
206
+ if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
207
+ var insertLayoutStep = (0, _updateSelection.getInsertLayoutStep)(tr);
208
+ mappedTo = insertLayoutStep === null || insertLayoutStep === void 0 ? void 0 : insertLayoutStep.from;
209
+ }
210
+ return tr;
211
+ });
212
+ if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
213
+ var _api$core2;
214
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref4) {
215
+ var tr = _ref4.tr;
216
+ if (mappedTo !== undefined) {
217
+ (0, _updateSelection.updateSelection)(tr, mappedTo, moveToEnd);
218
+ }
219
+ return tr;
220
+ });
221
+ }
197
222
  }
198
223
  }, [api, getPos, position]);
199
224
  var hoverZoneRectStyle = (0, _react.useMemo)(function () {
200
- var _ref3;
225
+ var _ref5;
201
226
  var isLayoutNode = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'layoutSection';
202
227
  var layoutAdjustment = isLayoutNode ? {
203
228
  width: 11,
@@ -205,7 +230,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
205
230
  top: 6,
206
231
  bottom: 2
207
232
  } : undefined;
208
- return _ref3 = {}, (0, _defineProperty2.default)(_ref3, HOVER_ZONE_WIDTH, nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_HEIGHT, "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_TOP, "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_BOTTOM, "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_ANCHOR_NAME, anchorName), _ref3;
233
+ return _ref5 = {}, (0, _defineProperty2.default)(_ref5, HOVER_ZONE_WIDTH, nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)")), (0, _defineProperty2.default)(_ref5, HOVER_ZONE_HEIGHT, "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")), (0, _defineProperty2.default)(_ref5, HOVER_ZONE_TOP, "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)")), (0, _defineProperty2.default)(_ref5, HOVER_ZONE_BOTTOM, "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")), (0, _defineProperty2.default)(_ref5, HOVER_ZONE_ANCHOR_NAME, anchorName), _ref5;
209
234
  }, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, nodeDimension, anchorName]);
210
235
  var dropIndicatorPos = (0, _react.useMemo)(function () {
211
236
  return isLeftPosition ? 'right' : 'left';
@@ -12,6 +12,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
12
  import { key } from '../pm-plugins/main';
13
13
  import { getNestedNodePosition, selectNode } from '../pm-plugins/utils';
14
14
  import { DIRECTION } from '../pm-plugins/utils/consts';
15
+ import { fireMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
15
16
  import { setCursorPositionAtMovedNode } from '../pm-plugins/utils/getSelection';
16
17
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
17
18
  import { canMoveNodeToIndex, isInsideTable, transformSliceExpandToNestedExpand } from '../pm-plugins/utils/validation';
@@ -155,7 +156,7 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
155
156
  export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_DROP, formatMessage) => ({
156
157
  tr
157
158
  }) => {
158
- var _node$nodeSize, _api$analytics;
159
+ var _node$nodeSize;
159
160
  const node = tr.doc.nodeAt(start);
160
161
  const resolvedNode = tr.doc.resolve(start);
161
162
  if (!node) {
@@ -163,11 +164,11 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
163
164
  }
164
165
  const size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
165
166
  const end = start + size;
167
+ const $from = tr.doc.resolve(start);
166
168
  let mappedTo;
167
169
  if (editorExperiment('nested-dnd', true)) {
168
170
  const nodeCopy = tr.doc.slice(start, end, false); // cut the content
169
171
  const $to = tr.doc.resolve(to);
170
- const $from = tr.doc.resolve(start);
171
172
  const destType = $to.node().type;
172
173
  const destParent = $to.node($to.depth);
173
174
  const sourceNode = $from.nodeAfter;
@@ -211,20 +212,26 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
211
212
  });
212
213
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
213
214
  const $mappedTo = tr.doc.resolve(mappedTo);
214
- api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
215
- eventType: EVENT_TYPE.TRACK,
216
- action: ACTION.MOVED,
217
- actionSubject: ACTION_SUBJECT.ELEMENT,
218
- actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
219
- attributes: {
220
- nodeDepth: resolvedNode.depth,
221
- nodeType: node.type.name,
222
- destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
223
- ...(fg('platform_editor_element_drag_and_drop_ed_23873') && {
224
- inputMethod
225
- })
226
- }
227
- })(tr);
215
+ if (editorExperiment('advanced_layouts', true)) {
216
+ fireMoveNodeAnalytics(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
217
+ } else {
218
+ var _api$analytics;
219
+ api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
220
+ eventType: EVENT_TYPE.TRACK,
221
+ action: ACTION.MOVED,
222
+ actionSubject: ACTION_SUBJECT.ELEMENT,
223
+ actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
224
+ attributes: {
225
+ nodeDepth: resolvedNode.depth,
226
+ nodeType: node.type.name,
227
+ destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
228
+ destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name,
229
+ ...(fg('platform_editor_element_drag_and_drop_ed_23873') && {
230
+ inputMethod
231
+ })
232
+ }
233
+ })(tr);
234
+ }
228
235
  if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
229
236
  var _api$accessibilityUti;
230
237
  const movedMessage = to > start ? blockControlsMessages.movedDown : blockControlsMessages.movedup;
@@ -1,6 +1,9 @@
1
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
3
5
  import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
6
+ import { fireInsertLayoutAnalytics, fireMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
4
7
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
5
8
  import { updateColumnWidths } from '../pm-plugins/utils/update-column-widths';
6
9
  import { isInSameLayout } from '../pm-plugins/utils/validation';
@@ -30,16 +33,29 @@ const createNewLayout = (schema, layoutContents) => {
30
33
  }
31
34
  return null;
32
35
  };
33
- const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr, isSameLayout) => {
36
+ const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr, $originalFrom, $originalTo, api) => {
37
+ const isSameLayout = isInSameLayout($originalFrom, $originalTo);
34
38
  if (isSameLayout) {
39
+ var _$originalFrom$nodeAf;
35
40
  // reorder columns
36
41
  tr.delete(from, from + sourceNode.nodeSize);
37
42
  const mappedTo = tr.mapping.map(to);
38
- tr.insert(mappedTo, sourceNode).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
43
+ tr.insert(mappedTo, sourceNode);
44
+ if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
45
+ tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
46
+ }
47
+ fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
39
48
  } else if (toLayout.childCount < maxLayoutColumnSupported()) {
40
- insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
41
- const mappedFrom = tr.mapping.map(from);
42
- removeFromSource(tr, tr.doc.resolve(mappedFrom));
49
+ var _$originalFrom$nodeAf2;
50
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
51
+ removeFromSource(tr, tr.doc.resolve(from));
52
+ insertToDestination(tr, tr.mapping.map(to), sourceNode, toLayout, tr.mapping.map(toLayoutPos));
53
+ } else {
54
+ insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
55
+ const mappedFrom = tr.mapping.map(from);
56
+ removeFromSource(tr, tr.doc.resolve(mappedFrom));
57
+ }
58
+ fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
43
59
  }
44
60
  return tr;
45
61
  };
@@ -53,7 +69,10 @@ const insertToDestination = (tr, to, sourceNode, toLayout, toLayoutPos) => {
53
69
  const content = layoutColumn.createChecked({
54
70
  width: newColumnWidth
55
71
  }, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
56
- tr.insert(to, content).setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
72
+ tr.insert(to, content);
73
+ if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
74
+ tr.setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
75
+ }
57
76
  return tr;
58
77
  };
59
78
 
@@ -136,12 +155,12 @@ export const moveToLayout = api => (from, to, options) => ({
136
155
  }
137
156
  if (toNode.type === layoutSection) {
138
157
  const toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize - 1 : to + 1;
139
- return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, isInSameLayout($from, $to));
158
+ return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, $from, $to, api);
140
159
  } else if (toNode.type === layoutColumn) {
141
160
  const toLayout = $to.parent;
142
161
  const toLayoutPos = to - $to.parentOffset - 1;
143
162
  const toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize : to;
144
- return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, toPos, tr, isInSameLayout($from, $to));
163
+ return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, toPos, tr, $from, $to, api);
145
164
  } else {
146
165
  let toNodeWithoutBreakout = toNode;
147
166
 
@@ -159,10 +178,14 @@ export const moveToLayout = api => (from, to, options) => ({
159
178
  if (newLayout) {
160
179
  tr = removeFromSource(tr, $from);
161
180
  const mappedTo = tr.mapping.map(to);
162
- tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
181
+ tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout);
182
+ if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
183
+ tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
184
+ }
163
185
  breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
164
186
  mode: breakoutMode
165
187
  })]);
188
+ fireInsertLayoutAnalytics(tr, api);
166
189
  }
167
190
  return tr;
168
191
  }
@@ -0,0 +1,30 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ export const fireMoveNodeAnalytics = (tr, inputMethod, fromDepth, fromNodeType, toDepth, toNodeType, isSameParent, api) => {
3
+ var _api$analytics, _api$analytics$action;
4
+ return api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent({
5
+ eventType: EVENT_TYPE.TRACK,
6
+ action: ACTION.MOVED,
7
+ actionSubject: ACTION_SUBJECT.ELEMENT,
8
+ actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
9
+ attributes: {
10
+ nodeDepth: fromDepth,
11
+ nodeType: fromNodeType,
12
+ destinationNodeDepth: toDepth,
13
+ destinationNodeType: toNodeType,
14
+ isSameParent: isSameParent,
15
+ inputMethod
16
+ }
17
+ })(tr);
18
+ };
19
+ export const fireInsertLayoutAnalytics = (tr, api) => {
20
+ var _api$analytics2, _api$analytics2$actio;
21
+ api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : (_api$analytics2$actio = _api$analytics2.actions) === null || _api$analytics2$actio === void 0 ? void 0 : _api$analytics2$actio.attachAnalyticsEvent({
22
+ action: ACTION.INSERTED,
23
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
24
+ actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
25
+ attributes: {
26
+ inputMethod: INPUT_METHOD.DRAG_AND_DROP
27
+ },
28
+ eventType: EVENT_TYPE.TRACK
29
+ })(tr);
30
+ };
@@ -0,0 +1,36 @@
1
+ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
2
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
+ import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
4
+ export const getInsertLayoutStep = tr => tr.steps.find(step => {
5
+ var _step$slice$content$f;
6
+ return step instanceof ReplaceStep && ['layoutSection', 'layoutColumn'].includes(((_step$slice$content$f = step.slice.content.firstChild) === null || _step$slice$content$f === void 0 ? void 0 : _step$slice$content$f.type.name) || '');
7
+ });
8
+ export const updateSelection = (tr, to, insertAtRight) => {
9
+ var _lastNode;
10
+ const $to = tr.doc.resolve(to);
11
+ const toNode = $to.nodeAfter;
12
+ let lastNode = toNode === null || toNode === void 0 ? void 0 : toNode.content.lastChild;
13
+ if (!toNode || !lastNode) {
14
+ return tr;
15
+ }
16
+ let offset = toNode.nodeSize;
17
+
18
+ // drop at the start of the layoutSection or to create a new layoutSection
19
+ if (toNode.type.name === 'layoutSection') {
20
+ if (insertAtRight) {
21
+ var _toNode$content$lastC;
22
+ lastNode = (_toNode$content$lastC = toNode.content.lastChild) === null || _toNode$content$lastC === void 0 ? void 0 : _toNode$content$lastC.lastChild;
23
+ offset = toNode.nodeSize - 1;
24
+ } else {
25
+ var _toNode$content$first, _toNode$content$first2;
26
+ lastNode = (_toNode$content$first = toNode.content.firstChild) === null || _toNode$content$first === void 0 ? void 0 : _toNode$content$first.lastChild;
27
+ offset = 1 + (((_toNode$content$first2 = toNode.content.firstChild) === null || _toNode$content$first2 === void 0 ? void 0 : _toNode$content$first2.nodeSize) || 0);
28
+ }
29
+ }
30
+ if (['paragraph', 'heading'].includes(((_lastNode = lastNode) === null || _lastNode === void 0 ? void 0 : _lastNode.type.name) || '')) {
31
+ tr.setSelection(TextSelection.near(tr.doc.resolve(to + offset - 2)));
32
+ } else if (lastNode) {
33
+ tr.setSelection(new GapCursorSelection(tr.doc.resolve(to + offset - 1), Side.RIGHT));
34
+ }
35
+ return tr;
36
+ };
@@ -7,6 +7,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { layoutBreakpointWidth } from '@atlaskit/editor-shared-styles';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
11
12
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
12
13
  import { B200 } from '@atlaskit/theme/colors';
@@ -14,6 +15,7 @@ import { getNodeAnchor } from '../pm-plugins/decorations-common';
14
15
  import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
15
16
  import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
16
17
  import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
18
+ import { getInsertLayoutStep, updateSelection } from '../pm-plugins/utils/update-selection';
17
19
 
18
20
  // 8px gap + 16px on left and right
19
21
  const DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH = 40;
@@ -70,12 +72,36 @@ export const DropTargetLayout = props => {
70
72
  return;
71
73
  }
72
74
  const to = getPos();
75
+ let mappedTo;
73
76
  if (to !== undefined) {
74
- var _api$core, _api$blockControls2, _api$blockControls2$c;
77
+ var _api$core;
75
78
  const {
76
79
  pos: from
77
80
  } = activeNode;
78
- api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveToLayout(from, to));
81
+ api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
82
+ tr
83
+ }) => {
84
+ var _api$blockControls2, _api$blockControls2$c;
85
+ api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveToLayout(from, to)({
86
+ tr
87
+ });
88
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
89
+ const insertColumnStep = getInsertLayoutStep(tr);
90
+ mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
91
+ }
92
+ return tr;
93
+ });
94
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
95
+ var _api$core2;
96
+ api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
97
+ tr
98
+ }) => {
99
+ if (mappedTo !== undefined) {
100
+ updateSelection(tr, mappedTo);
101
+ }
102
+ return tr;
103
+ });
104
+ }
79
105
  }
80
106
  }, [api, getPos, activeNode]);
81
107
  useEffect(() => {
@@ -9,6 +9,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
10
10
  import { css, jsx } from '@emotion/react';
11
11
  import { akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
12
13
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
13
14
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
14
15
  import { B200 } from '@atlaskit/theme/colors';
@@ -16,6 +17,7 @@ import { getNodeAnchor } from '../pm-plugins/decorations-common';
16
17
  import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
17
18
  import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
18
19
  import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
20
+ import { getInsertLayoutStep, updateSelection } from '../pm-plugins/utils/update-selection';
19
21
  const HOVER_ZONE_WIDTH = '--editor-blocks-inline-hover-zone-width';
20
22
  const HOVER_ZONE_HEIGHT = '--editor-blocks-inline-hover-zone-height';
21
23
  const HOVER_ZONE_TOP = '--editor-blocks-inline-hover-zone-top';
@@ -175,14 +177,39 @@ export const InlineDropTarget = ({
175
177
  return;
176
178
  }
177
179
  const toPos = getPos();
180
+ let mappedTo;
178
181
  if (activeNode && toPos !== undefined) {
179
- var _api$core, _api$blockControls2, _api$blockControls2$c;
182
+ var _api$core;
180
183
  const {
181
184
  pos: start
182
185
  } = activeNode;
183
- api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveToLayout(start, toPos, {
184
- moveToEnd: position === 'right'
185
- }));
186
+ const moveToEnd = position === 'right';
187
+ api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
188
+ tr
189
+ }) => {
190
+ var _api$blockControls2, _api$blockControls2$c;
191
+ api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveToLayout(start, toPos, {
192
+ moveToEnd
193
+ })({
194
+ tr
195
+ });
196
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
197
+ const insertLayoutStep = getInsertLayoutStep(tr);
198
+ mappedTo = insertLayoutStep === null || insertLayoutStep === void 0 ? void 0 : insertLayoutStep.from;
199
+ }
200
+ return tr;
201
+ });
202
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
203
+ var _api$core2;
204
+ api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
205
+ tr
206
+ }) => {
207
+ if (mappedTo !== undefined) {
208
+ updateSelection(tr, mappedTo, moveToEnd);
209
+ }
210
+ return tr;
211
+ });
212
+ }
186
213
  }
187
214
  }, [api, getPos, position]);
188
215
  const hoverZoneRectStyle = useMemo(() => {
@@ -15,6 +15,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
15
  import { key } from '../pm-plugins/main';
16
16
  import { getNestedNodePosition, selectNode } from '../pm-plugins/utils';
17
17
  import { DIRECTION } from '../pm-plugins/utils/consts';
18
+ import { fireMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
18
19
  import { setCursorPositionAtMovedNode } from '../pm-plugins/utils/getSelection';
19
20
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
20
21
  import { canMoveNodeToIndex, isInsideTable, transformSliceExpandToNestedExpand } from '../pm-plugins/utils/validation';
@@ -154,7 +155,7 @@ export var moveNode = function moveNode(api) {
154
155
  var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INPUT_METHOD.DRAG_AND_DROP;
155
156
  var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
156
157
  return function (_ref4) {
157
- var _node$nodeSize, _api$analytics;
158
+ var _node$nodeSize;
158
159
  var tr = _ref4.tr;
159
160
  var node = tr.doc.nodeAt(start);
160
161
  var resolvedNode = tr.doc.resolve(start);
@@ -163,11 +164,11 @@ export var moveNode = function moveNode(api) {
163
164
  }
164
165
  var size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
165
166
  var end = start + size;
167
+ var $from = tr.doc.resolve(start);
166
168
  var mappedTo;
167
169
  if (editorExperiment('nested-dnd', true)) {
168
170
  var nodeCopy = tr.doc.slice(start, end, false); // cut the content
169
171
  var $to = tr.doc.resolve(to);
170
- var $from = tr.doc.resolve(start);
171
172
  var destType = $to.node().type;
172
173
  var destParent = $to.node($to.depth);
173
174
  var sourceNode = $from.nodeAfter;
@@ -211,19 +212,25 @@ export var moveNode = function moveNode(api) {
211
212
  });
212
213
  api === null || api === void 0 || api.core.actions.focus();
213
214
  var $mappedTo = tr.doc.resolve(mappedTo);
214
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
215
- eventType: EVENT_TYPE.TRACK,
216
- action: ACTION.MOVED,
217
- actionSubject: ACTION_SUBJECT.ELEMENT,
218
- actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
219
- attributes: _objectSpread({
220
- nodeDepth: resolvedNode.depth,
221
- nodeType: node.type.name,
222
- destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth
223
- }, fg('platform_editor_element_drag_and_drop_ed_23873') && {
224
- inputMethod: inputMethod
225
- })
226
- })(tr);
215
+ if (editorExperiment('advanced_layouts', true)) {
216
+ fireMoveNodeAnalytics(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
217
+ } else {
218
+ var _api$analytics;
219
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
220
+ eventType: EVENT_TYPE.TRACK,
221
+ action: ACTION.MOVED,
222
+ actionSubject: ACTION_SUBJECT.ELEMENT,
223
+ actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
224
+ attributes: _objectSpread({
225
+ nodeDepth: resolvedNode.depth,
226
+ nodeType: node.type.name,
227
+ destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
228
+ destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name
229
+ }, fg('platform_editor_element_drag_and_drop_ed_23873') && {
230
+ inputMethod: inputMethod
231
+ })
232
+ })(tr);
233
+ }
227
234
  if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
228
235
  var _api$accessibilityUti;
229
236
  var movedMessage = to > start ? blockControlsMessages.movedDown : blockControlsMessages.movedup;
@@ -1,6 +1,9 @@
1
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
3
5
  import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
6
+ import { fireInsertLayoutAnalytics, fireMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
4
7
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
5
8
  import { updateColumnWidths } from '../pm-plugins/utils/update-column-widths';
6
9
  import { isInSameLayout } from '../pm-plugins/utils/validation';
@@ -29,16 +32,29 @@ var createNewLayout = function createNewLayout(schema, layoutContents) {
29
32
  }
30
33
  return null;
31
34
  };
32
- var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr, isSameLayout) {
35
+ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr, $originalFrom, $originalTo, api) {
36
+ var isSameLayout = isInSameLayout($originalFrom, $originalTo);
33
37
  if (isSameLayout) {
38
+ var _$originalFrom$nodeAf;
34
39
  // reorder columns
35
40
  tr.delete(from, from + sourceNode.nodeSize);
36
41
  var mappedTo = tr.mapping.map(to);
37
- tr.insert(mappedTo, sourceNode).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
42
+ tr.insert(mappedTo, sourceNode);
43
+ if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
44
+ tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
45
+ }
46
+ fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
38
47
  } else if (toLayout.childCount < maxLayoutColumnSupported()) {
39
- insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
40
- var mappedFrom = tr.mapping.map(from);
41
- removeFromSource(tr, tr.doc.resolve(mappedFrom));
48
+ var _$originalFrom$nodeAf2;
49
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
50
+ removeFromSource(tr, tr.doc.resolve(from));
51
+ insertToDestination(tr, tr.mapping.map(to), sourceNode, toLayout, tr.mapping.map(toLayoutPos));
52
+ } else {
53
+ insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
54
+ var mappedFrom = tr.mapping.map(from);
55
+ removeFromSource(tr, tr.doc.resolve(mappedFrom));
56
+ }
57
+ fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
42
58
  }
43
59
  return tr;
44
60
  };
@@ -50,7 +66,10 @@ var insertToDestination = function insertToDestination(tr, to, sourceNode, toLay
50
66
  var content = layoutColumn.createChecked({
51
67
  width: newColumnWidth
52
68
  }, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
53
- tr.insert(to, content).setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
69
+ tr.insert(to, content);
70
+ if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
71
+ tr.setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
72
+ }
54
73
  return tr;
55
74
  };
56
75
 
@@ -133,12 +152,12 @@ export var moveToLayout = function moveToLayout(api) {
133
152
  }
134
153
  if (toNode.type === layoutSection) {
135
154
  var toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize - 1 : to + 1;
136
- return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, isInSameLayout($from, $to));
155
+ return moveToExistingLayout(toNode, to, fromNodeWithoutBreakout, from, toPos, tr, $from, $to, api);
137
156
  } else if (toNode.type === layoutColumn) {
138
157
  var toLayout = $to.parent;
139
158
  var toLayoutPos = to - $to.parentOffset - 1;
140
159
  var _toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize : to;
141
- return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, _toPos, tr, isInSameLayout($from, $to));
160
+ return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, _toPos, tr, $from, $to, api);
142
161
  } else {
143
162
  var toNodeWithoutBreakout = toNode;
144
163
 
@@ -158,10 +177,14 @@ export var moveToLayout = function moveToLayout(api) {
158
177
  if (newLayout) {
159
178
  tr = removeFromSource(tr, $from);
160
179
  var mappedTo = tr.mapping.map(to);
161
- tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
180
+ tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout);
181
+ if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
182
+ tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
183
+ }
162
184
  breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
163
185
  mode: breakoutMode
164
186
  })]);
187
+ fireInsertLayoutAnalytics(tr, api);
165
188
  }
166
189
  return tr;
167
190
  }
@@ -0,0 +1,30 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ export var fireMoveNodeAnalytics = function fireMoveNodeAnalytics(tr, inputMethod, fromDepth, fromNodeType, toDepth, toNodeType, isSameParent, api) {
3
+ var _api$analytics;
4
+ return api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.attachAnalyticsEvent({
5
+ eventType: EVENT_TYPE.TRACK,
6
+ action: ACTION.MOVED,
7
+ actionSubject: ACTION_SUBJECT.ELEMENT,
8
+ actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
9
+ attributes: {
10
+ nodeDepth: fromDepth,
11
+ nodeType: fromNodeType,
12
+ destinationNodeDepth: toDepth,
13
+ destinationNodeType: toNodeType,
14
+ isSameParent: isSameParent,
15
+ inputMethod: inputMethod
16
+ }
17
+ })(tr);
18
+ };
19
+ export var fireInsertLayoutAnalytics = function fireInsertLayoutAnalytics(tr, api) {
20
+ var _api$analytics2;
21
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.attachAnalyticsEvent({
22
+ action: ACTION.INSERTED,
23
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
24
+ actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
25
+ attributes: {
26
+ inputMethod: INPUT_METHOD.DRAG_AND_DROP
27
+ },
28
+ eventType: EVENT_TYPE.TRACK
29
+ })(tr);
30
+ };
@@ -0,0 +1,38 @@
1
+ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
2
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
+ import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
4
+ export var getInsertLayoutStep = function getInsertLayoutStep(tr) {
5
+ return tr.steps.find(function (step) {
6
+ var _step$slice$content$f;
7
+ return step instanceof ReplaceStep && ['layoutSection', 'layoutColumn'].includes(((_step$slice$content$f = step.slice.content.firstChild) === null || _step$slice$content$f === void 0 ? void 0 : _step$slice$content$f.type.name) || '');
8
+ });
9
+ };
10
+ export var updateSelection = function updateSelection(tr, to, insertAtRight) {
11
+ var _lastNode;
12
+ var $to = tr.doc.resolve(to);
13
+ var toNode = $to.nodeAfter;
14
+ var lastNode = toNode === null || toNode === void 0 ? void 0 : toNode.content.lastChild;
15
+ if (!toNode || !lastNode) {
16
+ return tr;
17
+ }
18
+ var offset = toNode.nodeSize;
19
+
20
+ // drop at the start of the layoutSection or to create a new layoutSection
21
+ if (toNode.type.name === 'layoutSection') {
22
+ if (insertAtRight) {
23
+ var _toNode$content$lastC;
24
+ lastNode = (_toNode$content$lastC = toNode.content.lastChild) === null || _toNode$content$lastC === void 0 ? void 0 : _toNode$content$lastC.lastChild;
25
+ offset = toNode.nodeSize - 1;
26
+ } else {
27
+ var _toNode$content$first, _toNode$content$first2;
28
+ lastNode = (_toNode$content$first = toNode.content.firstChild) === null || _toNode$content$first === void 0 ? void 0 : _toNode$content$first.lastChild;
29
+ offset = 1 + (((_toNode$content$first2 = toNode.content.firstChild) === null || _toNode$content$first2 === void 0 ? void 0 : _toNode$content$first2.nodeSize) || 0);
30
+ }
31
+ }
32
+ if (['paragraph', 'heading'].includes(((_lastNode = lastNode) === null || _lastNode === void 0 ? void 0 : _lastNode.type.name) || '')) {
33
+ tr.setSelection(TextSelection.near(tr.doc.resolve(to + offset - 2)));
34
+ } else if (lastNode) {
35
+ tr.setSelection(new GapCursorSelection(tr.doc.resolve(to + offset - 1), Side.RIGHT));
36
+ }
37
+ return tr;
38
+ };
@@ -9,6 +9,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
10
10
  import { css, jsx } from '@emotion/react';
11
11
  import { layoutBreakpointWidth } from '@atlaskit/editor-shared-styles';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
12
13
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
13
14
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
14
15
  import { B200 } from '@atlaskit/theme/colors';
@@ -16,6 +17,7 @@ import { getNodeAnchor } from '../pm-plugins/decorations-common';
16
17
  import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
17
18
  import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
18
19
  import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
20
+ import { getInsertLayoutStep, updateSelection } from '../pm-plugins/utils/update-selection';
19
21
 
20
22
  // 8px gap + 16px on left and right
21
23
  var DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH = 40;
@@ -71,10 +73,32 @@ export var DropTargetLayout = function DropTargetLayout(props) {
71
73
  return;
72
74
  }
73
75
  var to = getPos();
76
+ var mappedTo;
74
77
  if (to !== undefined) {
75
- var _api$core, _api$blockControls2;
78
+ var _api$core;
76
79
  var from = activeNode.pos;
77
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.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(from, to));
80
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
81
+ var _api$blockControls2;
82
+ var tr = _ref2.tr;
83
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.moveToLayout(from, to)({
84
+ tr: tr
85
+ });
86
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
87
+ var insertColumnStep = getInsertLayoutStep(tr);
88
+ mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
89
+ }
90
+ return tr;
91
+ });
92
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
93
+ var _api$core2;
94
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
95
+ var tr = _ref3.tr;
96
+ if (mappedTo !== undefined) {
97
+ updateSelection(tr, mappedTo);
98
+ }
99
+ return tr;
100
+ });
101
+ }
78
102
  }
79
103
  }, [api, getPos, activeNode]);
80
104
  useEffect(function () {
@@ -11,6 +11,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
11
11
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
12
12
  import { css, jsx } from '@emotion/react';
13
13
  import { akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
14
+ import { fg } from '@atlaskit/platform-feature-flags';
14
15
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
15
16
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
16
17
  import { B200 } from '@atlaskit/theme/colors';
@@ -18,6 +19,7 @@ import { getNodeAnchor } from '../pm-plugins/decorations-common';
18
19
  import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
19
20
  import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
20
21
  import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
22
+ import { getInsertLayoutStep, updateSelection } from '../pm-plugins/utils/update-selection';
21
23
  var HOVER_ZONE_WIDTH = '--editor-blocks-inline-hover-zone-width';
22
24
  var HOVER_ZONE_HEIGHT = '--editor-blocks-inline-hover-zone-height';
23
25
  var HOVER_ZONE_TOP = '--editor-blocks-inline-hover-zone-top';
@@ -180,16 +182,39 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
180
182
  return;
181
183
  }
182
184
  var toPos = getPos();
185
+ var mappedTo;
183
186
  if (activeNode && toPos !== undefined) {
184
- var _api$core, _api$blockControls2;
187
+ var _api$core;
185
188
  var start = activeNode.pos;
186
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.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(start, toPos, {
187
- moveToEnd: position === 'right'
188
- }));
189
+ var moveToEnd = position === 'right';
190
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
191
+ var _api$blockControls2;
192
+ var tr = _ref3.tr;
193
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.moveToLayout(start, toPos, {
194
+ moveToEnd: moveToEnd
195
+ })({
196
+ tr: tr
197
+ });
198
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
199
+ var insertLayoutStep = getInsertLayoutStep(tr);
200
+ mappedTo = insertLayoutStep === null || insertLayoutStep === void 0 ? void 0 : insertLayoutStep.from;
201
+ }
202
+ return tr;
203
+ });
204
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
205
+ var _api$core2;
206
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref4) {
207
+ var tr = _ref4.tr;
208
+ if (mappedTo !== undefined) {
209
+ updateSelection(tr, mappedTo, moveToEnd);
210
+ }
211
+ return tr;
212
+ });
213
+ }
189
214
  }
190
215
  }, [api, getPos, position]);
191
216
  var hoverZoneRectStyle = useMemo(function () {
192
- var _ref3;
217
+ var _ref5;
193
218
  var isLayoutNode = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'layoutSection';
194
219
  var layoutAdjustment = isLayoutNode ? {
195
220
  width: 11,
@@ -197,7 +222,7 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
197
222
  top: 6,
198
223
  bottom: 2
199
224
  } : undefined;
200
- return _ref3 = {}, _defineProperty(_ref3, HOVER_ZONE_WIDTH, nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)")), _defineProperty(_ref3, HOVER_ZONE_HEIGHT, "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")), _defineProperty(_ref3, HOVER_ZONE_TOP, "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)")), _defineProperty(_ref3, HOVER_ZONE_BOTTOM, "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")), _defineProperty(_ref3, HOVER_ZONE_ANCHOR_NAME, anchorName), _ref3;
225
+ return _ref5 = {}, _defineProperty(_ref5, HOVER_ZONE_WIDTH, nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)")), _defineProperty(_ref5, HOVER_ZONE_HEIGHT, "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")), _defineProperty(_ref5, HOVER_ZONE_TOP, "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)")), _defineProperty(_ref5, HOVER_ZONE_BOTTOM, "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")), _defineProperty(_ref5, HOVER_ZONE_ANCHOR_NAME, anchorName), _ref5;
201
226
  }, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, nodeDimension, anchorName]);
202
227
  var dropIndicatorPos = useMemo(function () {
203
228
  return isLeftPosition ? 'right' : 'left';
@@ -0,0 +1,5 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import { type BlockControlsPlugin } from '../../blockControlsPluginType';
4
+ export declare const fireMoveNodeAnalytics: (tr: Transaction, inputMethod: string, fromDepth: number, fromNodeType: string, toDepth?: number, toNodeType?: string, isSameParent?: boolean, api?: ExtractInjectionAPI<BlockControlsPlugin>) => boolean | undefined;
5
+ export declare const fireInsertLayoutAnalytics: (tr: Transaction, api?: ExtractInjectionAPI<BlockControlsPlugin>) => void;
@@ -0,0 +1,3 @@
1
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ export declare const getInsertLayoutStep: (tr: Transaction) => import("prosemirror-transform").Step | undefined;
3
+ export declare const updateSelection: (tr: Transaction, to: number, insertAtRight?: boolean) => Transaction;
@@ -0,0 +1,5 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import { type BlockControlsPlugin } from '../../blockControlsPluginType';
4
+ export declare const fireMoveNodeAnalytics: (tr: Transaction, inputMethod: string, fromDepth: number, fromNodeType: string, toDepth?: number, toNodeType?: string, isSameParent?: boolean, api?: ExtractInjectionAPI<BlockControlsPlugin>) => boolean | undefined;
5
+ export declare const fireInsertLayoutAnalytics: (tr: Transaction, api?: ExtractInjectionAPI<BlockControlsPlugin>) => void;
@@ -0,0 +1,3 @@
1
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ export declare const getInsertLayoutStep: (tr: Transaction) => import("prosemirror-transform").Step | undefined;
3
+ export declare const updateSelection: (tr: Transaction, to: number, insertAtRight?: boolean) => Transaction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.14.1",
3
+ "version": "2.14.3",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,12 +31,12 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^46.1.0",
34
- "@atlaskit/editor-common": "^96.0.0",
34
+ "@atlaskit/editor-common": "^96.2.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",
38
38
  "@atlaskit/editor-plugin-feature-flags": "^1.2.0",
39
- "@atlaskit/editor-plugin-quick-insert": "^1.7.0",
39
+ "@atlaskit/editor-plugin-quick-insert": "^1.8.0",
40
40
  "@atlaskit/editor-plugin-width": "^1.3.0",
41
41
  "@atlaskit/editor-prosemirror": "6.2.1",
42
42
  "@atlaskit/editor-shared-styles": "^3.2.0",
@@ -44,11 +44,11 @@
44
44
  "@atlaskit/icon": "^23.0.0",
45
45
  "@atlaskit/platform-feature-flags": "^0.3.0",
46
46
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
47
- "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.0.0",
47
+ "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
48
48
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
49
49
  "@atlaskit/primitives": "^13.3.0",
50
50
  "@atlaskit/theme": "^14.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^2.22.0",
51
+ "@atlaskit/tmp-editor-statsig": "^2.23.0",
52
52
  "@atlaskit/tokens": "^2.4.0",
53
53
  "@atlaskit/tooltip": "^18.9.0",
54
54
  "@babel/runtime": "^7.0.0",
@@ -165,6 +165,9 @@
165
165
  },
166
166
  "platform_editor_use_nested_table_pm_nodes": {
167
167
  "type": "boolean"
168
+ },
169
+ "platform_editor_advanced_layouts_post_fix_patch_1": {
170
+ "type": "boolean"
168
171
  }
169
172
  }
170
173
  }