@atlaskit/editor-plugin-block-controls 2.7.0 → 2.8.0

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,21 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`ed73a2928e080`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ed73a2928e080) -
8
+ ED-25375 fix drop target v2 end position drop area
9
+
10
+ ## 2.7.1
11
+
12
+ ### Patch Changes
13
+
14
+ - [#153381](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/153381)
15
+ [`47cf4f0676e5a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/47cf4f0676e5a) -
16
+ ED-25040 setup feature flags and hooked up pre release-1
17
+ - Updated dependencies
18
+
3
19
  ## 2.7.0
4
20
 
5
21
  ### Minor Changes
@@ -48,6 +48,12 @@ var getNodeMargins = function getNodeMargins(node) {
48
48
  }
49
49
  return _consts.nodeMargins[nodeTypeName] || _consts.nodeMargins['default'];
50
50
  };
51
+ var shouldCollapseMargin = function shouldCollapseMargin(prevNode, nextNode) {
52
+ if (((prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) === 'mediaSingle' || (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'mediaSingle') && (prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) !== (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name)) {
53
+ return false;
54
+ }
55
+ return true;
56
+ };
51
57
  var getGapAndOffset = function getGapAndOffset(prevNode, nextNode, parentNode) {
52
58
  if (!prevNode && nextNode) {
53
59
  // first node
@@ -63,7 +69,7 @@ var getGapAndOffset = function getGapAndOffset(prevNode, nextNode, parentNode) {
63
69
  }
64
70
  var top = getNodeMargins(nextNode).top || 4;
65
71
  var bottom = getNodeMargins(prevNode).bottom || 4;
66
- var gap = Math.max(top, bottom);
72
+ var gap = shouldCollapseMargin(prevNode, nextNode) ? Math.max(top, bottom) : top + bottom;
67
73
  var offset = top - gap / 2;
68
74
  if ((prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) === 'mediaSingle' && (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'mediaSingle') {
69
75
  offset = -offset;
@@ -140,8 +146,7 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
140
146
  offset = _getGapAndOffset.offset;
141
147
  element.style.setProperty(_dropTargetV.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, "".concat(offset, "px"));
142
148
  element.style.setProperty(_dropTargetV.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, "".concat(gap, "px"));
143
- }
144
- if ((0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2')) {
149
+ element.style.setProperty('display', 'block');
145
150
  _reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTargetV.DropTargetV2, _objectSpread(_objectSpread({}, props), {}, {
146
151
  getPos: getPos,
147
152
  anchorRectCache: anchorRectCache
@@ -221,16 +226,14 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
221
226
 
222
227
  // only table and layout need to render full height drop target
223
228
  var isInSupportedContainer = (0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2') && ['tableCell', 'tableHeader', 'layoutColumn'].includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '');
224
-
225
- // container with only an empty paragrah
226
- var shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && (parent === null || parent === void 0 ? void 0 : parent.childCount) === 1 && (0, _utils.isEmptyParagraph)(node) && (0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2');
229
+ var shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && (0, _utils.isEmptyParagraph)(node);
227
230
  decs.push(createDropTargetDecoration(pos, {
228
231
  api: api,
229
232
  prevNode: previousNode,
230
233
  nextNode: node,
231
234
  parentNode: parent || undefined,
232
235
  formatMessage: formatMessage,
233
- dropTargetStyle: shouldShowFullHeight ? 'fullHeight' : 'default'
236
+ dropTargetStyle: shouldShowFullHeight ? 'remainingHeight' : 'default'
234
237
  }, -1, anchorRectCache));
235
238
  if (endPos !== undefined) {
236
239
  decs.push(createDropTargetDecoration(endPos, {
@@ -238,7 +241,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
238
241
  prevNode: (0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2') ? node : undefined,
239
242
  parentNode: parent || undefined,
240
243
  formatMessage: formatMessage,
241
- dropTargetStyle: isInSupportedContainer ? 'fullHeight' : 'default'
244
+ dropTargetStyle: 'remainingHeight'
242
245
  }, -1, anchorRectCache));
243
246
  }
244
247
  if ((0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2')) {
@@ -162,6 +162,10 @@ var nodeMargins = exports.nodeMargins = {
162
162
  top: 8,
163
163
  bottom: 0
164
164
  },
165
+ blockquote: {
166
+ top: 12,
167
+ bottom: 0
168
+ },
165
169
  default: {
166
170
  top: 0,
167
171
  bottom: 0
@@ -65,12 +65,6 @@ var nestedDropZoneStyle = (0, _react2.css)({
65
65
  width: 'unset'
66
66
  });
67
67
  var enableDropZone = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard'];
68
- var fullHeightStyle = (0, _react2.css)({
69
- top: '4px',
70
- bottom: '4px',
71
- height: 'unset',
72
- zIndex: 10
73
- });
74
68
 
75
69
  // This z index is used in container like layout
76
70
  var fullHeightStyleAdjustZIndexStyle = (0, _react2.css)({
@@ -98,6 +92,7 @@ var HoverZone = function HoverZone(_ref) {
98
92
  });
99
93
  }
100
94
  }, [onDragEnter, onDragLeave, onDrop]);
95
+ var isRemainingheight = dropTargetStyle === 'remainingHeight';
101
96
  var hoverZoneUpperStyle = (0, _react.useMemo)(function () {
102
97
  var anchorName = node ? (0, _decorations.getNodeAnchor)(node) : '';
103
98
  var heightStyleOffset = "var(--editor-block-controls-drop-indicator-gap, 0)/2";
@@ -113,12 +108,47 @@ var HoverZone = function HoverZone(_ref) {
113
108
  maxWidth: "".concat(editorWidth || 0, "px")
114
109
  });
115
110
  }, [anchorRectCache, editorWidth, node, position]);
116
- var isFullHeight = (0, _react.useMemo)(function () {
117
- return dropTargetStyle === 'fullHeight';
118
- }, [dropTargetStyle]);
119
- var isFullHeightInLayout = (0, _react.useMemo)(function () {
120
- return isFullHeight && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutColumn';
121
- }, [isFullHeight, parent === null || parent === void 0 ? void 0 : parent.type.name]);
111
+
112
+ /**
113
+ * 1. Above the last empty line
114
+ * 2. Below the last element
115
+ *
116
+ * Both cases will take the remaining height of the the container
117
+ */
118
+ var heightStyle = (0, _react.useMemo)(function () {
119
+ // only apply upper drop zone
120
+ if (isRemainingheight && position === 'upper') {
121
+ // previous node
122
+ var anchorName = node ? (0, _decorations.getNodeAnchor)(node) : '';
123
+ var top = 'unset';
124
+ if (anchorName) {
125
+ var enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
126
+ if ((0, _anchorUtils.isAnchorSupported)()) {
127
+ top = enabledDropZone ? "calc(anchor(".concat(anchorName, " 50%))") : "calc(anchor(".concat(anchorName, " bottom) - 4px)");
128
+ } else if (anchorRectCache) {
129
+ var preNodeTopPos = anchorRectCache.getTop(anchorName) || 0;
130
+ var prevNodeHeight = anchorRectCache.getHeight(anchorName) || 0;
131
+ top = enabledDropZone ? "calc(".concat(preNodeTopPos, "px + ").concat(prevNodeHeight / 2, "px)") : "calc(".concat(preNodeTopPos, "px + ").concat(prevNodeHeight, "px - 4px)");
132
+ } else {
133
+ // Should not happen
134
+ return null;
135
+ }
136
+ } else {
137
+ // first empty paragraph
138
+ top = '4px';
139
+ }
140
+ return (0, _react2.css)({
141
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
142
+ top: top,
143
+ bottom: '4px',
144
+ height: 'unset',
145
+ zIndex: 10,
146
+ transform: 'none'
147
+ });
148
+ }
149
+ return null;
150
+ }, [anchorRectCache, isRemainingheight, node, position]);
151
+ var isFullHeightInLayout = isRemainingheight && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutColumn';
122
152
  return (0, _react2.jsx)("div", {
123
153
  ref: ref
124
154
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -129,7 +159,9 @@ var HoverZone = function HoverZone(_ref) {
129
159
  ,
130
160
  css: [dropZoneStyles, isNestedDropTarget && nestedDropZoneStyle,
131
161
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
132
- hoverZoneUpperStyle, isFullHeight && fullHeightStyle, isFullHeightInLayout && fullHeightStyleAdjustZIndexStyle]
162
+ hoverZoneUpperStyle,
163
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
164
+ heightStyle, isFullHeightInLayout && fullHeightStyleAdjustZIndexStyle]
133
165
  });
134
166
  };
135
167
  var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(props) {
@@ -141,7 +173,8 @@ var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(props) {
141
173
  parentNode = props.parentNode,
142
174
  formatMessage = props.formatMessage,
143
175
  anchorRectCache = props.anchorRectCache,
144
- dropTargetStyle = props.dropTargetStyle;
176
+ _props$dropTargetStyl = props.dropTargetStyle,
177
+ dropTargetStyle = _props$dropTargetStyl === void 0 ? 'default' : _props$dropTargetStyl;
145
178
  var _useState = (0, _react.useState)(false),
146
179
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
147
180
  isDraggedOver = _useState2[0],
@@ -163,11 +196,10 @@ var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(props) {
163
196
  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.moveNode(start, pos, undefined, formatMessage));
164
197
  }
165
198
  };
166
- var isFullHeight = dropTargetStyle === 'fullHeight';
167
199
  var dynamicStyle = (_dynamicStyle = {
168
200
  width: isNestedDropTarget ? 'unset' : '100%'
169
201
  }, (0, _defineProperty2.default)(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), (0, _defineProperty2.default)(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? (0, _consts.getNestedNodeLeftPaddingMargin)(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), (0, _defineProperty2.default)(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, (0, _experiments.editorExperiment)('nested-dnd', true) ? _constants.layers.navigation() : _constants.layers.card()), _dynamicStyle);
170
- return (0, _react2.jsx)(_react.Fragment, null, !isFullHeight && (0, _react2.jsx)(HoverZone, {
202
+ return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(HoverZone, {
171
203
  onDragEnter: function onDragEnter() {
172
204
  return setIsDraggedOver(true);
173
205
  },
@@ -179,7 +211,8 @@ var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(props) {
179
211
  editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
180
212
  anchorRectCache: anchorRectCache,
181
213
  position: "upper",
182
- isNestedDropTarget: isNestedDropTarget
214
+ isNestedDropTarget: isNestedDropTarget,
215
+ dropTargetStyle: dropTargetStyle
183
216
  }), (0, _react2.jsx)("div", {
184
217
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
185
218
  css: [styleDropTarget, isNestedDropTarget && nestedDropIndicatorStyle]
@@ -194,7 +227,7 @@ var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(props) {
194
227
  "data-testid": "block-ctrl-drop-indicator"
195
228
  }, (0, _react2.jsx)(_box.DropIndicator, {
196
229
  edge: "bottom"
197
- }))), (0, _react2.jsx)(HoverZone, {
230
+ }))), dropTargetStyle !== 'remainingHeight' && (0, _react2.jsx)(HoverZone, {
198
231
  onDragEnter: function onDragEnter() {
199
232
  return setIsDraggedOver(true);
200
233
  },
@@ -207,8 +240,7 @@ var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(props) {
207
240
  editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
208
241
  anchorRectCache: anchorRectCache,
209
242
  position: "lower",
210
- isNestedDropTarget: isNestedDropTarget,
211
- dropTargetStyle: dropTargetStyle
243
+ isNestedDropTarget: isNestedDropTarget
212
244
  }), (0, _inlineDropTarget.shouldAllowInlineDropTarget)(isNestedDropTarget, nextNode) && (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget, (0, _extends2.default)({}, props, {
213
245
  position: "left"
214
246
  })), (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget, (0, _extends2.default)({}, props, {
@@ -44,7 +44,8 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
44
44
  var api = _ref.api,
45
45
  nextNode = _ref.nextNode,
46
46
  position = _ref.position,
47
- anchorRectCache = _ref.anchorRectCache;
47
+ anchorRectCache = _ref.anchorRectCache,
48
+ getPos = _ref.getPos;
48
49
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width']),
49
50
  widthState = _useSharedPluginState.widthState;
50
51
  var _useState = (0, _react.useState)(false),
@@ -74,6 +75,20 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
74
75
  top: "".concat((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.top) || 0, "px")
75
76
  });
76
77
  }, [anchorName, anchorRectCache, position]);
78
+ var onDrop = (0, _react.useCallback)(function () {
79
+ var _api$blockControls;
80
+ var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
81
+ activeNode = _ref2.activeNode;
82
+ if (!activeNode) {
83
+ return;
84
+ }
85
+ var toPos = getPos();
86
+ if (activeNode && toPos !== undefined) {
87
+ var _api$core, _api$blockControls2;
88
+ var start = activeNode.pos;
89
+ 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, position));
90
+ }
91
+ }, [api, getPos, position]);
77
92
  return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)("div", {
78
93
  "data-test-id": "block-ctrl-drop-target-".concat(position),
79
94
  css: [dropTargetCommonStyle, dropTargetRectStyle, !isDraggedOver && hideDropTargetStyle]
@@ -86,20 +101,20 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
86
101
  anchorRectCache: anchorRectCache,
87
102
  onDragEnter: handleDragEnter,
88
103
  onDragLeave: handleDragLeave,
89
- onDrop: function onDrop() {}
104
+ onDrop: onDrop
90
105
  }));
91
106
  };
92
- var InlineHoverZone = exports.InlineHoverZone = function InlineHoverZone(_ref2) {
93
- var node = _ref2.node,
94
- editorWidthState = _ref2.editorWidthState,
95
- anchorRectCache = _ref2.anchorRectCache,
96
- position = _ref2.position,
97
- onDragEnter = _ref2.onDragEnter,
98
- onDragLeave = _ref2.onDragLeave,
99
- onDrop = _ref2.onDrop;
107
+ var InlineHoverZone = exports.InlineHoverZone = function InlineHoverZone(_ref3) {
108
+ var node = _ref3.node,
109
+ editorWidthState = _ref3.editorWidthState,
110
+ anchorRectCache = _ref3.anchorRectCache,
111
+ position = _ref3.position,
112
+ onDragEnter = _ref3.onDragEnter,
113
+ onDragLeave = _ref3.onDragLeave,
114
+ onDrop = _ref3.onDrop;
100
115
  var ref = (0, _react.useRef)(null);
101
- var _ref3 = editorWidthState || {},
102
- editorWith = _ref3.width;
116
+ var _ref4 = editorWidthState || {},
117
+ editorWith = _ref4.width;
103
118
  var anchorName = node ? (0, _decorations.getNodeAnchor)(node) : '';
104
119
  (0, _react.useEffect)(function () {
105
120
  if (ref.current) {
@@ -3,9 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isPreRelease1 = void 0;
6
+ exports.isPreRelease2 = exports.isPreRelease1 = void 0;
7
7
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
8
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
9
+ // When we turn on re-release 2, will also turn on pre-release 1
10
+ // but not vice-versa
9
11
  var isPreRelease1 = exports.isPreRelease1 = function isPreRelease1() {
10
- return (0, _experiments.editorExperiment)('advanced_layouts', true) || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_1');
12
+ return (0, _experiments.editorExperiment)('advanced_layouts', true) || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_1') || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_2');
13
+ };
14
+ var isPreRelease2 = exports.isPreRelease2 = function isPreRelease2() {
15
+ return (0, _experiments.editorExperiment)('advanced_layouts', true) || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_2');
11
16
  };
@@ -35,6 +35,12 @@ const getNodeMargins = node => {
35
35
  }
36
36
  return nodeMargins[nodeTypeName] || nodeMargins['default'];
37
37
  };
38
+ const shouldCollapseMargin = (prevNode, nextNode) => {
39
+ if (((prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) === 'mediaSingle' || (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'mediaSingle') && (prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) !== (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name)) {
40
+ return false;
41
+ }
42
+ return true;
43
+ };
38
44
  const getGapAndOffset = (prevNode, nextNode, parentNode) => {
39
45
  if (!prevNode && nextNode) {
40
46
  // first node
@@ -50,7 +56,7 @@ const getGapAndOffset = (prevNode, nextNode, parentNode) => {
50
56
  }
51
57
  const top = getNodeMargins(nextNode).top || 4;
52
58
  const bottom = getNodeMargins(prevNode).bottom || 4;
53
- const gap = Math.max(top, bottom);
59
+ const gap = shouldCollapseMargin(prevNode, nextNode) ? Math.max(top, bottom) : top + bottom;
54
60
  let offset = top - gap / 2;
55
61
  if ((prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) === 'mediaSingle' && (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'mediaSingle') {
56
62
  offset = -offset;
@@ -122,8 +128,7 @@ export const createDropTargetDecoration = (pos, props, side, anchorRectCache) =>
122
128
  } = getGapAndOffset(props.prevNode, props.nextNode, props.parentNode);
123
129
  element.style.setProperty(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, `${offset}px`);
124
130
  element.style.setProperty(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, `${gap}px`);
125
- }
126
- if (fg('platform_editor_drag_and_drop_target_v2')) {
131
+ element.style.setProperty('display', 'block');
127
132
  ReactDOM.render( /*#__PURE__*/createElement(DropTargetV2, {
128
133
  ...props,
129
134
  getPos,
@@ -205,16 +210,14 @@ export const dropTargetDecorations = (newState, api, formatMessage, activeNode,
205
210
 
206
211
  // only table and layout need to render full height drop target
207
212
  const isInSupportedContainer = fg('platform_editor_drag_and_drop_target_v2') && ['tableCell', 'tableHeader', 'layoutColumn'].includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '');
208
-
209
- // container with only an empty paragrah
210
- const shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && (parent === null || parent === void 0 ? void 0 : parent.childCount) === 1 && isEmptyParagraph(node) && fg('platform_editor_drag_and_drop_target_v2');
213
+ const shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && isEmptyParagraph(node);
211
214
  decs.push(createDropTargetDecoration(pos, {
212
215
  api,
213
216
  prevNode: previousNode,
214
217
  nextNode: node,
215
218
  parentNode: parent || undefined,
216
219
  formatMessage,
217
- dropTargetStyle: shouldShowFullHeight ? 'fullHeight' : 'default'
220
+ dropTargetStyle: shouldShowFullHeight ? 'remainingHeight' : 'default'
218
221
  }, -1, anchorRectCache));
219
222
  if (endPos !== undefined) {
220
223
  decs.push(createDropTargetDecoration(endPos, {
@@ -222,7 +225,7 @@ export const dropTargetDecorations = (newState, api, formatMessage, activeNode,
222
225
  prevNode: fg('platform_editor_drag_and_drop_target_v2') ? node : undefined,
223
226
  parentNode: parent || undefined,
224
227
  formatMessage,
225
- dropTargetStyle: isInSupportedContainer ? 'fullHeight' : 'default'
228
+ dropTargetStyle: 'remainingHeight'
226
229
  }, -1, anchorRectCache));
227
230
  }
228
231
  if (fg('platform_editor_drag_and_drop_target_v2')) {
@@ -171,6 +171,10 @@ export const nodeMargins = {
171
171
  top: 8,
172
172
  bottom: 0
173
173
  },
174
+ blockquote: {
175
+ top: 12,
176
+ bottom: 0
177
+ },
174
178
  default: {
175
179
  top: 0,
176
180
  bottom: 0
@@ -55,12 +55,6 @@ const nestedDropZoneStyle = css({
55
55
  width: 'unset'
56
56
  });
57
57
  const enableDropZone = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard'];
58
- const fullHeightStyle = css({
59
- top: '4px',
60
- bottom: '4px',
61
- height: 'unset',
62
- zIndex: 10
63
- });
64
58
 
65
59
  // This z index is used in container like layout
66
60
  const fullHeightStyleAdjustZIndexStyle = css({
@@ -89,6 +83,7 @@ const HoverZone = ({
89
83
  });
90
84
  }
91
85
  }, [onDragEnter, onDragLeave, onDrop]);
86
+ const isRemainingheight = dropTargetStyle === 'remainingHeight';
92
87
  const hoverZoneUpperStyle = useMemo(() => {
93
88
  const anchorName = node ? getNodeAnchor(node) : '';
94
89
  const heightStyleOffset = `var(--editor-block-controls-drop-indicator-gap, 0)/2`;
@@ -104,12 +99,47 @@ const HoverZone = ({
104
99
  maxWidth: `${editorWidth || 0}px`
105
100
  });
106
101
  }, [anchorRectCache, editorWidth, node, position]);
107
- const isFullHeight = useMemo(() => {
108
- return dropTargetStyle === 'fullHeight';
109
- }, [dropTargetStyle]);
110
- const isFullHeightInLayout = useMemo(() => {
111
- return isFullHeight && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutColumn';
112
- }, [isFullHeight, parent === null || parent === void 0 ? void 0 : parent.type.name]);
102
+
103
+ /**
104
+ * 1. Above the last empty line
105
+ * 2. Below the last element
106
+ *
107
+ * Both cases will take the remaining height of the the container
108
+ */
109
+ const heightStyle = useMemo(() => {
110
+ // only apply upper drop zone
111
+ if (isRemainingheight && position === 'upper') {
112
+ // previous node
113
+ const anchorName = node ? getNodeAnchor(node) : '';
114
+ let top = 'unset';
115
+ if (anchorName) {
116
+ const enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
117
+ if (isAnchorSupported()) {
118
+ top = enabledDropZone ? `calc(anchor(${anchorName} 50%))` : `calc(anchor(${anchorName} bottom) - 4px)`;
119
+ } else if (anchorRectCache) {
120
+ const preNodeTopPos = anchorRectCache.getTop(anchorName) || 0;
121
+ const prevNodeHeight = anchorRectCache.getHeight(anchorName) || 0;
122
+ top = enabledDropZone ? `calc(${preNodeTopPos}px + ${prevNodeHeight / 2}px)` : `calc(${preNodeTopPos}px + ${prevNodeHeight}px - 4px)`;
123
+ } else {
124
+ // Should not happen
125
+ return null;
126
+ }
127
+ } else {
128
+ // first empty paragraph
129
+ top = '4px';
130
+ }
131
+ return css({
132
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
133
+ top: top,
134
+ bottom: '4px',
135
+ height: 'unset',
136
+ zIndex: 10,
137
+ transform: 'none'
138
+ });
139
+ }
140
+ return null;
141
+ }, [anchorRectCache, isRemainingheight, node, position]);
142
+ const isFullHeightInLayout = isRemainingheight && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutColumn';
113
143
  return jsx("div", {
114
144
  ref: ref
115
145
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -120,7 +150,9 @@ const HoverZone = ({
120
150
  ,
121
151
  css: [dropZoneStyles, isNestedDropTarget && nestedDropZoneStyle,
122
152
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
123
- hoverZoneUpperStyle, isFullHeight && fullHeightStyle, isFullHeightInLayout && fullHeightStyleAdjustZIndexStyle]
153
+ hoverZoneUpperStyle,
154
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
155
+ heightStyle, isFullHeightInLayout && fullHeightStyleAdjustZIndexStyle]
124
156
  });
125
157
  };
126
158
  export const DropTargetV2 = props => {
@@ -132,7 +164,7 @@ export const DropTargetV2 = props => {
132
164
  parentNode,
133
165
  formatMessage,
134
166
  anchorRectCache,
135
- dropTargetStyle
167
+ dropTargetStyle = 'default'
136
168
  } = props;
137
169
  const [isDraggedOver, setIsDraggedOver] = useState(false);
138
170
  const {
@@ -156,14 +188,13 @@ export const DropTargetV2 = props => {
156
188
  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.moveNode(start, pos, undefined, formatMessage));
157
189
  }
158
190
  };
159
- const isFullHeight = dropTargetStyle === 'fullHeight';
160
191
  const dynamicStyle = {
161
192
  width: isNestedDropTarget ? 'unset' : '100%',
162
193
  [EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH]: isNestedDropTarget ? '100%' : `${(widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH}px`,
163
194
  [EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN]: isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0',
164
195
  [EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX]: editorExperiment('nested-dnd', true) ? layers.navigation() : layers.card()
165
196
  };
166
- return jsx(Fragment, null, !isFullHeight && jsx(HoverZone, {
197
+ return jsx(Fragment, null, jsx(HoverZone, {
167
198
  onDragEnter: () => setIsDraggedOver(true),
168
199
  onDragLeave: () => setIsDraggedOver(false),
169
200
  onDrop: onDrop,
@@ -171,7 +202,8 @@ export const DropTargetV2 = props => {
171
202
  editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
172
203
  anchorRectCache: anchorRectCache,
173
204
  position: "upper",
174
- isNestedDropTarget: isNestedDropTarget
205
+ isNestedDropTarget: isNestedDropTarget,
206
+ dropTargetStyle: dropTargetStyle
175
207
  }), jsx("div", {
176
208
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
177
209
  css: [styleDropTarget, isNestedDropTarget && nestedDropIndicatorStyle]
@@ -186,7 +218,7 @@ export const DropTargetV2 = props => {
186
218
  "data-testid": "block-ctrl-drop-indicator"
187
219
  }, jsx(DropIndicator, {
188
220
  edge: "bottom"
189
- }))), jsx(HoverZone, {
221
+ }))), dropTargetStyle !== 'remainingHeight' && jsx(HoverZone, {
190
222
  onDragEnter: () => setIsDraggedOver(true),
191
223
  onDragLeave: () => setIsDraggedOver(false),
192
224
  onDrop: onDrop,
@@ -195,8 +227,7 @@ export const DropTargetV2 = props => {
195
227
  editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
196
228
  anchorRectCache: anchorRectCache,
197
229
  position: "lower",
198
- isNestedDropTarget: isNestedDropTarget,
199
- dropTargetStyle: dropTargetStyle
230
+ isNestedDropTarget: isNestedDropTarget
200
231
  }), shouldAllowInlineDropTarget(isNestedDropTarget, nextNode) && jsx(Fragment, null, jsx(InlineDropTarget, _extends({}, props, {
201
232
  position: "left"
202
233
  })), jsx(InlineDropTarget, _extends({}, props, {
@@ -35,7 +35,8 @@ export const InlineDropTarget = ({
35
35
  api,
36
36
  nextNode,
37
37
  position,
38
- anchorRectCache
38
+ anchorRectCache,
39
+ getPos
39
40
  }) => {
40
41
  const {
41
42
  widthState
@@ -64,6 +65,23 @@ export const InlineDropTarget = ({
64
65
  top: `${(nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.top) || 0}px`
65
66
  });
66
67
  }, [anchorName, anchorRectCache, position]);
68
+ const onDrop = useCallback(() => {
69
+ var _api$blockControls;
70
+ const {
71
+ activeNode
72
+ } = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
73
+ if (!activeNode) {
74
+ return;
75
+ }
76
+ const toPos = getPos();
77
+ if (activeNode && toPos !== undefined) {
78
+ var _api$core, _api$blockControls2, _api$blockControls2$c;
79
+ const {
80
+ pos: start
81
+ } = activeNode;
82
+ 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, position));
83
+ }
84
+ }, [api, getPos, position]);
67
85
  return jsx(Fragment, null, jsx("div", {
68
86
  "data-test-id": `block-ctrl-drop-target-${position}`,
69
87
  css: [dropTargetCommonStyle, dropTargetRectStyle, !isDraggedOver && hideDropTargetStyle]
@@ -76,7 +94,7 @@ export const InlineDropTarget = ({
76
94
  anchorRectCache: anchorRectCache,
77
95
  onDragEnter: handleDragEnter,
78
96
  onDragLeave: handleDragLeave,
79
- onDrop: () => {}
97
+ onDrop: onDrop
80
98
  }));
81
99
  };
82
100
  export const InlineHoverZone = ({
@@ -1,5 +1,11 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
2
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
+
4
+ // When we turn on re-release 2, will also turn on pre-release 1
5
+ // but not vice-versa
3
6
  export const isPreRelease1 = () => {
4
- return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_1');
7
+ return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_1') || fg('platform_editor_advanced_layouts_pre_release_2');
8
+ };
9
+ export const isPreRelease2 = () => {
10
+ return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_2');
5
11
  };
@@ -41,6 +41,12 @@ var getNodeMargins = function getNodeMargins(node) {
41
41
  }
42
42
  return nodeMargins[nodeTypeName] || nodeMargins['default'];
43
43
  };
44
+ var shouldCollapseMargin = function shouldCollapseMargin(prevNode, nextNode) {
45
+ if (((prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) === 'mediaSingle' || (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'mediaSingle') && (prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) !== (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name)) {
46
+ return false;
47
+ }
48
+ return true;
49
+ };
44
50
  var getGapAndOffset = function getGapAndOffset(prevNode, nextNode, parentNode) {
45
51
  if (!prevNode && nextNode) {
46
52
  // first node
@@ -56,7 +62,7 @@ var getGapAndOffset = function getGapAndOffset(prevNode, nextNode, parentNode) {
56
62
  }
57
63
  var top = getNodeMargins(nextNode).top || 4;
58
64
  var bottom = getNodeMargins(prevNode).bottom || 4;
59
- var gap = Math.max(top, bottom);
65
+ var gap = shouldCollapseMargin(prevNode, nextNode) ? Math.max(top, bottom) : top + bottom;
60
66
  var offset = top - gap / 2;
61
67
  if ((prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) === 'mediaSingle' && (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'mediaSingle') {
62
68
  offset = -offset;
@@ -133,8 +139,7 @@ export var createDropTargetDecoration = function createDropTargetDecoration(pos,
133
139
  offset = _getGapAndOffset.offset;
134
140
  element.style.setProperty(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, "".concat(offset, "px"));
135
141
  element.style.setProperty(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, "".concat(gap, "px"));
136
- }
137
- if (fg('platform_editor_drag_and_drop_target_v2')) {
142
+ element.style.setProperty('display', 'block');
138
143
  ReactDOM.render( /*#__PURE__*/createElement(DropTargetV2, _objectSpread(_objectSpread({}, props), {}, {
139
144
  getPos: getPos,
140
145
  anchorRectCache: anchorRectCache
@@ -214,16 +219,14 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
214
219
 
215
220
  // only table and layout need to render full height drop target
216
221
  var isInSupportedContainer = fg('platform_editor_drag_and_drop_target_v2') && ['tableCell', 'tableHeader', 'layoutColumn'].includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '');
217
-
218
- // container with only an empty paragrah
219
- var shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && (parent === null || parent === void 0 ? void 0 : parent.childCount) === 1 && isEmptyParagraph(node) && fg('platform_editor_drag_and_drop_target_v2');
222
+ var shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && isEmptyParagraph(node);
220
223
  decs.push(createDropTargetDecoration(pos, {
221
224
  api: api,
222
225
  prevNode: previousNode,
223
226
  nextNode: node,
224
227
  parentNode: parent || undefined,
225
228
  formatMessage: formatMessage,
226
- dropTargetStyle: shouldShowFullHeight ? 'fullHeight' : 'default'
229
+ dropTargetStyle: shouldShowFullHeight ? 'remainingHeight' : 'default'
227
230
  }, -1, anchorRectCache));
228
231
  if (endPos !== undefined) {
229
232
  decs.push(createDropTargetDecoration(endPos, {
@@ -231,7 +234,7 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
231
234
  prevNode: fg('platform_editor_drag_and_drop_target_v2') ? node : undefined,
232
235
  parentNode: parent || undefined,
233
236
  formatMessage: formatMessage,
234
- dropTargetStyle: isInSupportedContainer ? 'fullHeight' : 'default'
237
+ dropTargetStyle: 'remainingHeight'
235
238
  }, -1, anchorRectCache));
236
239
  }
237
240
  if (fg('platform_editor_drag_and_drop_target_v2')) {
@@ -155,6 +155,10 @@ export var nodeMargins = {
155
155
  top: 8,
156
156
  bottom: 0
157
157
  },
158
+ blockquote: {
159
+ top: 12,
160
+ bottom: 0
161
+ },
158
162
  default: {
159
163
  top: 0,
160
164
  bottom: 0
@@ -57,12 +57,6 @@ var nestedDropZoneStyle = css({
57
57
  width: 'unset'
58
58
  });
59
59
  var enableDropZone = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard'];
60
- var fullHeightStyle = css({
61
- top: '4px',
62
- bottom: '4px',
63
- height: 'unset',
64
- zIndex: 10
65
- });
66
60
 
67
61
  // This z index is used in container like layout
68
62
  var fullHeightStyleAdjustZIndexStyle = css({
@@ -90,6 +84,7 @@ var HoverZone = function HoverZone(_ref) {
90
84
  });
91
85
  }
92
86
  }, [onDragEnter, onDragLeave, onDrop]);
87
+ var isRemainingheight = dropTargetStyle === 'remainingHeight';
93
88
  var hoverZoneUpperStyle = useMemo(function () {
94
89
  var anchorName = node ? getNodeAnchor(node) : '';
95
90
  var heightStyleOffset = "var(--editor-block-controls-drop-indicator-gap, 0)/2";
@@ -105,12 +100,47 @@ var HoverZone = function HoverZone(_ref) {
105
100
  maxWidth: "".concat(editorWidth || 0, "px")
106
101
  });
107
102
  }, [anchorRectCache, editorWidth, node, position]);
108
- var isFullHeight = useMemo(function () {
109
- return dropTargetStyle === 'fullHeight';
110
- }, [dropTargetStyle]);
111
- var isFullHeightInLayout = useMemo(function () {
112
- return isFullHeight && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutColumn';
113
- }, [isFullHeight, parent === null || parent === void 0 ? void 0 : parent.type.name]);
103
+
104
+ /**
105
+ * 1. Above the last empty line
106
+ * 2. Below the last element
107
+ *
108
+ * Both cases will take the remaining height of the the container
109
+ */
110
+ var heightStyle = useMemo(function () {
111
+ // only apply upper drop zone
112
+ if (isRemainingheight && position === 'upper') {
113
+ // previous node
114
+ var anchorName = node ? getNodeAnchor(node) : '';
115
+ var top = 'unset';
116
+ if (anchorName) {
117
+ var enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
118
+ if (isAnchorSupported()) {
119
+ top = enabledDropZone ? "calc(anchor(".concat(anchorName, " 50%))") : "calc(anchor(".concat(anchorName, " bottom) - 4px)");
120
+ } else if (anchorRectCache) {
121
+ var preNodeTopPos = anchorRectCache.getTop(anchorName) || 0;
122
+ var prevNodeHeight = anchorRectCache.getHeight(anchorName) || 0;
123
+ top = enabledDropZone ? "calc(".concat(preNodeTopPos, "px + ").concat(prevNodeHeight / 2, "px)") : "calc(".concat(preNodeTopPos, "px + ").concat(prevNodeHeight, "px - 4px)");
124
+ } else {
125
+ // Should not happen
126
+ return null;
127
+ }
128
+ } else {
129
+ // first empty paragraph
130
+ top = '4px';
131
+ }
132
+ return css({
133
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
134
+ top: top,
135
+ bottom: '4px',
136
+ height: 'unset',
137
+ zIndex: 10,
138
+ transform: 'none'
139
+ });
140
+ }
141
+ return null;
142
+ }, [anchorRectCache, isRemainingheight, node, position]);
143
+ var isFullHeightInLayout = isRemainingheight && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutColumn';
114
144
  return jsx("div", {
115
145
  ref: ref
116
146
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -121,7 +151,9 @@ var HoverZone = function HoverZone(_ref) {
121
151
  ,
122
152
  css: [dropZoneStyles, isNestedDropTarget && nestedDropZoneStyle,
123
153
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
124
- hoverZoneUpperStyle, isFullHeight && fullHeightStyle, isFullHeightInLayout && fullHeightStyleAdjustZIndexStyle]
154
+ hoverZoneUpperStyle,
155
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
156
+ heightStyle, isFullHeightInLayout && fullHeightStyleAdjustZIndexStyle]
125
157
  });
126
158
  };
127
159
  export var DropTargetV2 = function DropTargetV2(props) {
@@ -133,7 +165,8 @@ export var DropTargetV2 = function DropTargetV2(props) {
133
165
  parentNode = props.parentNode,
134
166
  formatMessage = props.formatMessage,
135
167
  anchorRectCache = props.anchorRectCache,
136
- dropTargetStyle = props.dropTargetStyle;
168
+ _props$dropTargetStyl = props.dropTargetStyle,
169
+ dropTargetStyle = _props$dropTargetStyl === void 0 ? 'default' : _props$dropTargetStyl;
137
170
  var _useState = useState(false),
138
171
  _useState2 = _slicedToArray(_useState, 2),
139
172
  isDraggedOver = _useState2[0],
@@ -155,11 +188,10 @@ export var DropTargetV2 = function DropTargetV2(props) {
155
188
  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.moveNode(start, pos, undefined, formatMessage));
156
189
  }
157
190
  };
158
- var isFullHeight = dropTargetStyle === 'fullHeight';
159
191
  var dynamicStyle = (_dynamicStyle = {
160
192
  width: isNestedDropTarget ? 'unset' : '100%'
161
193
  }, _defineProperty(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), _defineProperty(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), _defineProperty(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, editorExperiment('nested-dnd', true) ? layers.navigation() : layers.card()), _dynamicStyle);
162
- return jsx(Fragment, null, !isFullHeight && jsx(HoverZone, {
194
+ return jsx(Fragment, null, jsx(HoverZone, {
163
195
  onDragEnter: function onDragEnter() {
164
196
  return setIsDraggedOver(true);
165
197
  },
@@ -171,7 +203,8 @@ export var DropTargetV2 = function DropTargetV2(props) {
171
203
  editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
172
204
  anchorRectCache: anchorRectCache,
173
205
  position: "upper",
174
- isNestedDropTarget: isNestedDropTarget
206
+ isNestedDropTarget: isNestedDropTarget,
207
+ dropTargetStyle: dropTargetStyle
175
208
  }), jsx("div", {
176
209
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
177
210
  css: [styleDropTarget, isNestedDropTarget && nestedDropIndicatorStyle]
@@ -186,7 +219,7 @@ export var DropTargetV2 = function DropTargetV2(props) {
186
219
  "data-testid": "block-ctrl-drop-indicator"
187
220
  }, jsx(DropIndicator, {
188
221
  edge: "bottom"
189
- }))), jsx(HoverZone, {
222
+ }))), dropTargetStyle !== 'remainingHeight' && jsx(HoverZone, {
190
223
  onDragEnter: function onDragEnter() {
191
224
  return setIsDraggedOver(true);
192
225
  },
@@ -199,8 +232,7 @@ export var DropTargetV2 = function DropTargetV2(props) {
199
232
  editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
200
233
  anchorRectCache: anchorRectCache,
201
234
  position: "lower",
202
- isNestedDropTarget: isNestedDropTarget,
203
- dropTargetStyle: dropTargetStyle
235
+ isNestedDropTarget: isNestedDropTarget
204
236
  }), shouldAllowInlineDropTarget(isNestedDropTarget, nextNode) && jsx(Fragment, null, jsx(InlineDropTarget, _extends({}, props, {
205
237
  position: "left"
206
238
  })), jsx(InlineDropTarget, _extends({}, props, {
@@ -36,7 +36,8 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
36
36
  var api = _ref.api,
37
37
  nextNode = _ref.nextNode,
38
38
  position = _ref.position,
39
- anchorRectCache = _ref.anchorRectCache;
39
+ anchorRectCache = _ref.anchorRectCache,
40
+ getPos = _ref.getPos;
40
41
  var _useSharedPluginState = useSharedPluginState(api, ['width']),
41
42
  widthState = _useSharedPluginState.widthState;
42
43
  var _useState = useState(false),
@@ -66,6 +67,20 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
66
67
  top: "".concat((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.top) || 0, "px")
67
68
  });
68
69
  }, [anchorName, anchorRectCache, position]);
70
+ var onDrop = useCallback(function () {
71
+ var _api$blockControls;
72
+ var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
73
+ activeNode = _ref2.activeNode;
74
+ if (!activeNode) {
75
+ return;
76
+ }
77
+ var toPos = getPos();
78
+ if (activeNode && toPos !== undefined) {
79
+ var _api$core, _api$blockControls2;
80
+ var start = activeNode.pos;
81
+ 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, position));
82
+ }
83
+ }, [api, getPos, position]);
69
84
  return jsx(Fragment, null, jsx("div", {
70
85
  "data-test-id": "block-ctrl-drop-target-".concat(position),
71
86
  css: [dropTargetCommonStyle, dropTargetRectStyle, !isDraggedOver && hideDropTargetStyle]
@@ -78,20 +93,20 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
78
93
  anchorRectCache: anchorRectCache,
79
94
  onDragEnter: handleDragEnter,
80
95
  onDragLeave: handleDragLeave,
81
- onDrop: function onDrop() {}
96
+ onDrop: onDrop
82
97
  }));
83
98
  };
84
- export var InlineHoverZone = function InlineHoverZone(_ref2) {
85
- var node = _ref2.node,
86
- editorWidthState = _ref2.editorWidthState,
87
- anchorRectCache = _ref2.anchorRectCache,
88
- position = _ref2.position,
89
- onDragEnter = _ref2.onDragEnter,
90
- onDragLeave = _ref2.onDragLeave,
91
- onDrop = _ref2.onDrop;
99
+ export var InlineHoverZone = function InlineHoverZone(_ref3) {
100
+ var node = _ref3.node,
101
+ editorWidthState = _ref3.editorWidthState,
102
+ anchorRectCache = _ref3.anchorRectCache,
103
+ position = _ref3.position,
104
+ onDragEnter = _ref3.onDragEnter,
105
+ onDragLeave = _ref3.onDragLeave,
106
+ onDrop = _ref3.onDrop;
92
107
  var ref = useRef(null);
93
- var _ref3 = editorWidthState || {},
94
- editorWith = _ref3.width;
108
+ var _ref4 = editorWidthState || {},
109
+ editorWith = _ref4.width;
95
110
  var anchorName = node ? getNodeAnchor(node) : '';
96
111
  useEffect(function () {
97
112
  if (ref.current) {
@@ -1,5 +1,11 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
2
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
+
4
+ // When we turn on re-release 2, will also turn on pre-release 1
5
+ // but not vice-versa
3
6
  export var isPreRelease1 = function isPreRelease1() {
4
- return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_1');
7
+ return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_1') || fg('platform_editor_advanced_layouts_pre_release_2');
8
+ };
9
+ export var isPreRelease2 = function isPreRelease2() {
10
+ return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_2');
5
11
  };
@@ -3,7 +3,7 @@ import { type IntlShape } from 'react-intl-next';
3
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { BlockControlsPlugin } from '../types';
6
- export type DropTargetStyle = 'default' | 'fullHeight';
6
+ export type DropTargetStyle = 'default' | 'remainingHeight';
7
7
  export type DropTargetProps = {
8
8
  api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
9
9
  getPos: () => number | undefined;
@@ -3,7 +3,7 @@ import { type EditorContainerWidth } from '@atlaskit/editor-common/src/types';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { type AnchorRectCache } from '../utils/anchor-utils';
5
5
  import { type DropTargetProps } from './drop-target';
6
- export declare const InlineDropTarget: ({ api, nextNode, position, anchorRectCache, }: DropTargetProps & {
6
+ export declare const InlineDropTarget: ({ api, nextNode, position, anchorRectCache, getPos, }: DropTargetProps & {
7
7
  anchorRectCache?: AnchorRectCache | undefined;
8
8
  position: 'left' | 'right';
9
9
  }) => jsx.JSX.Element;
@@ -1 +1,2 @@
1
1
  export declare const isPreRelease1: () => boolean;
2
+ export declare const isPreRelease2: () => boolean;
@@ -3,7 +3,7 @@ import { type IntlShape } from 'react-intl-next';
3
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { BlockControlsPlugin } from '../types';
6
- export type DropTargetStyle = 'default' | 'fullHeight';
6
+ export type DropTargetStyle = 'default' | 'remainingHeight';
7
7
  export type DropTargetProps = {
8
8
  api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
9
9
  getPos: () => number | undefined;
@@ -3,7 +3,7 @@ import { type EditorContainerWidth } from '@atlaskit/editor-common/src/types';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { type AnchorRectCache } from '../utils/anchor-utils';
5
5
  import { type DropTargetProps } from './drop-target';
6
- export declare const InlineDropTarget: ({ api, nextNode, position, anchorRectCache, }: DropTargetProps & {
6
+ export declare const InlineDropTarget: ({ api, nextNode, position, anchorRectCache, getPos, }: DropTargetProps & {
7
7
  anchorRectCache?: AnchorRectCache | undefined;
8
8
  position: 'left' | 'right';
9
9
  }) => jsx.JSX.Element;
@@ -1 +1,2 @@
1
1
  export declare const isPreRelease1: () => boolean;
2
+ export declare const isPreRelease2: () => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -47,7 +47,7 @@
47
47
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
48
48
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
49
49
  "@atlaskit/primitives": "^12.2.0",
50
- "@atlaskit/theme": "^13.1.0",
50
+ "@atlaskit/theme": "^14.0.0",
51
51
  "@atlaskit/tmp-editor-statsig": "^2.6.0",
52
52
  "@atlaskit/tokens": "^2.0.0",
53
53
  "@atlaskit/tooltip": "^18.8.0",
@@ -153,6 +153,9 @@
153
153
  },
154
154
  "platform_editor_advanced_layouts_pre_release_1": {
155
155
  "type": "boolean"
156
+ },
157
+ "platform_editor_advanced_layouts_pre_release_2": {
158
+ "type": "boolean"
156
159
  }
157
160
  }
158
161
  }